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:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformWidget.java

License:Apache License

/** 
 * @param inputLinkSchema//www  . jav  a 2 s .c om
 * @param currentCompSchema
 */
private boolean compareSchemaFields(List<GridRow> inputLinkSchema, List<GridRow> currentCompSchema) {
    for (int index = 0; index < currentCompSchema.size() - 1; index++) {
        for (GridRow gridRow : inputLinkSchema) {
            if (StringUtils.equals(gridRow.getFieldName(), currentCompSchema.get(index).getFieldName())) {
                if (!StringUtils.equals(gridRow.getDataTypeValue(),
                        currentCompSchema.get(index).getDataTypeValue())) {
                    MessageDialog dialog = new MessageDialog(new Shell(), "Warning", null,
                            "Output Schema is updated,Do you want to continue with changes?",
                            MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0);
                    int dialogResult = dialog.open();
                    if (dialogResult == 0) {
                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.ELTSchemaGridWidget.java

License:Apache License

private void propagateInternalSchema() {
    if (schemaGridRowList != null) {
        if (SchemaSyncUtility.INSTANCE.isAutoSchemaSyncAllow(getComponent().getComponentName())) {

            if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInMappingWidget(getComponent(),
                    schemaGridRowList)) {

                MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null,
                        Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM,
                        new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0);
                if (dialog.open() == 0) {
                    if (isSchemaUpdated)
                        SchemaSyncUtility.INSTANCE.pushSchemaToMapping(getComponent(), schemaGridRowList);
                    else
                        updateSchemaWithPropogatedSchema();
                }/*from   w ww.  j av a  2s.c  o m*/
            }
        }

    }
}

From source file:hydrograph.ui.propertywindow.widgets.utility.SchemaSyncUtility.java

License:Apache License

public void autoSyncSchema(Schema SchemaForInternalPropagation, Component component,
        List<AbstractWidget> widgets) {
    if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInSchemaTab(SchemaForInternalPropagation.getGridRow(),
            (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME))) {
        MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null,
                Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM,
                new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0);
        if (dialog.open() == 0) {
            getSchemaGridWidget(widgets).updateSchemaWithPropogatedSchema();
        }/*from  ww  w.java2  s. c  o m*/
    }
}

From source file:org.bbaw.pdr.ae.view.main.commands.ChangeUserHandler.java

License:Open Source License

/**
 * execute method.//from   w  w  w.  ja  v a2  s  . co m
 * @param event to be executed.
 * @throws ExecutionException ee.
 * @return null.
 */

@Override
public final Object execute(final ExecutionEvent event) throws ExecutionException {

    String message = NLMessages.getString("Commandsr_current_user") + _facade.getCurrentUser().getDisplayName();
    message += "\n" + NLMessages.getString("Commandsr_user_id") //$NON-NLS-1$
            + _facade.getCurrentUser().getPdrId().toString();
    message += "\n\n" + NLMessages.getString("Commandsr_question_login_as_other"); //$NON-NLS-1$
    MessageDialog messageDialog = new MessageDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            NLMessages.getString("Commandsr_current_user_data"), null, message, MessageDialog.CONFIRM,
            new String[] { NLMessages.getString("Commandsr_ok"), NLMessages.getString("Handler_cancel") }, 1); //$NON-NLS-2$
    if (messageDialog.open() == 0) {
        LoginDialog dialog = new LoginDialog(null, true);
        dialog.create();
        dialog.focusOkButton();
        dialog.open();

    }
    // System.out.println("!!!!!!!!!!!!!!!!!!!!! bevor test");
    // IEvaluationService es = (IEvaluationService)
    // HandlerUtil.getActiveWorkbenchWindow(event).
    // getService(IEvaluationService.class);
    // es.requestEvaluation("org.bbaw.pdr.ae.view.rights.userIsAdmin");
    //
    // IEvaluationService service = (IEvaluationService)
    // PlatformUI.getWorkbench().getService(IEvaluationService.class);
    // service.requestEvaluation("org.bbaw.pdr.ae.view.rights.userIsAdmin");
    //
    // System.out.println("!!!!!!!!!!!!!!!!!!!!! nach test");

    return null;
}

From source file:org.bonitasoft.studio.common.diagram.tools.CustomDiagramGraphicalViewerKeyHandler.java

License:Open Source License

@Override
public boolean keyPressed(KeyEvent event) {
    if (event.keyCode == 127) {
        GraphicalEditPart part = (GraphicalEditPart) getFocusEditPart();
        Widget widget = (Widget) part.resolveSemanticElement();
        String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
        List<Object> widgetSelected = new ArrayList<Object>();
        widgetSelected.add(widget);/*w w  w. j ava2  s .  c  o  m*/
        OutlineDialog dialog = new OutlineDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.deleteFormFieldDialogTitle, Display.getCurrent().getSystemImage(SWT.ICON_WARNING),
                Messages.bind(Messages.askConfirmationForDeleting, widget.getName()), MessageDialog.CONFIRM,
                buttonList, 1, widgetSelected);
        int ok = 0;
        RemoveWidgetReferencesOperation op = new RemoveWidgetReferencesOperation(
                ModelHelper.getPageFlow(widget), widget);
        if (ok == dialog.open()) {
            CompoundCommand cc = new CompoundCommand();
            op.setCompoundCommand(cc);
            op.updateReferencesInScripts();
            IProgressService service = PlatformUI.getWorkbench().getProgressService();
            try {
                service.busyCursorWhile(op);

            } catch (InvocationTargetException e) {
                BonitaStudioLog.error(e);
            } catch (InterruptedException e) {
                BonitaStudioLog.error(e);
            }
            if (!op.isCanExecute()) {
                event.doit = false;
                return false;
            }

        } else {
            event.doit = false;
            return false;
        }
    }
    return super.keyPressed(event);
}

From source file:org.bonitasoft.studio.data.ui.property.section.AbstractDataSection.java

License:Open Source License

protected void removeData(IStructuredSelection structuredSelection) {
    String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    OutlineDialog dialog = new OutlineDialog(Display.getDefault().getActiveShell(),
            Messages.deleteDataDialogTitle, Display.getCurrent().getSystemImage(SWT.ICON_WARNING),
            createMessage(structuredSelection), MessageDialog.CONFIRM, buttonList, 1,
            structuredSelection.toList());
    if (dialog.open() == Dialog.OK) {
        IProgressService service = PlatformUI.getWorkbench().getProgressService();
        CompoundCommand cc = new CompoundCommand("Remove list of data");
        boolean canExecute = false;
        for (Object d : structuredSelection.toList()) {
            RefactorDataOperation op = new RefactorDataOperation(
                    BonitaGroovyRefactoringAction.REMOVE_OPERATION);
            op.setCompoundCommand(cc);/*from  w ww . ja v a2s .  c  om*/
            op.setContainer(ModelHelper.getParentProcess(eObject));
            op.setEditingDomain(getEditingDomain());
            op.setOldData((Data) d);
            op.updateReferencesInScripts();
            try {
                if (op.isCanExecute()) {
                    service.run(true, false, op);
                    cc.append(DeleteCommand.create(getEditingDomain(), d));
                    canExecute = canExecute || true;
                } else {
                    canExecute = canExecute || false;
                }
            } catch (InvocationTargetException e) {
                BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
            } catch (InterruptedException e) {
                BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
            }
        }
        if (canExecute) {
            getEditingDomain().getCommandStack().execute(cc);
        } else {
            cc.dispose();
        }
        try {
            RepositoryManager.getInstance().getCurrentRepository().getProject().build(
                    IncrementalProjectBuilder.FULL_BUILD, XtextProjectHelper.BUILDER_ID,
                    new HashMap<String, String>(), null);
        } catch (CoreException e) {
            BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
        }
    }
}

From source file:org.bonitasoft.studio.data.ui.property.section.RemoveDataHandler.java

License:Open Source License

public void execute(final IStructuredSelection structuredSelection, final EObject container,
        final EStructuralFeature dataFeature) {
    final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    final OutlineDialog dialog = new OutlineDialog(Display.getDefault().getActiveShell(),
            org.bonitasoft.studio.common.Messages.removalConfirmationDialogTitle,
            Display.getCurrent().getSystemImage(SWT.ICON_WARNING), createMessage(structuredSelection),
            MessageDialog.CONFIRM, buttonList, 1, structuredSelection.toList());
    if (dialog.open() == Dialog.OK) {
        final IProgressService service = PlatformUI.getWorkbench().getProgressService();
        final RefactorDataOperation op = new RefactorDataOperation(RefactoringOperationType.REMOVE);
        for (final Object d : structuredSelection.toList()) {
            op.setEditingDomain(TransactionUtil.getEditingDomain(container));
            op.addItemToRefactor(null, (Data) d);
            op.setDataContainer((DataAware) container);
            op.setDataContainmentFeature(dataFeature);
            op.setAskConfirmation(true);
        }/*from   ww w  . ja v a2s  . co m*/
        try {
            if (op.canExecute()) {
                service.run(true, true, op);
            }
        } catch (final InvocationTargetException e) {
            BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
        } catch (final InterruptedException e) {
            BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
        }
        try {
            RepositoryManager.getInstance().getCurrentRepository().getProject().build(
                    IncrementalProjectBuilder.FULL_BUILD, XTEXT_BUILDER_ID,
                    Collections.<String, String>emptyMap(), null);
        } catch (final CoreException e) {
            BonitaStudioLog.error(e, DataPlugin.PLUGIN_ID);
        }
    }
}

From source file:org.bonitasoft.studio.document.ui.DocumentPropertySection.java

License:Open Source License

private int openOutlineDialog(final IStructuredSelection selection) {
    final StringBuilder sb = new StringBuilder();
    for (final Object selectionElement : selection.toList()) {
        if (selectionElement instanceof Document) {
            sb.append(((Document) selectionElement).getName() + "\n");
        }/* w  w w  . jav  a  2 s  . co  m*/
    }
    if (sb.length() > 0) {
        sb.delete(sb.length() - 1, sb.length());
    }
    final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    final java.util.List<Object> selectionList = ((IStructuredSelection) documentListViewer.getSelection())
            .toList();
    final OutlineDialog dialog = new OutlineDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), removalConfirmationDialogTitle,
            Display.getCurrent().getSystemImage(SWT.ICON_WARNING),
            NLS.bind(Messages.areYouSureMessage, sb.toString()), MessageDialog.CONFIRM, buttonList, 1,
            selectionList);
    return dialog.open();
}

From source file:org.bonitasoft.studio.parameters.property.section.ParameterPropertySection.java

License:Open Source License

protected void createRemoveParameterButton(final Composite buttonsComposite) {
    removeButton = widgetFactory.createButton(buttonsComposite, Messages.remove, SWT.FLAT);
    removeButton.setLayoutData(GridDataFactory.fillDefaults().hint(85, SWT.DEFAULT).create());
    removeButton.addSelectionListener(new SelectionAdapter() {

        @Override//from www  .j  a  v  a2 s .com
        public void widgetSelected(final SelectionEvent e) {
            final IStructuredSelection selection = (IStructuredSelection) parameterTableViewer.getSelection();
            final StringBuilder sb = new StringBuilder();
            for (final Object selectionElement : selection.toList()) {
                if (selectionElement instanceof Parameter) {
                    sb.append(((Parameter) selectionElement).getName() + "\n");
                }
            }
            if (sb.length() > 0) {
                sb.delete(sb.length() - 1, sb.length());
            }
            final String[] buttonList = { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
            final List<Object> selectionList = ((IStructuredSelection) parameterTableViewer.getSelection())
                    .toList();
            final OutlineDialog dialog = new OutlineDialog(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    removalConfirmationDialogTitle, Display.getCurrent().getSystemImage(SWT.ICON_WARNING),
                    NLS.bind(Messages.areYouSureMessage, sb.toString()), MessageDialog.CONFIRM, buttonList, 1,
                    selectionList);
            final int ok = 0;
            if (ok == dialog.open()) {
                for (final Object parameter : selection.toList()) {
                    final RemoveParametersOperation op = new RemoveParametersOperation((Parameter) parameter,
                            (AbstractProcess) getEObject());
                    op.setEditingDomain(getEditingDomain());
                    op.setAskConfirmation(true);
                    final IProgressService service = PlatformUI.getWorkbench().getProgressService();
                    try {
                        service.busyCursorWhile(op);
                    } catch (final InvocationTargetException ex) {
                        BonitaStudioLog.error(ex);
                    } catch (final InterruptedException ex) {
                        BonitaStudioLog.error(ex);
                    }
                }
                parameterTableViewer.refresh();
                try {
                    RepositoryManager.getInstance().getCurrentRepository().getProject().build(
                            IncrementalProjectBuilder.FULL_BUILD, XtextProjectHelper.BUILDER_ID,
                            Collections.<String, String>emptyMap(), null);
                } catch (final CoreException e1) {
                    BonitaStudioLog.error(e1, ParameterPlugin.PLUGIN_ID);
                }
            }
        }
    });

}

From source file:org.eclipse.acute.AcutePlugin.java

License:Open Source License

private static void openCommandErrorDialog(String title, String content) {
    Display.getDefault().asyncExec(() -> {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        int dialogResponse = MessageDialog.open(MessageDialog.CONFIRM, shell, title, content, SWT.NONE,
                Messages.acutePlugin_openPreferences, Messages.acutePlugin_cancel);
        if (dialogResponse == 0) {
            PreferenceDialog preferenceDialog = PreferencesUtil.createPreferenceDialogOn(shell,
                    AcutePreferencePage.PAGE_ID, new String[] { AcutePreferencePage.PAGE_ID }, null);
            preferenceDialog.setBlockOnOpen(false);
            preferenceDialog.open();//  w  w  w .j a v a 2s.  c om
        }
    });
}