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.runtime.registry;
11:
12: import org.eclipse.core.runtime.IConfigurationElement;
13:
14: public class ConfigurationElementAdapter extends ParentAdapter {
15:
16: class ConfigurationAttribute implements IConfigurationAttribute {
17: private String fLabel;
18:
19: public ConfigurationAttribute(String name, String value) {
20: fLabel = name + " = " + value; //$NON-NLS-1$
21: }
22:
23: public String getLabel() {
24: return fLabel;
25: }
26: }
27:
28: public ConfigurationElementAdapter(Object object) {
29: super (object);
30: }
31:
32: protected Object[] createChildren() {
33: IConfigurationElement config = (IConfigurationElement) getObject();
34: String[] atts = config.getAttributeNames();
35: IConfigurationAttribute[] catts = new IConfigurationAttribute[atts.length];
36: for (int i = 0; i < atts.length; i++)
37: catts[i] = new ConfigurationAttribute(atts[i], config
38: .getAttribute(atts[i]));
39: IConfigurationElement[] children = config.getChildren();
40: Object[] result = new Object[children.length + catts.length];
41: for (int i = 0; i < children.length; i++) {
42: IConfigurationElement child = children[i];
43: result[i] = new ConfigurationElementAdapter(child);
44: }
45: for (int i = 0; i < catts.length; i++) {
46: IConfigurationAttribute child = catts[i];
47: result[children.length + i] = new ConfigurationAttributeAdapter(
48: child);
49: }
50: return result;
51: }
52: }
|