Changeset 6748 for trunk/gli/src/org
- Timestamp:
- 2004-02-09T15:55:22+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java
r6630 r6748 32 32 import org.greenstone.gatherer.Gatherer; 33 33 import org.greenstone.gatherer.gui.FileAssociationDialog; 34 import org.greenstone.gatherer.gui.PreviewCommandDialog; 34 35 import org.greenstone.gatherer.msm.MSMUtils; 35 36 import org.greenstone.gatherer.util.StaticStrings; … … 104 105 return command; 105 106 } 106 // Failing that we have to prompt the user for what they want to do, but we do our best to provide a sensible default (if available).107 // F or windows we can have a pretty good guess107 command = null; 108 // Failing that we have a guess at a sensible default 108 109 if(Utility.isWindows()) { 109 110 // we use cmd and start … … 113 114 command = StaticStrings.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\""; 114 115 } 115 } 116 117 // Now prompt the user 118 FileAssociationDialog dialog = new FileAssociationDialog(this); 119 command = dialog.display(true, command); 120 dialog.dispose(); 121 dialog = null; 116 } else if (Utility.isMac()) { 117 command = StaticStrings.MAC_OPEN_COMMAND; // "open %1" 118 } else { 119 // we try to look for a browser 120 } 121 122 // if we still haven't found something, prompt the user 123 if (command == null) { 124 PreviewCommandDialog dialog = new PreviewCommandDialog(); 125 command = dialog.display(); 126 dialog.dispose(); 127 dialog = null; 128 } 122 129 123 130 // Store the result if any 124 if(command != null ) {131 if(command != null && !command.equals("")) { 125 132 Gatherer.config.setPreviewCommand(command); 126 } 127 128 // for now uder linux get the fileassoc thing. but eventually want a separate thing. 129 // pretend we are trying to open an html file 130 // Mmmoooo. - jmt12 131 133 command = command.replaceAll(FILENAME_ARG, url); 134 Gatherer.println("Result = " + command); 135 return command; 136 } 132 137 // if we haven't got a command by now, we'll never get one 133 if (command == null) { 134 Gatherer.println("Result = " + command); 135 return null; 136 } 137 // Replace %1 with the url in quotes 138 command = command.replaceAll(FILENAME_ARG, url); 139 Gatherer.println("Result = " + command); 140 return command; 138 Gatherer.println("Result = null"); 139 return null; 140 141 141 } 142 142 -
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.