當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageDialogWithToggle.openYesNoQuestion方法代碼示例

本文整理匯總了Java中org.eclipse.jface.dialogs.MessageDialogWithToggle.openYesNoQuestion方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageDialogWithToggle.openYesNoQuestion方法的具體用法?Java MessageDialogWithToggle.openYesNoQuestion怎麽用?Java MessageDialogWithToggle.openYesNoQuestion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jface.dialogs.MessageDialogWithToggle的用法示例。


在下文中一共展示了MessageDialogWithToggle.openYesNoQuestion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: askDeleteScript

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public void askDeleteScript(IFile f) {
    String mode = mainPrefs.getString(DB_UPDATE_PREF.DELETE_SCRIPT_AFTER_CLOSE);
    // if select "YES" with toggle
    if (mode.equals(MessageDialogWithToggle.ALWAYS)){
        deleteFile(f);
        // if not select "NO" with toggle, show choice message dialog
    } else if (!mode.equals(MessageDialogWithToggle.NEVER)){
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getSite().getShell(),
                Messages.SqlEditor_script_delete_dialog_title, MessageFormat.format(
                        Messages.SqlEditor_script_delete_dialog_message, f.getName()),
                Messages.remember_choice_toggle, false, mainPrefs, DB_UPDATE_PREF.DELETE_SCRIPT_AFTER_CLOSE);
        if(dialog.getReturnCode() == IDialogConstants.YES_ID){
            deleteFile(f);
        }
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:17,代碼來源:SQLEditor.java

示例2: promptForQuickDiffAnnotate

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Returns true if the user wishes to always use the live annotate view, false otherwise.
 * @return
 */
private boolean promptForQuickDiffAnnotate(){
	//check whether we should ask the user.
	final IPreferenceStore store = SVNUIPlugin.getPlugin().getPreferenceStore();
	final String option = store.getString(ISVNUIConstants.PREF_USE_QUICKDIFFANNOTATE);
	
	if (option.equals(MessageDialogWithToggle.ALWAYS))
		return true; //use live annotate
	else if (option.equals(MessageDialogWithToggle.NEVER))
		return false; //don't use live annotate
	
	final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(Utils.getShell(null), Policy.bind("AnnotateOperation_QDAnnotateTitle"),
			Policy.bind("AnnotateOperation_QDAnnotateMessage"), Policy.bind("AnnotateOperation_4"), false, store, ISVNUIConstants.PREF_USE_QUICKDIFFANNOTATE);
	
	final int result = dialog.getReturnCode();
	switch (result) {
		//yes
		case IDialogConstants.YES_ID:
		case IDialogConstants.OK_ID :
		    return true;
	}
	return false;
}
 
開發者ID:subclipse,項目名稱:subclipse,代碼行數:27,代碼來源:ShowAnnotationOperation.java

示例3: getCommentWithPrompt

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public String getCommentWithPrompt(Shell shell) {
    final String comment= getComment(false);
    if (comment.length() == 0) {
        final IPreferenceStore store= SVNUIPlugin.getPlugin().getPreferenceStore();
        final String value= store.getString(ISVNUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS);
        
        if (MessageDialogWithToggle.NEVER.equals(value))
            return null;
        
        if (MessageDialogWithToggle.PROMPT.equals(value)) {
            
            final String title= Policy.bind("CommitCommentArea_2"); 
            final String message= Policy.bind("CommitCommentArea_3"); 
            final String toggleMessage= Policy.bind("CommitCommentArea_4"); 
            
            final MessageDialogWithToggle dialog= MessageDialogWithToggle.openYesNoQuestion(shell, title, message, toggleMessage, false, store, ISVNUIConstants.PREF_ALLOW_EMPTY_COMMIT_COMMENTS);
            if (dialog.getReturnCode() != IDialogConstants.YES_ID) {
                fTextBox.setFocus();
                return null;
            }
        }
    }
    return getComment(true);
}
 
開發者ID:subclipse,項目名稱:subclipse,代碼行數:25,代碼來源:CommitCommentArea.java

示例4: openIgnoreMessageDialogConfirm

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * openIgnoreMessageDialogConfirm
 * 
 * @param shell
 * @param title
 * @param message
 * @param store
 * @param key
 *            Key to store the show/hide this message. Message will be hidden if true
 * @return int
 */
public static int openIgnoreMessageDialogConfirm(Shell shell, String title, String message, IPreferenceStore store,
		String key)
{
	String value = store.getString(key);
	if (!shouldShowDialog(key))
	{
		return value == MessageDialogWithToggle.ALWAYS ? IDialogConstants.YES_ID : IDialogConstants.NO_ID;
	}
	MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message,
			Messages.DialogUtils_doNotShowMessageAgain, false, store, key);
	if (dialog.getToggleState())
	{
		setShouldShowDialog(key, false);
		store.putValue(key, dialog.getReturnCode() == IDialogConstants.YES_ID ? MessageDialogWithToggle.ALWAYS
				: MessageDialogWithToggle.NEVER);
	}
	return dialog.getReturnCode();
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:30,代碼來源:DialogUtils.java

示例5: openQuestionWithIgnoreToggle

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public static boolean openQuestionWithIgnoreToggle(String title, String message, String key) {
    Shell shell = EditorUtils.getShell();
    IPreferenceStore store = PydevPlugin.getDefault().getPreferenceStore();
    String val = store.getString(key);
    if (val.trim().length() == 0) {
        val = MessageDialogWithToggle.PROMPT; //Initial value if not specified
    }

    if (!val.equals(MessageDialogWithToggle.ALWAYS)) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell, title, message,
                "Don't show this message again", false, store,
                key);
        if (dialog.getReturnCode() != IDialogConstants.YES_ID) {
            return false;
        }
    }
    return true;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:19,代碼來源:PyDialogHelpers.java

示例6: askPerspectiveChange

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private void askPerspectiveChange(IEditorSite site) {
    String mode = mainPrefs.getString(PG_EDIT_PREF.PERSPECTIVE_CHANGING_STATUS);
    // if select "YES" with toggle
    if (mode.equals(MessageDialogWithToggle.ALWAYS)){
        changePerspective(site);
        // if not select "NO" with toggle, show choice message dialog
    } else if (!mode.equals(MessageDialogWithToggle.NEVER)){
        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(site.getShell(),
                Messages.change_perspective_title, Messages.change_perspective_message,
                Messages.remember_choice_toggle, false, mainPrefs, PG_EDIT_PREF.PERSPECTIVE_CHANGING_STATUS);
        if(dialog.getReturnCode() == IDialogConstants.YES_ID){
            changePerspective(site);
        }
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:16,代碼來源:ProjectEditorDiffer.java

示例7: openYesNoQuestion

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Convenience method to open a simple confirm (OK/Cancel) dialog.
 *
 * @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 message
 *        the message
 * @param toggleMessage
 *        the message for the toggle control, or <code>null</code> for the
 *        default message
 * @param toggleState
 *        the initial state for the toggle
 * @param store
 *        the IPreference store in which the user's preference should be
 *        persisted; <code>null</code> if you don't want it persisted
 *        automatically.
 * @param key
 *        the key to use when persisting the user's preference;
 *        <code>null</code> if you don't want it persisted.
 * @return the dialog, after being closed by the user, which the client can
 *         only call <code>getReturnCode()</code> or
 *         <code>getToggleState()</code>
 */
public static boolean openYesNoQuestion(
    final Shell parent,
    final String title,
    final String message,
    final String toggleMessage,
    final boolean defaultToggleState,
    final String preferenceKey) {
    final IPreferenceStore prefStore = TFSCommonUIClientPlugin.getDefault().getPreferenceStore();

    final boolean toggleState = MessageDialogWithToggle.ALWAYS.equals(prefStore.getString(preferenceKey));

    if (!toggleState) {
        final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
            parent,
            title,
            message,
            toggleMessage,
            defaultToggleState,
            prefStore,
            preferenceKey);

        TFSCommonUIClientPlugin.getDefault().savePluginPreferences();

        return (dialog.getReturnCode() == IDialogConstants.YES_ID);
    }

    return true;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:54,代碼來源:ToggleMessageHelper.java

示例8: onBeforeShapeRemoved

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
@Override
public void onBeforeShapeRemoved(SceneEvent e) {
//		logger.debug("before shape removed called: "+e.shape);
		
		TrpSettings set = TrpMainWidget.getTrpSettings();
		
		for (ICanvasShape s : e.shapes) {
			ITrpShapeType st = GuiUtil.getTrpShape(s);
			if (st instanceof TrpBaselineType) {
				boolean removeParentLine = set.isDeleteLineIfBaselineDeleted();
				if (!removeParentLine) {
				
					MessageDialogWithToggle d = MessageDialogWithToggle.openYesNoQuestion(canvas.getShell(), "Delete line also?", "Do you also want to delete the parent line of this baseline?", 
							"Delete always", TrpMainWidget.getTrpSettings().isDeleteLineIfBaselineDeleted(), null, null);
					int rc = d.getReturnCode();
					logger.debug("answer = "+rc);
					
					removeParentLine = rc==IDialogConstants.YES_ID;
					if (removeParentLine)
						TrpMainWidget.getTrpSettings().setDeleteLineIfBaselineDeleted(d.getToggleState());
				}

				if (removeParentLine) { // remove parent line!
					logger.debug("removing parent line!");
					canvas.getShapeEditor().removeShapeFromCanvas(s.getParent(), true);
					e.stop = true;
				}
			}
			
		}
		
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:33,代碼來源:CanvasSceneListener.java

示例9: performOk

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Perform OK button.
 *
 * @return true, if successful {@inheritDoc}
 */
@Override
public boolean performOk() {
  try {
    if (preferences.needsSaving()) {
      preferences.save();
    }
  } catch (final IOException e) {
    LOGGER.error("Unable to save general preference page preferences", e); //$NON-NLS-1$
  }

  boolean preferenceChanged = false;
  for (final IPreferenceItem item : (IPreferenceItem[]) ((ValidModelTreeContentProvider) treeViewer.getContentProvider()).getElements(null)) {
    preferenceChanged = preferenceChanged | preferenceChanged(item);
  }

  if (preferenceChanged) {
    final MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(this.getShell(), REVALIDATE_DIALOG_TITLE, REVALIDATE_DIALOG_MESSAGE, EXPENSIVE_CHECKS_TOGGLE_MESSAGE, getPreferenceStore().getBoolean(PERFORM_EXPENSIVE_VALIDATION), null, null);

    final boolean yesWeCan = (dialog.getReturnCode() == IDialogConstants.YES_ID);
    final boolean performExpensiveValidations = dialog.getToggleState();

    getPreferenceStore().setValue(PERFORM_EXPENSIVE_VALIDATION, dialog.getToggleState());

    if (yesWeCan) {
      final ValidMarkerUpdateJob updateJob = new ValidMarkerUpdateJob(VALIDATION_JOB_MESSAGE, this.fileExtensions, this.resourceSet, this.markerCreator, this.resourceDescriptions, this.resourceServiceProvider, performExpensiveValidations, storage2UriMapper);
      // The following gets a global lock on all updateJob, no matter what the language is.
      // The reason is that we want to avoid the update job to consume too much memory, but
      // we may decide to change that to a lock on a language basis...
      updateJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
      updateJob.schedule();
    }

  }

  return super.performOk();
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:42,代碼來源:AbstractValidPreferencePage.java

示例10: confirmPerspectiveSwitch

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Prompts the user for whether to switch perspectives.
 *
 * @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;
}
 
開發者ID:angelozerr,項目名稱:typescript.java,代碼行數:50,代碼來源:AbstractNewProjectWizard.java

示例11: getUserDecision

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Shows a dialog which asks the user to confirm the deletion of one or more elements.
 * (if the preference is not set to not show the confirmation dialog)
 * 
 * @param context
 *            delete context
 * @return <code>true</code> to delete element(s); <code>false</code> to
 *         cancel delete
 */
@Override
protected boolean getUserDecision(IDeleteContext context) {
  IPreferenceStore store= TriqEditorPlugin.getDefault().getPreferenceStore();
  if (!store.getBoolean(DELETE_CONFIRMATION_PREFNAME)) {
    return true;
  } else {
    String msg;
    IMultiDeleteInfo multiDeleteInfo = context.getMultiDeleteInfo();
    if (multiDeleteInfo != null) {
      msg = MessageFormat.format(Messages.DeleteFeature_2_xmsg, multiDeleteInfo.getNumber());
    } else {
      String deleteName = getDeleteName(context);
      if (deleteName != null && deleteName.length() > 0) {
        msg = MessageFormat.format(Messages.DeleteFeature_3_xmsg, deleteName);
      } else {
        msg = Messages.DeleteFeature_4_xmsg;
      }
    }
    MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
        Messages.DeleteFeature_5_xfld,
        msg,
        Messages.DeleteFeature_6_xtgl,
        false,
        null,
        null);

    boolean deleteIsConfirmed = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
    if(deleteIsConfirmed) {
      store.setValue(DELETE_CONFIRMATION_PREFNAME, !toggleDialog.getToggleState());
    }
    return deleteIsConfirmed;
  }
}
 
開發者ID:eclipse,項目名稱:triquetrum,代碼行數:44,代碼來源:TriqDefaultDeleteFeature.java

示例12: switchToModelingPerspective

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public static void switchToModelingPerspective(IWorkbenchWindow window) {
	IPreferenceStore prefs = UIPluginActivator.getDefault()
			.getPreferenceStore();
	boolean hide = prefs.getBoolean(AUTO_SWITCH_PERSPECTIVE);
	IWorkbenchPage page = window.getActivePage();
	if (!hide) {
		IWorkbench workbench = window.getWorkbench();
		IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
		IPerspectiveDescriptor descriptor = registry
				.findPerspectiveWithId(IYakinduSctPerspectives.ID_PERSPECTIVE_SCT_MODELING);
		if ((page != null) && (page.getPerspective() != descriptor)) {
			MessageDialogWithToggle dialog = MessageDialogWithToggle
					.openYesNoQuestion(
							window.getShell(),
							"Confirm Perspective Switch",
							"This kind of editor is associated with the YAKINDU Modeling perspective. Do you want to switch to this perspective now?",
							"Do not offer to switch perspective in the future",
							hide, prefs, AUTO_SWITCH_PERSPECTIVE);
			if (dialog.getReturnCode() == 2)
				page.setPerspective(descriptor);
			hide = dialog.getToggleState();
			prefs.setValue(AUTO_SWITCH_PERSPECTIVE, hide);
			try {
				InstanceScope.INSTANCE.getNode(UIPluginActivator.PLUGIN_ID)
						.flush();
			} catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:32,代碼來源:PerspectiveUtil.java

示例13: isEditable

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
public static boolean isEditable(Shell shell, IJavaElement element) {
	if (! isProcessable(shell, element))
		return false;

	IJavaElement cu= element.getAncestor(IJavaElement.COMPILATION_UNIT);
	if (cu != null) {
		IResource resource= cu.getResource();
		if (resource != null && resource.isDerived(IResource.CHECK_ANCESTORS)) {

			// see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
			final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
			IPreferenceStore store= EditorsUI.getPreferenceStore();
			if (!store.getBoolean(warnKey))
				return true;

			MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
					shell,
					ActionMessages.ActionUtil_warning_derived_title,
					Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
					ActionMessages.ActionUtil_warning_derived_dontShowAgain,
					false,
					null,
					null);

			EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());

			return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
		}
	}
	return true;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:32,代碼來源:ActionUtil.java

示例14: askUserToConfigureUserDictionary

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Asks the user whether he wants to configure a user dictionary.
 * 
 * @param shell the shell
 * @return <code>true</code> if the user wants to configure the user dictionary
 * @since 3.3
 */
private boolean askUserToConfigureUserDictionary(Shell shell) {
	MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
			shell,
			JavaUIMessages.Spelling_add_askToConfigure_title,
			JavaUIMessages.Spelling_add_askToConfigure_question,
			JavaUIMessages.Spelling_add_askToConfigure_ignoreMessage,
			false,
			null,
			null);

	PreferenceConstants.getPreferenceStore().setValue(PREF_KEY_DO_NOT_ASK, toggleDialog.getToggleState());

	return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:22,代碼來源:AddWordProposal.java

示例15: canDoAction

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
@Override
protected boolean canDoAction() {
    final IPreferenceStore store = org.search.niem.uml.papyrus.Activator.getPlugin().getPreferenceStore();
    if (store.getBoolean(P_DISPLAY_MESSAGE_FOR_HIDE_ACTION)) {
        final MessageDialogWithToggle toggle = MessageDialogWithToggle.openYesNoQuestion(Display.getDefault()
                .getActiveShell(), Activator.INSTANCE.getString("_UI_HideCommandHandler_title"), Activator.INSTANCE
                .getString("_UI_HideCommandHandler_message"), Activator.INSTANCE
                .getString("_UI_HideCommandHandler_toggleMessage"), false, null, null);
        store.setValue(P_DISPLAY_MESSAGE_FOR_HIDE_ACTION, !toggle.getToggleState());
        return toggle.getReturnCode() == IDialogConstants.YES_ID;
    }
    return true;
}
 
開發者ID:info-sharing-environment,項目名稱:NIEM-Modeling-Tool,代碼行數:14,代碼來源:DeleteFromDiagramCommandHandler.java


注:本文中的org.eclipse.jface.dialogs.MessageDialogWithToggle.openYesNoQuestion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。