Example usage for javax.swing JOptionPane WARNING_MESSAGE

List of usage examples for javax.swing JOptionPane WARNING_MESSAGE

Introduction

In this page you can find the example usage for javax.swing JOptionPane WARNING_MESSAGE.

Prototype

int WARNING_MESSAGE

To view the source code for javax.swing JOptionPane WARNING_MESSAGE.

Click Source Link

Document

Used for warning messages.

Usage

From source file:interfaces.InterfazPrincipal.java

private void tablaUsuariosDelSistemaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaUsuariosDelSistemaMouseClicked
    // TODO add your handling code here:
    String opcionHabilitar = "Habilitar";
    String nombreUsuario = String
            .valueOf(tablaUsuariosDelSistema.getValueAt(tablaUsuariosDelSistema.getSelectedRow(), 0));
    String estado = String
            .valueOf(tablaUsuariosDelSistema.getValueAt(tablaUsuariosDelSistema.getSelectedRow(), 2));
    if (estado.equals("Habilitado")) {
        opcionHabilitar = "Deshabilitar";
    }//from  w  w w  . j  a va 2 s .c  o  m
    Object[] opciones = { "Cancelar", "Editar", opcionHabilitar };
    final ControladorUsuarios controladorUsuarios = new ControladorUsuarios();
    final Usuarios usuarioSelecionado = controladorUsuarios.obtenerUsuario(nombreUsuario);
    if (nombreUsuario.equals("admin") || nombreUsuario.equals(JTextFieldnombreDeUsuario.getText())) {
        JOptionPane.showMessageDialog(this,
                "No se puede editarse a si mismo o el usuario administrador del sistema", "Mensaje del sistema",
                JOptionPane.WARNING_MESSAGE);
    } else {
        int opcionElegida = JOptionPane.showOptionDialog(this, "Por favor elija una opcin", "Editar cliente",
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE, null, opciones, null);
        switch (opcionElegida) {
        case 1:
            final JDialog dialogoEditar = new JDialog(this);
            dialogoEditar.setTitle("Editar usuario");
            dialogoEditar.setSize(400, 310);
            dialogoEditar.setResizable(false);
            JPanel panelDialogo = new JPanel();
            panelDialogo.setLayout(new GridBagLayout());
            GridBagConstraints c = new GridBagConstraints();
            c.fill = GridBagConstraints.HORIZONTAL;
            JLabel editarTextoPrincipalDialogo = new JLabel("Editar clientes");
            c.gridx = 0;
            c.gridy = 0;
            c.gridwidth = 2;
            c.insets = new Insets(15, 10, 40, 0);
            c.ipadx = 0;
            Font textoGrande = new Font("Arial", 1, 18);
            editarTextoPrincipalDialogo.setFont(textoGrande);
            panelDialogo.add(editarTextoPrincipalDialogo, c);
            c.insets = new Insets(0, 5, 10, 0);
            c.gridx = 0;
            c.gridy = 1;
            c.gridwidth = 1;
            c.ipadx = 0;
            JLabel editarNombreClienteDialogo = new JLabel("Login:");
            panelDialogo.add(editarNombreClienteDialogo, c);
            final JTextField valorEditarNombreClienteDialogo = new JTextField();
            c.gridx = 1;
            c.gridy = 1;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            valorEditarNombreClienteDialogo.setText(usuarioSelecionado.getLogin());
            panelDialogo.add(valorEditarNombreClienteDialogo, c);
            c.gridx = 0;
            c.gridy = 2;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            JLabel editarPasswordClienteDialogo = new JLabel("Contrasea:");
            panelDialogo.add(editarPasswordClienteDialogo, c);
            final JTextField valoreditarPasswordClienteDialogo = new JTextField();
            c.gridx = 1;
            c.gridy = 2;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            panelDialogo.add(valoreditarPasswordClienteDialogo, c);
            c.gridx = 0;
            c.gridy = 3;
            c.gridwidth = 2;
            c.ipadx = 0;
            c.insets = new Insets(0, 5, 10, 0);
            JLabel mensajeEditarPassword = new JLabel(
                    "Si no desea editar la contrasea deje este espacio en blanco:");
            panelDialogo.add(mensajeEditarPassword, c);
            c.gridx = 0;
            c.gridy = 4;
            c.gridwidth = 1;
            c.ipadx = 0;
            c.insets = new Insets(0, 15, 10, 15);
            JButton botonGuardarClienteDialogo = new JButton("Guardar");
            panelDialogo.add(botonGuardarClienteDialogo, c);
            c.gridx = 1;
            c.gridy = 4;
            c.gridwidth = 1;
            c.insets = new Insets(0, 15, 10, 15);
            c.ipadx = 0;
            JButton botonCerrarClienteDialogo = new JButton("Cancelar");
            panelDialogo.add(botonCerrarClienteDialogo, c);
            botonCerrarClienteDialogo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    dialogoEditar.dispose();
                }
            });
            botonGuardarClienteDialogo.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    String nombreUsuario = valorEditarNombreClienteDialogo.getText();
                    usuarioSelecionado.setLogin(nombreUsuario);
                    if (!valoreditarPasswordClienteDialogo.getText().equals("")) {
                        usuarioSelecionado.setPassword(valoreditarPasswordClienteDialogo.getText());
                    }
                    controladorUsuarios.modificarUsuario(usuarioSelecionado.getUser_id(),
                            usuarioSelecionado.getLogin(), usuarioSelecionado.getPassword());
                    JOptionPane.showMessageDialog(dialogoEditar, "Se ha modificado el usuario con xito",
                            "Mensaje del sistema", JOptionPane.INFORMATION_MESSAGE);
                    generarTablaUsuarios();
                    dialogoEditar.dispose();
                }
            });
            dialogoEditar.add(panelDialogo);
            dialogoEditar.setVisible(true);
            break;
        case 2:
            if (estado.equals("Habilitado")) {
                usuarioSelecionado.setStatus('i');
            } else {
                usuarioSelecionado.setStatus('e');
            }
            controladorUsuarios.modificarEstadoUsuario(usuarioSelecionado);
            JOptionPane.showMessageDialog(this, "Se ha cambiado el estado del usuario", "Mensaje del sistema",
                    JOptionPane.INFORMATION_MESSAGE);
            generarTablaUsuarios();
            break;
        default:
            break;
        }
    } // TODO add your handling code here:

}

From source file:lu.fisch.unimozer.Diagram.java

private boolean saveWithAskingLocation() {
    OpenProject op = new OpenProject(new File(getContainingDirectoryName()), false);
    //op.setSelectedFile(new File(new File(getDirectoryName()).getName()));
    //op.set/* w w  w.j a v a  2 s  . com*/
    int result = op.showSaveDialog(frame, "Save");
    if (result == OpenProject.APPROVE_OPTION) {
        String dirName = op.getSelectedFile().getAbsolutePath().toString();
        File myDir = new File(dirName);
        if (myDir.exists()) {
            JOptionPane.showMessageDialog(frame,
                    "The selected project or directory already exists.\nPlease choose another one ...",
                    "New project", JOptionPane.WARNING_MESSAGE, Unimozer.IMG_WARNING);
            return false;
        } else {
            boolean created = myDir.mkdir();
            if (created == false) {
                JOptionPane.showMessageDialog(frame,
                        "Error while creating the projet directory.\n"
                                + "The project name you specified is probably not valid!\n",
                        "Save project as ...", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR);
                return false;
            } else {
                try {
                    //System.out.println(dirName);
                    diagram.save(dirName);
                    setChanged(false);
                    return true;
                } catch (Exception e) {
                    JOptionPane.showMessageDialog(frame, "An unknown error occured while saving your projet!\n",
                            "Save project as ...", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR);
                    return false;
                }
            }
        }
    }
    return false;

}

From source file:atlas.kingj.roi.FrmMain.java

public void DoLicenceCheck() {

    File[] licences = searchLCS();
    if (licences == null || licences.length < 1) {
        JOptionPane.showMessageDialog(frmTitanRoiCalculator,
                "Could not find a licence file. \nPlease put a valid \".lcs\" file in the same folder as this tool and try again.",
                "No licence", JOptionPane.ERROR_MESSAGE);
        System.exit(0);/* w  w w  .j  a v a  2 s .c o  m*/
    }
    for (int i = 0; i < licences.length; ++i) {
        Security checker = new Security(1, licences[i]);
        boolean result = checker.CheckLicence();
        if (result) {
            long currtime = System.currentTimeMillis();
            long timestart = checker.getStartTimestamp();
            long timeend = checker.getEndTimestamp();
            if (currtime < timestart || currtime > timeend) {
                JOptionPane.showMessageDialog(frmTitanRoiCalculator,
                        "The licence \"" + licences[i].getAbsolutePath()/*getName()*/
                                + "\" has expired. Please contact the software provider for more information.",
                        "Licence expired", JOptionPane.WARNING_MESSAGE);
            } else {
                SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
                Date time1 = new Date(timeend);
                String time1f = sdf.format(time1);
                time1f = "\".  Valid until " + time1f + ".";
                boolean unlim = false;
                if (timeend == Long.MAX_VALUE)
                    unlim = true;
                ShowMessageStandard("Loaded licence file \"" + licences[i].getAbsolutePath()
                        + (unlim ? "\".  Unlimited licence." : time1f));
                return;
            }
        }
    }
    // no valid licence
    JOptionPane.showMessageDialog(frmTitanRoiCalculator,
            "No valid licence file found on this machine. Please contact the software provider for more information.",
            "No licence", JOptionPane.ERROR_MESSAGE);
    System.exit(0);

}

From source file:net.technicpack.launcher.ui.LauncherFrame.java

protected void launchModpack() {
    ModpackModel pack = modpackSelector.getSelectedPack();
    boolean requiresInstall = false;

    if (pack == null || (pack.getInstalledPack() == null
            && (pack.getPackInfo() == null || !pack.getPackInfo().isComplete())))
        return;/*w w w . j av a 2s .c om*/

    if (pack.getInstalledDirectory() == null) {
        requiresInstall = true;
        pack.save();
        modpackSelector.forceRefresh();
    }

    if (requiresInstall) {
        try {
            if (pack.getPackInfo().shouldForceDirectory()
                    && FilenameUtils.directoryContains(directories.getLauncherDirectory().getCanonicalPath(),
                            pack.getInstalledDirectory().getCanonicalPath())) {
                JFileChooser chooser = new JFileChooser(directories.getLauncherDirectory());
                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                chooser.setCurrentDirectory(directories.getLauncherDirectory());
                int result = chooser.showOpenDialog(this);

                if (result == JFileChooser.APPROVE_OPTION) {
                    File file = chooser.getSelectedFile();

                    if (file.list().length > 0) {
                        JOptionPane.showMessageDialog(this,
                                resources.getString("modpackoptions.move.errortext"),
                                resources.getString("modpackoptions.move.errortitle"),
                                JOptionPane.WARNING_MESSAGE);
                        return;
                    } else if (FileUtils.directoryContains(directories.getLauncherDirectory(), file)) {
                        JOptionPane.showMessageDialog(this, resources.getString("launcher.launch.requiresmove"),
                                resources.getString("launcher.launch.requiretitle"),
                                JOptionPane.WARNING_MESSAGE);
                        return;
                    }

                    pack.setInstalledDirectory(file);
                }
            }
        } catch (IOException ex) {
            Utils.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
        }
    }

    boolean forceInstall = false;
    Version installedVersion = pack.getInstalledVersion();

    //Force a full install (check cache, redownload, unzip files) if we have no current installation of this modpack
    if (installedVersion == null)
        forceInstall = true;
    else if (pack.getBuild() != null && !pack.isLocalOnly()) {

        //Ask the user if they want to update to the newer version if:
        //1- the pack build is RECOMMENDED & the recommended version is diff from the installed version
        //2- the pack build is LATEST & the latest version is diff from the installed version
        //3- the pack build is neither LATEST or RECOMMENDED & the pack build is diff from the installed version
        boolean requestInstall = false;
        if (pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED)
                && pack.getPackInfo().getRecommended() != null
                && !pack.getPackInfo().getRecommended().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;
        else if (pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST)
                && pack.getPackInfo().getLatest() != null
                && !pack.getPackInfo().getLatest().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;
        else if (!pack.getBuild().equalsIgnoreCase(InstalledPack.RECOMMENDED)
                && !pack.getBuild().equalsIgnoreCase(InstalledPack.LATEST)
                && !pack.getBuild().equalsIgnoreCase(installedVersion.getVersion()))
            requestInstall = true;

        //If the user says yes, update, then force a full install
        if (requestInstall) {
            int result = JOptionPane.showConfirmDialog(this, resources.getString("launcher.install.query"),
                    resources.getString("launcher.install.query.title"), JOptionPane.YES_NO_OPTION,
                    JOptionPane.INFORMATION_MESSAGE);

            if (result == JOptionPane.YES_OPTION) {
                forceInstall = true;
            }
        }
    }

    //If we're forcing an install, then derive the installation build from the pack build
    //otherwise, just use the installed version
    String installBuild = null;
    if (forceInstall && !pack.isLocalOnly()) {
        installBuild = pack.getBuild();

        if (installBuild.equalsIgnoreCase(InstalledPack.RECOMMENDED))
            installBuild = pack.getPackInfo().getRecommended();
        else if (installBuild.equalsIgnoreCase(InstalledPack.LATEST))
            installBuild = pack.getPackInfo().getLatest();
    } else
        installBuild = installedVersion.getVersion();

    if (requiresInstall) {
        installer.justInstall(resources, pack, installBuild, forceInstall, this, installProgress);
    } else {
        installer.installAndRun(resources, pack, installBuild, forceInstall, this, installProgress);
    }

    installProgress.setVisible(true);
    installProgressPlaceholder.setVisible(false);
    userChanged(userModel.getCurrentUser());
    invalidate();
}

From source file:net.ytbolg.mcxa.MCLaucherXA.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    GameInfo.lauchArg = jComboBox1.getSelectedItem().toString();
    // jButton2.setVisible(false);
    if (jList1.getSelectedIndex() == -1) {
        JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoselectVersion"),
                Lang.getLang("Main_NoselectVersionTitle"), JOptionPane.WARNING_MESSAGE);
        return;/*from w w  w.j av a 2  s . com*/
    }

    //    System.out.println("a");
    if (jTextField1.getText().equals("")) {
        JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoUserName"), Lang.getLang("Main_Error"),
                JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (jTextField2.getText().equals("")) {
        JOptionPane.showMessageDialog(null, Lang.getLang("Main_NoMemory"), Lang.getLang("Main_Error"),
                JOptionPane.WARNING_MESSAGE);
        return;
    }
    GameInfo.memory = jTextField2.getText();
    Config.setConfig("username", jTextField1.getText());
    Config.setConfig("lastgameversion", String.valueOf(jList1.getSelectedIndex()));
    Config.setConfig("lastmemory", jTextField2.getText());
    Config.setConfig("iszhengban", String.valueOf(jCheckBox1.isSelected()));
    Config.setConfig("zhengbanmima", String.valueOf(jPasswordField1.getPassword()));
    ////    //    System.out.println(GameInfo.Rundir + tpf + "MCXA.cfg");
    Config.Save();
    YggdrasilCheck y = YggdrasilCheck.getThis();
    String name = jTextField1.getText();
    try {
        if (jCheckBox1.isSelected()) {
            JSONObject j = new JSONObject(y.login(
                    y.GenLoginJson(jTextField1.getText(), String.valueOf(jPasswordField1.getPassword()))));
            if (j.has("errorMessage")) {
                JOptionPane.showMessageDialog(null,
                        Lang.getLang("Main_LoginFaild") + "\n" + j.getString("errorMessage"),
                        Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE);
            }
            System.out.println(j.toString());
            name = new JSONObject(j.getString("selectedProfile")).getString("name");
            //  GameInfo.uuid=j.get("clientToken");
            GameInfo.token = j.getString("accessToken");
            //  System.out.println(j);

            GameInfo.uuid = j.getJSONObject("selectedProfile").getString("id");
            if (j.has("user")) {
                JSONObject j2 = j.getJSONObject("user");
                if (j2.has("properties")) {

                    JSONArray ja = j2.getJSONArray("properties");
                    System.out.println(ja);
                    for (int y1 = 0; y1 < ja.length(); y1++) {
                        JSONObject jo3 = ja.getJSONObject(y1);
                        if (jo3.getString("name").equals("twitch_access_token")) {
                            System.out.println(jo3);
                            GameInfo.twitchToken = "{\"twitch_access_token\":\"[" + jo3.getString("value")
                                    + "\"]}";
                        }
                    }
                }
            }

        }

    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, Lang.getLang("Main_LoginFaild") + "\n" + ex,
                Lang.getLang("Main_Error"), JOptionPane.WARNING_MESSAGE);
        return;
        //  Logger.getLogger(MCLaucherXA.class.getName()).log(Level.SEVERE, null, ex);
    } catch (JSONException ex) {
        JOptionPane.showMessageDialog(null, Lang.getLang("Main_LoginFaild"), Lang.getLang("Main_Error"),
                JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (GameInfo.twitchToken.equals("")) {
        GameInfo.twitchToken = "{}";
    }
    //GameInfo.token="auth_access_token";
    GameInfo.UserName = name;
    LauchInfoWindow.version = jList1.getSelectedValue().toString();
    new LauchInfoWindow().setVisible(true);
}

From source file:nl.detoren.ijsco.ui.Mainscreen.java

public void ShowWarning(String warning) {
    /*      JPanel p = new JPanel(new BorderLayout());
          DefaultTableModel tableModel = new DefaultTableModel();
          tableModel.addColumn("Selection", new Object[] { "A", "B", "C" });
            //from w  ww.  ja v a 2  s  .co  m
          JTable table = new JTable(tableModel);
          ListSelectionModel selectionModel = table.getSelectionModel();
          p.add(table, BorderLayout.CENTER);
    */
    Object[] options = { "OK" };
    int option = JOptionPane.showOptionDialog(null, warning, "Warning", JOptionPane.DEFAULT_OPTION,
            JOptionPane.WARNING_MESSAGE, null, options, options[0]);

    //int option = JOptionPane.showConfirmDialog(null, warning, "Warning", , JOptionPane.ERROR_MESSAGE);
    if (option == 0) {
        return;
    }

}

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 ww  w.  j  av  a  2 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.FileQueueHandler.java

@SuppressWarnings("unchecked")
public void update(IObservable observable, ImportEvent event) {
    final OMEROMetadataStoreClient store = viewer.getLoginHandler().getMetadataStore();

    if (event instanceof ome.formats.importer.util.ErrorHandler.EXCEPTION_EVENT) {
        viewer.getErrorHandler().update(observable, event);

        if (event instanceof ome.formats.importer.util.ErrorHandler.UNKNOWN_FORMAT
                && fileChooser.getSelectedFiles().length == 1 && fileChooser.getSelectedFile().isFile()) {
            JOptionPane.showMessageDialog(viewer,
                    "This file's format is not recognized. \n" + "Perhaps the file is damaged?",
                    "Unknown Format", JOptionPane.WARNING_MESSAGE);
        }//from   ww  w .  j  av a 2  s . com

        if (event instanceof ome.formats.importer.util.ErrorHandler.FILE_EXCEPTION) {
            candidatesFormatException = true;
        }
    }

    if (event instanceof ome.formats.importer.util.ErrorHandler.MISSING_LIBRARY) {
        JOptionPane.showMessageDialog(viewer, "You appear to be missing a required library needed for \n"
                + "this file import. See the debug log messages for details.");
    }

    else if (event instanceof ImportCandidates.SCANNING) {
        addEnabled(false);

        ImportCandidates.SCANNING ev = (ImportCandidates.SCANNING) event;
        if (scanEx.isShutdown() || cancelScan) {
            log.info("Cancelling scan");
            ev.cancel();
            cancelScan = false;
        }

        if (ev.totalFiles < 0) {
            if (progressDialog == null) {
                double layoutTable[][] = { { 10, 180, 100, 10 }, // columns
                        { 5, 20, 5, 30, 5 } }; // rows

                progressDialog = new JDialog(viewer, "Processing Files");
                progressDialog.setSize(300, 90);
                progressDialog.setLocationRelativeTo(viewer);
                TableLayout layout = new TableLayout(layoutTable);
                progressDialog.setLayout(layout);
                directoryProgressBar = new JProgressBar();
                directoryProgressBar.setString("Please wait.");
                directoryProgressBar.setStringPainted(true);
                directoryProgressBar.setIndeterminate(true);
                progressDialog.add(directoryProgressBar, "1,1,2,1");
                JButton cancelBtn = new JButton("Cancel");

                progressDialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

                cancelBtn.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent event) {
                        cancelScan = true;
                        progressDialog.dispose();
                        progressDialog = null;
                        addEnabled(true);
                    }
                });

                progressDialog.add(cancelBtn, "2,3,R,C");
                progressDialog.getRootPane().setDefaultButton(cancelBtn);
                progressDialog.setVisible(true);
                progressDialog.toFront();
            }
        } else {
            if (progressDialog != null) {
                updateProgress(ev.totalFiles, ev.numFiles);
            }

            if (ev.totalFiles == ev.numFiles && progressDialog != null) {
                progressDialog.dispose();
                progressDialog = null;
                addEnabled(true);
            }
        }

        viewer.appendToOutput(
                "Processing files: Scanned " + ev.numFiles + " of " + ev.totalFiles + " total.\n");

        log.debug(ev.toLog());

    }

    else if (event instanceof ImportEvent.REIMPORT) {

        String objectName = "", projectName = "", fileName = "";
        Long objectID = 0L, projectID = 0L;
        File file = null;
        Integer finalCount = 0;
        IObject object;

        int[] selectedRows = null;

        if (historyTable != null)
            selectedRows = historyTable.eTable.getSelectedRows();

        for (int r : selectedRows) {
            Vector row = new Vector();

            objectID = (Long) historyTable.table.getValueAt(r, 5);
            projectID = (Long) historyTable.table.getValueAt(r, 6);

            fileName = (String) historyTable.table.getValueAt(r, 0);
            file = new File((String) historyTable.table.getValueAt(r, 4));

            if (projectID == null || projectID == 0) {
                object = null;

                try {
                    object = store.getTarget(Screen.class, objectID);
                    objectName = ((Screen) object).getName().getValue();
                } catch (Exception e) {
                    log.warn("Failed to retrieve screen: " + objectID, e);
                    continue;
                }
            } else {
                object = null;
                try {
                    object = store.getTarget(Dataset.class, objectID);
                    objectName = ((Dataset) object).getName().getValue();
                } catch (Exception e) {
                    log.warn("Failed to retrieve dataset: " + objectID, e);
                    continue;
                }

                try {
                    projectName = store.getProject(projectID).getName().getValue();
                } catch (Exception e) {
                    log.warn("Failed to retrieve project: " + projectID, e);
                    continue;
                }
            }

            // TODO: The 6th parameter should be 'format', not 'fileName'!
            ImportContainer container = new ImportContainer(file, projectID, object, cancelScan, null, fileName,
                    null, cancelScan);

            finalCount = finalCount + 1;

            Double[] pixelSizes = new Double[] { 1.0, 1.0, 1.0 };

            row.add(fileName);
            if (projectID == null || projectID == 0) {
                row.add(objectName);
            } else {
                row.add(projectName + "/" + objectName);
            }
            // WHY ISN'T THIS CODE USING addFiletoQueue?!!?
            row.add("added");
            row.add(container);
            row.add(file);
            row.add(false);
            row.add(projectID);
            row.add(pixelSizes);
            qTable.getTable().addRow(row);
        }

        if (finalCount == 0) {
            JOptionPane.showMessageDialog(viewer,
                    "None of the images in this history\n" + "list can be reimported.");
        } else if (finalCount == 1) {
            JOptionPane.showMessageDialog(viewer, "One of the images in this history list has been\n"
                    + "re-added to the import queue for reimport.");
        } else if (finalCount > 1) {
            JOptionPane.showMessageDialog(viewer,
                    finalCount + " images in this history list have been re-added\n"
                            + "to the import queue for reimport.");
        }

        if (qTable.getTable().getRowCount() > 0)
            qTable.importBtn.setEnabled(true);
        qTable.importBtn.doClick();
    }
}

From source file:ome.formats.importer.gui.GuiImporter.java

private void showLogoutMessage() {
    JOptionPane.showMessageDialog(this,
            "You have been logged out of the importer.\n" + "Choose 'login' from the file menu to continue.",
            "Warning", JOptionPane.WARNING_MESSAGE);
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display errors in import dialog //www .  j av a  2s  .  c  om
 * 
 * @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);
}