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:net.refractions.udig.project.ui.internal.SaveDialog.java
License:Open Source License
@Override protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.NO_ID) { setReturnCode(IDialogConstants.NO_ID); close();/*from w ww .j av a 2 s . co m*/ } else if (buttonId == IDialogConstants.YES_ID) { setReturnCode(IDialogConstants.YES_ID); close(); } else { setReturnCode(IDialogConstants.CANCEL_ID); close(); } }
From source file:net.refractions.udig.project.ui.internal.SaveDialog.java
License:Open Source License
@Override protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false); createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); }
From source file:net.refractions.udig.ui.ZoomingDialog.java
License:Open Source License
public static boolean openQuestionMessage(Rectangle start, Shell parentShell, String dialogTitle, String dialogMessage) {// w ww . ja v a 2 s. co m int result = openMessageDialog(start, parentShell, dialogTitle, null, dialogMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); return result == IDialogConstants.YES_ID; }
From source file:net.rim.ejde.internal.ui.wizards.imports.ImportLegacyProjectsWizard.java
License:Open Source License
private void showDialogPersSwitch() { IWorkbench iwb = PlatformUI.getWorkbench(); IPerspectiveDescriptor ipd = iwb.getActiveWorkbenchWindow().getActivePage().getPerspective(); // Check if the BB perspective is currently active, if it isn't, do // nothing.//from w ww. j ava2 s . c o m if (!ipd.getId().equals("net.rim.ejde.ui.perspective.BlackBerryPerspective")) { // Get the default set of preferences. IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); // Get the default value for the persp switch preference. String pspm = store.getString(IDEInternalPreferences.PROJECT_SWITCH_PERSP_MODE); if (!IDEInternalPreferences.PSPM_PROMPT.equals(pspm)) { // Check if we need to switch or not. If not, stop here. return; } else { // If the user has already said yes, no need create the dialog. Just switch perspective. } // Add the perspective message and the perspective name to the // dialog String message = Messages.NewProject_perspSwitchMessage; MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(null, 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(); String preferenceValue; if (dialog.getToggleState()) { if (result == IDialogConstants.YES_ID) { preferenceValue = IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE; } else { preferenceValue = IWorkbenchPreferenceConstants.NO_NEW_PERSPECTIVE; } PrefUtil.getAPIPreferenceStore().setValue(IDE.Preferences.PROJECT_OPEN_NEW_PERSPECTIVE, preferenceValue); } // If the user said yes, switch the perspective. if (result == IDialogConstants.YES_ID) { switchPerspective(); } } }
From source file:net.sf.eclipsecs.ui.preferences.CheckstylePreferencePage.java
License:Open Source License
/** * {@inheritDoc}//from w w w . ja v a2s.c o m */ public boolean performOk() { try { // // Save the check configurations. // mWorkingSet.store(); // // Save the general preferences. // CheckstyleUIPluginPrefs.setString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD, mRebuildIfNeeded.getItem(mRebuildIfNeeded.getSelectionIndex())); // // fileset warning preference // boolean warnFileSetsNow = mWarnBeforeLosingFilesets.getSelection(); CheckstyleUIPluginPrefs.setBoolean(CheckstyleUIPluginPrefs.PREF_FILESET_WARNING, warnFileSetsNow); // // Include rule names preference. // boolean includeRuleNamesNow = mIncludeRuleNamesButton.getSelection(); boolean includeRuleNamesOriginal = CheckstylePluginPrefs .getBoolean(CheckstylePluginPrefs.PREF_INCLUDE_RULE_NAMES); CheckstylePluginPrefs.setBoolean(CheckstylePluginPrefs.PREF_INCLUDE_RULE_NAMES, includeRuleNamesNow); // // Include module id preference. // boolean includeModuleIdNow = mIncludeModuleIdButton.getSelection(); boolean includeModuleIdOriginal = CheckstylePluginPrefs .getBoolean(CheckstylePluginPrefs.PREF_INCLUDE_MODULE_IDS); CheckstylePluginPrefs.setBoolean(CheckstylePluginPrefs.PREF_INCLUDE_MODULE_IDS, includeModuleIdNow); // // Limit markers preference // boolean limitMarkersNow = mLimitCheckstyleMarkers.getSelection(); boolean limitMarkersOriginal = CheckstylePluginPrefs .getBoolean(CheckstylePluginPrefs.PREF_LIMIT_MARKERS_PER_RESOURCE); CheckstylePluginPrefs.setBoolean(CheckstylePluginPrefs.PREF_LIMIT_MARKERS_PER_RESOURCE, limitMarkersNow); int markerLimitNow = Integer.parseInt(mTxtMarkerLimit.getText()); int markerLimitOriginal = CheckstylePluginPrefs.getInt(CheckstylePluginPrefs.PREF_MARKER_AMOUNT_LIMIT); CheckstylePluginPrefs.setInt(CheckstylePluginPrefs.PREF_MARKER_AMOUNT_LIMIT, markerLimitNow); // // Include background build preference. // boolean runInBackgroundNow = mBackgroundFullBuild.getSelection(); CheckstylePluginPrefs.setBoolean(CheckstylePluginPrefs.PREF_BACKGROUND_FULL_BUILD, runInBackgroundNow); // See if all projects need rebuild boolean needRebuildAllProjects = (includeRuleNamesNow != includeRuleNamesOriginal) || (includeModuleIdNow != includeModuleIdOriginal) || (limitMarkersNow != limitMarkersOriginal) || (markerLimitNow != markerLimitOriginal) || mRebuildAll; // Get projects that need rebuild considering the changes Collection<IProject> projectsToBuild = mWorkingSet.getAffectedProjects(); String promptRebuildPref = CheckstyleUIPluginPrefs .getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); boolean rebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && (needRebuildAllProjects || projectsToBuild.size() > 0); // // Prompt for rebuild // if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && (needRebuildAllProjects || projectsToBuild.size() > 0)) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), Messages.CheckstylePreferencePage_titleRebuild, Messages.CheckstylePreferencePage_msgRebuild, Messages.CheckstylePreferencePage_nagRebuild, false, CheckstyleUIPlugin.getDefault().getPreferenceStore(), CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); rebuild = dialog.getReturnCode() == IDialogConstants.YES_ID; } if (rebuild) { try { if (needRebuildAllProjects) { CheckstyleBuilder.buildAllProjects(); } else { CheckstyleBuilder.buildProjects(projectsToBuild); } } catch (CheckstylePluginException e) { CheckstyleUIPlugin.errorDialog(getShell(), NLS.bind(Messages.errorFailedRebuild, e.getMessage()), e, true); } } } catch (CheckstylePluginException e) { CheckstyleUIPlugin.errorDialog(getShell(), NLS.bind(Messages.errorFailedSavePreferences, e.getLocalizedMessage()), e, true); } catch (BackingStoreException e) { CheckstyleUIPlugin.errorDialog(getShell(), NLS.bind(Messages.errorFailedSavePreferences, e.getLocalizedMessage()), e, true); } return true; }
From source file:net.sf.eclipsecs.ui.properties.CheckstylePropertyPage.java
License:Open Source License
/** * @return the result of the ok action/* w ww . j a v a 2s.c om*/ * @see org.eclipse.jface.preference.IPreferencePage#performOk() */ public boolean performOk() { try { IProject project = mProjectConfig.getProject(); // save the edited project configuration if (mProjectConfig.isDirty()) { mProjectConfig.store(); } boolean checkstyleEnabled = mChkEnable.getSelection(); boolean needRebuild = mProjectConfig.isRebuildNeeded(); // check if checkstyle nature has to be configured/deconfigured if (checkstyleEnabled != mCheckstyleInitiallyActivated) { ConfigureDeconfigureNatureJob configOperation = new ConfigureDeconfigureNatureJob(project, CheckstyleNature.NATURE_ID); configOperation.setRule(ResourcesPlugin.getWorkspace().getRoot()); configOperation.schedule(); needRebuild = needRebuild || !mCheckstyleInitiallyActivated; } if (checkstyleEnabled && mProjectConfig.isSyncFormatter()) { TransformCheckstyleRulesJob transFormJob = new TransformCheckstyleRulesJob(project); transFormJob.schedule(); } // if a rebuild is advised, check/prompt if the rebuild should // really be done. if (checkstyleEnabled && needRebuild) { String promptRebuildPref = CheckstyleUIPluginPrefs .getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); boolean doRebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && needRebuild; // // Prompt for rebuild // if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && needRebuild) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(), Messages.CheckstylePropertyPage_titleRebuild, Messages.CheckstylePropertyPage_msgRebuild, Messages.CheckstylePropertyPage_nagRebuild, false, CheckstyleUIPlugin.getDefault().getPreferenceStore(), CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD); doRebuild = dialog.getReturnCode() == IDialogConstants.YES_ID; } // check if a rebuild is necessary if (checkstyleEnabled && doRebuild) { BuildProjectJob rebuildOperation = new BuildProjectJob(project, IncrementalProjectBuilder.FULL_BUILD); rebuildOperation.setRule(ResourcesPlugin.getWorkspace().getRoot()); rebuildOperation.schedule(); } } } catch (CheckstylePluginException e) { CheckstyleUIPlugin.errorDialog(getShell(), e, true); } return true; }
From source file:net.sf.eclipsensis.startup.FileAssociationChecker.java
License:Open Source License
private void scheduleJob(final FileAssociationDef def) { if (def != null) { Job job = new UIJob(mJobName) { private boolean isValidEditor(String[] editorIds, IEditorDescriptor descriptor) { if (descriptor != null) { String id = descriptor.getId(); for (int i = 0; i < editorIds.length; i++) { if (editorIds[i].equals(id)) { return true; }//ww w .j a v a 2 s . c o m } } return false; } @Override public IStatus runInUIThread(final IProgressMonitor monitor) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } if (!cCheckedAssociations.contains(def.getAssociationId())) { final boolean toggleState = getFileAssociationChecking(def.getAssociationId()); if (toggleState) { cCheckedAssociations.add(def.getAssociationId()); final String[] fileTypes = def.getFileTypes(); for (int i = 0; i < fileTypes.length; i++) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } if (!isValidEditor(def.getEditorIds(), mEditorRegistry.getDefaultEditor(fileTypes[i]))) { if (!monitor.isCanceled()) { String[] args = new String[] { def.getFileTypesName(), def.getEditorsName() }; MessageDialogWithToggle dialog = MessageDialogWithToggle .openYesNoCancelQuestion( PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(), mDialogTitleFormat.format(args), mDialogMessageFormat.format(args), mDialogToggleMessageFormat.format(args), !toggleState, null, null); int rc = dialog.getReturnCode(); switch (rc) { case IDialogConstants.YES_ID: { for (int j = 0; j < fileTypes.length; j++) { mEditorRegistry.setDefaultEditor(fileTypes[j], def.getEditorIds()[0]); } //Cast to inner class because otherwise it cannot be saved. ((EditorRegistry) mEditorRegistry).saveAssociations(); //Fall through to next case to save the toggle state } //$FALL-THROUGH$ case IDialogConstants.NO_ID: { boolean newToggleState = !dialog.getToggleState(); if (toggleState != newToggleState) { setFileAssociationChecking(def.getAssociationId(), newToggleState); } break; } case IDialogConstants.CANCEL_ID: return Status.CANCEL_STATUS; } } break; } } } } if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } else { return Status.OK_STATUS; } } }; job.setRule(cSchedulingRule); job.schedule(5000); } }
From source file:net.sourceforge.eclipseccase.ClearCaseModificationHandler.java
License:Open Source License
/** * Checks out the specified files./*from w w w .ja v a2s . c o m*/ * * @param files * @return a status describing the result */ private IStatus checkout(final IFile[] files) { ClearCaseProvider provider = getProvider(files); if (PreventCheckoutHelper.isPreventedFromCheckOut(provider, files, ClearCasePreferences.isSilentPrevent())) { return CANCEL; } if (!PreventCheckoutHelper.isPromtedCoTypeOk()) { return CANCEL; } if (ClearCasePreferences.isCheckoutAutoNever()) return CANCEL; if (!ClearCasePreferences.isCheckoutAutoAlways()) { //CheckoutQuestionRunnable checkoutQuestion = new CheckoutQuestionRunnable(); CheckoutQuestionRunnable checkoutQuestion = new CheckoutQuestionRunnable(files); getDisplay().syncExec(checkoutQuestion); int returncode = checkoutQuestion.getResult(); if (checkoutQuestion.isRemember()) { if (returncode == IDialogConstants.YES_ID) ClearCasePreferences.setCheckoutAutoAlways(); else if (returncode == IDialogConstants.NO_ID) ClearCasePreferences.setCheckoutAutoNever(); } if (returncode != IDialogConstants.YES_ID) return new Status(IStatus.CANCEL, ClearCasePlugin.PLUGIN_ID, "Checkout operation failed, operation was cancelled by user."); } // check for provider if (null == provider) return new Status(IStatus.ERROR, ClearCaseProvider.ID, TeamException.NOT_CHECKED_OUT, "No ClearCase resources!", new IllegalStateException("Provider is null!")); // checkout try { synchronized (provider) { boolean refreshing = setResourceRefreshing(provider, false); try { if (ClearCasePreferences.isUseClearDlg()) { ClearDlgHelper.checkout(files); } for (int i = 0; i < files.length; i++) { IFile file = files[i]; if (!ClearCasePreferences.isUseClearDlg()) { provider.checkout(new IFile[] { file }, IResource.DEPTH_ZERO, null); } file.refreshLocal(IResource.DEPTH_ZERO, null); } } finally { setResourceRefreshing(provider, refreshing); } } } catch (CoreException ex) { return ex.getStatus(); } return OK; }
From source file:net.sourceforge.sqlexplorer.connections.actions.CloseAllConnectionsAction.java
License:Open Source License
public void run() { boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences() .getBoolean(IConstants.CONFIRM_BOOL_CLOSE_ALL_CONNECTIONS); if (confirm) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( getView().getSite().getShell(), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Title"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Message"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Toggle"), false, null, null); if (dialog.getToggleState() && dialog.getReturnCode() == IDialogConstants.YES_ID) SQLExplorerPlugin.getDefault().getPluginPreferences() .setValue(IConstants.CONFIRM_BOOL_CLOSE_ALL_CONNECTIONS, false); if (dialog.getReturnCode() != IDialogConstants.YES_ID) return; }/* ww w . j a v a 2 s .c o m*/ Set<SQLConnection> connections = getView().getSelectedConnections(true); for (SQLConnection connection : connections) { synchronized (connection) { Session session = connection.getSession(); if (session != null) { synchronized (session) { if (!session.isConnectionInUse()) session.disposeConnection(); } } else connection.getUser().releaseFromPool(connection); } } setEnabled(false); getView().refresh(); }
From source file:net.sourceforge.sqlexplorer.connections.actions.CloseConnectionAction.java
License:Open Source License
public void run() { boolean confirm = SQLExplorerPlugin.getDefault().getPluginPreferences() .getBoolean(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION); for (SQLConnection connection : getView().getSelectedConnections(false)) { Session session = connection.getSession(); if (session != null && !session.isConnectionInUse()) { if (confirm) { MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( getView().getSite().getShell(), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Title"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Message"), Messages.getString("ConnectionsView.Actions.CloseAll.Confirm.Toggle"), false, null, null);// w w w . j a va2s. c o m if (dialog.getToggleState() && dialog.getReturnCode() == IDialogConstants.YES_ID) SQLExplorerPlugin.getDefault().getPluginPreferences() .setValue(IConstants.CONFIRM_BOOL_CLOSE_CONNECTION, false); if (dialog.getReturnCode() != IDialogConstants.YES_ID) return; } session.disposeConnection(); } else if (session == null) connection.getUser().releaseFromPool(connection); } getView().refresh(); }