1 11 package org.eclipse.pde.internal.core.bundle; 12 13 import java.io.PrintWriter ; 14 import java.io.Serializable ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.core.runtime.Status; 19 import org.eclipse.pde.core.IModelChangeProvider; 20 import org.eclipse.pde.core.IModelChangedEvent; 21 import org.eclipse.pde.core.IWritable; 22 import org.eclipse.pde.core.ModelChangedEvent; 23 import org.eclipse.pde.internal.core.PDECore; 24 import org.eclipse.pde.internal.core.ibundle.IBundleModel; 25 import org.eclipse.pde.internal.core.plugin.IWritableDelimiter; 26 27 public class BundleObject implements Serializable , IWritable, IWritableDelimiter { 28 private static final long serialVersionUID = 1L; 29 30 private transient IBundleModel model; 31 32 public BundleObject() { 33 } 34 35 public IBundleModel getModel() { 36 return model; 37 } 38 public void setModel(IBundleModel newModel) { 39 model = newModel; 40 } 41 protected void throwCoreException(String message) throws CoreException { 42 Status status = 43 new Status( 44 IStatus.ERROR, 45 PDECore.PLUGIN_ID, 46 IStatus.OK, 47 message, 48 null); 49 throw new CoreException(status); 50 } 51 52 protected void fireStructureChanged(BundleObject[] children, int changeType) { 53 IModelChangedEvent e = new ModelChangedEvent( 54 model, 55 changeType, 56 children, 57 null); 58 fireModelChanged(e); 59 } 60 61 protected void fireStructureChanged(BundleObject child, int changeType) { 62 IModelChangedEvent e = new ModelChangedEvent( 63 model, 64 changeType, 65 new Object []{child}, 66 null); 67 fireModelChanged(e); 68 } 69 70 protected void fireModelChanged(IModelChangedEvent e) { 71 IModelChangeProvider provider = model; 72 provider.fireModelChanged(e); 73 } 74 75 protected void firePropertyChanged(BundleObject object, String property, 76 Object oldValue, Object newValue) { 77 IModelChangeProvider provider = model; 78 provider.fireModelObjectChanged(object, property, oldValue, newValue); 79 } 80 81 public void write(String indent, PrintWriter writer) { 82 writer.print(indent); 83 writer.print(toString()); 84 } 85 86 89 public void reconnect(IBundleModel model) { 90 this.model = model; 92 } 93 94 97 public void writeDelimeter(PrintWriter writer) { 98 writer.println(','); 99 writer.print(' '); 100 } 101 102 } 103 | Popular Tags |