Example usage for javax.swing JOptionPane QUESTION_MESSAGE

List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE

Introduction

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

Prototype

int QUESTION_MESSAGE

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

Click Source Link

Document

Used for questions.

Usage

From source file:gdt.jgui.entity.webset.JWeblinksPanel.java

/**
 * Get the context menu./*from  w  ww  .j av  a  2 s  . c om*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = super.getContextMenu();
    int cnt = menu.getItemCount();
    mia = new JMenuItem[cnt];
    for (int i = 0; i < cnt; i++)
        mia[i] = menu.getItem(i);
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            //System.out.println("WeblinkPanel:getConextMenu:menu selected");
            menu.removeAll();
            if (mia != null) {
                for (JMenuItem mi : mia)
                    menu.add(mi);
                menu.addSeparator();
            }
            if (hasSelectedItems()) {
                JMenuItem deleteItem = new JMenuItem("Delete");
                deleteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {

                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            String[] sa = JWeblinksPanel.this.listSelectedItems();
                            if (sa == null)
                                return;
                            String webLinkKey$;
                            Entigrator entigrator = console.getEntigrator(entihome$);
                            Sack entity = entigrator.getEntityAtKey(entityKey$);
                            for (String aSa : sa) {
                                webLinkKey$ = Locator.getProperty(aSa, WEB_LINK_KEY);
                                if (webLinkKey$ == null)
                                    continue;
                                entity.removeElementItem("web", webLinkKey$);
                                entity.removeElementItem("web.login", webLinkKey$);
                                entity.removeElementItem("web.icon", webLinkKey$);
                            }
                            entigrator.save(entity);

                            JConsoleHandler.execute(console, locator$);
                        }
                    }
                });
                menu.add(deleteItem);
                JMenuItem copyItem = new JMenuItem("Copy");
                copyItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        JItemPanel[] ipa = JWeblinksPanel.this.getItems();
                        ArrayList<String> sl = new ArrayList<String>();
                        for (JItemPanel ip : ipa)
                            if (ip.isChecked())
                                sl.add(ip.getLocator());
                        String[] sa = sl.toArray(new String[0]);
                        console.clipboard.clear();
                        for (String aSa : sa)
                            console.clipboard.putString(aSa);
                    }
                });
                menu.add(copyItem);
            }
            JMenuItem newItem = new JMenuItem("New");
            newItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    System.out.println("WeblinksPanel:new:" + locator$);
                    Entigrator entigrator = console.getEntigrator(entihome$);
                    Sack entity = entigrator.getEntityAtKey(entityKey$);
                    if (!entity.existsElement("web"))
                        entity.createElement("web");
                    String webLinkKey$ = Identity.key();
                    entity.putElementItem("web", new Core("Google", webLinkKey$, "http://www.google.com"));
                    if (!entity.existsElement("web.icon"))
                        entity.createElement("web.icon");
                    String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png");
                    entity.putElementItem("web.icon", new Core(null, webLinkKey$, icon$));
                    entigrator.save(entity);
                    JWeblinkEditor wle = new JWeblinkEditor();
                    String wleLocator$ = wle.getLocator();
                    wleLocator$ = Locator.append(wleLocator$, Entigrator.ENTIHOME, entihome$);
                    wleLocator$ = Locator.append(wleLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    wleLocator$ = Locator.append(wleLocator$, WEB_LINK_KEY, webLinkKey$);
                    String requesterResponseLocator$ = Locator.compressText(getLocator());
                    wleLocator$ = Locator.append(wleLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR,
                            requesterResponseLocator$);
                    JConsoleHandler.execute(console, wleLocator$);

                }
            });
            menu.add(newItem);
            if (hasItemsToPaste()) {
                JMenuItem pasteItem = new JMenuItem("Paste");
                pasteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String[] sa = getItemsToPaste();
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack entity = entigrator.getEntityAtKey(entityKey$);
                        if (!entity.existsElement("web"))
                            entity.createElement("web");
                        if (!entity.existsElement("web.icon"))
                            entity.createElement("web.icon");
                        if (!entity.existsElement("web.login"))
                            entity.createElement("web.login");
                        Properties itemLocator;
                        String webLinkKey$;
                        String webLinkUrl$;
                        String webLinkName$;
                        String webLinkIcon$;
                        String webLinkLogin$;
                        String webLinkPassword$;
                        for (String aSa : sa) {
                            itemLocator = Locator.toProperties(aSa);
                            webLinkKey$ = itemLocator.getProperty(WEB_LINK_KEY);
                            webLinkUrl$ = itemLocator.getProperty(WEB_LINK_URL);
                            webLinkName$ = itemLocator.getProperty(WEB_LINK_NAME);
                            webLinkIcon$ = itemLocator.getProperty(Locator.LOCATOR_ICON);
                            webLinkLogin$ = itemLocator.getProperty(WEB_LINK_LOGIN);
                            webLinkPassword$ = itemLocator.getProperty(WEB_LINK_PASSWORD);
                            if (webLinkKey$ == null || webLinkUrl$ == null)
                                continue;
                            entity.putElementItem("web", new Core(webLinkName$, webLinkKey$, webLinkUrl$));
                            if (webLinkLogin$ != null || webLinkPassword$ != null)
                                entity.putElementItem("web.login",
                                        new Core(webLinkLogin$, webLinkKey$, webLinkPassword$));
                            if (webLinkIcon$ != null)
                                entity.putElementItem("web.icon", new Core(null, webLinkKey$, webLinkIcon$));
                        }
                        entigrator.save(entity);
                        JConsoleHandler.execute(console, getLocator());
                    }
                });
                menu.add(pasteItem);
            }
            menu.addSeparator();
            JMenuItem doneItem = new JMenuItem("Done");
            doneItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (requesterResponseLocator$ != null) {
                        try {
                            byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                            String responseLocator$ = new String(ba, "UTF-8");
                            JConsoleHandler.execute(console, responseLocator$);
                        } catch (Exception ee) {
                            Logger.getLogger(JWeblinksPanel.class.getName()).severe(ee.toString());
                        }
                    } else
                        console.back();
                }
            });
            menu.add(doneItem);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu;
}

From source file:me.timothy.ddd.DrunkDuckDispatch.java

License:asdf

/**
 * Gets the OS type, prompts the user for a choice if it cannot be determined.
 * /*w w  w  .  j  ava 2  s.com*/
 * @return the os
 */
private static String getOS() {
    String envOS = System.getProperty("os.name").toLowerCase();
    System.out.println(envOS);
    if (envOS.contains("win"))
        return "windows";
    else if (envOS.contains("mac"))
        return "macosx";
    else if (envOS.contains("nix"))
        return "linux";
    else if (envOS.contains("sunos"))
        return "solaris";

    String[] os = new String[] { "Windows", "Linux", "MacOSX", "Solaris" };
    String choice = (String) JOptionPane.showInputDialog(null,
            "Your OS could not be detected, please choose from the available options below", "OS Picker",
            JOptionPane.QUESTION_MESSAGE, null, os, os[1]);
    if (choice == null)
        System.exit(0);
    return choice.toLowerCase();
}

From source file:com.floreantpos.ui.dialog.ManagerDialog.java

private void doShowServerTips(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetDrawerActionPerformed
    try {//from   w  w  w  .jav  a 2s  .co m
        setGlassPaneVisible(true);

        JPanel panel = new JPanel(new MigLayout());
        List<User> users = UserDAO.getInstance().findAll();

        JXDatePicker fromDatePicker = UiUtil.getCurrentMonthStart();
        JXDatePicker toDatePicker = UiUtil.getCurrentMonthEnd();

        panel.add(new JLabel(com.floreantpos.POSConstants.SELECT_USER + ":"), "grow"); //$NON-NLS-1$ //$NON-NLS-2$
        JComboBox userCombo = new JComboBox(new ListComboBoxModel(users));
        panel.add(userCombo, "grow, wrap"); //$NON-NLS-1$
        panel.add(new JLabel(com.floreantpos.POSConstants.FROM + ":"), "grow"); //$NON-NLS-1$ //$NON-NLS-2$
        panel.add(fromDatePicker, "wrap"); //$NON-NLS-1$
        panel.add(new JLabel(com.floreantpos.POSConstants.TO_), "grow"); //$NON-NLS-1$
        panel.add(toDatePicker);

        int option = JOptionPane.showOptionDialog(ManagerDialog.this, panel,
                com.floreantpos.POSConstants.SELECT_CRIETERIA, JOptionPane.OK_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE, null, null, null);
        if (option != JOptionPane.OK_OPTION) {
            return;
        }

        GratuityDAO gratuityDAO = new GratuityDAO();
        TipsCashoutReport report = gratuityDAO.createReport(fromDatePicker.getDate(), toDatePicker.getDate(),
                (User) userCombo.getSelectedItem());

        TipsCashoutReportDialog dialog = new TipsCashoutReportDialog(report);
        dialog.setSize(400, 600);
        dialog.open();
    } catch (Exception e) {
        POSMessageDialog.showError(Application.getPosWindow(), com.floreantpos.POSConstants.ERROR_MESSAGE, e);
    } finally {
        setGlassPaneVisible(false);
    }
}

From source file:eu.apenet.dpt.standalone.gui.dateconversion.DateConversionRulesDialog.java

private void createOptionPaneForIsoDate(int row, int column) {
    DateNormalization dateNormalization = new DateNormalization();
    String currentResult = (String) dm.getValueAt(row, column);
    String explanation = "'" + currentResult + "' " + labels.getString("dateConversion.notValidDate") + "\n"
            + labels.getString("dateConversion.enterCorrectIsoDate") + "\n"
            + labels.getString("dateConversion.validValues");
    String result;/*from w  ww .j a v  a 2 s.co  m*/
    do {
        result = (String) JOptionPane.showInputDialog(getContentPane(), explanation,
                labels.getString("dateConversion.header"), JOptionPane.QUESTION_MESSAGE, Utilities.icon, null,
                null);
        if (result == null)
            break;
    } while (dateNormalization.checkForNormalAttribute(result) == null);
    if (result != null) {
        dm.setValueAt(result, row, column);
        dm.fireTableCellUpdated(row, column);
    } else {
        dm.setValueAt("", row, column);
        dm.fireTableCellUpdated(row, column);
    }
}

From source file:de.adv_online.aaa.katalogtool.KatalogDialog.java

public void initialise(Converter c, Options o, ShapeChangeResult r, String mdl)
        throws ShapeChangeAbortException {

    try {/*  ww  w . j a  v  a 2s  . co  m*/
        String msg = "Akzeptieren Sie die in der mit diesem Tool ausgelieferten Datei 'Lizenzbedingungen zur Nutzung von Softwareskripten.doc' beschriebenen Lizenzbedingungen?"; // Meldung
        if (msg != null) {
            Object[] options = { "Ja", "Nein" };
            int val = JOptionPane.showOptionDialog(null, msg, "Confirmation", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
            if (val == 1)
                System.exit(0);
        }
    } catch (Exception e) {
        System.out.println("Fehler in Dialog: " + e.toString());
    }

    options = o;

    File eapFile = new File(mdl);
    try {
        eap = eapFile.getCanonicalFile().getAbsolutePath();
    } catch (IOException e) {
        eap = "ERROR.eap";
    }

    converter = new Converter(options, r);
    result = r;
    modelTransformed = false;
    transformationRunning = false;

    StatusBoard.getStatusBoard().registerStatusReader(this);

    // frame
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    // panel
    newContentPane = new JPanel(new BorderLayout());
    newContentPane.setOpaque(true);
    setContentPane(newContentPane);

    // target elements
    for (String label : targetLabels) {
        try {
            TargetGuiElements t = new TargetGuiElements(this, label);
            targetGuiElems.put(label, t);
        } catch (Exception e) {
            throw new ShapeChangeAbortException("Fatal error while creating dialog elements for target " + label
                    + ".\nMessage: " + eap.toString() + "\nPlease check configuration file.");
        }
    }

    //JTabbedPane tabbedPane = new JTabbedPane();
    //tabbedPane.addTab("Main options", createMainTab());

    newContentPane.add(createMainTab(), BorderLayout.CENTER);

    statusBar = new StatusBar();

    Box fileBox = Box.createVerticalBox();
    fileBox.add(createStartPanel());
    fileBox.add(statusBar);

    newContentPane.add(fileBox, BorderLayout.SOUTH);

    // frame size
    int height = 720;
    int width = 600;

    pack();

    Insets fI = getInsets();
    setSize(width + fI.right + fI.left, height + fI.top + fI.bottom);
    Dimension sD = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation((sD.width - width) / 2, (sD.height - height) / 2);
    this.setMinimumSize(new Dimension(width, height));

    // frame closing
    WindowListener listener = new WindowAdapter() {
        public void windowClosing(WindowEvent w) {
            //JOptionPane.showMessageDialog(null, "Nein", "NO", JOptionPane.ERROR_MESSAGE);
            closeDialog();
        }
    };
    addWindowListener(listener);
}

From source file:com.esp8266.mkspiffs.ESP8266FS.java

private void createAndUpload() {
    if (!PreferencesData.get("target_platform").contentEquals("esp8266")) {
        System.err.println();//from w w  w  .java  2 s  .c o m
        editor.statusError("SPIFFS Not Supported on " + PreferencesData.get("target_platform"));
        return;
    }

    if (!BaseNoGui.getBoardPreferences().containsKey("build.spiffs_start")
            || !BaseNoGui.getBoardPreferences().containsKey("build.spiffs_end")) {
        System.err.println();
        editor.statusError("SPIFFS Not Defined for " + BaseNoGui.getBoardPreferences().get("name"));
        return;
    }
    long spiStart, spiEnd, spiPage, spiBlock;
    try {
        spiStart = getIntPref("build.spiffs_start");
        spiEnd = getIntPref("build.spiffs_end");
        spiPage = getIntPref("build.spiffs_pagesize");
        if (spiPage == 0)
            spiPage = 256;
        spiBlock = getIntPref("build.spiffs_blocksize");
        if (spiBlock == 0)
            spiBlock = 4096;
    } catch (Exception e) {
        editor.statusError(e);
        return;
    }

    TargetPlatform platform = BaseNoGui.getTargetPlatform();

    //Make sure mkspiffs binary exists
    String mkspiffsCmd;
    if (PreferencesData.get("runtime.os").contentEquals("windows"))
        mkspiffsCmd = "mkspiffs.exe";
    else
        mkspiffsCmd = "mkspiffs";

    File tool = new File(platform.getFolder() + "/tools", mkspiffsCmd);
    if (!tool.exists() || !tool.isFile()) {
        tool = new File(platform.getFolder() + "/tools/mkspiffs", mkspiffsCmd);
        if (!tool.exists()) {
            tool = new File(PreferencesData.get("runtime.tools.mkspiffs.path"), mkspiffsCmd);
            if (!tool.exists()) {
                System.err.println();
                editor.statusError("SPIFFS Error: mkspiffs not found!");
                return;
            }
        }
    }

    Boolean isNetwork = false;
    File espota = new File(platform.getFolder() + "/tools");
    File esptool = new File(platform.getFolder() + "/tools");
    String serialPort = PreferencesData.get("serial.port");

    //make sure the serial port or IP is defined
    if (serialPort == null || serialPort.isEmpty()) {
        System.err.println();
        editor.statusError("SPIFFS Error: serial port not defined!");
        return;
    }

    //find espota if IP else find esptool
    if (serialPort.split("\\.").length == 4) {
        isNetwork = true;
        String espotaCmd = "espota.py";
        espota = new File(platform.getFolder() + "/tools", espotaCmd);
        if (!espota.exists() || !espota.isFile()) {
            System.err.println();
            editor.statusError("SPIFFS Error: espota not found!");
            return;
        }
    } else {
        String esptoolCmd = platform.getTool("esptool").get("cmd");
        esptool = new File(platform.getFolder() + "/tools", esptoolCmd);
        if (!esptool.exists() || !esptool.isFile()) {
            esptool = new File(platform.getFolder() + "/tools/esptool", esptoolCmd);
            if (!esptool.exists()) {
                esptool = new File(PreferencesData.get("runtime.tools.esptool.path"), esptoolCmd);
                if (!esptool.exists()) {
                    System.err.println();
                    editor.statusError("SPIFFS Error: esptool not found!");
                    return;
                }
            }
        }
    }

    //load a list of all files
    int fileCount = 0;
    File dataFolder = new File(editor.getSketch().getFolder(), "data");
    if (!dataFolder.exists()) {
        dataFolder.mkdirs();
    }
    if (dataFolder.exists() && dataFolder.isDirectory()) {
        File[] files = dataFolder.listFiles();
        if (files.length > 0) {
            for (File file : files) {
                if ((file.isDirectory() || file.isFile()) && !file.getName().startsWith("."))
                    fileCount++;
            }
        }
    }

    String dataPath = dataFolder.getAbsolutePath();
    String toolPath = tool.getAbsolutePath();
    String sketchName = editor.getSketch().getName();
    String imagePath = getBuildFolderPath(editor.getSketch()) + "\\" + sketchName + ".spiffs.bin";
    String resetMethod = BaseNoGui.getBoardPreferences().get("upload.resetmethod");
    String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed");
    String uploadAddress = BaseNoGui.getBoardPreferences().get("build.spiffs_start");

    Object[] options = { "Yes", "No" };
    String title = "SPIFFS Create";
    String message = "No files have been found in your data folder!\nAre you sure you want to create an empty SPIFFS image?";

    if (fileCount == 0 && JOptionPane.showOptionDialog(editor, message, title, JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, options, options[1]) != JOptionPane.YES_OPTION) {
        System.err.println();
        editor.statusError("SPIFFS Warning: mkspiffs canceled!");
        return;
    }

    editor.statusNotice("SPIFFS Creating Image...");
    System.out.println("[SPIFFS] data   : " + dataPath);
    System.out.println("[SPIFFS] size   : " + ((spiEnd - spiStart) / 1024));
    System.out.println("[SPIFFS] page   : " + spiPage);
    System.out.println("[SPIFFS] block  : " + spiBlock);

    try {
        if (listenOnProcess(new String[] { toolPath, "-c", dataPath, "-p", spiPage + "", "-b", spiBlock + "",
                "-s", (spiEnd - spiStart) + "", imagePath }) != 0) {
            System.err.println();
            editor.statusError("SPIFFS Create Failed!");
            return;
        }
    } catch (Exception e) {
        editor.statusError(e);
        editor.statusError("SPIFFS Create Failed!");
        return;
    }

    title = "SPIFFS Copy";
    message = "Would you like a copy of the SPIFFS image in your project folder?";

    if (JOptionPane.showOptionDialog(editor, message, title, JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE, null, options, options[0]) == JOptionPane.YES_OPTION) {
        File source = new File(imagePath);
        File dest = new File(editor.getSketch().getFolder(), "\\" + sketchName + ".spiffs.bin");
        try {
            Files.copy(source.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
            System.out.println("Copied SPIFFS image");
        } catch (IOException e) {
            System.out.println(e);
            editor.statusError("Copy SPIFFS image failed");
        }
    }

    editor.statusNotice("SPIFFS Uploading Image...");
    System.out.println("[SPIFFS] upload : " + imagePath);

    if (isNetwork) {
        String pythonCmd;
        if (PreferencesData.get("runtime.os").contentEquals("windows"))
            pythonCmd = "python.exe";
        else
            pythonCmd = "python";

        System.out.println("[SPIFFS] IP     : " + serialPort);
        System.out.println();
        sysExec(new String[] { pythonCmd, espota.getAbsolutePath(), "-i", serialPort, "-s", "-f", imagePath });
    } else {
        System.out.println("[SPIFFS] address: " + uploadAddress);
        System.out.println("[SPIFFS] reset  : " + resetMethod);
        System.out.println("[SPIFFS] port   : " + serialPort);
        System.out.println("[SPIFFS] speed  : " + uploadSpeed);
        System.out.println();
        sysExec(new String[] { esptool.getAbsolutePath(), "-cd", resetMethod, "-cb", uploadSpeed, "-cp",
                serialPort, "-ca", uploadAddress, "-cf", imagePath });
    }
}

From source file:kevin.gvmsgarch.App.java

private static ContactFilter buildFilter() {
    ContactFilter retval = null;/* w  w w .j a v  a2s .  c om*/

    int optionPaneResult;

    //        optionPaneResult = JOptionPane.showConfirmDialog(null, "Do you want to enable filtering?", "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
    String[] options = new String[] { "Yes", "No" };

    optionPaneResult = JOptionPane.showOptionDialog(null, "Do you want to enable filtering?", "",
            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

    if (optionPaneResult == 0) {
        JOptionPane.showMessageDialog(null, filterExplanation);
        String contactName = JOptionPane
                .showInputDialog("Filter String (contact display name or phone number)");
        if (contactName == null || contactName.trim().isEmpty()) {
            retval = new NullFilter();
        } else {
            if (contactName.trim().equals("Unknown")) {
                retval = new UnknownFilter();
            } else {
                retval = new NameNumberFilter(contactName);
            }
        }
    } else if (optionPaneResult == JOptionPane.NO_OPTION) {
        retval = new NullFilter();

    }

    return retval;
}

From source file:gdt.jgui.tool.JEntityEditor.java

/**
 * Get the context menu./*from w  w  w  .ja  v  a2s . c om*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {
    menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            //         System.out.println("EntityEditor:getConextMenu:menu selected");

            if (editCellItem != null)
                menu.remove(editCellItem);
            if (deleteItemsItem != null)
                menu.remove(deleteItemsItem);
            if (copyItem != null)
                menu.remove(copyItem);
            if (pasteItem != null)
                menu.remove(pasteItem);
            if (cutItem != null)
                menu.remove(cutItem);
            if (hasEditingCell()) {
                //menu.addSeparator();
                editCellItem = new JMenuItem("Edit item");
                editCellItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String locator$ = getEditCellLocator();
                        if (locator$ != null)
                            JConsoleHandler.execute(console, locator$);
                    }
                });
                menu.add(editCellItem);
            }
            if (hasSelectedRows()) {
                deleteItemsItem = new JMenuItem("Delete items");
                deleteItemsItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(JEntityEditor.this,
                                "Delete selected items ?", "Confirm", JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {
                            deleteRows();
                        }
                    }
                });
                menu.add(deleteItemsItem);
                copyItem = new JMenuItem("Copy");
                copyItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        element$ = null;
                        content = getContent(true);
                    }
                });
                menu.add(copyItem);
                cutItem = new JMenuItem("Cut");
                cutItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int i = tabbedPane.getSelectedIndex();
                        element$ = tabbedPane.getTitleAt(i);
                        content = getContent(true);
                    }
                });
                menu.add(cutItem);
            }
            if (content != null) {
                pasteItem = new JMenuItem("Paste");
                pasteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        pasteTable(content);
                        int j = tabbedPane.getSelectedIndex();
                        if (element$ != null) {
                            int cnt = tabbedPane.getComponentCount();
                            for (int i = 0; i < cnt; i++) {
                                if (element$.equals(tabbedPane.getTitleAt(i))) {
                                    tabbedPane.setSelectedIndex(i);
                                    cutTable(content);
                                    tabbedPane.setSelectedIndex(j);
                                }
                            }
                        }
                    }
                });
                menu.add(pasteItem);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    JMenuItem doneItem = new JMenuItem("Done");
    doneItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            save();
            console.back();

        }
    });
    menu.add(doneItem);
    JMenuItem cancelItem = new JMenuItem("Cancel");
    cancelItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            console.back();
        }
    });
    menu.add(cancelItem);
    menu.addSeparator();
    JMenuItem addItemItem = new JMenuItem("Add item");
    addItemItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addRow();
        }
    });
    menu.add(addItemItem);
    JMenuItem addElementItem = new JMenuItem("Add element");
    addElementItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String element$ = "new element";
            //addElement(element$);
            String locator$ = getRenameElementLocator(element$);
            JConsoleHandler.execute(console, locator$);
        }
    });
    menu.add(addElementItem);
    JMenuItem deleteElementItem = new JMenuItem("Delete element");
    deleteElementItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int response = JOptionPane.showConfirmDialog(JEntityEditor.this, "Delete element ?", "Confirm",
                    JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                tabbedPane.remove(tabbedPane.getSelectedComponent());
            }
        }
    });
    menu.add(deleteElementItem);
    JMenuItem renameElementItem = new JMenuItem("Rename element");
    renameElementItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int i = tabbedPane.getSelectedIndex();
            String locator$ = getRenameElementLocator(tabbedPane.getTitleAt(i));
            JConsoleHandler.execute(console, locator$);
        }
    });
    menu.add(renameElementItem);
    menu.addSeparator();
    if (hasEditingCell()) {
        editCellItem = new JMenuItem("Edit item");
        editCellItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String locator$ = getEditCellLocator();
                if (locator$ != null)
                    JConsoleHandler.execute(console, locator$);
            }
        });
        menu.add(editCellItem);
    }
    return menu;
}

From source file:fr.vdl.android.holocolors.HoloColorsDialog.java

private void unzipFile(File zipFile) throws Exception {
    File outputFolder = new File(resPathTextField.getText());

    boolean overwriteAll = false;
    boolean overwriteNone = false;
    Object[] overwriteOptions = { "Overwrite this file", "Overwrite all", "Do not overwrite this file",
            "Do not overwrite any file" };

    ZipInputStream zis = null;/*w  w w.  j  av  a  2  s.c  om*/
    byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
    try {
        zis = new ZipInputStream(new FileInputStream(zipFile));
        ZipEntry ze = zis.getNextEntry();
        while (ze != null) {
            String fileName = ze.getName().replaceFirst("res/", "");
            File newFile = new File(outputFolder + File.separator + fileName);

            new File(newFile.getParent()).mkdirs();

            boolean overwrite = overwriteAll || (!newFile.exists());
            if (newFile.exists() && newFile.isFile() && !overwriteAll && !overwriteNone) {
                int option = JOptionPane.showOptionDialog(ahcPanel,
                        newFile.getName() + " already exists, overwrite ?", "File exists",
                        JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
                        new ImageIcon(getClass().getResource("/icons/H64.png")), overwriteOptions,
                        overwriteOptions[0]);

                switch (option) {
                case 0:
                    overwrite = true;
                    break;
                case 1:
                    overwrite = true;
                    overwriteAll = true;
                    break;
                case 2:
                    overwrite = false;
                    break;
                case 3:
                    overwrite = false;
                    overwriteNone = true;
                    break;
                default:
                    overwrite = false;
                }
            }

            if (overwrite && !fileName.endsWith(File.separator)) {
                FileOutputStream fos = new FileOutputStream(newFile);
                int len;
                while ((len = zis.read(buffer)) > 0) {
                    fos.write(buffer, 0, len);
                }
                fos.close();
            }
            ze = zis.getNextEntry();
        }

        zis.closeEntry();
        zis.close();
    } finally {
        if (zis != null) {
            try {
                zis.close();
            } catch (IOException e) {
            }
        }
    }
}

From source file:gdt.jgui.entity.bonddetail.JBondDetailPanel.java

/**
 * Get the context menu./*from  ww w  .  java  2s  . co  m*/
 * @return the context menu.
 */
@Override
public JMenu getContextMenu() {

    menu1 = new JMenu("Context");
    menu1.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            //   System.out.println("JBondDetailPanel:getConextMenu:BEGIN");
            menu1.removeAll();
            JMenuItem selectItem = new JMenuItem("Select all");
            selectItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JItemPanel[] ipa = getItems();
                    if (ipa != null) {
                        for (JItemPanel ip : ipa)
                            ip.setChecked(true);
                    }
                }
            });
            menu1.add(selectItem);
            JMenuItem unselectItem = new JMenuItem("Unselect all");
            unselectItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    JItemPanel[] ipa = getItems();
                    if (ipa != null) {
                        for (JItemPanel ip : ipa)
                            ip.setChecked(false);
                    }
                }
            });
            menu1.addSeparator();
            JMenuItem doneItem = new JMenuItem("Done");
            doneItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (requesterResponseLocator$ != null) {
                        try {
                            byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                            String responseLocator$ = new String(ba, "UTF-8");
                            JConsoleHandler.execute(console, responseLocator$);
                        } catch (Exception ee) {
                            LOGGER.severe(ee.toString());
                        }
                    } else
                        console.back();

                }

            });
            menu1.add(doneItem);
            menu1.addSeparator();
            addItem = new JMenuItem("Add");
            addItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        Entigrator entigrator = console.getEntigrator(entihome$);

                        JContext adp = (JContext) ExtensionHandler.loadHandlerInstance(entigrator,
                                BondDetailHandler.EXTENSION_KEY, "gdt.jgui.entity.bonddetail.JAddDetailPanel");
                        String adpLocator$ = adp.getLocator();
                        adpLocator$ = Locator.append(adpLocator$, Entigrator.ENTIHOME, entihome$);
                        adpLocator$ = Locator.append(adpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                        JConsoleHandler.execute(console, adpLocator$);

                    } catch (Exception ee) {
                        LOGGER.severe(ee.toString());
                    }
                }
            });
            menu1.add(addItem);
            if (hasToPaste()) {
                JMenuItem pasteItem = new JMenuItem("Paste");
                pasteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        paste();

                    }
                });
                menu1.add(pasteItem);
            }
            if (hasSelectedItems()) {
                JMenuItem deleteItem = new JMenuItem("Delete");
                deleteItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?",
                                "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                        if (response == JOptionPane.YES_OPTION) {

                            delete();
                            JBondDetailPanel bdp = new JBondDetailPanel();
                            String bdpLocator$ = bdp.getLocator();
                            bdpLocator$ = Locator.append(bdpLocator$, Entigrator.ENTIHOME, entihome$);
                            bdpLocator$ = Locator.append(bdpLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                            bdpLocator$ = Locator.append(bdpLocator$, JBondsPanel.BOND_KEY, bondKey$);
                            JConsoleHandler.execute(console, bdpLocator$);
                        }
                    }
                });
                menu1.add(deleteItem);
            }

        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });
    return menu1;
}