KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > WizardCollectionElement


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.ui.wizards;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.pde.internal.ui.elements.ElementList;
16 import org.eclipse.ui.IPluginContribution;
17
18
19
20 public class WizardCollectionElement extends ElementList implements IPluginContribution {
21     private WizardCollectionElement parent;
22     private ElementList wizards = new ElementList("wizards"); //$NON-NLS-1$
23
private String JavaDoc id;
24
25     // properties
26
public static String JavaDoc P_WIZARDS = "org.eclipse.pde.ui.wizards"; //$NON-NLS-1$
27

28 public WizardCollectionElement(String JavaDoc id, String JavaDoc name, WizardCollectionElement parent) {
29     super(name, null, parent);
30     this.id = id;
31 }
32 public WizardCollectionElement findChildCollection(IPath searchPath) {
33     String JavaDoc searchString = searchPath.segment(0);
34
35     Object JavaDoc [] children = getChildren();
36     for (int i=0; i<children.length; i++) {
37         WizardCollectionElement currentCategory = (WizardCollectionElement)children[i];
38         if (currentCategory.getLabel().equals(searchString)) {
39             if (searchPath.segmentCount() == 1)
40                 return currentCategory;
41                 
42             return currentCategory.findChildCollection(searchPath.removeFirstSegments(1));
43         }
44     }
45     
46     return null;
47 }
48 public WizardElement findWizard(String JavaDoc searchId) {
49     Object JavaDoc [] children = getWizards().getChildren();
50
51     for (int i=0; i<children.length; i++) {
52         WizardElement currentWizard = (WizardElement)children[i];
53         if (currentWizard.getID().equals(searchId))
54             return currentWizard;
55     }
56     return null;
57 }
58 public String JavaDoc getId() {
59     return id;
60 }
61 public IPath getPath() {
62     if (parent == null)
63         return new Path(""); //$NON-NLS-1$
64

65     return parent.getPath().append(getLabel());
66 }
67 public ElementList getWizards() {
68     return wizards;
69 }
70 public void setId(java.lang.String JavaDoc newId) {
71     id = newId;
72 }
73 public void setWizards(ElementList value) {
74     wizards = value;
75 }
76     /* (non-Javadoc)
77      * @see org.eclipse.ui.IPluginContribution#getLocalId()
78      */

79     public String JavaDoc getLocalId() {
80         return getId();
81     }
82     /* (non-Javadoc)
83      * @see org.eclipse.ui.IPluginContribution#getPluginId()
84      */

85     public String JavaDoc getPluginId() {
86         return null;
87     }
88 }
89
Popular Tags