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:edu.virginia.iath.oxygenplugins.juel.JUELPluginMenu.java

public JUELPluginMenu(StandalonePluginWorkspace spw, LocalOptions ops) {
    super(name, true);
    ws = spw;/*w w  w .  ja  v a 2  s  . c  om*/
    options = ops;

    // setup the options
    //options.readStorage();

    // Find names
    JMenuItem search = new JMenuItem("Find Name");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Name";

            final JTextField lastName = new JTextField("", 30);
            lastName.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL("http://juel.iath.virginia.edu/academical_db/people/find_people?term="
                                + lastName.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String name = cur.getString("label");
                            String id = String.format("P%05d", cur.getInt("value"));
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for last name, then choose a full name from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Last Name: "));
            addPanelInner.add(lastName);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find places
    search = new JMenuItem("Find Place");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Place";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/places/find_places?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("PL%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a place name, then choose one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find corporate bodies
    search = new JMenuItem("Find Corporate Body");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Corporate Body";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/corporate_bodies/find?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("CB%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a corporate body, then one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);

    // Find Courses
    search = new JMenuItem("Find Course");
    search.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent selection) {
            String label = "Find Course";

            final JTextField searchText = new JTextField("", 30);
            searchText.setPreferredSize(new Dimension(350, 25));
            //JTextField projectName = new JTextField("", 30);

            final JComboBox possibleVals = new JComboBox();
            possibleVals.setEnabled(false);
            possibleVals.setPreferredSize(new Dimension(350, 25));

            JButton search = new JButton("Search");
            search.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent selection) {
                    // query the database
                    try {
                        String json = "";
                        String line;
                        URL url = new URL(
                                "http://academical.village.virginia.edu/academical_db/courses/find?term="
                                        + searchText.getText());
                        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                        while ((line = in.readLine()) != null) {
                            json += line;
                        }
                        JSONArray obj = new JSONArray(json);

                        // Read the JSON and update possibleVals
                        possibleVals.removeAllItems();
                        possibleVals.setEnabled(false);

                        for (int i = 0; i < obj.length(); i++) {
                            JSONObject cur = obj.getJSONObject(i);
                            String id = String.format("C%04d", cur.getInt("value"));
                            String name = cur.getString("label") + " (" + id + ")";
                            possibleVals.addItem(new ComboBoxObject(name, id));
                            possibleVals.setEnabled(true);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        possibleVals.setEnabled(false);
                    }

                    return;
                }
            });
            search.setPreferredSize(new Dimension(100, 25));

            JButton insert = new JButton("Insert");
            insert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent sel) {
                    // Insert into the page
                    // Get the selected value, grab the ID, then insert into the document

                    // Get the editor
                    WSTextEditorPage ed = null;
                    WSEditor editorAccess = ws
                            .getCurrentEditorAccess(StandalonePluginWorkspace.MAIN_EDITING_AREA);
                    if (editorAccess != null && editorAccess.getCurrentPage() instanceof WSTextEditorPage) {
                        ed = (WSTextEditorPage) editorAccess.getCurrentPage();
                    }

                    String result = "key=\"" + ((ComboBoxObject) possibleVals.getSelectedItem()).id + "\"";

                    // Update the text in the document
                    ed.beginCompoundUndoableEdit();
                    int selectionOffset = ed.getSelectionStart();
                    ed.deleteSelection();
                    javax.swing.text.Document doc = ed.getDocument();
                    try {
                        if (selectionOffset > 0 && !doc.getText(selectionOffset - 1, 1).equals(" "))
                            result = " " + result;
                        if (selectionOffset > 0 && !doc.getText(selectionOffset, 1).equals(" ")
                                && !doc.getText(selectionOffset, 1).equals(">"))
                            result = result + " ";
                        doc.insertString(selectionOffset, result, javax.swing.text.SimpleAttributeSet.EMPTY);
                    } catch (javax.swing.text.BadLocationException b) {
                        // Okay if it doesn't work
                    }
                    ed.endCompoundUndoableEdit();

                    return;
                }
            });
            insert.setPreferredSize(new Dimension(100, 25));

            java.awt.GridLayout layoutOuter = new java.awt.GridLayout(3, 1);
            java.awt.FlowLayout layout = new java.awt.FlowLayout(FlowLayout.RIGHT); // rows, columns

            JPanel addPanel = new JPanel();
            JPanel addPanelInner = new JPanel();
            addPanel.setLayout(layoutOuter);
            addPanel.add(new JLabel("Search for a course, then choose one from the list below"));
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Search Keyword: "));
            addPanelInner.add(searchText);
            addPanelInner.add(search);
            addPanel.add(addPanelInner);
            addPanelInner = new JPanel();
            addPanelInner.setLayout(layout);
            addPanelInner.add(new JLabel("Narrow Search: "));
            addPanelInner.add(possibleVals);
            addPanelInner.add(insert);
            addPanel.add(addPanelInner);

            JOptionPane.showMessageDialog((java.awt.Frame) ws.getParentFrame(), addPanel, label,
                    JOptionPane.PLAIN_MESSAGE);

        }
    });
    this.add(search);
}

From source file:eu.europeana.sip.gui.SipCreatorGUI.java

private File getFileStoreDirectory() throws FileStoreException {
    File fileStore = new File(System.getProperty("user.home"), "/sip-creator-file-store");
    if (fileStore.isFile()) {
        try {//  w w w. j  a va  2  s .co m
            List<String> lines = FileUtils.readLines(fileStore);
            String directory;
            if (lines.size() == 1) {
                directory = lines.get(0);
            } else {
                directory = (String) JOptionPane.showInputDialog(null, "Please choose file store",
                        "Launch SIP-Creator", JOptionPane.PLAIN_MESSAGE, null, lines.toArray(), "");
            }
            if (directory == null) {
                System.exit(0);
            }
            fileStore = new File(directory);
            if (fileStore.exists() && !fileStore.isDirectory()) {
                throw new FileStoreException(
                        String.format("%s is not a directory", fileStore.getAbsolutePath()));
            }
        } catch (IOException e) {
            throw new FileStoreException("Unable to read the file " + fileStore.getAbsolutePath());
        }
    }
    return fileStore;
}

From source file:it.imtech.configuration.ChooseServer.java

/**
 * Setta il percorso del file di configurazione se  la prima volta che
 * viene avviata l'applicazione/*from w w  w . j a va  2 s. c o m*/
 *
 * @param change Definisce se  l'avvio dell'applicazione o se si vuole
 * modificare il percorso
 * @throws MalformedURLException
 * @throws ConfigurationException
 */
private XMLConfiguration setConfigurationPaths(boolean change, XMLConfiguration internalConf,
        ResourceBundle bundle) {
    URL urlConfig = null;
    XMLConfiguration configuration = null;

    try {
        String text = Utility.getBundleString("setconf", bundle);
        String title = Utility.getBundleString("setconf2", bundle);

        internalConf.setAutoSave(true);

        String n = internalConf.getString("configurl[@path]");

        if (n.isEmpty()) {
            String s = (String) JOptionPane.showInputDialog(new Frame(), text, title, JOptionPane.PLAIN_MESSAGE,
                    null, null, "http://phaidrastatic.cab.unipd.it/xml/config.xml");

            //If a string was returned, say so.
            if ((s != null) && (s.length() > 0)) {
                internalConf.setProperty("configurl[@path]", s);
                urlConfig = new URL(s);
            } else {
                logger.info("File di configurazione non settato");
            }
        } else {
            urlConfig = new URL(n);
        }

        if (urlConfig != null) {
            if (Globals.DEBUG)
                configuration = new XMLConfiguration(new File(Globals.JRPATH + Globals.DEBUG_XML));
            else
                configuration = new XMLConfiguration(urlConfig);
        }
    } catch (final MalformedURLException ex) {
        logger.error(ex.getMessage());
        JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("exc_conf_1", bundle));
    } catch (final ConfigurationException ex) {
        logger.error(ex.getMessage());
        JOptionPane.showMessageDialog(new Frame(), Utility.getBundleString("exc_conf_2", bundle));
    }

    return configuration;
}

From source file:com.frostwire.gui.library.LibraryUtils.java

public static void createNewPlaylist(final PlaylistItem[] playlistItems, boolean starred) {
    if (starred) {
        Thread t = new Thread(new Runnable() {
            public void run() {
                Playlist playlist = LibraryMediator.getLibrary().getStarredPlaylist();
                addToPlaylist(playlist, playlistItems, true, -1);
                GUIMediator.safeInvokeLater(new Runnable() {
                    public void run() {
                        DirectoryHolder dh = LibraryMediator.instance().getLibraryExplorer()
                                .getSelectedDirectoryHolder();
                        if (dh instanceof StarredDirectoryHolder) {
                            LibraryMediator.instance().getLibraryExplorer().refreshSelection();
                        } else {
                            LibraryMediator.instance().getLibraryExplorer().selectStarred();
                        }//from  w  ww .  j  av  a 2  s  .  c o m
                    }
                });
            }
        }, "createNewPlaylist");
        t.setDaemon(true);
        t.start();
    } else {
        String playlistName = (String) JOptionPane.showInputDialog(GUIMediator.getAppFrame(),
                I18n.tr("Playlist name"), I18n.tr("Playlist name"), JOptionPane.PLAIN_MESSAGE, null, null,
                calculateName(playlistItems));

        if (playlistName != null && playlistName.length() > 0) {
            final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);

            Thread t = new Thread(new Runnable() {
                public void run() {
                    try {
                        playlist.save();
                        addToPlaylist(playlist, playlistItems);
                        playlist.save();
                        GUIMediator.safeInvokeLater(new Runnable() {
                            public void run() {
                                LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
                            }
                        });
                    } finally {
                        asyncAddToPlaylistFinalizer(playlist);
                    }
                }
            }, "createNewPlaylist");
            t.setDaemon(true);
            t.start();
        }
    }
}

From source file:gate.corpora.CSVImporter.java

@Override
protected List<Action> buildActions(final NameBearerHandle handle) {
    List<Action> actions = new ArrayList<Action>();

    if (!(handle.getTarget() instanceof Corpus))
        return actions;

    actions.add(new AbstractAction("Populate from CSV File") {
        @Override//  w w w. jav  a 2  s.c o m
        public void actionPerformed(ActionEvent e) {

            // display the populater dialog and return if it is cancelled
            if (JOptionPane.showConfirmDialog(null, dialog, "Populate From CSV File",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION)
                return;

            // we want to run the population in a separate thread so we don't lock
            // up the GUI
            Thread thread = new Thread(Thread.currentThread().getThreadGroup(), "CSV Corpus Populater") {

                public void run() {
                    try {

                        // unescape the strings that define the format of the file and
                        // get the actual chars
                        char separator = StringEscapeUtils.unescapeJava(txtSeparator.getText()).charAt(0);
                        char quote = StringEscapeUtils.unescapeJava(txtQuoteChar.getText()).charAt(0);

                        // see if we can convert the URL to a File instance
                        File file = null;
                        try {
                            file = Files.fileFromURL(new URL(txtURL.getText()));
                        } catch (IllegalArgumentException iae) {
                            // this will happen if someone enters an actual URL, but we
                            // handle that later so we can just ignore the exception for
                            // now and keep going
                        }

                        if (file != null && file.isDirectory()) {
                            // if we have a File instance and that points at a directory
                            // then....

                            // get all the CSV files in the directory structure
                            File[] files = Files.listFilesRecursively(file, CSV_FILE_FILTER);

                            for (File f : files) {
                                // for each file...

                                // skip directories as we don't want to handle those
                                if (f.isDirectory())
                                    continue;

                                if (cboDocuments.isSelected()) {
                                    // if we are creating lots of documents from a single
                                    // file
                                    // then call the populate method passing through all the
                                    // options from the GUI
                                    populate((Corpus) handle.getTarget(), f.toURI().toURL(),
                                            txtEncoding.getText(), (Integer) textColModel.getValue(),
                                            cboFeatures.isSelected(), separator, quote);
                                } else {
                                    // if we are creating a single document from a single
                                    // file
                                    // then call the createDoc method passing through all
                                    // the
                                    // options from the GUI
                                    createDoc((Corpus) handle.getTarget(), f.toURI().toURL(),
                                            txtEncoding.getText(), (Integer) textColModel.getValue(),
                                            cboFeatures.isSelected(), separator, quote);
                                }
                            }
                        } else {
                            // we have a single URL to process so...

                            if (cboDocuments.isSelected()) {
                                // if we are creating lots of documents from a single file
                                // then call the populate method passing through all the
                                // options from the GUI
                                populate((Corpus) handle.getTarget(), new URL(txtURL.getText()),
                                        txtEncoding.getText(), (Integer) textColModel.getValue(),
                                        cboFeatures.isSelected(), separator, quote);
                            } else {
                                // if we are creating a single document from a single file
                                // then call the createDoc method passing through all the
                                // options from the GUI
                                createDoc((Corpus) handle.getTarget(), new URL(txtURL.getText()),
                                        txtEncoding.getText(), (Integer) textColModel.getValue(),
                                        cboFeatures.isSelected(), separator, quote);
                            }
                        }
                    } catch (Exception e) {
                        // TODO give a sensible error message
                        e.printStackTrace();
                    }
                }
            };

            // let's leave the GUI nice and responsive
            thread.setPriority(Thread.MIN_PRIORITY);

            // lets get to it and do some actual work!
            thread.start();

        }
    });

    return actions;
}

From source file:com.swg.parse.docx.OpenWord.java

/***
 * Allows the user to enter the version of the document in question
 *//*from  www  .j  av a  2s  . c  o m*/
private void VersionSlector() {

    Object[] possibilities = { 0, 1, 2 };

    version = (int) JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(),
            "please select the version of the form", "Form Version", JOptionPane.PLAIN_MESSAGE, icon,
            possibilities, 0);

}

From source file:com.google.code.facebook.graph.sna.applet.MultiViewDemo.java

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features.//  w ww .  ja va  2 s  . c o m
 * 
 */
public MultiViewDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    // create one layout for the graph
    FRLayout<String, Number> layout = new FRLayout<String, Number>(graph);
    layout.setMaxIterations(1000);

    // create one model that all 3 views will share
    VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            layout, preferredSize);

    // create 3 views that share the same model
    vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>());
    vv2.getRenderContext()
            .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12)));

    vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>());

    vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>());

    //        transformer = vv1.getLayoutTransformer();
    //        vv2.setLayoutTransformer(transformer);
    //        vv3.setLayoutTransformer(transformer);
    //        
    //        vv2.setViewTransformer(vv1.getViewTransformer());
    //        vv3.setViewTransformer(vv1.getViewTransformer());

    vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());
    vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1);
    vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2);
    vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3);

    vv1.setBackground(Color.white);
    vv2.setBackground(Color.white);
    vv3.setBackground(Color.white);

    // create one pick support for all 3 views to share
    GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1);
    vv1.setPickSupport(pickSupport);
    vv2.setPickSupport(pickSupport);
    vv3.setPickSupport(pickSupport);

    // create one picked state for all 3 views to share
    PickedState<Number> pes = new MultiPickedState<Number>();
    PickedState<String> pvs = new MultiPickedState<String>();
    vv1.setPickedVertexState(pvs);
    vv2.setPickedVertexState(pvs);
    vv3.setPickedVertexState(pvs);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);
    vv3.setPickedEdgeState(pes);

    // set an edge paint function that shows picked edges
    vv1.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv2.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv3.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));
    vv2.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan));
    vv3.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));

    // add default listener for ToolTips
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());
    vv3.setVertexToolTipTransformer(new ToStringLabeller());

    Container content = getContentPane();
    JPanel panel = new JPanel(new GridLayout(1, 0));

    final JPanel p1 = new JPanel(new BorderLayout());
    final JPanel p2 = new JPanel(new BorderLayout());
    final JPanel p3 = new JPanel(new BorderLayout());

    p1.add(new GraphZoomScrollPane(vv1));
    p2.add(new GraphZoomScrollPane(vv2));
    p3.add(new GraphZoomScrollPane(vv3));

    JButton h1 = new JButton("?");
    h1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageOne);
            JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h2 = new JButton("?");
    h2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageTwo);
            JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h3 = new JButton("?");
    h3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageThree);
            textArea.setCaretPosition(0);
            JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE);
        }
    });

    // create a GraphMouse for each view
    // each one has a different scaling plugin
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }
    };

    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }

    };

    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() {
    };

    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    vv3.setGraphMouse(gm3);

    vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>");
    vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>");
    vv3.setToolTipText(
            "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>");

    vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1"));
    vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2"));
    vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3"));

    textArea = new JTextArea(6, 30);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);

    JPanel flow = new JPanel();
    flow.add(h1);
    flow.add(gm1.getModeComboBox());
    p1.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h2);
    flow.add(gm2.getModeComboBox());
    p2.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h3);
    flow.add(gm3.getModeComboBox());
    p3.add(flow, BorderLayout.SOUTH);

    panel.add(p1);
    panel.add(p2);
    panel.add(p3);
    content.add(panel);

}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

public static String showInputDialog(Component parent, String title, String message) {
    Object[] possibilities = null;
    String s = (String) JOptionPane.showInputDialog(parent, message, title, JOptionPane.PLAIN_MESSAGE, null,
            possibilities, null);//from  w  w  w  . j a v a2s  .c  om

    return StringUtils.isNotBlank(s) ? s : null;
}

From source file:edu.uci.ics.jung.samples.MultiViewDemo.java

/**
 * create an instance of a simple graph in two views with controls to
 * demo the zoom features./*from   www.  j a v a  2s  . c  om*/
 * 
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public MultiViewDemo() {

    // create a simple graph for the demo
    graph = TestGraphs.getOneComponentGraph();

    // create one layout for the graph
    FRLayout<String, Number> layout = new FRLayout<String, Number>(graph);
    layout.setMaxIterations(1000);

    // create one model that all 3 views will share
    VisualizationModel<String, Number> visualizationModel = new DefaultVisualizationModel<String, Number>(
            layout, preferredSize);

    // create 3 views that share the same model
    vv1 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv2 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);
    vv3 = new VisualizationViewer<String, Number>(visualizationModel, preferredSize);

    vv1.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line<String, Number>());
    vv2.getRenderContext()
            .setVertexShapeTransformer(new ConstantTransformer(new Rectangle2D.Float(-6, -6, 12, 12)));

    vv2.getRenderContext().setEdgeShapeTransformer(new EdgeShape.QuadCurve<String, Number>());

    vv3.getRenderContext().setEdgeShapeTransformer(new EdgeShape.CubicCurve<String, Number>());

    //        transformer = vv1.getLayoutTransformer();
    //        vv2.setLayoutTransformer(transformer);
    //        vv3.setLayoutTransformer(transformer);
    //        
    //        vv2.setViewTransformer(vv1.getViewTransformer());
    //        vv3.setViewTransformer(vv1.getViewTransformer());

    vv2.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());
    vv3.getRenderContext().setMultiLayerTransformer(vv1.getRenderContext().getMultiLayerTransformer());

    vv1.getRenderContext().getMultiLayerTransformer().addChangeListener(vv1);
    vv2.getRenderContext().getMultiLayerTransformer().addChangeListener(vv2);
    vv3.getRenderContext().getMultiLayerTransformer().addChangeListener(vv3);

    vv1.setBackground(Color.white);
    vv2.setBackground(Color.white);
    vv3.setBackground(Color.white);

    // create one pick support for all 3 views to share
    GraphElementAccessor<String, Number> pickSupport = new ShapePickSupport<String, Number>(vv1);
    vv1.setPickSupport(pickSupport);
    vv2.setPickSupport(pickSupport);
    vv3.setPickSupport(pickSupport);

    // create one picked state for all 3 views to share
    PickedState<Number> pes = new MultiPickedState<Number>();
    PickedState<String> pvs = new MultiPickedState<String>();
    vv1.setPickedVertexState(pvs);
    vv2.setPickedVertexState(pvs);
    vv3.setPickedVertexState(pvs);
    vv1.setPickedEdgeState(pes);
    vv2.setPickedEdgeState(pes);
    vv3.setPickedEdgeState(pes);

    // set an edge paint function that shows picked edges
    vv1.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv2.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv3.getRenderContext()
            .setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(pes, Color.black, Color.red));
    vv1.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));
    vv2.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.blue, Color.cyan));
    vv3.getRenderContext().setVertexFillPaintTransformer(
            new PickableVertexPaintTransformer<String>(pvs, Color.red, Color.yellow));

    // add default listener for ToolTips
    vv1.setVertexToolTipTransformer(new ToStringLabeller());
    vv2.setVertexToolTipTransformer(new ToStringLabeller());
    vv3.setVertexToolTipTransformer(new ToStringLabeller());

    Container content = getContentPane();
    JPanel panel = new JPanel(new GridLayout(1, 0));

    final JPanel p1 = new JPanel(new BorderLayout());
    final JPanel p2 = new JPanel(new BorderLayout());
    final JPanel p3 = new JPanel(new BorderLayout());

    p1.add(new GraphZoomScrollPane(vv1));
    p2.add(new GraphZoomScrollPane(vv2));
    p3.add(new GraphZoomScrollPane(vv3));

    JButton h1 = new JButton("?");
    h1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageOne);
            JOptionPane.showMessageDialog(p1, scrollPane, "View 1", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h2 = new JButton("?");
    h2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageTwo);
            JOptionPane.showMessageDialog(p2, scrollPane, "View 2", JOptionPane.PLAIN_MESSAGE);
        }
    });
    JButton h3 = new JButton("?");
    h3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText(messageThree);
            textArea.setCaretPosition(0);
            JOptionPane.showMessageDialog(p3, scrollPane, "View 3", JOptionPane.PLAIN_MESSAGE);
        }
    });

    // create a GraphMouse for each view
    // each one has a different scaling plugin
    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new LayoutScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }
    };

    DefaultModalGraphMouse gm2 = new DefaultModalGraphMouse() {
        protected void loadPlugins() {
            pickingPlugin = new PickingGraphMousePlugin();
            animatedPickingPlugin = new AnimatedPickingGraphMousePlugin();
            translatingPlugin = new TranslatingGraphMousePlugin(InputEvent.BUTTON1_MASK);
            scalingPlugin = new ScalingGraphMousePlugin(new ViewScalingControl(), 0);
            rotatingPlugin = new RotatingGraphMousePlugin();
            shearingPlugin = new ShearingGraphMousePlugin();

            add(scalingPlugin);
            setMode(Mode.TRANSFORMING);
        }

    };

    DefaultModalGraphMouse gm3 = new DefaultModalGraphMouse() {
    };

    vv1.setGraphMouse(gm1);
    vv2.setGraphMouse(gm2);
    vv3.setGraphMouse(gm3);

    vv1.setToolTipText("<html><center>MouseWheel Scales Layout</center></html>");
    vv2.setToolTipText("<html><center>MouseWheel Scales View</center></html>");
    vv3.setToolTipText(
            "<html><center>MouseWheel Scales Layout and<p>crosses over to view<p>ctrl+MouseWheel scales view</center></html>");

    vv1.addPostRenderPaintable(new BannerLabel(vv1, "View 1"));
    vv2.addPostRenderPaintable(new BannerLabel(vv2, "View 2"));
    vv3.addPostRenderPaintable(new BannerLabel(vv3, "View 3"));

    textArea = new JTextArea(6, 30);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);

    JPanel flow = new JPanel();
    flow.add(h1);
    flow.add(gm1.getModeComboBox());
    p1.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h2);
    flow.add(gm2.getModeComboBox());
    p2.add(flow, BorderLayout.SOUTH);
    flow = new JPanel();
    flow.add(h3);
    flow.add(gm3.getModeComboBox());
    p3.add(flow, BorderLayout.SOUTH);

    panel.add(p1);
    panel.add(p2);
    panel.add(p3);
    content.add(panel);

}

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

/**
 * Handles an action event./*  ww w  .  j  a v  a  2 s  .c o m*/
 * 
 * @param evt
 *            the event.
 */
public void actionPerformed(ActionEvent evt) {
    try {
        String acmd = evt.getActionCommand();

        if (acmd.equals(ACTION_CHART_ZOOM_BOX)) {
            setPanMode(false);
        } else if (acmd.equals(ACTION_CHART_PAN)) {
            setPanMode(true);
        } else if (acmd.equals(ACTION_CHART_ZOOM_IN)) {
            ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
            Rectangle2D rect = info.getPlotInfo().getDataArea();
            zoomBoth(rect.getCenterX(), rect.getCenterY(), ZOOM_FACTOR);
        } else if (acmd.equals(ACTION_CHART_ZOOM_OUT)) {
            ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
            Rectangle2D rect = info.getPlotInfo().getDataArea();
            zoomBoth(rect.getCenterX(), rect.getCenterY(), 1 / ZOOM_FACTOR);
        } else if (acmd.equals(ACTION_CHART_ZOOM_TO_FIT)) {

            // X-axis (has no fixed borders)
            chartPanel.autoRangeHorizontal();
            Plot plot = chartPanel.getChart().getPlot();
            if (plot instanceof ValueAxisPlot) {
                XYPlot vvPlot = (XYPlot) plot;
                ValueAxis axis = vvPlot.getRangeAxis();
                if (axis != null) {
                    axis.setLowerBound(yMin);
                    axis.setUpperBound(yMax);
                }
            }
        } else if (acmd.equals(ACTION_CHART_EXPORT)) {
            try {
                chartPanel.doSaveAs();
            } catch (IOException i) {
                MsgBox.error(i.getMessage());
            }
        } else if (acmd.equals(ACTION_CHART_PRINT)) {
            chartPanel.createChartPrintJob();

        } else if (acmd.equals(ACTION_CHART_PROPERTIES)) {
            ChartPropertyEditPanel panel = new ChartPropertyEditPanel(jFreeChart);
            int result = JOptionPane.showConfirmDialog(this, panel,
                    localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);
            if (result == JOptionPane.OK_OPTION) {
                panel.updateChartProperties(jFreeChart);
            }
        }

    } catch (Exception e) {
        MsgBox.error(e.getMessage());
    }
}