List of usage examples for org.eclipse.jface.dialogs MessageDialog WARNING
int WARNING
To view the source code for org.eclipse.jface.dialogs MessageDialog WARNING.
Click Source Link
From source file:org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage.java
License:Open Source License
@Override public boolean performOk() { if (this.fpjwc == null) { return true; }/*w ww. j ava 2 s . c om*/ for (IProjectFacetVersion fv : this.fpjwc.getFacetedProject().getProjectFacets()) { if (fv.getPluginId() == null || fv.getProjectFacet().getPluginId() == null) { final MessageDialog dialog = new MessageDialog(getShell(), Resources.warningDialogTitle, null, Resources.modifyWithUnknownWarningMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); if (dialog.open() != Window.OK) { return false; } } } final IWorkspaceRunnable wr = new IWorkspaceRunnable() { public void run(final IProgressMonitor monitor) throws CoreException { FacetsPropertyPage.this.fpjwc.commitChanges(monitor); } }; final IRunnableWithProgress op = new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { final IWorkspace ws = ResourcesPlugin.getWorkspace(); ws.run(wr, ws.getRoot(), IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { new ProgressMonitorDialog(getShell()).run(true, false, op); } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { final Throwable te = e.getTargetException(); if (te instanceof CoreException) { IStatus st = ((CoreException) te).getStatus(); final String msg = st.getMessage(); if (!(te instanceof FacetedProjectFrameworkException) || !((FacetedProjectFrameworkException) te).isExpected()) { FacetUiPlugin.log(st); } final Throwable cause = st.getException(); if (cause instanceof CoreException) { st = ((CoreException) cause).getStatus(); } ErrorDialog.openError(getShell(), Resources.errDlgTitle, msg, st); } else { throw new RuntimeException(te); } } finally { // Take care of the case where all changes could not be applied, such as if the user // rejects a validateEdit request. try { this.fpjwc.revertChanges(); } catch (Exception e) { FacetUiPlugin.log(e); } } return true; }
From source file:org.eclipse.wst.jsdt.internal.ui.text.java.ContentAssistProcessor.java
License:Open Source License
/** * Informs the user about the fact that there are no enabled categories in the default content * assist set and shows a link to the preferences. * /* w w w . j ava 2s. co m*/ * */ private boolean informUserAboutEmptyDefaultCategory() { if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) { final Shell shell = JavaScriptPlugin.getActiveWorkbenchShell(); String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title; String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message; // see PreferencePage#createControl for the 'defaults' label final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$ final String linkMessage = Messages.format( JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel)); final int restoreId = IDialogConstants.CLIENT_ID + 10; final int settingsId = IDialogConstants.CLIENT_ID + 11; final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) { /* * @see org.eclipse.wst.jsdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) */ protected Control createCustomArea(Composite composite) { // wrap link and checkbox in one composite without space Composite parent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; parent.setLayout(layout); Composite linkComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); linkComposite.setLayout(layout); Link link = new Link(linkComposite, SWT.NONE); link.setText(linkMessage); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setReturnCode(settingsId); close(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); // create checkbox and "don't show this message" prompt super.createCustomArea(parent); return parent; } /* * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { Button[] buttons = new Button[2]; buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false); buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); setButtons(buttons); } }; int returnValue = dialog.open(); if (restoreId == returnValue || settingsId == returnValue) { if (restoreId == returnValue) { IPreferenceStore store = JavaScriptPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); } if (settingsId == returnValue) PreferencesUtil .createPreferenceDialogOn(shell, "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault(); registry.reload(); return true; } } return false; }
From source file:org.eclipse.wst.jsdt.ui.actions.FormatAllAction.java
License:Open Source License
public void run(IStructuredSelection selection) { IJavaScriptUnit[] cus = getCompilationUnits(selection); if (cus.length == 0) { MessageDialog.openInformation(getShell(), ActionMessages.FormatAllAction_EmptySelection_title, ActionMessages.FormatAllAction_EmptySelection_description); return;//from ww w . j av a 2 s.c om } try { if (cus.length == 1) { JavaScriptUI.openInEditor(cus[0]); } else { int returnCode = OptionalMessageDialog.open("FormatAll", //$NON-NLS-1$ getShell(), ActionMessages.FormatAllAction_noundo_title, null, ActionMessages.FormatAllAction_noundo_message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); if (returnCode != OptionalMessageDialog.NOT_SHOWN && returnCode != Window.OK) return; } } catch (CoreException e) { ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); } runOnMultiple(cus); }
From source file:org.eclipse.wst.jsdt.ui.actions.SortMembersAction.java
License:Open Source License
private void run(Shell shell, IJavaScriptUnit cu, IEditorPart editor, boolean isNotSortFields) { if (containsRelevantMarkers(editor)) { int returnCode = OptionalMessageDialog.open(ID_OPTIONAL_DIALOG, getShell(), getDialogTitle(), null, ActionMessages.SortMembersAction_containsmarkers, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); if (returnCode != OptionalMessageDialog.NOT_SHOWN && returnCode != Window.OK) return; }//w w w . j ava2s .c o m SortMembersOperation op = new SortMembersOperation(cu, null, isNotSortFields); try { BusyIndicatorRunnableContext context = new BusyIndicatorRunnableContext(); PlatformUI.getWorkbench().getProgressService().runInUI(context, new WorkbenchRunnableAdapter(op, op.getScheduleRule()), op.getScheduleRule()); } catch (InvocationTargetException e) { ExceptionHandler.handle(e, shell, getDialogTitle(), null); } catch (InterruptedException e) { // Do nothing. Operation has been canceled by user. } }
From source file:org.eclipse.wst.server.ui.internal.actions.BreakpointDialog.java
License:Open Source License
public BreakpointDialog(Shell parentShell) { super(parentShell, Messages.wizDebugOnServerTitle, null, Messages.dialogBreakpoints, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL }, 0);//w w w .jav a 2 s. com }
From source file:org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.java
License:Open Source License
/** * <p>Informs the user about the fact that there are no enabled categories in the default content * assist set and shows a link to the preferences.</p> * * @return <code>true</code> if the default should be restored *//*from w ww.j a va2s . c o m*/ private boolean informUserAboutEmptyDefaultCategory() { /*If warn about empty default category and there are associated properties for this * processors content type and those properties have an associated properties page then * display warning message to user. */ ICompletionProposalCategoriesConfigurationReader properties = CompletionProposoalCatigoriesConfigurationRegistry .getDefault().getReadableConfiguration(this.fContentTypeID); if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY) && properties instanceof ICompletionProposalCategoriesConfigurationWriter && ((ICompletionProposalCategoriesConfigurationWriter) properties).hasAssociatedPropertiesPage()) { ICompletionProposalCategoriesConfigurationWriter propertiesExtension = (ICompletionProposalCategoriesConfigurationWriter) properties; final Shell shell = SSEUIPlugin.getActiveWorkbenchShell(); String title = SSEUIMessages.ContentAssist_all_disabled_title; String message = SSEUIMessages.ContentAssist_all_disabled_message; // see PreferencePage#createControl for the 'defaults' label final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$ final String linkMessage = NLS.bind(SSEUIMessages.ContentAssist_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel)); final int restoreId = IDialogConstants.CLIENT_ID + 10; final int settingsId = IDialogConstants.CLIENT_ID + 11; final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) { /* * @see org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) */ protected Control createCustomArea(Composite composite) { // wrap link and checkbox in one composite without space Composite parent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.verticalSpacing = 0; parent.setLayout(layout); Composite linkComposite = new Composite(parent, SWT.NONE); layout = new GridLayout(); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); linkComposite.setLayout(layout); Link link = new Link(linkComposite, SWT.NONE); link.setText(linkMessage); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setReturnCode(settingsId); close(); } }); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = this.getMinimumMessageWidth(); link.setLayoutData(gridData); // create checkbox and "don't show this message" prompt super.createCustomArea(parent); return parent; } /* * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite) */ protected void createButtonsForButtonBar(Composite parent) { Button[] buttons = new Button[2]; buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false); buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); setButtons(buttons); } }; int returnValue = dialog.open(); //based on user actions either reset defaults or open preference dialog if (restoreId == returnValue || settingsId == returnValue) { if (restoreId == returnValue) { propertiesExtension.loadDefaults(); propertiesExtension.saveConfiguration(); } if (settingsId == returnValue) { PreferencesUtil .createPreferenceDialogOn(shell, propertiesExtension.getPropertiesPageID(), null, null) .open(); } return true; } } return false; }
From source file:org.eclipse.wst.xquery.set.internal.ui.handlers.SETCoreSDKCommandHandler.java
License:Open Source License
protected IJobChangeListener createWarningListener(final IProject project) { JobChangeAdapter successListener = new JobChangeAdapter() { @Override/*w w w . j a v a2s . co m*/ public void done(IJobChangeEvent event) { final IStatus result = event.getResult(); if (result.getSeverity() == IStatus.WARNING) { Display.getDefault().syncExec(new Runnable() { public void run() { StringBuilder message = new StringBuilder(); message.append(getWarningMessage(project)); // SETCoreSDKCommandJob sends warnings only when the message is non-empty message.append("\n\n"); message.append(result.getMessage()); MessageDialog md = new MessageDialog(Display.getDefault().getActiveShell(), getProjectActionLabel(project), null, message.toString(), MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL }, 0); md.open(); } }); } } }; return successListener; }
From source file:org.eclipse.wst.xsl.jaxp.launching.internal.JAXPJavaLaunchConfigurationDelegate.java
License:Open Source License
@Override public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { this.launchHelper = new LaunchHelper(configuration); if (mode.equals(ILaunchManager.DEBUG_MODE)) { // TODO don't like having UI code in the launching plugin...where // else can it go? final IProcessorInstall install = getProcessorInstall(configuration, ILaunchManager.RUN_MODE); if (install.getDebugger() == null) { final boolean[] result = new boolean[] { false }; // open a dialog for choosing a different install that does have // an associated debugger PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { String debuggingInstallId = JAXPLaunchingPlugin.getDefault().getPluginPreferences() .getString(JAXPLaunchConfigurationConstants.ATTR_DEFAULT_DEBUGGING_INSTALL_ID); IProcessorInstall processor = JAXPRuntime.getProcessor(debuggingInstallId); IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); String title = Messages.XSLTLaunchConfigurationDelegate_0; String message = Messages.XSLTLaunchConfigurationDelegate_1 + install.getName() + Messages.XSLTLaunchConfigurationDelegate_2 + Messages.XSLTLaunchConfigurationDelegate_3 + processor.getName() + Messages.XSLTLaunchConfigurationDelegate_4; MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); // yes // is // the // default result[0] = dialog.open() == 0; }/*from ww w .j a v a 2 s.co m*/ }); return result[0]; } else { String debuggerTF = install.getDebugger().getTransformerFactory(); String installTF = launchHelper.getTransformerFactory() == null ? null : launchHelper.getTransformerFactory().getFactoryClass(); if (!debuggerTF.equals(installTF)) { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); String title = Messages.JAXPJavaLaunchConfigurationDelegate_0; String message = install.getName() + Messages.JAXPJavaLaunchConfigurationDelegate_1 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_2 + Messages.JAXPJavaLaunchConfigurationDelegate_3 + launchHelper.getTransformerFactory().getName() + Messages.JAXPJavaLaunchConfigurationDelegate_4; MessageDialog dialog = new MessageDialog(dw.getShell(), title, null, message, MessageDialog.WARNING, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); // yes is the default dialog.open(); } }); } } } return super.preLaunchCheck(configuration, mode, monitor); }
From source file:org.fastcode.util.SourceUtil.java
License:Open Source License
/** * @param msg//from w ww .ja va2 s.c o m * @return */ public static int openMessageDilalog(final String msg, final String button1Name, final String button2Name) { final MessageDialog dialog = new MessageDialog(new Shell(), "Warning", null, msg, MessageDialog.WARNING, new String[] { button1Name, button2Name }, 0) { @Override protected void buttonPressed(final int buttonId) { setReturnCode(buttonId); close(); } }; dialog.open(); return dialog.getReturnCode(); }
From source file:org.grails.ide.eclipse.ui.internal.wizard.ANewGrailsProjectWizard.java
License:Open Source License
@Override public void addPages() { if (isSubclipse()) { MessageDialog.open(MessageDialog.WARNING, getShell(), "Warning! Your chosen method of checkout is unreliable!", "You asked Subclipse to configure a project using the New Grails Project Wizard.\n" + "This method is unlreliable because it requires the wizard to generate a project " + "configuration before its contents is checked out.\n" + "\n" + "The resulting project will likely be configured incorrectly.\n" + "\n" + "Please consider using 'Check out as project in the workspace instead'.\n" + "STS will detect a new Grails project after it has been checked out\n" + "and offer to configure it for you.", SWT.NONE);//from ww w.j av a 2 s . co m } projectPage = new NewGrailsProjectWizardPageOne(getPageTitle(), getPageDescription(), isPluginWizard()); addPage(projectPage); }