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


Java MessageDialogWithToggle.getReturnCode方法代碼示例

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


在下文中一共展示了MessageDialogWithToggle.getReturnCode方法的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: openIgnoreMessageDialogInformation

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
/**
 * Conditionally open an information message dialog. In case this is the first time this dialog is opened (defined
 * by its key), the dialog will be displayed, and a "Do not show this message again" checkbox will be available. The
 * message dialog will not be opened again when the checkbox is selected.<br>
 * Once checked, the only way to display this dialog again is by resetting the messaged through the Studio's main
 * preference page.
 * 
 * @param shell
 * @param title
 * @param message
 * @param dialogKey
 *            A dialog key that will be checked to confirm if the dialog should be diaplayed.
 * @return The dialog's return code.
 */
public static int openIgnoreMessageDialogInformation(Shell shell, String title, String message, String dialogKey)
{
	if (!shouldShowDialog(dialogKey))
	{
		return MessageDialog.CANCEL;
	}
	MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(shell, title, message,
			Messages.DialogUtils_doNotShowMessageAgain, false, null, null);
	if (dialog.getReturnCode() == Dialog.OK)
	{
		// check the toggle state to see if we need to add the dialog key to the list of hidden dialogs.
		if (dialog.getToggleState())
		{
			setShouldShowDialog(dialogKey, false);
		}
	}
	return dialog.getReturnCode();
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:33,代碼來源:DialogUtils.java

示例6: actionReimportTour_12_ConfirmDialog

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private boolean actionReimportTour_12_ConfirmDialog(final String toggleState, final String confirmMessage) {

		if (_prefStore.getBoolean(toggleState)) {

			return true;

		} else {

			final MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(//
					Display.getCurrent().getActiveShell(), //
					Messages.import_data_dlg_reimport_title, //
					confirmMessage, //
					Messages.App_ToggleState_DoNotShowAgain, //
					false, // toggle default state
					null,
					null);

			if (dialog.getReturnCode() == Window.OK) {
				_prefStore.setValue(toggleState, dialog.getToggleState());
				return true;
			}
		}

		return false;
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:26,代碼來源:RawDataManager.java

示例7: confirmUndoChanges

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
private boolean confirmUndoChanges() {

		// check if confirmation is disabled
		if (_prefStore.getBoolean(ITourbookPreferences.TOURDATA_EDITOR_CONFIRMATION_REVERT_TOUR)) {

			return true;

		} else {

			final MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(//
					Display.getCurrent().getActiveShell(), //
					Messages.tour_editor_dlg_revert_tour_title, // title
					Messages.tour_editor_dlg_revert_tour_message, // message
					Messages.tour_editor_dlg_revert_tour_toggle_message, // toggle message
					false, // toggle default state
					null,
					null);

			_prefStore.setValue(ITourbookPreferences.TOURDATA_EDITOR_CONFIRMATION_REVERT_TOUR, dialog.getToggleState());

			return dialog.getReturnCode() == Window.OK;
		}
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:24,代碼來源:TourDataEditorView.java

示例8: askUserToSwitch

import org.eclipse.jface.dialogs.MessageDialogWithToggle; //導入方法依賴的package包/類
protected static void askUserToSwitch(IWorkbenchPart part, int warningsNumber) {
    final IPreferenceStore store = FindbugsPlugin.getDefault().getPreferenceStore();
    String message = "FindBugs analysis finished, " + warningsNumber
            + " warnings found.\n\nSwitch to the FindBugs perspective?";

    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(null, "FindBugs analysis finished",
            message, "Remember the choice and do not ask me in the future", false, store,
            FindBugsConstants.ASK_ABOUT_PERSPECTIVE_SWITCH);

    boolean remember = dialog.getToggleState();
    int returnCode = dialog.getReturnCode();

    if (returnCode == IDialogConstants.YES_ID) {
        if (remember) {
            store.setValue(FindBugsConstants.SWITCH_PERSPECTIVE_AFTER_ANALYSIS, true);
        }
        switchPerspective(part);
    } else if (returnCode == IDialogConstants.NO_ID) {
        if (remember) {
            store.setValue(FindBugsConstants.SWITCH_PERSPECTIVE_AFTER_ANALYSIS, false);
        }
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:24,代碼來源:FindBugsAction.java

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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