List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_ID
int YES_ID
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_ID.
Click Source Link
From source file:au.gov.ga.earthsci.catalog.part.CatalogBrowserController.java
License:Apache License
private boolean isFullNodePathRequiredOnAdd() { if (preferences.getAddNodeStructureMode() != UserActionPreference.ASK) { return preferences.getAddNodeStructureMode() == UserActionPreference.ALWAYS; }//www . ja v a 2s . c om MessageDialogWithToggle message = MessageDialogWithToggle.openYesNoQuestion(null, Messages.CatalogBrowserController_AddNodePathDialogTitle, Messages.CatalogBrowserController_AddNodePathDialogMessage, Messages.CatalogBrowserController_DialogDontAsk, false, null, null); UserActionPreference preference = (message.getReturnCode() == IDialogConstants.YES_ID) ? UserActionPreference.ALWAYS : UserActionPreference.NEVER; preferences.setAddNodeStructureMode(message.getToggleState() ? preference : UserActionPreference.ASK); return preference == UserActionPreference.ALWAYS; }
From source file:au.gov.ga.earthsci.catalog.part.CatalogBrowserController.java
License:Apache License
private boolean isEmptyFolderDeletionRequiredOnRemoval() { if (preferences.getDeleteEmptyFoldersMode() != UserActionPreference.ASK) { return preferences.getDeleteEmptyFoldersMode() == UserActionPreference.ALWAYS; }/* w ww. j av a 2s . c om*/ MessageDialogWithToggle message = MessageDialogWithToggle.openYesNoQuestion(null, Messages.CatalogBrowserController_DeleteEmptyFoldersDialogTitle, Messages.CatalogBrowserController_DeleteEmptyFoldersMessage, Messages.CatalogBrowserController_DialogDontAsk, false, null, null); UserActionPreference preference = (message.getReturnCode() == IDialogConstants.YES_ID) ? UserActionPreference.ALWAYS : UserActionPreference.NEVER; preferences.setDeleteEmptyFoldersMode(message.getToggleState() ? preference : UserActionPreference.ASK); return preference == UserActionPreference.ALWAYS; }
From source file:ca.uvic.cs.tagsea.monitor.jobs.UploadJob.java
License:Open Source License
@Override protected synchronized IStatus run(IProgressMonitor monitor) { //get the logs that have to be uploaded. monitor.beginTask(getName(), 101);/*from w w w .java 2 s .c o m*/ IPreferenceStore prefs = TagSEAMonitorPlugin.getDefault().getPreferenceStore(); String date = prefs.getString(MonitorPreferences.LAST_DATE_PREF); DateFormat f = DateFormat.getDateInstance(DateFormat.SHORT); Date today = new Date(System.currentTimeMillis()); NetworkLogging logging = new NetworkLogging(); int id = TagSEAPlugin.getDefault().getUserID(); //ask to register if we haven't already. if (id < 0 && !MonitorPreferences.hasAskedToRegister()) { Display disp = TagSEAMonitorPlugin.getDefault().getWorkbench().getDisplay(); disp.syncExec(new Runnable() { public void run() { Shell shell = TagSEAMonitorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow() .getShell(); MessageDialogWithToggle d = MessageDialogWithToggle.openYesNoQuestion(shell, "Register TagSEA", "TagSEA is not registered.\n\n" + "You have requested that a log of your interactions with TagSEA be" + " uploaded to the University of Victoria for research purposes, but" + " you have not yet registered TagSEA with the University of Victoria." + " You must register before these logs can be uploaded.\n\n " + "Selecting 'Yes' will prompt you to register TagSEA. Selecting 'No'" + " will cancel the current upload.\n\n" + " You may manually upload your logging data, by selecting the 'Upload'" + " action in the TagSEA log view (Window>Show Views>Other>TagSEA>TagSEA Log)" + " You may also register at any time using the TagSEA preference page.\n\n" + "Would you like to register now?", " Don't ask again.", false, null, null); int result = 0; int code = d.getReturnCode(); if (code == IDialogConstants.YES_ID) { result = TagSEAPlugin.getDefault().askForUserID(); } if (d.getToggleState() && result != -2) { MonitorPreferences.setAskedToRegister(true); } } }); } id = TagSEAPlugin.getDefault().getUserID(); if (id < 0) { //id is still 0. cancel monitor.done(); this.status = Status.CANCEL_STATUS; return Status.CANCEL_STATUS; } try { today = f.parse(f.format(today)); ArrayList<Date> newDates = new ArrayList<Date>(); if (!"".equals(date)) { Date last = f.parse(date); Date[] ds = TagSEAMonitorPlugin.getDefault().getLogDates(); Arrays.sort(ds); for (Date current : ds) { if (current.after(last) && current.before(today)) { newDates.add(current); } else if (current.after(today)) { //shouldn't happen break; } } } else { Date[] ds = TagSEAMonitorPlugin.getDefault().getLogDates(); for (Date current : ds) { if (current.before(today)) { newDates.add(current); } } } monitor.worked(1); int work = (int) Math.floor(100.0 / newDates.size()); for (Date current : newDates) { monitor.subTask(DateFormat.getDateInstance().format(current)); if (!logging.uploadForDate(current)) { monitor.done(); this.status = new Status(Status.ERROR, TagSEAMonitorPlugin.PLUGIN_ID, 0, "Unable to upload log.", null); return this.status; } monitor.worked(work); } } catch (ParseException e) { TagSEAMonitorPlugin.getDefault().log(e); return new Status(Status.ERROR, TagSEAMonitorPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e); } catch (IOException e) { TagSEAMonitorPlugin.getDefault().log(e); return new Status(Status.ERROR, TagSEAMonitorPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e); } finally { monitor.done(); } this.status = Status.OK_STATUS; return Status.OK_STATUS; }
From source file:ca.uvic.cs.tagsea.statistics.svn.jobs.SVNCommentScanningJob.java
License:Open Source License
/** * @return/*from www.j a v a 2s . c om*/ */ private int askForID() { Display disp = Display.getDefault(); if (SVNStatistics.getDefault().getPreferenceStore().getBoolean("register.asked")) { return -1; } disp.syncExec(new Runnable() { public void run() { Shell shell = SVNStatistics.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialogWithToggle d = MessageDialogWithToggle.openYesNoQuestion(shell, "Register TagSEA", "TagSEA is not registered.\n\n" + "You have installed the TagSEA Subversion plugin. By doing so, you have" + " agreed that you would like to send the developers of TagSEA some information" + " about how you comment your code. This can be done, however, you must first" + " register TagSEA.\n\n" + "Would you like to register now?", " Don't ask again.", false, null, null); int result = 0; int code = d.getReturnCode(); if (code == IDialogConstants.YES_ID) { result = TagSEAPlugin.getDefault().askForUserID(); } if (d.getToggleState() && result != -2) { SVNStatistics.getDefault().getPreferenceStore().setValue("register.asked", true); } } }); return TagSEAPlugin.getDefault().getUserID(); }
From source file:ccw.leiningen.NewLeiningenProjectWizard.java
License:Open Source License
/** * Prompts the user for whether to switch perspectives. * /*from w ww .j ava 2s . co m*/ * @param window * The workbench window in which to switch perspectives; must not * be <code>null</code> * @param finalPersp * The perspective to switch to; must not be <code>null</code>. * * @return <code>true</code> if it's OK to switch, <code>false</code> * otherwise */ private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, IPerspectiveDescriptor finalPersp) { IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) { // Return whether or not we should always switch return IDEInternalPreferences.PSPM_ALWAYS.equals(pspm); } String desc = finalPersp.getDescription(); String message; if (desc == null || desc.length() == 0) message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()); else message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessageWithDesc, new String[] { finalPersp.getLabel(), desc }); MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(window.getShell(), ResourceMessages.NewProject_perspSwitchTitle, message, null /* use the default message for the toggle */, false /* toggle is initially unchecked */, store, IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); int result = dialog.getReturnCode(); // If we are not going to prompt anymore propogate the choice. if (dialog.getToggleState()) { String preferenceValue; if (result == IDialogConstants.YES_ID) { // Doesn't matter if it is replace or new window // as we are going to use the open perspective setting preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE; } else { preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE; } // update PROJECT_OPEN_NEW_PERSPECTIVE to correspond PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue); } return result == IDialogConstants.YES_ID; }
From source file:ch.elexis.core.ui.importer.div.importers.dialog.QueryOverwriteDialog.java
License:Open Source License
/** * Create contents of the button bar./* w w w .ja v a 2 s. c o m*/ * * @param parent */ @Override protected void createButtonsForButtonBar(Composite parent) { Button buttonNo = createButton(parent, IDialogConstants.NO_ID, IDialogConstants.OK_LABEL, true); buttonNo.setText(Messages.QueryOverwriteDialog_NO); Button buttonYesToAll = createButton(parent, IDialogConstants.YES_TO_ALL_ID, IDialogConstants.CANCEL_LABEL, false); buttonYesToAll.setText(Messages.QueryOverwriteDialog_YESTOALL); Button buttonYes = createButton(parent, IDialogConstants.YES_ID, IDialogConstants.CANCEL_LABEL, false); buttonYes.setText(Messages.QueryOverwriteDialog_YES); }
From source file:com.amalto.workbench.export.ImportItemsWizard.java
License:Open Source License
private int isOveride(String name, String obTypeName) { final MessageDialog dialog = new MessageDialog(getShell(), Messages.ImportItemsWizard_12, null, Messages.ImportItemsWizard_13 + obTypeName + Messages.ImportItemsWizard_14 + name + Messages.ImportItemsWizard_15, MessageDialog.QUESTION,//from w w w.j a v a 2s .co m new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.open(); int result = dialog.getReturnCode(); if (result == 0) { return IDialogConstants.YES_ID; } if (result == 1) { return IDialogConstants.YES_TO_ALL_ID; } if (result == 2) { return IDialogConstants.NO_ID; } return IDialogConstants.CANCEL_ID; }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.properties.XmlPropertyEditor.java
License:Open Source License
@Override protected boolean setEditorText(Property property, String text) throws Exception { Object oldValue = property.getValue(); String old = oldValue != null ? oldValue.toString() : null; // If users enters a new id without specifying the @id/@+id prefix, insert it boolean isId = isIdProperty(property); if (isId && !text.startsWith(PREFIX_RESOURCE_REF)) { text = NEW_ID_PREFIX + text;/*from w ww.j av a2s . c o m*/ } // Handle id refactoring: if you change an id, may want to update references too. // Ask user. if (isId && property instanceof XmlProperty && old != null && !old.isEmpty() && text != null && !text.isEmpty() && !text.equals(old)) { XmlProperty xmlProperty = (XmlProperty) property; IPreferenceStore store = AdtPlugin.getDefault().getPreferenceStore(); String refactorPref = store.getString(AdtPrefs.PREFS_REFACTOR_IDS); boolean performRefactor = false; Shell shell = AdtPlugin.getShell(); if (refactorPref == null || refactorPref.isEmpty() || refactorPref.equals(MessageDialogWithToggle.PROMPT)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, "Update References?", "Update all references as well? " + "This will update all XML references and Java R field references.", "Do not show again", false, store, AdtPrefs.PREFS_REFACTOR_IDS); switch (dialog.getReturnCode()) { case IDialogConstants.CANCEL_ID: return false; case IDialogConstants.YES_ID: performRefactor = true; break; case IDialogConstants.NO_ID: performRefactor = false; break; } } else { performRefactor = refactorPref.equals(MessageDialogWithToggle.ALWAYS); } if (performRefactor) { CommonXmlEditor xmlEditor = xmlProperty.getXmlEditor(); if (xmlEditor != null) { IProject project = xmlEditor.getProject(); if (project != null && shell != null) { RenameResourceWizard.renameResource(shell, project, ResourceType.ID, stripIdPrefix(old), stripIdPrefix(text), false); } } } } property.setValue(text); return true; }
From source file:com.aptana.ide.debug.internal.ui.InstallDebuggerPromptStatusHandler.java
License:Open Source License
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) *//*from ww w. j a va 2s .com*/ public Object handleStatus(IStatus status, Object source) throws CoreException { Shell shell = DebugUiPlugin.getActiveWorkbenchShell(); String title = Messages.InstallDebuggerPromptStatusHandler_InstallDebuggerExtension; if ("install".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_AcceptExtensionInstallation_Quit); return null; } else if ("postinstall".equals(source)) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, Messages.InstallDebuggerPromptStatusHandler_WaitbrowserLaunches_Quit); return null; } else if ("nopdm".equals(source)) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, Messages.InstallDebuggerPromptStatusHandler_PDMNotInstalled, MessageDialog.WARNING, new String[] { StringUtils.ellipsify(Messages.InstallDebuggerPromptStatusHandler_Download), CoreStrings.CONTINUE, CoreStrings.CANCEL, CoreStrings.HELP }, 0); switch (md.open()) { case 0: WorkbenchHelper.launchBrowser("http://www.aptana.com/pro/pdm.php", "org.eclipse.ui.browser.ie"); //$NON-NLS-1$ //$NON-NLS-2$ /* continue */ case 1: return new Boolean(true); case 3: WorkbenchHelper.launchBrowser("http://www.aptana.com/docs/index.php/Installing_the_IE_debugger"); //$NON-NLS-1$ return new Boolean(true); default: break; } return null; } else if (source instanceof String && ((String) source).startsWith("quit_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_BrowserIsRunning, new String[] { ((String) source).substring(5) })); return null; } else if (source instanceof String && ((String) source).startsWith("installed_")) { //$NON-NLS-1$ MessageDialog.openInformation(shell, title, StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstalled, new String[] { ((String) source).substring(10) })); return null; } else if (source instanceof String && ((String) source).startsWith("warning_")) { //$NON-NLS-1$ MessageDialog.openWarning(shell, title, ((String) source).substring(8)); return null; } else if (source instanceof String && ((String) source).startsWith("failed_")) { //$NON-NLS-1$ MessageDialog md = new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, null, MessageFormat.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionInstallFailed, new Object[] { ((String) source).substring(7) }), MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL, CoreStrings.HELP }, 0); while (true) { switch (md.open()) { case IDialogConstants.OK_ID: return null; default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } } IPreferenceStore store = DebugUiPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IDebugUIConstants.PREF_INSTALL_DEBUGGER); if (pref != null) { if (pref.equals(MessageDialogWithToggle.ALWAYS)) { return new Boolean(true); } } String message = StringUtils.format(Messages.InstallDebuggerPromptStatusHandler_ExtensionNotInstalled, new String[] { (String) source }); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, title, null, message, MessageDialog.INFORMATION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, CoreStrings.HELP }, 2, null, false); dialog.setPrefKey(IDebugUIConstants.PREF_INSTALL_DEBUGGER); dialog.setPrefStore(store); while (true) { switch (dialog.open()) { case IDialogConstants.YES_ID: return new Boolean(true); case IDialogConstants.NO_ID: return new Boolean(false); default: break; } WorkbenchHelper.launchBrowser(((String) source).indexOf("Internet Explorer") != -1 //$NON-NLS-1$ ? "http://www.aptana.com/docs/index.php/Installing_the_IE_debugger" //$NON-NLS-1$ : "http://www.aptana.com/docs/index.php/Installing_the_JavaScript_debugger"); //$NON-NLS-1$ } }
From source file:com.aptana.ide.server.jetty.ShowPerspectiveClient.java
License:Open Source License
private boolean promptUser(String id) { Shell shell = JettyPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(); MessageDialogWithToggle dialog = new MessageDialogWithToggle(shell, Messages.ShowPerspectiveClient_1, null, // accept the default window icon MessageFormat.format(Messages.ShowPerspectiveClient_2, getPerspectiveName(id)), MessageDialogWithToggle.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0, // YES is the default null, false) {//w w w . j a va 2 s . c o m @Override protected Control createCustomArea(Composite parent) { try { URL url = JettyPlugin.getDefault().getBundle().getEntry("/icons/animation.gif"); //$NON-NLS-1$ url = FileLocator.toFileURL(url); Browser animation = new Browser(parent, SWT.NULL); animation.setText("<html>" + //$NON-NLS-1$ "<body style='margin: 0; padding:0; border: 1px solid black' >" + //$NON-NLS-1$ "<center>" + //$NON-NLS-1$ "<img src='" + url.toExternalForm() + "' />" + //$NON-NLS-1$ //$NON-NLS-2$ "</center>" + //$NON-NLS-1$ "</body>" + //$NON-NLS-1$ "</html>" //$NON-NLS-1$ ); GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, false); gridData.widthHint = 311 + 2; // 2 for border gridData.heightHint = 169 + 2; // 2 for border animation.setLayoutData(gridData); return animation; } catch (IOException e) { } Label animation = new Label(parent, SWT.CENTER); animation.setImage(JettyPlugin.getImage("/icons/animation.gif")); //$NON-NLS-1$ GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); animation.setLayoutData(gridData); return animation; } }; dialog.setPrefStore(JettyPlugin.getDefault().getPreferenceStore()); dialog.setPrefKey(getPrefKey(id)); dialog.open(); return (dialog.getReturnCode() == IDialogConstants.YES_ID); }