Example usage for javax.swing JOptionPane PLAIN_MESSAGE

List of usage examples for javax.swing JOptionPane PLAIN_MESSAGE

Introduction

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

Prototype

int PLAIN_MESSAGE

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

Click Source Link

Document

No icon is used.

Usage

From source file:org.nuclos.client.ui.collect.Chart.java

private void actionCommandShow() {
    final JOptionPane optpn = new JOptionPane(subform, JOptionPane.PLAIN_MESSAGE, JOptionPane.CLOSED_OPTION);

    // perform the dialog:
    final JDialog dlg = optpn.createDialog(panel, "Chart-Daten anzeigen");
    dlg.setModal(true);/*  w  w  w. ja  v a  2 s. co  m*/
    dlg.setResizable(true);
    dlg.pack();
    dlg.setLocationRelativeTo(panel);
    dlg.setVisible(true);
}

From source file:org.accretegb.modules.germplasm.stockannotation.StockAnnotationPanel.java

private JPanel addStockPanelToolButtons() {
    JPanel panel = new JPanel();
    panel.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    List<Integer> editableColumns = new ArrayList<Integer>();
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE));
    editableColumns.add(stockTablePanel.getTable().getIndexOf(ColumnConstants.GENERATION));
    stockTablePanel.getTable().setEditableColumns(editableColumns);
    ;// w  w  w  .ja v a2s  . c o  m
    JButton importStockList = new JButton("Import Stocks By Search");
    JButton importHarvestGroup = new JButton("Import Stocks From Harvest Group");
    JPanel subPanel1 = new JPanel();
    subPanel1.setLayout(new MigLayout("insets 0 0 0 0, gapx 0"));
    subPanel1.add(importStockList, "gapRight 10");
    subPanel1.add(importHarvestGroup, "gapRight 10, wrap");
    panel.add(subPanel1, "gapLeft 10, spanx,wrap");
    importStockList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            StocksInfoPanel stockInfoPanel = CreateStocksInfoPanel
                    .createStockInfoPanel("stock annotation popup");
            stockInfoPanel.setSize(new Dimension(500, 400));
            int option = JOptionPane.showConfirmDialog(null, stockInfoPanel, "Search Stock Packets",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            ArrayList<Integer> stockIds = new ArrayList<Integer>();

            if (option == JOptionPane.OK_OPTION) {
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                CheckBoxIndexColumnTable stocksOutputTable = stockInfoPanel.getSaveTablePanel().getTable();
                for (int row = 0; row < stocksOutputTable.getRowCount(); ++row) {
                    int stockId = (Integer) stocksOutputTable.getValueAt(row,
                            stocksOutputTable.getIndexOf(ColumnConstants.STOCK_ID));
                    stockIds.add(stockId);
                }
                List<Stock> stocks = StockDAO.getInstance().getStocksByIds(stockIds);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }

            }

        }

    });

    importHarvestGroup.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ArrayList<PMProject> projects = TokenRelationDAO.getInstance()
                    .findProjectObjects(LoginScreen.loginUserId);
            HashMap<String, Harvesting> name_tap = new HashMap<String, Harvesting>();
            for (PMProject project : projects) {
                List<HarvestingGroup> HarvestingGroups = HarvestingGroupDAO.getInstance()
                        .findByProjectid(project.getProjectId());
                for (HarvestingGroup hg : HarvestingGroups) {
                    Harvesting harvestingPanel = (Harvesting) getContext()
                            .getBean("Harvesting - " + project.getProjectId() + hg.getHarvestingGroupName());
                    name_tap.put(project.getProjectName() + "-" + hg.getHarvestingGroupName(), harvestingPanel);
                }

            }
            JPanel popup = new JPanel(new MigLayout("insets 0, gap 5"));
            JScrollPane jsp = new JScrollPane(popup) {
                @Override
                public Dimension getPreferredSize() {
                    return new Dimension(250, 320);
                }
            };
            ButtonGroup group = new ButtonGroup();
            for (String name : name_tap.keySet()) {
                JRadioButton button = new JRadioButton(name);
                group.add(button);
                popup.add(button, "wrap");

                button.setSelected(true);
            }
            String selected_group = null;
            int option = JOptionPane.showConfirmDialog(null, jsp, "Select Harvesting Group Name: ",
                    JOptionPane.OK_CANCEL_OPTION);
            if (option == JOptionPane.OK_OPTION) {
                for (Enumeration<AbstractButton> buttons = group.getElements(); buttons.hasMoreElements();) {
                    AbstractButton button = buttons.nextElement();
                    if (button.isSelected()) {
                        selected_group = button.getText();

                    }
                }
            }
            if (selected_group != null) {
                Harvesting harvestingPanel = name_tap.get(selected_group);
                DefaultTableModel model = (DefaultTableModel) stockTablePanel.getTable().getModel();
                ArrayList<String> stocknames = harvestingPanel.getStickerGenerator().getCreatedStocks();
                List<Stock> stocks = StockDAO.getInstance().getStocksByNames(stocknames);
                for (Stock stock : stocks) {
                    Object[] rowData = new Object[stockTablePanel.getTable().getColumnCount()];
                    rowData[0] = new Boolean(false);
                    Passport passport = stock.getPassport();
                    StockGeneration generation = stock.getStockGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_NAME)] = stock
                            .getStockName();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.STOCK_ID)] = stock
                            .getStockId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.GENERATION)] = generation == null ? null
                                    : generation.getGeneration();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.PASSPORT_ID)] = passport == null ? null : passport.getPassportId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.ACCESSION)] = passport == null
                            ? null
                            : passport.getAccession_name();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.PEDIGREE)] = passport == null
                            ? null
                            : passport.getPedigree();

                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_CODE)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationCode();
                    rowData[stockTablePanel.getTable().getIndexOf(
                            ColumnConstants.CLASSIFICATION_ID)] = passport.getClassification() == null ? null
                                    : passport.getClassification().getClassificationId();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.POPULATION)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getPopulation();
                    rowData[stockTablePanel.getTable()
                            .getIndexOf(ColumnConstants.TAXONOMY_ID)] = passport.getTaxonomy() == null ? null
                                    : passport.getTaxonomy().getTaxonomyId();
                    rowData[stockTablePanel.getTable().getIndexOf(ColumnConstants.MODIFIED)] = new Boolean(
                            false);
                    model.addRow(rowData);
                }
            }

        }

    });
    getstockTablePanel().getTable().addFocusListener(new FocusAdapter() {
        public void focusLost(FocusEvent e) {
            int row = getstockTablePanel().getTable().getSelectionModel().getAnchorSelectionIndex();
            getstockTablePanel().getTable().setValueAt(true, row,
                    getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
        }
    });
    JPanel subPanel2 = new JPanel();
    subPanel2.setLayout(new MigLayout("insets 0 0 0 0 , gapx 0"));
    subPanel2.add(new JLabel("Pedigree: "));
    this.pedigreeField = new JTextField(10);
    subPanel2.add(pedigreeField);
    JButton setPedigree = new JButton("set");
    setPedigree.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(pedigreeField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.PEDIGREE));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setPedigree, "gapRight 15");

    subPanel2.add(new JLabel("Accession: "));
    this.accessionField = new JTextField(10);
    subPanel2.add(accessionField);
    JButton setAccession = new JButton("set");
    setAccession.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(accessionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.ACCESSION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));

            }
        }
    });
    subPanel2.add(setAccession, "gapRight 15");

    subPanel2.add(new JLabel("Generarion: "));
    this.generarionField = new JTextField(10);
    subPanel2.add(generarionField);
    JButton setGeneration = new JButton("set");
    setGeneration.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            for (int row : getstockTablePanel().getTable().getSelectedRows()) {
                getstockTablePanel().getTable().setValueAt(generarionField.getText(), row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.GENERATION));
                getstockTablePanel().getTable().setValueAt(true, row,
                        getstockTablePanel().getTable().getIndexOf(ColumnConstants.MODIFIED));
            }
        }
    });
    subPanel2.add(setGeneration);

    panel.add(subPanel2, "gapLeft 10,spanx");
    return panel;

}

From source file:org.apache.jackrabbit.oak.explorer.Explorer.java

private void createAndShowGUI(final File path, boolean skipSizeCheck) throws IOException {
    JTextArea log = new JTextArea(5, 20);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setLineWrap(true);/*from   ww w.j  a va  2  s . co  m*/
    log.setEditable(false);

    final NodeStoreTree treePanel = new NodeStoreTree(backend, log, skipSizeCheck);

    final JFrame frame = new JFrame("Explore " + path + " @head");
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        @Override
        public void windowClosing(java.awt.event.WindowEvent windowEvent) {
            IOUtils.closeQuietly(treePanel);
            System.exit(0);
        }
    });

    JPanel content = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(treePanel),
            new JScrollPane(log));
    splitPane.setDividerLocation(0.3);
    content.add(new JScrollPane(splitPane), c);
    frame.getContentPane().add(content);

    JMenuBar menuBar = new JMenuBar();
    menuBar.setMargin(new Insets(2, 2, 2, 2));

    JMenuItem menuReopen = new JMenuItem("Reopen");
    menuReopen.setMnemonic(KeyEvent.VK_R);
    menuReopen.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            try {
                treePanel.reopen();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });

    JMenuItem menuCompaction = new JMenuItem("Time Machine");
    menuCompaction.setMnemonic(KeyEvent.VK_T);
    menuCompaction.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> revs = backend.readRevisions();
            String s = (String) JOptionPane.showInputDialog(frame, "Revert to a specified revision",
                    "Time Machine", JOptionPane.PLAIN_MESSAGE, null, revs.toArray(), revs.get(0));
            if (s != null && treePanel.revert(s)) {
                frame.setTitle("Explore " + path + " @" + s);
            }
        }
    });

    JMenuItem menuRefs = new JMenuItem("Tar File Info");
    menuRefs.setMnemonic(KeyEvent.VK_I);
    menuRefs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            List<String> tarFiles = new ArrayList<String>();
            for (File f : path.listFiles()) {
                if (f.getName().endsWith(".tar")) {
                    tarFiles.add(f.getName());
                }
            }

            String s = (String) JOptionPane.showInputDialog(frame, "Choose a tar file", "Tar File Info",
                    JOptionPane.PLAIN_MESSAGE, null, tarFiles.toArray(), tarFiles.get(0));
            if (s != null) {
                treePanel.printTarInfo(s);
            }
        }
    });

    JMenuItem menuSCR = new JMenuItem("Segment Refs");
    menuSCR.setMnemonic(KeyEvent.VK_R);
    menuSCR.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame, "Segment References\nUsage: <segmentId>",
                    "Segment References", JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printSegmentReferences(s);
            }
        }
    });

    JMenuItem menuDiff = new JMenuItem("SegmentNodeState diff");
    menuDiff.setMnemonic(KeyEvent.VK_D);
    menuDiff.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            String s = JOptionPane.showInputDialog(frame,
                    "SegmentNodeState diff\nUsage: <recordId> <recordId> [<path>]", "SegmentNodeState diff",
                    JOptionPane.PLAIN_MESSAGE);
            if (s != null) {
                treePanel.printDiff(s);
            }
        }
    });

    JMenuItem menuPCM = new JMenuItem("Persisted Compaction Maps");
    menuPCM.setMnemonic(KeyEvent.VK_P);
    menuPCM.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ev) {
            treePanel.printPCMInfo();
        }
    });

    menuBar.add(menuReopen);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuCompaction);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuRefs);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuSCR);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuDiff);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));
    menuBar.add(menuPCM);
    menuBar.add(new JSeparator(JSeparator.VERTICAL));

    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setSize(960, 720);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

}

From source file:org.apache.pdfbox.debugger.PDFDebugger.java

/**
 * This will parse a document./*from www . j a  v a  2  s.  c o  m*/
 *
 * @param file The file addressing the document.
 * @throws IOException If there is an error parsing the document.
 */
private void parseDocument(File file, String password) throws IOException {
    while (true) {
        try {
            document = PDDocument.load(file, password);
        } catch (InvalidPasswordException ipe) {
            // https://stackoverflow.com/questions/8881213/joptionpane-to-get-password
            JPanel panel = new JPanel();
            JLabel label = new JLabel("Password:");
            JPasswordField pass = new JPasswordField(10);
            panel.add(label);
            panel.add(pass);
            String[] options = new String[] { "OK", "Cancel" };
            int option = JOptionPane.showOptionDialog(null, panel, "Enter password", JOptionPane.NO_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null, options, "");
            if (option == 0) {
                password = new String(pass.getPassword());
                continue;
            }
            throw ipe;
        }
        break;
    }
    printMenuItem.setEnabled(true);
    reopenMenuItem.setEnabled(true);
}

From source file:org.apache.tika.gui.TikaGUI.java

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if ("openfile".equals(command)) {
        int rv = chooser.showOpenDialog(this);
        if (rv == JFileChooser.APPROVE_OPTION) {
            openFile(chooser.getSelectedFile());
        }/*from w w  w  .j  av a  2s  .  c  om*/
    } else if ("openurl".equals(command)) {
        Object rv = JOptionPane.showInputDialog(this, "Enter the URL of the resource to be parsed:", "Open URL",
                JOptionPane.PLAIN_MESSAGE, null, null, "");
        if (rv != null && rv.toString().length() > 0) {
            try {
                openURL(new URL(rv.toString().trim()));
            } catch (MalformedURLException exception) {
                JOptionPane.showMessageDialog(this, "The given string is not a valid URL", "Invalid URL",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else if ("html".equals(command)) {
        layout.show(cards, command);
    } else if ("text".equals(command)) {
        layout.show(cards, command);
    } else if ("main".equals(command)) {
        layout.show(cards, command);
    } else if ("xhtml".equals(command)) {
        layout.show(cards, command);
    } else if ("metadata".equals(command)) {
        layout.show(cards, command);
    } else if ("json".equals(command)) {
        layout.show(cards, command);
    } else if ("about".equals(command)) {
        textDialog("About Apache Tika", TikaGUI.class.getResource("about.html"));
    } else if ("exit".equals(command)) {
        Toolkit.getDefaultToolkit().getSystemEventQueue()
                .postEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:org.apache.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog// www  . j a  v  a2 s  . c  om
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);
    } catch (DAOException e) {

        displayError(e.getMessage());
    }

    /*
     * File[] documents = dir.listFiles(); Vector docVector = new Vector(); for (int i = 0; i <
     * documents.length; i++) { if (documents[i].isFile()) { docVector.add(documents[i].getName()); } }
     * final JList analyzedResultsList = new JList(docVector);
     */
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.getViewport().add(analyzedResultsList, null);

    JPanel southernPanel = new JPanel();
    southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

    JPanel controlsPanel = new JPanel();
    controlsPanel.setLayout(new SpringLayout());

    Caption displayFormatLabel = new Caption("Results Display Format:");
    controlsPanel.add(displayFormatLabel);

    JPanel displayFormatPanel = new JPanel();
    displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    javaViewerRB = new JRadioButton("Java Viewer");
    javaViewerUCRB = new JRadioButton("JV user colors");
    htmlRB = new JRadioButton("HTML");
    xmlRB = new JRadioButton("XML");

    ButtonGroup displayFormatButtonGroup = new ButtonGroup();
    displayFormatButtonGroup.add(javaViewerRB);
    displayFormatButtonGroup.add(javaViewerUCRB);
    displayFormatButtonGroup.add(htmlRB);
    displayFormatButtonGroup.add(xmlRB);

    // select the appropraite viewer button according to user's prefs
    javaViewerRB.setSelected(true); // default, overriden below
    if ("Java Viewer".equals(med.getViewType())) {
        javaViewerRB.setSelected(true);
    } else if ("JV User Colors".equals(med.getViewType())) {
        javaViewerUCRB.setSelected(true);
    } else if ("HTML".equals(med.getViewType())) {
        htmlRB.setSelected(true);
    } else if ("XML".equals(med.getViewType())) {
        xmlRB.setSelected(true);
    }

    displayFormatPanel.add(javaViewerRB);
    displayFormatPanel.add(javaViewerUCRB);
    displayFormatPanel.add(htmlRB);
    displayFormatPanel.add(xmlRB);

    controlsPanel.add(displayFormatPanel);

    SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
            4, 4, // initX, initY
            0, 0); // xPad, yPad

    JButton editStyleMapButton = new JButton("Edit Style Map");

    // event for the editStyleMapButton button
    editStyleMapButton.addActionListener(this);

    southernPanel.add(controlsPanel);

    // southernPanel.add( new JSeparator() );

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

    // APL: edit style map feature disabled for SDK
    buttonsPanel.add(editStyleMapButton);

    if (performanceStats != null) {
        JButton perfStatsButton = new JButton("Performance Stats");
        perfStatsButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                        JOptionPane.PLAIN_MESSAGE);
            }
        });
        buttonsPanel.add(perfStatsButton);
    }

    JButton closeButton = new JButton("Close");
    buttonsPanel.add(closeButton);

    southernPanel.add(buttonsPanel);

    // add jlist and panel container to Dialog
    getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    getContentPane().add(southernPanel, BorderLayout.SOUTH);

    // event for the closeButton button
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            DBAnnotationViewerDialog.this.setVisible(false);
        }
    });

    // event for analyzedResultsDialog window closing
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setLF(); // set default look and feel
    analyzedResultsList.setCellRenderer(new MyListCellRenderer());

    // doubleclicking on document shows the annotated result
    MouseListener mouseListener = new ListMouseAdapter();
    // styleMapFile, analyzedResultsList,
    // inputDirPath,typeSystem , typesToDisplay ,
    // javaViewerRB , javaViewerUCRB ,xmlRB ,
    // viewerDirectory , this);

    // add mouse Listener to the list
    analyzedResultsList.addMouseListener(mouseListener);
}

From source file:org.barcelonamedia.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog//from   w w w.  j  av a2 s  .c o  m
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.getViewport().add(analyzedResultsList, null);

        JPanel southernPanel = new JPanel();
        southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

        JPanel controlsPanel = new JPanel();
        controlsPanel.setLayout(new SpringLayout());

        Caption displayFormatLabel = new Caption("Results Display Format:");
        controlsPanel.add(displayFormatLabel);

        JPanel displayFormatPanel = new JPanel();
        displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        javaViewerRB = new JRadioButton("Java Viewer");
        javaViewerUCRB = new JRadioButton("JV user colors");
        htmlRB = new JRadioButton("HTML");
        xmlRB = new JRadioButton("XML");

        ButtonGroup displayFormatButtonGroup = new ButtonGroup();
        displayFormatButtonGroup.add(javaViewerRB);
        displayFormatButtonGroup.add(javaViewerUCRB);
        displayFormatButtonGroup.add(htmlRB);
        displayFormatButtonGroup.add(xmlRB);

        // select the appropraite viewer button according to user's prefs
        javaViewerRB.setSelected(true); // default, overriden below

        if ("Java Viewer".equals(med.getViewType())) {
            javaViewerRB.setSelected(true);
        } else if ("JV User Colors".equals(med.getViewType())) {
            javaViewerUCRB.setSelected(true);
        } else if ("HTML".equals(med.getViewType())) {
            htmlRB.setSelected(true);
        } else if ("XML".equals(med.getViewType())) {
            xmlRB.setSelected(true);
        }

        displayFormatPanel.add(javaViewerRB);
        displayFormatPanel.add(javaViewerUCRB);
        displayFormatPanel.add(htmlRB);
        displayFormatPanel.add(xmlRB);

        controlsPanel.add(displayFormatPanel);

        SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
                4, 4, // initX, initY
                0, 0); // xPad, yPad

        JButton editStyleMapButton = new JButton("Edit Style Map");

        // event for the editStyleMapButton button
        editStyleMapButton.addActionListener(this);

        southernPanel.add(controlsPanel);

        // southernPanel.add( new JSeparator() );

        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        // APL: edit style map feature disabled for SDK
        buttonsPanel.add(editStyleMapButton);

        if (performanceStats != null) {
            JButton perfStatsButton = new JButton("Performance Stats");
            perfStatsButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                            JOptionPane.PLAIN_MESSAGE);
                }
            });
            buttonsPanel.add(perfStatsButton);
        }

        JButton closeButton = new JButton("Close");
        buttonsPanel.add(closeButton);

        southernPanel.add(buttonsPanel);

        // add list and panel container to Dialog
        getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(southernPanel, BorderLayout.SOUTH);

        // event for the closeButton button
        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DBAnnotationViewerDialog.this.setVisible(false);
            }
        });

        // event for analyzedResultsDialog window closing
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLF(); // set default look and feel
        analyzedResultsList.setCellRenderer(new MyListCellRenderer());

        // doubleclicking on document shows the annotated result
        MouseListener mouseListener = new ListMouseAdapter();
        // styleMapFile, analyzedResultsList,
        // inputDirPath,typeSystem , typesToDisplay ,
        // javaViewerRB , javaViewerUCRB ,xmlRB ,
        // viewerDirectory , this);

        // add mouse Listener to the list
        analyzedResultsList.addMouseListener(mouseListener);
    } catch (DAOException e) {

        displayError(e.getMessage());

        this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:org.broad.igv.track.TrackMenuUtils.java

public static JMenuItem getRemoveMenuItem(final Collection<Track> selectedTracks) {

    boolean multiple = selectedTracks.size() > 1;

    JMenuItem item = new JMenuItem("Remove Track" + (multiple ? "s" : ""));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent evt) {
            if (selectedTracks.isEmpty()) {
                return;
            }/*from w w w .  j a  va  2 s  .co  m*/

            StringBuffer buffer = new StringBuffer();
            for (Track track : selectedTracks) {
                buffer.append("\n\t");
                buffer.append(track.getName());
            }
            String deleteItems = buffer.toString();

            JTextArea textArea = new JTextArea();
            textArea.setEditable(false);
            JScrollPane scrollPane = new JScrollPane(textArea);
            textArea.setText(deleteItems);

            JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.YES_NO_OPTION);
            optionPane.setPreferredSize(new Dimension(550, 500));
            JDialog dialog = optionPane.createDialog(IGV.getMainFrame(), "Remove The Following Tracks");
            dialog.setVisible(true);

            Object choice = optionPane.getValue();
            if ((choice == null) || (JOptionPane.YES_OPTION != ((Integer) choice).intValue())) {
                return;
            }

            IGV.getInstance().removeTracks(selectedTracks);
            IGV.getInstance().doRefresh();
        }
    });
    return item;
}

From source file:org.broad.igv.ui.action.SetTrackHeightMenuAction.java

/**
 * Method description/*from  w w w .ja  v a  2  s  . com*/
 */
final public void doSetTrackHeight() {

    boolean doRefresh = false;
    try {
        JPanel container = new JPanel();
        JLabel trackHeightLabel = new JLabel("Track Height (pixels)");
        JTextField trackHeightField = new JTextField();
        Dimension preferredSize = trackHeightField.getPreferredSize();
        trackHeightField.setPreferredSize(new Dimension(50, (int) preferredSize.getHeight()));
        container.add(trackHeightLabel);
        container.add(trackHeightField);

        int repTrackHeight = getRepresentativeTrackHeight();
        trackHeightField.setText(String.valueOf(repTrackHeight));

        int status = JOptionPane.showConfirmDialog(mainFrame.getMainFrame(), container, "Set Track Height",
                JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);

        if ((status == JOptionPane.CANCEL_OPTION) || (status == JOptionPane.CLOSED_OPTION)) {
            return;
        }

        try {
            int newTrackHeight = Integer.parseInt(trackHeightField.getText().trim());
            IGV.getInstance().setAllTrackHeights(newTrackHeight);
            lastTrackHeight = newTrackHeight;
            doRefresh = true;
        } catch (NumberFormatException numberFormatException) {
            JOptionPane.showMessageDialog(mainFrame.getMainFrame(), "Track height must be an integer number.");
        }

    } finally {

        // Refresh view
        if (doRefresh) {

            // Update the state of the current tracks for drawing purposes

            mainFrame.doRefresh();
        }
        mainFrame.resetStatusMessage();
    }

}

From source file:org.colombbus.tangara.ConfigurationWindow.java

/**
 * This method launches a password window allowing to display the ConfigurationWindow.
 *///from  www . ja  va 2  s .  com
private void displayPasswordWindow() {
    String passwordWindow = Messages.getString("ConfigurationWindow.password.window");
    String enterPassword = Messages.getString("ConfigurationWindow.password.passwordMessage");
    String typedPassword = (String) JOptionPane.showInputDialog(parent, enterPassword, passwordWindow,
            JOptionPane.PLAIN_MESSAGE, null, null, null);
    if (typedPassword == null) {
        cancelWindow = true;
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    exit();
                }
            });
        } catch (InterruptedException e) {
            LOG.warn("displayPasswordWindow", e);
        } catch (InvocationTargetException e) {
            LOG.warn("displayPasswordWindow", e);
        }
    } else if (!typedPassword.equals(password)) {
        String wrongPasswordTitle = Messages.getString("ConfigurationWindow.password.wrongPasswordTitle");
        String wrongPasswordMessage = Messages.getString("ConfigurationWindow.password.wrongPasswordMessage");
        JOptionPane.showMessageDialog(null, wrongPasswordMessage, wrongPasswordTitle,
                JOptionPane.WARNING_MESSAGE);
        displayPasswordWindow();
    }
}