/** * Constructs an "Import" file chooser with the given title and the given reader plug-in. * * @param title the dialog title, must not be <code>null</code> * @param readerPlugIn the reader plug-in for a particular product type, must not be <code>null</code> */ public ProductFileChooser(String title, ProductReaderPlugIn readerPlugIn) { Guardian.assertNotNullOrEmpty("title", title); Guardian.assertNotNull("readerPlugIn", readerPlugIn); _readerPlugIn = readerPlugIn; setCurrentFilename("noname"); setDialogTitle(title); setFileSelectionMode(JFileChooser.FILES_ONLY); // setAcceptAllFileFilterUsed(true); addChoosableFileFilter(new BeamFileFilter()); createUI(); }
if (isImportDialog()) { File file = getSelectedFile(); if (file != null) { _product = readProductNodes(file); _productSubsetDef = null; ProductSubsetDialog dialog = new ProductSubsetDialog(getWindow(), _product, _productSubsetDef _productSubsetDef = dialog.getProductSubsetDef(); if (getCurrentFilename() != null && !getCurrentFilename().startsWith("subset_")) { setCurrentFilename("subset_" + getCurrentFilename()); updateUIState();
/** * Constructs an "Export" file chooser with the given title and for the given product. * * @param title the dialog title, must not be <code>null</code> * @param product the product to export, must not be <code>null</code> */ public ProductFileChooser(String title, Product product) { Guardian.assertNotNullOrEmpty("title", title); Guardian.assertNotNull("product", product); setProduct(product); setDialogTitle(title); setFileSelectionMode(JFileChooser.FILES_ONLY); // setAcceptAllFileFilterUsed(true); createUI(); }
fileChooser = new ProductFileChooser(title, product); fileChooser.addChoosableFileFilter(writerPlugin.getProductFileFilter()); fileChooser.setFileFilter(writerPlugin.getProductFileFilter()); HelpSys.enableHelpKey(fileChooser, getHelpId()); } else { fileChooser.setProduct(product); fileChooser.clearProductSubsetDef(); fileChooser.setCurrentDirectory(currentDir); final ProductSubsetDef productSubsetDef = fileChooser.getProductSubsetDef(); if (productSubsetDef != null) { final String subsetName = productSubsetDef.getSubsetName();
if (isImportDialog()) { _product = null; _productSubsetDef = null; File selectedFile = getSelectedFile(); if (selectedFile != null && !selectedFile.isFile()) { selectedFile = null; if (isImportDialog()) { setDialogType(JFileChooser.OPEN_DIALOG); _subsetButton.setEnabled(selectedFile != null); if (_productSubsetDef != null) { setApproveButtonText("Import Subset"); /*I18N*/ setApproveButtonMnemonic('I');/*I18N*/ setApproveButtonToolTipText("Imports the specified subset of the product.");/*I18N*/ } else { setApproveButtonText("Import Product");/*I18N*/ setApproveButtonMnemonic('I');/*I18N*/ setApproveButtonToolTipText("Imports the entire product.");/*I18N*/ setDialogType(JFileChooser.SAVE_DIALOG); _subsetButton.setEnabled(_product != null); if (_productSubsetDef != null) { setApproveButtonText("Export Subset"); /*I18N*/ setApproveButtonMnemonic('E');/*I18N*/ setApproveButtonToolTipText("Exports the specified subset of the product.");/*I18N*/ } else { setApproveButtonText("Export Product");/*I18N*/ setApproveButtonMnemonic('E');/*I18N*/
GridBagUtils.addVerticalFiller(accessoryPane, gbc); setAccessory(accessoryPane); addPropertyChangeListener(new PropertyChangeListener() { ProductFileChooser.this.setPreferredSize(new Dimension(640, 400)); updateUIState();
protected File promptForFile(final Product product) { final BasicApp.MainFrame parent = getVisatApp().getMainFrame(); if (fileChooser.showDialog(parent, null) == JFileChooser.APPROVE_OPTION) { final File selectedFile = fileChooser.getSelectedFile(); if (selectedFile != null && selectedFile.getParent() != null) { getVisatApp().getPreferences().setPropertyString(lastDirKey, selectedFile.getParent()); } return selectedFile; } return null; }
private Product readProductNodes(final File file) { final ProductReader reader = _readerPlugIn.createReaderInstance(); Product product = null; Cursor cursor = UIUtils.setRootFrameWaitCursor(this); try { product = reader.readProductNodes(file, null); UIUtils.setRootFrameCursor(this, cursor); } catch (IOException e) { UIUtils.setRootFrameCursor(this, cursor); JOptionPane.showMessageDialog(getWindow(), "Product I/O Error:\n" + "'" + e.getMessage() + "'", "Product I/O Error", JOptionPane.ERROR_MESSAGE); } return product; } }