1 11 package org.eclipse.pde.internal.core; 12 13 import org.eclipse.core.resources.IResource; 14 15 public abstract class AbstractNLModel extends AbstractModel { 16 protected transient NLResourceHelper fNLHelper; 17 18 public NLResourceHelper getNLResourceHelper() { 19 if (fNLHelper == null) 20 fNLHelper = createNLResourceHelper(); 21 return fNLHelper; 22 } 23 24 public void resetNLResourceHelper() { 25 fNLHelper = null; 26 } 27 28 public void dispose() { 29 if (fNLHelper != null) { 30 fNLHelper.dispose(); 31 fNLHelper = null; 32 } 33 super.dispose(); 34 } 35 36 public String getResourceString(String key) { 37 if (key == null) 38 return ""; 40 if (fNLHelper == null) 41 fNLHelper = createNLResourceHelper(); 42 43 return fNLHelper != null ? fNLHelper.getResourceString(key) : key; 44 } 45 46 protected abstract NLResourceHelper createNLResourceHelper(); 47 48 public Object getAdapter(Class adapter) { 49 if(adapter == IResource.class) { 50 IResource resource = getUnderlyingResource(); 51 return resource == null ? null : resource.getProject(); 52 } 53 return super.getAdapter(adapter); 54 } 55 56 } 57 | Popular Tags |