Example usage for javax.swing JOptionPane showInputDialog

List of usage examples for javax.swing JOptionPane showInputDialog

Introduction

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

Prototype

public static String showInputDialog(Component parentComponent, Object message, String title, int messageType)
        throws HeadlessException 

Source Link

Document

Shows a dialog requesting input from the user parented to parentComponent with the dialog having the title title and message type messageType.

Usage

From source file:org.bimserver.client.Client.java

public void checkin(SProject project, DataSource dataSource, long fileSize) {
    String comment = JOptionPane.showInputDialog(Client.this, "Please give a short description of your changes",
            "Checkin", JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE);
    try {//from w  ww.jav a  2  s.  co m
        DataHandler ifcFile = new DataHandler(dataSource);
        int checkinId = serviceHolder.getService().checkin(project.getOid(), comment, "TODO", fileSize, ifcFile,
                false, true);
        SCheckinResult sCheckinResult = serviceHolder.getService().getCheckinState(checkinId);
        JOptionPane.showMessageDialog(this, "New revision number: " + sCheckinResult.getRevisionId(),
                "Checkin successful", JOptionPane.OK_OPTION | JOptionPane.INFORMATION_MESSAGE);
        revisionPanel.showProject(project);
    } catch (ServiceException e) {
        JOptionPane.showMessageDialog(this, e.getUserMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

From source file:org.datacleaner.actions.PublishResultToMonitorActionListener.java

@Override
protected boolean doBeforeAction() {
    if (_jobFilename == null) {
        final String jobName = JOptionPane.showInputDialog(null,
                "Enter the name of a (new or existing) job on the server that this result refers to?",
                "Job name on server", JOptionPane.QUESTION_MESSAGE);
        if (Strings.isNullOrEmpty(jobName)) {
            return false;
        }/*  w w  w .  ja va2  s .com*/
        _resultFilename = jobName;
    } else {
        final String jobExtension = FileFilters.ANALYSIS_XML.getExtension();

        String baseName = _jobFilename.getName().getBaseName();
        if (baseName.endsWith(jobExtension)) {
            baseName = baseName.substring(0, baseName.length() - jobExtension.length());
        }
        _resultFilename = baseName;
    }
    return true;
}

From source file:org.dc.file.search.ui.DashboardForm.java

private void btnNewCommentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewCommentActionPerformed
    int row = tblSearchResults.getSelectedRow();
    if (row == -1) {
        JOptionPane.showMessageDialog(this, "Please select a file first.", "Information",
                JOptionPane.INFORMATION_MESSAGE);
        return;//from  w w w.  ja  v a2s  .c o m
    }
    String fileName = tblSearchResults.getModel().getValueAt(row, 2).toString();
    String commentString = JOptionPane.showInputDialog(null, "Add comment for " + fileName, "Add A New Comment",
            JOptionPane.QUESTION_MESSAGE);
    if (commentString != null && !commentString.isEmpty()) {
        String username = Store.getInstance().getLocalPeer().getUsername();
        DFile commentedFile = resultFiles.get(fileName);
        Comment comment = new Comment();
        comment.setCommentId(RandomStringUtils.randomAlphanumeric(8));
        comment.setFileName(fileName);
        comment.setUserName(username);
        comment.setText(commentString);

        List<Comment> comments = commentedFile.getComments();
        comments.add(comment);

        Store.getInstance().addComment(comment);
        final String commentJSON = new Gson().toJson(comment);
        Store.getInstance().getPeerList().forEach(stringPeerEntry -> {
            String peerIP = stringPeerEntry.getValue().getIp();
            int peerPort = stringPeerEntry.getValue().getPort();
            Peer localPeer = Store.getInstance().getLocalPeer();
            MessageUtils.sendUDPMessage(peerIP, peerPort, MessageType.COMMENT + " " + localPeer.getIp() + " "
                    + localPeer.getPort() + " " + commentJSON);
        });

        //Update comments table again
        updateCommentTable();
    }
}

From source file:org.dc.file.search.ui.DashboardForm.java

public ButtonPanel(JTable jTable) {
    this.jTable = jTable;
    setLayout(new GridLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    button.addActionListener(e -> {//  w  w w .  ja v a2s  .  c o  m
        int row = jTable.getSelectedRow();
        if (row == -1) {
            JOptionPane.showMessageDialog(this, "Please select a comment first.", "Information",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        String commentId = jTable.getValueAt(jTable.getSelectedRow(), 0).toString();
        String commentString = JOptionPane.showInputDialog(null, "Add reply for " + commentId,
                "Add A New Reply", JOptionPane.QUESTION_MESSAGE);
        if (commentString != null && !commentString.isEmpty()) {
            String username = Store.getInstance().getLocalPeer().getUsername();
            DFile commentedFile = resultFiles.get(selectedFile);
            List<Comment> comments = commentedFile.getComments();
            Comment selectedComment = null;
            for (Comment c : comments) {
                if (c.getCommentId().equals(commentId)) {
                    selectedComment = c;
                    break;
                }
            }

            if (selectedComment != null) {
                Comment replyComment = new Comment();
                replyComment.setCommentId(RandomStringUtils.randomAlphanumeric(8));
                replyComment.setFileName(selectedFile);
                replyComment.setParentId(commentId);
                replyComment.setUserName(username);
                replyComment.setText(commentString);

                selectedComment.getReplies().add(replyComment);
                Store.getInstance().addComment(replyComment);
                final String commentJSON = new Gson().toJson(replyComment);
                Store.getInstance().getPeerList().forEach(stringPeerEntry -> {
                    String peerIP = stringPeerEntry.getValue().getIp();
                    int peerPort = stringPeerEntry.getValue().getPort();
                    Peer localPeer = Store.getInstance().getLocalPeer();
                    MessageUtils.sendUDPMessage(peerIP, peerPort, MessageType.COMMENT + " " + localPeer.getIp()
                            + " " + localPeer.getPort() + " " + commentJSON);
                });
            }
        }
    });
    add(button);
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.Cockpit.java

/**
 * Adds a bucket not owned by the current S3 user to the bucket listing, after
 * prompting the user for the name of the bucket to add.
 * To be added in this way, the third-party bucket must be publicly available.
 *
 *//*from   ww  w.  j  av a  2  s .co  m*/
private void addThirdPartyBucket() {
    try {
        String bucketName = (String) JOptionPane.showInputDialog(ownerFrame, "Name for third-party bucket:",
                "Add a third-party bucket", JOptionPane.QUESTION_MESSAGE);

        if (bucketName != null) {
            if (s3ServiceMulti.getS3Service().isBucketAccessible(bucketName)) {
                S3Bucket thirdPartyBucket = new S3Bucket(bucketName);
                bucketTableModel.addBucket(thirdPartyBucket, false);
            } else {
                String message = "Unable to access third-party bucket: " + bucketName;
                log.error(message);
                ErrorDialog.showDialog(ownerFrame, this, message, null);
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        String message = "Unable to access third-party bucket";
        log.error(message, e);
        ErrorDialog.showDialog(ownerFrame, this, message, e);
    }
}

From source file:org.gitools.ui.app.actions.file.OpenFromURLAction.java

@Override
public void actionPerformed(ActionEvent e) {

    String fileURL = JOptionPane.showInputDialog(null, "Specify URL:", "Open URL",
            JOptionPane.QUESTION_MESSAGE);

    if (!isEmpty(fileURL)) {
        JobRunnable loadFile = new CommandLoadFile(fileURL);
        JobThread.execute(Application.get(), loadFile);
        Application.get().showNotification("File loaded.");
    }/*from w ww . ja  va2 s.  co  m*/
}

From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java

/** File Menu Action */
@Action/*from   ww  w  .  ja  va  2 s  .  co  m*/
public void fileOpenURL() {
    final String a = "fileOpenURL";
    if (!askDiscardUnsaved(gui.findAction(a)))
        return;
    final ResourceMap r = getContext().getResourceMap();
    final String title = r.getString(a + ".Dialog" + ".title");
    final String msg = r.getString(a + ".Dialog" + ".message");
    for (;;) {
        final String url = JOptionPane.showInputDialog(getMainFrame(), msg, title,
                JOptionPane.QUESTION_MESSAGE);
        if (url == null)
            return;
        try {
            setDocument(new URL(url));
            return;
        } catch (final IOException e) {
            showErrorDialog(r.getString(a + ".Dialog" + ".error", url), e);
        }
    }
}

From source file:org.omegat.gui.main.ProjectUICommands.java

/**
 * Does wikiread// w  w w.  ja  v  a 2  s.c o m
 */
public static void doWikiImport() {
    String remote_url = JOptionPane.showInputDialog(Core.getMainWindow().getApplicationFrame(),
            OStrings.getString("TF_WIKI_IMPORT_PROMPT"), OStrings.getString("TF_WIKI_IMPORT_TITLE"),
            JOptionPane.OK_CANCEL_OPTION);
    String projectsource = Core.getProject().getProjectProperties().getSourceRoot();
    if (remote_url == null || remote_url.trim().isEmpty()) {
        // [1762625] Only try to get MediaWiki page if a string has been entered
        return;
    }
    try {
        WikiGet.doWikiGet(remote_url, projectsource);
        projectReload();
    } catch (Exception ex) {
        Log.log(ex);
        Core.getMainWindow().displayErrorRB(ex, "TF_WIKI_IMPORT_FAILED");
    }
}

From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java

/**
 * <p>// w  w w.  j ava 2 s .  c o m
 * Method for adding a fuzzer in the payloads table.
 * </p>
 */
@Override
public void add() {

    // Check to see what text has been selected
    try {
        requestPane.getSelectedText();
    } catch (final IllegalArgumentException e) {

        JOptionPane.showInputDialog(this, "An exception was thrown while attempting to get the selected text",
                "Add Fuzzer", JOptionPane.ERROR_MESSAGE);
    }
    // Find the location of where the text has been selected
    final int sPoint = requestPane.getSelectionStart();
    final int fPoint = requestPane.getSelectionEnd();

    new PayloadsDialog(this, sPoint, fPoint);

}

From source file:org.pgptool.gui.ui.tools.UiUtils.java

public static String promptUserForTextString(String fieldLabel, Object[] fieldLabelMsgArgs, String windowTitle,
        Window window) {//from  w  w  w . jav a  2s  .  c o  m
    String ret = JOptionPane.showInputDialog(window, Messages.get(fieldLabel, fieldLabelMsgArgs),
            Messages.get(windowTitle), JOptionPane.QUESTION_MESSAGE);

    return ret == null ? null : ret.trim();
}