List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
From source file:org.eclipse.wst.jsdt.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; }// ww w . ja v a 2 s . c om 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) { JavaScriptPlugin.log(e); return false; } if (doBuild) { CoreUtility.getBuildJob(fProject).schedule(); } } return true; }
From source file:org.eclipse.xtext.ui.preferences.OptionsConfigurationBlock.java
License:Open Source License
protected boolean processChanges(IWorkbenchPreferenceContainer container) { boolean needsBuild = !getPreferenceChanges().isEmpty(); boolean doBuild = false; if (needsBuild) { int count = getRebuildCount(); if (count > rebuildCount) { needsBuild = false;/*from www . jav a 2 s.c o m*/ rebuildCount = count; } } if (needsBuild) { String[] strings = getFullBuildDialogStrings(project == null); if (strings != null) { MessageDialog dialog = new MessageDialog(shell, 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; } } } savePreferences(); if (container != null) { if (doBuild) { incrementRebuildCount(); container.registerUpdateJob(getBuildJob(getProject())); } } else { if (doBuild) { getBuildJob(getProject()).schedule(); } } captureOriginalSettings(keys); return true; }
From source file:org.eclipseguru.gwt.ui.properties.ProjectProperties.java
License:Open Source License
@Override public boolean performOk() { final GwtProject project = getProject(); boolean build = false; if (isRebuildNecessary) { final MessageDialog dialog = new MessageDialog(getShell(), "Build Needed", null, "The deployment settings have changed. The project needs to be rebuilt for the changes to take effect. Do you want to rebuild now?", MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);//from w w w . j a v a 2 s . c om switch (dialog.open()) { case 2: return false; case Window.OK: build = true; break; } } final IEclipsePreferences projectPreferences = project.getProjectPreferences(); if (null == projectPreferences) { return false; } // hosted mode projectPreferences.putBoolean(GwtCorePreferenceConstants.PREF_HOSTED_DEPLOY_MODE, isHosted); // output location if (project.getProjectResource().getFullPath().isPrefixOf(outputLocationPath)) { outputLocationPath = outputLocationPath.removeFirstSegments(1); } projectPreferences.put(GwtCorePreferenceConstants.PREF_OUTPUT_LOCATION, outputLocationPath.makeRelative().toString()); // module auto build final boolean autoBuildModules = autoBuildModulesDialogField.isSelected(); projectPreferences.putBoolean(GwtCorePreferenceConstants.PREF_AUTO_BUILD_MODULES, autoBuildModules); // modules list project.setIncludedModules(modulesListDialogField.getElements()); // deployment path projectPreferences.put(GwtCorePreferenceConstants.PREF_DEPLOYMENT_PATH, deploymentPath.makeAbsolute().toString()); // VM arguments final String compilerVmArgs = getCompilerVmArgs(); if ((null != compilerVmArgs) && (compilerVmArgs.trim().length() > 0)) { projectPreferences.put(GwtCorePreferenceConstants.PREF_COMPILER_VM_ARGS, compilerVmArgs); } else { projectPreferences.remove(GwtCorePreferenceConstants.PREF_COMPILER_VM_ARGS); } // style projectPreferences.put(GwtCorePreferenceConstants.PREF_COMPILER_JAVASCRIPT_STYLE, getCompilerJavascriptStyle()); // flush changes try { projectPreferences.flush(); } catch (final BackingStoreException e) { // problem with pref store - quietly ignore } // build if (build) { doFullBuild(); } return true; }
From source file:org.eclipselabs.spray.runtime.graphiti.containers.SampleUtil.java
License:Open Source License
public static boolean confirmDialog(String dialogTitle, String dialogMessage) { Shell shell = getShell();//w w w. java 2 s. c om MessageDialog dialog = new MessageDialog(shell, dialogTitle, (Image) null, dialogMessage, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { protected int getShellStyle() { return super.getShellStyle() | SWT.SHEET; } }; // ensure yes is the default return dialog.open() == 0; }
From source file:org.erlide.ui.wizards.ErlangProjectImportWizardPage.java
License:Open Source License
/** * The <code>WizardDataTransfer</code> implementation of this * <code>IOverwriteQuery</code> method asks the user whether the existing * resource at the given path should be overwritten. * /* w ww . j a va2 s .c o m*/ * @param pathString * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>, * <code>"ALL"</code>, or <code>"CANCEL"</code> */ @Override public String queryOverwrite(final String pathString) { final Path path = new Path(pathString); String messageString; // Break the message up if there is a file name and a directory // and there are at least 2 segments. if (path.getFileExtension() == null || path.segmentCount() < 2) { messageString = NLS.bind(WizardMessages.WizardDataTransfer_existsQuestion, pathString); } else { messageString = NLS.bind(WizardMessages.WizardDataTransfer_overwriteNameAndPathQuestion, path.lastSegment(), path.removeLastSegments(1).toOSString()); } final MessageDialog dialog = new MessageDialog(getContainer().getShell(), WizardMessages.Question, null, messageString, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0) { }; final String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL }; // run in syncExec because callback is from an operation, // which is probably not running in the UI thread. getControl().getDisplay().syncExec(new Runnable() { @Override public void run() { dialog.open(); } }); return dialog.getReturnCode() < 0 ? CANCEL : response[dialog.getReturnCode()]; }
From source file:org.erlide.ui.wizards.ErlangProjectImportWizardPage.java
License:Open Source License
/** * Displays a Yes/No question to the user with the specified message and * returns the user's response./* www . jav a 2 s . c o m*/ * * @param message * the question to ask * @return <code>true</code> for Yes, and <code>false</code> for No */ protected boolean queryYesNoQuestion(final String message) { final MessageDialog dialog = new MessageDialog(getContainer().getShell(), WizardMessages.Question, null, message, MessageDialog.NONE, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0) { }; // ensure yes is the default return dialog.open() == 0; }
From source file:org.hibernate.eclipse.console.AbstractQueryEditor.java
License:Open Source License
/** * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#performSaveAs(IProgressMonitor) * the same method except line: "dialog.setOriginalName(getSaveAsFileExtension());" *//* w w w . j av a 2s.com*/ protected void performSaveAs(IProgressMonitor progressMonitor) { Shell shell = getSite().getShell(); final IEditorInput input = getEditorInput(); IDocumentProvider provider = getDocumentProvider(); final IEditorInput newInput; if (input instanceof IURIEditorInput && !(input instanceof IFileEditorInput)) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); IPath oldPath = URIUtil.toPath(((IURIEditorInput) input).getURI()); if (oldPath != null) { dialog.setFileName(oldPath.lastSegment()); dialog.setFilterPath(oldPath.toOSString()); } String path = dialog.open(); if (path == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } // Check whether file exists and if so, confirm overwrite final File localFile = new File(path); if (localFile.exists()) { MessageDialog overwriteDialog = new MessageDialog(shell, HibernateConsoleMessages.AbstractQueryEditor_save_as, null, MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_already_exists_do_you_want_to_replace_it, path), MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); // 'No' is the default if (overwriteDialog.open() != Window.OK) { if (progressMonitor != null) { progressMonitor.setCanceled(true); return; } } } IFileStore fileStore; try { fileStore = EFS.getStore(localFile.toURI()); } catch (CoreException ex) { HibernateConsolePlugin.getDefault().log(ex.getStatus()); String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as; String msg = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, ex.getMessage()); MessageDialog.openError(shell, title, msg); return; } IFile file = getWorkspaceFile(fileStore); if (file != null) newInput = new FileEditorInput(file); else newInput = new FileStoreEditorInput(fileStore); } else { SaveAsDialog dialog = new SaveAsDialog(shell); IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; if (original != null) { dialog.setOriginalFile(original); } else { dialog.setOriginalName(getSaveAsFileExtension()); } dialog.create(); if (provider.isDeleted(input) && original != null) { String message = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_the_original_file_has_been_deleted_or_is_not_accessible, original.getName()); dialog.setErrorMessage(null); dialog.setMessage(message, IMessageProvider.WARNING); } if (dialog.open() == Window.CANCEL) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IPath filePath = dialog.getResult(); if (filePath == null) { if (progressMonitor != null) progressMonitor.setCanceled(true); return; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IFile file = workspace.getRoot().getFile(filePath); newInput = new FileEditorInput(file); } if (provider == null) { // editor has programmatically been closed while the dialog was open return; } boolean success = false; try { provider.aboutToChange(newInput); provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true); success = true; } catch (CoreException x) { final IStatus status = x.getStatus(); if (status == null || status.getSeverity() != IStatus.CANCEL) { String title = HibernateConsoleMessages.AbstractQueryEditor_problems_during_save_as; String msg = MessageFormat.format( HibernateConsoleMessages.AbstractQueryEditor_save_could_not_be_completed, x.getMessage()); MessageDialog.openError(shell, title, msg); } } finally { provider.changed(newInput); if (success) setInput(newInput); } if (progressMonitor != null) progressMonitor.setCanceled(!success); }
From source file:org.hibernate.eclipse.console.views.SchemaExportAction.java
License:Open Source License
/** * Convenience method to open a standard warning Yes/No dialog. * /*from ww w. j a va 2s.co m*/ * @param parent the parent shell of the dialog, or <code>null</code> if none * @param title the dialog's title, or <code>null</code> if none * @param msg the message * @return <code>true</code> if the user presses the Yes button, * <code>false</code> otherwise */ public static boolean openWarningYesNoDlg(Shell parent, String title, String msg) { String[] dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; MessageDialog dialog = new MessageDialog(parent, title, null, msg, MessageDialog.WARNING, dialogButtonLabels, 0); return dialog.open() == 0; }
From source file:org.hibernate.eclipse.mapper.editors.ReverseEngineeringEditor.java
License:Open Source License
public LazyDatabaseSchema getLazyDatabaseSchema() { try {//from w ww. j a v a 2s . c om ConsoleConfiguration configuration = KnownConfigurations.getInstance() .find(getConsoleConfigurationName()); if (configuration == null) { configuration = askForConsoleConfiguration(); if (configuration == null) { return null; } else { setConsoleConfigurationName(configuration.getName()); } } org.hibernate.eclipse.console.model.ITableFilter[] tableFilters = getReverseEngineeringDefinition() .getTableFilters(); IConfiguration cfg = configuration.buildWith(null, false); ISettings settings = configuration.getSettings(cfg); IService service = configuration.getHibernateExtension().getHibernateService(); IOverrideRepository repository = service.newOverrideRepository(); boolean hasIncludes = false; for (int i = 0; i < tableFilters.length; i++) { org.hibernate.eclipse.console.model.ITableFilter filter = tableFilters[i]; ITableFilter tf = service.newTableFilter(); tf.setExclude(filter.getExclude()); if (filter.getExclude() != null && !filter.getExclude().booleanValue()) { hasIncludes = true; } tf.setMatchCatalog(filter.getMatchCatalog()); tf.setMatchName(filter.getMatchName()); tf.setMatchSchema(filter.getMatchSchema()); repository.addTableFilter(tf); } ITableFilter tf = service.newTableFilter(); tf.setExclude(Boolean.FALSE); tf.setMatchCatalog(".*"); //$NON-NLS-1$ tf.setMatchSchema(".*"); //$NON-NLS-1$ tf.setMatchName(".*"); //$NON-NLS-1$ repository.addTableFilter(tf); String dialogId = ReverseEngineeringEditor.class.getName(); if (tableFilters.length == 0 && OptionalMessageDialog.isDialogEnabled(dialogId)) { int returnCode = OptionalMessageDialog.open(dialogId, getContainer().getShell(), MapperMessages.ReverseEngineeringEditor_no_filters_defined, null, MapperMessages.ReverseEngineeringEditor_no_filters_has_been_defined, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0); if (returnCode == Window.CANCEL) return null; } LazyDatabaseSchema lazyDatabaseSchema = new LazyDatabaseSchema(configuration, repository.getReverseEngineeringStrategy(service.newDefaultReverseEngineeringStrategy())); return lazyDatabaseSchema; } catch (Exception he) { HibernateConsolePlugin.getDefault().showError(getContainer().getShell(), MapperMessages.ReverseEngineeringEditor_error_while_refreshing_databasetree, he); return null; } }
From source file:org.jboss.ide.eclipse.as.classpath.ui.containers.custom.CustomClasspathPreferencePage.java
License:Open Source License
public boolean performOk() { String[] changed2 = rootComp.getChanged(); ArrayList<Object> list; IRuntimePathProvider[] arr;//from w w w.j a va 2 s .c o m final ArrayList<IProject> projectsNeedRefresh = new ArrayList<IProject>(); for (int i = 0; i < changed2.length; i++) { String runtimeId = changed2[i]; IRuntimeType rt = ServerCore.findRuntimeType(runtimeId); list = rootComp.getDataForComboSelection(changed2[i]); arr = (IRuntimePathProvider[]) list.toArray(new IRuntimePathProvider[list.size()]); CustomRuntimeClasspathModel.getInstance().savePathProviders(rt, arr); IProject[] projectsTargeting = findProjectsTargeting(rt); projectsNeedRefresh.addAll(Arrays.asList(projectsTargeting)); } // Save the recently selected String lastSelected = rootComp.getCurrentId(); IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(JBossServerUIPlugin.PLUGIN_ID); prefs.put(LAST_SELECTED_RUNTIME_TYPE, lastSelected); try { prefs.flush(); } catch (BackingStoreException e) { // IGNORE this since it is only a setting to remember what was the last selected // runtime. This is extremely not necessary to log or inform the user about. } MessageDialog dialog = new MessageDialog(getShell(), Messages.CustomClasspathsSettingsChanged, null, Messages.CustomClasspathsRequiresRebuild, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res = dialog.open(); if (res == 0) { Job j = new WorkspaceJob(Messages.CustomClasspathsWorkspaceJob) { public IStatus runInWorkspace(IProgressMonitor monitor) { Iterator<IProject> i = projectsNeedRefresh.iterator(); monitor.beginTask(Messages.CustomClasspathsWorkspaceJob, projectsNeedRefresh.size()); while (i.hasNext()) { IJavaProject jp = JavaCore.create(i.next()); try { // Must reset the classpath to actually force both views and models to refresh // A full build is not enough jp.setRawClasspath(jp.getRawClasspath(), new NullProgressMonitor()); } catch (JavaModelException jme) { return jme.getStatus(); } CoreUtility.getBuildJob(jp.getProject()).schedule(); } monitor.done(); return Status.OK_STATUS; } }; j.setRule(ResourcesPlugin.getWorkspace().getRoot()); j.schedule(); } rootComp.clearChanged(); return true; }