Saves the current tab to a file selected with a chooser. @return the name of the saved file, or null if not saved
()
| 2402 | * @return the name of the saved file, or null if not saved |
| 2403 | */ |
| 2404 | protected String saveAs() { |
| 2405 | int result = OSPRuntime.getChooser().showSaveDialog(this); |
| 2406 | if (result == JFileChooser.APPROVE_OPTION) { |
| 2407 | OSPRuntime.chooserDir = OSPRuntime.getChooser().getCurrentDirectory().toString(); |
| 2408 | File file = OSPRuntime.getChooser().getSelectedFile(); |
| 2409 | // check to see if file already exists |
| 2410 | if (file.exists()) { |
| 2411 | int selected = JOptionPane.showConfirmDialog(null, |
| 2412 | ToolsRes.getString("Tool.Dialog.ReplaceFile.Message") + " " + file.getName() + "?", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 2413 | ToolsRes.getString("Tool.Dialog.ReplaceFile.Title"), //$NON-NLS-1$ |
| 2414 | JOptionPane.YES_NO_CANCEL_OPTION); |
| 2415 | if (selected != JOptionPane.YES_OPTION) { |
| 2416 | return null; |
| 2417 | } |
| 2418 | } |
| 2419 | String fileName = file.getAbsolutePath(); |
| 2420 | if ((fileName == null) || fileName.trim().equals("")) { //$NON-NLS-1$ |
| 2421 | return null; |
| 2422 | } |
| 2423 | // add .xml extension if none but don't require it |
| 2424 | if (XML.getExtension(fileName) == null) { |
| 2425 | fileName += ".xml"; //$NON-NLS-1$ |
| 2426 | } |
| 2427 | return save(XML.getRelativePath(fileName)); |
| 2428 | } |
| 2429 | return null; |
| 2430 | } |
| 2431 | |
| 2432 | /** |
| 2433 | * Returns the index of the tab containing the specified Data object. |
no test coverage detected