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