Example usage for javax.swing JDialog toFront

List of usage examples for javax.swing JDialog toFront

Introduction

In this page you can find the example usage for javax.swing JDialog toFront.

Prototype

public void toFront() 

Source Link

Document

If this Window is visible, brings this Window to the front and may make it the focused Window.

Usage

From source file:com.aw.swing.mvp.JDialogView.java

public void unHide() {
    JDialog dlg = (JDialog) parentContainer;
    dlg.setSize(size);
    dlg.toFront();
}

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 ww. j  a  v  a 2 s  .  co  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  .ja v a2  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   ww w.j a  v a2 s. com
 * 
 * @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//w ww .  ja  v a2  s.  com
 * 
 * @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   ww w .  ja  v a 2 s.co 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:tvbrowser.ui.mainframe.MainFrame.java

private void quit(boolean log, boolean export) {
    mTimer.stop(); // disable the update timer to avoid new update events
    if (log && downloadingThread != null && downloadingThread.isAlive()) {
        final JDialog info = new JDialog(UiUtilities.getLastModalChildOf(this));
        info.setModal(true);//from  www.j ava  2 s . c om
        info.setUndecorated(true);
        info.toFront();

        JPanel main = new JPanel(new FormLayout("5dlu,pref,5dlu", "5dlu,pref,5dlu"));
        main.setBorder(BorderFactory.createLineBorder(Color.black));
        main.add(
                new JLabel(mLocalizer.msg("downloadinfo",
                        "A data update is running. TV-Browser will be closed when the update is done.")),
                new CellConstraints().xy(2, 2));

        info.setContentPane(main);
        info.pack();
        info.setLocationRelativeTo(this);

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                if (downloadingThread != null && downloadingThread.isAlive()) {
                    try {
                        downloadingThread.join();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                info.setVisible(false);
                info.dispose();
            }
        });

        info.setVisible(true);
    }
    if (log && this.isUndecorated()) {
        switchFullscreenMode();
    }
    if (mShuttingDown) {
        return;
    }
    mShuttingDown = true;

    if (log) {
        FavoritesPlugin.getInstance().handleTvBrowserIsShuttingDown();
    }

    if (log) {
        mLog.info("Finishing plugins");
    }
    PluginProxyManager.getInstance().shutdownAllPlugins(log);

    if (log) {
        mLog.info("Storing dataservice settings");
    }
    TvDataServiceProxyManager.getInstance().shutDown();

    FavoritesPlugin.getInstance().store();
    ReminderPlugin.getInstance().store();

    TVBrowser.shutdown(log);

    if (log) {
        mLog.info("Closing TV data base");
    }

    try {
        TvDataBase.getInstance().close();
    } catch (Exception exc) {
        if (log) {
            mLog.log(Level.WARNING, "Closing database failed", exc);
        }
    }

    if (export) {
        Settings.propTVDataDirectory.resetToDefault();
        Settings.copyToSystem();
    }

    if (log) {
        mLog.info("Quitting");
        System.exit(0);
    }
}