Changeset 751 for DataCleaner/trunk/DataCleaner-gui/src/main/java/dk/eobjects/datacleaner/gui/dialogs/CsvConfigurationDialog.java
- Timestamp:
- 03/15/09 13:35:43 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DataCleaner/trunk/DataCleaner-gui/src/main/java/dk/eobjects/datacleaner/gui/dialogs/CsvConfigurationDialog.java
r645 r751 18 18 19 19 import java.awt.BorderLayout; 20 import java.awt.Color;21 20 import java.awt.Component; 21 import java.awt.GridBagLayout; 22 22 import java.awt.event.ActionEvent; 23 23 import java.awt.event.ActionListener; … … 32 32 import javax.swing.JTextField; 33 33 import javax.swing.JToolBar; 34 import javax.swing.border.LineBorder;35 34 36 35 import dk.eobjects.datacleaner.data.DataContextSelection; … … 41 40 import dk.eobjects.metamodel.data.Row; 42 41 import dk.eobjects.metamodel.query.Query; 42 import dk.eobjects.metamodel.query.SelectItem; 43 import dk.eobjects.metamodel.schema.Column; 43 44 import dk.eobjects.metamodel.schema.Table; 44 45 … … 47 48 48 49 private static final long serialVersionUID = -8449807287294665745L; 50 49 51 private static final String COMMA_ACTION_CMD = ","; 50 52 private static final String SEMI_COLON_ACTION_CMD = ";"; … … 52 54 private static final String SINGLE_QUOTE_ACTION_CMD = "'"; 53 55 private static final String DOUBLE_QUOTE_ACTION_CMD = "\""; 54 private JPanel _dataConfigurationPanel; 56 private static final int PREVIEW_ROWS = 5; 57 58 private JPanel _panel; 55 59 private JTextField _sampleText; 56 60 private DataTable _table; … … 59 63 private DataContextSelection _dataContextSelection; 60 64 private File _file; 61 private JRadioButton _tabButton;65 private String _fileExtension; 62 66 private JPanel _tablePanel; 63 67 64 68 public CsvConfigurationDialog(DataContextSelection selection, File file) { 65 super( 600, 480);69 super(500, 480); 66 70 _file = file; 67 71 _dataContextSelection = selection; … … 78 82 add(toolbar, BorderLayout.SOUTH); 79 83 80 String fileExtension = DataContextSelection.getExtention(file); 81 if (DataContextSelection.EXTENSION_TAB_SEPARATED.equals(fileExtension)) { 82 _tabButton.setSelected(true); 83 _curSeparator = TAB_ACTION_CMD.charAt(0); 84 } 84 _fileExtension = DataContextSelection.getExtention(file); 85 85 86 86 updateContent(); … … 90 90 protected Component getContent() { 91 91 ButtonGroup delimitorGroup = new ButtonGroup(); 92 _dataConfigurationPanel = GuiHelper.createPanel().applyLayout(null) 93 .toComponent(); 94 JLabel delimitorLbl = new JLabel("Select the Delimitor:"); 95 addToPanel(delimitorLbl, 10, 5, 200, 20); 92 _panel = GuiHelper.createPanel().toComponent(); 93 94 JLabel delimitorLabel = new JLabel("Select the Delimitor:"); 95 GuiHelper.addToGridBag(delimitorLabel, _panel, 0, 0); 96 96 97 JRadioButton commaButton = GuiHelper.createRadio("Use Comma [,]", 97 98 delimitorGroup).toComponent(); … … 99 100 commaButton.setSelected(true); 100 101 commaButton.addActionListener(this); 101 addToPanel(commaButton, 10, 35, 150, 20);102 GuiHelper.addToGridBag(commaButton, _panel, 0, 1); 102 103 103 104 JRadioButton semiColonButton = GuiHelper.createRadio( … … 105 106 semiColonButton.setActionCommand(SEMI_COLON_ACTION_CMD); 106 107 semiColonButton.addActionListener(this); 107 addToPanel(semiColonButton, 10, 60, 150, 20); 108 109 _tabButton = GuiHelper.createRadio("Use Tab [ ]", delimitorGroup) 110 .toComponent(); 111 _tabButton.setActionCommand(TAB_ACTION_CMD); 112 _tabButton.addActionListener(this); 113 addToPanel(_tabButton, 10, 85, 150, 20); 114 115 delimitorGroup.add(_tabButton); 116 117 JLabel quotationLbl = new JLabel("Select the Quotation type:"); 108 GuiHelper.addToGridBag(semiColonButton, _panel, 0, 2); 109 110 JRadioButton tabButton = GuiHelper.createRadio("Use Tab [ ]", 111 delimitorGroup).toComponent(); 112 tabButton.setActionCommand(TAB_ACTION_CMD); 113 tabButton.addActionListener(this); 114 if (DataContextSelection.EXTENSION_TAB_SEPARATED.equals(_fileExtension)) { 115 tabButton.setSelected(true); 116 _curSeparator = TAB_ACTION_CMD.charAt(0); 117 } 118 GuiHelper.addToGridBag(tabButton, _panel, 0, 3); 119 120 delimitorGroup.add(tabButton); 121 122 JLabel quotationLabel = new JLabel("Select the Quotation type:"); 123 GuiHelper.addToGridBag(quotationLabel, _panel, 1, 0); 118 124 119 125 ButtonGroup quoteGroup = new ButtonGroup(); 120 addToPanel(quotationLbl, 200, 5, 200, 20); 121 JRadioButton doubleButton = GuiHelper.createRadio( 126 JRadioButton doubleQuoteButton = GuiHelper.createRadio( 122 127 "Use Double Quote [\"sample text\"]", quoteGroup).toComponent(); 123 doubleButton.setActionCommand(DOUBLE_QUOTE_ACTION_CMD); 124 doubleButton.setSelected(true); 125 doubleButton.addActionListener(this); 126 addToPanel(doubleButton, 200, 35, 200, 20); 127 JRadioButton singleButton = GuiHelper.createRadio( 128 doubleQuoteButton.setActionCommand(DOUBLE_QUOTE_ACTION_CMD); 129 doubleQuoteButton.setSelected(true); 130 doubleQuoteButton.addActionListener(this); 131 GuiHelper.addToGridBag(doubleQuoteButton, _panel, 1, 1); 132 133 JRadioButton singleQuoteButton = GuiHelper.createRadio( 128 134 "Use Single Quote ['sample text']", quoteGroup).toComponent(); 129 single Button.setActionCommand(SINGLE_QUOTE_ACTION_CMD);130 single Button.addActionListener(this);131 addToPanel(singleButton, 200, 60, 200, 20);135 singleQuoteButton.setActionCommand(SINGLE_QUOTE_ACTION_CMD); 136 singleQuoteButton.addActionListener(this); 137 GuiHelper.addToGridBag(singleQuoteButton, _panel, 1, 2); 132 138 133 139 _sampleText = new JTextField("Sample Text"); 134 140 _sampleText.setText("\"sample text1\", \"sample text2\", ..."); 135 141 _sampleText.setEnabled(false); 136 addToPanel(_sampleText, 10, 115, 400, 20);142 GuiHelper.addToGridBag(_sampleText, _panel, 0, 10, 2, 1); 137 143 138 144 JLabel tableHeading = new JLabel("Preview Data:"); 139 addToPanel(tableHeading, 10, 145, 200, 20); 140 141 _table = new DataTable(new DataSet(new ArrayList<Row>(0))); 145 GuiHelper.addToGridBag(tableHeading, _panel, 0, 11, 2, 1); 146 147 ArrayList<Row> initialData = new ArrayList<Row>(PREVIEW_ROWS); 148 SelectItem[] selectItems = new SelectItem[] { new SelectItem( 149 new Column("")) }; 150 for (int i = 0; i < PREVIEW_ROWS; i++) { 151 initialData.add(new Row(selectItems, new Object[] { "" })); 152 } 153 154 _table = new DataTable(new DataSet(initialData)); 142 155 _table.setName("previewTable"); 143 156 _tablePanel = _table.toPanel(); 144 _tablePanel.setBorder(new LineBorder(Color.GRAY, 1)); 145 _tablePanel.setLocation(10, 170); 146 _dataConfigurationPanel.add(_tablePanel); 147 // addToPanel(tablePanel, 10, 150, 580, 108); 148 return _dataConfigurationPanel; 149 } 150 151 private void addToPanel(Component c, int xPos, int yPos, int width, 152 int height) { 153 c.setLocation(xPos, yPos); 154 c.setSize(width, height); 155 _dataConfigurationPanel.add(c); 157 GuiHelper.addToGridBag(_tablePanel, _panel, 0, 12, 2, 1); 158 159 GridBagLayout layout = (GridBagLayout) _panel.getLayout(); 160 layout.columnWidths = new int[] { 240, 240 }; 161 162 return _panel; 156 163 } 157 164 … … 180 187 Query q = new Query(); 181 188 q.from(table).select(table.getColumns()); 182 q.setMaxRows( 5);189 q.setMaxRows(PREVIEW_ROWS); 183 190 184 191 _table.updateTable(dataContext.executeQuery(q)); 185 _tablePanel.setSize(_table.getPanelPreferredSize());186 192 } 187 193
Note: See TracChangeset
for help on using the changeset viewer.
