public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Open Layout"); chooser.setFileFilter(new ExtensionFileFilter( new String[] { "xml" })); int retVal = chooser.showOpenDialog(basePane); if (retVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (file != null) { try { openLayout(file.toURI().toURL().openStream()); } catch (IOException ex) { logger.error("Error saving default layout", ex); } } } } };
public boolean accept(File f) { if (f.isDirectory()) { return true; } String extension = getExtension(f); if (extension != null) { for (int i = 0; i < allowedExtensions.length; i++) { if (extension.equalsIgnoreCase(allowedExtensions[i])) { return true; } } } return false; }
public void actionPerformed(ActionEvent e) { Preferences prefs = Preferences .userNodeForPackage(OpenNestedWorkflowFromFileAction.class); String curDir = prefs.get("currentDir", System .getProperty("user.home")); fileChooser.setDialogTitle("Open Nested Workflow"); fileChooser.resetChoosableFileFilters(); fileChooser.setFileFilter(new ExtensionFileFilter( new String[] { "xml" })); fileChooser.setCurrentDirectory(new File(curDir)); int returnVal = fileChooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { prefs.put("currentDir", fileChooser.getCurrentDirectory() .toString()); File file = fileChooser.getSelectedFile(); createNestedWorkflow(file.toURI().toString(), (Component) e .getSource()); } }
public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save perspective"); chooser.setFileFilter(new ExtensionFileFilter( new String[] { "xml" })); int retVal = chooser.showSaveDialog(basePane); if (retVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (file != null) { PrintWriter out; try { out = new PrintWriter(new FileWriter(file)); Element element = basePane.getElement(); XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat()); out.print(xo.outputString(element)); out.flush(); out.close(); } catch (IOException ex) { logger.error("IOException saving layout", ex); JOptionPane.showMessageDialog(basePane, "Error saving layout file: " + ex.getMessage()); } } } } };
public void actionPerformed(ActionEvent e) { try { generateSheet(); JFileChooser jfc = new JFileChooser(); Preferences prefs = Preferences.userNodeForPackage(SaveWorkflowAction.class); String curDir = prefs.get("currentDir", System.getProperty("user.home")); jfc.resetChoosableFileFilters(); jfc.setFileFilter(new ExtensionFileFilter(new String[] { "xls" })); jfc.setCurrentDirectory(new File(curDir)); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = jfc.showSaveDialog(component); if (returnVal == JFileChooser.APPROVE_OPTION) { // Build the string containing the XML // document from the datathing map File f = jfc.getSelectedFile(); saveSheet(f); } } catch (Exception ex) { logger.warn("Could not save to Excel", ex); JOptionPane.showMessageDialog(component, "Problem saving results : \n" + ex.getMessage(), "Error!", JOptionPane.ERROR_MESSAGE); } }
public void actionPerformed(ActionEvent e) { Preferences prefs = Preferences.userNodeForPackage(OpenWorkflowFromFileAction.class); String curDir = prefs .get("currentDir", System.getProperty("user.home")); fileChooser.setDialogTitle("Open Workflow"); fileChooser.resetChoosableFileFilters(); fileChooser.setFileFilter(new ExtensionFileFilter( new String[] { "xml" })); fileChooser.setCurrentDirectory(new File(curDir)); int returnVal = fileChooser.showOpenDialog(parentComponent); if (returnVal == JFileChooser.APPROVE_OPTION) { prefs.put("currentDir", fileChooser.getCurrentDirectory() .toString()); final File file = fileChooser.getSelectedFile(); // mrp Refactored to do the heavy-lifting in a new thread final URL url; try { url = file.toURI().toURL(); } catch (MalformedURLException ex) { logger.error("Malformed URL from file " + file, ex); return; } try { openFromURL(url.openConnection()); } catch (IOException ex) { ex.printStackTrace(); } } }
String curDir = prefs.get("currentDir", System.getProperty("user.home")); jfc.resetChoosableFileFilters(); jfc.setFileFilter(new ExtensionFileFilter(new String[]{"xml"})); jfc.setCurrentDirectory(new File(curDir)); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
public void actionPerformed(ActionEvent e) { try { JFileChooser fc = new JFileChooser(); Preferences prefs = Preferences.userNodeForPackage(TavernaIcons.class); String curDir = prefs.get("currentDir", System.getProperty("user.home")); fc.resetChoosableFileFilters(); fc.setFileFilter(new ExtensionFileFilter(new String[]{"xml"})); fc.setCurrentDirectory(new File(curDir)); int returnVal = fc.showOpenDialog(s.getContainingFrame()); if (returnVal == JFileChooser.APPROVE_OPTION) { prefs.put("currentDir", fc.getCurrentDirectory().toString()); File file = fc.getSelectedFile(); URL url = file.toURL(); s.addScavenger(new APIConsumerScavenger(url)); } } catch (Exception sce) { JOptionPane.showMessageDialog (null, "Unable to create scavenger!\n"+sce.getMessage(), "Exception!", JOptionPane.ERROR_MESSAGE); } } };
fc.setDialogTitle(windowTitle + ": " + title); fc.resetChoosableFileFilters(); fc.setFileFilter(new ExtensionFileFilter(new String[] { extension })); File lastSavedAs = workflowChanges.lastFilename(model); if (lastSavedAs != null) {