Changeset 3120 for DataCleaner
- Timestamp:
- 02/02/12 23:41:20 (4 months ago)
- Location:
- DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner
- Files:
-
- 6 added
- 3 edited
-
panels/datastructures (added)
-
panels/datastructures/BuildMapJobBuilderPresenter.java (added)
-
panels/datastructures/BuildMapJobBuilderPresenterRenderer.java (added)
-
panels/datastructures/KeysAndTypesPropertyWidget.java (added)
-
panels/datastructures/SelectFromMapJobBuilderPresenter.java (added)
-
panels/datastructures/SelectFromMapJobBuilderPresenterRenderer.java (added)
-
widgets/properties/MultipleMappedStringsPropertyWidget.java (modified) (3 diffs)
-
widgets/properties/MultipleStringPropertyWidget.java (modified) (9 diffs)
-
widgets/properties/SingleClassPropertyWidget.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/MultipleMappedStringsPropertyWidget.java
r2845 r3120 129 129 final DCPanel panel = new DCPanel(); 130 130 panel.setLayout(new BorderLayout()); 131 panel.add(checkBox, BorderLayout. CENTER);131 panel.add(checkBox, BorderLayout.WEST); 132 132 panel.add(textField, BorderLayout.EAST); 133 133 return panel; 134 134 } 135 135 136 public PropertyWidget<String[]> getMapped ColumnNamesPropertyWidget() {136 public PropertyWidget<String[]> getMappedStringsPropertyWidget() { 137 137 return _mappedStringPropertyWidget; 138 138 } … … 161 161 @Override 162 162 public String[] getValue() { 163 return getMapped ColumnNames();163 return getMappedStrings(); 164 164 } 165 165 … … 203 203 } 204 204 205 private String[] getMapped ColumnNames() {205 private String[] getMappedStrings() { 206 206 final InputColumn<?>[] inputColumns = MultipleMappedStringsPropertyWidget.this.getValue(); 207 207 final List<String> result = new ArrayList<String>(); -
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/MultipleStringPropertyWidget.java
r2788 r3120 24 24 import java.awt.event.ActionEvent; 25 25 import java.awt.event.ActionListener; 26 import java.util.IdentityHashMap; 27 import java.util.Map; 26 28 27 29 import javax.inject.Inject; 28 30 import javax.swing.JButton; 31 import javax.swing.JComponent; 29 32 import javax.swing.border.EmptyBorder; 30 33 import javax.swing.event.DocumentEvent; 31 import javax.swing.text.JTextComponent;32 34 33 35 import org.eobjects.analyzer.descriptors.ConfiguredPropertyDescriptor; … … 49 51 50 52 private final DCPanel _textFieldPanel; 53 private final Map<JComponent, JXTextField> _textFieldDecorations; 51 54 52 55 @Inject … … 55 58 super(beanJobBuilder, propertyDescriptor); 56 59 60 _textFieldDecorations = new IdentityHashMap<JComponent, JXTextField>(); 61 57 62 _textFieldPanel = new DCPanel(); 58 63 _textFieldPanel.setLayout(new VerticalLayout(2)); 59 60 String[] currentValue = getCurrentValue();61 updateComponents(currentValue);62 64 63 65 final JButton addButton = WidgetFactory.createSmallButton("images/actions/add.png"); … … 76 78 int componentCount = _textFieldPanel.getComponentCount(); 77 79 if (componentCount > 0) { 78 _textFieldPanel.remove(componentCount - 1);80 removeTextField(); 79 81 _textFieldPanel.updateUI(); 80 82 fireValueChanged(); … … 98 100 } 99 101 102 @Override 103 public void initialize(String[] value) { 104 updateComponents(value); 105 } 106 100 107 public void updateComponents(String[] values) { 101 108 if (values == null) { … … 107 114 // modify text boxes 108 115 if (!EqualsBuilder.equals(previousValues[i], values[i])) { 109 JTextComponent component = (JTextComponent) _textFieldPanel.getComponent(i); 116 Component decoration = _textFieldPanel.getComponent(i); 117 JXTextField component = _textFieldDecorations.get(decoration); 110 118 component.setText(values[i]); 111 119 } … … 119 127 120 128 while (_textFieldPanel.getComponentCount() > values.length) { 121 // remove text boxes if there are too many 122 _textFieldPanel.remove(_textFieldPanel.getComponentCount() - 1); 129 removeTextField(); 123 130 } 124 131 _textFieldPanel.updateUI(); 125 132 } 133 } 134 135 private void removeTextField() { 136 int componentCount = _textFieldPanel.getComponentCount(); 137 if (componentCount == 0) { 138 return; 139 } 140 int index = componentCount - 1; 141 Component decoration = _textFieldPanel.getComponent(index); 142 _textFieldDecorations.remove(decoration); 143 _textFieldPanel.remove(index); 126 144 } 127 145 … … 137 155 } 138 156 }); 139 _textFieldPanel.add(textField); 157 158 JComponent decoration = decorateTextField(textField); 159 _textFieldDecorations.put(decoration, textField); 160 161 _textFieldPanel.add(decoration); 140 162 if (updateUI) { 141 163 _textFieldPanel.updateUI(); 142 164 } 165 } 166 167 protected JComponent decorateTextField(JXTextField textField) { 168 return textField; 143 169 } 144 170 … … 148 174 String[] result = new String[components.length]; 149 175 for (int i = 0; i < components.length; i++) { 150 JXTextField textField = (JXTextField) components[i]; 176 Component decoration = components[i]; 177 JXTextField textField = _textFieldDecorations.get(decoration); 151 178 result[i] = textField.getText(); 152 179 } -
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/SingleClassPropertyWidget.java
r3104 r3120 46 46 Collection<Class<?>> items = new ArrayList<Class<?>>(); 47 47 48 if (!propertyDescriptor.isRequired()) { 48 _comboBox = createClassComboBox(propertyDescriptor.isRequired()); 49 Class<?> currentValue = getCurrentValue(); 50 if (currentValue != null) { 51 _comboBox.setSelectedItem(currentValue); 52 } 53 54 _comboBox.addListener(new Listener<Class<?>>() { 55 @Override 56 public void onItemSelected(Class<?> item) { 57 fireValueChanged(item); 58 } 59 }); 60 61 add(_comboBox); 62 } 63 64 public static DCComboBox<Class<?>> createClassComboBox(boolean required) { 65 Collection<Class<?>> items = new ArrayList<Class<?>>(); 66 67 if (!required) { 49 68 items.add(null); 50 69 } … … 57 76 items.add(Object.class); 58 77 59 _comboBox = new DCComboBox<Class<?>>(items);60 _comboBox.setRenderer(new DefaultListCellRenderer() {78 DCComboBox<Class<?>> comboBox = new DCComboBox<Class<?>>(items); 79 comboBox.setRenderer(new DefaultListCellRenderer() { 61 80 62 81 private static final long serialVersionUID = 1L; … … 72 91 } 73 92 }); 74 _comboBox.addListener(new Listener<Class<?>>() { 75 @Override 76 public void onItemSelected(Class<?> item) { 77 fireValueChanged(item); 78 } 79 }); 80 81 add(_comboBox); 93 return comboBox; 82 94 } 83 95
Note: See TracChangeset
for help on using the changeset viewer.
