- Timestamp:
- 2004-02-09T15:55:22+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/FileAssociationDialog.java
r6539 r6748 64 64 extends ModalDialog { 65 65 66 static final private String NORMAL = "normal";67 static final private String PREVIEW = "preview";68 69 66 /** The default size of a label. */ 70 67 static final private Dimension LABEL_SIZE = new Dimension(150, 25); … … 73 70 74 71 private boolean ignore = false; 75 private boolean preview_type;76 private CardLayout card_layout;77 72 private FileAssociationDialog self; 78 73 private FileAssociationManager file_association_manager; … … 82 77 private JButton remove_button; 83 78 private JButton replace_button; 84 private JPanel swap_pane;85 79 private JTable existing_associations_table; 86 80 private JTextField command_field; … … 117 111 existing_associations_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 118 112 JPanel lower_pane = new JPanel(); 119 120 113 JPanel details_pane = new JPanel(); 121 122 card_layout = new CardLayout();123 swap_pane = new JPanel(card_layout);124 114 125 115 JPanel extension_pane = new JPanel(); … … 127 117 extension_label.setPreferredSize(LABEL_SIZE); 128 118 extension_field = new NonWhitespaceField(); 129 130 JLabel preview_label = new JLabel();131 Dictionary.setText(preview_label, "FileAssociationDialog.Preview");132 119 133 120 JLabel command_label = new JLabel(); … … 192 179 command_pane.add(browse_button, BorderLayout.EAST); 193 180 194 swap_pane.add(extension_pane, NORMAL);195 swap_pane.add(preview_label, PREVIEW);196 197 181 details_pane.setBorder(BorderFactory.createTitledBorder(Dictionary.get("FileAssociationDialog.Details"))); 198 182 details_pane.setLayout(new GridLayout(3,1)); 199 details_pane.add( swap_pane);183 details_pane.add(extension_pane); 200 184 details_pane.add(command_label); 201 185 details_pane.add(command_pane); … … 242 226 */ 243 227 public String display(String new_extension) { 244 preview_type = false;245 246 228 // Clear the current selection 247 229 existing_associations_table.clearSelection(); 248 249 // Now ensable the components that aren't important for the preview collection command250 existing_associations_table.setEnabled(true);251 Dictionary.setBoth(close_button, "FileAssociationDialog.Close", "FileAssociationDialog.Close_Tooltip");252 // And display the extension chooser253 card_layout.show(swap_pane, NORMAL);254 swap_pane.updateUI();255 256 230 if(new_extension != null) { 257 231 extension_field.setText(new_extension); 258 232 } 259 260 233 setVisible(true); 261 262 234 if(new_extension != null) { 263 235 return file_association_manager.getCommandString(new_extension); 264 236 } 265 266 237 return null; 267 }268 269 public String display(boolean is_preview_type, String command) {270 System.err.println("Preview type");271 272 preview_type = true;273 274 if(command != null) {275 command_field.setText(command);276 }277 278 // Clear the current selection279 existing_associations_table.clearSelection();280 281 // Now disable the components that aren't important for the preview collection command282 existing_associations_table.setEnabled(false);283 284 Dictionary.setBoth(close_button, "General.OK", "FileAssociationDialog.Close_Tooltip");285 286 // And display the preview collection message287 card_layout.show(swap_pane, PREVIEW);288 swap_pane.updateUI();289 290 setVisible(true);291 return command_field.getText();292 238 } 293 239 … … 305 251 306 252 public void actionPerformed(ActionEvent event) { 307 if(!preview_type) { 308 String extension_str = extension_field.getText(); 309 file_association_manager.setCommand(extension_str, command_field.getText()); 310 // Select the appropriate entry in the table 311 int index = -1; 312 for(int i = 0; index == -1 && i < file_association_manager.size(); i++) { 313 if(file_association_manager.getExtension(i).equals(extension_str)) { 314 index = i; 315 } 316 } 317 if(index > -1) { 318 existing_associations_table.setRowSelectionInterval(index, index); 319 } 320 // And update buttons 321 add_button.setEnabled(false); 322 remove_button.setEnabled(true); 323 } 253 String extension_str = extension_field.getText(); 254 file_association_manager.setCommand(extension_str, command_field.getText()); 255 // Select the appropriate entry in the table 256 int index = -1; 257 for(int i = 0; index == -1 && i < file_association_manager.size(); i++) { 258 if(file_association_manager.getExtension(i).equals(extension_str)) { 259 index = i; 260 } 261 } 262 if(index > -1) { 263 existing_associations_table.setRowSelectionInterval(index, index); 264 } 265 // And update buttons 266 add_button.setEnabled(false); 267 remove_button.setEnabled(true); 324 268 } 325 269 }
Note:
See TracChangeset
for help on using the changeset viewer.