Example usage for org.eclipse.jface.dialogs IDialogLabelKeys NO_LABEL_KEY

List of usage examples for org.eclipse.jface.dialogs IDialogLabelKeys NO_LABEL_KEY

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogLabelKeys NO_LABEL_KEY.

Prototype

String NO_LABEL_KEY

To view the source code for org.eclipse.jface.dialogs IDialogLabelKeys NO_LABEL_KEY.

Click Source Link

Document

The key used to retrieve the label for no buttons.

Usage

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
 *///  w w  w  .j  a v  a  2  s .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/*from   w  w w .  j a v  a 2s. 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.jubula.client.ui.utils.ErrorHandlingUtil.java

License:Open Source License

/**
 * Open the message dialog./*from   w w w  . j  a  v  a 2  s  .  co  m*/
 * <p><b>Use createMessageDialog(JBException ex, Object[] params, String[] details)
 * instead, if you want to get an entry in error log.</b></p>
 * @param messageID the actual messageID
 * @param params Parameter of the message text or null, if not needed.
 * @param details use null, or overwrite in MessageIDs hardcoded details.
 * @param parent the parent shell to use for this message dialog
 * @return the dialog.
 */
public static Dialog createMessageDialog(final Integer messageID, final Object[] params, final String[] details,
        final Shell parent) {
    String title = StringConstants.EMPTY;
    String message = StringConstants.EMPTY;
    String[] labels = new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY) };
    int imageID = MessageDialog.INFORMATION;
    Message msg = MessageIDs.getMessageObject(messageID);
    String[] detail = lineFeed(msg.getDetails());
    if (details != null) {
        detail = lineFeed(details);
    }
    switch (msg.getSeverity()) {
    case Message.ERROR:
        title = Messages.UtilsError;
        message = Messages.UtilsErrorOccurred;
        break;
    case Message.INFO:
        title = Messages.UtilsInfo1;
        message = Messages.UtilsInfo2;
        break;
    case Message.WARNING:
        title = Messages.UtilsWarning1;
        message = Messages.UtilsWarning2;
        break;
    case Message.QUESTION:
        title = Messages.UtilsRequest1;
        message = Messages.UtilsRequest2;
        labels = new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) };
        imageID = MessageDialog.QUESTION;
        break;
    default:
        break;
    }
    IStatus[] status = new Status[detail.length];
    for (int i = 0; i < detail.length; i++) {
        status[i] = new Status(msg.getSeverity(), Constants.PLUGIN_ID, IStatus.OK, detail[i], null);
    }
    if ((msg.getSeverity() == Message.INFO || msg.getSeverity() == Message.QUESTION)) {
        StringBuilder messageBuilder = new StringBuilder(message);
        messageBuilder.append(msg.getMessage(params));
        messageBuilder.append(StringConstants.NEWLINE);
        for (IStatus s : status) {
            if (s.getMessage() != Message.NO_DETAILS) {
                messageBuilder.append(StringConstants.NEWLINE);
                messageBuilder.append(s.getMessage());
            }
        }
        dlg = new MessageDialog(parent, title, null, messageBuilder.toString(), imageID, labels, 0);
    } else {
        dlg = new ErrorDialog(parent, title, message,
                new MultiStatus(Constants.PLUGIN_ID, IStatus.OK, status, msg.getMessage(params), null),
                IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
    }
    dlg.create();
    DialogUtils.setWidgetNameForModalDialog(dlg);
    dlg.open();
    return dlg;
}