KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > text > plugin > PluginParentNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.core.text.plugin;
12
13 import java.util.ArrayList JavaDoc;
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     /* (non-Javadoc)
26      * @see org.eclipse.pde.core.plugin.IPluginParent#add(int, org.eclipse.pde.core.plugin.IPluginObject)
27      */

28     public void add(int index, IPluginObject child) throws CoreException {
29         addChildNode((IDocumentNode)child, index);
30         fireStructureChanged(child, IModelChangedEvent.INSERT);
31     }
32     /* (non-Javadoc)
33      * @see org.eclipse.pde.core.plugin.IPluginParent#add(org.eclipse.pde.core.plugin.IPluginObject)
34      */

35     public void add(IPluginObject child) throws CoreException {
36         add(getChildCount(), child);
37         child.setInTheModel(true);
38         ((PluginObjectNode)child).setModel(getModel());
39     }
40     /* (non-Javadoc)
41      * @see org.eclipse.pde.core.plugin.IPluginParent#getChildCount()
42      */

43     public int getChildCount() {
44         return getChildNodes().length;
45     }
46     /* (non-Javadoc)
47      * @see org.eclipse.pde.core.plugin.IPluginParent#getIndexOf(org.eclipse.pde.core.plugin.IPluginObject)
48      */

49     public int getIndexOf(IPluginObject child) {
50         return indexOf((IDocumentNode)child);
51     }
52     /* (non-Javadoc)
53      * @see org.eclipse.pde.core.plugin.IPluginParent#swap(org.eclipse.pde.core.plugin.IPluginObject, org.eclipse.pde.core.plugin.IPluginObject)
54      */

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     /* (non-Javadoc)
61      * @see org.eclipse.pde.core.plugin.IPluginParent#getChildren()
62      */

63     public IPluginObject[] getChildren() {
64         ArrayList JavaDoc result = new ArrayList JavaDoc();
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     /* (non-Javadoc)
72      * @see org.eclipse.pde.core.plugin.IPluginParent#remove(org.eclipse.pde.core.plugin.IPluginObject)
73      */

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