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:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java

License:Open Source License

/**
 * Updates the page status./*from   ww w . j  a  v a 2  s  .  c  o m*/
 * @param message the message to show, or null to show nothing
 * @param status a {@link IMessageProvider} constant
 */
private void updateStatus(String message, int status) {

    setMessage(null, IMessageProvider.ERROR);
    setMessage(null, IMessageProvider.INFORMATION);
    setMessage(null, IMessageProvider.WARNING);
    setMessage(null, IMessageProvider.NONE);

    setMessage(message, status);
    setPageComplete(status != IMessageProvider.ERROR || message == null);
}

From source file:com.ebmwebsourcing.petals.components.wizards.ComponentNewWizardPage.java

License:Open Source License

/**
 * Updates the page status.// w  w w  .  jav  a2s  .com
 * @param message the error message, or null if everything is all right
 */
private void updateStatus(String message) {
    updateStatus(message, IMessageProvider.ERROR);
}

From source file:com.ebmwebsourcing.petals.server.ui.wizards.PetalsRuntimeWizardFragment3x.java

License:Open Source License

/**
 * Validates the page data./*from   w w  w .j  a  v a 2s .co m*/
 */
public void validate() {

    // Validate the petalsRuntimeWc
    this.petalsRuntimeWc.setVMInstall(this.vmInstall);
    if (this.runtimeName == null || this.runtimeName.trim().length() == 0) {
        this.wizard.setMessage("You must give your runtime a name.", IMessageProvider.ERROR);
        setComplete(false);
        this.wizard.update();
        return;
    }

    // Install path
    boolean complete = false;
    if (this.installPath != null)
        this.runtimeWc.setLocation(new Path(this.installPath));
    else
        this.runtimeWc.setLocation(null);

    IStatus status = this.runtimeWc.validate(null);
    complete = status == null || status.getSeverity() != IStatus.ERROR;
    int severity = IMessageProvider.NONE;

    if (status != null) {
        if (status.getSeverity() == IStatus.ERROR)
            severity = IMessageProvider.ERROR;
        else if (status.getSeverity() == IStatus.WARNING)
            severity = IMessageProvider.WARNING;
        else if (status.getSeverity() == IStatus.INFO)
            severity = IMessageProvider.INFORMATION;
    }

    if (status != null && severity != IMessageProvider.NONE)
        this.wizard.setMessage(status.getMessage(), severity);
    else
        this.wizard.setMessage(null, IMessageProvider.ERROR);

    getTaskModel().putObject(TaskModel.TASK_RUNTIME, this.runtimeWc);
    setComplete(complete);
    this.wizard.update();
}

From source file:com.ebmwebsourcing.petals.server.ui.wizards.PetalsServerWizardFragment3x.java

License:Open Source License

/**
 * Validates the page data./*ww w.ja  va 2  s. co m*/
 */
public void validate() {

    // Validate the runtime
    this.petalsServerWc.setContainerName(this.containerName);
    this.petalsServerWc.setHost(this.host);
    this.petalsServerWc.setPort(this.port);
    this.petalsServerWc.setWsPrefix(this.wsPrefix);
    this.serverWc.setName(this.serverName);

    String errorMsg = this.petalsServerWc.validateTopologyInformation();
    this.wizard.setMessage(errorMsg, IMessageProvider.ERROR);
    setComplete(errorMsg == null);
    this.wizard.update();
}

From source file:com.ge.research.sadl.ui.preferences.ReasonerConfigurationDialog.java

License:Open Source License

private void updateButtons(boolean isValid) {
    Button okButton = getButton(IDialogConstants.OK_ID);
    if (okButton != null) {
        okButton.setEnabled(isValid);/*  w ww. j  a  v a  2s.c  om*/
    }
    if (isValid) {
        messageArea.updateText(null, IMessageProvider.NONE);
    } else {
        messageArea.updateText(getErrorMessages(), IMessageProvider.ERROR);
    }
}

From source file:com.ge.research.sadl.ui.preferences.TranslatorConfigurationDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    ConfigurationItem configItem = null;
    if (buttonId == IDialogConstants.OK_ID) {
        // make each editor save its value
        for (FieldEditor editor : editors) {
            editor.store();/*from  ww w  .j  a  va  2s .  c o m*/
        }
        // copy updated values into configuration map
        configItem = constructConfigurationOptions();
        Method validateMethod = null;
        try {
            validateMethod = translator.getClass().getMethod("ValidateConfigurationOptions", null);
            if (validateMethod != null) {
                logger.debug("Translator method ValidateConfigurationOptions found");
                translator.configure(configItem);
                String errorMessage = (String) validateMethod.invoke(translator, null);
                if (errorMessage.length() > 0) {
                    messageArea.updateText(errorMessage, IMessageProvider.ERROR);
                    return;
                }
            }
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        } catch (NoSuchMethodException e) {
            logger.debug("No Translator method ValidateConfigurationOptions found");
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return;
        }
    }
    updateConfigurationOptions(configItem);
    super.buttonPressed(buttonId);
}

From source file:com.google.appengine.eclipse.core.deploy.ui.DeployProjectDialog.java

License:Open Source License

private static int convertSeverity(IStatus status) {
    switch (status.getSeverity()) {
    case IStatus.ERROR:
        return IMessageProvider.ERROR;
    case IStatus.WARNING:
        return IMessageProvider.WARNING;
    case IStatus.INFO:
        return IMessageProvider.INFORMATION;
    default://w w w  . j a v  a2 s . c  om
        return IMessageProvider.NONE;
    }
}

From source file:com.google.cloud.tools.eclipse.appengine.deploy.ui.DeployPreferencesDialog.java

License:Apache License

@Override
protected Control createDialogArea(final Composite parent) {
    Composite dialogArea = (Composite) super.createDialogArea(parent);

    Composite container = new Composite(dialogArea, SWT.NONE);
    content = new StandardDeployPreferencesPanel(container, project, loginService, getLayoutChangedHandler(),
            true /* requireValues */);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(content);

    // we pull in Dialog's content margins which are zeroed out by TitleAreaDialog
    GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
    GridLayoutFactory.fillDefaults()//ww  w.ja v  a 2s  .  co m
            .margins(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN),
                    convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN))
            .spacing(convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING),
                    convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING))
            .generateLayout(container);

    TitleAreaDialogSupport.create(this, content.getDataBindingContext())
            .setValidationMessageProvider(new ValidationMessageProvider() {
                @Override
                public int getMessageType(ValidationStatusProvider statusProvider) {
                    int type = super.getMessageType(statusProvider);
                    setValid(type != IMessageProvider.ERROR);
                    return type;
                }
            });
    return dialogArea;
}

From source file:com.google.cloud.tools.eclipse.preferences.areas.AreaPreferencePageTest.java

License:Apache License

@Test
public void testErrorStatusResults() {
    page = new AreaBasedPreferencePage("test");
    area1 = new TestPrefArea("pref1", "value", preferences);
    page.addArea(area1);//from ww w.jav a2  s .c o  m

    show(page);
    assertTrue(page.isValid());
    assertEquals(IMessageProvider.NONE, page.getMessageType());

    area1.status = new Status(IStatus.ERROR, "foo", "message");
    area1.fireValueChanged(TestPrefArea.IS_VALID, true, false);

    assertFalse(page.isValid());
    assertEquals(IMessageProvider.ERROR, page.getMessageType());
    assertEquals("message", page.getMessage());
}

From source file:com.google.cloud.tools.eclipse.preferences.areas.AreaPreferencePageTest.java

License:Apache License

@Test
public void testStatusSeverityError() {
    // add three areas, status = WARN, ERROR, INFO; verify showing ERROR

    setupAreas();/*from w  ww  .  j  ava  2  s.  com*/

    area3.status = new Status(IStatus.INFO, "foo", "info3");
    area3.fireValueChanged(TestPrefArea.IS_VALID, true, false);

    assertTrue("should still be valid", page.isValid());
    assertEquals(IMessageProvider.INFORMATION, page.getMessageType());
    assertEquals("info3", page.getMessage());

    area1.status = new Status(IStatus.WARNING, "foo", "warn1");
    area1.fireValueChanged(TestPrefArea.IS_VALID, true, false);

    assertTrue("should still be valid", page.isValid());
    assertEquals(IMessageProvider.WARNING, page.getMessageType());
    assertEquals("warn1", page.getMessage());

    area2.status = new Status(IStatus.ERROR, "foo", "error2");
    area2.fireValueChanged(TestPrefArea.IS_VALID, true, false);

    assertFalse("should now be invalid", page.isValid());
    assertEquals(IMessageProvider.ERROR, page.getMessageType());
    assertEquals("error2", page.getMessage());
}