// public static final String showElementTreeAction = "showElementTree"; // ------------------------------------------------------------- public void openFile(String currDirStr, String currFileStr) { if (fileDialog == null) { fileDialog = new FileDialog(this); } fileDialog.setMode(FileDialog.LOAD); if (!(currDirStr.equals(""))) { fileDialog.setDirectory(currDirStr); } if (!(currFileStr.equals(""))) { fileDialog.setFile(currFileStr); } fileDialog.show(); String file = fileDialog.getFile(); // cancel pushed if (file == null) { return; } String directory = fileDialog.getDirectory(); File f = new File(directory, file); if (f.exists()) { Document oldDoc = getEditor().getDocument(); if (oldDoc != null) // oldDoc.removeUndoableEditListener(undoHandler); /* if (elementTreePanel != null) { elementTreePanel.setEditor(null); } */ getEditor().setDocument(new PlainDocument()); fileDialog.setTitle(file); Thread loader = new FileLoader(f, editor1.getDocument()); loader.start(); } }
/** Handle ItemEvents. */ public void itemStateChanged(ItemEvent e) { final String dialog_title = ResourceHandler.getMessage("template_dialog.title"); Component target = (Component) e.getSource(); if (target == recursiveCheckBox) { converter.setRecurse(recursiveCheckBox.isSelected()); } else if (target == staticVersioningRadioButton || target == dynamicVersioningRadioButton) { converter.setStaticVersioning(staticVersioningRadioButton.isSelected()); } else if (target == templateCh && (e.getStateChange() == e.SELECTED)) { // Process only when item is Selected // Get the current template selection String choiceStr = (String) templateCh.getSelectedItem(); // If the user chooses 'other', display a file dialog to allow // them to select a template file. if (choiceStr.equals(TemplateFileChoice.OTHER_STR)) { String templatePath = null; FileDialog fd = new FileDialog(this, dialog_title, FileDialog.LOAD); fd.show(); // Capture the path entered, if any. if (fd.getDirectory() != null && fd.getFile() != null) { templatePath = fd.getDirectory() + fd.getFile(); } // If the template file is valid add it and select it. if (templatePath != null && setTemplateFile(templatePath)) { if (!templateCh.testIfInList(templatePath)) { templateCh.addItem(templatePath); } templateCh.select(templatePath); } else { templateCh.select(templateCh.getPreviousSelection()); } fd.dispose(); } else { templateCh.select(choiceStr); } } }