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.jboss.tools.jst.web.ui.internal.editor.i18n.ExternalizeStringsWizardPage.java

License:Open Source License

/**
 * Initialize dialog's controls.//from   ww w.  ja v  a  2 s  . c om
 * 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) {
            WebUiPlugin.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 {
        WebUiPlugin.getDefault().logWarning(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_INITIALIZATION_ERROR);
    }
}

From source file:org.jboss.tools.jst.web.ui.palette.html.jquery.wizard.JQueryVersionPage.java

License:Open Source License

protected void createFieldPanel(Composite parent) {
    for (JSLib lib : JSLibFactory.getInstance().getPreferenceModel().getSortedLibs()) {
        if (lib.getVersions().isEmpty())
            continue;
        String libName = lib.getName();
        List<String> versions = new ArrayList<String>(lib.getVersionNames());
        String defaultVersion = getWizard().getPreferredVersions().getLibVersion(libName);

        boolean isAddSelected = getWizard().getPreferredVersions().shouldAddLib(libName);
        boolean isEnabled = !getWizard().getPreferredVersions().isLibDisabled(libName);

        String checkboxId = "add " + libName;
        IFieldEditor checkbox = JQueryFieldEditorFactory.createAddJSLibEditor(checkboxId, libName,
                isAddSelected && isEnabled);
        addEditor(checkbox, parent);/*www. j a v  a  2 s  .  co m*/
        checkboxIds.put(libName, checkboxId);

        String selectorId = "select " + libName;
        IFieldEditor selector = JQueryFieldEditorFactory.createJSLibVersionEditor(selectorId, versions,
                defaultVersion);
        addEditor(selector, parent);
        selectorIds.put(libName, selectorId);

        if (!isEnabled && fields != null) {
            checkbox.setEnabled(false);
            selector.setEnabled(false);
            if (defaultMessage == null) {
                setMessage(defaultMessage = "Page already contains " + libName + " library.",
                        IMessageProvider.INFORMATION);
            }
        }
    }

    if (parent != null)
        createReference(parent);
}

From source file:org.jboss.tools.jst.web.ui.palette.html.wizard.VersionPage.java

License:Open Source License

protected void createFieldPanel(Composite parent) {
    for (JSLib lib : JSLibFactory.getInstance().getPreferenceModel().getSortedLibs()) {
        if (lib.getVersions().isEmpty())
            continue;
        String libName = lib.getName();
        List<String> versions = new ArrayList<String>(lib.getVersionNames());
        String defaultVersion = getPreferredVersions().getLibVersion(libName);

        boolean isAddSelected = getPreferredVersions().shouldAddLib(libName);
        boolean isEnabled = !getPreferredVersions().isLibDisabled(libName);

        String checkboxId = "add " + libName;
        IFieldEditor checkbox = JQueryFieldEditorFactory.createAddJSLibEditor(checkboxId, libName,
                isAddSelected && isEnabled);
        addEditor(checkbox, parent);/*from ww w.  j  ava  2 s  .c o  m*/
        checkboxIds.put(libName, checkboxId);

        String selectorId = "select " + libName;
        IFieldEditor selector = JQueryFieldEditorFactory.createJSLibVersionEditor(selectorId, versions,
                defaultVersion);
        addEditor(selector, parent);
        selectorIds.put(libName, selectorId);

        if (!isEnabled && fields != null) {
            checkbox.setEnabled(false);
            selector.setEnabled(false);
            if (defaultMessage == null) {
                setMessage(defaultMessage = "Page already contains " + libName + " library.",
                        IMessageProvider.INFORMATION);
            }
        }
    }

    if (parent != null)
        createReference(parent);
}

From source file:org.jboss.tools.modeshape.rest.wizards.PublishPage.java

License:Open Source License

/**
 * Updates message, message icon, and OK button enablement based on validation results
 *///from  w  w w  .j ava 2  s.  com
void updateState() {
    // get the current state
    validate();

    // update OK/Finish button enablement
    setPageComplete(!this.status.isError());

    // update page message
    if (this.status.isError()) {
        setMessage(this.status.getMessage(), IMessageProvider.ERROR);
    } else {
        if (this.status.isWarning()) {
            setMessage(this.status.getMessage(), IMessageProvider.WARNING);
        } else if (this.status.isInfo()) {
            setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
        } else {
            setMessage(this.status.getMessage(), IMessageProvider.NONE);
        }
    }
}

From source file:org.jboss.tools.modeshape.rest.wizards.ServerPage.java

License:Open Source License

/**
 * Updates message, message icon, and OK button enablement based on validation results
 *//* www .  j  a va 2  s.c om*/
private void updateState() {
    // get the current status
    validate();

    // update OK/Finish button
    setPageComplete(!this.status.isError());

    // update message
    if (this.status.isError()) {
        setMessage(this.status.getMessage(), IMessageProvider.ERROR);
    } else {
        if (this.status.isWarning()) {
            setMessage(this.status.getMessage(), IMessageProvider.WARNING);
        } else if (this.status.isInfo()) {
            setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
        } else {
            setMessage(RestClientI18n.serverPageOkStatusMsg);
        }
    }
}

From source file:org.jboss.tools.openshift.express.internal.ui.server.CommitDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    //      parent.getShell().setText(UIText.CommitDialog_CommitChanges);
    parent.getShell().setText("Publish Changes");

    container = toolkit.createComposite(container);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
    toolkit.paintBordersFor(container);//  www  .  j  a v  a2s  .c o  m
    GridLayoutFactory.swtDefaults().applyTo(container);

    final SashForm sashForm = new SashForm(container, SWT.VERTICAL | SWT.FILL);
    toolkit.adapt(sashForm, true, true);
    sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    createMessageAndPersonArea(sashForm);
    filesSection = createFileSection(sashForm);
    sashForm.setWeights(new int[] { 50, 50 });

    applyDialogFont(container);
    container.pack();
    commitText.setFocus();
    //      Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage();
    //      UIUtils.hookDisposal(parent, titleImage);
    //      setTitleImage(titleImage);
    setTitleImage(ExpressImages.OPENSHIFT_LOGO_WHITE_MEDIUM_IMG);
    //      setTitle(UIText.CommitDialog_Title);
    setTitle("Commit and push local changes to OpenShift");
    setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION);

    filesViewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateMessage();
        }
    });

    updateFileSectionText();
    return container;
}

From source file:org.jboss.tools.openshift.express.internal.ui.server.CommitDialog.java

License:Open Source License

private void updateMessage() {
    if (commitButton == null)
        // Not yet fully initialized.
        return;/*from   w  w w  . j  a v  a2 s .c  o  m*/

    String message = null;
    int type = IMessageProvider.NONE;

    String commitMsg = commitMessageComponent.getCommitMessage();
    if (commitMsg == null || commitMsg.trim().length() == 0) {
        message = UIText.CommitDialog_Message;
        type = IMessageProvider.INFORMATION;
    } else if (!isCommitWithoutFilesAllowed()) {
        message = UIText.CommitDialog_MessageNoFilesSelected;
        type = IMessageProvider.INFORMATION;
    } else {
        CommitStatus status = commitMessageComponent.getStatus();
        message = status.getMessage();
        type = status.getMessageType();
    }

    //      setMessage(message, type);
    //      boolean commitEnabled = type == IMessageProvider.WARNING
    //            || type == IMessageProvider.NONE;
    this.canCommit = type == IMessageProvider.WARNING || type == IMessageProvider.NONE;
    commitButton.setEnabled(canCommit);
    //      commitAndPushButton.setEnabled(commitEnabled);
    if (canCommit) {
        commitButton.setText("Commit and Publish");
        commitButton.setEnabled(canCommit);
    } else {
        if (isAhead) {
            commitButton.setText("Publish Only");
            commitButton.setEnabled(true);
        } else {
            commitButton.setText("Commit and Publish");
            commitButton.setEnabled(false);
        }
    }

    if (!canCommit && isAhead && isDirty()) {
        message += NLS.bind(
                "\nIf you publish now, uncommitted changes will not be present in your OpenShift application {0}",
                applicationName);
    }

    setMessage(message, type);
}

From source file:org.jcryptool.crypto.xml.ui.decrypt.PageKey.java

License:Open Source License

/**
 * Determines the (error) message for the missing field.
 *///from   ww w.j av a2 s . c  o  m
private void dialogChanged() {
    if (tKeyName.getText().length() == 0) {
        updateStatus(Messages.missingKeyName, IMessageProvider.INFORMATION);
        return;
    }

    if (tKeyPassword.getText().length() == 0) {
        updateStatus(Messages.missingKeyPassword, IMessageProvider.INFORMATION);
        return;
    }

    updateStatus(null, IMessageProvider.NONE);
}

From source file:org.jcryptool.crypto.xml.ui.decrypt.PageKeystore.java

License:Open Source License

/**
 * Determines the (error) message for the missing field.
 *//*w w  w . ja  v a  2 s . c om*/
private void dialogChanged() {
    if (tKeystore.getText().length() == 0) {
        updateStatus(Messages.missingKeystore, IMessageProvider.INFORMATION);
        return;
    } else if (!(new File(tKeystore.getText()).exists())) {
        updateStatus(Messages.keystoreNotFound, IMessageProvider.ERROR);
        return;
    }

    if (tKeystorePassword.getText().length() == 0) {
        updateStatus(Messages.missingKeystorePassword, IMessageProvider.INFORMATION);
        return;
    }

    if (tKeyName.getText().length() == 0) {
        updateStatus(Messages.missingKeyName, IMessageProvider.INFORMATION);
        return;
    }

    if (tKeyPassword.getText().length() == 0) {
        updateStatus(Messages.missingKeyPassword, IMessageProvider.INFORMATION);
        return;
    }

    if (new File(tKeystore.getText()).exists()) {
        try {
            keystore = new Keystore(tKeystore.getText(), tKeystorePassword.getText(), IGlobals.KEYSTORE_TYPE);
            keystore.load();
            if (!keystore.containsKey(tKeyName.getText())) {
                updateStatus(Messages.verifyKeyName, IMessageProvider.ERROR);
                return;
            }

            if (keystore.getSecretKey(tKeyName.getText(), tKeyPassword.getText().toCharArray()) == null) {
                updateStatus(Messages.verifyKeyPassword, IMessageProvider.ERROR);
                return;
            }
        } catch (Exception ex) {
            updateStatus(Messages.verifyAll, IMessageProvider.ERROR);
            return;
        }
    } else {
        updateStatus(Messages.keystoreNotFound, IMessageProvider.ERROR);
        return;
    }

    updateStatus(null, IMessageProvider.NONE);
}

From source file:org.jcryptool.crypto.xml.ui.decrypt.PageResource.java

License:Open Source License

/**
 * Determines the (error) message for the missing field.
 *//*from ww  w  .j  a  v a 2 s . co  m*/
private void dialogChanged() {
    if (globalError) {
        return;
    }

    if ("".equals(cEncryptionId.getText())) {
        updateStatus(Messages.missingEncryptionId, IMessageProvider.INFORMATION);
        return;
    }

    updateStatus(null, IMessageProvider.NONE);
}