@Override public FileChooser getFilechooser() throws InvalidDataTypeException, BackendException { return fileChooserFactory.getFileChooser(FILE_RECENT_PREFERENCESKEY); }
@Override public FileChooser getConfiguratonFilechooser() throws InvalidDataTypeException, BackendException { return fileChooserFactory.getFileChooser(MANAGER_FILECHOOSER_PREFS_KEY); }
@Override public void actionPerformed(ActionEvent e) { log.trace("Obtaining a file chooser"); FileChooser chooser = chooserFactory.getFileChooser(DesktopPlugIn.FILE_OPEN_PREFERENCESKEY); log.trace("Setting the recently used file menu on the chooser"); StringMenu<File> menu = menuFactory.getCachedMenu(File.class, DesktopPlugIn.FILE_RECENT_PREFERENCESKEY); chooser.setMenu(menu); log.trace("Requesting the file chooser to open a file"); File file = chooser.openFile(); log.trace("File chooser selected file: " + file); if (file != null) { try { fileOpener.openFile(file); } catch (ResourceNotFoundException resourceNotFoundException) { // TODO: Log error } } }
public void saveManager(final boolean saveAs) { try { String managerFileName = preferences.getString(PreferencesUtil.MANAGER_FILENAME_PREFS_KEY); // there is no default name or we should select a new name if ((managerFileName == null) || saveAs) { FileChooser fileChooser = fileChooserFactory.getFileChooser(PreferencesUtil.MANAGER_FILECHOOSER_PREFS_KEY); File selectedSaveFile = fileChooser.saveFile(); if (selectedSaveFile != null) { managerFileName = selectedSaveFile.getCanonicalPath(); } } // make sure it ends with .xml if (managerFileName != null) { if (!managerFileName.endsWith(".xml")) { managerFileName = managerFileName + ".xml"; } final File saveFile = new File(managerFileName); JAXBContext jc = JAXBContext.newInstance(StyleRulesManager.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty("jaxb.formatted.output", true); marshaller.marshal(manager, saveFile); manager.resetChangeStatus(); preferences.setString(PreferencesUtil.MANAGER_FILENAME_PREFS_KEY, saveFile.getCanonicalPath()); } } catch (Exception e) { workbench.getErrorReporter().reportError( messages.getMessage("nu.zoom.catonine.configurations.save.failed"), e); } }
public void importManager() { if (this.manager == null) { openManager(); } else { final FileChooser fileChooser = fileChooserFactory.getFileChooser(PreferencesUtil.MANAGER_FILECHOOSER_PREFS_KEY); File openFile = fileChooser.openFile(); if (openFile != null) { StyleRulesManager importFrom = readManager(openFile); if (importFrom != null) { workbench.startWorkIndicator(); this.manager.importManager(importFrom); workbench.stopWorkIndicator(); } } } }
public boolean openManager() { final FileChooser fileChooser = fileChooserFactory.getFileChooser(PreferencesUtil.MANAGER_FILECHOOSER_PREFS_KEY); File openFile = fileChooser.openFile(); if (openFile != null) { try { final boolean success = loadManager(openFile.getCanonicalPath()); if (success) { fireStyleRulesManagerChanged(); } return success; } catch (IOException ex) { try { String message = localizedResources.getMessage("nu.zoom.catonine.configurations.load.failed"); workbench.getErrorReporter().reportError(message, ex); } catch (ResourceNotFoundException ex1) { workbench.getErrorReporter().reportError("Unable to load resource", ex); } } } return false; }