1 11 package org.eclipse.pde.internal.core.target; 12 13 import org.eclipse.core.runtime.PlatformObject; 14 import org.eclipse.pde.core.IModelChangeProvider; 15 import org.eclipse.pde.core.ModelChangedEvent; 16 import org.eclipse.pde.internal.core.itarget.ITarget; 17 import org.eclipse.pde.internal.core.itarget.ITargetModel; 18 import org.eclipse.pde.internal.core.itarget.ITargetObject; 19 import org.eclipse.pde.internal.core.util.PDEXMLHelper; 20 21 public abstract class TargetObject extends PlatformObject implements ITargetObject { 22 23 private transient ITargetModel fModel; 24 25 public TargetObject(ITargetModel model) { 26 fModel = model; 27 } 28 29 public ITargetModel getModel() { 30 return fModel; 31 } 32 33 public void setModel(ITargetModel model) { 34 fModel = model; 35 } 36 37 public ITarget getTarget() { 38 return getModel().getTarget(); 39 } 40 41 protected void firePropertyChanged(String property, Object oldValue, Object newValue) { 42 firePropertyChanged(this, property, oldValue, newValue); 43 } 44 45 protected void firePropertyChanged(ITargetObject object, String property, 46 Object oldValue, Object newValue) { 47 if (fModel.isEditable()) { 48 IModelChangeProvider provider = fModel; 49 provider.fireModelObjectChanged(object, property, oldValue, newValue); 50 } 51 } 52 53 protected void fireStructureChanged(ITargetObject child, int changeType) { 54 fireStructureChanged(new ITargetObject[] { child }, changeType); 55 } 56 57 protected void fireStructureChanged(ITargetObject[] children, int changeType) { 58 if (fModel.isEditable()) { 59 IModelChangeProvider provider = fModel; 60 provider.fireModelChanged(new ModelChangedEvent(provider, changeType, 61 children, null)); 62 } 63 } 64 65 protected boolean isEditable() { 66 return getModel().isEditable(); 67 } 68 69 public String getWritableString(String source) { 70 return PDEXMLHelper.getWritableString(source); 71 } 72 73 } 74 | Popular Tags |