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:de.tub.tfs.muvitor.actions.DNPTBAction.java
License:Open Source License
@Override public void run() { // MessageBox dialog = new MessageBox(new Shell(), SWT.ICON_WARNING); // dialog.setText("You pushed the button!"); // dialog.setMessage("Please don't push the button again!"); final MessageDialog dialog = new MessageDialog(Display.getDefault().getActiveShell(), "You pushed the button!", null, "Please don't push the button again!", MessageDialog.WARNING, new String[] { "I promise..." }, 0); dialog.open();/* www .j av a 2 s. c o m*/ }
From source file:de.walware.ecommons.debug.ui.UnterminatedLaunchAlerter.java
License:Open Source License
@Override public boolean preShutdown(final IWorkbench workbench, final boolean forced) { final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); final List<ILaunchConfigurationType> programTypes = new LinkedList<ILaunchConfigurationType>(); synchronized (gMutex) { for (final String id : fLauchTypeIds) { final ILaunchConfigurationType programType = manager.getLaunchConfigurationType(id); if (programType != null) { programTypes.add(programType); }/*from www . j a va 2 s.c o m*/ } } if (programTypes.isEmpty()) { return true; } final Set<ILaunchConfigurationType> stillRunningTypes = new HashSet<ILaunchConfigurationType>(); int count = 0; final ILaunch launches[] = manager.getLaunches(); for (final ILaunch launch : launches) { ILaunchConfigurationType configType; ILaunchConfiguration config; try { config = launch.getLaunchConfiguration(); if (config == null) { continue; } configType = config.getType(); } catch (final CoreException e) { continue; } if (programTypes.contains(configType) && !launch.isTerminated()) { count++; stillRunningTypes.add(configType); } } if (stillRunningTypes.isEmpty()) { return true; } final StringBuilder names = new StringBuilder(stillRunningTypes.size() * 20); names.append('\n'); for (final ILaunchConfigurationType type : stillRunningTypes) { names.append("- "); //$NON-NLS-1$ names.append(type.getName()); names.append('\n'); } final String message = NLS.bind(Messages.UnterminatedLaunchAlerter_WorkbenchClosing_message, new Object[] { count, names }); if (forced) { MessageDialog.openWarning(UIAccess.getDisplay().getActiveShell(), Messages.UnterminatedLaunchAlerter_WorkbenchClosing_title, message); return true; } else { final MessageDialog dialog = new MessageDialog(UIAccess.getDisplay().getActiveShell(), Messages.UnterminatedLaunchAlerter_WorkbenchClosing_title, null, message, MessageDialog.WARNING, new String[] { Messages.UnterminatedLaunchAlerter_WorkbenchClosing_button_Continue, Messages.UnterminatedLaunchAlerter_WorkbenchClosing_button_Cancel, }, 1); final int answer = dialog.open(); if (answer == 1) { return false; } return true; } }
From source file:descent.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. * //ww w. jav a 2s .c om * @since 3.3 */ private boolean informUserAboutEmptyDefaultCategory() { if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) { final Shell shell = JavaPlugin.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 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 descent.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) { close(); PreferencesUtil .createPreferenceDialogOn(shell, "descent.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$ .open(); } }); 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); } }; if (restoreId == dialog.open()) { IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore(); store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault(); registry.reload(); return true; } } return false; }
From source file:descent.ui.actions.FormatAllAction.java
License:Open Source License
public void run(IStructuredSelection selection) { ICompilationUnit[] cus = getCompilationUnits(selection); if (cus.length == 0) { MessageDialog.openInformation(getShell(), ActionMessages.FormatAllAction_EmptySelection_title, ActionMessages.FormatAllAction_EmptySelection_description); return;/* w w w . jav a 2 s. co m*/ } if (cus.length > 1) { 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; } IStatus status = Resources.makeCommittable(getResources(cus), getShell()); if (!status.isOK()) { ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title, ActionMessages.FormatAllAction_failedvalidateedit_message, status); return; } runOnMultiple(cus); }
From source file:es.cv.gvcase.mdt.common.commands.DeleteDiagramCommand.java
License:Open Source License
public void redo() { if (getDiagramToDelete() == null) { return;//from w w w.j av a 2 s . c om } // Get upper diagram to open in case the one deleted is active. Diagram diagramToOpen = MultiDiagramUtil.getUpperDiagram(getDiagramToDelete()); if (diagramToOpen == null || diagramToOpen.equals(getDiagramToDelete())) { // This is the uppest diagram we'll look for a diagram at the same // level diagramToOpen = MultiDiagramUtil.getOtherDiagram(getDiagramToDelete()); if (diagramToOpen == null) { // no suitable diagram to open return; } } // The diagram is Ok to be deleted. Ask user confirmation. MessageDialog confirmDialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Delete diagram?", null, "Are you sure you want to delete the selected diagram?", MessageDialog.WARNING, new String[] { "Yes", "No" }, 1); int result = confirmDialog.open(); if (result == Window.CANCEL) { return; } // modify the parent diagram of the diagrams that has this deleted // diagram as parent boolean hasParent = getDiagramToDelete().getEAnnotation(MultiDiagramUtil.UpperDiagram) == null ? false : true; for (Resource r : diagramToOpen.eResource().getResourceSet().getResources()) { if (r instanceof GMFResource) { for (EObject eo : r.getContents()) { if (eo instanceof Diagram) { Diagram son = (Diagram) eo; EAnnotation eAnnotation = son.getEAnnotation(MultiDiagramUtil.UpperDiagram); if (eAnnotation != null && eAnnotation.getReferences().size() > 0 && (eAnnotation.getReferences().get(0) instanceof Diagram)) { Diagram parent = (Diagram) eAnnotation.getReferences().get(0); if (parent.equals(getDiagramToDelete())) { if (!hasParent) { // remove the eAnnotation son.getEAnnotations().remove(MultiDiagramUtil.UpperDiagram); if (diagramToOpen != null) diagramToOpen = son; } else { // change the parent diagram Diagram parentDiagram = (Diagram) getDiagramToDelete() .getEAnnotation(MultiDiagramUtil.UpperDiagram).getReferences().get(0); eAnnotation.getReferences().clear(); eAnnotation.getReferences().add(parentDiagram); } } } } } } } IEditorPart editorPart = MDTUtil.getActiveEditor(); if (!isDiagramActive()) { // If the diagram to delete is not active it can be deleted without // problems. MultiDiagramUtil.deleteDiagramAndSave(getDiagramToDelete(), !(editorPart instanceof MOSKittMultiPageEditor)); } else { // If the diagram to delete is active, a complex process must be // followed to delete it. // Close all diagram editors that have the diagram to be deleted // active. // EditingDomainRegistry.getInstance().setChangingCachedEditors(true); MultiDiagramUtil.closeEditorsThatShowDiagram(getDiagramToDelete()); // Delete diagram MultiDiagramUtil.deleteDiagramAndSave(getDiagramToDelete(), !(editorPart instanceof MOSKittMultiPageEditor)); // Open its upper diagram try { MultiDiagramUtil.openDiagram(diagramToOpen); } catch (ExecutionException ex) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Can't open diagram"); Activator.getDefault().getLog().log(status); } finally { // EditingDomainRegistry.getInstance().setChangingCachedEditors( // false); return; } } }
From source file:es.cv.gvcase.mdt.common.util.MultiDiagramUtil.java
License:Open Source License
/** * Perform delete {@link Diagram}./*from www . ja v a 2 s . c o m*/ * * @param diagram * the diagram * @param confirm * the confirm * * @return the diagram */ public static Diagram performDeleteDiagram(Diagram diagram, boolean confirm) { if (diagram == null) { return null; } // Get upper diagram to open in case the one deleted is active. Diagram diagramToOpen = getUpperDiagram(diagram); if (diagramToOpen == null || diagramToOpen.equals(diagram)) { // This is the uppest diagram we'll look for a diagram at the same // level diagramToOpen = getOtherDiagram(diagram); if (diagramToOpen == null) { // no suitable diagram to open return null; } } // The diagram is Ok to be deleted. Ask user confirmation. if (confirm) { MessageDialog confirmDialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Delete diagram?", null, "Are oyu sure you want to delete the selected diagram?", MessageDialog.WARNING, new String[] { "Yes", "No" }, 1); int result = confirmDialog.open(); if (result == Window.CANCEL) { return null; } } if (!isDiagramActive(diagram)) { // If the diagram to delete is not active it can be deleted without // problems. deleteDiagramAndSave(diagram); } else { // If the diagram to delete is active, a complex process must be // folowed to delete it. // Close all diagram editors that have the diagram to be deleted // active. // EditingDomainRegistry.getInstance().setChangingCachedEditors(true); closeEditorsThatShowDiagram(diagram); // Delete diagram deleteDiagramAndSave(diagram); // Open its upper diagram try { openDiagram(diagramToOpen); } catch (ExecutionException ex) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Can't open diagram"); Activator.getDefault().getLog().log(status); return null; } finally { // EditingDomainRegistry.getInstance().setChangingCachedEditors( // false); } } return diagramToOpen; }
From source file:eu.aniketos.securebpmn.util.DialogUtil.java
License:Apache License
/** * Opens a dialog window that contains an image and a message. * * @param title/*from www.ja v a2 s . c o m*/ * The title of the message window. * @param message * The message to be displayed in the window. * @param image * The image that should be displayed in the window. * @param buttons * The labels of the Buttons the window should contain. * @param defaultButton * The index of the Button that should be selected by default. * @return The index of the Button that was pressed. */ public static int openMessageDialog(String title, String message, int image, String[] buttons, int defaultButton) { MessageDialog dialog; switch (image) { case INFO: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.INFORMATION, buttons, defaultButton); break; case WARNING: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.WARNING, buttons, defaultButton); break; case ERROR: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.ERROR, buttons, defaultButton); break; default: dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.NONE, buttons, defaultButton); break; } return dialog.open(); }
From source file:eu.geclipse.ui.internal.actions.DeleteGridElementAction.java
License:Open Source License
private void deleteWorkflowJobDescriptions(final List<IGridJobDescription> selectedJobDescriptions) { MessageDialog dialog = null;/*from w w w . ja va2s . co m*/ String dialogMessage = ""; //$NON-NLS-1$ if (selectedJobDescriptions.size() == 1) { IGridJobDescription selectedJobDesc = selectedJobDescriptions.get(0); String jsdl = selectedJobDesc.getResource().getName(); dialogMessage = String.format(Messages.getString("DeleteGridElementAction.confirmJobDescDeleteOne"), //$NON-NLS-1$ jsdl); } else { String jsdlList = ""; //$NON-NLS-1$ for (Iterator<IGridJobDescription> i = selectedJobDescriptions.iterator(); i.hasNext();) { jsdlList = jsdlList + " " + i.next().getResource().getName(); //$NON-NLS-1$ } dialogMessage = String.format(Messages.getString("DeleteGridElementAction.confirmJobDescDeleteMany"), //$NON-NLS-1$ jsdlList); } dialog = new MessageDialog(DeleteGridElementAction.this.shell, Messages.getString("DeleteGridElementAction.confirmationTitle"), //$NON-NLS-1$ null, dialogMessage, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (dialog.open() == Window.OK) { try { for (Iterator<IGridJobDescription> i1 = selectedJobDescriptions.iterator(); i1.hasNext();) { IResource r = i1.next().getResource(); r.delete(true, new NullProgressMonitor()); // TODO add a proper progress monitor to use } } catch (CoreException e) { // TODO Auto-generated catch block, add proper problem reporting e.printStackTrace(); } } }
From source file:eu.geclipse.ui.internal.actions.DeleteGridElementAction.java
License:Open Source License
private ConfirmChoice confirmDeleteJobs(final List<IGridJob> selectedJobs) { ConfirmChoice choice = ConfirmChoice.cancel; String question = null, warning = null; if (selectedJobs.size() == 1) { IGridJob job = selectedJobs.iterator().next(); question = String.format(Messages.getString("DeleteGridElementAction.confirmationOne"), //$NON-NLS-1$ job.getJobName());//from w ww . j ava 2 s.co m if (job.getJobStatus().canChange()) { warning = String.format(Messages.getString("DeleteGridElementAction.warningOne"), job.getJobName()); //$NON-NLS-1$ } } else { question = String.format(Messages.getString("DeleteGridElementAction.confirmationMany"), //$NON-NLS-1$ Integer.valueOf(selectedJobs.size())); for (IGridJob job : selectedJobs) { if (job.getJobStatus().canChange()) { warning = Messages.getString("DeleteGridElementAction.warningMany"); //$NON-NLS-1$ break; } } } String msg = question; if (warning != null) { msg += "\n\n" + warning; //$NON-NLS-1$ } ConfirmDeleteJobsDialog dialog = new ConfirmDeleteJobsDialog(msg, warning == null ? MessageDialog.QUESTION : MessageDialog.WARNING); if (dialog.open() == 0) { if (dialog.isDeleteFromGrid()) { choice = ConfirmChoice.deleteFromGrid; } else { choice = ConfirmChoice.deleteOnlyFromWorkspace; } } return choice; }
From source file:eu.geclipse.workflow.ui.edit.policies.WorkflowJobDragDropEditPolicy.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// ww w .j a v a 2 s . co m public Command getDropObjectsCommand(DropObjectsRequest dropRequest) { List objects = dropRequest.getObjects(); CompoundCommand cmd = new CompoundCommand(); JSDLJobDescription jsdl = null; for (Object o : objects) { if (o instanceof JSDLJobDescription) { jsdl = (JSDLJobDescription) o; this.selectedElement = (WorkflowJobEditPart) getHost(); IWorkflowJob selectedJob = (IWorkflowJob) this.selectedElement.resolveSemanticElement(); CopyJobDescToWorkflowCommand copyCmd = new CopyJobDescToWorkflowCommand( this.selectedElement.resolveSemanticElement(), jsdl); UpdateJobPortsCommand updatePortsCmd = new UpdateJobPortsCommand(this.selectedElement, jsdl); if (!(selectedJob.getName() == null && selectedJob.getJobDescription() == null)) { MessageDialog confirmDialog = new MessageDialog(null, Messages.getString("WorkflowJobDragDropEditPolicy_confirmationTitle"), //$NON-NLS-1$ null, Messages.getString("WorkflowJobDragDropEditPolicy_userPrompt"), //$NON-NLS-1$ true ? MessageDialog.QUESTION : MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); int result = confirmDialog.open(); if (result == 0) { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } else { cmd.add(new ICommandProxy(copyCmd)); cmd.add(new ICommandProxy(updatePortsCmd)); } } return cmd; } return super.getDropObjectsCommand(dropRequest); }