List of usage examples for javax.swing JDialog JDialog
public JDialog(Window owner, String title, Dialog.ModalityType modalityType)
From source file:ome.formats.importer.gui.FileQueueHandler.java
/** * Retrieve the file chooser's selected reader then iterate over * each of our supplied containers filtering out those whose format * do not match those of the selected reader. * /*from w w w.j a v a2 s . c o m*/ * @param allContainers List of ImporterContainers */ private void handleFiles(List<ImportContainer> allContainers) { FileFilter selectedFilter = fileChooser.getFileFilter(); IFormatReader selectedReader = null; if (selectedFilter instanceof FormatFileFilter) { log.debug("Selected file filter: " + selectedFilter); selectedReader = ((FormatFileFilter) selectedFilter).getReader(); } List<ImportContainer> containers = new ArrayList<ImportContainer>(); for (ImportContainer ic : allContainers) { if (selectedReader == null) { // The user selected "All supported file types" containers = allContainers; break; } String a = selectedReader.getFormat(); String b = ic.getReader(); if (a.equals(b) || b == null) { containers.add(ic); } else { log.debug(String.format("Skipping %s (%s != %s)", ic.getFile().getAbsoluteFile(), a, b)); } } Boolean spw = spwOrNull(containers); if (containers.size() == 0 && !candidatesFormatException) { final JOptionPane optionPane = new JOptionPane("\nNo importable files found in this selection.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(viewer, "No Importable Files Found", true); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(viewer); errorDialog.setVisible(true); } if (candidatesFormatException) { viewer.candidateErrorsCollected(viewer); candidatesFormatException = false; } if (spw == null) { addEnabled(true); containers.clear(); return; // Invalid containers. } if (getOMEROMetadataStoreClient() != null && spw.booleanValue()) { addEnabled(true); SPWDialog dialog = new SPWDialog(config, viewer, "Screen Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.screen == null) return; for (ImportContainer ic : containers) { ic.setTarget(dialog.screen); String title = dialog.screen.getName().getValue(); addFileToQueue(ic, title, false, 0); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else if (getOMEROMetadataStoreClient() != null) { addEnabled(true); ImportDialog dialog = new ImportDialog(config, viewer, "Image Import", true, getOMEROMetadataStoreClient()); if (dialog.cancelled == true || dialog.dataset == null) return; Double[] pixelSizes = new Double[] { dialog.pixelSizeX, dialog.pixelSizeY, dialog.pixelSizeZ }; Boolean useFullPath = config.useFullPath.get(); if (dialog.useCustomNamingChkBox.isSelected() == false) useFullPath = null; //use the default bio-formats naming for (ImportContainer ic : containers) { ic.setTarget(dialog.dataset); ic.setUserPixels(pixelSizes); ic.setArchive(dialog.archiveImage.isSelected()); String title = ""; if (dialog.project.getId() != null) { ic.setProjectID(dialog.project.getId().getValue()); title = dialog.project.getName().getValue() + " / " + dialog.dataset.getName().getValue(); } else { title = "none / " + dialog.dataset.getName().getValue(); } addFileToQueue(ic, title, useFullPath, config.numOfDirectories.get()); } qTable.centerOnRow(qTable.getQueue().getRowCount() - 1); qTable.importBtn.requestFocus(); } else { addEnabled(true); JOptionPane.showMessageDialog(viewer, "Due to an error the application is unable to \n" + "retrieve an OMEROMetadataStore and cannot continue." + "The most likely cause for this error is that you" + "are not logged in. Please try to login again."); } }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display errors in import dialog /* w w w . j a va 2 s. c o m*/ * * @param frame - parent frame */ private void importErrorsCollected(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nYour import has produced one or more errors, " + "\nvisit the 'Import Errors' tab for details.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(this, "Errors Collected", false); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(frame); errorDialog.setVisible(true); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display errors in candidates dialog/*from w w w .j av a 2s .co m*/ * * @param frame - parent frame */ public void candidateErrorsCollected(Component frame) { errors_pending = false; final JOptionPane optionPane = new JOptionPane( "\nAdding these files to the queue has produced one or more errors and some" + "\n files will not be displayed on the queue. View the 'Import Errors' tab for details.", JOptionPane.WARNING_MESSAGE); final JDialog errorDialog = new JDialog(this, "Errors Collected", true); errorDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (errorDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { errorDialog.dispose(); } } }); errorDialog.toFront(); errorDialog.pack(); errorDialog.setLocationRelativeTo(frame); errorDialog.setVisible(true); }
From source file:ome.formats.importer.gui.GuiImporter.java
/** * Display failed sending errors dialog//from w ww .j a v a 2 s . c o m * * @param frame - parent frame */ public void sendingErrorsFailed(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nDue to an error we were not able to send your error messages." + "\nto our feedback server. Please try again.", JOptionPane.WARNING_MESSAGE); final JDialog failedDialog = new JDialog(this, "Feedback Failed!", true); failedDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (failedDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { failedDialog.dispose(); } } }); failedDialog.toFront(); failedDialog.pack(); failedDialog.setLocationRelativeTo(frame); failedDialog.setVisible(true); }
From source file:ome.formats.importer.gui.ImportDialog.java
/** * Dialog explaining metadata limitations when changing the main dialog's naming settings * /*from w w w .j a va 2 s . c o m*/ * @param frame - parent component */ public void sendNamingWarning(Component frame) { final JOptionPane optionPane = new JOptionPane( "\nNOTE: Some file formats do not include the file name in their metadata, " + "\nand disabling this option may result in files being imported without a " + "\nreference to their file name. For example, 'myfile.lsm [image001]' " + "\nwould show up as 'image001' with this optioned turned off.", JOptionPane.WARNING_MESSAGE); final JDialog warningDialog = new JDialog(this, "Naming Warning!", true); warningDialog.setContentPane(optionPane); optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); if (warningDialog.isVisible() && (e.getSource() == optionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY))) { warningDialog.dispose(); } } }); warningDialog.toFront(); warningDialog.pack(); warningDialog.setLocationRelativeTo(frame); warningDialog.setVisible(true); }
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * creates the help menu item if it does not already exists * //from w ww. j a v a2s .c o m * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiTextConfig.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiTextConfig.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulator.this, guiTextConfig.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiTextConfig.getString("AboutDialogTitle")); JLabel text = new JLabel(guiTextConfig.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new antenna *///from w w w. java 2s.c o m private void showAddAntennaDialog() { Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; if (newAntennaDialog == null) { newAntennaDialog = new JDialog(this, guiTextConfig.getString("AddNewAntennaDialogTitle"), true); newAntennaDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newAntennaDialog.setLayout(new BorderLayout()); // input fields JLabel idLabel = new JLabel(guiTextConfig.getString("AntennaIdLabel") + ": "); final JTextField idField = new JTextField(); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(idLabel); inputFields.add(idField); // cancel button JButton cancelButton = new JButton(guiTextConfig.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); idField.setText(""); } }); // add button JButton addButton = new JButton(guiTextConfig.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); createNewAntenna(idField.getText()); idField.setText(""); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); newAntennaDialog.add(inputFields, BorderLayout.CENTER); newAntennaDialog.add(buttons, BorderLayout.SOUTH); newAntennaDialog.getRootPane().setDefaultButton(addButton); } newAntennaDialog.setLocation(pos); newAntennaDialog.setVisible(true); }
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new tag *///from w ww . jav a2 s .c om private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = propsConfig.getString("TagPrefix"); for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiTextConfig.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiTextConfig.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiTextConfig.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiTextConfig.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item//from w w w.ja v a 2s. c o m * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiTextConfig.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiTextConfig.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiTextConfig.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiTextConfig.getString("AboutDialogTitle")); JLabel text = new JLabel(guiTextConfig.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * shows the dialog menu to add a new tag */// ww w. ja va2 s . c om private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = "A47033F"; for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiTextConfig.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiTextConfig.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiTextConfig.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiTextConfig.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }