KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > plugin > PluginParentNode


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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.ui.model.plugin;
12
13 import java.util.*;
14
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.pde.core.*;
17 import org.eclipse.pde.core.plugin.*;
18 import org.eclipse.pde.internal.ui.model.*;
19
20 public class PluginParentNode extends PluginObjectNode implements IPluginParent {
21
22     private static final long serialVersionUID = 1L;
23
24     /* (non-Javadoc)
25      * @see org.eclipse.pde.core.plugin.IPluginParent#add(int, org.eclipse.pde.core.plugin.IPluginObject)
26      */

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

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

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

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

54     public void swap(IPluginObject child1, IPluginObject child2)
55             throws CoreException {
56         swap((IDocumentNode)child1, (IDocumentNode)child2);
57         firePropertyChanged(this, P_SIBLING_ORDER, child1, child2);
58     }
59     /* (non-Javadoc)
60      * @see org.eclipse.pde.core.plugin.IPluginParent#getChildren()
61      */

62     public IPluginObject[] getChildren() {
63         ArrayList result = new ArrayList();
64         IDocumentNode[] nodes = getChildNodes();
65         for (int i = 0; i < nodes.length; i++)
66             result.add(nodes[i]);
67                       
68         return (IPluginObject[])result.toArray(new IPluginObject[result.size()]);
69     }
70     /* (non-Javadoc)
71      * @see org.eclipse.pde.core.plugin.IPluginParent#remove(org.eclipse.pde.core.plugin.IPluginObject)
72      */

73     public void remove(IPluginObject child) throws CoreException {
74         removeChildNode((IDocumentNode)child);
75         child.setInTheModel(false);
76         fireStructureChanged(child, IModelChangedEvent.REMOVE);
77     }
78 }
79
Popular Tags