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.motorola.studio.android.packaging.ui.export.PackageExportWizardArea.java

License:Apache License

/**
 * Can finish used in {@link IWizardPage} This method validate the page and
 * change the severity/message.// w w  w  . ja va 2  s  .  c om
 * 
 * @return true if can finish this wizard, false otherwise
 */
public boolean canFinish() {
    String messageAux = null;
    int severity_aux = IMessageProvider.NONE;

    /*
     * Check is has selected items
     */
    if (!hasItemChecked()) {
        messageAux = Messages.SELECTOR_MESSAGE_NO_SELECTION;
        if (treeSelectionChanged) {
            severity_aux = IMessageProvider.ERROR;
        } else {
            severity_aux = IMessageProvider.INFORMATION;
        }
    }

    // validate if some selected project has errors
    if (messageAux == null) {
        Iterator<IProject> iterator = getSelectedProjects().iterator();
        while (iterator.hasNext() && (severity_aux != IMessageProvider.ERROR)) {
            severity_aux = projectSeverity.get(iterator.next());
        }
        if (severity_aux == IMessageProvider.ERROR) {
            messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_PROJECTS_WITH_ERRORS_SELECTED;

        }
    }

    /*
     * Check if the selected location is valid, even if non existent.
     */
    IPath path = new Path(this.destinationText.getText());

    if (!this.defaultDestination.getSelection() && (messageAux == null)) {
        // Test if path is blank, to warn user instead of show an error
        // message
        if (this.destinationText.getText().equals("")) //$NON-NLS-1$
        {
            messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID;
            severity_aux = IMessageProvider.INFORMATION;
        }

        /*
         * Do Win32 Validation
         */
        if ((messageAux == null) && Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)) {
            // test path size
            if (path.toString().length() > 255) {
                messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_PATH_TOO_LONG;
                severity_aux = IMessageProvider.ERROR;
            }
            String device = path.getDevice();
            File deviceFile = null;
            if (device != null) {
                deviceFile = new File(path.getDevice());
            }

            if ((device != null) && !deviceFile.exists()) {
                messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID_DEVICE + " [" + device //$NON-NLS-1$
                        + "]"; //$NON-NLS-1$
                severity_aux = IMessageProvider.ERROR;
            }

        }
        // test if path is absolute
        if (messageAux == null) {
            if (!path.isAbsolute()) {
                messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID;
                severity_aux = IMessageProvider.ERROR;
            }
        }

        if (messageAux == null) {
            for (String folderName : path.segments()) {
                if (!ResourcesPlugin.getWorkspace().validateName(folderName, IResource.FOLDER).isOK()) {
                    messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID;
                    severity_aux = IMessageProvider.ERROR;

                }
            }
        }

        if ((messageAux == null) && path.toFile().exists() && !path.toFile().isDirectory()) {
            messageAux = Messages.SELECTOR_MESSAGE_LOCATION_ERROR_NOT_DIRECTORY;
            severity_aux = IMessageProvider.ERROR;
        }
    }

    /*
     * Check if there are available certificates and if selection isn't null
     */
    if (messageAux == null) {

        if (this.signingEnabled && (this.signCheckBox != null) && this.signCheckBox.getSelection()
                && !((this.keystores != null) && (this.keystores.getItemCount() > 0))) {
            messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_SIGN_NO_KEYSTORE_AVAILABLE;
            severity_aux = IMessageProvider.ERROR;
        }

        else if (this.signCheckBox.getSelection() && !((this.keysCombo != null)
                && (this.keysCombo.getItemCount() > 0) && (this.keysCombo.getSelectionIndex() >= 0)
                && (this.keysCombo.getItem(this.keysCombo.getSelectionIndex()) != null)
                && !this.keysCombo.getItem(this.keysCombo.getSelectionIndex()).equals(""))) //$NON-NLS-1$ 
        {
            messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_SIGN_NO_KEYSTORE_OR_KEY_SELECTED;
            severity_aux = IMessageProvider.ERROR;
        }

    }

    if (messageAux == null) {
        if (!this.signCheckBox.getSelection()) {
            messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_UNSIGNEDPACKAGE_WARNING;
            severity_aux = IMessageProvider.WARNING;
        }
    }

    /*
     * Setting message
     */
    if (messageAux == null) {
        messageAux = Messages.PACKAGE_EXPORT_WIZARD_AREA_DESCRIPTION;
        severity_aux = IMessageProvider.NONE;
    }
    this.message = messageAux;
    this.severity = severity_aux;

    boolean result;
    switch (severity_aux) {
    case IMessageProvider.ERROR:
        // ERROR. can't finish wizard
        result = false;
        break;

    case IMessageProvider.WARNING:
        // WARNING. ok to finish the wizard
        result = true;
        break;

    case IMessageProvider.INFORMATION:
        // INFORMATION. Path is empty, so it's NOT OK to finish the wizard
        result = false;
        break;

    default:
        // by default, canFinish returns true
        result = true;
        break;

    }

    return result;
}

From source file:com.motorola.studio.android.propertypage.MotodevStudioPropertyPage.java

License:Apache License

private void addFirstSection(Composite parent) {
    Composite group = createDefaultComposite(parent);

    Composite composite = new Composite(group, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*from   w w  w.ja v  a2s .  c o m*/
    composite.setLayout(layout);

    GridData data = new GridData();
    data.verticalAlignment = GridData.FILL;
    data.horizontalAlignment = GridData.FILL;
    composite.setLayoutData(data);

    obfuscateCkbox = new Button(composite, SWT.CHECK);

    setDefaultObfuscate();

    Label obfuscateLabel = new Label(composite, SWT.NONE);
    obfuscateLabel.setText(AndroidNLS.UI_ProjectPropertyPage_Obfuscate);

    obfuscateCkbox.addSelectionListener(new SelectionAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);

            boolean showWarningMessage = false;
            if (obfuscateCkbox.getSelection()) {
                if ((project != null) && project.getLocation().toOSString().contains(" ")) //$NON-NLS-1$
                {
                    showWarningMessage = true;
                }
            }
            if (showWarningMessage) {
                setMessage(AndroidNLS.WRN_Obfuscation_ProjectLocationContainWhitespaces,
                        IMessageProvider.WARNING);

            } else {
                setMessage("MOTODEV Studio"); //$NON-NLS-1$
            }
        }
    });
}

From source file:com.motorola.studio.android.remote.ui.wireless.WirelessDeviceWizardPage.java

License:Apache License

private void setStatusMessage() {
    IStatus status = composite.getStatus();
    switch (status.getSeverity()) {
    case IStatus.ERROR:
        setErrorMessage(status.getMessage());
        setMessage(null);/*w ww .j  a  va2s.c o  m*/
        break;
    case IStatus.WARNING:
        setErrorMessage(null);
        setMessage(status.getMessage(), IMessageProvider.WARNING);
        break;
    case IStatus.OK:
        setErrorMessage(null);
        setMessage(status.getMessage(), IMessageProvider.INFORMATION);
        break;
    }
}

From source file:com.motorolamobility.preflighting.ui.CommandLinePreferencePage.java

License:Apache License

public void validateUI(AbstractAppValidatorTabComposite composite) {
    IStatus status = composite.isValid();

    if (status.getSeverity() == IStatus.ERROR) {
        setValid(false);/*from w  w  w .  j av  a2 s.co  m*/
        setMessage(status.getMessage(), IMessageProvider.ERROR);
    } else if (status.getSeverity() == IStatus.WARNING) {
        setMessage(status.getMessage(), IMessageProvider.WARNING);
    } else {
        setValid(true);
        setMessage(null);
    }

}

From source file:com.motorolamobility.preflighting.ui.wizards.ApkValidationWizardPage.java

License:Apache License

/**
 * Validates if the source directory is valid one
 * //www. j a  va 2  s.c o m
 * @return true if the source dir text is valid, false otherwise
 */
private boolean isSourceDirValid() {

    String messageAux = null;
    int severity = IMessageProvider.NONE;

    /*
     * Check if the selected location is valid, even if non existent.
     */
    IPath path = new Path(this.sourceDirText.getText());

    // Test if path is blank, to warn user instead of show an error message
    if (this.sourceDirText.getText().equals("")) //$NON-NLS-1$
    {
        messageAux = PreflightingUiNLS.ApkValidationWizardPage_emptyListMsg;
        severity = IMessageProvider.INFORMATION;
    }

    /*
     * Do Win32 Validation
     */
    if ((messageAux == null) && Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)) {
        // test path size
        if (path.toString().length() > 255) {
            messageAux = PreflightingUiNLS.ApkValidationWizardPage_tooLongMsg;
            severity = IMessageProvider.WARNING;
        }
        String device = path.getDevice();
        File deviceFile = null;
        if (device != null) {
            deviceFile = new File(path.getDevice());
        }

        if ((device != null) && !deviceFile.exists()) {
            messageAux = PreflightingUiNLS.ApkValidationWizardPage_invalidDeviceMsg + " [" + device + "]"; //$NON-NLS-2$ //$NON-NLS-3$
            severity = IMessageProvider.ERROR;
        }

    }
    // test if path is absolute
    if (messageAux == null) {
        if (!path.isAbsolute() || !path.toFile().exists()) {
            messageAux = PreflightingUiNLS.ApkValidationWizardPage_invalidFolderMsg;
            severity = IMessageProvider.ERROR;
        }
    }

    if (messageAux == null) {
        for (String folderName : path.segments()) {
            if (!ResourcesPlugin.getWorkspace().validateName(folderName, IResource.FOLDER).isOK()) {
                messageAux = PreflightingUiNLS.ApkValidationWizardPage_invalidFolderMsg;
                severity = IMessageProvider.ERROR;
            }
        }
    }

    if ((messageAux == null) && ((path.toFile().exists() && !path.toFile().isDirectory()))) {
        messageAux = PreflightingUiNLS.ApkValidationWizardPage_invalidSourceDirectoryMsg;
        severity = IMessageProvider.ERROR;
    }

    /*
     * Setting message
     */
    if (messageAux == null) {
        messageAux = PreflightingUiNLS.ApkValidationWizardPage_validateMsg;
        severity = IMessageProvider.NONE;
    }
    setMessage(messageAux, severity);
    return severity == IMessageProvider.NONE;
}

From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.BackupDialog.java

License:Apache License

private void validate() {

    boolean isValid = true;
    boolean hasWarn = false;
    Path path = new Path(archivePath);
    try {/*  www .  j  a va  2s  . c o  m*/
        if (archivePath.isEmpty() || !path.isValidPath(archiveFile.getCanonicalPath())) {
            setErrorMessage(CertificateManagerNLS.BackupDialog_Invalid_Destination_Title);
            isValid = false;
        }
    } catch (IOException e) {
        setErrorMessage(CertificateManagerNLS.BackupDialog_Invalid_Destination_Title);
        isValid = false;
    }

    if (isValid) {
        if (archiveFile.exists() && (archiveFile.isDirectory())) {
            setErrorMessage(CertificateManagerNLS.BackupDialog_Invalid_Destination_Message);
            isValid = false;
        }
    }

    if (isValid) {
        if (!archiveFile.isAbsolute()) {
            setMessage(NLS.bind(CertificateManagerNLS.BackupDialog_Non_Absolute_Path,
                    archiveFile.getAbsolutePath()), IMessageProvider.WARNING);
            hasWarn = true;
        }
    }

    if (isValid) {
        if (selectedKeyStores.isEmpty()) {
            setErrorMessage(CertificateManagerNLS.BackupDialog_Select_KeyStore);
            isValid = false;
        } else {
            setErrorMessage(null);
            if (!hasWarn) {
                setMessage(CertificateManagerNLS.BackupDialog_Default_Message);
            }
            isValid = true;
        }
    }

    getButton(OK).setEnabled(isValid);
}

From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.importks.ConvertKeyStoreTypeDialog.java

License:Apache License

public void validateUi() {
    boolean isValid = true;
    setErrorMessage(null);/*  ww  w .  ja  v a2s  .c o m*/
    if (isValid && (keyStore == null)) {
        isValid = false;
        setMessage(CertificateManagerNLS.ConvertKeyStoreTypeDialog_Choose_KeyStore_Msg);
    }
    if (isValid) {
        boolean passwordValid;
        try {
            passwordValid = keyStore.isPasswordValid(password);
        } catch (KeyStoreManagerException e) {
            passwordValid = false;
        } catch (InvalidPasswordException e) {
            passwordValid = false;
        }
        if (!passwordValid) {
            isValid = false;
            setErrorMessage(CertificateManagerNLS.ConvertKeyStoreTypeDialog_Invalid_Keystore_Pass);
        }
    }
    if (isValid && newType.isEmpty()) {
        isValid = false;
        setMessage(CertificateManagerNLS.ConvertKeyStoreTypeDialog_Choose_New_Type_Msg);
    }
    if (isValid) {
        Object input = entriesTableViewer.getInput();
        if (input != null) {
            int itemCount = ((List<?>) input).size();
            for (int i = 0; i < itemCount; i++) {
                EntryModel entryModel = (EntryModel) entriesTableViewer.getElementAt(i);
                if ((entryModel != null) && !entryModel.isVerified()) {
                    isValid = false;
                    setMessage(CertificateManagerNLS.ConvertKeyStoreTypeDialog_Incorrect_Entry_Pass,
                            IMessageProvider.WARNING);
                    break;
                }
            }
        }
    }

    Button okButton = getButton(OK);
    if (okButton != null) {
        if (!isValid) {
            okButton.setEnabled(false);
        } else {
            getButton(OK).setEnabled(true);
            setErrorMessage(null);
            setMessage(CertificateManagerNLS.ConvertKeyStoreTypeDialog_DefaultMessage);
        }
    }
}

From source file:com.motorolamobility.studio.android.certmanager.ui.dialogs.importks.ImportEntriesDialog.java

License:Apache License

public void validateUi() {
    boolean isValid = true;
    setErrorMessage(null);/*from   ww w .j a  va  2 s  .com*/
    if (isValid && (sourceKeyStore == null)) {
        isValid = false;
        setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Select_Source_Ks);
    }
    if (isValid && ((sourcePassword == null) || sourcePassword.isEmpty())) {
        isValid = false;
        setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Type_SourceKs_Passwd);
    }
    if (isValid) {
        try {
            if (!sourceKeyStore.isPasswordValid(sourcePassword)) {
                isValid = false;
                setErrorMessage("Wrong source keystore password.");
            }
        } catch (KeyStoreManagerException e) {
            isValid = false;
            setErrorMessage("Unable to access source keystore.\n" + e.getMessage());
        } catch (InvalidPasswordException e) {
            isValid = false;
            setErrorMessage("Wrong source keystore password.");
        }
    }
    if (isValid) {
        List<?> input = (List<?>) entriesTableViewer.getInput();
        if (input != null) {
            int itemCount = input.size();
            if (itemCount == 0) {
                isValid = false;
                setMessage(CertificateManagerNLS.ImportKeyStoreDialog_No_Entries_To_Import,
                        IMessageProvider.WARNING);
            }
            if (entriesTableViewer.getCheckedElements().length == 0) {
                isValid = false;
                setMessage(CertificateManagerNLS.ImportKeyStoreDialog_No_Entries_To_Import,
                        IMessageProvider.WARNING);
            } else {
                for (int i = 0; i < itemCount; i++) {
                    EntryModel entryModel = (EntryModel) entriesTableViewer.getElementAt(i);
                    if (entriesTableViewer.getChecked(entryModel) && !entryModel.isVerified()) {
                        isValid = false;
                        setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Wrong_Entries_Passwd,
                                IMessageProvider.WARNING);
                        break;
                    }
                }
            }
        } else {
            isValid = false;
            setMessage(CertificateManagerNLS.ImportKeyStoreDialog_No_Entries_To_Import,
                    IMessageProvider.WARNING);
        }
    }
    if (isValid && (targetKeyStore == null)) {
        isValid = false;
        setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Select_Target_Kesytore);
    }

    if (!isValid) {
        getButton(OK).setEnabled(false);
    } else {
        getButton(OK).setEnabled(true);
        setErrorMessage(null);
        setMessage(CertificateManagerNLS.ImportKeyStoreDialog_Default_Message);
    }
}

From source file:com.motorolamobility.studio.android.certmanager.ui.wizards.RemoveExternalPackageSignaturePage.java

License:Apache License

/**
 * Validates if the source directory is valid one
 * /*from www  . j  av a  2 s.co  m*/
 * @return true if the source dir text is valid, false otherwise
 */
private boolean isSourceDirValid() {

    String messageAux = null;
    int severity = IMessageProvider.NONE;

    /*
     * Check if the selected location is valid, even if non existent.
     */
    IPath path = new Path(this.sourceDirText.getText());

    // Test if path is blank, to warn user instead of show an error message
    if (this.sourceDirText.getText().equals("")) //$NON-NLS-1$
    {
        messageAux =

                CertificateManagerNLS.SIGN_EXTERNAL_PKG_WIZARD_SOURCE_DIR_EMPTY;
        severity = IMessageProvider.INFORMATION;
    }

    /*
     * Do Win32 Validation
     */
    if ((messageAux == null) && Platform.getOS().equalsIgnoreCase(Platform.OS_WIN32)) {
        // test path size
        if (path.toString().length() > 255) {
            messageAux =

                    CertificateManagerNLS.SELECTOR_MESSAGE_LOCATION_ERROR_PATH_TOO_LONG;
            severity = IMessageProvider.WARNING;
        }
        String device = path.getDevice();
        File deviceFile = null;
        if (device != null) {
            deviceFile = new File(path.getDevice());
        }

        if ((device != null) && !deviceFile.exists()) {
            messageAux =

                    CertificateManagerNLS.SELECTOR_MESSAGE_LOCATION_ERROR_INVALID_DEVICE + " [" + device + "]";
            severity = IMessageProvider.ERROR;
        }

    }
    // test if path is absolute
    if (messageAux == null) {
        if (!path.isAbsolute() || !path.toFile().exists()) {
            messageAux =

                    CertificateManagerNLS.SIGN_EXTERNAL_PKG_WIZARD_SOURCE_DIR_INVALID;
            severity = IMessageProvider.ERROR;
        }
    }

    if (messageAux == null) {
        for (String folderName : path.segments()) {
            if (!ResourcesPlugin.getWorkspace().validateName(folderName, IResource.FOLDER).isOK()) {
                messageAux =

                        CertificateManagerNLS.SIGN_EXTERNAL_PKG_WIZARD_SOURCE_DIR_INVALID;
                severity = IMessageProvider.ERROR;

            }
        }
    }

    if ((messageAux == null) && ((path.toFile().exists() && !path.toFile().isDirectory()))) {
        messageAux =

                CertificateManagerNLS.SIGN_EXTERNAL_PKG_WIZARD_SOURCE_DIR_NOT_DIRECTORY;
        severity = IMessageProvider.ERROR;

    }

    /*
     * Setting message
     */
    if (messageAux == null) {
        messageAux = CertificateManagerNLS.SIGN_EXTERNAL_PKG_WIZARD_DESCRIPTION;
        severity = IMessageProvider.NONE;
    }
    setMessage(messageAux, severity);
    return severity == IMessageProvider.NONE;
}

From source file:com.nextep.designer.vcs.ui.services.impl.CommonUIService.java

License:Open Source License

@Override
public void updateFormMessages(IManagedForm form, ITypedObject model, Object source) {
    form.getMessageManager().removeAllMessages();
    // Checking external user lock
    IVersionable<?> versionable = VersionHelper.getVersionable(model);
    if (versionable != null) {
        final IVersionInfo version = versionable.getVersion();
        // If element is not committed and does not belong to us, we display the lock msg
        if (version.getStatus() != IVersionStatus.CHECKED_IN
                && version.getUser() != VCSPlugin.getService(IWorkspaceService.class).getCurrentUser()) {
            // Warning message to inform that everything is locked
            form.getMessageManager().addMessage(MSG_KEY_USER_LOCK,
                    MessageFormat.format(VCSUIMessages.getString("page.lockedByUserMsg"), //$NON-NLS-1$
                            version.getUser().getName()),
                    null, IMessageProvider.WARNING);
        }/* w w w. j  a v  a  2 s  . c o  m*/
    }

    // Fetching markers
    final IMessageManager msgManager = form.getMessageManager();
    fillMessages(model, msgManager);
    if (model instanceof IReferenceContainer) {
        for (IReferenceable r : ((IReferenceContainer) model).getReferenceMap().values()) {
            if (r instanceof ITypedObject) {
                fillMessages((ITypedObject) r, msgManager);
            }
        }
    }
}