List of usage examples for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL
String CANCEL_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants CANCEL_LABEL.
Click Source Link
From source file:de.walware.ecommons.ui.dialogs.ExtStatusDialog.java
License:Open Source License
private Composite createMonitorComposite(final Composite parent) { fProgressComposite = new Composite(parent, SWT.NULL); final GridLayout layout = LayoutUtil.createCompositeGrid(2); layout.marginLeft = LayoutUtil.defaultHMargin(); fProgressComposite.setLayout(layout); fProgressMonitorPart = new ProgressMonitorPart(fProgressComposite, null); fProgressMonitorPart.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); fProgressMonitorCancelButton = createButton(fProgressComposite, 1000, IDialogConstants.CANCEL_LABEL, true); Dialog.applyDialogFont(fProgressComposite); fProgressComposite.setVisible(false); return fProgressComposite; }
From source file:de.walware.ecommons.ui.dialogs.ToolPopup.java
License:Open Source License
private void create(final Shell parent) { if (UIAccess.isOkToUse(fShell)) { if (fShell.getParent() == parent) { return; }// w w w .j ava 2s.c o m dispose(); } fToolTabs.clear(); fShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); // SWT.RESIZE fShell.setText("Color"); fShell.setFont(JFaceResources.getDialogFont()); fShell.setSize(320, 300); { final GridLayout gl = new GridLayout(); gl.marginHeight = 0; gl.marginWidth = 0; gl.horizontalSpacing = 0; gl.verticalSpacing = 0; fShell.setLayout(gl); } final SWTListener listener = new SWTListener(); parent.addListener(SWT.Dispose, listener); fShell.addListener(SWT.Deactivate, listener); fShell.setBackground(fShell.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); fShell.setBackgroundMode(SWT.INHERIT_FORCE); fTabFolder = new CTabFolder(fShell, SWT.BOTTOM | SWT.FLAT); fTabFolder.setSimple(true); fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); fTabFolder.setSelectionBackground(G_BACKGROUND); addTabs(fTabFolder); final Composite commonBar = new Composite(fShell, SWT.NONE); commonBar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); commonBar.setLayout(LayoutUtil.createContentGrid(3)); // final Composite status = new Composite(commonBar, SWT.NONE); // status.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); addStatusControls(commonBar); fOKButton = new Button(commonBar, SWT.PUSH | SWT.FLAT); fOKButton.setText(IDialogConstants.OK_LABEL); fOKButton.setFont(fShell.getFont()); fOKButton.addListener(SWT.Selection, listener); fCancelButton = new Button(commonBar, SWT.PUSH | SWT.FLAT); fCancelButton.setText(IDialogConstants.CANCEL_LABEL); fCancelButton.setFont(fShell.getFont()); fCancelButton.addListener(SWT.Selection, listener); { final Point size = fOKButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); size.x = Math.max(size.x, fCancelButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); { final GridData gd = new GridData(SWT.FILL, SWT.FILL); gd.widthHint = size.x; gd.heightHint = size.y - 2; fOKButton.setLayoutData(gd); } { final GridData gd = new GridData(SWT.FILL, SWT.FILL); gd.widthHint = size.x; gd.heightHint = size.y - 2; fCancelButton.setLayoutData(gd); } } fTabFolder.addListener(SWT.Selection, listener); fShell.setDefaultButton(fOKButton); fShell.pack(); }
From source file:de.walware.statet.nico.ui.util.ToolMessageDialog.java
License:Open Source License
public static boolean openConfirm(final ToolProcess tool, final Shell parent, final String title, final String message) { final ToolMessageDialog dialog = new ToolMessageDialog(tool, parent, title, null, message, QUESTION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); return (dialog.open() == 0); }
From source file:descent.internal.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List /* <Key>*/ changedOptions = new ArrayList(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }/*from ww w. ja v a2s .c o m*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } if (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build incrementRebuildCount(); container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { JavaPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:descent.internal.ui.wizards.buildpaths.BuildPathsBlock.java
License:Open Source License
public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) { return new IRemoveOldBinariesQuery() { public boolean doQuery(final IPath oldOutputLocation) throws OperationCanceledException { final int[] res = new int[] { 1 }; Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh = shell != null ? shell : JavaPlugin.getActiveWorkbenchShell(); String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, oldOutputLocation.toString()); MessageDialog dialog = new MessageDialog(sh, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0);// w ww .ja v a 2 s . c o m res[0] = dialog.open(); } }); if (res[0] == 0) { return true; } else if (res[0] == 1) { return false; } throw new OperationCanceledException(); } }; }
From source file:descent.internal.ui.wizards.buildpaths.newsourcepage.AddFolderToBuildpathAction.java
License:Open Source License
/** * {@inheritDoc}/*from w w w. java2 s.c o m*/ */ public void run() { try { final IJavaProject project; Object object = fSelectedElements.get(0); if (object instanceof IJavaProject) { project = (IJavaProject) object; } else if (object instanceof IPackageFragment) { project = ((IPackageFragment) object).getJavaProject(); } else { IFolder folder = (IFolder) object; project = JavaCore.create(folder.getProject()); if (project == null) return; } final Shell shell = fSite.getShell() != null ? fSite.getShell() : JavaPlugin.getActiveWorkbenchShell(); final boolean removeProjectFromClasspath; IPath outputLocation = project.getOutputLocation(); final IPath defaultOutputLocation = outputLocation.makeRelative(); final IPath newDefaultOutputLocation; final boolean removeOldClassFiles; IPath projPath = project.getProject().getFullPath(); if (!(fSelectedElements.size() == 1 && fSelectedElements.get(0) instanceof IJavaProject) && //if only the project should be added, then the query does not need to be executed (outputLocation.equals(projPath) || defaultOutputLocation.segmentCount() == 1)) { final OutputFolderQuery outputFolderQuery = ClasspathModifierQueries.getDefaultFolderQuery(shell, defaultOutputLocation); if (outputFolderQuery.doQuery(true, ClasspathModifier.getValidator(fSelectedElements, project), project)) { newDefaultOutputLocation = outputFolderQuery.getOutputLocation(); removeProjectFromClasspath = outputFolderQuery.removeProjectFromClasspath(); if (BuildPathsBlock.hasClassfiles(project.getProject()) && outputLocation.equals(projPath)) { String title = NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_title; String message = Messages.format( NewWizardMessages.BuildPathsBlock_RemoveBinariesDialog_description, projPath.toString()); MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); int answer = dialog.open(); if (answer == 0) { removeOldClassFiles = true; } else if (answer == 1) { removeOldClassFiles = false; } else { return; } } else { removeOldClassFiles = false; } } else { return; } } else { removeProjectFromClasspath = false; removeOldClassFiles = false; newDefaultOutputLocation = defaultOutputLocation; } try { final IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { List result = addToClasspath(fSelectedElements, project, newDefaultOutputLocation.makeAbsolute(), removeProjectFromClasspath, removeOldClassFiles, monitor); selectAndReveal(new StructuredSelection(result)); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; PlatformUI.getWorkbench().getProgressService().run(true, false, runnable); } catch (final InvocationTargetException e) { if (e.getCause() instanceof CoreException) { showExceptionDialog((CoreException) e.getCause()); } else { JavaPlugin.log(e); } } catch (final InterruptedException e) { } } catch (CoreException e) { showExceptionDialog(e); } }
From source file:descent.internal.ui.wizards.buildpaths.VariableBlock.java
License:Open Source License
public boolean performOk() { ArrayList removedVariables = new ArrayList(); ArrayList changedVariables = new ArrayList(); removedVariables.addAll(Arrays.asList(JavaCore.getClasspathVariableNames())); // remove all unchanged List changedElements = fVariablesList.getElements(); for (int i = changedElements.size() - 1; i >= 0; i--) { CPVariableElement curr = (CPVariableElement) changedElements.get(i); if (curr.isReserved()) { changedElements.remove(curr); } else {/*from w ww. j a v a2 s. c o m*/ IPath path = curr.getPath(); IPath prevPath = JavaCore.getClasspathVariable(curr.getName()); if (prevPath != null && prevPath.equals(path)) { changedElements.remove(curr); } else { changedVariables.add(curr.getName()); } } removedVariables.remove(curr.getName()); } int steps = changedElements.size() + removedVariables.size(); if (steps > 0) { boolean needsBuild = false; if (fAskToBuild && doesChangeRequireFullBuild(removedVariables, changedVariables)) { String title = NewWizardMessages.VariableBlock_needsbuild_title; String message = NewWizardMessages.VariableBlock_needsbuild_message; MessageDialog buildDialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = buildDialog.open(); if (res != 0 && res != 1) { return false; } needsBuild = (res == 0); } final VariableBlockRunnable runnable = new VariableBlockRunnable(removedVariables, changedElements); final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(true, true, runnable); } catch (InvocationTargetException e) { ExceptionHandler.handle(new InvocationTargetException(new NullPointerException()), getShell(), NewWizardMessages.VariableBlock_variableSettingError_titel, NewWizardMessages.VariableBlock_variableSettingError_message); return false; } catch (InterruptedException e) { return false; } if (needsBuild) { CoreUtility.getBuildJob(null).schedule(); } } return true; }
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;/*from ww w .j a v a2 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:eclipse.spellchecker.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { IScopeContext currContext = fLookupOrder[0]; List<Key> changedOptions = new ArrayList<Key>(); boolean needsBuild = getChanges(currContext, changedOptions); if (changedOptions.isEmpty()) { return true; }/*ww w. j a va 2 s . co m*/ if (needsBuild) { int count = getRebuildCount(); if (count > fRebuildCount) { needsBuild = false; // build already requested fRebuildCount = count; } } boolean doBuild = false; if (needsBuild) { String[] strings = getFullBuildDialogStrings(fProject == null); if (strings != null) { if (ResourcesPlugin.getWorkspace().getRoot().getProjects().length == 0) { doBuild = true; // don't bother the user } else { MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { doBuild = true; } else if (res != 1) { return false; // cancel pressed } } } } if (container != null) { // no need to apply the changes to the original store: will be done by the page container if (doBuild) { // post build incrementRebuildCount(); container.registerUpdateJob(CoreUtility.getBuildJob(fProject)); } } else { // apply changes right away try { fManager.applyChanges(); } catch (BackingStoreException e) { Activator.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:edu.iastate.cs.boa.ui.dialogs.InputSelectionDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(final Composite parent) { createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); combo.setFocus();//from w w w.ja va2 s .c o m if (value != null) combo.setText(value); }