Example usage for org.eclipse.jface.dialogs IDialogConstants YES_ID

List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_ID

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants YES_ID.

Prototype

int YES_ID

To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_ID.

Click Source Link

Document

Button id for a "Yes" button (value 2).

Usage

From source file:org.eclipse.epf.authoring.ui.dialogs.SwitchConfigDialog.java

License:Open Source License

/**
 * Displays the dialog iff the given recommendedConfig is different than the
 * currently selected config//from  w  w  w .j  a  v a2 s  . com
 * 
 * returns IDialogConstants.OK_ID if dialog wasn't shown, or if config was
 * switched returns IDialogConstants.CANCEL_ID if dialog was shown and user
 * did not click Yes
 */
public void execute() {
    Display display = shell != null ? shell.getDisplay() : null;
    if (display == null) {
        display = MsgBox.getDisplay();
    }
    if (display == null) {
        // could not get display
        return;
    }
    display.asyncExec(new Runnable() {
        public void run() {
            Object obj = null;
            if (part instanceof AbstractDiagramEditor) {
                if (((AbstractDiagramEditor) part).isDisposed()) {
                    return;
                }
                BreakdownElementEditorInput input = (BreakdownElementEditorInput) ((IEditorPart) part)
                        .getEditorInput();
                if (input.getSuppression().getProcess() != null) {
                    obj = input.getSuppression().getProcess().eContainer();
                }
            } else if (part instanceof ProcessEditor) {
                if (((ProcessEditor) part).isDisposed()) {
                    return;
                }
                obj = EditorChooser.getInstance().getMethodEditorInput(part);
            }
            if (obj != null && obj instanceof ProcessComponent) {
                MethodConfiguration recommendedConfig = ((ProcessComponent) obj).getProcess()
                        .getDefaultContext();
                if (recommendedConfig instanceof Scope || recommendedConfig == null) {
                    return;
                }

                String switchConfigPref = LibraryUIPreferences.getSwitchConfig();
                if (MessageDialogWithToggle.NEVER.equals(switchConfigPref)) {
                    // Call this to refresh active part if needed.
                    // TODO: Review implementation.
                    //                  LibraryService.getInstance().setCurrentMethodConfiguration(
                    //                        LibraryService.getInstance()
                    //                              .getCurrentMethodConfiguration());
                    return;
                }
                if (LibraryService.getInstance().getCurrentMethodConfiguration() != recommendedConfig) {
                    final String configName = recommendedConfig.getName();
                    if (MessageDialogWithToggle.PROMPT.equals(switchConfigPref)) {
                        MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(shell,
                                LibraryUIResources.switchConfigDialog_title,
                                LibraryUIResources.bind(LibraryUIResources.switchConfigDialog_text, configName),
                                null, false, LibraryUIPlugin.getDefault().getPreferenceStore(),
                                LibraryUIPreferences.getSwitchConfigPreferenceKey());
                        if (dialog.getReturnCode() == IDialogConstants.YES_ID) {
                            MethodConfiguration config = LibraryServiceUtil.getMethodConfiguration(
                                    LibraryService.getInstance().getCurrentMethodLibrary(), configName);
                            LibraryService.getInstance().setCurrentMethodConfiguration(config);
                        } else {
                            // Call this to refresh active part if needed.
                            // TODO: Review implementation.
                            LibraryService.getInstance().setCurrentMethodConfiguration(
                                    LibraryService.getInstance().getCurrentMethodConfiguration());
                        }

                    } else if (MessageDialogWithToggle.ALWAYS.equals(switchConfigPref)) {
                        MethodConfiguration config = LibraryServiceUtil.getMethodConfiguration(
                                LibraryService.getInstance().getCurrentMethodLibrary(), configName);
                        LibraryService.getInstance().setCurrentMethodConfiguration(config);
                    }
                }
            }
        }
    });
}

From source file:org.eclipse.epf.diagram.ad.edit.policies.UMLReferenceConnectionEditPolicy.java

License:Open Source License

/**
 * @generated/*  ww  w .jav a  2s . com*/
 */
private boolean showMessageDialog() {
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
            Display.getCurrent().getActiveShell(), DELETE_FROM_DIAGRAM_DLG_TITLE,
            DELETE_FROM_DIAGRAM_DLG_MESSAGE, DELETE_FROM_MODEL_DLG_TOGGLE_LABEL, false,
            (IPreferenceStore) ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint()
                    .getPreferenceStore(),
            IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM);
    if (dialog.getReturnCode() == IDialogConstants.YES_ID)
        return true;
    else
        return false;
}

From source file:org.eclipse.equinox.internal.p2.ui.sdk.SDKPolicy.java

License:Open Source License

public boolean continueWorkingOperation(ProfileChangeOperation operation, Shell shell) {
    // don't continue if superclass has already identified problem scenarios
    boolean ok = super.continueWorkingWithOperation(operation, shell);
    if (!ok)/*ww w.ja  v  a 2  s  .  c  om*/
        return false;

    IProvisioningPlan plan = operation.getProvisioningPlan();
    if (plan == null)
        return false;

    // Check the preference to see whether to continue.
    IPreferenceStore prefs = ProvSDKUIActivator.getDefault().getPreferenceStore();
    String openPlan = prefs.getString(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);
    if (MessageDialogWithToggle.ALWAYS.equals(openPlan)) {
        return true;
    }
    if (MessageDialogWithToggle.NEVER.equals(openPlan)) {
        StatusManager.getManager().handle(plan.getStatus(), StatusManager.SHOW | StatusManager.LOG);
        return false;
    }
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell,
            ProvSDKMessages.ProvSDKUIActivator_Question, ProvSDKMessages.ProvSDKUIActivator_OpenWizardAnyway,
            null, false, prefs, PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN);

    // Any answer but yes will stop the performance of the plan, but NO is interpreted to mean, show me the error.
    if (dialog.getReturnCode() == IDialogConstants.NO_ID)
        StatusManager.getManager().handle(plan.getStatus(), StatusManager.SHOW | StatusManager.LOG);
    return dialog.getReturnCode() == IDialogConstants.YES_ID;
}

From source file:org.eclipse.gmf.runtime.diagram.ui.editpolicies.ComponentEditPolicy.java

License:Open Source License

/**
 * launches the prompting dialogBox on deletion of elements from the diagram for the end user.
 * /* ww w.  j ava2  s  .c o  m*/
 * @return boolean  true if user pressed YES; false otherwise
 */
private boolean showMessageDialog() {
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
            Display.getCurrent().getActiveShell(), DELETE_FROM_DIAGRAM_DLG_TITLE,
            DELETE_FROM_DIAGRAM_DLG_MESSAGE, DELETE_FROM_MODEL_DLG_TOGGLE_LABEL, false,
            (IPreferenceStore) ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint()
                    .getPreferenceStore(),
            IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_DIAGRAM);

    if (dialog.getReturnCode() == IDialogConstants.YES_ID)
        return true;
    else
        return false;
}

From source file:org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy.java

License:Open Source License

/**
 * launches the prompting dialogBox on deletion of elements from the model
 * for the end user.//from   ww  w.  jav  a2 s. c  om
 * 
 * @return boolean true if user pressed YES; false otherwise
 */
private boolean showMessageDialog() {
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
            Display.getCurrent().getActiveShell(), DELETE_FROM_MODEL_DLG_TITLE, DELETE_FROM_MODEL_DLG_MESSAGE,
            DELETE_FROM_MODEL_DLG_TOGGLE_LABEL, false, (IPreferenceStore) ((IGraphicalEditPart) getHost())
                    .getDiagramPreferencesHint().getPreferenceStore(),
            IPreferenceConstants.PREF_PROMPT_ON_DEL_FROM_MODEL);

    if (dialog.getReturnCode() == IDialogConstants.YES_ID)
        return true;
    else
        return false;
}

From source file:org.eclipse.jpt.jaxb.ui.internal.ClassesGeneratorUi.java

License:Open Source License

private boolean displayOverwritingClassesWarning(ClassesGeneratorOptions generatorOptions) {

    if (!this.isOverwritingClasses(generatorOptions)
            || !OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
        return true;
    } else {//from w  w  w  .  j a v a2s  .co m
        OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getShell());
        return dialog.open() == IDialogConstants.YES_ID;
    }
}

From source file:org.eclipse.jpt.jaxb.ui.internal.wizards.classesgen.ClassesGeneratorWizard.java

License:Open Source License

private boolean displayOverwritingClassesWarning(ClassesGeneratorOptions generatorOptions) {

    if (!this.isOverridingClasses(generatorOptions)
            || !OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
        return true;
    } else {/*from   w w  w  .  java 2 s.  c  om*/
        OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getShell());
        return dialog.open() == IDialogConstants.YES_ID;
    }
}

From source file:org.eclipse.jpt.jpa.eclipselink.ui.internal.ddlgen.wizards.EclipseLinkGenerateDDLWizard.java

License:Open Source License

private boolean displayGeneratingDDLWarning() {
    if (!OptionalMessageDialog.isDialogEnabled(OverwriteConfirmerDialog.ID)) {
        return true;
    } else {//from   w  w w . j a v a  2s  .c  om
        OverwriteConfirmerDialog dialog = new OverwriteConfirmerDialog(this.getCurrentShell());
        return dialog.open() == IDialogConstants.YES_ID;
    }
}

From source file:org.eclipse.jpt.jpa.eclipselink.ui.internal.wizards.conversion.java.EclipseLinkJavaMetadataConversionWizardPage.java

License:Open Source License

/**
 * Return whether the user wants to continue the conversion even though
 * the persistence unit contains "equivalent" Java metadata (e.g. one or
 * more of the Java queries are "equivalent").
 *///  w  w  w.  ja va 2  s. c  o m
protected boolean userWantsToContinueWithEquivalentJavaMetadata() {
    if (!OptionalMessageDialog.isDialogEnabled(EquivalentJavaMetadataWarningDialog.ID)) {
        return true; // ?
    }
    MessageDialog dialog = this.buildEquivalentJavaMetadataWarningDialog();
    return dialog.open() == IDialogConstants.YES_ID;
}

From source file:org.eclipse.jsch.ui.UserInfoPrompter.java

License:Open Source License

public boolean promptYesNo(String question) {
    int prompt = prompt(MessageDialog.QUESTION, Messages.UserInfoPrompter_0, question,
            new int[] { IDialogConstants.YES_ID, IDialogConstants.NO_ID }, 0 // yes
    // the// www. j  av a 2 s.c  om
    // default
    );
    return prompt == 0;
}