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:org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock.java
License:Open Source License
@Override protected void validateSettings(Key changedKey, String oldValue, String newValue) { if (!areSettingsEnabled()) { return;// w ww. j a v a2 s. com } if (changedKey != null) { if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) || PREF_PB_DEPRECATION.equals(changedKey) || PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey) || PREF_15_PB_INCOMPLETE_ENUM_SWITCH.equals(changedKey) || PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey) || PREF_PB_SUPPRESS_WARNINGS.equals(changedKey) || PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey)) { updateEnableStates(); } if (checkValue(PREF_ANNOTATION_NULL_ANALYSIS, ENABLED) && (PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey) || PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey))) { boolean badNullRef = lessSevere(getValue(PREF_PB_NULL_REFERENCE), getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); boolean badPotNullRef = lessSevere(getValue(PREF_PB_POTENTIAL_NULL_REFERENCE), getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); boolean ask = false; ask |= badNullRef && (PREF_PB_NULL_REFERENCE.equals(changedKey) || PREF_PB_NULL_SPECIFICATION_VIOLATION.equals(changedKey)); ask |= badPotNullRef && (PREF_PB_POTENTIAL_NULL_REFERENCE.equals(changedKey) || PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT.equals(changedKey)); ask |= (badNullRef || badPotNullRef) && PREF_ANNOTATION_NULL_ANALYSIS.equals(changedKey); if (ask) { final Combo comboBoxNullRef = getComboBox(PREF_PB_NULL_REFERENCE); final Label labelNullRef = fLabels.get(comboBoxNullRef); int highlightNullRef = getHighlight(labelNullRef); final Combo comboBoxPotNullRef = getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE); final Label labelPotNullRef = fLabels.get(comboBoxPotNullRef); int highlightPotNullRef = getHighlight(labelPotNullRef); getShell().getDisplay().asyncExec(new Runnable() { public void run() { highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, HIGHLIGHT_FOCUS); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, HIGHLIGHT_FOCUS); } }); MessageDialog messageDialog = new MessageDialog(getShell(), PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_title, null, PreferencesMessages.ProblemSeveritiesConfigurationBlock_adapt_null_pointer_access_settings_dialog_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); messageDialog.create(); Shell messageShell = messageDialog.getShell(); messageShell.setLocation(messageShell.getLocation().x, getShell().getLocation().y + 40); if (messageDialog.open() == 0) { if (badNullRef) { setValue(PREF_PB_NULL_REFERENCE, getValue(PREF_PB_NULL_SPECIFICATION_VIOLATION)); updateCombo(getComboBox(PREF_PB_NULL_REFERENCE)); } if (badPotNullRef) { setValue(PREF_PB_POTENTIAL_NULL_REFERENCE, getValue(PREF_PB_POTENTIAL_NULL_ANNOTATION_INFERENCE_CONFLICT)); updateCombo(getComboBox(PREF_PB_POTENTIAL_NULL_REFERENCE)); } } highlight(comboBoxNullRef.getParent(), labelNullRef, comboBoxNullRef, highlightNullRef); highlight(comboBoxPotNullRef.getParent(), labelPotNullRef, comboBoxPotNullRef, highlightPotNullRef); } } else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) { // merging the two options setValue(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue); } else if (INTR_DEFAULT_NULL_ANNOTATIONS.equals(changedKey)) { if (ENABLED.equals(newValue)) { setValue(PREF_NULLABLE_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[0]); setValue(PREF_NONNULL_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[1]); setValue(PREF_NONNULL_BY_DEFAULT_ANNOTATION_NAME, NULL_ANNOTATIONS_DEFAULTS[2]); } else { openNullAnnotationsConfigurationDialog(); } } else { return; } } else { updateEnableStates(); updateNullAnnotationsSetting(); } }
From source file:org.eclipse.jdt.internal.ui.refactoring.reorg.DeleteAction.java
License:Open Source License
/** * Removes or hides the selected working sets. * //from www . j a v a 2 s . c o m * @param selection the selected working sets * @since 3.5 */ private void deleteWorkingSets(IStructuredSelection selection) { MessageDialog dialog; if (selection.size() == 1) { IWorkingSet workingSet = (IWorkingSet) selection.getFirstElement(); final String workingSetID = workingSet.getId(); String dialogMessage; if (isDefaultWorkingSet(workingSetID)) dialogMessage = MessageFormat.format(ReorgMessages.DeleteWorkingSet_hideworkingset_single, new Object[] { workingSet.getLabel() }); else dialogMessage = MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_single, new Object[] { workingSet.getLabel() }); dialog = new MessageDialog(getShell(), ReorgMessages.DeleteWorkingSet_single, null, dialogMessage, MessageDialog.QUESTION, new String[] { ReorgMessages.DeleteWorkingSet_Hide, ReorgMessages.DeleteWorkingSet_Remove, IDialogConstants.CANCEL_LABEL }, 0) { /* * @see org.eclipse.jface.dialogs.MessageDialog#createButton(org.eclipse.swt.widgets.Composite, int, java.lang.String, boolean) * @since 3.5 */ @Override protected Button createButton(Composite parent, int id, String label, boolean defaultButton) { Button button = super.createButton(parent, id, label, defaultButton); if (id == REMOVE_BUTTON && IWorkingSetIDs.OTHERS.equals(workingSetID)) button.setEnabled(false); return button; } }; } else { dialog = new MessageDialog(getShell(), ReorgMessages.DeleteWorkingSet_multiple, null, MessageFormat.format(ReorgMessages.DeleteWorkingSet_removeorhideworkingset_multiple, new Object[] { new Integer(selection.size()) }), MessageDialog.QUESTION, new String[] { ReorgMessages.DeleteWorkingSet_Hide, ReorgMessages.DeleteWorkingSet_Remove, IDialogConstants.CANCEL_LABEL }, 0); } int dialogResponse = dialog.open(); if (dialogResponse == REMOVE_BUTTON) { Iterator<?> iter = selection.iterator(); IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); while (iter.hasNext()) { IWorkingSet workingSet = (IWorkingSet) iter.next(); if (isDefaultWorkingSet(workingSet.getId())) hideWorkingSets(Collections.singletonList(workingSet)); else manager.removeWorkingSet(workingSet); } } else if (dialogResponse == HIDE_BUTTON) { hideWorkingSets((List<IWorkingSet>) SelectionUtil.toList(selection)); } }
From source file:org.eclipse.jdt.internal.ui.text.java.hover.ConfigureProblemSeverityAction.java
License:Open Source License
@Override public void run() { boolean showPropertyPage; Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); if (!hasProjectSpecificOptions()) { String message = Messages.format(JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_message, new Object[] { JavaElementLabels.getElementLabel(fProject, JavaElementLabels.ALL_DEFAULT) }); String[] buttons = new String[] { JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_button_project, JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_button_workspace, IDialogConstants.CANCEL_LABEL }; int result = OptionalMessageDialog.open(CONFIGURE_PROBLEM_SEVERITY_DIALOG_ID, shell, JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_title, null, message, MessageDialog.QUESTION, buttons, 0, JavaHoverMessages.ProblemHover_chooseSettingsTypeDialog_checkBox_dontShowAgain); if (result == OptionalMessageDialog.NOT_SHOWN) { showPropertyPage = false;/*from w ww . j av a 2 s .co m*/ } else if (result == 2 || result == SWT.DEFAULT) { return; } else if (result == 0) { showPropertyPage = true; } else { showPropertyPage = false; } } else { showPropertyPage = true; } Map<String, Object> data = new HashMap<>(); String pageId; if (fIsJavadocOption) { if (showPropertyPage) { pageId = JavadocProblemsPreferencePage.PROP_ID; data.put(JavadocProblemsPreferencePage.DATA_USE_PROJECT_SPECIFIC_OPTIONS, Boolean.TRUE); } else { pageId = JavadocProblemsPreferencePage.PREF_ID; } data.put(JavadocProblemsPreferencePage.DATA_SELECT_OPTION_KEY, fOptionId); data.put(JavadocProblemsPreferencePage.DATA_SELECT_OPTION_QUALIFIER, JavaCore.PLUGIN_ID); } else { if (showPropertyPage) { pageId = ProblemSeveritiesPreferencePage.PROP_ID; data.put(ProblemSeveritiesPreferencePage.USE_PROJECT_SPECIFIC_OPTIONS, Boolean.TRUE); } else { pageId = ProblemSeveritiesPreferencePage.PREF_ID; } data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_KEY, fOptionId); data.put(ProblemSeveritiesPreferencePage.DATA_SELECT_OPTION_QUALIFIER, JavaCore.PLUGIN_ID); } if (fInfoControl != null) { fInfoControl.dispose(); //FIXME: should have protocol to hide, rather than dispose } if (showPropertyPage) { PreferencesUtil.createPropertyDialogOn(shell, fProject, pageId, null, data).open(); } else { PreferencesUtil.createPreferenceDialogOn(shell, pageId, null, data).open(); } }
From source file:org.eclipse.jdt.ui.actions.AddGetterSetterAction.java
License:Open Source License
private int showQueryDialog(final String message, final String[] buttonLabels, int[] returnCodes) { final Shell shell = getShell(); if (shell == null) { JavaPlugin.logErrorMessage("AddGetterSetterAction.showQueryDialog: No active shell found"); //$NON-NLS-1$ return IRequestQuery.CANCEL; }/*ww w. jav a2s. c o m*/ final int[] result = { Window.CANCEL }; shell.getDisplay().syncExec(new Runnable() { public void run() { String title = ActionMessages.AddGetterSetterAction_QueryDialog_title; MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttonLabels, 0); result[0] = dialog.open(); } }); int returnVal = result[0]; return returnVal < 0 ? IRequestQuery.CANCEL : returnCodes[returnVal]; }
From source file:org.eclipse.jsch.ui.UserInfoPrompter.java
License:Open Source License
public boolean promptYesNo(String question) { int prompt = prompt(MessageDialog.QUESTION, Messages.UserInfoPrompter_0, question, new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID }, 0 // yes // the//from w w w. j a v a 2 s. com // default ); return prompt == 0; }
From source file:org.eclipse.jst.j2ee.internal.AddModulestoEARPropertiesPage.java
License:Open Source License
public boolean performOk() { NullProgressMonitor monitor = new NullProgressMonitor(); if (isVersion5) { if (libDir.length() == 0) { MessageDialog dlg = new MessageDialog(null, J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR), null, J2EEUIMessages.getResourceString(J2EEUIMessages.BLANK_LIB_DIR_WARN_QUESTION), MessageDialog.QUESTION, new String[] { J2EEUIMessages.YES_BUTTON, J2EEUIMessages.NO_BUTTON, J2EEUIMessages.CANCEL_BUTTON }, 1);//from www . j a v a 2 s . co m switch (dlg.open()) { case 0: break; case 1: { handleChangeLibDirButton(false); return false; } case 2: return false; default: return false; } } updateLibDir(monitor); } removeModulesFromEAR(monitor); addModulesToEAR(monitor); refresh(); return true; }
From source file:org.eclipse.jubula.client.api.ui.handlers.ExportObjectMappingHandler.java
License:Open Source License
/** * Opens a question dialogue to determine the desired export type * @return the export type//from w ww. j a v a2 s .c om * <code>0</code> for a Java Class File * <code>1</code> for a Properties File */ private int determineExportType() { String dialogTitle = Messages.ExportObjectMappingDialogTitle; String dialogMessage = Messages.ExportObjectMappingDialogMessage; MessageDialog dialog = new MessageDialog(getActiveShell(), dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { Messages.ExportObjectMappingDialogChoiceJavaClass, Messages.ExportObjectMappingDialogChoicePropertiesFile }, 0); return dialog.open(); }
From source file:org.eclipse.jubula.client.ui.rcp.controllers.dnd.DropFileOperation.java
License:Open Source License
/** * Asks the user to confirm the import operation * @param files the list of file URLs/*from w ww. j a v a 2s. com*/ * @return whether the operation can proceed */ private static boolean canProceed(List<URL> files) { StringBuilder builder = new StringBuilder(); builder.append(Messages.ConfirmImportDialogText); File f; URI uri; for (URL url : files) { builder.append(StringConstants.SPACE); builder.append(StringConstants.SPACE); try { uri = url.toURI(); builder.append(Paths.get(uri).getFileName().toString()); f = new File(uri); builder.append(StringConstants.SPACE); builder.append(StringConstants.LEFT_PARENTHESES); builder.append(f.length()); builder.append(StringConstants.SPACE); builder.append(Messages.Bytes); builder.append(StringConstants.RIGHT_PARENTHESES); builder.append(StringConstants.NEWLINE); } catch (URISyntaxException e) { // nothing, we just don't list this 'file's } } MessageDialog dialog = new MessageDialog(null, Messages.ConfirmImportDialogTitle, null, builder.toString(), MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }
From source file:org.eclipse.jubula.client.ui.rcp.controllers.dnd.objectmapping.OMEditorDndSupport.java
License:Open Source License
/** * Checks whether mapping the CNs to the Technical Name creates any problems * if yes, the user is notified and can cancel the action * @param compNamesToMove The Component Names to assign. * @param target The association to which the Component Names will be * assigned.//w w w. j a va 2s. c o m * @param editor Editor in which the assignment is taking place. * @return whether the operation is cancelled by the user */ private static boolean checkProblemsAndStop(List<IComponentNamePO> compNamesToMove, IObjectMappingAssoziationPO target, ObjectMappingMultiPageEditor editor) { List<IComponentNamePO> problems = new ArrayList<>(); List<Component> availableComponents = ComponentBuilder.getInstance().getCompSystem() .getComponents(editor.getAut().getToolkit(), true); String type = null; if (target.getTechnicalName() != null) { type = CompSystem.getComponentType(target.getTechnicalName().getSupportedClassName(), availableComponents); } IComponentNamePO masterCN; for (IComponentNamePO cN : compNamesToMove) { masterCN = CompNameManager.getInstance().getResCompNamePOByGuid(cN.getGuid()); if (masterCN == null) { continue; } if (!masterCN.getUsageType().equals(ComponentNamesBP.UNKNOWN_COMPONENT_TYPE) && !CompNameTypeManager.doesFirstTypeRealizeSecond(type, masterCN.getUsageType())) { problems.add(masterCN); } } if (problems.isEmpty()) { return false; } StringBuilder list = new StringBuilder(); for (IComponentNamePO cN : problems) { list.append(StringConstants.SPACE); list.append(StringConstants.SPACE); list.append(StringConstants.SPACE); list.append(cN.getName()); list.append(StringConstants.SPACE); list.append(StringConstants.LEFT_BRACKET); list.append(CompSystemI18n.getString(cN.getUsageType())); list.append(StringConstants.RIGHT_BRACKET); list.append(StringConstants.NEWLINE); } String message = NLS.bind(Messages.IncompatibleMapDialogText, list.toString()); MessageDialog dialog = new MessageDialog(null, Messages.IncompatibleMapDialogTitle, null, message, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() != 0; }
From source file:org.eclipse.jubula.client.ui.rcp.dialogs.CNTypeProblemDialog.java
License:Open Source License
/** * Presents the user with the Dialog and returns their decision * @param problems the CN Type problems// www.j ava 2 s . c om * @return whether continue with the problem-causing action */ public boolean canCommence(Map<String, ProblemType> problems) { List<String> info; StringBuilder msg = new StringBuilder(); int num = 0; for (String guid : problems.keySet()) { info = m_calc.getProblemInfo(guid); IComponentNamePO cN = m_cache.getResCompNamePOByGuid(guid); if (cN == null) { continue; } msg.append(cN.getName()); msg.append(StringConstants.COLON); msg.append(StringConstants.SPACE); if (problems.get(guid).equals(ProblemType.REASON_INCOMPATIBLE_MAP_TYPE)) { msg.append(StringConstants.NEWLINE); msg.append("Mapped to: "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(0)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.COMMA); msg.append(StringConstants.SPACE); msg.append("used as: "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(1)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.NEWLINE); } else { msg.append(StringConstants.NEWLINE); for (int i = 0; i < 6; i++) { msg.append(StringConstants.SPACE); } msg.append("Used as "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(0)); msg.append(StringConstants.QUOTE); msg.append(" and "); //$NON-NLS-1$ msg.append(StringConstants.QUOTE); msg.append(info.get(1)); msg.append(StringConstants.QUOTE); msg.append(StringConstants.NEWLINE); } num++; if (num > 10) { msg.append(StringConstants.DOT); msg.append(StringConstants.DOT); msg.append(StringConstants.DOT); msg.append(StringConstants.NEWLINE); break; } } String message = NLS.bind(Messages.IncompatiblePairChangeDialogText, msg.toString()); MessageDialog dialog = new MessageDialog(null, Messages.IncompatiblePairChangeDialogTitle, null, message, MessageDialog.QUESTION, new String[] { Messages.DialogMessageButton_YES, Messages.DialogMessageButton_NO }, 0); dialog.create(); DialogUtils.setWidgetNameForModalDialog(dialog); dialog.open(); return dialog.getReturnCode() == 0; }