1 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; } 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 } 50 | Popular Tags |