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:info.evanchik.eclipse.karaf.wtp.ui.KarafRuntimeComposite.java

License:Open Source License

/**
 * Validate the state of the wizard based on the results of the listeners on
 * the various controls.//w w w  .ja  va  2s .  co  m
 */
protected void validateWizardState() {
    if (karafRuntimeWC == null) {
        wizard.setMessage("", IMessageProvider.ERROR);
        return;
    }

    final IStatus status = karafRuntimeWC.validate(null);
    if (status == null || status.isOK()) {
        wizard.setMessage(null, IMessageProvider.NONE);
    } else if (status.getSeverity() == IStatus.WARNING) {
        wizard.setMessage(status.getMessage(), IMessageProvider.WARNING);
    } else {
        wizard.setMessage(status.getMessage(), IMessageProvider.ERROR);
    }

    wizard.update();
}

From source file:io.sarl.eclipse.log.IssueInformationPage.java

License:Apache License

/** Update the page status and change the "finish" state button.
 *///from w  ww .  j av a2 s  .c o m
protected void updatePageStatus() {
    final boolean ok;
    if (Strings.isEmpty(this.titleField.getText())) {
        ok = false;
        setMessage(Messages.IssueInformationPage_5, IMessageProvider.ERROR);
    } else if (Strings.isEmpty(this.trackerLogin.getText())) {
        ok = false;
        setMessage(Messages.IssueInformationPage_6, IMessageProvider.ERROR);
    } else if (Strings.isEmpty(this.trackerPassword.getText())) {
        ok = false;
        setMessage(Messages.IssueInformationPage_7, IMessageProvider.ERROR);
    } else {
        ok = true;
        if (Strings.isEmpty(this.descriptionField.getText())) {
            setMessage(Messages.IssueInformationPage_8, IMessageProvider.WARNING);
        } else {
            setMessage(null, IMessageProvider.NONE);
        }
    }
    setPageComplete(ok);
}

From source file:io.sarl.eclipse.wizards.sreinstall.AbstractSREInstallPage.java

License:Apache License

/**
 * Updates the status message on the page, based on the status of the SRE and other
 * status provided by the page./*from  w  ww .  ja  v a2  s.  co m*/
 */
protected void updatePageStatus() {
    if (this.status.isOK()) {
        setMessage(null, IMessageProvider.NONE);
    } else {
        switch (this.status.getSeverity()) {
        case IStatus.ERROR:
            setMessage(this.status.getMessage(), IMessageProvider.ERROR);
            break;
        case IStatus.INFO:
            setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
            break;
        case IStatus.WARNING:
            setMessage(this.status.getMessage(), IMessageProvider.WARNING);
            break;
        default:
            break;
        }
    }
    setPageComplete(this.status.isOK() || this.status.getSeverity() == IStatus.INFO);
}

From source file:jasima_gui.dialogs.streamEditor.DetailsPageBase.java

License:Open Source License

public boolean checkGlobalConstraints() {
    hideError();/*  www.j  a va  2s. c  o m*/

    // any local error?
    boolean anyError = false;
    for (FormProperty p : props.values()) {
        ControlDecoration deco = p.getDecoration();
        if (p.error != null) {
            anyError = true;
            deco.setDescriptionText(p.error.errorMsg);
            deco.show();
            deco.showHoverText(p.error.hoverText);
        } else {
            deco.setDescriptionText(null);
            deco.hide();
        }
    }

    if (!anyError) {
        // check global constraints
        ArrayList<ConstraintValidator> failed = new ArrayList<ConstraintValidator>();
        for (ConstraintValidator v : getConstraints()) {
            if (!v.isValid())
                failed.add(v);
        }

        // report errors
        if (failed.size() > 0) {
            anyError = true;
            String mainMsg = failed.size() == 1 ? "1 error" : String.format("%d errors", failed.size());
            master.getManagedForm().getForm().setMessage(mainMsg, IMessageProvider.ERROR,
                    failed.toArray(new IMessage[failed.size()]));

            // show error decoration on causing properties
            for (ConstraintValidator cv : failed) {
                for (FormProperty p : cv.dependsOn()) {
                    ControlDecoration deco = p.getDecoration();
                    String s = deco.getDescriptionText();
                    if (s != null)
                        s += "\n" + cv.getMessage();
                    else
                        s = cv.getMessage();
                    deco.setDescriptionText(s);
                    deco.show();
                }
            }
        } else {
            anyError = false;
        }
    }

    master.okButton.setEnabled(!anyError);

    return !anyError;
}

From source file:jasima_gui.dialogs.streamEditor.util.ConstraintValidator.java

License:Open Source License

@Override
public int getMessageType() {
    return IMessageProvider.ERROR;
}

From source file:jasima_gui.editor.EditorWidget.java

License:Open Source License

/**
 * Shows an error without interrupting the user's work flow. This should be
 * used for errors that can be ignored temporarily, like invalid property
 * values./* w  w w . j  ava  2s. c o  m*/
 * 
 * @param message
 *            the error message that should be shown
 */
protected void showError(String message) {
    if (message != null && (message = message.trim()).isEmpty())
        message = null;
    if (message == null && getScrolledForm().getMessageType() == IMessageProvider.NONE) {
        return;
    }
    getScrolledForm().setMessage(message, message == null ? IMessageProvider.NONE : IMessageProvider.ERROR);
}

From source file:melnorme.lang.ide.ui.preferences.common.AbstractComponentsPrefPage.java

License:Open Source License

public static int statusLevelToMessageType(StatusLevel statusLevel) {
    switch (statusLevel) {
    case OK:/*from www .ja v  a  2s . c  o  m*/
        return IMessageProvider.NONE;
    case INFO:
        return IMessageProvider.INFORMATION;
    case WARNING:
        return IMessageProvider.WARNING;
    case ERROR:
        return IMessageProvider.ERROR;
    }
    throw assertFail();
}

From source file:melnorme.lang.ide.ui.utils.DialogPageUtils.java

License:Open Source License

public static int severityToMessageType(IStatus status) {
    switch (status.getSeverity()) {
    case IStatus.ERROR:
        return IMessageProvider.ERROR;
    case IStatus.WARNING:
        return IMessageProvider.WARNING;
    case IStatus.INFO:
        return IMessageProvider.INFORMATION;
    case IStatus.OK:
        return IMessageProvider.NONE;
    default:// w  w w. j av  a2  s.  c o  m
        return IMessageProvider.NONE;
    }
}

From source file:msi.gama.application.workspace.PickWorkspaceDialog.java

@Override
protected Control createDialogArea(final Composite parent) {
    setTitle("Choose a Workspace to store your models, settings, etc.");
    setMessage(strMsg);//from   ww  w. j  a  v  a2s  .c o m

    try {
        final Composite inner = new Composite(parent, SWT.NONE);
        final GridLayout l = new GridLayout(4, false);
        // double[][] layout =
        // new double[][] {
        // { 5, LatticeConstants.PREFERRED, 5, 250, 5,
        // LatticeConstants.PREFERRED, 5 },
        // { 5, LatticeConstants.PREFERRED, 5, LatticeConstants.PREFERRED,
        // 40 } };
        inner.setLayout(l);
        inner.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));

        /* Label on the left */
        final CLabel label = new CLabel(inner, SWT.NONE);
        label.setText("GAMA Workspace");
        label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));

        /* Combo in the middle */
        workspacePathCombo = new Combo(inner, SWT.BORDER);
        final GridData data = new GridData(SWT.LEFT, SWT.CENTER, true, false);
        data.widthHint = 200;
        workspacePathCombo.setLayoutData(data);
        String wsRoot = getNode().get(keyWorkspaceRootDir, "");
        if (wsRoot == null || wsRoot.length() == 0) {
            wsRoot = getWorkspacePathSuggestion();
        }
        workspacePathCombo.setText(wsRoot);

        /* Checkbox below */
        rememberWorkspaceButton = new Button(inner, SWT.CHECK);
        rememberWorkspaceButton.setText("Remember");
        rememberWorkspaceButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
        rememberWorkspaceButton.setSelection(getNode().getBoolean(keyRememberWorkspace, false));

        final String lastUsed = getNode().get(keyLastUsedWorkspaces, "");
        lastUsedWorkspaces = new ArrayList<String>();
        if (lastUsed != null) {
            final String[] all = lastUsed.split(splitChar);
            for (final String str : all) {
                lastUsedWorkspaces.add(str);
            }
        }
        for (final String last : lastUsedWorkspaces) {
            workspacePathCombo.add(last);
        }

        /* Browse button on the right */
        final Button browse = new Button(inner, SWT.PUSH);
        browse.setText("Browse...");
        browse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
        browse.addListener(SWT.Selection, event -> {
            final DirectoryDialog dd = new DirectoryDialog(getParentShell());
            dd.setText("Select Workspace Root");
            dd.setMessage(strInfo);
            dd.setFilterPath(workspacePathCombo.getText());
            final String pick = dd.open();
            if (pick == null) {
                if (workspacePathCombo.getText().length() == 0) {
                    setMessage(strError, IMessageProvider.ERROR);
                }
            } else {
                setMessage(strMsg);
                workspacePathCombo.setText(pick);
            }
        });
        return inner;
    } catch (final RuntimeException err) {
        err.printStackTrace();
        return null;
    }
}

From source file:msi.gama.application.workspace.PickWorkspaceDialog.java

@Override
protected void okPressed() {
    final String str = workspacePathCombo.getText();
    // scope.getGui().debug("Directory to create " + str);
    if (str.length() == 0) {
        setMessage(strError, IMessageProvider.ERROR);
        return;/* w w w  .  ja  v a 2 s. co  m*/
    }

    final String ret = WorkspacePreferences.checkWorkspaceDirectory(str, true, true, cloning);
    if (ret != null) {
        setMessage(ret, IMessageProvider.ERROR);
        return;
    }
    // scope.getGui().debug("Directory to create (after check " + str);
    /* Save it so we can show it in combo later */
    lastUsedWorkspaces.remove(str);

    if (!lastUsedWorkspaces.contains(str)) {
        lastUsedWorkspaces.add(0, str);
    }

    /* Deal with the max history */
    if (lastUsedWorkspaces.size() > maxHistory) {
        final List<String> remove = new ArrayList<String>();
        for (int i = maxHistory; i < lastUsedWorkspaces.size(); i++) {
            remove.add(lastUsedWorkspaces.get(i));
        }

        lastUsedWorkspaces.removeAll(remove);
    }

    /* Create a string concatenation of all our last used workspaces */
    final StringBuffer buf = new StringBuffer();
    for (int i = 0; i < lastUsedWorkspaces.size(); i++) {
        buf.append(lastUsedWorkspaces.get(i));
        if (i != lastUsedWorkspaces.size() - 1) {
            buf.append(splitChar);
        }
    }

    /* Save them onto our preferences */
    getNode().putBoolean(keyRememberWorkspace, rememberWorkspaceButton.getSelection());
    getNode().put(keyLastUsedWorkspaces, buf.toString());
    try {
        getNode().flush();
    } catch (final BackingStoreException e) {
        e.printStackTrace();
    }

    /* Now create it */
    final boolean ok = checkAndCreateWorkspaceRoot(str);
    if (!ok) {
        // scope.getGui().debug("Problem creating " + str);
        setMessage("No workspace could be created at location " + str + ", please check the error log");
        return;
    }

    /* Here we set the location so that we can later fetch it again */
    WorkspacePreferences.setSelectedWorkspaceRootLocation(str);

    /* And on our preferences as well */
    // scope.getGui().debug("Writing " + str + " in the preferences");
    if (cloning) {
        final String previousLocation = getNode().get(keyWorkspaceRootDir, "");
        File workspaceDirectory = new File(previousLocation);
        if (!workspaceDirectory.exists() || previousLocation.equals(str)) {
            final DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
            dialog.setText("Choose an existing workspace");
            final String result = dialog.open();
            if (result != null) {
                workspaceDirectory = new File(result);
            } else {
                workspaceDirectory = null;
            }
        }
        if (workspaceDirectory != null) {
            final File targetDirectory = new File(str);
            try {
                copyFiles(workspaceDirectory, targetDirectory);
                WorkspacePreferences.setApplyPrefs(true);
            } catch (final Exception err) {
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
                        "There was an error cloning the workspace: " + err.getMessage());
                return;
            }

        }
    }
    getNode().put(keyWorkspaceRootDir, str);
    try {
        getNode().flush();
    } catch (final BackingStoreException e) {
        e.printStackTrace();
    }

    super.okPressed();
}