01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards;
11:
12: import org.eclipse.core.runtime.IPath;
13: import org.eclipse.core.runtime.Path;
14: import org.eclipse.pde.internal.ui.elements.ElementList;
15: import org.eclipse.ui.IPluginContribution;
16:
17: public class WizardCollectionElement extends ElementList implements
18: IPluginContribution {
19: private WizardCollectionElement parent;
20: private ElementList wizards = new ElementList("wizards"); //$NON-NLS-1$
21: private String id;
22:
23: // properties
24: public static String P_WIZARDS = "org.eclipse.pde.ui.wizards"; //$NON-NLS-1$
25:
26: public WizardCollectionElement(String id, String name,
27: WizardCollectionElement parent) {
28: super (name, null, parent);
29: this .id = id;
30: }
31:
32: public WizardCollectionElement findChildCollection(IPath searchPath) {
33: String searchString = searchPath.segment(0);
34:
35: Object[] 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
43: .removeFirstSegments(1));
44: }
45: }
46:
47: return null;
48: }
49:
50: public WizardElement findWizard(String searchId) {
51: Object[] children = getWizards().getChildren();
52:
53: for (int i = 0; i < children.length; i++) {
54: WizardElement currentWizard = (WizardElement) children[i];
55: if (currentWizard.getID().equals(searchId))
56: return currentWizard;
57: }
58: return null;
59: }
60:
61: public String getId() {
62: return id;
63: }
64:
65: public IPath getPath() {
66: if (parent == null)
67: return new Path(""); //$NON-NLS-1$
68:
69: return parent.getPath().append(getLabel());
70: }
71:
72: public ElementList getWizards() {
73: return wizards;
74: }
75:
76: public void setId(java.lang.String newId) {
77: id = newId;
78: }
79:
80: public void setWizards(ElementList value) {
81: wizards = value;
82: }
83:
84: /* (non-Javadoc)
85: * @see org.eclipse.ui.IPluginContribution#getLocalId()
86: */
87: public String getLocalId() {
88: return getId();
89: }
90:
91: /* (non-Javadoc)
92: * @see org.eclipse.ui.IPluginContribution#getPluginId()
93: */
94: public String getPluginId() {
95: return null;
96: }
97: }
|