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

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

Introduction

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

Prototype

int WARNING

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

Click Source Link

Document

Constant for a warning message (value 2).

Usage

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

License:Apache License

@Override
public IStatus getStatus() {
    // DialogPage has an unfortunately complex set of message possibilities
    String message = messages.getErrorMessage();
    if (message != null) {
        return new Status(IStatus.ERROR, PLUGIN_ID, message);
    }//from w  ww. ja  va 2s  . c  o  m
    int messageType = messages.getMessageType();
    switch (messageType) {
    case IMessageProvider.INFORMATION:
        return new Status(IStatus.INFO, PLUGIN_ID, messages.getMessage());
    case IMessageProvider.WARNING:
        return new Status(IStatus.WARNING, PLUGIN_ID, messages.getMessage());
    case IMessageProvider.ERROR:
        return new Status(IStatus.ERROR, PLUGIN_ID, messages.getMessage());
    default:
        return Status.OK_STATUS;
    }
}

From source file:com.google.dart.tools.ui.internal.projects.CreateFileWizardPage.java

License:Open Source License

@Override
protected boolean validatePage() {
    boolean workspaceValidation = super.validatePage();
    if (!workspaceValidation) {
        return workspaceValidation;
    }//from w ww .java 2s .  co  m

    setMessage(null);

    String fileName = getFileName();

    boolean hasExtension = fileName.contains("."); //$NON-NLS-1$

    if ((!hasExtension || hasExtension && DartCore.isDartLikeFileName(fileName))
            && (StringUtilities.containsUpperCase(fileName) || StringUtilities.containsWhitespace(fileName))) {
        setMessage(ProjectMessages.CreateFileWizardPage_filename_content_warning_label,
                IMessageProvider.WARNING);
    }

    return true;
}

From source file:com.google.gdt.eclipse.core.ui.AbstractProjectPropertyPage.java

License:Open Source License

/**
 * Converts a standard IStatus's severity into the severity flags used by
 * dialogs and property pages./*from  ww  w  .  j  av  a 2s  .  co  m*/
 */
protected 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:
        return IMessageProvider.NONE;
    }
}

From source file:com.google.gdt.eclipse.core.ui.SdkTable.java

License:Open Source License

public SdkTable(Composite parent, int style, SdkSet<T> startingSdks,
        SdkManagerStateChangeListener stateChangeListener, DialogPage dialogPage) {
    super(parent, style);

    this.dialogPage = dialogPage;
    this.stateChangeListener = stateChangeListener;

    this.sdks = startingSdks;

    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;/*from  w ww . j  av a2s  . c  om*/
    layout.marginHeight = 0;
    setLayout(layout);

    final Label headerLabel = new Label(this, SWT.WRAP);
    final GridData headerLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    headerLabelGridData.widthHint = 250;
    headerLabel.setLayoutData(headerLabelGridData);
    headerLabel.setText(
            "Add, remove or download SDKs.\n\nBy default, the checked SDK is added to the build path of newly created projects.");

    Composite panel = this;
    final Label spacerLabel = new Label(panel, SWT.NONE);
    final GridData spacerLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    spacerLabelGridData.heightHint = 1;
    spacerLabel.setLayoutData(spacerLabelGridData);

    final Composite versionsPanel = new Composite(panel, SWT.NONE);
    final GridData versionsPanelGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    versionsPanel.setLayoutData(versionsPanelGridData);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.numColumns = 2;
    versionsPanel.setLayout(gridLayout);

    final Label tableHeaderLabel = new Label(versionsPanel, SWT.NONE);
    tableHeaderLabel.setText("SDKs:");
    GridDataFactory.fillDefaults().span(2, 1).applyTo(tableHeaderLabel);

    sdkTableViewer = CheckboxTableViewer.newCheckList(versionsPanel, SWT.FULL_SELECTION | SWT.BORDER);
    sdkTableViewer.setContentProvider(new ArrayContentProvider());
    sdkTableViewer.setLabelProvider(new ColumnLabelProvider());
    sdkTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateRemoteButtonEnabled();
            SdkTable.this.dialogPage.setMessage(null, IMessageProvider.NONE);

            // NOTE: It is bad form that this control sets the dialog page's message
            // directly.
            ISelection selection = event.getSelection();
            if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
                IStructuredSelection sselection = (IStructuredSelection) selection;
                Object firstElement = sselection.getFirstElement();
                Sdk sdk = (Sdk) firstElement;
                IStatus validationStatus = sdk != null ? sdk.validate() : Status.OK_STATUS;
                if (!validationStatus.isOK()) {
                    SdkTable.this.dialogPage.setMessage(validationStatus.getMessage(),
                            IMessageProvider.WARNING);
                }
            }
        }
    });
    sdkTableViewer.addCheckStateListener(new ICheckStateListener() {
        @SuppressWarnings("unchecked")
        public void checkStateChanged(CheckStateChangedEvent event) {
            // Only one GWT runtime can be the default
            if (event.getChecked()) {
                T sdk = (T) event.getElement();
                sdks.setDefault(sdk);
            }

            updateControls();

            fireStateChangedEvent();
        }
    });

    table = sdkTableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridDataFactory.fillDefaults().grab(true, true).hint(200, 200).applyTo(table);

    final TableColumn nameTableColumn = new TableColumn(table, SWT.NONE);
    nameTableColumn.setWidth(110);
    nameTableColumn.setText("Name");

    final TableColumn versionTableColumn = new TableColumn(table, SWT.NONE);
    versionTableColumn.setWidth(53);
    versionTableColumn.setText("Version");

    final TableColumn locationTableColumn = new TableColumn(table, SWT.NONE);
    locationTableColumn.setWidth(600);
    locationTableColumn.setText("Location");

    final Composite buttonsPanel = new Composite(versionsPanel, SWT.NONE);
    final GridData buttonsPanelGridData = new GridData(SWT.LEFT, SWT.TOP, false, false);
    buttonsPanel.setLayoutData(buttonsPanelGridData);
    final GridLayout buttonsPanelGridLayout = new GridLayout();
    buttonsPanelGridLayout.marginHeight = 0;
    buttonsPanelGridLayout.marginWidth = 0;
    buttonsPanel.setLayout(buttonsPanelGridLayout);

    final Button addButton = new Button(buttonsPanel, SWT.NONE);
    final GridData addButtonGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    addButtonGridData.widthHint = 76;
    addButton.setLayoutData(addButtonGridData);
    addButton.setText("Add...");
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStatus status = doAddSdk();
            if (status.isOK()) {
                updateControls();
                fireStateChangedEvent();
            }
        }
    });

    removeButton = new Button(buttonsPanel, SWT.NONE);
    final GridData removeButtonGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    removeButtonGridData.widthHint = 76;
    removeButton.setLayoutData(removeButtonGridData);
    removeButton.setText("Remove");
    removeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            removeSelectedSdk();
            updateControls();
            fireStateChangedEvent();
        }
    });

    dowloadButton = new Button(buttonsPanel, SWT.NONE);
    final GridData downloadButtonGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    removeButtonGridData.widthHint = 76;
    dowloadButton.setLayoutData(downloadButtonGridData);
    dowloadButton.setText("Download...");
    dowloadButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStatus status = doDownloadSdk();
            if (status.isOK()) {
                updateControls();
                fireStateChangedEvent();
            }
        }
    });

    final Label footerLabel = new Label(panel, SWT.NONE);
    final GridData footerLabelGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    footerLabel.setLayoutData(footerLabelGridData);

    sdkTableViewer.setInput(sdks);
    sdkTableViewer.setContentProvider(new IStructuredContentProvider() {
        public void dispose() {
        }

        public Object[] getElements(Object inputElement) {
            return sdks.toArray();
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });

    updateControls();
    updateRemoteButtonEnabled();
}

From source file:com.google.gdt.eclipse.mobile.android.wizards.NewAndroidCloudProjectWizardPage.java

License:Open Source License

/**
 * Sets the error message for the wizard with the given message icon.
 * //  ww w.  j a  v  a 2s .  c  o m
 * @param message The wizard message type, one of MSG_ERROR or MSG_WARNING.
 * @return As a convenience, always returns messageType so that the caller can
 *         return immediately.
 */
private int setStatus(String message, int messageType) {
    if (message == null) {
        setErrorMessage(null);
        setMessage(null);
    } else if (!message.equals(getMessage())) {
        if (messageType == MSG_NONE) {
            setMessage(message, IMessageProvider.NONE);
        } else if (messageType == MSG_ERROR) {
            setMessage(message, IMessageProvider.ERROR);
        } else {
            setMessage(message, IMessageProvider.WARNING);
        }
    }
    return messageType;
}

From source file:com.gorillalogic.monkeyconsole.editors.utils.TitleAreaDialogStyledTextMessage.java

License:Open Source License

/**
 * Sets the message for this dialog with an indication of what type of
 * message it is./*from  w ww .  ja  v  a  2  s  .  com*/
 * <p>
 * The valid message types are one of <code>NONE</code>,
 * <code>INFORMATION</code>,<code>WARNING</code>, or
 * <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type
 * <code>ERROR</code> is different than an error message (set using
 * <code>setErrorMessage</code>). An error message overrides the current
 * message until the error message is cleared. This method replaces the
 * current message and does not affect the error message.
 * </p>
 * 
 * @param newMessage
 *            the message, or <code>null</code> to clear the message
 * @param newType
 *            the message type
 * @since 2.0
 */
public void setMessage(String newMessage, int newType) {
    Image newImage = null;
    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;
        }
    }
    showMessage(newMessage, newImage);
}

From source file:com.ibm.xsp.extlib.designer.bluemix.wizard.AbstractBluemixWizardPage.java

License:Open Source License

protected void showWarning(String msg) {
    if (StringUtil.isEmpty(msg)) {
        setMessage(StringUtil.format(getPageMsg(), "\n"), IMessageProvider.INFORMATION); // $NON-NLS-1$
    } else {/*from   w  w w.ja v  a 2s . c om*/
        setMessage(msg, IMessageProvider.WARNING);
    }
}

From source file:com.ibm.xsp.extlib.designer.bluemix.wizard.DirectoryBluemixWizardPage.java

License:Open Source License

@Override
public void modifyText(ModifyEvent event) {
    if (event.widget == _dirText) {
        if (_wiz.origConfig.isValid(false)) {
            if (!StringUtil.equalsIgnoreCase(_wiz.origConfig.directory, getDirectory())) {
                setMessage(//from ww  w . java2s  .c  om
                        "Warning, you are changing the deployment directory for this application. The existing configuration will be lost.", // $NLX-DirectoryBluemixWizardPage.Warningyouarechangingthedeploymen-1$
                        IMessageProvider.WARNING);
            } else {
                setMessage(getPageMsg(), IMessageProvider.INFORMATION);
            }
        }

        validatePage();
    }
}

From source file:com.inavare.maven.platform.WizardPageExtension.java

License:Open Source License

protected void update() {
    String dir = this.directoryText.getText();
    File file = new File(dir);

    setMessage(null);/*from w ww  .j  a va  2 s . co m*/
    setPageComplete(false);

    if (!file.exists()) {
        setMessage(String.format("Directory '%s' does not exists", file.getAbsolutePath()),
                IMessageProvider.ERROR);
        return;
    }
    if (!file.isDirectory()) {
        setMessage(String.format("Path '%s' is not a directory", file.getAbsolutePath()),
                IMessageProvider.ERROR);
        return;
    }
    if (!file.canRead()) {
        setMessage(String.format("Directory '%s' is not readable", file.getAbsolutePath()),
                IMessageProvider.WARNING);
    }
    if (!file.isAbsolute()) {
        setMessage(String.format("Path to '%s' is not absolute", file.getAbsolutePath()),
                IMessageProvider.WARNING);
    }

    setPageComplete(true);
}

From source file:com.iw.plugins.spindle.ui.preferences.AbstractPreferencePage.java

License:Open Source License

private void applyToStatusLine(DialogPage page, IStatus status) {
    String message = status.getMessage();
    switch (status.getSeverity()) {
    case IStatus.OK:
        page.setMessage(message, IMessageProvider.NONE);
        page.setErrorMessage(null);/*from w w  w . j av  a  2 s. com*/
        break;
    case IStatus.WARNING:
        page.setMessage(message, IMessageProvider.WARNING);
        page.setErrorMessage(null);
        break;
    case IStatus.INFO:
        page.setMessage(message, IMessageProvider.INFORMATION);
        page.setErrorMessage(null);
        break;
    default:
        if (message.length() == 0) {
            message = null;
        }
        page.setMessage(null);
        page.setErrorMessage(message);
        break;
    }
}