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

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

Introduction

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

Prototype

int ERROR

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

Click Source Link

Document

Constant for an error message (value 3).

Usage

From source file:org.eclipse.birt.report.designer.data.ui.property.AbstractPropertyDialog.java

License:Open Source License

public final void setMessage(String message, int messageType) {
    if (messageArea != null) {
        if (messageType != IMessageProvider.NONE) {
            titleImage.setVisible(false);
        } else {// ww w.j a v a2  s.  c  o m
            titleImage.setVisible(true);
        }
        if (message == null && messageType == IMessageProvider.ERROR) {
            messageArea.updateText("", messageType);
        } else {
            messageArea.updateText(message, messageType);
        }
    }
}

From source file:org.eclipse.birt.report.designer.internal.ui.wizards.WizardCSSSettingPage.java

License:Open Source License

/**
 * Applies the status to the status line of a dialog page.
 *///from  w  ww .j a v  a2 s.c  o  m
private void applyToStatusLine(IStatus status) {
    String message = status.getMessage();
    if (message.length() == 0)
        message = pageDefaultDesc;
    switch (status.getSeverity()) {
    case IStatus.OK:
        setErrorMessage(null);
        setMessage(message);
        break;
    case IStatus.ERROR:
        setErrorMessage(message);
        setMessage(message, IMessageProvider.ERROR);
        break;
    default:
        setErrorMessage(message);
        setMessage(null);
        break;
    }
}

From source file:org.eclipse.birt.report.designer.internal.ui.wizards.WizardLibrarySettingPage.java

License:Open Source License

/**
 * Applies the status to the status line of a dialog page.
 *//* w ww.  j  a  v a2  s.c  om*/
private void applyToStatusLine(IStatus status) {
    String message = status.getMessage();
    if (message.length() == 0)
        message = PAGE_DESC;
    switch (status.getSeverity()) {
    case IStatus.OK:
        setErrorMessage(null);
        setMessage(message);
        break;
    case IStatus.ERROR:
        setErrorMessage(message);
        setMessage(message, IMessageProvider.ERROR);
        break;
    default:
        setErrorMessage(message);
        setMessage(null);
        break;
    }
}

From source file:org.eclipse.birt.report.designer.ui.dialogs.BaseTitleAreaDialog.java

License:Open Source License

public void setMessage(String msg, int newType) {
    super.setMessage(msg, newType);

    if (newType == IMessageProvider.ERROR) {
        this.errorMsg = msg;
    } else {/* ww  w  .j  a  va  2s. com*/
        this.errorMsg = null;
    }
}

From source file:org.eclipse.birt.report.designer.ui.dialogs.StyleBuilder.java

License:Open Source License

public void setTitleMessage(String newMessage, int newType) {
    Image newImage = null;//from  w  ww . java2  s. co m
    if (newMessage != null) {
        switch (newType) {
        case IMessageProvider.NONE:
            break;
        case IMessageProvider.INFORMATION:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_INFO);
            break;
        case IMessageProvider.WARNING:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_WARNING);
            break;
        case IMessageProvider.ERROR:
            newImage = JFaceResources.getImage(DLG_IMG_MESSAGE_ERROR);
            break;
        }
    }
    showTitleMessage(newMessage, newImage);
}

From source file:org.eclipse.birt.report.designer.ui.viewer.StaticHTMLViewer.java

License:Open Source License

public Control createUI(Composite parent) {
    if (parent == null) {
        return null;
    }// w w  w. java 2s  .  co m
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);

    form.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT));
    form.setImage(
            StaticHTMLPrviewPlugin.getDefault().getImageRegistry().get(StaticHTMLPrviewPlugin.IMG_FORM_TITLE));

    toolkit.decorateFormHeading(form);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));

    GridLayout layout = new GridLayout();
    layout.horizontalSpacing = layout.verticalSpacing = 0;
    layout.marginWidth = layout.marginHeight = 0;
    form.getBody().setLayout(layout);

    // Re-run the report action
    reRunReportAction = new Action("Re-run the report", //$NON-NLS-1$
            Action.AS_PUSH_BUTTON) {

        public void run() {
            render();
        }
    };
    reRunReportAction.setToolTipText("Re-run the report"); //$NON-NLS-1$
    reRunReportAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_RE_RUN));
    form.getToolBarManager().add(reRunReportAction);

    // paramAction
    paramAction = new Action("Enter parameter", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            render();
        }
    };
    paramAction.setToolTipText("Open Parameters Dialog"); //$NON-NLS-1$
    paramAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_PARAMS));
    form.getToolBarManager().add(paramAction);

    // tocAction
    tocAction = new Action("TOC", Action.AS_RADIO_BUTTON) { //$NON-NLS-1$

        public void run() {
            if (sashForm.getMaximizedControl() != null) {
                sashForm.setMaximizedControl(null);
                setChecked(true);
            } else {
                sashForm.setMaximizedControl(browserContainer);
                setChecked(false);
            }
        }
    };
    tocAction.setToolTipText("Show TOC"); //$NON-NLS-1$
    tocAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_TOC));
    tocAction.setChecked(false);
    form.getToolBarManager().add(tocAction);

    form.getToolBarManager().add(new Separator());

    // navFirstAction
    navFirstAction = new Action("First", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            currentPageNum = 1;
            renderWithoutAskingForParams();
        }
    };
    navFirstAction.setToolTipText("First"); //$NON-NLS-1$
    navFirstAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_FIRST));
    form.getToolBarManager().add(navFirstAction);

    // navPreAction
    navPreAction = new Action("Previous", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            if (currentPageNum > 1) {
                currentPageNum--;
                renderWithoutAskingForParams();
            }
        }
    };

    navPreAction.setToolTipText("Previous"); //$NON-NLS-1$
    navPreAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_PRE));
    form.getToolBarManager().add(navPreAction);

    // navNextAction
    navNextAction = new Action("Next", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            if (currentPageNum < totalPageNum) {
                currentPageNum++;
                renderWithoutAskingForParams();
            }
        }
    };

    navNextAction.setToolTipText("Next"); //$NON-NLS-1$
    navNextAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_NEXT));
    form.getToolBarManager().add(navNextAction);

    // navLastAction
    navLastAction = new Action("Last", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            currentPageNum = totalPageNum;
            renderWithoutAskingForParams();
        }
    };

    navLastAction.setToolTipText("Last"); //$NON-NLS-1$
    navLastAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_LAST));
    form.getToolBarManager().add(navLastAction);

    form.getToolBarManager().add(new Separator());

    ContributionItem inputText = new ContributionItem() {

        public void fill(ToolBar parent, int index) {
            ToolItem toolitem = new ToolItem(parent, SWT.SEPARATOR, index);
            Composite container = new Composite(parent, SWT.NULL);
            // container.setFont( JFaceResources.getFontRegistry( )
            // .get( JFaceResources.TEXT_FONT ) );
            GridLayout layout = new GridLayout();
            layout.numColumns = 2;
            layout.marginWidth = layout.marginHeight = 1;
            container.setLayout(layout);
            Label label = new Label(container, SWT.NULL);
            label.setFont(container.getFont());
            label.setText("Go to page:"); //$NON-NLS-1$

            goPageInput = toolkit.createText(container, "", SWT.BORDER); //$NON-NLS-1$
            goPageInput.setFont(container.getFont());

            goPageInput.setLayoutData(new GridData(GridData.FILL_BOTH));
            goPageInput.addKeyListener(new KeyAdapter() {

                public void keyPressed(KeyEvent e) {
                    if (e.character == SWT.LF || e.character == SWT.CR) {
                        if (navGoAction.isEnabled()) {
                            currentPageNum = Long.parseLong(goPageInput.getText());
                            renderWithoutAskingForParams();
                        }
                    }
                }

            });

            goPageInput.addModifyListener(new ModifyListener() {

                /**
                 * last valid status
                 */
                private boolean isValid = true;

                public void modifyText(ModifyEvent e) {
                    if (!"".equals(goPageInput.getText())) //$NON-NLS-1$
                    {
                        try {
                            long page = Long.parseLong(goPageInput.getText());
                            if (page > 0 && page <= totalPageNum) {
                                if (!isValid) {
                                    form.setMessage(null);
                                    isValid = true;
                                }
                                navGoAction.setEnabled(true);
                            } else {
                                form.setMessage("Page Number '" //$NON-NLS-1$
                                        + page + "' is invalid!", //$NON-NLS-1$
                                        IMessageProvider.ERROR);
                                isValid = false;
                                navGoAction.setEnabled(false);
                            }
                        } catch (NumberFormatException e1) {
                            form.setMessage("Page Number '" //$NON-NLS-1$
                                    + goPageInput.getText() + "' is invalid!", //$NON-NLS-1$
                                    IMessageProvider.ERROR);
                            isValid = false;
                            navGoAction.setEnabled(false);
                        }
                    } else {
                        form.setMessage(null);
                        isValid = true;
                    }
                }
            });

            toolitem.setWidth(label.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + 40);
            toolitem.setControl(container);
        }

    };
    inputText.setVisible(true);
    form.getToolBarManager().add(inputText);

    // navSelectAction
    navGoAction = new Action("Go to page", Action.AS_PUSH_BUTTON) { //$NON-NLS-1$

        public void run() {
            if (goPageInput != null && !goPageInput.isDisposed()) {
                currentPageNum = Long.parseLong(goPageInput.getText());
                // render( );
                renderWithoutAskingForParams();
            }
        }
    };

    navGoAction.setToolTipText("Go to page"); //$NON-NLS-1$
    navGoAction.setImageDescriptor(StaticHTMLPrviewPlugin.getDefault().getImageRegistry()
            .getDescriptor(StaticHTMLPrviewPlugin.IMG_NAV_GO));
    form.getToolBarManager().add(navGoAction);

    form.updateToolBar();

    sashForm = new SashForm(form.getBody(), SWT.NULL);
    sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    sashForm.setLayout(layout);
    toolkit.adapt(sashForm, false, false);

    createTOCSection(sashForm);
    createBrowserSection(sashForm);

    sashForm.setWeights(new int[] { 2, 8 });

    toolkit.paintBordersFor(form.getBody());

    return this.form;
}

From source file:org.eclipse.buildship.ui.projectimport.AbstractWizardPage.java

License:Open Source License

/**
 * Constructor setting up the main messages and the validation facility for this wizard page.
 *
 * @param name the name of the page// w  w  w  .j  av a2  s  .com
 * @param title the page title
 * @param defaultMessage the default message to show when there is no validation error
 * @param configuration the data model of the wizard
 * @param observedProperties the subset of the properties from the data model that are managed
 *            on this page
 */
protected AbstractWizardPage(String name, String title, String defaultMessage,
        ProjectImportConfiguration configuration, final List<Property<?>> observedProperties) {
    super(name);

    this.configuration = configuration;
    this.observedProperties = observedProperties;
    this.defaultMessage = defaultMessage;

    // set the basic message and the attached image
    setTitle(title);
    setMessage(defaultMessage);
    setImageDescriptor(
            ImageDescriptor.createFromFile(GradleProjectWizardPage.class, "/icons/full/wizban/import_wiz.png")); //$NON-NLS-1$

    // set up the UI builder
    this.defaultFont = FontUtils.getDefaultDialogFont();
    this.builderFactory = new UiBuilder.UiBuilderFactory(this.defaultFont);

    // create a listener that updates the state and the message if an observed property in the
    // model changes
    ValidationListener listener = new ValidationListener() {

        @Override
        public void validationTriggered(Property<?> source, Optional<String> validationErrorMessage) {
            // if the modified property is invalid, show its error message, otherwise check if
            // any of the other properties of this page is invalid and if so, display the first
            // found error message
            if (validationErrorMessage.isPresent()) {
                setMessage(validationErrorMessage.get(), IMessageProvider.ERROR);
            } else {
                Optional<String> otherErrorMessage = validateAllObservedProperties();
                if (!otherErrorMessage.isPresent()) {
                    setMessage(AbstractWizardPage.this.defaultMessage);
                } else {
                    setMessage(otherErrorMessage.get(), IMessageProvider.ERROR);
                }
            }

            // we set the page to completed if all its properties are valid
            setPageComplete(isPageComplete());
        }

        private Optional<String> validateAllObservedProperties() {
            for (Property<?> property : observedProperties) {
                Optional<String> errorMessage = property.validate();
                if (errorMessage.isPresent()) {
                    return errorMessage;
                }
            }
            return Optional.absent();
        }
    };

    // attach the listener to all of the observed properties
    for (Property<?> property : observedProperties) {
        property.addValidationListener(listener);
    }
}

From source file:org.eclipse.buildship.ui.wizard.project.AbstractWizardPage.java

License:Open Source License

/**
 * Constructor setting up the main messages and the validation facility for this wizard page.
 *
 * @param name the name of the page/*from  w w  w.j  a v a2s  .  c  om*/
 * @param title the page title
 * @param defaultMessage the default message to show when there is no validation error
 * @param configuration the data model of the wizard
 * @param observedProperties the subset of the properties from the data model that are managed
 *            on this page
 */
protected AbstractWizardPage(String name, String title, String defaultMessage,
        ProjectImportConfiguration configuration, final List<Property<?>> observedProperties) {
    super(name);

    this.configuration = configuration;
    this.observedProperties = observedProperties;
    this.defaultMessage = defaultMessage;

    // set the basic message and the attached image
    setTitle(title);
    setMessage(defaultMessage);
    setImageDescriptor(
            ImageDescriptor.createFromFile(GradleProjectWizardPage.class, "/icons/full/wizban/wizard.png")); //$NON-NLS-1$

    // set up the UI builder
    this.defaultFont = FontUtils.getDefaultDialogFont();
    this.builderFactory = new UiBuilder.UiBuilderFactory(this.defaultFont);

    // create a listener that updates the state and the message if an observed property in the
    // model changes
    ValidationListener listener = new ValidationListener() {

        @Override
        public void validationTriggered(Property<?> source, Optional<String> validationErrorMessage) {
            // if the modified property is invalid, show its error message, otherwise check if
            // any of the other properties of this page is invalid and if so, display the first
            // found error message
            if (validationErrorMessage.isPresent()) {
                setMessage(validationErrorMessage.get(), IMessageProvider.ERROR);
            } else {
                Optional<String> otherErrorMessage = validateAllObservedProperties();
                if (!otherErrorMessage.isPresent()) {
                    setMessage(AbstractWizardPage.this.defaultMessage);
                } else {
                    setMessage(otherErrorMessage.get(), IMessageProvider.ERROR);
                }
            }

            // we set the page to completed if all its properties are valid
            setPageComplete(isPageComplete());
        }

        private Optional<String> validateAllObservedProperties() {
            for (Property<?> property : observedProperties) {
                Optional<String> errorMessage = property.validate();
                if (errorMessage.isPresent()) {
                    return errorMessage;
                }
            }
            return Optional.absent();
        }
    };

    // attach the listener to all of the observed properties
    for (Property<?> property : observedProperties) {
        property.addValidationListener(listener);
    }
}

From source file:org.eclipse.cdt.internal.ui.preferences.PathEntryVariableDialog.java

License:Open Source License

/**
 * Validates the current variable name, and updates this dialog's message.
 * /*from www. j a va2s .c  om*/
 * @return true if the name is valid, false otherwise
 */
private boolean validateVariableName() {
    boolean allowFinish = false;

    // if the current validationStatus is ERROR, no additional validation applies
    if (validationStatus == IMessageProvider.ERROR)
        return false;

    // assumes everything will be ok
    String message = standardMessage;
    int newValidationStatus = IMessageProvider.NONE;

    if (variableName.length() == 0) {
        // the variable name is empty
        if (nameEntered) {
            // a name was entered before and is now empty
            newValidationStatus = IMessageProvider.ERROR;
            message = PreferencesMessages.PathEntryVariableDialog_variableNameEmptyMessage;
        }
    } else {
        if (namesInUse.contains(variableName) && !variableName.equals(originalName)) {
            // the variable name is already in use
            message = PreferencesMessages.PathEntryVariableDialog_variableAlreadyExistsMessage;
            newValidationStatus = IMessageProvider.ERROR;
        } else {
            allowFinish = true;
        }
    }

    // overwrite the current validation status / message only if everything is ok (clearing them)
    // or if we have a more serious problem than the current one
    if (validationStatus == IMessageProvider.NONE || newValidationStatus == IMessageProvider.ERROR) {
        validationStatus = newValidationStatus;
        validationMessage = message;
    }
    // only set the message here if it is not going to be set in 
    // validateVariableValue to avoid flashing.
    if (allowFinish == false)
        setMessage(validationMessage, validationStatus);
    return allowFinish;
}

From source file:org.eclipse.cdt.internal.ui.preferences.PathEntryVariableDialog.java

License:Open Source License

/**
 * Validates the current variable value, and updates this dialog's message.
 * /*from w ww .j  av  a  2 s . c o m*/
 * @return true if the value is valid, false otherwise
 */
private boolean validateVariableValue() {
    boolean allowFinish = false;

    // if the current validationStatus is ERROR, no additional validation applies
    if (validationStatus == IMessageProvider.ERROR)
        return false;

    // assumes everything will be ok
    String message = standardMessage;
    int newValidationStatus = IMessageProvider.NONE;

    if (variableValue.length() == 0) {
        // the variable value is empty
        if (locationEntered) {
            // a location value was entered before and is now empty
            newValidationStatus = IMessageProvider.ERROR;
            message = PreferencesMessages.PathEntryVariableDialog_variableValueEmptyMessage;
        }
    } else if (!Path.EMPTY.isValidPath(variableValue)) {
        // the variable value is an invalid path
        message = PreferencesMessages.PathEntryVariableDialog_variableValueInvalidMessage;
        newValidationStatus = IMessageProvider.ERROR;
    } else if (!new Path(variableValue).isAbsolute()) {
        // the variable value is a relative path
        message = PreferencesMessages.PathEntryVariableDialog_pathIsRelativeMessage;
        newValidationStatus = IMessageProvider.ERROR;
    } else if (!new File(variableValue).exists()) {
        // the path does not exist (warning)
        message = PreferencesMessages.PathEntryVariableDialog_pathDoesNotExistMessage;
        newValidationStatus = IMessageProvider.WARNING;
        allowFinish = true;
    } else {
        allowFinish = true;
    }

    // overwrite the current validation status / message only if everything is ok (clearing them)
    // or if we have a more serious problem than the current one
    if (validationStatus == IMessageProvider.NONE || newValidationStatus > validationStatus) {
        validationStatus = newValidationStatus;
        validationMessage = message;
    }
    setMessage(validationMessage, validationStatus);
    return allowFinish;
}