1 package net.suberic.util.gui.propedit; 2 import javax.swing.*; 3 import java.awt.Container ; 4 import java.awt.Component ; 5 import java.util.Vector ; 6 import java.util.ArrayList ; 7 import java.util.List ; 8 import net.suberic.util.VariableBundle; 9 10 27 public class CompositeEditorPane extends CompositeSwingPropertyEditor { 28 29 32 public CompositeEditorPane() { 33 34 } 35 36 45 public void configureEditor(String propertyName, String template, String propertyBaseName, PropertyEditorManager newManager) { 46 47 configureBasic(propertyName, template, propertyBaseName, newManager); 48 49 getLogger().fine("creating CompositeEditorPane for " + property + " with template " + editorTemplate); 50 51 53 String borderLabel = manager.getProperty(editorTemplate + ".label.border", ""); 54 if (borderLabel.length() > 0) { 55 this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), borderLabel)); 56 } 57 58 List <String > properties = new ArrayList <String >(); 59 List <String > templates = new ArrayList <String >(); 60 61 getLogger().fine("testing for template " + template); 62 63 List <String > templateNames = manager.getPropertyAsList(template, ""); 64 getLogger().fine("templateNames = getProp(" + template + ") = " + manager.getProperty(template, "")); 65 66 for (int i = 0; i < templateNames.size() ; i++) { 67 String subTemplateString = templateNames.get(i); 68 properties.add(createSubProperty(subTemplateString)); 69 templates.add(createSubTemplate(subTemplateString)); 70 } 71 72 addEditors(properties, templates); 73 } 74 75 public void addEditors(List <String > properties, List <String > templates) { 76 SwingPropertyEditor currentEditor; 77 78 editors = new Vector (); 79 80 SpringLayout layout = new SpringLayout(); 81 82 this.setLayout(new SpringLayout()); 83 Component [] labelComponents = new Component [properties.size()]; 84 Component [] valueComponents = new Component [properties.size()]; 85 for (int i = 0; i < properties.size(); i++) { 86 getLogger().fine("creating editor for " + properties.get(i) + ", template " + templates.get(i) + ", propertyBase " + propertyBase); 87 currentEditor = (SwingPropertyEditor) manager.createEditor(properties.get(i), templates.get(i), propertyBase); 88 getLogger().fine("got " + currentEditor.getClass().getName()); 89 editors.add(currentEditor); 90 91 if (currentEditor instanceof LabelValuePropertyEditor) { 92 LabelValuePropertyEditor lvEditor = (LabelValuePropertyEditor) currentEditor; 93 this.add(lvEditor.labelComponent); 94 labelComponents[i] = lvEditor.labelComponent; 95 this.add(lvEditor.valueComponent); 96 valueComponents[i] = lvEditor.valueComponent; 97 } else { 98 this.add(currentEditor); 99 labelComponents[i] = currentEditor; 100 } 101 } 102 layoutGrid(this, labelComponents, valueComponents, 5, 5, 5, 5, manager.getProperty(editorTemplate + ".nested", "false").equalsIgnoreCase("true")); 104 manager.registerPropertyEditor(property, this); 105 } 106 107 108 } 109 | Popular Tags |