List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
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; }//www . ja v a 2 s .co m _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.datacleaner.windows.AnalysisJobBuilderWindowImpl.java
@Override protected boolean onWindowClosing() { if (!super.onWindowClosing()) { return false; }//from ww w. ja v a2s . c om switch (_currentPanelType) { case WELCOME: final int count = getWindowContext().getWindowCount(AnalysisJobBuilderWindow.class); if (count == 1) { if (getWindowContext().showExitDialog()) { cleanupForWindowClose(); getWindowContext().exit(); } } else { cleanupForWindowClose(); return true; } break; case EDITING_CONTEXT: // if datastore is set and datastore selection is enabled, // return to datastore selection. if (isJobUnsaved(getJobFile(), _analysisJobBuilder) && (_saveButton.isEnabled())) { final Object[] buttons = { "Save changes", "Discard changes", "Cancel" }; final int unsavedChangesChoice = JOptionPane.showOptionDialog(this, "The job has unsaved changes. What would you like to do?", "Unsaved changes detected", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, buttons, buttons[1]); if (unsavedChangesChoice == 0) { // save changes _saveButton.doClick(); } else if (unsavedChangesChoice != 1) { // cancel closing return false; } } resetJob(); break; default: changePanel(AnalysisWindowPanelType.WELCOME); } return false; }
From source file:org.datavyu.views.DataControllerV.java
/** * Presents a confirmation dialog when removing a plugin from the project. * @return True if the plugin should be removed, false otherwise. *//* www . ja va2s . co m*/ private boolean shouldRemove() { ResourceMap rMap = Application.getInstance(Datavyu.class).getContext().getResourceMap(Datavyu.class); String cancel = "Cancel"; String ok = "OK"; String[] options = new String[2]; if (Datavyu.getPlatform() == Platform.MAC) { options[0] = cancel; options[1] = ok; } else { options[0] = ok; options[1] = cancel; } int selection = JOptionPane.showOptionDialog(this, rMap.getString("ClosePluginDialog.message"), rMap.getString("ClosePluginDialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, cancel); // Button behaviour is platform dependent. return (Datavyu.getPlatform() == Platform.MAC) ? (selection == 1) : (selection == 0); }
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.j av a 2 s. 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 -> {//from w w w.j a va 2s .com 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.docx4all.ui.main.WordMLEditor.java
private int showConfirmClosingInternalFrame(JInternalFrame iframe, String resourceKeyPrefix) { int answer = JOptionPane.CANCEL_OPTION; String filePath = (String) iframe.getClientProperty(WordMLDocument.FILE_PATH_PROPERTY); ResourceMap rm = getContext().getResourceMap(); String title = rm.getString(resourceKeyPrefix + ".dialog.title") + " " + filePath.substring(filePath.lastIndexOf(File.separator) + 1); String message = filePath + "\n" + rm.getString(resourceKeyPrefix + ".confirmMessage"); Object[] options = { rm.getString(resourceKeyPrefix + ".confirm.saveNow"), rm.getString(resourceKeyPrefix + ".confirm.dontSave"), rm.getString(resourceKeyPrefix + ".confirm.cancel") }; answer = showConfirmDialog(title, message, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, options, options[0]);//from w w w . j a va 2 s . c o m if (answer == JOptionPane.CANCEL_OPTION) { ; } else if (answer == JOptionPane.YES_OPTION) { boolean success = FileMenu.getInstance().save(iframe, null, FileMenu.SAVE_FILE_ACTION_NAME); if (success) { getToolbarStates().setDocumentDirty(iframe, false); getToolbarStates().setLocalEditsEnabled(iframe, false); } else { answer = JOptionPane.CANCEL_OPTION; } } else { //getToolbarStates().setDocumentDirty(iframe, false); } return answer; }
From source file:org.docx4all.ui.menu.FileMenu.java
private RETURN_TYPE saveAsFile(String callerActionName, ActionEvent actionEvent, String fileType) { Preferences prefs = Preferences.userNodeForPackage(getClass()); WordMLEditor editor = WordMLEditor.getInstance(WordMLEditor.class); ResourceMap rm = editor.getContext().getResourceMap(getClass()); JInternalFrame iframe = editor.getCurrentInternalFrame(); String oldFilePath = (String) iframe.getClientProperty(WordMLDocument.FILE_PATH_PROPERTY); VFSJFileChooser chooser = createFileChooser(rm, callerActionName, iframe, fileType); RETURN_TYPE returnVal = chooser.showSaveDialog((Component) actionEvent.getSource()); if (returnVal == RETURN_TYPE.APPROVE) { FileObject selectedFile = getSelectedFile(chooser, fileType); boolean error = false; boolean newlyCreatedFile = false; if (selectedFile == null) { // Should never happen, whether the file exists or not } else {// w w w . j a v a2 s . c o m //Check selectedFile's existence and ask user confirmation when needed. try { boolean selectedFileExists = selectedFile.exists(); if (!selectedFileExists) { FileObject parent = selectedFile.getParent(); String uri = UriParser.decode(parent.getName().getURI()); if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") > -1 && parent.getName().getScheme().startsWith("file") && !parent.isWriteable() && (uri.indexOf("/Documents") > -1 || uri.indexOf("/My Documents") > -1)) { //TODO: Check whether we still need this workaround. //See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4939819 //Re: File.canWrite() returns false for the "My Documents" directory (win) String localpath = org.docx4j.utils.VFSUtils.getLocalFilePath(parent); File f = new File(localpath); f.setWritable(true, true); } selectedFile.createFile(); newlyCreatedFile = true; } else if (!selectedFile.getName().getURI().equalsIgnoreCase(oldFilePath)) { String title = rm.getString(callerActionName + ".Action.text"); String message = VFSUtils.getFriendlyName(selectedFile.getName().getURI()) + "\n" + rm.getString(callerActionName + ".Action.confirmMessage"); int answer = editor.showConfirmDialog(title, message, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (answer != JOptionPane.YES_OPTION) { selectedFile = null; } } // if (!selectedFileExists) } catch (FileSystemException exc) { exc.printStackTrace();//ignore log.error("Couldn't create new file or assure file existence. File = " + selectedFile.getName().getURI()); selectedFile = null; error = true; } } //Check whether there has been an error, cancellation by user //or may proceed to saving file. if (selectedFile != null) { //Proceed to saving file String selectedPath = selectedFile.getName().getURI(); if (log.isDebugEnabled()) { log.debug("saveAsFile(): selectedFile = " + VFSUtils.getFriendlyName(selectedPath)); } prefs.put(Constants.LAST_OPENED_FILE, selectedPath); if (selectedFile.getName().getScheme().equals("file")) { prefs.put(Constants.LAST_OPENED_LOCAL_FILE, selectedPath); } PreferenceUtil.flush(prefs); boolean success = false; if (EXPORT_AS_NON_SHARED_DOC_ACTION_NAME.equals(callerActionName)) { log.info("saveAsFile(): Exporting as non shared document to " + VFSUtils.getFriendlyName(selectedPath)); success = export(iframe, selectedPath, callerActionName); if (success) { prefs.put(Constants.LAST_OPENED_FILE, selectedPath); if (selectedPath.startsWith("file:")) { prefs.put(Constants.LAST_OPENED_LOCAL_FILE, selectedPath); } PreferenceUtil.flush(prefs); log.info("saveAsFile(): Opening " + VFSUtils.getFriendlyName(selectedPath)); editor.createInternalFrame(selectedFile); } } else { success = save(iframe, selectedPath, callerActionName); if (success) { if (Constants.DOCX_STRING.equals(fileType) || Constants.FLAT_OPC_STRING.equals(fileType)) { //If saving as .docx then update the document dirty flag //of toolbar states as well as internal frame title. editor.getToolbarStates().setDocumentDirty(iframe, false); editor.getToolbarStates().setLocalEditsEnabled(iframe, false); FileObject file = null; try { file = VFSUtils.getFileSystemManager().resolveFile(oldFilePath); editor.updateInternalFrame(file, selectedFile); } catch (FileSystemException exc) { ;//ignore } } else { //Because document dirty flag is not cleared //and internal frame title is not changed, //we present a success message. String title = rm.getString(callerActionName + ".Action.text"); String message = VFSUtils.getFriendlyName(selectedPath) + "\n" + rm.getString(callerActionName + ".Action.successMessage"); editor.showMessageDialog(title, message, JOptionPane.INFORMATION_MESSAGE); } } } if (!success && newlyCreatedFile) { try { selectedFile.delete(); } catch (FileSystemException exc) { log.error("saveAsFile(): Saving failure and cannot remove the newly created file = " + selectedPath); exc.printStackTrace(); } } } else if (error) { log.error("saveAsFile(): selectedFile = NULL"); String title = rm.getString(callerActionName + ".Action.text"); String message = rm.getString(callerActionName + ".Action.errorMessage"); editor.showMessageDialog(title, message, JOptionPane.ERROR_MESSAGE); } } //if (returnVal == JFileChooser.APPROVE_OPTION) return returnVal; }
From source file:org.domainmath.gui.MainFrame.java
/** * It closes a file.//w ww . j a v a 2s .c o m * @param selectedIndex */ public void askSave(int selectedIndex) { String s = fileTab.getTitleAt(selectedIndex); if (s.endsWith("*")) { //modified document. String f = s.substring(0, s.lastIndexOf("*")); // ask to save file. int i = JOptionPane.showConfirmDialog(this, "Do you want to save changes in " + f + " ?", "DomainMath IDE", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (i == JOptionPane.YES_OPTION) { //need to save file // add this file to recent menu list. File selected_file = new File(fileTab.getToolTipTextAt(selectedIndex)); recentFileMenu.addEntry(selected_file.getAbsolutePath()); // save the file. save(selected_file, selectedIndex); // close the file. this.removeFileNameFromList(selectedIndex); fileTab.remove(selectedIndex); FILE_TAB_INDEX--; } else if (i == JOptionPane.NO_OPTION) { // I dont need to save the file. // add this file to recent menu list. File selected_file = new File(fileTab.getToolTipTextAt(selectedIndex)); recentFileMenu.addEntry(selected_file.getAbsolutePath()); // close the file. this.removeFileNameFromList(selectedIndex); fileTab.remove(selectedIndex); FILE_TAB_INDEX--; } } else { //unmodified file. // add this file to recent menu list. File selected_file = new File(fileTab.getToolTipTextAt(selectedIndex)); recentFileMenu.addEntry(selected_file.getAbsolutePath()); // close the file. removeFileNameFromList(selectedIndex); fileTab.remove(selectedIndex); FILE_TAB_INDEX--; } }
From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java
public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration, final OpenAnalysisJobActionListener openAnalysisJobActionListener) { super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT); _file = file;/* ww w.j av a 2 s . com*/ _openAnalysisJobActionListener = openAnalysisJobActionListener; setLayout(new BorderLayout()); setBorder(WidgetUtils.BORDER_LIST_ITEM); final AnalysisJobMetadata metadata = getMetadata(configuration); final String jobName = metadata.getJobName(); final String jobDescription = metadata.getJobDescription(); final String datastoreName = metadata.getDatastoreName(); final boolean isDemoJob = isDemoJob(metadata); final DCPanel labelListPanel = new DCPanel(); labelListPanel.setLayout(new VerticalLayout(4)); labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final String title; final String filename = file.getName().getBaseName(); if (Strings.isNullOrEmpty(jobName)) { final String extension = FileFilters.ANALYSIS_XML.getExtension(); if (filename.toLowerCase().endsWith(extension)) { title = filename.substring(0, filename.length() - extension.length()); } else { title = filename; } } else { title = jobName; } final JButton titleButton = new JButton(title); titleButton.setFont(WidgetUtils.FONT_HEADER1); titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM); titleButton.setHorizontalAlignment(SwingConstants.LEFT); titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM)); titleButton.setToolTipText("Open job"); titleButton.setOpaque(false); titleButton.setMargin(new Insets(0, 0, 0, 0)); titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); titleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { _openAnalysisJobActionListener.openFile(_file); } } }); final JButton executeButton = new JButton(executeIcon); executeButton.setOpaque(false); executeButton.setToolTipText("Execute job directly"); executeButton.setMargin(new Insets(0, 0, 0, 0)); executeButton.setBorderPainted(false); executeButton.setHorizontalAlignment(SwingConstants.RIGHT); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE); final String question = "Are you sure you want to execute the job\n'" + title + "'?"; final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge); if (choice == JOptionPane.YES_OPTION) { final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file); if (injector != null) { final ResultWindow resultWindow = injector.getInstance(ResultWindow.class); resultWindow.open(); resultWindow.startAnalysis(); } } } } }); final DCPanel titlePanel = new DCPanel(); titlePanel.setLayout(new BorderLayout()); titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER); titlePanel.add(executeButton, BorderLayout.EAST); labelListPanel.add(titlePanel); if (!Strings.isNullOrEmpty(jobDescription)) { String desc = StringUtils.replaceWhitespaces(jobDescription, " "); desc = StringUtils.replaceAll(desc, " ", " "); final JLabel label = new JLabel(desc); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); } final Icon icon; { if (!StringUtils.isNullOrEmpty(datastoreName)) { final JLabel label = new JLabel(" " + datastoreName); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (isDemoJob) { icon = demoBadgeIcon; } else { icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore); } } else { icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE); } } final JLabel iconLabel = new JLabel(icon); iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); add(iconLabel, BorderLayout.WEST); add(labelListPanel, BorderLayout.CENTER); }
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. * *///w w w. ja v a 2s . 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); } }