Example usage for org.eclipse.jface.dialogs MessageDialog CONFIRM

List of usage examples for org.eclipse.jface.dialogs MessageDialog CONFIRM

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs MessageDialog CONFIRM.

Prototype

int CONFIRM

To view the source code for org.eclipse.jface.dialogs MessageDialog CONFIRM.

Click Source Link

Document

Constant for a simple dialog with the question image and OK/Cancel buttons (value 5).

Usage

From source file:org.eclipse.birt.report.designer.ui.actions.PublishTemplateAction.java

License:Open Source License

public void run(IAction action) {
    if (selectReport) {
        if (reportFile != null) {
            String url = reportFile.getLocation().toOSString();
            try {
                ModuleHandle handle = SessionHandleAdapter.getInstance().getSessionHandle().openDesign(url);

                //               if ( !( handle instanceof ReportDesignHandle ) )
                //               {
                //                  action.setEnabled( false );
                //                  return;
                //               }

                IEditorPart editor = UIUtil.findOpenedEditor(url);

                if (editor != null && editor.isDirty()) {
                    MessageDialog md = new MessageDialog(UIUtil.getDefaultShell(),
                            Messages.getString("PublishTemplateAction.SaveBeforeGenerating.dialog.title"), //$NON-NLS-1$
                            null,/*  w  w w .j  a v  a 2  s . c om*/
                            Messages.getFormattedString(
                                    "PublishTemplateAction.SaveBeforeGenerating.dialog.message", //$NON-NLS-1$
                                    new Object[] { reportFile.getName() }), MessageDialog.CONFIRM,
                            new String[] {
                                    Messages.getString(
                                            "PublishTemplateAction.SaveBeforeGenerating.dialog.button.yes"), //$NON-NLS-1$
                                    Messages.getString(
                                            "PublishTemplateAction.SaveBeforeGenerating.dialog.button.no") //$NON-NLS-1$
                            }, 0);
                    switch (md.open()) {
                    case 0:
                        editor.doSave(null);
                        break;
                    case 1:
                    default:
                    }
                }

                WizardDialog dialog = new BaseWizardDialog(UIUtil.getDefaultShell(),
                        new PublishTemplateWizard((ReportDesignHandle) handle));
                dialog.setPageSize(500, 250);
                dialog.open();

                handle.close();
            } catch (Exception e) {
                ExceptionHandler.handle(e);
                return;
            }
        }
    } else {
        IEditorPart editor = UIUtil.getActiveEditor(true);

        if (editor != null && editor.isDirty()) {
            MessageDialog md = new MessageDialog(UIUtil.getDefaultShell(),
                    Messages.getString("PublishTemplateAction.SaveBeforeGenerating.dialog.title"), //$NON-NLS-1$
                    null,
                    Messages.getFormattedString("PublishTemplateAction.SaveBeforeGenerating.dialog.message", //$NON-NLS-1$
                            new Object[] { editor.getTitle() }), MessageDialog.CONFIRM,
                    new String[] {
                            Messages.getString("PublishTemplateAction.SaveBeforeGenerating.dialog.button.yes"), //$NON-NLS-1$
                            Messages.getString("PublishTemplateAction.SaveBeforeGenerating.dialog.button.no") //$NON-NLS-1$
                    }, 0);
            switch (md.open()) {
            case 0:
                editor.doSave(null);
                break;
            case 1:
            default:
            }
        }

        WizardDialog dialog = new BaseWizardDialog(UIUtil.getDefaultShell(), new PublishTemplateWizard(
                (ReportDesignHandle) SessionHandleAdapter.getInstance().getReportDesignHandle()));
        dialog.setPageSize(500, 250);
        dialog.open();
    }

}

From source file:org.eclipse.birt.report.designer.ui.ide.navigator.PublishTemplateNavigatorAction.java

License:Open Source License

/**
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 *///from w  ww.  j a  va2 s. c o m
public void run(IAction action) {
    IFile file = getSelectedFile();
    if (file != null) {
        String url = file.getLocation().toOSString();
        try {
            ModuleHandle handle = SessionHandleAdapter.getInstance().getSessionHandle().openDesign(url);

            if (handle == null) {
                action.setEnabled(false);
                return;
            }

            IEditorPart editor = org.eclipse.birt.report.designer.internal.ui.util.UIUtil.findOpenedEditor(url);

            if (editor != null && editor.isDirty()) {
                MessageDialog md = new MessageDialog(UIUtil.getDefaultShell(),
                        Messages.getString("PublishTemplateAction.SaveBeforeGenerating.dialog.title"), //$NON-NLS-1$
                        null,
                        Messages.getFormattedString("PublishTemplateAction.SaveBeforeGenerating.dialog.message", //$NON-NLS-1$
                                new Object[] { file.getName() }), MessageDialog.CONFIRM,
                        new String[] {
                                Messages.getString(
                                        "PublishTemplateAction.SaveBeforeGenerating.dialog.button.yes"), //$NON-NLS-1$
                                Messages.getString(
                                        "PublishTemplateAction.SaveBeforeGenerating.dialog.button.no") //$NON-NLS-1$
                        }, 0);
                switch (md.open()) {
                case 0:
                    editor.doSave(null);
                    break;
                case 1:
                default:
                }
            }

            WizardDialog dialog = new BaseWizardDialog(UIUtil.getDefaultShell(),
                    new PublishTemplateWizard((ReportDesignHandle) handle));
            dialog.setPageSize(500, 250);
            dialog.open();

            handle.close();
        } catch (Exception e) {
            ExceptionUtil.handle(e);
            return;
        }
    } else {
        action.setEnabled(false);
    }
}

From source file:org.eclipse.e4.demo.contacts.views.DetailsView.java

License:Open Source License

@Inject
public void setSelection(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) Contact contact) {
    if (contact != null) {
        if (dirtyable.isDirty()) {
            MessageDialog dialog = new MessageDialog(detailComposite.getShell(), "Save vCard", null,
                    "The current vCard has been modified. Save changes?", MessageDialog.CONFIRM,
                    new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
            dialog.create();//from   w w  w  .j  a v a2  s  .com
            ThemeUtil.applyDialogStyles(engine, dialog.getShell());
            if (dialog.open() == Window.OK) {
                ParameterizedCommand saveCommand = commandService.createCommand("contacts.save",
                        Collections.EMPTY_MAP);
                handlerService.executeHandler(saveCommand);
            }
        }

        updatePartTitle(contact);
    } else {
        uiItem.setLabel("Details");
    }
    dirtyable.setDirty(false);
    if (!detailComposite.isDisposed()) {
        detailComposite.update(contact);
    }
}

From source file:org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.actions.ui.SynchronizerDialog.java

License:Open Source License

/**
 * Constructor.// w  w w . ja  v a 2 s .c o m
 * 
 * @param parentShell
 *            Parent shell
 * @param title
 *            Title of the dialog
 * @param message
 *            MEssage of the dialog
 * @param preferencePageID
 *            Preference page id if the dialog should have a hyperlink to a preference page or
 *            <code>null</code> otherwise
 */
public SynchronizerDialog(Shell parentShell, String title, String message, String preferencePageID) {
    super(parentShell, title, null, message, MessageDialog.CONFIRM, defaultButtonLabels, NO_BUTTON_INDEX,
            EMFCompareRCPUIMessages.getString("SynchronizerDialog.notAskAgain.label"), false); //$NON-NLS-1$
    this.preferencePageID = preferencePageID;

}

From source file:org.eclipse.emf.ecp.edit.internal.swt.controls.TableControl.java

License:Open Source License

/**
 * This method shows a user confirmation dialog when the user attempts to delete a row in the table.
 *
 * @param deletionList the list of selected EObjects to delete
 *///from  www. java  2s  . c om
protected void deleteRowUserConfirmDialog(final List<EObject> deletionList) {
    final MessageDialog dialog = new MessageDialog(tableViewer.getTable().getShell(),
            LocalizationServiceHelper.getString(getClass(), DepricatedControlMessageKeys.TableControl_Delete),
            null,
            LocalizationServiceHelper.getString(getClass(),
                    DepricatedControlMessageKeys.TableControl_DeleteAreYouSure),
            MessageDialog.CONFIRM, new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                    JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) },
            0);

    new ECPDialogExecutor(dialog) {

        @Override
        public void handleResult(int codeResult) {
            if (codeResult == IDialogConstants.CANCEL_ID) {
                return;
            }

            deleteRows(deletionList);

            final List<?> containments = (List<?>) mainSetting.get(true);
            if (containments.size() < getTableReference().getUpperBound()) {
                addButton.setEnabled(true);
            }
            if (containments.size() <= getTableReference().getLowerBound()) {
                removeButton.setEnabled(false);
            }
        }
    }.execute();
}

From source file:org.eclipse.emf.ecp.view.spi.table.swt.TableControlSWTRenderer.java

License:Open Source License

/**
 * This method shows a user confirmation dialog when the user attempts to delete a row in the table.
 *
 * @param deletionList the list of selected EObjects to delete
 * @param eObject The containment reference {@link EObject}
 * @param structuralFeature The containment reference {@link EStructuralFeature}
 * @param addButton the add button/*w  w w  .  jav a  2  s.  c  o  m*/
 * @param removeButton the remove button
 * @since 1.6
 */
protected void deleteRowUserConfirmDialog(final List<EObject> deletionList, final EObject eObject,
        final EStructuralFeature structuralFeature, final Button addButton, final Button removeButton) {
    final MessageDialog dialog = new MessageDialog(addButton.getShell(),
            LocalizationServiceHelper.getString(TableControlSWTRenderer.class, MessageKeys.TableControl_Delete),
            null,
            LocalizationServiceHelper.getString(TableControlSWTRenderer.class,
                    MessageKeys.TableControl_DeleteAreYouSure),
            MessageDialog.CONFIRM, new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                    JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) },
            0);

    new ECPDialogExecutor(dialog) {

        @Override
        public void handleResult(int codeResult) {
            if (codeResult == IDialogConstants.CANCEL_ID || codeResult == SWT.DEFAULT) { // SWT.DEFAULT is return by closing a message dialog
                return;
            }

            deleteRows(deletionList, eObject, structuralFeature);

            final List<?> containments = (List<?>) eObject.eGet(structuralFeature, true);
            if (containments.size() < structuralFeature.getUpperBound()) {
                addButton.setEnabled(true);
            }
            if (containments.size() <= structuralFeature.getLowerBound()) {
                removeButton.setEnabled(false);
            }
        }
    }.execute();
}

From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java

License:Open Source License

private static String[] getButtonLabels(final int kind) {
    String[] dialogButtonLabels;/* ww w.  j  ava 2s .c o m*/
    switch (kind) {
    case MessageDialog.ERROR:
    case MessageDialog.INFORMATION:
    case MessageDialog.WARNING: {
        dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL };
        break;
    }
    case MessageDialog.CONFIRM: {
        dialogButtonLabels = new String[] { IDialogConstants.get().OK_LABEL,
                IDialogConstants.get().CANCEL_LABEL };
        break;
    }
    case MessageDialog.QUESTION: {
        dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL };
        break;
    }
    case MessageDialog.QUESTION_WITH_CANCEL: {
        dialogButtonLabels = new String[] { IDialogConstants.get().YES_LABEL, IDialogConstants.get().NO_LABEL,
                IDialogConstants.get().CANCEL_LABEL };
        break;
    }
    default: {
        throw new IllegalArgumentException("Illegal value for kind in MessageDialog.open()");
    }
    }
    return dialogButtonLabels;
}

From source file:org.eclipse.gyrex.admin.ui.internal.widgets.NonBlockingMessageDialogs.java

License:Open Source License

public static void openConfirm(final Shell parent, final String title, final String message,
        final DialogCallback callback) {
    open(MessageDialog.CONFIRM, parent, title, message, callback);
}

From source file:org.eclipse.m2e.core.ui.internal.wizards.MavenDiscoveryProposalWizard.java

License:Open Source License

private boolean warnIncompleteMapping() {
    if (!skipIncompleteWarning()) {
        MessageDialogWithToggle dialog = MessageDialogWithToggle.open(MessageDialog.CONFIRM, getShell(),
                Messages.MavenImportWizard_titleIncompleteMapping,
                Messages.MavenImportWizard_messageIncompleteMapping,
                Messages.MavenImportWizard_hideWarningMessage, false, null, null, SWT.SHEET);
        if (dialog.getReturnCode() == Window.OK) {
            M2EUIPluginActivator.getDefault().getPreferenceStore()
                    .setValue(MavenPreferenceConstants.P_WARN_INCOMPLETE_MAPPING, dialog.getToggleState());
            return true;
        }/*w  ww  . ja  va 2 s  .c  o m*/
        return false;
    }
    return true;
}

From source file:org.eclipse.net4j.util.ui.confirmation.ConfirmationDialog.java

License:Open Source License

private ConfirmationDialog(Shell shell, String title, String message, String[] buttonLabels, int defaultIndex) {
    super(shell, title, null, message, MessageDialog.CONFIRM, buttonLabels, defaultIndex);
}