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.motorola.studio.android.common.utilities.ui.PasswordInputDialog.java

License:Apache License

public void updateStatus() {
    String errorMessage = null;/*from w w  w  .  j  a  va  2  s  . c om*/
    int severity = IMessageProvider.NONE;

    if (oldPasswordText.getText().length() > 0) {
        oldPassword = oldPasswordText.getText();
    } else {
        errorMessage = "";
        oldPassword = null;
    }

    if ((errorMessage == null) && changePassword) {
        if (newPasswordText.getText().length() < passwordMinimumSize) {
            errorMessage = UtilitiesNLS.bind(UtilitiesNLS.Passwordinput_Error_PasswordMinimumSize,
                    passwordMinimumSize);
            severity = IMessageProvider.ERROR;
        } else {
            if (!newPasswordText.getText().equals(newPasswordConfirmText.getText())) {
                errorMessage = UtilitiesNLS.Passwordinput_Error_Passwordnotmatch;
                severity = IMessageProvider.ERROR;
            } else {
                newPassword = newPasswordText.getText();
            }
        }
    }

    setErrorMessage(errorMessage, severity);

}

From source file:com.motorola.studio.android.common.utilities.ui.PasswordInputDialog.java

License:Apache License

private void setErrorMessage(String errorMsg, int severity) {
    if ((errorMsg == null) || (severity == IMessageProvider.NONE)) {
        image.setImage(null);/*from  w  ww .jav  a2  s  . c o  m*/
        image.setVisible(false);
        message.setText(description);
        getButton(OK).setEnabled(errorMsg == null);
    } else {
        message.setText(errorMsg);
        message.setVisible(true);
        switch (severity) {
        case IMessageProvider.ERROR:
            image.setImage(
                    PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
            break;

        case IMessageProvider.INFORMATION:
            image.setImage(
                    PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK));
            break;

        case IMessageProvider.WARNING:
            image.setImage(
                    PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK));
            break;

        default:
            image.setImage(
                    PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
            break;
        }
        image.setVisible(true);
        getButton(OK).setEnabled(false);
    }
    message.getParent().layout();
}

From source file:com.motorola.studio.android.generatemenucode.ui.GenerateMenuCodeDialog.java

License:Apache License

/**
 * Validate the UI/*from   ww  w  .jav  a  2s.  c  om*/
 * @return
 */
protected void validate() {

    String errorMessage = null;

    if ((projectNameComboBox != null) && (projectNameComboBox.getItemCount() == 0)) {
        errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableProjects;
    }
    if ((errorMessage == null) && (classNameComboBox != null) && (classNameComboBox.getItemCount() == 0)) {
        errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableClasses;
    }
    if ((errorMessage == null) && (menuFileNameComboBox != null)) {
        if ((menuFileErrorMessage != null) && (menuFileNameComboBox.getSelectionIndex() >= 0)
                && (menuFileNameComboBox.getData(menuFileNameComboBox
                        .getItem(menuFileNameComboBox.getSelectionIndex())) instanceof String)) {
            errorMessage = (String) menuFileNameComboBox
                    .getData(menuFileNameComboBox.getItem(menuFileNameComboBox.getSelectionIndex()));
        } else {
            if ((menuFileNameComboBox.getItemCount() == 0) && (getJavaFile() != null)) {
                errorMessage = CodeUtilsNLS.GenerateMenuCodeDialog_NoSuitableMenus;
            } else if (getJavaFile() == null) {
                errorMessage = menuFileErrorMessage;
            }
        }
    }

    this.setMessage(errorMessage, IMessageProvider.ERROR);

    if (errorMessage == null) {
        if ((this.getMessage() == null) || (this.getMessage().length() == 0)) {
            this.setMessage(defaultMessage, IMessageProvider.NONE);
        }
    }

    if (getButton(OK) != null) {
        getButton(OK).setEnabled((getErrorMessage() == null)
                || ((getErrorMessage() != null) && (getErrorMessage().trim().isEmpty())));
    }
}

From source file:com.motorola.studio.android.generateviewbylayout.ui.ChooseLayoutItemsDialog.java

License:Apache License

/**
 * Handles the enablement of the Ok button.
 * It will only be enabled when at least one table item is checked.
 *//*from  w  w w . j  a v  a 2s .  c  o  m*/
@Override
protected void validate() {
    super.validate();
    if ((getViewer() != null) && (getErrorMessage() == null)) {

        // set the appropriate message
        String message = ""; //$NON-NLS-1$
        int messageType = IMessageProvider.NONE;

        //check if at least one table item was selected
        for (TableItem item : getViewer().getTable().getItems()) {
            LayoutNode node = (LayoutNode) item.getData();
            if (item.getChecked() && (getCodeGeneratorData() != null) && getCodeGeneratorData()
                    .getJavaLayoutData().getVisitor().checkIfAttributeAlreadyDeclared(node, true)) {
                message = NLS.bind(CodeUtilsNLS.ChooseLayoutItemsDialog_VariableNameInUse_Error,
                        node.getNodeId());
                messageType = IMessageProvider.ERROR;
                break;
            }
        }

        if (messageType == IMessageProvider.NONE) {

            if (getViewer().getTable().getItemCount() == 0) {
                message = CodeUtilsNLS.UI_ChooseLayoutItemsDialog_No_Gui_Items_Available;
                messageType = IMessageProvider.INFORMATION;
            } else if (hasGuiItemsWithoutId) {
                message = CodeUtilsNLS.ChooseLayoutItemsDialog_Gui_Items_Available_No_Id;
                messageType = IMessageProvider.INFORMATION;
            } else {
                message = CodeUtilsNLS.ChooseLayoutItemsDialog_DefaultMessage;
            }
        }
        this.setMessage(message, messageType);

    }
}

From source file:com.motorola.studio.android.packaging.ui.export.PackageExportWizardArea.java

License:Apache License

/**
 * This method is responsible to add all the existent descriptor files of
 * the current workspace in the tree shown in the wizard.
 *///from w  w  w  .  j av  a  2s  . c  o m
private void populateTree() {
    tree.removeAll();
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    try {
        for (IProject project : projects) {
            if (project.isOpen() && (project.getNature(AndroidPlugin.Android_Nature) != null)
                    && !SdkUtils.isLibraryProject(project)) {
                TreeItem item = new TreeItem(tree, SWT.NONE);
                item.setData(project);
                item.setText(project.getName());
                item.setImage(projectSeverity.get(project) == IMessageProvider.ERROR ? icon_nok : icon_ok);
                if (selection.toList().contains(project)) {
                    item.setChecked(true);
                }
            }
        }
    } catch (CoreException e) {
        StudioLogger.error(PackageExportWizardArea.class, "Error populating tree: " + e.getMessage()); //$NON-NLS-1$
    }

}

From source file:com.motorola.studio.android.packaging.ui.export.PackageExportWizardArea.java

License:Apache License

/**
 * Get all projects severities to avoid user selects erroneous projects
 *///ww  w  . ja v  a2  s.  c o m
private void validateProjects() {
    try {
        for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            if (project.isOpen()) {
                int sev = project.findMaxProblemSeverity(null, true, IResource.DEPTH_INFINITE);
                int projectSev;
                switch (sev) {
                case IMarker.SEVERITY_ERROR:
                    projectSev = IMessageProvider.ERROR;
                    break;
                case IMarker.SEVERITY_INFO:
                    projectSev = IMessageProvider.INFORMATION;
                    break;
                case IMarker.SEVERITY_WARNING:
                    projectSev = IMessageProvider.WARNING;
                    break;
                default:
                    projectSev = IMessageProvider.NONE;
                    break;
                }
                projectSeverity.put(project, new Integer(projectSev));
            }
        }
    } catch (CoreException e) {
        StudioLogger.error(PackageExportWizardArea.class, "Impossible to get project severity"); //$NON-NLS-1$
    }
}

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./*from   w  w w .  ja v a2s .  co  m*/
 * 
 * @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.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 a v a 2  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
 * /*from w  w  w . j  av  a 2s.com*/
 * @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.preflighting.ui.wizards.ApkValidationWizardPage.java

License:Apache License

/**
 * Update the page status, validating each field of this page Subclasses
 *//*from   w  ww  .  j a v a  2s  .  c o m*/
public void updatePageComplete() {
    String messageAux = null;
    int severity = IMessageProvider.NONE;

    if (isSourceDirValid()) {
        if (this.packagesTree.getItemCount() == 0) {
            messageAux = PreflightingUiNLS.ApkValidationWizardPage_emptyFolderMsg;
            severity = IMessageProvider.ERROR;
        }
    } else {
        messageAux = getMessage();
        severity = getMessageType();
    }

    if ((messageAux == null) && (getSelectedPackages().size() == 0)) {
        messageAux = PreflightingUiNLS.ApkValidationWizardPage_onePackageMsg;
        severity = IMessageProvider.INFORMATION;
    }

    if (messageAux == null) {
        messageAux = PreflightingUiNLS.ApkValidationWizardPage_validateMsg;
        severity = IMessageProvider.NONE;
    }

    setMessage(messageAux, severity);
    setPageComplete(severity == IMessageProvider.NONE);
}