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

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

Introduction

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

Prototype

int INFORMATION

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

Click Source Link

Document

Constant for an info message (value 1).

Usage

From source file:org.erlide.ui.prefs.RuntimePreferencePage.java

License:Open Source License

/**
 * Removes the given VMs from the table.
 * /*from   w  ww  .j ava2 s.  co m*/
 * @param vms
 */
public void removeRuntimes(final RuntimeInfo[] vms) {
    final IStructuredSelection prev = (IStructuredSelection) getSelection();
    if (runtimes.size() == 1) {
        setMessage("You can't delete the last runtime definition", IMessageProvider.INFORMATION);
        return;
    }
    for (final RuntimeInfo element : vms) {
        runtimes.remove(element);
    }
    fRuntimeList.refresh();
    final IStructuredSelection curr = (IStructuredSelection) getSelection();
    if (!curr.equals(prev)) {
        final List<RuntimeInfo> installs = getRuntimes();
        if (curr.size() == 0 && installs.size() == 1) {
            // pick a default VM automatically
            setSelection(new StructuredSelection(installs.get(0)));
        } else {
            fireSelectionChanged();
        }
    }
    selectSingle();
}

From source file:org.fedoraproject.eclipse.packager.git.internal.ui.SelectModulePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    composite.setLayout(layout);/*from  ww w .  j  ava2  s  .  co  m*/

    // Package name controls
    Label label = new Label(composite, SWT.NONE);
    label.setText(FedoraPackagerGitText.SelectModulePage_packageName);
    projectText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    projectText.setLayoutData(gd);
    projectText.setFocus();
    projectText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (projectText.getText() == null || projectText.getText().trim().equals("")) { //$NON-NLS-1$
                setPageComplete(false);
                setErrorMessage(FedoraPackagerGitText.SelectModulePage_badPackageName);
            } else {
                setPageComplete(true);
                setErrorMessage(null);
            }
        }
    });

    boolean isUnknownUser = fasUser.equals(FedoraSSL.UNKNOWN_USER);

    // Options group
    Group optionsGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
    optionsGroup.setText(FedoraPackagerGitText.SelectModulePage_optionsGroup);
    optionsGroup.setLayout(new GridLayout());
    // Clone anonymously button
    anonymousCloneBtn = new Button(optionsGroup, SWT.CHECK);
    anonymousCloneBtn.setText(FedoraPackagerGitText.SelectModulePage_anonymousCheckout);
    anonymousCloneBtn.setSelection(isUnknownUser);
    // disable checkbox if there is no choice of cloning non-anonymously
    anonymousCloneBtn.setEnabled(!isUnknownUser);
    GridDataFactory.fillDefaults().grab(true, false).span(GROUP_SPAN, 1).applyTo(optionsGroup);
    updateMargins(optionsGroup);

    // Working set controls
    Control workingSetControl = workingSetGroup.createControl(composite);
    workingSetControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Set info message indicating which kind of clone we are about
    // to perform
    if (isUnknownUser) {
        setMessage(FedoraPackagerGitText.SelectModulePage_anonymousCloneInfoMsg, IMessageProvider.INFORMATION);
    } else {
        setMessage(NLS.bind(FedoraPackagerGitText.SelectModulePage_sshCloneInfoMsg, fasUser),
                IMessageProvider.INFORMATION);
    }

    setControl(composite);
}

From source file:org.fornax.cartridges.sculptor.framework.richclient.controller.AbstractWizardController.java

License:Apache License

/**
 * /* ww w.  j ava 2  s  .  c om*/
 * @return true if page is valid
 */
protected boolean updateValidationMessages() {
    boolean messageSet = false;
    IStatus statusParent = AggregateValidationStatus.getStatusMerged(getBindingContext().getBindings());

    // Iter for errors
    for (IStatus statusChild : statusParent.getChildren()) {
        if (statusChild.getSeverity() == IStatus.ERROR) {
            presentation.setErrorMessage(statusChild.getMessage());
            messageSet = true;
            if (statusChild.getException() != null) {
                statusChild.getException().printStackTrace();
            }
            break;
        }
    }
    if (!messageSet) {
        presentation.clearErrorMessage();
        // Iter for warnings
        for (IStatus statusChild : statusParent.getChildren()) {
            if (statusChild.getSeverity() == IStatus.WARNING) {
                presentation.setMessage(statusChild.getMessage(), IMessageProvider.WARNING);
                messageSet = true;
                break;
            }
        }
    }
    if (!messageSet) {
        // Iter for information
        for (IStatus statusChild : statusParent.getChildren()) {
            if (statusChild.getSeverity() == IStatus.INFO) {
                presentation.setMessage(statusChild.getMessage(), IMessageProvider.INFORMATION);
                messageSet = true;
                break;
            }
        }
    }

    if (!messageSet) {
        IStatus customValidationStatus = getValidationStatus();
        if (customValidationStatus == null) {
            presentation.clearErrorMessage();
            presentation.setMessage(null, IMessageProvider.NONE);
        } else if (customValidationStatus.getSeverity() == IStatus.ERROR) {
            presentation.setErrorMessage(customValidationStatus.getMessage());
        } else if (customValidationStatus.getSeverity() == IStatus.WARNING) {
            presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.WARNING);

        } else if (customValidationStatus.getSeverity() == IStatus.INFO) {
            presentation.setMessage(customValidationStatus.getMessage(), IMessageProvider.INFORMATION);
        }
    }

    if (!messageSet) {
        presentation.setMessage(null, IMessageProvider.NONE);
    }

    return !presentation.hasErrorMessage();
}

From source file:org.franca.core.ui.addons.wizard.StatusWizardPage.java

License:Open Source License

/**
 * Applies the status to the status line of the wizard page.
 * @param status the status to apply//from ww w.j  a v a2  s.co  m
 */
protected void applyStatus(IStatus status) {
    String msg = status.getMessage();
    if (msg != null && msg.length() == 0) {
        msg = null;
    }

    switch (status.getSeverity()) {
    case IStatus.OK:
        setMessage(msg, IMessageProvider.NONE);
        setErrorMessage(null);
        break;
    case IStatus.WARNING:
        setMessage(msg, IMessageProvider.WARNING);
        setErrorMessage(null);
        break;
    case IStatus.INFO:
        setMessage(msg, IMessageProvider.INFORMATION);
        setErrorMessage(null);
        break;
    default:
        setMessage(null);
        setErrorMessage(msg);
        break;
    }
}

From source file:org.fusesource.ide.camel.editor.dialogs.ConditionalBreakpointEditorDialog.java

License:Open Source License

@Override
public void create() {
    super.create();
    setTitle("Edit the condition and language of your breakpoint...");
    setMessage("Please choose a language and define a condition for the breakpoint...",
            IMessageProvider.INFORMATION);
}

From source file:org.fusesource.ide.camel.editor.preferences.PreferredLabelDialog.java

License:Open Source License

public void setDescription(String msg) {
    setMessage(msg, IMessageProvider.INFORMATION);
}

From source file:org.fusesource.ide.fabric8.ui.actions.jclouds.SelectCloudImageDialog.java

License:Open Source License

@Override
public void create() {
    super.create();
    setTitle("Select a cloud image...");
    setMessage("Please select the cloud image you want to use...", IMessageProvider.INFORMATION);
}

From source file:org.jboss.tools.fuse.transformation.editor.internal.wizards.WizardValidationMessageProvider.java

License:Open Source License

@Override
public int getMessageType(ValidationStatusProvider statusProvider) {
    if (statusProvider instanceof Binding) {
        Binding binding = (Binding) statusProvider;
        IStatus status = (IStatus) binding.getValidationStatus().getValue();

        // For required validations, we do not want to display an error
        // icon since the user has not done anything wrong.
        if (status.matches(IStatus.ERROR)) {
            return IMessageProvider.INFORMATION;
        }//from  www. j a  va 2 s.c  om
    }
    return super.getMessageType(statusProvider);
}

From source file:org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizardPage.java

License:Open Source License

/**
 * Initialize dialog's controls.//from   www  .ja va 2s.com
 * Fill in appropriate text and make validation.
 */
private void initializeFieldsAndAddLIsteners() {
    ISelection sel = getSelectionProvider().getSelection();
    if (ExternalizeStringsUtils.isSelectionCorrect(sel)) {
        String text = Constants.EMPTY;
        String stringToUpdate = Constants.EMPTY;
        TextSelection textSelection = null;
        IStructuredSelection structuredSelection = (IStructuredSelection) sel;
        textSelection = (TextSelection) sel;
        text = textSelection.getText();
        Object selectedElement = structuredSelection.getFirstElement();
        /*
         * When selected text is empty
         * parse selected element and find a string to replace..
         */
        if ((text.trim().length() == 0)) {
            if (selectedElement instanceof org.w3c.dom.Text) {
                /*
                 * ..it could be a plain text
                 */
                org.w3c.dom.Text textNode = (org.w3c.dom.Text) selectedElement;
                if (textNode.getNodeValue().trim().length() > 0) {
                    stringToUpdate = textNode.getNodeValue();
                    getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
                }
            } else if (selectedElement instanceof Attr) {
                /*
                 * ..or an attribute's value
                 */
                Attr attrNode = (Attr) selectedElement;
                if (attrNode.getNodeValue().trim().length() > 0) {
                    stringToUpdate = attrNode.getNodeValue();
                    getSelectionProvider().setSelection(new StructuredSelection(stringToUpdate));
                }
            }
            if ((stringToUpdate.trim().length() > 0)) {
                text = stringToUpdate;
            }
        }
        /*
         * https://issues.jboss.org/browse/JBIDE-9203
         * Replace special characters with their string representation.
         * Key should be generated first.
         */
        propsKey.setText(ExternalizeStringsUtils.generatePropertyKey(text));
        /*
         * Replaced escaped symbols by strings.
         */
        String value = text;
        if (value != null) {
            value = value.replaceAll("\t", "\\\\t"); //$NON-NLS-1$ //$NON-NLS-2$
            value = value.replaceAll("\r", "\\\\r"); //$NON-NLS-1$ //$NON-NLS-2$
            value = value.replaceAll("\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
        }
        propsValue.setText(value);
        /*
         * Initialize bundle messages field
         */
        if (bm == null) {
            JspEditorPlugin.getDefault().logWarning(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING);
        } else {
            BundleEntry[] bundles = bm.getBundles();
            Set<String> uriSet = new HashSet<String>();
            for (BundleEntry bundleEntry : bundles) {
                if (!uriSet.contains(bundleEntry.uri)) {
                    uriSet.add(bundleEntry.uri);
                    rbCombo.add(bundleEntry.uri);
                }
            }
            /*
             * Select the first bundle if there is any in the list 
             */
            if (rbCombo.getItemCount() > 0) {
                rbCombo.select(0);
                setResourceBundlePath(rbCombo.getText());
            } else {
                /*
                 * https://jira.jboss.org/browse/JBIDE-7247
                 * Select 'Create new file' checkbox and
                 * disable bundle group if no bundles are found.
                 */
                newFile.setSelection(true);
                enableBundleGroup(false);
            }
        }
        /*
         * Check the initial value status
         * When the same value is already externalized --
         * suggest to use already created key as well.
         */
        updatePropertiesValueStatus();
        updateDuplicateValueStatus();
        /*
         * When selected text is fine perform further validation
         */
        if (propsValueStatus.isOK()) {
            /*
             * Check the bundle for the value in it.
             * if so -- show the warning and set correct key.
             */
            if (!duplicateValueStatus.isOK()) {
                /*
                 * Set the same key value
                 */
                propsKey.setText(getValueForKey(propsValue.getText()));
                /*
                 * Set the new warning message
                 */
                applyStatus(this, new IStatus[] { duplicateValueStatus });
            } else {
                /*
                 * Check the initial key status
                 * If there is the error - add sequence number to the key
                 */
                updateDuplicateKeyStatus();
                while (!duplicateKeyStatus.isOK()) {
                    int index = propsKey.getText().lastIndexOf('_');
                    String newKey = Constants.EMPTY;
                    if (index != -1) {
                        /*
                         * String sequence at the end should be checked.
                         * If it is a sequence number - it should be increased by 1.
                         * If not - new number should be added.
                         */
                        String numberString = propsKey.getText().substring(index + 1);
                        int number;
                        try {
                            number = Integer.parseInt(numberString);
                            number++;
                            newKey = propsKey.getText().substring(0, index + 1) + number;
                        } catch (NumberFormatException e) {
                            newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
                        }
                    } else {
                        /*
                         * If the string has no sequence number - add it.
                         */
                        newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
                    }
                    /*
                     * Set the new key text
                     */
                    propsKey.setText(newKey);
                    updateDuplicateKeyStatus();
                }
                /*
                 * https://jira.jboss.org/browse/JBIDE-6945
                 * Set the greeting message only.
                 * All the validation will take place in the fields' listeners
                 * after user enters some new values. 
                 */
                setMessage(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME,
                        IMessageProvider.INFORMATION);
            }
        } else {
            /*
             * Set the message about wrong selected text.
             */
            applyStatus(this, new IStatus[] { propsValueStatus });
        }
        /*
         * Update the Buttons state.
         * When all the fields are correct -- 
         * then user should be able to  press OK
         */
        setPageComplete(isPageComplete());
        /*
         * Add selection listeners to the fields
         */
        propsKey.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                updateStatus();
            }
        });
        propsKey.addVerifyListener(new VerifyListener() {
            public void verifyText(VerifyEvent e) {
                for (int i = 0; i < ExternalizeStringsUtils.REPLACED_CHARACTERS.length; i++) {
                    /*
                     * Entering of the forbidden characters will be prevented.
                     * https://issues.jboss.org/browse/JBIDE-11551
                     * Dot(.) should be supported.
                     */
                    if ((e.character == ExternalizeStringsUtils.REPLACED_CHARACTERS[i])
                            && (e.character != '.')) {
                        e.doit = false;
                        break;
                    }
                }
            }
        });
        propsValue.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                updateStatus();
            }
        });
        newFile.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean selected = ((Button) e.getSource()).getSelection();
                if (selected) {
                    enableBundleGroup(false);
                } else {
                    enableBundleGroup(true);
                }
                updateStatus();
            }
        });
        rbCombo.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                setResourceBundlePath(rbCombo.getText());
                updateDuplicateKeyStatus();
                updateStatus();
            }
        });
    } else {
        JspEditorPlugin.getDefault().logWarning(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
    }
}

From source file:org.jboss.tools.jst.jsp.i18n.ExternalizeStringsWizardPage.java

License:Open Source License

/**
 * Apply status to the dialog.//w ww  . j  av  a  2s. c o  m
 *
 * @param page the page
 * @param statuses all the statuses
 */
private void applyStatus(DialogPage page, IStatus[] statuses) {
    IStatus severeStatus = statuses[0];
    for (IStatus status : statuses) {
        severeStatus = severeStatus.getSeverity() >= status.getSeverity() ? severeStatus : status;
    }
    String message = severeStatus.getMessage();
    switch (severeStatus.getSeverity()) {
    case IStatus.OK:
        page.setMessage(null, IMessageProvider.NONE);
        page.setErrorMessage(null);
        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;
    }
}