Changeset 3120 for DataCleaner


Ignore:
Timestamp:
02/02/12 23:41:20 (4 months ago)
Author:
kasper
Message:

Ticket #754: Added UI support in DataCleaner for most operations, still a few TODOs pending

Location:
DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner
Files:
6 added
3 edited

Legend:

Unmodified
Added
Removed
  • DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/MultipleMappedStringsPropertyWidget.java

    r2845 r3120  
    129129                final DCPanel panel = new DCPanel(); 
    130130                panel.setLayout(new BorderLayout()); 
    131                 panel.add(checkBox, BorderLayout.CENTER); 
     131                panel.add(checkBox, BorderLayout.WEST); 
    132132                panel.add(textField, BorderLayout.EAST); 
    133133                return panel; 
    134134        } 
    135135 
    136         public PropertyWidget<String[]> getMappedColumnNamesPropertyWidget() { 
     136        public PropertyWidget<String[]> getMappedStringsPropertyWidget() { 
    137137                return _mappedStringPropertyWidget; 
    138138        } 
     
    161161                        @Override 
    162162                        public String[] getValue() { 
    163                                 return getMappedColumnNames(); 
     163                                return getMappedStrings(); 
    164164                        } 
    165165 
     
    203203        } 
    204204 
    205         private String[] getMappedColumnNames() { 
     205        private String[] getMappedStrings() { 
    206206                final InputColumn<?>[] inputColumns = MultipleMappedStringsPropertyWidget.this.getValue(); 
    207207                final List<String> result = new ArrayList<String>(); 
  • DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/MultipleStringPropertyWidget.java

    r2788 r3120  
    2424import java.awt.event.ActionEvent; 
    2525import java.awt.event.ActionListener; 
     26import java.util.IdentityHashMap; 
     27import java.util.Map; 
    2628 
    2729import javax.inject.Inject; 
    2830import javax.swing.JButton; 
     31import javax.swing.JComponent; 
    2932import javax.swing.border.EmptyBorder; 
    3033import javax.swing.event.DocumentEvent; 
    31 import javax.swing.text.JTextComponent; 
    3234 
    3335import org.eobjects.analyzer.descriptors.ConfiguredPropertyDescriptor; 
     
    4951 
    5052        private final DCPanel _textFieldPanel; 
     53        private final Map<JComponent, JXTextField> _textFieldDecorations; 
    5154 
    5255        @Inject 
     
    5558                super(beanJobBuilder, propertyDescriptor); 
    5659 
     60                _textFieldDecorations = new IdentityHashMap<JComponent, JXTextField>(); 
     61 
    5762                _textFieldPanel = new DCPanel(); 
    5863                _textFieldPanel.setLayout(new VerticalLayout(2)); 
    59  
    60                 String[] currentValue = getCurrentValue(); 
    61                 updateComponents(currentValue); 
    6264 
    6365                final JButton addButton = WidgetFactory.createSmallButton("images/actions/add.png"); 
     
    7678                                int componentCount = _textFieldPanel.getComponentCount(); 
    7779                                if (componentCount > 0) { 
    78                                         _textFieldPanel.remove(componentCount - 1); 
     80                                        removeTextField(); 
    7981                                        _textFieldPanel.updateUI(); 
    8082                                        fireValueChanged(); 
     
    98100        } 
    99101 
     102        @Override 
     103        public void initialize(String[] value) { 
     104                updateComponents(value); 
     105        } 
     106 
    100107        public void updateComponents(String[] values) { 
    101108                if (values == null) { 
     
    107114                                // modify text boxes 
    108115                                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); 
    110118                                        component.setText(values[i]); 
    111119                                } 
     
    119127 
    120128                        while (_textFieldPanel.getComponentCount() > values.length) { 
    121                                 // remove text boxes if there are too many 
    122                                 _textFieldPanel.remove(_textFieldPanel.getComponentCount() - 1); 
     129                                removeTextField(); 
    123130                        } 
    124131                        _textFieldPanel.updateUI(); 
    125132                } 
     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); 
    126144        } 
    127145 
     
    137155                        } 
    138156                }); 
    139                 _textFieldPanel.add(textField); 
     157 
     158                JComponent decoration = decorateTextField(textField); 
     159                _textFieldDecorations.put(decoration, textField); 
     160 
     161                _textFieldPanel.add(decoration); 
    140162                if (updateUI) { 
    141163                        _textFieldPanel.updateUI(); 
    142164                } 
     165        } 
     166 
     167        protected JComponent decorateTextField(JXTextField textField) { 
     168                return textField; 
    143169        } 
    144170 
     
    148174                String[] result = new String[components.length]; 
    149175                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); 
    151178                        result[i] = textField.getText(); 
    152179                } 
  • DataCleaner/trunk/core/src/main/java/org/eobjects/datacleaner/widgets/properties/SingleClassPropertyWidget.java

    r3104 r3120  
    4646                Collection<Class<?>> items = new ArrayList<Class<?>>(); 
    4747 
    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) { 
    4968                        items.add(null); 
    5069                } 
     
    5776                items.add(Object.class); 
    5877 
    59                 _comboBox = new DCComboBox<Class<?>>(items); 
    60                 _comboBox.setRenderer(new DefaultListCellRenderer() { 
     78                DCComboBox<Class<?>> comboBox = new DCComboBox<Class<?>>(items); 
     79                comboBox.setRenderer(new DefaultListCellRenderer() { 
    6180 
    6281                        private static final long serialVersionUID = 1L; 
     
    7291                        } 
    7392                }); 
    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; 
    8294        } 
    8395 
Note: See TracChangeset for help on using the changeset viewer.