List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:net.bioclipse.structuredb.actions.RemoveAllDatabasesAction.java
License:Open Source License
@Override public void run(IAction action) { MessageDialog dialog = new MessageDialog(null, "Confirm removal of all databases", null, "Really remove all databases?", MessageDialog.QUESTION, new String[] { "Yes", "Cancel" }, 0); // yes is the default int result = dialog.open(); if (result == 0) { Activator.getDefault().getStructuredbManager().deleteAllDatabases(); }/*ww w . j a v a 2s .c o m*/ }
From source file:net.bioclipse.ui.dialogs.SaveAsDialog.java
License:Open Source License
protected void okPressed() { // Get new path. IPath path = resourceGroup.getContainerFullPath().append(resourceGroup.getResource()); //If the user does not supply a file extension and if the save //as dialog was provided a default file name append the extension //of the default filename to the new name if (path.getFileExtension() == null) { if (originalFile != null && originalFile.getFileExtension() != null) { path = path.addFileExtension(originalFile.getFileExtension()); } else if (originalName != null) { int pos = originalName.lastIndexOf('.'); if (++pos > 0 && pos < originalName.length()) { path = path.addFileExtension(originalName.substring(pos)); }/*from w w w . ja v a2s. c o m*/ } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = NLS.bind(IDEWorkbenchMessages.SaveAsDialog_overwriteQuestion, path.toString()); MessageDialog d = new MessageDialog(getShell(), IDEWorkbenchMessages.Question, null, question, MessageDialog.QUESTION, buttons, 0); int overwrite = d.open(); switch (overwrite) { case 0: // Yes break; case 1: // No return; case 2: // Cancel default: cancelPressed(); return; } } // Store path and close. result = path; close(); }
From source file:net.geoprism.shapefile.LocalizedWizardDialog.java
License:Open Source License
/** * Creates and return a new wizard closing dialog without opening it. * //from w w w . ja v a 2s.co m * @return MessageDalog */ private MessageDialog createWizardClosingDialog() { MessageDialog result = new MessageDialog(getShell(), Localizer.getMessage("WINDOW_CLOSING_TITLE"), //$NON-NLS-1$ null, Localizer.getMessage("WINDOW_CLOSING"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Localizer.getMessage("OK") }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; return result; }
From source file:net.leboxondelex.daplomb.utils.Utils.java
License:Open Source License
/** * Opens a message dialog with a the inner i18n system. * @param parent// w ww . ja v a 2s .c o m * @param title * @param message * @return true if the user presses the "yes" button */ public static boolean showQuestion(Shell parent, String title, String message) { MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.QUESTION, new String[] { "Oui", "Non" }, 0); return dialog.open() == 0; }
From source file:net.refractions.udig.ui.dialogs.WizardDataTransferPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and returns * the user's response.//from w w w .ja va2s .co m * * @param message the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ protected boolean queryYesNoQuestion(String message) { MessageDialog dialog = new MessageDialog(getContainer().getShell(), Messages.WizardDataTransferPage_dialog_title, (Image) null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); // ensure yes is the default return dialog.open() == 0; }
From source file:net.refractions.udig.ui.ZoomingDialog.java
License:Open Source License
public static boolean openQuestionMessage(Rectangle start, Shell parentShell, String dialogTitle, String dialogMessage) {/*from www . j a v a 2s . c om*/ int result = openMessageDialog(start, parentShell, dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); return result == IDialogConstants.YES_ID; }
From source file:net.resheim.eclipse.timekeeper.ui.Activator.java
License:Open Source License
/** * Must be called by the UI-thread// www .j a v a 2 s . c o m * * @param idleTimeMillis */ private void handleReactivation(long idleTimeMillis) { // We want only one dialog open. if (dialogIsOpen) { return; } synchronized (this) { if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) { // If we have an active task ITask task = TasksUi.getTaskActivityManager().getActiveTask(); if (task != null && Activator.getValue(task, Activator.START) != null) { dialogIsOpen = true; String tickString = Activator.getValue(task, Activator.TICK); LocalDateTime started = getActiveSince(); LocalDateTime ticked = LocalDateTime.parse(tickString); LocalDateTime lastTick = ticked; // Subtract the IDLE_INTERVAL time the computer _was_ // idle while counting up to the threshold. During this // period fields were updated. Thus must be adjusted for. ticked = ticked.minusNanos(IDLE_INTERVAL); String time = DurationFormatUtils.formatDuration(lastIdleTime, "H:mm:ss", true); StringBuilder sb = new StringBuilder(); if (task.getTaskKey() != null) { sb.append(task.getTaskKey()); sb.append(": "); } sb.append(task.getSummary()); MessageDialog md = new MessageDialog(Display.getCurrent().getActiveShell(), "Disregard idle time?", null, MessageFormat.format( "The computer has been idle since {0}, more than {1}. The active task \"{2}\" was started on {3}. Deactivate the task and disregard the idle time?", ticked.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US)), time, sb.toString(), started.format(DateTimeFormatter.ofPattern("EEE e, HH:mm:ss", Locale.US))), MessageDialog.QUESTION, new String[] { "No", "Yes" }, 1); int open = md.open(); dialogIsOpen = false; if (open == 1) { // Stop task, subtract initial idle time TasksUi.getTaskActivityManager().deactivateTask(task); reduceTime(task, ticked.toLocalDate().toString(), IDLE_INTERVAL / 1000); } else { // Continue task, add idle time LocalDateTime now = LocalDateTime.now(); long seconds = lastTick.until(now, ChronoUnit.MILLIS); accumulateTime(task, ticked.toLocalDate().toString(), seconds); Activator.setValue(task, Activator.TICK, now.toString()); } } } } }
From source file:net.rim.ejde.internal.ui.preferences.WarningsPrefsPage.java
License:Open Source License
private void storePrefValues() { Map<String, Boolean> currentStatusTable = new HashMap<String, Boolean>(); boolean needBuild = false, givePrompt = ContextManager.getDefault().getPreferenceStore() .getBoolean(IConstants.PROMPT_FOR_BUILD_KEY); List<IMarker> problems = null; for (TreeItem item : _checkTree.getItems()) { Integer itemKey = VMUtils.convertPreferenceLabelToKey(item.getText()); currentStatusTable.put(item.getText(), Boolean.valueOf(item.getChecked())); boolean oldCheckedValue = WarningsPreferences.getWarnStatus(item.getText()); if (item.getChecked() && !oldCheckedValue) { if (problems == null) { try { problems = Arrays.asList(ResourcesPlugin.getWorkspace().getRoot() .findMarkers(IRIMMarker.CODE_SIGN_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE)); } catch (CoreException e) { _log.error("Error Finding Workspace Markers", e); }//from ww w. j a v a2 s. c o m if (problems == null) { break; } } List<IMarker> retainedProblems = new ArrayList<IMarker>(); for (IMarker marker : problems) { try { Object key = marker.getAttribute(IRIMMarker.KEY); if (key != null && key.equals(itemKey)) { marker.delete(); } else { retainedProblems.add(marker); } } catch (CoreException e) { _log.error("Error Retrieving Key from marker", e); } } problems = retainedProblems; } else if (!item.getChecked() && oldCheckedValue) { needBuild = true; } } WarningsPreferences.setCodeSignWarnStatus(currentStatusTable); WarningsPreferences.setPromptForMissingDebugFiles(_promptForDebugFileButton.getSelection()); WarningsPreferences .setPromptForMissingDependenciesFiles(_promptForMissingDependenciesFileButton.getSelection()); if (needBuild && givePrompt) { MessageDialog dialog = new MessageDialog(getShell(), Messages.CodeSigningPrefsPage_MessageDialogTitle2, null, Messages.CodeSigningPrefsPage_MessageDialogMsg2, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 2); int res = dialog.open(); if (res == 0) { CoreUtility.getBuildJob(null).schedule(); } } }
From source file:net.sf.eclipse.tomcat.TomcatProjectChangeListener.java
License:Open Source License
public void resourceChanged(IResourceChangeEvent event) { if (event.getResource() instanceof IProject) { final TomcatProject project = TomcatProject.create((IProject) event.getResource()); if (project != null) { Display.getDefault().syncExec(new Runnable() { public void run() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); String[] labels = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog(window.getShell(), WIZARD_PROJECT_REMOVE_TITLE, null, WIZARD_PROJECT_REMOVE_DESCRIPTION, MessageDialog.QUESTION, labels, 1); if (dialog.open() == MessageDialog.OK) { try { project.removeContext(); } catch (Exception ex) { TomcatLauncherPlugin.log(ex.getMessage()); }//from ww w. ja va 2 s . c om } } }); } } }
From source file:net.sf.eclipsensis.dialogs.NSISAssociatedHeadersPropertyPage.java
License:Open Source License
@Override public Control createControl(final Composite parent) { mOriginalHeaders = mHeaderAssociationManager .getAssociatedHeaders((IFile) ((NSISProperties) mSettings).getResource()); mHeaders = new HashSet<IFile>(); initHeaders();// w w w . j a v a2 s . c o m final IFilter filter = new IFilter() { public boolean select(Object toTest) { if (toTest instanceof IFile) { String ext = ((IFile) toTest).getFileExtension(); if (ext != null && ext.equalsIgnoreCase(INSISConstants.NSH_EXTENSION)) { return mHeaders != null && !mHeaders.contains(toTest); } } return false; } }; Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, false); composite.setLayout(layout); Label l = new Label(composite, SWT.NONE); l.setText(EclipseNSISPlugin.getResourceString("associated.headers.title")); //$NON-NLS-1$ GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); data.horizontalSpan = 2; l.setLayoutData(data); Table table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn column = new TableColumn(table, SWT.LEFT, 0); column.setText(EclipseNSISPlugin.getResourceString("associated.headers.column.label")); //$NON-NLS-1$ table.addControlListener(new TableResizer()); mViewer = new TableViewer(table); mViewer.setContentProvider(new CollectionContentProvider()); mViewer.setLabelProvider(new CollectionLabelProvider() { @Override public String getColumnText(Object element, int columnIndex) { if (element instanceof IFile) { return ((IFile) element).getFullPath().toString(); } return null; } }); mViewer.setComparator(new ViewerComparator() { @Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof IFile && e2 instanceof IFile) { return ((IFile) e1).getFullPath().toString().compareTo(((IFile) e2).getFullPath().toString()); } return super.compare(viewer, e1, e2); } }); data = new GridData(SWT.FILL, SWT.FILL, true, true); data.verticalSpan = 2; table.setLayoutData(data); Button addButton = new Button(composite, SWT.PUSH); addButton.setImage(CommonImages.ADD_ICON); addButton.setToolTipText(EclipseNSISPlugin.getResourceString("add.associated.header.toolip")); //$NON-NLS-1$ addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { FileSelectionDialog dialog = new FileSelectionDialog(parent.getShell(), ((NSISProperties) mSettings).getResource().getParent(), filter); dialog.setDialogMessage(EclipseNSISPlugin.getResourceString("nsis.script.prompt")); //$NON-NLS-1$ dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IFile file = dialog.getFile(); IFile script = mHeaderAssociationManager.getAssociatedScript(file); if (script != null && !script.equals(((NSISProperties) mSettings).getResource()) && mReassociateHeaderWarning.getSelection()) { MessageDialogWithToggle dlg = new MessageDialogWithToggle(parent.getShell(), EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$ EclipseNSISPlugin.getShellImage(), EclipseNSISPlugin.getFormattedString("associated.header.warning", //$NON-NLS-1$ new String[] { file.getFullPath().toString(), script.getFullPath().toString() }), MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0, EclipseNSISPlugin.getResourceString("associated.header.toggle.message"), false); //$NON-NLS-1$ dlg.open(); if (dialog.getReturnCode() == IDialogConstants.OK_ID) { mReassociateHeaderWarning.setSelection(!dlg.getToggleState()); } else { return; } } if (!mHeaders.contains(file)) { mHeaders.add(file); mViewer.refresh(false); } } } }); addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); final Button removeButton = new Button(composite, SWT.PUSH); removeButton.setImage(CommonImages.DELETE_ICON); removeButton.setToolTipText(EclipseNSISPlugin.getResourceString("remove.associated.header.toolip")); //$NON-NLS-1$ removeButton.setEnabled(false); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { IStructuredSelection sel = (IStructuredSelection) mViewer.getSelection(); if (!sel.isEmpty()) { mHeaders.removeAll(sel.toList()); mViewer.refresh(false); } } }); data = new GridData(SWT.FILL, SWT.TOP, false, false); data.verticalSpan = 2; removeButton.setLayoutData(data); Composite c = new Composite(composite, SWT.NONE); data = new GridData(SWT.FILL, SWT.FILL, true, false); c.setLayoutData(data); layout = new GridLayout(2, false); layout.marginWidth = layout.marginHeight = 0; layout.horizontalSpacing = 3; c.setLayout(layout); mReassociateHeaderWarning = new Button(c, SWT.CHECK); mReassociateHeaderWarning.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); mReassociateHeaderWarning.setSelection(NSISPreferences.getInstance().getPreferenceStore() .getBoolean(INSISPreferenceConstants.WARN_REASSOCIATE_HEADER)); l = new Label(c, SWT.WRAP); l.setText(EclipseNSISPlugin.getResourceString("show.associated.header.warning.label")); //$NON-NLS-1$ l.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); mViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); removeButton.setEnabled((selection != null && !selection.isEmpty())); } }); mViewer.setInput(mHeaders); PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, INSISConstants.PLUGIN_CONTEXT_PREFIX + "nsis_assochdrproperties_context"); //$NON-NLS-1$ return composite; }