1 11 package org.eclipse.pde.internal.core.text.plugin; 12 13 import java.util.ArrayList ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.pde.core.IModelChangedEvent; 17 import org.eclipse.pde.core.plugin.IPluginObject; 18 import org.eclipse.pde.core.plugin.IPluginParent; 19 import org.eclipse.pde.internal.core.text.IDocumentNode; 20 21 public class PluginParentNode extends PluginObjectNode implements IPluginParent { 22 23 private static final long serialVersionUID = 1L; 24 25 28 public void add(int index, IPluginObject child) throws CoreException { 29 addChildNode((IDocumentNode)child, index); 30 fireStructureChanged(child, IModelChangedEvent.INSERT); 31 } 32 35 public void add(IPluginObject child) throws CoreException { 36 add(getChildCount(), child); 37 child.setInTheModel(true); 38 ((PluginObjectNode)child).setModel(getModel()); 39 } 40 43 public int getChildCount() { 44 return getChildNodes().length; 45 } 46 49 public int getIndexOf(IPluginObject child) { 50 return indexOf((IDocumentNode)child); 51 } 52 55 public void swap(IPluginObject child1, IPluginObject child2) 56 throws CoreException { 57 swap((IDocumentNode)child1, (IDocumentNode)child2); 58 firePropertyChanged(this, P_SIBLING_ORDER, child1, child2); 59 } 60 63 public IPluginObject[] getChildren() { 64 ArrayList result = new ArrayList (); 65 IDocumentNode[] nodes = getChildNodes(); 66 for (int i = 0; i < nodes.length; i++) 67 result.add(nodes[i]); 68 69 return (IPluginObject[])result.toArray(new IPluginObject[result.size()]); 70 } 71 74 public void remove(IPluginObject child) throws CoreException { 75 removeChildNode((IDocumentNode)child); 76 child.setInTheModel(false); 77 fireStructureChanged(child, IModelChangedEvent.REMOVE); 78 } 79 } 80 | Popular Tags |