Example usage for javax.swing JOptionPane NO_OPTION

List of usage examples for javax.swing JOptionPane NO_OPTION

Introduction

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

Prototype

int NO_OPTION

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

Click Source Link

Document

Return value from class method if NO is chosen.

Usage

From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java

@Override
public boolean aboutToShutdown() {
    super.aboutToShutdown();

    for (WorkBenchPluginIFace wbp : workBenchPlugins.values()) {
        wbp.shutdown();/*from  w  ww.jav a  2  s .  c  o m*/
    }

    // Tell it is about to be hidden.
    // this way it can end any editing
    if (formPane != null) {
        if (!checkCurrentEditState()) {
            SubPaneMgr.getInstance().showPane(this);
            // Need to reverify to get the error to display again.
            if (spreadSheet.getCellEditor() != null) {
                spreadSheet.getCellEditor().stopCellEditing();
            }
            return false;
        }
    }

    if (datasetUploader != null && !datasetUploader.aboutToShutdown(this)) {
        return false;
    }

    if (datasetUploader != null) {
        if (datasetUploader.closing(this)) {
            datasetUploader = null;
            Uploader.unlockApp();
            Uploader.unlockUpload();
        }
    }

    boolean retStatus = true;
    if (hasChanged) {

        // turn off alwaysOnTop for Swing repaint reasons (prevents a lock up)
        if (imageFrame != null) {
            imageFrame.setAlwaysOnTop(false);
        }
        String msg = String.format(getResourceString("SaveChanges"), getTitle());
        JFrame topFrame = (JFrame) UIRegistry.getTopWindow();

        final String wbName = workbench.getName();

        int rv = JOptionPane.showConfirmDialog(topFrame, msg, getResourceString("SaveChangesTitle"),
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (rv == JOptionPane.YES_OPTION) {
            //GlassPane and Progress bar currently don't show up during shutdown
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    UIRegistry.writeSimpleGlassPaneMsg(
                            String.format(getResourceString("WB_SAVING"), new Object[] { workbench.getName() }),
                            WorkbenchTask.GLASSPANE_FONT_SIZE);
                    UIRegistry.getStatusBar().setIndeterminate(wbName, true);
                }
            });

            SwingWorker saver = new SwingWorker() {

                /* (non-Javadoc)
                 * @see edu.ku.brc.helpers.SwingWorker#construct()
                 */
                @Override
                public Object construct() {

                    Boolean result = null;
                    try {
                        saveObject();
                        result = new Boolean(true);
                    } catch (Exception ex) {
                        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchPaneSS.class, ex);
                        log.error(ex);
                    }
                    return result;
                }

                /* (non-Javadoc)
                 * @see edu.ku.brc.helpers.SwingWorker#finished()
                 */
                @Override
                public void finished() {
                    UIRegistry.clearSimpleGlassPaneMsg();
                    UIRegistry.getStatusBar().setProgressDone(wbName);
                    shutdownLock.decrementAndGet();
                    shutdown();
                }

            };
            shutdownLock.incrementAndGet();
            saver.start();
            //retStatus = saver.get() != null;
        } else if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
            return false;
        } else if (rv == JOptionPane.NO_OPTION) {
            hasChanged = false; // we do this so we don't get asked a second time
        }

    }

    if (retStatus) {
        ((WorkbenchTask) ContextMgr.getTaskByClass(WorkbenchTask.class)).closing(this);
        ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).closing(this);

        if (spreadSheet != null) {
            spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener);
        }
        workbenchRowChangeListener = null;
    }

    return retStatus;
}

From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java

/**
 * This filters out all non-image files per the image filter and adds them to the Vector.
 * @param files the list of files/* www  .  j  ava2 s .com*/
 * @param fileList the returned Vector of image files
 * @param imageFilter the filter to use to weed out non-image files
 * @return true if it should continue, false to stop
 */
protected boolean filterSelectedFileNames(final File[] files, final Vector<File> fileList,
        final ImageFilter imageFilter) {
    if (files == null || files.length == 0) {
        return false;
    }

    Hashtable<String, Boolean> badFileExts = new Hashtable<String, Boolean>();

    for (int i = 0; i < files.length; i++) {
        if (files[i].isFile()) {
            String fileName = files[i].getName();
            if (imageFilter.isImageFile(fileName)) {
                fileList.add(files[i]);
            } else {
                badFileExts.put(FilenameUtils.getExtension(fileName), true);
            }
        }
    }

    // No check to see if we had any bad files and warn the user about them
    if (badFileExts.size() > 0) {
        StringBuffer badExtStrBuf = new StringBuffer();
        for (String ext : badFileExts.keySet()) {
            if (badExtStrBuf.length() > 0)
                badExtStrBuf.append(", ");
            badExtStrBuf.append(ext);
        }

        // Now, if none of the files were good we tell them and then quit the import task
        if (fileList.size() == 0) {
            JOptionPane.showMessageDialog(UIRegistry.getMostRecentWindow(),
                    String.format(getResourceString("WB_WRONG_IMG_NO_IMAGES"),
                            new Object[] { badExtStrBuf.toString() }),
                    UIRegistry.getResourceString("WARNING"), JOptionPane.ERROR_MESSAGE);
            return false;

        }

        // So we know we have at least one good image file type
        // So let them choose if they want to continue.
        Object[] options = { getResourceString("Continue"), getResourceString("Stop") };

        if (JOptionPane.showOptionDialog(UIRegistry.getMostRecentWindow(),
                String.format(getResourceString("WB_WRONG_IMG_SOME_IMAGES"),
                        new Object[] { badExtStrBuf.toString() }),
                title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options,
                options[1]) == JOptionPane.NO_OPTION) {
            return false;
        }
    }
    return true;
}

From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java

private void attackToBBAction() {
    try {//w w  w.  j a v a 2 s .co m
        List<Attack> attacks = getSelectedResults();
        if (attacks.isEmpty()) {
            showInfo("Keine Angriffe ausgewhlt", true);
            return;
        }
        boolean extended = (JOptionPaneHelper.showQuestionConfirmBox(jResultFrame,
                "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]Angriffsplan[/size][/u]\n\n");
        } else {
            buffer.append("[u]Angriffsplan[/u]\n\n");
        }

        buffer.append(new AttackListFormatter().formatElements(attacks, extended));

        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(jResultFrame,
                    "Die ausgewhlten Angriffe bentigen mehr als 1000 BB-Codes\n"
                            + "und knnen daher im Spiel (Forum/IGM/Notizen) nicht auf einmal dargestellt werden.\nTrotzdem exportieren?",
                    "Zu viele BB-Codes", "Nein", "Ja") == JOptionPane.NO_OPTION) {
                return;
            }
        }

        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(b), null);
        showInfo("BB-Codes in Zwischenablage kopiert", true);
    } catch (Exception e) {
        logger.error("Failed to copy data to clipboard", e);
        showError("Fehler beim Kopieren in die Zwischenablage", true);
    }
}

From source file:it.isislab.dmason.util.SystemManagement.Master.thrower.DMasonMaster.java

private void loadUpdateFile() {
    String message = "There is no reference worker JAR. Do you want to specify a reference\n "
            + "JAR for the worker?\n" + "\n"
            + "If you choose Yes, D-Mason will ensure that every worker is running an\n"
            + "instance of the reference JAR and update them automatically.\n"
            + "If you choose No, D-Mason won't perform any check (this is highly\n"
            + "discouraged as it may lead to unreported errors during the simulation).\n"
            + "If you choose Cancel, D-Mason will exit.\n\n";

    int res = JOptionPane.showConfirmDialog(this, message);

    if (res == JOptionPane.OK_OPTION) {
        updateFile = showFileChooser();// www.j  a v  a2s  . com

        if (updateFile != null) {
            File dest = new File(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + updateFile.getName());

            try {
                FileUtils.copyFile(updateFile, dest);

                Digester dg = new Digester(DigestAlgorithm.MD5);

                InputStream in = new FileInputStream(dest);
                curWorkerDigest = dg.getDigest(in);
                workerJarName = updateFile.getName();

                String fileName = FilenameUtils.removeExtension(updateFile.getName());
                dg.storeToPropFile(FTP_HOME + dirSeparator + UPDATE_DIR + dirSeparator + fileName + ".hash");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (NoDigestFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        //         else
        //         {
        //            JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit.");
        //            this.dispose();
        //            System.exit(EXIT_ON_CLOSE);
        //         }

    } else if (res == JOptionPane.NO_OPTION) {
        enableWorkersUpdate = false;
        return;
    }
    if (updateFile == null || res == JOptionPane.CANCEL_OPTION || res == JOptionPane.CLOSED_OPTION) {
        JOptionPane.showMessageDialog(this, "User aborted, D-Mason will now exit.");
        this.dispose();
        System.exit(EXIT_ON_CLOSE);
    }
}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java

@Override
public boolean aboutToShutdown() {
    boolean result = true;
    unlock();/*from www .  ja  v a2s .  c  o  m*/
    if (isChanged()) {
        String msg = String.format(getResourceString("SaveChanges"), getTitle());
        JFrame topFrame = (JFrame) UIRegistry.getTopWindow();

        int rv = JOptionPane.showConfirmDialog(topFrame, msg, getResourceString("SaveChangesTitle"),
                JOptionPane.YES_NO_CANCEL_OPTION);
        if (rv == JOptionPane.YES_OPTION) {
            saveQuery(false);
        } else if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
            return false;
        } else if (rv == JOptionPane.NO_OPTION) {
            // nothing
        }
    }
    return result;
}

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

public boolean askToSave() {
    try {//from  w  w w  .j av a  2s  .  com
        if (diagram.getClassCount() > 0 && isChanged() == true) {
            int answ = JOptionPane.showConfirmDialog(frame, "Do you want to save the current project?",
                    "Save project?", JOptionPane.YES_NO_CANCEL_OPTION);
            if (answ == JOptionPane.YES_OPTION) {
                if (directoryName == null)
                    return saveWithAskingLocation();
                else
                    return save();
            } else if (answ == JOptionPane.NO_OPTION) {
                return true;
            } else
                return false;
        }
        return true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(frame, "A terrible error occured!\n" + e.getMessage() + "\n", "Error",
                JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR);
        return false;
    }
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the planAnalysisFramePanel.
 *//*from  ww  w. j  a  v  a  2s. co m*/
private ItFramePanel getPlanAnalysisFramePanel() {
    if (planAnalysisFramePanel == null) {
        planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE);

        // tool bar
        JToolBar chartsToolBar = new JToolBar();
        chartsToolBar.add(new JButton(drawChartAction));

        // charts panel
        chartsPanel = new JPanel();
        chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS));

        ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked",
                ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        //variableSelectionPanel.setBackground(new Color(151,151,157));

        JSplitPane split = new JSplitPane();
        split.setContinuousLayout(true);
        split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        split.setDividerLocation(2 * screenSize.height / 3);

        split.setDividerSize(8);
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120));
        split.setLeftComponent(new JScrollPane(variablesPlanTree));
        split.setRightComponent(new JScrollPane(selectedVariablesPlanTree));

        variableSelectionPanel.setContent(split, false);
        //variableSelectionPanel.setParentSplitPane()

        //JPanel variableSelectionPanel  = new JPanel(new BorderLayout());
        //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER);
        //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST);

        ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        variableGraphPanel.setContent(chartsPanel, true);

        JSplitPane mainvariablesplit = new JSplitPane();
        mainvariablesplit.setContinuousLayout(true);
        mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
        mainvariablesplit.setDividerLocation(150);
        mainvariablesplit.setDividerSize(8);
        //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        mainvariablesplit.setTopComponent(variableSelectionPanel);
        mainvariablesplit.setBottomComponent(variableGraphPanel);

        // main charts panel - used to locate the tool bar above the charts panel
        JPanel mainChartsPanel = new JPanel(new BorderLayout());
        mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH);
        //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER);
        mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER);

        //Results
        planInfoEditorPane = new JEditorPane();
        planInfoEditorPane.setContentType("text/html");
        planInfoEditorPane.setEditable(false);
        planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        planInfoEditorPane.setBackground(Color.WHITE);

        JPanel resultsPanel = new JPanel(new BorderLayout());

        JToolBar resultsToolBar = new JToolBar();
        resultsToolBar.setRollover(true);

        JButton planReportButton = new JButton("View Full Report",
                new ImageIcon("resources/images/viewreport.png"));
        planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need "
                + "access to the Internet.<br> The components used in the report require such access (no data is "
                + "sent through the Internet).</html>");
        planReportButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Opens html with defaut browser
                String path = "resources/report/Report.html";
                File report = new File(path);
                path = report.getAbsolutePath();
                try {
                    BrowserLauncher launcher = new BrowserLauncher();
                    launcher.openURLinBrowser("file://" + path);
                } catch (BrowserLaunchingInitializingException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                } catch (UnsupportedOperatingSystemException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                }
            }
        });
        resultsToolBar.add(planReportButton);

        resultsToolBar.addSeparator();
        JButton planReportDataButton = new JButton("Save Report Data",
                new ImageIcon("resources/images/savePDDL.png"));
        planReportDataButton.setToolTipText("<html>Save report data to file</html>");
        planReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Save report data
                if (solveResult != null) {
                    Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                            .getChild("lastOpenFolder");
                    JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                    fc.setDialogTitle("Save Report Data");
                    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                    fc.setFileFilter(new XMLFileFilter());

                    int returnVal = fc.showSaveDialog(ItSIMPLE.this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File selectedFile = fc.getSelectedFile();
                        String path = selectedFile.getPath();

                        if (!path.toLowerCase().endsWith(".xml")) {
                            path += ".xml";
                        }
                        //save file (xml)
                        try {
                            FileWriter file = new FileWriter(path);
                            file.write(XMLUtilities.toString(solveResult));
                            file.close();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }

                        //Save as a last open folder
                        String folder = selectedFile.getParent();
                        //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder");
                        lastOpenFolderElement.setText(folder);
                        XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                        //Ask if the user wants to save plans individually too.
                        boolean needToSavePlans = false;
                        int option = JOptionPane.showOptionDialog(instance,
                                "<html><center>Do you also want to save the plans"
                                        + "<br>in individual files?</center></html>",
                                "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                                null, null);
                        switch (option) {
                        case JOptionPane.YES_OPTION: {
                            needToSavePlans = true;
                        }
                            break;
                        case JOptionPane.NO_OPTION: {
                            needToSavePlans = false;
                        }
                            break;
                        }

                        if (needToSavePlans) {
                            //Close Open tabs
                            List<?> problems = null;
                            try {
                                XPath ppath = new JDOMXPath("project/domains/domain/problems/problem");
                                problems = ppath.selectNodes(solveResult);
                            } catch (JaxenException e2) {
                                e2.printStackTrace();
                            }

                            for (int i = 0; i < problems.size(); i++) {
                                Element problem = (Element) problems.get(i);
                                //create a folder for each problem and put all plans inside as xml files
                                String folderName = problem.getChildText("name");
                                String folderPath = selectedFile.getAbsolutePath()
                                        .replace(selectedFile.getName(), folderName);
                                //System.out.println(folderPath);
                                File planfolder = new File(folderPath);
                                boolean canSavePlan = false;
                                try {
                                    if (planfolder.mkdir()) {
                                        System.out.println("Directory '" + folderPath + "' created.");
                                        canSavePlan = true;
                                    } else {
                                        System.out.println("Directory '" + folderPath + "' was not created.");
                                    }

                                } catch (Exception ep) {
                                    ep.printStackTrace();
                                }

                                if (canSavePlan) {
                                    Element plans = problem.getChild("plans");
                                    for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it
                                            .hasNext();) {
                                        Element eaplan = it.next();
                                        Element theplanner = eaplan.getChild("planner");
                                        //save file (xml)
                                        String planFileName = "solution" + theplanner.getChildText("name") + "-"
                                                + theplanner.getChildText("version") + "-"
                                                + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                + ".xml";
                                        String planPath = folderPath + File.separator + planFileName;
                                        /*
                                        try {
                                            FileWriter planfile = new FileWriter(planPath);
                                            planfile.write(XMLUtilities.toString(eaplan));
                                            planfile.close();
                                            System.out.println("File '" + planPath + "' created.");
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                        }
                                        *
                                        */
                                        if (eaplan.getChild("plan").getChildren().size() > 0) {

                                            //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes
                                            String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan);
                                            String planFileNamePDDL = "solution"
                                                    + theplanner.getChildText("name") + "-"
                                                    + theplanner.getChildText("version") + "-"
                                                    + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                    + ".pddl";
                                            String planPathPDDL = folderPath + File.separator
                                                    + planFileNamePDDL;

                                            //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), "");
                                            //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl";
                                            //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL;
                                            //if (!theplanner.getChildText("name").contains("MIPS")){
                                            try {
                                                FileWriter planfile = new FileWriter(planPathPDDL);
                                                planfile.write(pddlplan);
                                                planfile.close();
                                                System.out.println("File '" + planPathPDDL + "' created.");
                                            } catch (IOException e1) {
                                                e1.printStackTrace();
                                            }
                                        } //}

                                    }

                                }

                            }
                        }

                    }
                } else {
                    appendOutputPanelText(">> No report data available to save! \n");
                }

            }
        });
        resultsToolBar.add(planReportDataButton);

        JButton openPlanReportDataButton = new JButton("Open Report Data",
                new ImageIcon("resources/images/openreport.png"));
        openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>");
        openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                planSimStatusBar.setText("Status: Opening File...");
                appendOutputPanelText(">> Opening File... \n");
                //Open report data
                Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                        .getChild("lastOpenFolder");
                JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                fc.setDialogTitle("Open Report Data");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setFileFilter(new XMLFileFilter());

                int returnVal = fc.showOpenDialog(ItSIMPLE.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {

                    File file = fc.getSelectedFile();
                    // Get itSIMPLE itSettings from itSettings.xml
                    org.jdom.Document resultsDoc = null;
                    try {
                        resultsDoc = XMLUtilities.readFromFile(file.getPath());
                        solveResult = resultsDoc.getRootElement();
                        //XMLUtilities.printXML(solveResult);
                        if (solveResult.getName().equals("projects")) {

                            String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult);
                            String comparisonReport = PlanAnalyzer
                                    .generateFullPlannersComparisonReport(solveResult);
                            //Save Comparison Report file
                            saveFile("resources/report/Report.html", comparisonReport);
                            setPlanInfoPanelText(report);
                            setPlanEvaluationInfoPanelText("");
                            appendOutputPanelText(">> Report data read! \n");

                            //My experiments
                            PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult);
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    //Save as a last open folder
                    String folder = fc.getSelectedFile().getParent();
                    lastOpenFolderElement.setText(folder);
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                } else {
                    planSimStatusBar.setText("Status:");
                    appendOutputPanelText(">> Canceled \n");
                }

            }
        });
        resultsToolBar.add(openPlanReportDataButton);

        JButton compareProjectReportDataButton = new JButton("Compare Project Data",
                new ImageIcon("resources/images/compare.png"));
        compareProjectReportDataButton.setToolTipText(
                "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>"
                        + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>");
        compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                final ProjectComparisonDialog dialog = new ProjectComparisonDialog();
                dialog.setVisible(true);

                final List<String> files = dialog.getFiles();

                if (files.size() > 1) {

                    new Thread() {
                        public void run() {
                            appendOutputPanelText(">> Project comparison report requested. Processing... \n");

                            planSimStatusBar.setText("Status: Reading files ...");
                            appendOutputPanelText(">> Reading files ... \n");

                            //base project file
                            String baseFileName = files.get(0);
                            appendOutputPanelText(">> Reading file '" + baseFileName + "' \n");
                            org.jdom.Document baseProjectDoc = null;
                            try {
                                baseProjectDoc = XMLUtilities.readFromFile(baseFileName);
                            } catch (Exception ec) {
                                ec.printStackTrace();
                            }
                            Element baseProject = null;
                            if (baseProjectDoc != null) {
                                baseProject = baseProjectDoc.getRootElement().getChild("project");
                            }

                            //The comparible projects
                            List<Element> comparableProjects = new ArrayList<Element>();

                            for (int i = 1; i < files.size(); i++) {
                                String eafile = files.get(i);
                                appendOutputPanelText(">> Reading file '" + eafile + "' \n");
                                org.jdom.Document eaProjectDoc = null;
                                try {
                                    eaProjectDoc = XMLUtilities.readFromFile(eafile);
                                } catch (Exception ec) {
                                    ec.printStackTrace();
                                }
                                if (eaProjectDoc != null) {
                                    comparableProjects.add(eaProjectDoc.getRootElement().getChild("project"));
                                }

                            }
                            appendOutputPanelText(">> Files read. Building report... \n");

                            String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject,
                                    comparableProjects);
                            saveFile("resources/report/Report.html", comparisonReport);
                            appendOutputPanelText(
                                    ">> Project comparison report generated. Press 'View Full Report'\n");
                            appendOutputPanelText(" \n");

                        }
                    }.start();

                }

            }
        });
        resultsToolBar.add(compareProjectReportDataButton);

        resultsPanel.add(resultsToolBar, BorderLayout.NORTH);
        resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER);

        JTabbedPane planAnalysisTabbedPane = new JTabbedPane();
        planAnalysisTabbedPane.addTab("Results", resultsPanel);
        planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel);
        planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel());
        planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel());
        planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel());
        planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel());

        JPanel planAnalysisPanel = new JPanel(new BorderLayout());
        //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH);
        planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER);
        planAnalysisFramePanel.setContent(planAnalysisPanel, false);

    }

    return planAnalysisFramePanel;
}

From source file:nl.tudelft.goal.SimpleIDE.FilePanel.java

/**
 * propose user to create new file as it does not exist now. Throws
 * GOALUserError if user cancels the proposal or if creation of file failed.
 *
 * It's a bit weird to have static function in FilePanel, but also it would
 * be weird to put a GUI function in IOManager. CHECK
 *
 * @param parent//from  w w w.  j a v  a2s.  co  m
 *            is the GUI parent for this panel, used for centering the
 *            panel.
 * @param newFile
 *            is {@link File} to be created. Filename should have the
 *            extension.
 * @param extension
 *            is the type of extension to be made, used to pick up the
 *            appropriate template for the file.
 */
public static void proposeToCreate(Container parent, File newFile, Extension extension) throws GOALUserError {
    try {
        int selection = JOptionPane.showConfirmDialog(parent, "The file " //$NON-NLS-1$
                + newFile + " does not exist. Create it?", //$NON-NLS-1$
                "Create new file?", JOptionPane.YES_NO_OPTION); //$NON-NLS-1$
        if (selection == JOptionPane.NO_OPTION) {
            throw new GOALUserError("File " + newFile //$NON-NLS-1$
                    + " does not exist; creation cancelled"); //$NON-NLS-1$
        }
        PlatformManager.createfile(newFile, extension);
    } catch (IOException e) {
        throw new GOALUserError("Cannot create file " + newFile, e); //$NON-NLS-1$
    }
}

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

/**
 * Import cancelled dialog// w ww  . j a  v  a  2  s. c  om
 * 
 * @param frame parent frame
 * @return - true / false if import cancelled
 */
private boolean cancelImportDialog(Component frame) {
    String s1 = "OK";
    String s2 = "Force Quit Now";
    Object[] options = { s1, s2 };
    int n = JOptionPane.showOptionDialog(frame, "Click 'OK' to cancel after the current file has\n"
            + "finished importing, or click 'Force Quit Now' to\n"
            + "force the importer to quit importing immediately.\n\n"
            + "You should only force quit the importer if there\n"
            + "has been an import problem, as this leaves partial\n" + "files in your server dataset.\n\n",
            "Cancel Import", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, s1);
    if (n == JOptionPane.NO_OPTION) {
        return true;
    } else {
        return false;
    }
}

From source file:org.apache.cayenne.modeler.action.OpenProjectAction.java

protected boolean processUpgrades(UpgradeMetaData md) {
    // need an upgrade
    int returnCode = JOptionPane.showConfirmDialog(Application.getFrame(),
            "Project needs an upgrade to a newer version. Upgrade?", "Upgrade Needed",
            JOptionPane.YES_NO_OPTION);
    if (returnCode == JOptionPane.NO_OPTION) {
        return false;
    }//from  ww  w. java  2 s  .c o m
    return true;
}