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:jeplus.JEPlusFrameMain.java

/**
 * Start batch operation// w  w  w  . ja  va 2 s . c om
 * @param file
 * @param dir
 * @return 
 */
public boolean createJobList(String file, String dir) {
    if (this.validateBatchJobs()) {
        // Check batch size and exec agent's capacity
        if (BatchManager.getBatchInfo()
                .getTotalNumberOfJobs() > 100000 /* BatchManager.getAgent().getQueueCapacity() */) {
            // Project is too large
            StringBuilder buf = new StringBuilder("<html><p>The estimated batch size (");
            buf.append(LargeIntFormatter.format(BatchManager.getBatchInfo().getTotalNumberOfJobs()));
            buf.append(") exceeds 10,000. </p><p>Are you sure to create a list of all jobs?</p>");
            buf.append("<p>Select Yes if you want to go ahead generate the job list file. </p>");
            int res = JOptionPane.showConfirmDialog(this, buf.toString(), "List is too long",
                    JOptionPane.YES_NO_OPTION);
            if (res == JOptionPane.NO_OPTION) {
                OutputPanel.appendContent("Operation cancelled.\n");
                return false;
            }
        }
        // Build jobs
        displayInfo("Building jobs ... ");
        BatchManager.buildJobs();
        displayInfo("" + BatchManager.getJobQueue().size() + " jobs created.\n");
        displayInfo("Saving job list in " + dir + file + "...\n");
        BatchManager.writeJobListFile(file, dir);
        displayInfo("Done.\n");
    } else {

    }
    return true;
}

From source file:edu.harvard.i2b2.query.QueryConceptTreePanel.java

private void populateChildNodes(DefaultMutableTreeNode node) {
    QueryConceptTreeNodeData data = (QueryConceptTreeNodeData) node.getUserObject();
    try {/*from w ww  .j  a v a  2 s .  co m*/
        GetChildrenType parentType = new GetChildrenType();

        parentType.setMax(null);//Integer.parseInt(System.getProperty("OntMax")));
        parentType.setHiddens(Boolean.parseBoolean(System.getProperty("OntHiddens")));
        parentType.setSynonyms(Boolean.parseBoolean(System.getProperty("OntSynonyms")));

        //   log.info("sent : " + parentType.getMax() + System.getProperty("OntMax") + System.getProperty("OntHiddens")
        //      + System.getProperty("OntSynonyms") );

        parentType.setMax(parentPanel.max_child());
        //System.out.println("Max children set to: "+parentPanel.max_child());

        parentType.setBlob(true);
        //   parentType.setType("all");

        parentType.setParent(data.fullname());
        //System.out.println(parentType.getParent());

        //Long time = System.currentTimeMillis();
        //log.info("making web service call " + time);
        GetChildrenResponseMessage msg = new GetChildrenResponseMessage();
        StatusType procStatus = null;
        //while(procStatus == null || !procStatus.getType().equals("DONE")){
        String response = OntServiceDriver.getChildren(parentType, "");
        //System.out.println("Ontology service getchildren response: "+response);
        parentPanel.parentPanel.lastResponseMessage(response);
        //         Long time2 = System.currentTimeMillis();
        //         log.info("returned from 1st web service call " + (time2 - time));         
        procStatus = msg.processResult(response);
        //         log.info(procStatus.getType());
        //         log.info(procStatus.getValue());
        int result;
        if (procStatus.getValue().equals("MAX_EXCEEDED")) {
            result = JOptionPane.showConfirmDialog(parentPanel,
                    "The node has exceeded maximum number of children.\n" + "Do you want to continue?",
                    "Please note ...", JOptionPane.YES_NO_OPTION);

            if (result == JOptionPane.NO_OPTION) {
                DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0);
                QueryConceptTreeNodeData tmpdata = (QueryConceptTreeNodeData) tmpnode.getUserObject();
                tmpdata.name("Over maximum number of child nodes");
                //procStatus.setType("DONE");
                jTree1.repaint();
                jTree1.scrollPathToVisible(new TreePath(tmpnode.getPath()));
                return;
            } else {
                parentType.setMax(null);
                response = OntServiceDriver.getChildren(parentType, "");
                procStatus = msg.processResult(response);
            }
        }

        if (!procStatus.getType().equals("DONE")) {
            JOptionPane.showMessageDialog(parentPanel, "Error message delivered from the remote server, "
                    + "you may wish to retry your last action");
            return;
        }

        ConceptsType allConcepts = msg.doReadConcepts();
        List concepts = allConcepts.getConcept();
        if (concepts != null) {
            addNodesFromOntXML(concepts, node);
            DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) node.getChildAt(0);
            treeModel.removeNodeFromParent(tmpnode);
            jTree1.scrollPathToVisible(new TreePath(node.getPath()));
        }

    } catch (Exception e) {
        e.printStackTrace();
        JOptionPane.showMessageDialog(parentPanel,
                "Response delivered from the remote server could not be understood,\n"
                        + "you may wish to retry your last action.");
        return;
    }
}

From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java

private JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();
    JMenuItem mItem = null;//  w  ww . ja va2s. c om
    String urlString;
    URL url;

    //============================================================================================
    // File Menu
    //============================================================================================
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    menuBar.add(fileMenu);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-new.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconNew = new ImageIcon(url, "New");
    mItem = new JMenuItem(new NewTextFileAction("New", iconNew));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-open.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconOpen = new ImageIcon(url, "Open");
    mItem = new JMenuItem(new OpenFileAction("Open...", iconOpen, new Integer(KeyEvent.VK_A)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSave = new ImageIcon(url, "Save");
    mItem = new JMenuItem(new SaveAction("Save", iconSave, new Integer(KeyEvent.VK_S)));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-save-as.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconSaveAs = new ImageIcon(url, "Save As");
    mItem = new JMenuItem(new SaveAsAction("Save As...", iconSaveAs));
    fileMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/status/folder-visiting.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconClose = new ImageIcon(url, "Close All Tabs");
    mItem = new JMenuItem(new CloseAllTabsAction("Close All Tabs...", iconClose, new Integer(KeyEvent.VK_C)));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-print.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPrint = new ImageIcon(url, "Print");
    mItem = new JMenuItem(new PrintAction("Print...", iconPrint));
    fileMenu.add(mItem);

    fileMenu.addSeparator();

    //      exit menu item
    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/system-log-out.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExit = new ImageIcon(url, "Exit");
    mItem = new JMenuItem(new ExitAction("Exit", iconExit));
    fileMenu.add(mItem);

    //============================================================================================
    // Edit Menu
    //============================================================================================
    JMenu editMenu = new JMenu("Edit");
    editMenu.setMnemonic(KeyEvent.VK_E);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-cut.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCut = new ImageIcon(url, "Cut");
    mItem = new JMenuItem(new DefaultEditorKit.CutAction());
    mItem.setText("Cut");
    mItem.setIcon(iconCut);
    mItem.setMnemonic(KeyEvent.VK_X);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-copy.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCopy = new ImageIcon(url, "Copy");
    mItem = new JMenuItem(new DefaultEditorKit.CopyAction());
    mItem.setText("Copy");
    mItem.setIcon(iconCopy);
    mItem.setMnemonic(KeyEvent.VK_C);
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-paste.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconPaste = new ImageIcon(url, "Paste");
    mItem = new JMenuItem(new DefaultEditorKit.PasteAction());
    mItem.setText("Paste");
    mItem.setIcon(iconPaste);
    mItem.setMnemonic(KeyEvent.VK_V);
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-undo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconUndo = new ImageIcon(url, "Undo");
    mItem = new JMenuItem(new UndoAction("Undo", iconUndo, new Integer(KeyEvent.VK_Z)));
    editMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-redo.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconRedo = new ImageIcon(url, "Redo");
    mItem = new JMenuItem(new RedoAction("Redo", iconRedo, new Integer(KeyEvent.VK_Y)));
    editMenu.add(mItem);

    editMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/categories/preferences-system.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconView = new ImageIcon(url, "Preferences");
    mItem = new JMenuItem("Preferences");
    mItem.setIcon(iconView);
    mItem.setToolTipText("Edit jMetrik preferences");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikPreferencesManager prefs = new JmetrikPreferencesManager();
            prefs.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
            prefs.addPropertyChangeListener(statusBar.getStatusListener());
            JmetrikPreferencesDialog propDialog = new JmetrikPreferencesDialog(Jmetrik.this, prefs);
            //                propDialog.loadPreferences();
            propDialog.setVisible(true);
        }
    });
    editMenu.setMnemonic('e');
    editMenu.add(mItem);

    menuBar.add(editMenu);

    //============================================================================================
    // Log Menu
    //============================================================================================
    JMenu logMenu = new JMenu("Log");

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/document-properties.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconLog = new ImageIcon(url, "View Log");
    mItem = new JMenuItem(new ViewLogAction("View Log", iconLog));
    logMenu.setMnemonic('l');
    logMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/mimetypes/text-x-generic.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconCommand = new ImageIcon(url, "Script Log");
    mItem = new JMenuItem(new ViewScriptLogAction("Script Log", iconCommand));
    logMenu.setMnemonic('c');
    logMenu.add(mItem);

    menuBar.add(logMenu);

    //============================================================================================
    // Manage Menu
    //============================================================================================
    JMenu manageMenu = new JMenu("Manage");
    manageMenu.setMnemonic('m');

    mItem = new JMenuItem("New Database...");//create db
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            NewDatabaseDialog newDatabaseDialog = new NewDatabaseDialog(Jmetrik.this);
            newDatabaseDialog.setVisible(true);
            if (newDatabaseDialog.canRun()) {
                if (workspace == null) {
                    //                        workspace = new Workspace(workspaceTree, tabbedPane, dataTable, variableTable);
                    workspace = new Workspace(workspaceList, tabbedPane, dataTable, variableTable);
                    workspace.addPropertyChangeListener(statusBar.getStatusListener());
                    workspace.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener());
                }
                workspace.runProcess(newDatabaseDialog.getCommand());
                //                    workspace.createDatabase(newDatabaseDialog.getCommand());
            }
        }
    });
    manageMenu.add(mItem);

    mItem = new JMenuItem("Open Database...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog openDbDialog = new OpenDatabaseDialog(Jmetrik.this, "Open");
            JList l = openDbDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            openDbDialog.setVisible(true);
            if (openDbDialog.canRun()) {
                openWorkspace(openDbDialog.getDatabaseName());
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDelete = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Database...");
    mItem.setIcon(iconDelete);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            OpenDatabaseDialog selectDialog = new OpenDatabaseDialog(Jmetrik.this, "Delete");
            JList l = selectDialog.getDatabaseList();
            workspace.setDatabaseListModel(l);
            selectDialog.setVisible(true);
            if (selectDialog.canRun()) {
                int answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                        "Do you want to delete " + selectDialog.getDatabaseName()
                                + " and all of its contents? \n"
                                + "All data will be permanently deleted. You cannot undo this action.",
                        "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);

                if (answer == JOptionPane.YES_OPTION) {
                    DatabaseCommand command = new DatabaseCommand();
                    DatabaseName dbName = new DatabaseName(selectDialog.getDatabaseName());
                    command.getFreeOption("name").add(dbName.getName());
                    command.getSelectOneOption("action").setSelected("delete-db");

                    DatabaseName currentDb = workspace.getDatabaseName();
                    if (currentDb.getName().equals(dbName.getName())) {
                        JOptionPane.showMessageDialog(Jmetrik.this,
                                "You cannot delete the current database.\n"
                                        + "Close the database before attempting to delete it.",
                                "Database Delete Error", JOptionPane.WARNING_MESSAGE);
                    } else {
                        workspace.runProcess(command);
                    }

                }

            }
        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/accessories-text-editor.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDesc = new ImageIcon(url, "Descriptions");
    mItem = new JMenuItem("Table Descriptions...");
    mItem.setIcon(iconDesc);
    mItem.addActionListener(new TableDescriptionActionListener());
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/list-add.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconImport = new ImageIcon(url, "Import");
    mItem = new JMenuItem("Import Data...");
    mItem.setIcon(iconImport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                ImportDialog importDialog = new ImportDialog(Jmetrik.this, workspace.getDatabaseName(),
                        importExportPath);
                importDialog.setVisible(true);

                if (importDialog.canRun()) {
                    importExportPath = importDialog.getCurrentDirectory();
                    workspace.runProcess(importDialog.getCommand());
                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before importing data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/format-indent-less.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconExport = new ImageIcon(url, "Export");
    mItem = new JMenuItem("Export Data...");
    mItem.setIcon(iconExport);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before exporting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n "
                                + "Select a table to continue the export.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                ExportDataDialog exportDialog = new ExportDataDialog(Jmetrik.this, workspace.getDatabaseName(),
                        tableName, importExportPath);
                if (exportDialog.canRun()) {
                    importExportPath = exportDialog.getCurrentDirectory();
                    workspace.runProcess(exportDialog.getCommand());
                }
            }
        }
    });
    manageMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteTable = new ImageIcon(url, "Delete");
    mItem = new JMenuItem("Delete Table...");
    mItem.setIcon(iconDeleteTable);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (workspace.databaseOpened()) {
                DeleteTableDialog deleteDialog = new DeleteTableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), (SortedListModel<DataTableName>) workspaceList.getModel());
                deleteDialog.setVisible(true);
                if (deleteDialog.canRun()) {
                    int nSelected = deleteDialog.getNumberOfSelectedTables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " tables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        ArrayList<DataTableName> dList = deleteDialog.getSelectedTables();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the table " + dList.get(0).getTableName() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteDialog.getCommand());
                    }

                }
            } else {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before deleting a table.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            }

        }
    });
    manageMenu.add(mItem);

    manageMenu.addSeparator();

    SubsetCasesProcess subsetCasesProcess = new SubsetCasesProcess();
    subsetCasesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    SubsetVariablesProcess subsetVariablesProcess = new SubsetVariablesProcess();
    subsetVariablesProcess.addMenuItem(Jmetrik.this, manageMenu, dialogs, workspace, workspaceList);

    urlString = "/org/tango-project/tango-icon-theme/16x16/actions/edit-delete.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconDeleteVariables = new ImageIcon(url, "Delete Variables");
    mItem = new JMenuItem("Delete Variables...");
    mItem.setIcon(iconDeleteVariables);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (!workspace.databaseOpened()) {
                JOptionPane.showMessageDialog(Jmetrik.this, "You must open a database before subsetting data.",
                        "No Open Database", JOptionPane.ERROR_MESSAGE);
            } else if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must select a table in the workspace list. \n " + "Select a table to continue.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else if (workspace.tableOpen()) {
                DeleteVariableDialog deleteVariableDialog = new DeleteVariableDialog(Jmetrik.this,
                        workspace.getDatabaseName(), workspace.getCurrentDataTable(), workspace.getVariables());
                deleteVariableDialog.setVisible(true);
                if (deleteVariableDialog.canRun()) {
                    int nSelected = deleteVariableDialog.getNumberOfSelectedVariables();
                    int answer = JOptionPane.NO_OPTION;
                    if (nSelected > 1) {
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete these " + nSelected + " variables? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Variables", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    } else {
                        VariableAttributes v = deleteVariableDialog.getSelectedVariable();
                        answer = JOptionPane.showConfirmDialog(Jmetrik.this,
                                "Do you want to delete the variable " + v.getName().toString() + "? \n"
                                        + "All data will be permanently deleted. You cannot undo this action.",
                                "Delete Database", JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION);
                    }
                    if (answer == JOptionPane.YES_OPTION) {
                        workspace.runProcess(deleteVariableDialog.getCommand());
                    }
                }
            }

        }
    });
    manageMenu.add(mItem);

    menuBar.add(manageMenu);

    //============================================================================================
    // Transform Menu
    //============================================================================================
    JMenu transformMenu = new JMenu("Transform");
    transformMenu.setMnemonic('t');

    BasicScoringProcess basicScoringProcess = new BasicScoringProcess();
    basicScoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    ScoringProcess scoringProcess = new ScoringProcess();
    scoringProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    RankingProcess rankingProcess = new RankingProcess();
    rankingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    TestScalingProcess testScalingProcess = new TestScalingProcess();
    testScalingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    LinearTransformationProcess linearTransformationProcess = new LinearTransformationProcess();
    linearTransformationProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    transformMenu.addSeparator();

    IrtLinkingProcess irtLinkingProcess = new IrtLinkingProcess();
    irtLinkingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    IrtEquatingProcess irtEquatingProcess = new IrtEquatingProcess();
    irtEquatingProcess.addMenuItem(Jmetrik.this, transformMenu, dialogs, workspace, workspaceList);

    menuBar.add(transformMenu);

    //============================================================================================
    // Analyze Menu
    //============================================================================================
    JMenu analyzeMenu = new JMenu("Analyze");
    analyzeMenu.setMnemonic('a');

    FrequencyProcess frequencyProcess = new FrequencyProcess();
    frequencyProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    DescriptiveProcess descriptiveProcess = new DescriptiveProcess();
    descriptiveProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CorrelationProcess correlationProcess = new CorrelationProcess();
    correlationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    ItemAnalysisProcess itemAnalysisProcess = new ItemAnalysisProcess();
    itemAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    CmhProcess cmhProcess = new CmhProcess();
    cmhProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    analyzeMenu.addSeparator();

    RaschAnalysisProcess raschAnalysisProcess = new RaschAnalysisProcess();
    raschAnalysisProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtItemCalibrationProcess irtItemCalibrationProcess = new IrtItemCalibrationProcess();
    irtItemCalibrationProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    IrtPersonScoringProcess irtPersonScoringProcess = new IrtPersonScoringProcess();
    irtPersonScoringProcess.addMenuItem(Jmetrik.this, analyzeMenu, dialogs, workspace, workspaceList);

    menuBar.add(analyzeMenu);

    //============================================================================================
    // Graph Menu
    //============================================================================================
    JMenu graphMenu = new JMenu("Graph");
    graphMenu.setMnemonic('g');

    BarChartProcess barchartProcess = new BarChartProcess();
    barchartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    PieChartProcess piechartProcess = new PieChartProcess();
    piechartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    HistogramProcess histogramProcess = new HistogramProcess();
    histogramProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    DensityProcess densityProcess = new DensityProcess();
    densityProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    LineChartProcess lineChartProcess = new LineChartProcess();
    lineChartProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    ScatterplotProcess scatterplotProcess = new ScatterplotProcess();
    scatterplotProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    graphMenu.addSeparator();

    NonparametricCurveProcess nonparametricCurveProcess = new NonparametricCurveProcess();
    nonparametricCurveProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    mItem = new JMenuItem("Irt Plot...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            DataTableName tableName = (DataTableName) workspaceList.getSelectedValue();
            if (tableName == null) {
                JOptionPane.showMessageDialog(Jmetrik.this,
                        "You must open a database and select a table. \n "
                                + "Select a table to continue scoring.",
                        "No Table Selected", JOptionPane.ERROR_MESSAGE);
            } else {
                if (irtPlotDialog == null && workspace.tableOpen()) {

                    //Note that starting this dialog is different because variables
                    //names must be obtained from the rows of a table.

                    DatabaseAccessObject dao = workspace.getDatabaseFactory().getDatabaseAccessObject();

                    try {
                        ArrayList<VariableAttributes> tempVar = dao.getVariableAttributesFromColumn(
                                workspace.getConnection(), workspace.getCurrentDataTable(),
                                new VariableName("name"));
                        irtPlotDialog = new IrtPlotDialog(Jmetrik.this, workspace.getDatabaseName(), tableName,
                                tempVar, (SortedListModel<DataTableName>) workspaceList.getModel());
                    } catch (SQLException ex) {
                        logger.fatal(ex.getMessage(), ex);
                        firePropertyChange("error", "", "Error - Check log for details.");
                    }
                }
                if (irtPlotDialog != null)
                    irtPlotDialog.setVisible(true);
            }

            if (irtPlotDialog != null && irtPlotDialog.canRun()) {
                workspace.runProcess(irtPlotDialog.getCommand());
            }
        }
    });
    graphMenu.add(mItem);

    ItemMapProcess itemMapProcess = new ItemMapProcess();
    itemMapProcess.addMenuItem(Jmetrik.this, graphMenu, dialogs, workspace, workspaceList);

    menuBar.add(graphMenu);

    //============================================================================================
    // Command Menu
    //============================================================================================

    JMenu commandMenu = new JMenu("Commands");
    commandMenu.setMnemonic('c');
    mItem = new JMenuItem("Run command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JScrollPane pain = (JScrollPane) tabbedPane.getSelectedComponent();
            JViewport vp = pain.getViewport();
            Component c = vp.getComponent(0);
            if (c instanceof JmetrikTextFile) {
                JmetrikTab tempTab = (JmetrikTab) tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex());
                JmetrikTextFile textFile = (JmetrikTextFile) c;
                workspace.runFromSyntax(textFile.getText());
            }
        }
    });
    commandMenu.add(mItem);

    mItem = new JMenuItem("Stop command");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    mItem = new JMenuItem("Command Reference...");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //add something
        }
    });
    mItem.setEnabled(false);
    commandMenu.add(mItem);

    menuBar.add(commandMenu);

    //============================================================================================
    // Help Menu
    //============================================================================================
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic('h');
    mItem = new JMenuItem("Quick Start Guide");
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Desktop deskTop = Desktop.getDesktop();
            try {
                URI uri = new URI("http://www.itemanalysis.com/quick-start-guide.php");
                deskTop.browse(uri);
            } catch (URISyntaxException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            } catch (IOException ex) {
                logger.fatal(ex.getMessage(), ex);
                firePropertyChange("error", "", "Error - Check log for details.");
            }
        }
    });
    helpMenu.add(mItem);

    urlString = "/org/tango-project/tango-icon-theme/16x16/apps/help-browser.png";
    url = this.getClass().getResource(urlString);
    ImageIcon iconAbout = new ImageIcon(url, "About");
    mItem = new JMenuItem("About");
    mItem.setIcon(iconAbout);
    mItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JmetrikAboutDialog aboutDialog = new JmetrikAboutDialog(Jmetrik.this, APP_NAME, VERSION, AUTHOR,
                    RELEASE_DATE, COPYRIGHT_YEAR, BETA_VERSION);
            aboutDialog.setVisible(true);
        }
    });
    helpMenu.add(mItem);

    menuBar.add(helpMenu);

    return menuBar;
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public void actionPerformed(ActionEvent event) {
    // Get the name of the action command
    String command = event.getActionCommand();

    if (sessionActions.containsKey(event.getActionCommand())) {
        SessionProviderAction action = (SessionProviderAction) sessionActions.get(event.getActionCommand());
        SessionProviderFrame frame;/*from   ww  w. ja v a2s  . c  o  m*/
        // Do we have an existing frame?
        for (Iterator it = sessionFrames.iterator(); it.hasNext();) {
            frame = (SessionProviderFrame) it.next();
            if (action.getProvider().getProviderClass().isInstance(frame.getSessionPanel())
                    && frame.getSessionPanel().singleFrame()) {
                frame.show();
                return;
            }
        }

        try {
            frame = new SessionProviderFrame(getCurrentConnectionProfile(), ssh, action.getProvider());
            if (frame.initFrame(getApplication())) {
                frame.show();
                sessionFrames.add(frame);
            }

        } catch (Throwable ex) {
            ex.printStackTrace();
        }
    }
    /*if ((shiftAction != null)
        && command.equals(shiftAction.getActionCommand())) {
      //boolean error = false;
        try {
          SessionProviderFrame browserFrame = new SessionProviderFrame(
         getCurrentConnectionProfile(),
                                ssh,
         SessionProviderFactory.getInstance().getProvider("shift"));
          if (PreferencesStore.preferenceExists(PREF_SHIFT_GEOMETRY)) {
    browserFrame.setBounds(PreferencesStore.getRectangle(
        PREF_SHIFT_GEOMETRY, browserFrame.getBounds()));
          }
          else {
    browserFrame.setLocation(40, 40);
          }
          browserFrame.init(getApplication());
          browserFrame.show();
          browserFrames.add(browserFrame);
        }
        catch (Exception e) {
          showExceptionMessage("Error", e.getMessage());
        }
      }
      /*if (browserFrame != null) {
         //  We need to go back to windowed mode if in full screen mode
         if (!browserFrame.isVisible()) {
           setFullScreenMode(false);
         }
         browserFrame.setVisible(!browserFrame.isVisible());
       }*/

    /* if ( (tunnelingAction != null)
         && command.equals(tunnelingAction.getActionCommand())) {
         try {
    if(tunnelingFrame==null) {
    tunnelingFrame = new SessionProviderFrame(
         getCurrentConnectionProfile(),
                                  ssh,
         SessionProviderFactory.getInstance().getProvider("tunneling"));
    /*if (PreferencesStore.preferenceExists(PREF_SHIFT_GEOMETRY)) {
       tunnelingFrame.setBounds(PreferencesStore.getRectangle(
           PREF_SHIFT_GEOMETRY, tunnelingFrame.getBounds()));
     }
     else {
       tunnelingFrame.setLocation(40, 40);
     }*/

    /*      }
    tunnelingFrame.init(getApplication());
    tunnelingFrame.show();
        }
        catch (Exception e) {
    showExceptionMessage("Error", e.getMessage());
        }*/

    /*if (portForwardingDialog == null) {
         Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class,
     this);
       if (parent instanceof JFrame) {
         portForwardingDialog = new JDialog( (JFrame) parent,
                                      "Port Forwarding", false);
       }
       else if (parent instanceof JDialog) {
         portForwardingDialog = new JDialog( (JDialog) parent,
                                      "Port Forwarding", false);
       }
       else {
         portForwardingDialog = new JDialog( (JFrame)null,
                                      "Port Forwarding", false);
       }
       portForwardingDialog.getContentPane().setLayout(new BorderLayout());
       portForwardingDialog.getContentPane().add(portForwardingPane,
                                           BorderLayout.CENTER);
       portForwardingDialog.pack();
       if (PreferencesStore.preferenceExists(
     PREF_PORT_FORWARDING_GEOMETRY)) {
         portForwardingDialog.setBounds(PreferencesStore
                                  .getRectangle(
       PREF_PORT_FORWARDING_GEOMETRY,
       portForwardingDialog.getBounds()));
       }
       else {
         portForwardingDialog.setLocation(40, 40);
         portForwardingDialog.setSize(new Dimension(260, 420));
       }
       PreferencesStore.restoreTableMetrics(portForwardingPane
                                      .getPortForwardingTable(),
     PREF_PORT_FORWARDING_FORWARDS_TABLE_METRICS,
     new int[] {68, 62, 44, 54, 98, 78});
       PreferencesStore.restoreTableMetrics(portForwardingPane.
                                      getActiveChannelPane()
                                      .getActiveChannelTable(),
     PREF_PORT_FORWARDING_ACTIVE_TABLE_METRICS,
     new int[] {22, 22, 92, 264});
       if (PreferencesStore.preferenceExists(
     PREF_PORT_FORWARDING_DIVIDER_LOCATION)) {
         portForwardingPane.setDividerLocation(PreferencesStore
                                         .getInt(
       PREF_PORT_FORWARDING_DIVIDER_LOCATION, 100));
       }
       else {
         portForwardingPane.setDividerLocation(0.75d);
       }
     }
     //  We need to go back to windowed mode if in full screen mode
     if (!portForwardingDialog.isVisible()) {
       setFullScreenMode(false);
     }
     portForwardingDialog.setVisible(!portForwardingDialog.isVisible());*/
    //}

    if ((stopAction != null) && command.equals(stopAction.getActionCommand())) {
        stopRecording();
    }

    if ((recordAction != null) && command.equals(recordAction.getActionCommand())) {
        //  We need to go back to windowed mode if in full screen mode
        setFullScreenMode(false);

        // Select the file to record to
        JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home"));
        int ret = fileDialog.showSaveDialog(this);

        if (ret == fileDialog.APPROVE_OPTION) {
            recordingFile = fileDialog.getSelectedFile();

            if (recordingFile.exists()
                    && (JOptionPane.showConfirmDialog(this, "File exists. Are you sure?", "File exists",
                            JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.NO_OPTION)) {
                return;
            }

            try {
                recordingOutputStream = new FileOutputStream(recordingFile);
                statusBar.setStatusText("Recording to " + recordingFile.getName());
                setAvailableActions();
            } catch (IOException ioe) {
                showExceptionMessage("Error", "Could not open file for recording\n\n" + ioe.getMessage());
            }
        }
    }

    if ((playAction != null) && command.equals(playAction.getActionCommand())) {
        //  We need to go back to windowed mode if in full screen mode
        setFullScreenMode(false);

        // Select the file to record to
        JFileChooser fileDialog = new JFileChooser(System.getProperty("user.home"));
        int ret = fileDialog.showOpenDialog(this);

        if (ret == fileDialog.APPROVE_OPTION) {
            File playingFile = fileDialog.getSelectedFile();
            InputStream in = null;

            try {
                statusBar.setStatusText("Playing from " + playingFile.getName());
                in = new FileInputStream(playingFile);

                byte[] b = null;
                int a = 0;

                while (true) {
                    a = in.available();

                    if (a == -1) {
                        break;
                    }

                    if (a == 0) {
                        a = 1;
                    }

                    b = new byte[a];
                    a = in.read(b);

                    if (a == -1) {
                        break;
                    }

                    //emulation.write(b);
                    emulation.getOutputStream().write(b);
                }

                statusBar.setStatusText("Finished playing " + playingFile.getName());
                setAvailableActions();
            } catch (IOException ioe) {
                statusBar.setStatusText("Error playing " + playingFile.getName());
                showExceptionMessage("Error", "Could not open file for playback\n\n" + ioe.getMessage());
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException ioe) {
                        log.error(ioe);
                    }
                }
            }
        }
    }

    if ((newAction != null) && command.equals(newAction.getActionCommand())) {
        setFullScreenMode(false);

        // Clear the screen
        emulation.clearScreen();
        emulation.setCursorPosition(0, 0);

        // Force a repaint
        terminal.refresh();

        SshToolsConnectionProfile p = SshToolsConnectionPanel.showConnectionDialog(this,
                getCurrentConnectionProfile(), getAdditionalConnectionTabs());

        if (p != null) {
            currentConnectionProfile = p;
            setContainerTitle(null);
            setNeedSave(true);
            connect(p, true);
        } else {
            log.info("New connection cancelled");
        }

        return;
    }

    if ((closeAction != null) && command.equals(closeAction.getActionCommand())) {
        if (ssh != null) {
            if (performVerifiedDisconnect(true)) {
                disconnecting = true;
                ssh.disconnect();
            }
        }
    }

    if ((openAction != null) && command.equals(openAction.getActionCommand())) {
        open();
    }

    if ((saveAction != null) && command.equals(saveAction.getActionCommand())) {
        // Make sure we dont have a null connection object
        saveConnection(false);
    }

    if ((saveAsAction != null) && command.equals(saveAsAction.getActionCommand())) {
        saveConnection(true);
    }

    //  Keygen
    if ((keygenAction != null) && event.getActionCommand().equals(keygenAction.getActionCommand())) {
        if (keygenFrame == null) {
            keygenFrame = new com.sshtools.common.keygen.Main();
            keygenFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            keygenFrame.pack();
            UIUtil.positionComponent(SwingConstants.CENTER, keygenFrame);
        }

        if (!keygenFrame.isVisible()) {
            setFullScreenMode(false);
        }

        keygenFrame.setVisible(!keygenFrame.isVisible());
    }

    //GSI options
    if ((proxyInfoAction != null) && command.equals(proxyInfoAction.getActionCommand())) {
        ProxyHelper.showProxyInfo(getContainer().getWindow());
    }
    if ((proxyDestroyAction != null) && command.equals(proxyDestroyAction.getActionCommand())) {
        ProxyHelper.destroyProxy();
        setAvailableActions();
    }
}

From source file:ca.uhn.hl7v2.testpanel.controller.Controller.java

/**
 * Prompt for a filename and save the currently selected messages
 * //from   www  .  jav  a 2  s .  c o m
 * @return Returns true if the file is saved
 */
public boolean saveMessagesAs(Hl7V2MessageCollection theSelectedValue) {
    Validate.notNull(theSelectedValue);

    if (mySaveMessagesFileChooser == null) {
        mySaveMessagesFileChooser = new JFileChooser(Prefs.getInstance().getSavePathMessages());
        mySaveMessagesFileChooser.setDialogTitle("Choose a file to save the current message(s) to");
        mySaveMessagesFileChooserAccessory = new FileChooserSaveAccessory();
        mySaveMessagesFileChooser.setAccessory(mySaveMessagesFileChooserAccessory);

        FileFilter type = new ExtensionFilter("HL7 Files", new String[] { ".hl7" });
        mySaveMessagesFileChooser.addChoosableFileFilter(type);

        type = new ExtensionFilter("XML Files", new String[] { ".xml" });
        mySaveMessagesFileChooser.addChoosableFileFilter(type);

        type = new AllFileFilter();
        mySaveMessagesFileChooser.addChoosableFileFilter(type);

        mySaveMessagesFileChooser.setPreferredSize(new Dimension(700, 500));
    }

    int value = mySaveMessagesFileChooser.showSaveDialog(myView.getFrame());
    if (value == JFileChooser.APPROVE_OPTION) {

        File file = mySaveMessagesFileChooser.getSelectedFile();
        Prefs.getInstance().setSavePathMessages(file.getPath());

        if (!file.getName().contains(".")) {
            switch (theSelectedValue.getEncoding()) {
            case ER_7:
                file = new File(file.getAbsolutePath() + ".hl7");
                break;
            case XML:
                file = new File(file.getAbsolutePath() + ".xml");
                break;
            }
        }

        if (file.exists()) {
            String message = "The file \"" + file.getName() + "\" already exists. Do you wish to overwrite it?";
            int confirmed = showDialogYesNo(message);
            if (confirmed == JOptionPane.NO_OPTION) {
                return false;
            }

            ourLog.info("Deleting file: {}", file.getAbsolutePath());
            file.delete();
        }

        theSelectedValue.setSaveCharset(mySaveMessagesFileChooserAccessory.getSelectedCharset());
        theSelectedValue.setSaveFileName(file.getAbsolutePath());

        theSelectedValue.setSaveStripComments(mySaveMessagesFileChooserAccessory.isSelectedSaveStripComments());
        theSelectedValue.setSaveLineEndings(mySaveMessagesFileChooserAccessory.getSelectedLineEndings());

        doSave(theSelectedValue);

        return true;

    } else {

        return false;

    }
}

From source file:jeplus.JEPlusFrameMain.java

/**
 * Start batch operation with a random sample of jobs
 * @param njobs The number of jobs to run
 * @param opt//from   ww w .j a  v  a 2  s.  c  o  m
 * @param randomsrc Random generator source. Null means no randomisation is required
 */
public void startBatchRunSample(int njobs, EPlusBatch.SampleType opt, Random randomsrc) {
    // Update display
    if (OutputPanel == null) {
        OutputPanel = new EPlusTextPanelOld("Output", EPlusTextPanel.VIEWER_MODE);
        int tabn = TpnEditors.getTabCount();
        this.TpnEditors.insertTab("Executing batch ...", null, OutputPanel, "This is the execution log.", tabn);
        TpnEditors.setSelectedIndex(tabn);
    } else {
        TpnEditors.setSelectedComponent(OutputPanel);
    }
    if (opt == EPlusBatch.SampleType.SHUFFLE) {
        // Check batch size 
        if (BatchManager.getBatchInfo().getTotalNumberOfJobs() > 1000000) {
            // Project is too large
            StringBuilder buf = new StringBuilder("<html><p>The estimated solution space size (");
            buf.append(LargeIntFormatter.format(BatchManager.getBatchInfo().getTotalNumberOfJobs()));
            buf.append(") is too big. </p><p>Creating a random sample may take a (very) long time. </p>");
            buf.append(
                    "<p>The Latin Hypercube Sampling method is more suitable.</p><p>Are you sure you want to continue? </p>");
            int res = JOptionPane.showConfirmDialog(this, buf.toString(), "Solution space is too large",
                    JOptionPane.YES_NO_OPTION);
            if (res == JOptionPane.NO_OPTION) {
                OutputPanel.appendContent("Sample cancelled.\n");
                return;
            }
        }
        OutputPanel.appendContent("Start sampling. Please waite ... \n");
    }
    ActingManager = BatchManager;
    ActingManager.runSample(opt, njobs, randomsrc);
    OutputPanel.appendContent("A " + opt + " sample of " + njobs + " jobs has started ...\n");
}

From source file:edu.ku.brc.specify.tools.ireportspecify.MainFrameSpecify.java

/**
 * @param repResName/*from  ww w .  j  av a  2s .  c o m*/
 * @param tableId
 * @param spReport
 * @param appRes
 * 
 * Allows editing of SpReport and SpAppResource properties for reports.
 */
protected static AppResAndProps getProps(final String repResName, final Integer tableId,
        final ReportSpecify spReport, final AppResourceIFace appRes) {
    String repType;
    if (appRes == null) {
        repType = "Report";
    } else {
        String mime = appRes.getMimeType();
        String reportType = appRes.getMetaDataMap().getProperty("reporttype", null);
        if (mime.equals(ReportsBaseTask.LABELS_MIME)) {
            repType = "Label";
        } else if (mime.equals(ReportsBaseTask.SUBREPORTS_MIME)) {
            repType = "Subreport";
        } else {
            if (reportType != null && reportType.equalsIgnoreCase("invoice")) {
                repType = "Invoice";
            } else {
                repType = "Report";
            }
        }
    }

    RepResourcePropsPanel propPanel = new RepResourcePropsPanel(repResName, repType, tableId == null, spReport);
    boolean goodProps = false;
    boolean overwrite = false;
    SpAppResource match = null;
    CustomDialog cd = new CustomDialog((Frame) UIRegistry.getTopWindow(),
            UIRegistry.getResourceString("REP_PROPS_DLG_TITLE"), true, propPanel);
    propPanel.setCanceller(cd.getCancelBtn());
    while (!goodProps) {
        UIHelper.centerAndShow(cd);
        if (cd.isCancelled()) {
            return null;
        }

        String repName = propPanel.getNameTxt().getText().trim();
        boolean isNameOK = repName.matches("[a-zA-Z0-9\\-. '`_]*");
        if (StringUtils.isEmpty(repName)) {
            JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                    String.format(UIRegistry.getResourceString("REP_NAME_MUST_NOT_BE_BLANK"),
                            propPanel.getNameTxt().getText()));
        } else if (!isNameOK) {
            Toolkit.getDefaultToolkit().beep();
            JOptionPane.showMessageDialog(UIRegistry.getTopWindow(),
                    UIRegistry.getResourceString("INVALID_CHARS_NAME"));
        } else {
            match = getRepResource(propPanel.getNameTxt().getText());
            if (match != null) {
                if (appRes == null || !((SpAppResource) appRes).getId().equals(match.getId())) {
                    int chc = JOptionPane.showConfirmDialog(UIRegistry.getTopWindow(),
                            String.format(
                                    UIRegistry.getResourceString("REP_NAME_ALREADY_EXISTS_OVERWRITE_CONFIRM"),
                                    propPanel.getNameTxt().getText()));
                    if (chc == JOptionPane.OK_OPTION) {
                        goodProps = true;
                        overwrite = true;
                    } else if (chc != JOptionPane.NO_OPTION) {
                        return null;
                    }
                } else {
                    goodProps = true;
                }
            } else {
                goodProps = true;
            }

            goodProps = goodProps && propPanel.validInputs();
        }
    }
    if (goodProps /*just in case*/) {
        if (match != null && overwrite) {
            //user has chosen to overwrite an identically named report
            //XXX - Is it possible that another user created the matching report?

            //first close design frame for match if one exists.
            /*
             * Actually, never mind, too hard to do in this method.
             * Let the user deal with it.
             */

            //delete match
            Integer matchRepId = null;
            DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
            try {
                SpReport matchRep = session.getData(SpReport.class, "appResource", match,
                        DataProviderSessionIFace.CompareType.Equals);
                if (matchRep == null) {
                    JOptionPane.showMessageDialog(null,
                            String.format(UIRegistry.getResourceString("REP_UNABLE_TO_OVERWRITE"),
                                    match.getName()),
                            UIRegistry.getResourceString("Error"), JOptionPane.ERROR_MESSAGE);
                    return null;
                }
                matchRepId = matchRep.getId();
            } finally {
                session.close();
                session = null;
            }
            ReportsBaseTask.deleteReportAndResource(matchRepId, match.getId());
            overwrittenReportId = matchRepId;
        }

        AppResourceIFace modifiedRes = null;
        if (appRes == null) {
            String dirName = ((RepResourcePropsPanel.ResDirItem) propPanel.getResDirCombo().getSelectedItem())
                    .getName();
            SpAppResourceDir dir = getDirForResource(dirName);
            modifiedRes = ((SpecifyAppContextMgr) AppContextMgr.getInstance()).createAppResourceForDir(dir);
        } else {
            modifiedRes = appRes;
            String dirName = ((RepResourcePropsPanel.ResDirItem) propPanel.getResDirCombo().getSelectedItem())
                    .getName();
            SpAppResourceDir dir = getDirForResource(dirName);
            ((SpAppResource) modifiedRes).setSpAppResourceDir(dir);
        }
        modifiedRes.setName(propPanel.getNameTxt().getText().trim());
        modifiedRes.setDescription(propPanel.getNameTxt().getText().trim());
        modifiedRes.setLevel(Short.valueOf(propPanel.getLevelTxt().getText()));

        propPanel.getResDirCombo().getSelectedItem();
        String metaDataStr = "tableid=" + propPanel.getTableId() + ";";
        if (propPanel.getTypeCombo().getSelectedIndex() == 2) {
            metaDataStr += "reporttype=Invoice;";
        } else {
            metaDataStr += "reporttype=Report;";
        }
        if (propPanel.getSubReportsTxt() != null && propPanel.getSubReportsTxt().getText() != null) {
            metaDataStr += "subreports=" + propPanel.getSubReportsTxt().getText() + ";";
        }

        if (propPanel.getTypeCombo().getSelectedIndex() == 3) {
            modifiedRes.setMimeType("jrxml/subreport");
        } else if (propPanel.getTypeCombo().getSelectedIndex() == 1) {
            modifiedRes.setMimeType("jrxml/label");
        } else {
            modifiedRes.setMimeType("jrxml/report");
        }

        if (StringUtils.isNotEmpty(modifiedRes.getMetaData())) {
            /* Assuming ReportResources only get edited by this class...
            metaDataStr = metaDataStr + ";" + modifiedRes.getMetaData();*/
            log.info("overwriting existing AppResource metadata (" + modifiedRes.getMetaData() + ") with ("
                    + metaDataStr + ")");
        }
        modifiedRes.setMetaData(metaDataStr);
        AppResAndProps result = new AppResAndProps(modifiedRes, propPanel.getRepeats());
        return result;
    }
    return null;
}

From source file:com.sshtools.powervnc.PowerVNCPanel.java

private void startRecording() {

    if (recordingFileChooser == null) {

        recordingFileChooser =/*from  w ww.  j  a va2s. co m*/

                new JFileChooser(System.getProperty("user.home"));

    }

    int ret = recordingFileChooser.showSaveDialog(this);

    int i = 1;

    File file = null;

    while (file == null) {

        File f =

                new File(

                        recordingFileChooser.getCurrentDirectory(),

                        "vncsession.fbs." + i);

        if (!f.exists()) {

            file = f;

        }

        i++;

    }

    recordingFileChooser.setSelectedFile(file);

    if (ret == recordingFileChooser.APPROVE_OPTION) {

        file = recordingFileChooser.getSelectedFile();

        if (file.exists()

                && JOptionPane.showConfirmDialog(

                        this,

                        "File " + file.getName() + " already exists. Are you sure?",

                        "File exists",

                        JOptionPane.YES_NO_OPTION,

                        JOptionPane.WARNING_MESSAGE)

                == JOptionPane.NO_OPTION) {

            return;

        }

        vnc.setRecordingStatus(file.getAbsolutePath());

        setAvailableActions();

    }

}

From source file:jeplus.gui.JPanel_TrnsysProjectFiles.java

private void cmdEditRVIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditRVIActionPerformed

    // Test if the template file is present
    String fn = (String) cboRviFile.getSelectedItem();
    if (fn.startsWith("Select ")) {
        fn = "my.rvx";
    }//from  w  w w  .  j a  v a 2s  .c  om
    String templfn = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText() + fn, Project.getBaseDir());
    File ftmpl = new File(templfn);
    if (!ftmpl.exists()) {
        int n = JOptionPane.showConfirmDialog(this,
                "<html><p><center>" + templfn + " does not exist."
                        + "Do you want to copy one from an existing file?</center></p>"
                        + "<p> Alternatively, select 'NO' to create this file. </p>",
                "RVI file not available", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            // Select a file to open
            if (this.chkReadVar.isSelected()) {
                MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVX));
            } else {
                MainGUI.getFileChooser().setFileFilter(EPlusConfig.getFileFilter(EPlusConfig.RVI));
            }
            MainGUI.getFileChooser().setMultiSelectionEnabled(false);
            MainGUI.getFileChooser().setSelectedFile(new File(""));
            String rvidir = RelativeDirUtil.checkAbsolutePath(txtRviDir.getText(), Project.getBaseDir());
            MainGUI.getFileChooser().setCurrentDirectory(new File(rvidir));
            if (MainGUI.getFileChooser().showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
                File file = MainGUI.getFileChooser().getSelectedFile();
                try {
                    FileUtils.copyFile(file, new File(templfn));
                    cboRviFile.setModel(new DefaultComboBoxModel(new String[] { fn }));
                    Project.setRVIDir(txtRviDir.getText());
                    Project.setRVIFile(fn);
                } catch (IOException ex) {
                    logger.error("Error copying RVX from source.", ex);
                }
            }
            MainGUI.getFileChooser().resetChoosableFileFilters();
            MainGUI.getFileChooser().setSelectedFile(new File(""));
        } else if (n == JOptionPane.NO_OPTION) {

        } else {
            return;
        }
    }
    int idx = MainGUI.getTpnEditors().indexOfTab(fn);
    if (idx >= 0) {
        MainGUI.getTpnEditors().setSelectedIndex(idx);
    } else {
        EPlusEditorPanel RviFilePanel;
        if (FilenameUtils.getExtension(fn).equals("rvx")) {
            RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                    EPlusEditorPanel.FileType.RVX, null);
        } else {
            RviFilePanel = new EPlusEditorPanel(MainGUI.getTpnEditors(), fn, templfn,
                    EPlusEditorPanel.FileType.RVI, null);
        }
        int ti = MainGUI.getTpnEditors().getTabCount();
        MainGUI.getTpnEditors().addTab(fn, RviFilePanel);
        RviFilePanel.setTabId(ti);
        MainGUI.getTpnEditors().setSelectedIndex(ti);
        MainGUI.getTpnEditors().setTabComponentAt(ti,
                new ButtonTabComponent(MainGUI.getTpnEditors(), RviFilePanel));
        MainGUI.getTpnEditors().setToolTipTextAt(ti, templfn);
    }

}

From source file:com.iucosoft.eavertizare.gui.MainJFrame.java

private void jButtonDeleteFirmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDeleteFirmaActionPerformed
    int index = jListFirma.getSelectedIndex();
    if (index != -1) {
        Object numeFirma = jListFirma.getModel().getElementAt(index);
        firma = firmaDao.findByName((String) numeFirma);

        int rez = JOptionPane.showConfirmDialog(this, "Esti sigur vrei sa sterg firma ?", "Question",
                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        switch (rez) {
        case JOptionPane.YES_OPTION:

            int idConfiguratie = firma.getConfiguratii().getId();
            firmaDao.dropTableClients(firma.getTabelaClientiLocal());
            System.out.println("conf id = " + idConfiguratie);
            firmaDao.delete(firma.getId());
            configuratiiDao.delete(idConfiguratie);
            JOptionPane.showMessageDialog(this, "Firma stersa cu success", "Succes",
                    JOptionPane.INFORMATION_MESSAGE);
            break;
        case JOptionPane.NO_OPTION:
        case JOptionPane.CLOSED_OPTION:
            break;
        }//from  w  w w . j a va 2  s . c om
        refreshFrame();
    } else {
        JOptionPane.showMessageDialog(this, "Selectati firma!", "Info", JOptionPane.INFORMATION_MESSAGE);
    }
}