1 package net.suberic.util.gui.propedit; 2 import javax.swing.*; 3 import java.util.Vector ; 4 import java.util.List ; 5 import java.util.ArrayList ; 6 7 30 public class TabbedEditorPane extends CompositeSwingPropertyEditor { 31 32 JTabbedPane tabbedPane; 33 protected boolean templateScoped = false; 34 protected boolean propertyScoped = false; 35 36 45 public void configureEditor(String propertyName, String template, String propertyBaseName, PropertyEditorManager newManager) { 46 configureBasic(propertyName, template, propertyBaseName, newManager); 47 48 debug = manager.getProperty("editors.debug", "false").equalsIgnoreCase("true"); 49 getLogger().fine("configuring editor with property " + propertyName + ", editorTemplate " + editorTemplate); 50 51 tabbedPane = new JTabbedPane(); 52 53 55 getLogger().fine("creating prop from " + template + "=" + manager.getProperty(template, "")); 56 57 List <String > propsToEdit = manager.getPropertyAsList(template, ""); 58 59 editors = createEditors(propsToEdit); 60 61 getLogger().fine("minimumSize for tabbedPane = " + tabbedPane.getMinimumSize()); 62 getLogger().fine("preferredSize for tabbedPane = " + tabbedPane.getPreferredSize()); 63 getLogger().fine("size for tabbedPane = " + tabbedPane.getSize()); 64 65 SpringLayout layout = new SpringLayout(); 66 this.setLayout(layout); 67 this.add(tabbedPane); 68 layout.putConstraint(SpringLayout.WEST, tabbedPane, 0, SpringLayout.WEST, this); 69 layout.putConstraint(SpringLayout.NORTH, tabbedPane, 0, SpringLayout.NORTH, this); 70 layout.putConstraint(SpringLayout.SOUTH, this, 0 ,SpringLayout.SOUTH, tabbedPane); 71 layout.putConstraint(SpringLayout.EAST, this, 0 ,SpringLayout.EAST, tabbedPane); 72 73 manager.registerPropertyEditor(property, this); 74 } 75 76 79 public List createEditors(List <String > propsToEdit) { 80 List editorList = new ArrayList (); 81 SwingPropertyEditor currentEditor; 82 83 for (int i = 0; i < propsToEdit.size(); i++) { 84 String subTemplateString = propsToEdit.get(i); 85 String property = createSubProperty(subTemplateString); 86 String currentTemplate = createSubTemplate(subTemplateString); 87 currentEditor = createEditorPane(property, currentTemplate); 88 89 getLogger().fine("adding " + currentEditor); 90 getLogger().fine("currentEditor.getMinimumSize() = " + currentEditor.getMinimumSize()); 91 92 editorList.add(currentEditor); 93 tabbedPane.add(manager.getProperty(currentTemplate + ".label", currentTemplate), currentEditor); 94 } 95 96 return editorList; 97 } 98 99 100 103 private SwingPropertyEditor createEditorPane(String subProperty, String subTemplate) { 104 return (SwingPropertyEditor) manager.getFactory().createEditor(subProperty, subTemplate, subProperty, manager); 105 106 } 107 108 111 public String getHelpID() { 112 String subProperty = manager.getProperty(editorTemplate + ".helpController", ""); 113 if (subProperty.length() == 0) { 114 java.awt.Component selectedComponent = tabbedPane.getSelectedComponent(); 115 if (selectedComponent == null || ! (selectedComponent instanceof PropertyEditorUI)) { 116 return super.getHelpID(); 117 } else { 118 return ((PropertyEditorUI) selectedComponent).getHelpID(); 119 } 120 } else { 121 return super.getHelpID(); 122 } 123 } 124 125 } 126 127 128 129 | Popular Tags |