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.gyrex.admin.ui.jobs.internal.ExclusiveLockWizardPage.java

License:Open Source License

void validate() {
    final String id = getLockId();
    if (StringUtils.isNotBlank(id)) {
        if (!IdHelper.isValidId(id)) {
            setMessage(/*from w ww  . jav  a  2s  . c om*/
                    "The entered lock id is invalid. It may only contain ASCII chars a-z, 0-9, '.', '-' and/or '_'.",
                    IMessageProvider.ERROR);
            setPageComplete(false);
            return;
        }
    }

    if (StringUtils.isBlank(id) && requireLockCheckBox.isSelected()) {
        setMessage("Please enter an lock identifier.", INFORMATION);
        setPageComplete(false);
        return;
    }

    setMessage(null);
    setPageComplete(true);
}

From source file:org.eclipse.gyrex.admin.ui.jobs.internal.externalprocess.ExternalProcessWizardPage.java

License:Open Source License

void validate() {
    final String command = getCommand();
    if (StringUtils.isBlank(command)) {
        setMessage("Please enter a program to launch.");
        setPageComplete(false);/* ww  w . j  av  a  2  s  .  c om*/
        return;
    }

    final String returnCode = expectedReturnCodeField.getText();
    if (StringUtils.isNotBlank(returnCode)) {
        try {
            Integer.parseInt(returnCode);
        } catch (final NumberFormatException e) {
            setMessage("The entered return code must be an integer number.", IMessageProvider.ERROR);
            setPageComplete(false);
            return;
        }
    }

    saveParameterToSession();

    setMessage(null);
    setPageComplete(true);
}

From source file:org.eclipse.gyrex.admin.ui.jobs.internal.ScheduleEntryWizardPage.java

License:Open Source License

void validate() {
    final String id = getEntryId();
    if (StringUtils.isNotBlank(id)) {
        if (!IdHelper.isValidId(id)) {
            setMessage(/*ww  w  .  j a va2  s.c om*/
                    "The entered entry id is invalid. It may only contain ASCII chars a-z, 0-9, '.', '-' and/or '_'.",
                    IMessageProvider.ERROR);
            setPageComplete(false);
            return;
        }
        if ((null == getEntry()) && getSchedule().hasEntry(id)) {
            setMessage(String.format("Schedule '%s' already contains an entry with the specified id.",
                    getSchedule().getId()), IMessageProvider.ERROR);
            setPageComplete(false);
            return;
        }
    }

    if (StringUtils.isBlank(id)) {
        setMessage("Please enter an entry identifier.", INFORMATION);
        setPageComplete(false);
        return;
    }

    if ((jobType == null) || StringUtils.isBlank(getJobTypeId())) {
        setMessage("Please select a task.", INFORMATION);
        setPageComplete(false);
        return;
    }

    if (isScheduleUsingCronExpression()) {
        final String cronExpression = getCronExpression();
        if (StringUtils.isNotBlank(cronExpression)) {
            try {
                ScheduleEntryImpl.validateCronExpression(cronExpression);
            } catch (final IllegalArgumentException e) {
                setMessage("The cron expression is invalid. " + e.getMessage(), IMessageProvider.ERROR);
                setPageComplete(false);
                return;
            }
        } else {
            setMessage("Please enter a cron expression.", INFORMATION);
            setPageComplete(false);
            return;
        }
    }

    if (isScheduleUsingPreceedingEntries()) {
        if (preceedingEntriesTree.getElements().isEmpty()) {
            setMessage("Please select an entry this task depends on.", INFORMATION);
            setPageComplete(false);
            return;
        }

        // check for loops
        if (entry != null) {
            final String[] preceedingEntryIds = getPreceedingEntryIds();
            for (final String preceedingEntryId : preceedingEntryIds) {
                final LinkedList<String> sequence = new LinkedList<>();
                sequence.add(entry.getId());
                try {
                    ScheduleImpl.checkExecutionSequenceForLoops(entry, sequence,
                            Collections.singletonList(preceedingEntryId));
                } catch (final IllegalArgumentException e) {
                    setMessage(String.format("Preceeding entry %s will produce a loop. Please remove it!",
                            preceedingEntryId), ERROR);
                    setPageComplete(false);
                    return;
                }
            }
        }
    }

    setMessage(null);
    setPageComplete(true);
}

From source file:org.eclipse.gyrex.admin.ui.logback.internal.AppenderWizardPage.java

License:Open Source License

void validate() {
    final String name = getName();
    if (name == null) {
        setMessage("Please enter an appender name.", INFORMATION);
        setPageComplete(false);//from w ww. ja  va2  s .  c o m
        return;
    } else if (!IdHelper.isValidId(name)) {
        setMessage(
                "The entered appender name is invalid. It may only contain ASCII chars a-z, 0-9, '.', '-' and/or '_'.",
                IMessageProvider.ERROR);
        setPageComplete(false);
        return;
    }

    final List<Object> selectedElements = appenderTypeField.getSelectedElements();
    if (selectedElements.size() != 1) {
        setMessage("Please select an appender to use.", INFORMATION);
        setPageComplete(false);
        return;
    }

    setAppenderType((AppenderType) selectedElements.get(0));

    setMessage(null);
    setPageComplete(true);
}

From source file:org.eclipse.ice.client.rcp.actions.ChooseWorkspaceDialog.java

License:Open Source License

@Override
// Creates the SWT widgets needed to get user information
protected Control createDialogArea(Composite parent) {
    // Set the title and message of this TitleAreaDialog
    this.setTitle("Pick a Workspace");
    this.setMessage(message);

    // Create the underlying composite
    comp = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    // Give it 3 columns and allow the widgets to fill available horizontal
    // space/*  ww w .  java2 s.c o m*/
    layout.numColumns = 3;
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL | GridData.FILL_VERTICAL
            | GridData.VERTICAL_ALIGN_END);
    // Set the composites layout and layout data
    comp.setLayout(layout);
    comp.setLayoutData(data);

    // Create a workspace label
    CLabel wsLabel = new CLabel(comp, SWT.NONE);
    wsLabel.setText("Workspace Root Path");

    // Create the workspace combo box, it lists the selected workspace
    // and any previous workspaces
    wsPath = new Combo(comp, SWT.BORDER);
    // Get what default directory should be in the box upon opening
    String wsRoot = prefs.get(key_workspaceRootDir, "");
    if (wsRoot == null || wsRoot.length() == 0) {
        wsRoot = getWorkspaceSuggestion();
    }
    wsPath.setText(wsRoot == null ? "" : wsRoot);
    wsPath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    // Create the browse button as a SWT.Push variety
    Button browseButton = new Button(comp, SWT.PUSH);
    browseButton.setText("Browse");
    // Add an event listener that displays a Directory Dialog prompt
    browseButton.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event event) {
            // Create the DirectoryDialog and set its text and info
            DirectoryDialog dialog = new DirectoryDialog(new Shell(Display.getCurrent()));
            dialog.setText("Select Workspace Directory");
            dialog.setMessage(info);
            dialog.setFilterPath(wsPath.getText());
            // Open the dialog and get the user's selection
            String userSelection = dialog.open();
            // Check the selections validity
            if (userSelection == null && wsPath.getText().length() == 0) {
                setMessage(error, IMessageProvider.ERROR);
            } else {
                // If valid set the selection in the combo box
                setMessage(message);
                wsPath.setText(userSelection);
            }
        }
    });

    // Create a remember workspace check button
    rememberButton = new Button(comp, SWT.CHECK);
    rememberButton.setText("Remember Workspace");
    rememberButton.setSelection(prefs.getBoolean(key_rememberWS, false));

    // Populate the list of previous workspace selections for the combo box
    String lastUsedWS = prefs.get(key_lastUsedWorkspaces, "");
    lastUsed = new ArrayList<String>();
    if (lastUsed != null) {
        String[] all = lastUsedWS.split("#");
        for (String str : all) {
            lastUsed.add(str);
        }
    }
    // Add the gathered last workspaces and add them to the combo box
    for (String last : lastUsed) {
        wsPath.add(last);
    }

    return comp;
}

From source file:org.eclipse.ice.client.rcp.actions.ChooseWorkspaceDialog.java

License:Open Source License

@Override
// This method is called when the OK button is pressed
protected void okPressed() {
    // Get the users selected directory
    String str = wsPath.getText();

    // Check the directory's validity
    if (str.length() == 0) {
        setMessage(error, IMessageProvider.ERROR);
        return;//from   ww w  .  j a  va  2s.co m
    }

    // Make sure the selected workspace exists and is valid
    if (!checkWorkspaceExists(str)) {
        setMessage(error, IMessageProvider.ERROR);
        Status status = new Status(IStatus.ERROR, "gov.ice.iceclient", 0, reason, null);
        // Display the dialog
        ErrorDialog.openError(Display.getCurrent().getActiveShell(), "Workspace Selection Error",
                "Error creating the workspace directory " + this.wsPath.getText() + ".", status);
        return;
    }

    // Remove the selection from the lastUsed String array
    // If the array does not contain the directory then add it to the array
    lastUsed.remove(str);
    if (!lastUsed.contains(str)) {
        lastUsed.add(0, str);
    }

    // If size of array is greater than the maximum number of used
    // workspaces we want to show, delete the oldest one.
    if (lastUsed.size() > MaxHistory) {
        List<String> remove = new ArrayList<String>();
        for (int i = 5; i < lastUsed.size(); i++) {
            remove.add(lastUsed.get(i));
        }
        lastUsed.removeAll(remove);
    }

    // Create a string concatenation of all the last used workspaces
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < lastUsed.size(); i++) {
        buf.append(lastUsed.get(i));
        if (i != lastUsed.size() - 1) {
            buf.append("#");
        }
    }

    // Save the remember and last workspace preferences
    prefs.putBoolean(key_rememberWS, rememberButton.getSelection());
    prefs.put(key_lastUsedWorkspaces, buf.toString());

    // Save the valid workspace directory path
    workspaceDirectoryPath = str;

    // Set the workspace directory preference
    prefs.put(key_workspaceRootDir, str);

    // Call the super classes okPressed method
    super.okPressed();

    return;
}

From source file:org.eclipse.ice.client.widgets.AbstractEntryComposite.java

License:Open Source License

/**
 * This operation sets the value of the Entry and, if possible and
 * necessary, reports to the message manager.
 *
 * @param value/*  ww w .  j  a  va2 s .c  om*/
 */
protected void setEntryValue(String value) {

    boolean success = entry.setValue(value);
    // Set the value and post a message if necessary
    if (!success && messageManager != null) {
        // Get the message
        String errorMessage = entry.getErrorMessage();
        // Post it if it exists
        if (errorMessage != null) {
            // Display the error at the top of the screen
            if (messageManager != null) {
                messageManager.addMessage(messageName, errorMessage, null, IMessageProvider.ERROR);
            }
            // Highlight the text if it is in a text box
            if (widget != null && widget instanceof Text) {
                Text text = (Text) widget;
                Color color = new Color(Display.getCurrent(), 200, 0, 0);
                text.setForeground(color);
                FontData fontData = new FontData();
                fontData.setStyle(SWT.BOLD);
                Font font = new Font(getDisplay(), fontData);
                text.setFont(font);
            }
        }

    } else if (value == null) {

        if (entry instanceof DiscreteEntry) {
            // Set the Entry to the first AllowedValue if it's Discrete
            if (!entry.getAllowedValues().isEmpty()) {
                String allowedValue = entry.getAllowedValues().get(0);
                entry.setValue(allowedValue);
            }
        } else {
            // Otherwise, set the default value
            entry.setValue(entry.getDefaultValue());
        }

    } else {
        // Remove a posted message if necessary
        if (messageManager != null) {
            messageManager.removeMessage(messageName);
        }
        // Remove the text box highlight if it is in a text box
        if (widget != null && widget instanceof Text) {
            Text text = (Text) widget;
            Color color = new Color(Display.getCurrent(), 0, 0, 0);
            text.setForeground(color);
            FontData fontData = new FontData();
            fontData.setStyle(SWT.NORMAL);
            fontData.setHeight(10);
            Font font = new Font(getDisplay(), fontData);
            text.setFont(font);
        }
    }

    return;
}

From source file:org.eclipse.ice.client.widgets.DiscreteEntryComposite.java

License:Open Source License

/**
 * This operation will post a message to the message manager (if one exists)
 * if the Entry has no value, but requires a value from a discrete set.
 *//*  www  .ja  va2 s. c o m*/
private void throwMissingValuesError() {

    if (messageManager != null) {
        // Get the message
        String errorMessage = "There are no allowed values, can't create DiscreteEntryComposite.";// entry.getErrorMessage();
        // Post it if it exists
        if (errorMessage != null) {
            // Display the error at the top of the screen
            if (messageManager != null) {
                messageManager.addMessage(messageName, errorMessage, null, IMessageProvider.ERROR);
            }
            // Highlight the text if it is in a text box
            if (widget != null) {
                Color color = new Color(Display.getCurrent(), 200, 0, 0);
                widget.setForeground(color);
                FontData fontData = new FontData();
                fontData.setStyle(SWT.BOLD);
                Font font = new Font(getDisplay(), fontData);
                widget.setFont(font);
            }
        }
    }

    return;
}

From source file:org.eclipse.ice.client.widgets.EntryComposite.java

License:Open Source License

/**
 * This operation will post a message to the message manager (if one exists)
 * if the Entry has no value, but requires a value from a discrete set.
 *//*w w  w . ja v  a 2  s . c o  m*/
private void throwMissingValuesError() {

    if (messageManager != null) {
        // Get the message
        String errorMessage = entry.getErrorMessage();
        // Post it if it exists
        if (errorMessage != null) {
            // Display the error at the top of the screen
            if (messageManager != null) {
                messageManager.addMessage(messageName, errorMessage, null, IMessageProvider.ERROR);
            }
            // Highlight the text if it is in a text box
            if (text != null) {
                Color color = new Color(Display.getCurrent(), 200, 0, 0);
                text.setForeground(color);
                FontData fontData = new FontData();
                fontData.setStyle(SWT.BOLD);
                Font font = new Font(getDisplay(), fontData);
                text.setFont(font);
            }
        }
    }

    return;
}

From source file:org.eclipse.ice.client.widgets.EntryComposite.java

License:Open Source License

/**
 * This operation sets the value of the Entry and, if possible and
 * necessary, reports to the message manager.
 * /*from w  ww .ja va2  s  . c  o  m*/
 * @param value
 */
protected void setEntryValue(String value) {

    // Set the value and post a message if necessary
    if (!entry.setValue(value) && messageManager != null) {
        // Get the message
        String errorMessage = entry.getErrorMessage();
        // Post it if it exists
        if (errorMessage != null) {
            // Display the error at the top of the screen
            if (messageManager != null) {
                messageManager.addMessage(messageName, errorMessage, null, IMessageProvider.ERROR);
            }
            // Highlight the text if it is in a text box
            if (text != null) {
                Color color = new Color(Display.getCurrent(), 200, 0, 0);
                text.setForeground(color);
                FontData fontData = new FontData();
                fontData.setStyle(SWT.BOLD);
                Font font = new Font(getDisplay(), fontData);
                text.setFont(font);
            }
        }

    } else if (value == null) {

        if (entry.getValueType().equals(AllowedValueType.Discrete)) {
            // Set the Entry to the first AllowedValue if it's Discrete
            if (!entry.getAllowedValues().isEmpty()) {
                String allowedValue = entry.getAllowedValues().get(0);
                entry.setValue(allowedValue);
            }
        } else {
            // Otherwise, set the default value
            entry.setValue(entry.getDefaultValue());
        }

    } else {
        // Remove a posted message if necessary
        if (messageManager != null) {
            messageManager.removeMessage(messageName);
        }
        // Remove the text box highlight if it is in a text box
        if (text != null) {
            Color color = new Color(Display.getCurrent(), 0, 0, 0);
            text.setForeground(color);
            FontData fontData = new FontData();
            fontData.setStyle(SWT.NORMAL);
            fontData.setHeight(10);
            Font font = new Font(getDisplay(), fontData);
            text.setFont(font);
        }
    }

    return;
}