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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

Constant for the error image, or a simple dialog with the error image and a single OK button (value 1).

Usage

From source file:org.eclipse.b3.build.ui.dialogs.B3MessageDialog.java

License:Open Source License

public static void openMultiStatusError(Shell parent, String title, String message, IStatus status,
        int defaultIndex) {
    String[] labels;/* w ww .  j a  va 2  s  .c o  m*/
    if (status == null || status.isOK()) {
        labels = new String[] { IDialogConstants.OK_LABEL };
        defaultIndex = 0;
    } else {
        labels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.SHOW_DETAILS_LABEL };
        defaultIndex = 0;
    }

    B3MessageDialog dialog = new B3MessageDialog(parent, title, null, // accept the default window icon
            message, status, MessageDialog.ERROR, labels, defaultIndex);
    if (status != null && !status.isOK()) {
        dialog.setDetailButton(1);
    }
    dialog.open();

}

From source file:org.eclipse.b3.build.ui.dialogs.B3MessageDialog.java

License:Open Source License

/**
 * Convenience method to open an error dialog with a stack trace
 * /* w  w w.  j a  v  a 2  s  .c om*/
 * @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 detail
 *            the error
 * @param defaultIndex
 *            the default index of the button to select
 * @return <code>true</code> if the user presses the OK button, <code>false</code> otherwise
 */
public static void openStackTrace(Shell parent, String title, String message, Throwable detail,
        int defaultIndex) {
    String[] labels;
    if (detail == null) {
        labels = new String[] { IDialogConstants.OK_LABEL };
        defaultIndex = 0;
    } else {
        labels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.SHOW_DETAILS_LABEL };
        defaultIndex = 0;
    }

    B3MessageDialog dialog = new B3MessageDialog(parent, title, null, // accept the default window icon
            message, detail, MessageDialog.ERROR, labels, defaultIndex);
    if (detail != null) {
        dialog.setDetailButton(1);
    }
    dialog.open();
}

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

License:Open Source License

public void run() {
    Object selection = getSelection();
    if (selection instanceof StructuredSelection) {
        selection = ((StructuredSelection) selection).getFirstElement();
    }/*from w  ww.j  a v  a  2 s.c  o m*/
    if (selection instanceof OdaDataSourceHandle) {
        try {
            DesignSessionRequest designSessionRequest = DTPUtil.getInstance()
                    .createDesignSessionRequest((OdaDataSourceHandle) selection);

            if (designSessionRequest.getDataSourceDesign().hasLinkToProfile()) {
                MessageDialog errorDialog = new MessageDialog(UIUtil.getDefaultShell(),
                        Messages.getString("datasource.exprotToCP.title"), null,
                        Messages.getFormattedString("datasource.exportToCP.error.alreadyExported",
                                new Object[] { ((OdaDataSourceHandle) selection).getName() }),
                        MessageDialog.ERROR, new String[] { BUTTON_OK }, 0);

                errorDialog.open();
                return;
            }
            ExportDataSourceDialog dialog = new ExportDataSourceDialog(
                    PlatformUI.getWorkbench().getDisplay().getActiveShell(),
                    Messages.getString("datasource.exprotToCP.title"), (DataSourceHandle) selection);

            if (dialog.open() == Dialog.OK) {
                OdaDesignSession session = DataSourceDesignSession.convertDesignToLinkedProfile(
                        designSessionRequest, dialog.getProfileName(), dialog.isExternalToCP(),
                        dialog.doesCreateProfileStore(),
                        PlatformUI.getWorkbench().getDisplay().getActiveShell());
                DTPUtil.getInstance().updateDataSourceHandle(session.getResponse(),
                        session.getRequestDataSourceDesign(), (OdaDataSourceHandle) selection);
            }
        } catch (Exception ex) {
            ExceptionHandler.handle(ex);
        }
    }
}

From source file:org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyPart.java

License:Open Source License

public void generateErrorDialog(String message) {
    MessageDialog messageDialog = new MessageDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
            DisassemblyMessages.Disassembly_Error_Dialog_title, null, message, MessageDialog.ERROR,
            new String[] { DisassemblyMessages.Disassembly_Error_Dialog_ok_button }, 0);
    messageDialog.open();//from   w  w  w . ja va 2 s .  c o  m
}

From source file:org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry.java

License:Open Source License

/**
 * Log the status and inform the user about a misbehaving extension.
 * /*w  w  w .  ja v a 2 s .  c o  m*/
 * @param descriptor the descriptor of the misbehaving extension
 * @param status a status object that will be logged
 */
void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    CUIPlugin.log(status);
    String title = ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
    CompletionProposalCategory category = descriptor.getCategory();
    IContributor culprit = descriptor.getContributor();
    Set<String> affectedPlugins = getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName = culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty()) {
        if (CUIPlugin.PLUGIN_ID.equals(culpritName)) {
            // don't warn about internal computers
            return;
        }
        avoidHint = Messages.format(
                ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
                new Object[] { culpritName, category.getDisplayName() });
    } else {
        avoidHint = Messages.format(
                ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
                new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) });
    }
    String message = status.getMessage();
    // inlined from MessageDialog.openError
    MessageDialog dialog = new MessageDialog(CUIPlugin.getActiveWorkbenchShell(), title,
            null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL },
            0) {
        @Override
        protected Control createCustomArea(Composite parent) {
            Link link = new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil
                            .createPreferenceDialogOn(getShell(),
                                    "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                            .open();
                }
            });
            GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
    };
    dialog.open();
}

From source file:org.eclipse.datatools.connectivity.oda.design.internal.ui.profile.ProfileStoreCreationDialog.java

License:Open Source License

private boolean validateFileExtension(File file, String defaultExtension) {
    String fileName = file.getName();

    int lastIndex = fileName.lastIndexOf(EXT_SEPARATOR);
    if (lastIndex >= 0 && fileName.length() > lastIndex + 1) // file has file extension
        return true;

    // raise error dialog about missing file extension in the file name
    String[] dialogLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    MessageDialog dialog = new MessageDialog(getShell(), Messages.ui_errorLabel, null,
            Messages.bind(Messages.profileStoreCreationDialog_fileext_error, defaultExtension),
            MessageDialog.ERROR, dialogLabels, 0);

    int response = dialog.open();
    if (response != 0) // user presses Cancel
        return false;

    // user presses Ok,
    // append the default extension to the user-input file path
    String userFilePathText = super.getFilePathText();
    StringBuilder revisedFilePathText = new StringBuilder(userFilePathText);
    if (!userFilePathText.endsWith(EXT_SEPARATOR))
        revisedFilePathText.append(EXT_SEPARATOR);
    revisedFilePathText.append(defaultExtension);

    super.setFilePathText(revisedFilePathText.toString());
    return false; // requires user to verify the filePath and press Ok to continue
}

From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.routineeditor.action.EditRoutineInFormAction.java

License:Open Source License

private void objectNotFound() {
    ExamplePlugin.getDisplay().syncExec(new Runnable() {
        public void run() {
            String[] buttons = new String[] { IDialogConstants.OK_LABEL };
            MessageDialog d = new MessageDialog(ExamplePlugin.getActiveWorkbenchShell(),
                    org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.routineeditor.action.Messages.EditRoutineObjectAction_obj_not_found,
                    null,/*from   w  w  w. j a  v a  2  s .c  o m*/
                    NLS.bind(
                            org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.routineeditor.action.Messages.EditRoutineObjectAction_obj_not_found_detail,
                            _sqlObject.getName()),
                    MessageDialog.ERROR, buttons, 0);
            d.open();
        }
    });
}

From source file:org.eclipse.datatools.enablement.sybase.asa.schemaobjecteditor.examples.tableeditor.action.EditASATableAction.java

License:Open Source License

public void run(IProgressMonitor monitor) {
    init();//from w  ww  .j  ava2  s.c  om

    if (_table.getColumns().size() == 0) {
        ExamplePlugin.getStandardDisplay().syncExec(new Runnable() {
            public void run() {
                String[] buttons = new String[] { IDialogConstants.OK_LABEL };
                MessageDialog d = new MessageDialog(ExamplePlugin.getActiveWorkbenchShell(),
                        Messages.EditASATableAction_obj_not_found, null,
                        NLS.bind(Messages.EditASATableAction_obj_not_found_detail, _table.getName()),
                        MessageDialog.ERROR, buttons, 0);
                d.open();
            }
        });
        return;
    }

    // The monitor is already there
    monitor.beginTask(_taskTitle, monitor.UNKNOWN);
    monitor.subTask(Messages.EditASATableAction_read_objects);

    // Start to collect additional objects
    Map additionalObjs = new HashMap();

    collectPrimaryTable(additionalObjs);

    // Check point 1
    if (monitor.isCanceled()) {
        return;
    }

    collectionAuthIds(additionalObjs);

    // Check point 2
    if (monitor.isCanceled()) {
        return;
    }

    collectIndexes(additionalObjs);

    // FIX475744-2: don't clone UDT due to performance issue
    // collectUDTs(additionalObjs);

    monitor.worked(3);

    // Check point 3
    if (monitor.isCanceled()) {
        return;
    }
    // Finish collecting additional objects

    monitor.subTask(Messages.EditASATableAction_read_objects);
    ASATableSchemaImmutableModel editorModel = new ASATableSchemaImmutableModel((BaseTable) _table,
            additionalObjs);

    DatabaseIdentifier di = new DatabaseIdentifier(
            ModelUtil.getConnectionProfile(_table.getSchema().getDatabase()).getName(),
            _table.getSchema().getCatalog().getName());
    ASATableSchemaEditModel editModel = new ASATableSchemaEditModel(editorModel, di);
    setModelObj(editModel);
    monitor.worked(5);

    // Check point 4
    if (monitor.isCanceled()) {
        return;
    }

    monitor.subTask(Messages.EditASATableAction_initializing);
    ExamplePlugin.getStandardDisplay().syncExec(new Runnable() {
        public void run() {
            checkAndOpenEditor();
            ISchemaObjectEditModel obj = (ISchemaObjectEditModel) getModelObj();
            IEditorPart part = getPart();
            if (part != null && (part instanceof ISchemaObjectEditor)) {
                ((ISchemaObjectEditor) part).setEditorPartName(obj.getMainSQLObject().getName());
            }
            setActivePage();
        }
    });
    monitor.worked(2);
    monitor.done();
}

From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.action.EditSchemaObjectAction.java

License:Open Source License

public void checkAndOpenEditor() {
    if (_modelObj == null) {
        String[] buttons = new String[] { IDialogConstants.OK_LABEL };
        MessageDialog d = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(),
                Messages.EditSchemaObjectAction_error, null, Messages.EditSchemaObjectAction_model_null,
                MessageDialog.ERROR, buttons, 0);
        d.open();/*  w  w  w.j  a  v  a 2  s. co m*/
        return;
    }

    // open the editor using editor id
    if (_editorId != null && _editorId.trim().length() != 0) {
        _part = SchemaObjectEditorUtils.openEditor(_editorId, _modelObj, _databaseIdentifier);
    }

    if (_vendorName == null || _version == null || _objectTypeId == null || _databaseIdentifier == null) {
        boolean calculated = false;
        if (_sqlObject != null) {
            Object root = ContainmentServiceImpl.INSTANCE.getRootElement(_sqlObject);
            if (root != null && root instanceof Database) {
                calculated = true;
                Database db = (Database) root;
                if (_vendorName == null) {
                    _vendorName = db.getVendor();
                }
                if (_version == null) {
                    _version = db.getVersion();
                }
                if (_databaseIdentifier == null) {
                    SQLDevToolsUtil.getDatabaseIdentifier(_sqlObject);
                }
                if (_objectTypeId == null) {
                    _objectTypeId = _sqlObject.eClass().getEPackage().getName() + "."
                            + _sqlObject.eClass().getName();
                }
            }
        } else if (!calculated) {
            String[] buttons = new String[] { IDialogConstants.OK_LABEL };
            MessageDialog d = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(),
                    Messages.EditSchemaObjectAction_error, null, Messages.EditSchemaObjectAction_no_vendor_name,
                    MessageDialog.ERROR, buttons, 0);
            d.open();
            return;
        }
    }

    _part = SchemaObjectEditorUtils.openEditor(_vendorName, _version, _objectTypeId, _modelObj,
            _databaseIdentifier);
}

From source file:org.eclipse.datatools.sqltools.schemaobjecteditor.ui.core.DefaultSchemaObjectEditorHandler.java

License:Open Source License

private void promptObjectLost(final ISchemaObjectEditModel editModel) {
    SOEUIPlugin.getActiveWorkbenchShell().getDisplay().syncExec(new Runnable() {
        public void run() {
            String[] buttons = new String[] { IDialogConstants.OK_LABEL };
            MessageDialog d = new MessageDialog(SOEUIPlugin.getActiveWorkbenchShell(),
                    Messages.AbstractSchemaObjectEditModel_fatal_error, null,
                    Messages.bind(Messages.AbstractSchemaObjectEditModel_main_object_lost,
                            editModel.getMainSQLObject().getName()),
                    MessageDialog.ERROR, buttons, 0);
            d.open();/*from   ww w . ja  va  2s . co m*/
            return;
        }
    });
}