Example usage for javax.swing JOptionPane YES_OPTION

List of usage examples for javax.swing JOptionPane YES_OPTION

Introduction

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

Prototype

int YES_OPTION

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

Click Source Link

Document

Return value from class method if YES is chosen.

Usage

From source file:de.tor.tribes.ui.views.DSWorkbenchChurchFrame.java

private void bbCopySelection() {
    try {//from   w ww  .java 2s . c  o  m
        int[] rows = jChurchTable.getSelectedRows();
        if (rows.length == 0) {
            return;
        }

        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this,
                "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code",
                "Nein", "Ja") == JOptionPane.YES_OPTION);

        StringBuilder buffer = new StringBuilder();
        if (extended) {
            buffer.append("[u][size=12]Kirchendrfer[/size][/u]\n\n");
        } else {
            buffer.append("[u]Kirchendrfer[/u]\n\n");
        }

        buffer.append("[table]\n");
        buffer.append("[**]Spieler[||]Dorf[||]Radius[/**]\n");

        for (int row1 : rows) {
            int row = jChurchTable.convertRowIndexToModel(row1);
            int tribeCol = jChurchTable.convertColumnIndexToModel(0);
            int villageCol = jChurchTable.convertColumnIndexToModel(1);
            int rangeCol = jChurchTable.convertColumnIndexToModel(2);
            buffer.append("[*]").append(((Tribe) jChurchTable.getModel().getValueAt(row, tribeCol)).toBBCode())
                    .append("[|]")
                    .append(((Village) jChurchTable.getModel().getValueAt(row, villageCol)).toBBCode())
                    .append("[|]").append(jChurchTable.getModel().getValueAt(row, rangeCol));
        }

        buffer.append("[/table]");

        if (extended) {
            buffer.append("\n[size=8]Erstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n");
        } else {
            buffer.append("\nErstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n");
        }

        String b = buffer.toString();
        StringTokenizer t = new StringTokenizer(b, "[");
        int cnt = t.countTokens();
        if (cnt > 1000) {
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Die ausgewhlten Kirchen bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\n"
                            + "Trotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        String result = "Daten in Zwischenablage kopiert.";
        showSuccess(result);
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        String result = "Fehler beim Kopieren in die Zwischenablage.";
        showError(result);
    }
}

From source file:com.floreantpos.ui.views.SwitchboardView.java

protected void doAssignDriver() {
    try {//  ww  w  .  j a v  a  2  s . co  m

        Ticket ticket = getFirstSelectedTicket();

        if (ticket == null) {
            return;
        }

        if (!ticket.getOrderType().isDelivery()) {
            POSMessageDialog.showError(this, Messages.getString("SwitchboardView.8")); //$NON-NLS-1$
            return;
        }

        User assignedDriver = ticket.getAssignedDriver();
        if (assignedDriver != null) {
            int option = JOptionPane.showOptionDialog(Application.getPosWindow(),
                    Messages.getString("SwitchboardView.9"), POSConstants.CONFIRM, //$NON-NLS-1$
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);

            if (option != JOptionPane.YES_OPTION) {
                return;
            }
        }

        orderServiceExtension.assignDriver(ticket.getId());
    } catch (Exception e) {
        PosLog.error(getClass(), e);
        POSMessageDialog.showError(this, e.getMessage());
        LogFactory.getLog(SwitchboardView.class).error(e);
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchTagFrame.java

private void removeSelectedTags() {
    List<Tag> selection = getSelectedTags();
    if (selection.isEmpty()) {
        showInfo("Keine Gruppe ausgewhlt");
        return;// ww w.j ava2s.  c  o  m
    }

    if (JOptionPaneHelper.showQuestionConfirmBox(this, "Willst du die gewhlte"
            + ((selection.size() == 1) ? " Gruppe " : "n Gruppen ") + "wirklich lschen?", "Lschen", "Nein",
            "Ja") == JOptionPane.YES_OPTION) {
        TagManager.getSingleton().invalidate();
        for (Tag t : selection) {
            TagManager.getSingleton().removeElement(t);
        }
        TagManager.getSingleton().revalidate(true);
        showSuccess("Gruppe(n) erfolgreich gelscht");
    }
}

From source file:com.edduarte.protbox.Protbox.java

private static void changeProtPath(PReg reg, File serializedDirectory) throws ProtboxException {

    if (JOptionPane.showConfirmDialog(null,
            "The prot folder from one of your registries\n" + "was deleted while Protbox wasn't running!\n"
                    + "Do you wish to set a new folder to place the decoded files from the shared folder?\n"
                    + "CHOOSING \"NO\" WILL DELETE THE REGISTRY AND YOU WILL LOSE ACCESS TO THE FILES "
                    + "IN THE SHARED FOLDER!",
            "Prot Folder was deleted!", JOptionPane.YES_NO_OPTION,
            JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
        final DirectoryChooser chooser = new DirectoryChooser("Choose Output folder...");
        String newOutputPath = chooser.getDirectory();
        if (newOutputPath != null) {
            reg.changeProtPath(newOutputPath);
        } else {// ww  w . java2s  .  c o  m
            changeProtPath(reg, serializedDirectory);
        }

    } else {
        reg.stop();
        serializedDirectory.deleteOnExit();
    }
}

From source file:uk.co.markfrimston.tasktree.Main.java

@Override
public boolean confirmMerge() {
    return JOptionPane.showConfirmDialog(this, "Was the merge completed successfully?", "Merge",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION;

}

From source file:es.emergya.ui.plugins.admin.AdminLayers.java

protected SummaryAction getSummaryAction(final CapaInformacion capaInformacion) {
    SummaryAction action = new SummaryAction(capaInformacion) {

        private static final long serialVersionUID = -3691171434904452485L;

        @Override/*from  w w w.  j  a v a 2 s  . c  o m*/
        protected JFrame getSummaryDialog() {

            if (capaInformacion != null) {
                d = getDialog(capaInformacion, null, "", null, "image/png");
                return d;
            } else {
                JDialog primera = getJDialog();
                primera.setResizable(false);
                primera.setVisible(true);
                primera.setAlwaysOnTop(true);
            }
            return null;
        }

        private JDialog getJDialog() {
            final JDialog dialog = new JDialog();
            dialog.setTitle(i18n.getString("admin.capas.nueva.titleBar"));
            dialog.setIconImage(getBasicWindow().getIconImage());

            dialog.setLayout(new BorderLayout());

            JPanel centro = new JPanel(new FlowLayout());
            centro.setOpaque(false);
            JLabel label = new JLabel(i18n.getString("admin.capas.nueva.url"));
            final JTextField url = new JTextField(50);
            final JLabel icono = new JLabel(LogicConstants.getIcon("48x48_transparente"));
            label.setLabelFor(url);
            centro.add(label);
            centro.add(url);
            centro.add(icono);
            dialog.add(centro, BorderLayout.CENTER);

            JPanel pie = new JPanel(new FlowLayout(FlowLayout.TRAILING));
            pie.setOpaque(false);
            final JButton siguiente = new JButton(i18n.getString("admin.capas.nueva.boton.siguiente"),
                    LogicConstants.getIcon("button_next"));
            JButton cancelar = new JButton(i18n.getString("admin.capas.nueva.boton.cancelar"),
                    LogicConstants.getIcon("button_cancel"));
            final SiguienteActionListener siguienteActionListener = new SiguienteActionListener(url, dialog,
                    icono, siguiente);
            url.addActionListener(siguienteActionListener);

            siguiente.addActionListener(siguienteActionListener);

            cancelar.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    dialog.dispose();
                }
            });
            pie.add(siguiente);
            pie.add(cancelar);
            dialog.add(pie, BorderLayout.SOUTH);

            dialog.getContentPane().setBackground(Color.WHITE);

            dialog.pack();
            dialog.setLocationRelativeTo(null);
            return dialog;
        }

        private JFrame getDialog(final CapaInformacion c, final Capa[] left_items, final String service,
                final Map<String, Boolean> transparentes, final String png) {

            if (left_items != null && left_items.length == 0) {
                JOptionPane.showMessageDialog(AdminLayers.this,
                        i18n.getString("admin.capas.nueva.error.noCapasEnServicio"));
            } else {

                final String label_cabecera = i18n.getString("admin.capas.nueva.nombreCapa");
                final String label_pie = i18n.getString("admin.capas.nueva.infoAdicional");
                final String centered_label = i18n.getString("admin.capas.nueva.origenDatos");
                final String left_label = i18n.getString("admin.capas.nueva.subcapasDisponibles");
                final String right_label;
                if (left_items != null) {
                    right_label = i18n.getString("admin.capas.nueva.capasSeleccionadas");
                } else {
                    right_label = i18n.getString("admin.capas.ficha.capasSeleccionadas");
                }
                final String tituloVentana, cabecera;
                if (c.getNombre() == null) {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.nuevaCapa");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.nuevaCapa");
                } else {
                    tituloVentana = i18n.getString("admin.capas.nueva.titulo.ficha");
                    cabecera = i18n.getString("admin.capas.nueva.cabecera.ficha");
                }

                final Capa[] right_items = c.getCapas().toArray(new Capa[0]);
                final AdminPanel.SaveOrUpdateAction<CapaInformacion> guardar = layers.new SaveOrUpdateAction<CapaInformacion>(
                        c) {

                    private static final long serialVersionUID = 7447770296943341404L;

                    @Override
                    public void actionPerformed(ActionEvent e) {

                        if (isNew && CapaConsultas.alreadyExists(textfieldCabecera.getText())) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaYaExiste"));

                        } else if (textfieldCabecera.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.nombreCapaEnBlanco"));

                        } else if (((DefaultListModel) right.getModel()).size() == 0) {
                            JOptionPane.showMessageDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.error.noCapasSeleccionadas"));

                        } else if (cambios) {
                            int i = JOptionPane.showConfirmDialog(super.frame,
                                    i18n.getString("admin.capas.nueva.confirmar.guardar.titulo"),
                                    i18n.getString("admin.capas.nueva.confirmar.boton.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                if (original == null) {
                                    original = new CapaInformacion();

                                }
                                original.setInfoAdicional(textfieldPie.getText());
                                original.setNombre(textfieldCabecera.getText());
                                original.setHabilitada(habilitado.isSelected());
                                original.setOpcional(comboTipoCapa.getSelectedIndex() != 0);

                                boolean transparente = true;

                                HashSet<Capa> capas = new HashSet<Capa>();
                                List<Capa> capasEnOrdenSeleccionado = new ArrayList<Capa>();
                                int indice = 0;
                                for (Object c : ((DefaultListModel) right.getModel()).toArray()) {
                                    if (c instanceof Capa) {
                                        transparente = transparente && (transparentes != null
                                                && transparentes.get(((Capa) c).getNombre()) != null
                                                && transparentes.get(((Capa) c).getNombre()));
                                        capas.add((Capa) c);
                                        capasEnOrdenSeleccionado.add((Capa) c);
                                        ((Capa) c).setCapaInformacion(original);
                                        ((Capa) c).setOrden(indice++);
                                        // ((Capa)
                                        // c).setNombre(c.toString());
                                    }

                                }
                                original.setCapas(capas);

                                if (original.getId() == null) {
                                    String url = nombre.getText();

                                    if (url.indexOf("?") > -1) {
                                        if (!url.endsWith("?")) {
                                            url += "&";

                                        }
                                    } else {
                                        url += "?";

                                    }
                                    url += "VERSION=" + version + "&REQUEST=GetMap&FORMAT=" + png + "&SERVICE="
                                            + service + "&WIDTH={2}&HEIGHT={3}&BBOX={1}&SRS={0}";
                                    // if (transparente)
                                    url += "&TRANSPARENT=TRUE";
                                    url += "&LAYERS=";

                                    String estilos = "";
                                    final String coma = "%2C";
                                    if (capasEnOrdenSeleccionado.size() > 0) {
                                        for (Capa c : capasEnOrdenSeleccionado) {
                                            url += c.getTitulo().replaceAll(" ", "+") + coma;
                                            estilos += c.getEstilo() + coma;
                                        }
                                        estilos = estilos.substring(0, estilos.length() - coma.length());

                                        estilos = estilos.replaceAll(" ", "+");

                                        url = url.substring(0, url.length() - coma.length());
                                    }
                                    url += "&STYLES=" + estilos;
                                    original.setUrl_visible(original.getUrl());
                                    original.setUrl(url);
                                }
                                CapaInformacionAdmin.saveOrUpdate(original);

                                cambios = false;

                                layers.setTableData(getAll(new CapaInformacion()));

                                closeFrame();
                            } else if (i == JOptionPane.NO_OPTION) {
                                closeFrame();

                            }
                        } else {
                            closeFrame();

                        }
                    }
                };
                JFrame segunda = generateUrlDialog(label_cabecera, label_pie, centered_label, tituloVentana,
                        left_items, right_items, left_label, right_label, guardar,
                        LogicConstants.getIcon("tittleficha_icon_capa"), cabecera, c.getHabilitada(),
                        c.getOpcional(), c.getUrl_visible());
                segunda.setResizable(false);

                if (c != null) {
                    textfieldCabecera.setText(c.getNombre());
                    textfieldPie.setText(c.getInfoAdicional());
                    nombre.setText(c.getUrl_visible());
                    nombre.setEditable(false);
                    if (c.getHabilitada() == null) {
                        c.setHabilitada(false);

                    }
                    habilitado.setSelected(c.getHabilitada());
                    if (c.isOpcional() != null && c.isOpcional()) {
                        comboTipoCapa.setSelectedIndex(1);
                    } else {
                        comboTipoCapa.setSelectedIndex(0);
                    }
                }

                if (c.getId() == null) {
                    habilitado.setSelected(true);
                    comboTipoCapa.setSelectedIndex(1);
                }

                habilitado.setEnabled(true);
                if (c == null || c.getId() == null) {
                    textfieldCabecera.setEditable(true);
                } else {
                    textfieldCabecera.setEditable(false);
                }

                cambios = false;

                segunda.pack();
                segunda.setLocationRelativeTo(null);
                segunda.setVisible(true);
                return segunda;
            }
            return null;
        }

        class SiguienteActionListener implements ActionListener {

            private final JTextField url;
            private final JDialog dialog;
            private final JLabel icono;
            private final JButton siguiente;

            public SiguienteActionListener(JTextField url, JDialog dialog, JLabel icono, JButton siguiente) {
                this.url = url;
                this.dialog = dialog;
                this.icono = icono;
                this.siguiente = siguiente;
            }

            @Override
            public void actionPerformed(ActionEvent e) {
                final CapaInformacion ci = new CapaInformacion();
                ci.setUrl(url.getText());
                ci.setCapas(new HashSet<Capa>());
                SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                    private List<Capa> res = new LinkedList<Capa>();
                    private String service = "WMS";
                    private String png = null;
                    private Map<String, Boolean> transparentes = new HashMap<String, Boolean>();
                    private ArrayList<String> errorStack = new ArrayList<String>();
                    private Boolean goOn = true;

                    @SuppressWarnings(value = "unchecked")
                    @Override
                    protected Object doInBackground() throws Exception {
                        try {
                            final String url2 = ci.getUrl();
                            WMSClient client = new WMSClient(url2);
                            client.connect(new ICancellable() {

                                @Override
                                public boolean isCanceled() {
                                    return false;
                                }

                                @Override
                                public Object getID() {
                                    return System.currentTimeMillis();
                                }
                            });

                            version = client.getVersion();

                            for (final String s : client.getLayerNames()) {
                                WMSLayer layer = client.getLayer(s);
                                // this.service =
                                // client.getServiceName();
                                final Vector allSrs = layer.getAllSrs();
                                boolean epsg = (allSrs != null) ? allSrs.contains("EPSG:4326") : false;
                                final Vector formats = client.getFormats();
                                if (formats.contains("image/png")) {
                                    png = "image/png";
                                } else if (formats.contains("IMAGE/PNG")) {
                                    png = "IMAGE/PNG";
                                } else if (formats.contains("png")) {
                                    png = "png";
                                } else if (formats.contains("PNG")) {
                                    png = "PNG";
                                }
                                boolean image = png != null;
                                if (png == null) {
                                    png = "IMAGE/PNG";
                                }
                                if (epsg && image) {
                                    boolean hasTransparency = layer.hasTransparency();
                                    this.transparentes.put(s, hasTransparency);
                                    Capa capa = new Capa();
                                    capa.setCapaInformacion(ci);
                                    if (layer.getStyles().size() > 0) {
                                        capa.setEstilo(((WMSStyle) layer.getStyles().get(0)).getName());
                                    }
                                    capa.setNombre(layer.getTitle());
                                    capa.setTitulo(s);
                                    res.add(capa);
                                    if (!hasTransparency) {
                                        errorStack.add(i18n.getString(Locale.ROOT,
                                                "admin.capas.nueva.error.capaNoTransparente",
                                                layer.getTitle()));
                                    }
                                } else {
                                    String error = "";
                                    // if (opaque)
                                    // error += "<li>Es opaca</li>";
                                    if (!image) {
                                        error += i18n.getString("admin.capas.nueva.error.formatoPNG");
                                    }
                                    if (!epsg) {
                                        error += i18n.getString("admin.capas.nueva.error.projeccion");
                                    }
                                    final String cadena = i18n.getString(Locale.ROOT,
                                            "admin.capas.nueva.error.errorCapa", new Object[] { s, error });
                                    errorStack.add(cadena);
                                }
                            }
                        } catch (final Throwable t) {
                            log.error("Error al parsear el WMS", t);
                            goOn = false;
                            icono.setIcon(LogicConstants.getIcon("48x48_transparente"));

                            JOptionPane.showMessageDialog(dialog,
                                    i18n.getString("admin.capas.nueva.error.errorParseoWMS"));

                            siguiente.setEnabled(true);
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        super.done();
                        if (goOn) {

                            dialog.dispose();
                            ci.setUrl_visible(ci.getUrl());
                            final JFrame frame = getDialog(ci, res.toArray(new Capa[0]), service, transparentes,
                                    png);
                            if (!errorStack.isEmpty()) {
                                String error = "<html>";
                                for (final String s : errorStack) {
                                    error += s + "<br/>";
                                }
                                error += "</html>";
                                final String errorString = error;
                                SwingUtilities.invokeLater(new Runnable() {

                                    @Override
                                    public void run() {
                                        JOptionPane.showMessageDialog(frame, errorString);
                                    }
                                });
                            }
                        }
                    }
                };
                sw.execute();
                icono.setIcon(LogicConstants.getIcon("anim_conectando"));
                icono.repaint();
                siguiente.setEnabled(false);
            }
        }
    };

    return action;
}

From source file:edu.ku.brc.specify.ui.AppBase.java

/**
 * //  w w w  . j a va2  s . c o m
 */
protected void checkForUpdates() {
    try {
        UpdateDescriptor updateDesc = UpdateChecker.getUpdateDescriptor(
                UIRegistry.getResourceString("UPDATE_PATH"), ApplicationDisplayMode.UNATTENDED);

        UpdateDescriptorEntry entry = updateDesc.getPossibleUpdateEntry();

        if (entry != null) {
            Object[] options = { getResourceString("Specify.INSTALLUPDATE"), //$NON-NLS-1$
                    getResourceString("Specify.SKIP") //$NON-NLS-1$
            };
            int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(),
                    getLocalizedMessage("Specify.UPDATE_AVAIL", entry.getNewVersion()), //$NON-NLS-1$
                    getResourceString("Specify.UPDATE_AVAIL_TITLE"), //$NON-NLS-1$
                    JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
            if (userChoice == JOptionPane.YES_OPTION) {
                if (!doExit(false)) {
                    return;
                }

            } else {
                return;
            }
        } else {
            UIRegistry.showLocalizedError("Specify.NO_UPDATE_AVAIL");
            return;
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        UIRegistry.showLocalizedError("Specify.UPDATE_CHK_ERROR");
        return;
    }

    try {
        ApplicationLauncher.Callback callback = new ApplicationLauncher.Callback() {
            public void exited(int exitValue) {
                System.err.println("exitValue: " + exitValue);
                //startApp(doConfig);
            }

            public void prepareShutdown() {
                System.err.println("prepareShutdown");

            }
        };
        ApplicationLauncher.launchApplication("100", null, true, callback);

    } catch (Exception ex) {
        System.err.println("EXPCEPTION");
    }
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private void jchkCompletedActionPerformed(ActionEvent evt) {
    String todoName = (String) jcbTodos.getSelectedItem();
    boolean isCompletedTodo = StringUtils.containsIgnoreCase(todoName,
            CoreObject.getConfig().getString(Constants.CONFIG_COMPLETED_ITEM_TAG));
    if (jchkCompleted.isSelected() && !isCompletedTodo) {
        String message = "This to-do item will be marked as completed. Are you sure to continue?";
        String title = "Complete To-Do Item";
        int optionType = JOptionPane.YES_NO_OPTION;
        int messageType = JOptionPane.QUESTION_MESSAGE;
        int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType, null,
                null, null);/*www. jav  a  2s .  c  o m*/
        if (selectedOption == JOptionPane.YES_OPTION) {
            String todoDescription = (String) jcbTodos.getSelectedItem();
            BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription);
            Integer todoItemId = todoItem.getId();
            String statusCode = BasecampBusiness.completeTodoItem(todoItemId.toString());
            if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) {
                jtfHours.setText("0");
                jDateChooser_IL.setDate(new Date());
                jchkCompleted.setSelected(false);
                jtfDescription.setText("");
                CoreObject.reloadTodoMap();
                lblMessages.setText("ToDo has been completed!");
            } else {
                lblMessages.setText("Failed! Status: " + statusCode);
            }

        } else {
            jchkCompleted.setSelected(false);
        }
    } else {
        if (isCompletedTodo) {
            String message = "This to-do item will be marked as uncompleted. Are you sure to activate the item?";
            String title = "Activate To-Do Item";
            int optionType = JOptionPane.YES_NO_OPTION;
            int messageType = JOptionPane.QUESTION_MESSAGE;
            int selectedOption = JOptionPane.showOptionDialog(this, message, title, optionType, messageType,
                    null, null, null);
            if (selectedOption == JOptionPane.YES_OPTION) {
                String todoDescription = (String) jcbTodos.getSelectedItem();
                BasecampTodoItem todoItem = CoreObject.getTodoMap().get(todoDescription);
                Integer todoItemId = todoItem.getId();
                String statusCode = BasecampBusiness.uncompleteTodoItem(todoItemId.toString());
                if (statusCode.trim().equals("200") || statusCode.trim().equals("201")) {
                    jtfHours.setText("0");
                    jDateChooser_IL.setDate(new Date());
                    jchkCompleted.setSelected(false);
                    jtfDescription.setText("");
                    CoreObject.reloadTodoMap();
                    lblMessages.setText("ToDo is now active!");
                } else {
                    lblMessages.setText("Failed! Status: " + statusCode);
                }
            } else {
                jchkCompleted.setSelected(true);
            }
        }
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchWatchtowerFrame.java

private void bbCopySelection() {
    try {//  ww  w.ja v a  2  s  . c  o m
        int[] rows = jWatchtowerTable.getSelectedRows();
        if (rows.length == 0) {
            return;
        }

        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(this,
                "Erweiterte BB-Codes verwenden (nur fr Forum und Notizen geeignet)?", "Erweiterter BB-Code",
                "Nein", "Ja") == JOptionPane.YES_OPTION);

        StringBuilder buffer = new StringBuilder();
        if (extended) {
            buffer.append("[u][size=12]Watchturmdrfer[/size][/u]\n\n");
        } else {
            buffer.append("[u]Watchturmdrfer[/u]\n\n");
        }

        buffer.append("[table]\n");
        buffer.append("[**]Spieler[||]Dorf[||]Radius[/**]\n");

        for (int row1 : rows) {
            int row = jWatchtowerTable.convertRowIndexToModel(row1);
            int tribeCol = jWatchtowerTable.convertColumnIndexToModel(0);
            int villageCol = jWatchtowerTable.convertColumnIndexToModel(1);
            int rangeCol = jWatchtowerTable.convertColumnIndexToModel(2);
            buffer.append("[*]")
                    .append(((Tribe) jWatchtowerTable.getModel().getValueAt(row, tribeCol)).toBBCode())
                    .append("[|]")
                    .append(((Village) jWatchtowerTable.getModel().getValueAt(row, villageCol)).toBBCode())
                    .append("[|]").append(jWatchtowerTable.getModel().getValueAt(row, rangeCol));
        }

        buffer.append("[/table]");

        if (extended) {
            buffer.append("\n[size=8]Erstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "[/size]\n");
        } else {
            buffer.append("\nErstellt am ");
            buffer.append(
                    new SimpleDateFormat("dd.MM.yy 'um' HH:mm:ss").format(Calendar.getInstance().getTime()));
            buffer.append(" mit DS Workbench ");
            buffer.append(Constants.VERSION).append(Constants.VERSION_ADDITION + "\n");
        }

        String b = buffer.toString();
        StringTokenizer t = new StringTokenizer(b, "[");
        int cnt = t.countTokens();
        if (cnt > 1000) {
            if (JOptionPaneHelper.showQuestionConfirmBox(this,
                    "Die ausgewhlten Wachtrme bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\n"
                            + "Trotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        String result = "Daten in Zwischenablage kopiert.";
        showSuccess(result);
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        String result = "Fehler beim Kopieren in die Zwischenablage.";
        showError(result);
    }
}

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoCampo.java

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnguardarActionPerformed
    // TODO add your handling code here:
    String palabra = "";
    String palabra2 = "";
    if (accion == 1) {
        palabra = "registrar";
        palabra2 = "registrado";

        if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Campo?", "Mensaje del Sistema",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            campoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
            campoControlador.getSeleccionado().setClase((Clase) cmbClase.getSelectedItem());
            //                campoControlador.getSeleccionado().setUnidadMedida((UnidadMedida) cmbUnidad.getSelectedItem());

            campoControlador.accion(accion);
            lista.add(campoControlador.getSeleccionado());

            if (accion == 1) {
                JOptionPane.showMessageDialog(null, "Campo " + palabra2 + " correctamente",
                        "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);
                FormularioUtil.limpiarComponente(panelDatos);
            } else {
                JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }//from w w w.j  a  v a 2 s .c  om
        } else {
            FormularioUtil.limpiarComponente(panelDatos);
            JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        }
    } else if (accion == 2) {
        palabra = "modificar";
        palabra2 = "modificado";

        if (JOptionPane.showConfirmDialog(null, "Desea " + palabra + " el Campo?", "Mensaje del Sistema",
                JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

            if (accion == 2) {
                JOptionPane.showMessageDialog(null, "Campo " + palabra2 + " correctamente",
                        "Mensaje del Sistema", JOptionPane.INFORMATION_MESSAGE);

                lista.clear();

                campoControlador.getSeleccionado().setNombre(nombreField.getText().toUpperCase());
                campoControlador.getSeleccionado().setClase((Clase) cmbClase.getSelectedItem());
                //                    campoControlador.getSeleccionado().setUnidadMedida((UnidadMedida) cmbUnidad.getSelectedItem());

                campoControlador.accion(accion);
                listar();

                FormularioUtil.limpiarComponente(panelDatos);

            } else {
                JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else {
            FormularioUtil.limpiarComponente(panelDatos);
            JOptionPane.showMessageDialog(null, "Campo no " + palabra2, "Mensaje del Sistema",
                    JOptionPane.ERROR_MESSAGE);
        }
    }

    FormularioUtil.activarComponente(panelOpciones, true);
    FormularioUtil.activarComponente(panelGuardar, false);
    FormularioUtil.activarComponente(panelDatos, false);

}