Examples of StatusInfo


Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

        gd.grabExcessVerticalSpace = false;
        gd.widthHint = convertWidthInCharsToPixels(40);
    }

    protected IStatus updateArgumentTypes() {
        StatusInfo status = new StatusInfo();
        if (getTargetClassName().length() == 0 && fArgumentTypesDialogField.getElements().size() > 0) {
            status.setError("Target class must not be empty.");
        }
        return status;
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

        }
        source.append(" target");
    }

    protected IStatus updateTargetException() {
        StatusInfo status = new StatusInfo();
        IPackageFragmentRoot root = getMainPage().getPackageFragmentRoot();
        fTargetExceptionDialogField.enableButton(root != null);

        fTargetException = null;

        String targetClassName = getTargetExceptionName();
        if (targetClassName.length() == 0) {
            // accept the empty field (stands for java.lang.Object)
            return status;
        }
        IStatus val = JavaConventions.validateJavaTypeName(targetClassName);
        if (val.getSeverity() == IStatus.ERROR) {
            status.setError("Target exception name is not valid.");
            return status;
        }
        if (root != null) {
            try {
                IType type = resolveClassName(root.getJavaProject(), targetClassName);
                if (type == null) {
                    status.setWarning("Target exception does not exist in current project.");
                    return status;
                }
                // TODO Check if exception is subclass of Throwable
                fTargetException = type;
            } catch (JavaModelException e) {
                status.setError("Target exception name is not valid.");
                JavaPlugin.log(e);
            }
        } else {
            status.setError(""); //$NON-NLS-1$
        }
        return status;

    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

        fUseAddCommentButtonValue = false; // only used when enabled

        fCurrPackageCompletionProcessor = new JavaPackageCompletionProcessor();
        fEnclosingTypeCompletionProcessor = new JavaTypeCompletionProcessor(false, false, true);

        fPackageStatus = new StatusInfo();
        fEnclosingTypeStatus = new StatusInfo();

        fCanModifyPackage = true;
        fCanModifyEnclosingType = true;
        updateEnableState();

        fTypeNameStatus = new StatusInfo();
        fSuperClassStatus = new StatusInfo();
        fSuperInterfacesStatus = new StatusInfo();
        fModifierStatus = new StatusInfo();
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

        IJavaProject project = root.getJavaProject();

        if ((fTypeKind == ANNOTATION_TYPE || fTypeKind == ENUM_TYPE) && !status.matches(IStatus.ERROR)) {
            if (!JavaModelUtil.is50OrHigher(project)) {
                // error as createType will fail otherwise (bug 96928)
                return new StatusInfo(IStatus.ERROR, Messages.format(NewWizardMessages.NewTypeWizardPage_warning_NotJDKCompliant, BasicElementLabels.getJavaElementName(project.getElementName())));
            }
            if (fTypeKind == ENUM_TYPE) {
                try {
                    // if findType(...) == null then Enum is unavailable
                    if (findType(project, "java.lang.Enum") == null) //$NON-NLS-1$
                        return new StatusInfo(IStatus.WARNING, NewWizardMessages.NewTypeWizardPage_warning_EnumClassNotFound);
                } catch (JavaModelException e) {
                    JavaPlugin.log(e);
                }
            }
        }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus packageChanged() {
        StatusInfo status = new StatusInfo();
        IPackageFragmentRoot root = getPackageFragmentRoot();
        fPackageDialogField.enableButton(root != null);

        IJavaProject project = root != null ? root.getJavaProject() : null;

        String packName = getPackageText();
        if (packName.length() > 0) {
            IStatus val = validatePackageName(packName, project);
            if (val.getSeverity() == IStatus.ERROR) {
                status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidPackageName, val.getMessage()));
                return status;
            } else if (val.getSeverity() == IStatus.WARNING) {
                status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_DiscouragedPackageName, val.getMessage()));
                // continue
            }
        } else {
            status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_DefaultPackageDiscouraged);
        }

        if (project != null) {
            assert (root != null);
            if (project.exists() && packName.length() > 0) {
                try {
                    IPath rootPath = root.getPath();
                    IPath outputPath = project.getOutputLocation();
                    if (rootPath.isPrefixOf(outputPath) && !rootPath.equals(outputPath)) {
                        // if the bin folder is inside of our root, don't allow to name a package
                        // like the bin folder
                        IPath packagePath = rootPath.append(packName.replace('.', '/'));
                        if (outputPath.isPrefixOf(packagePath)) {
                            status.setError(NewWizardMessages.NewTypeWizardPage_error_ClashOutputLocation);
                            return status;
                        }
                    }
                } catch (JavaModelException e) {
                    JavaPlugin.log(e);
                    // let pass
                }
            }

            fCurrPackage = root.getPackageFragment(packName);
            IResource resource = fCurrPackage.getResource();
            if (resource != null) {
                if (resource.isVirtual()) {
                    status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageIsVirtual);
                    return status;
                }
                if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
                    status.setError(NewWizardMessages.NewTypeWizardPage_error_PackageNameFiltered);
                    return status;
                }
            }
        } else {
            status.setError(""); //$NON-NLS-1$
        }
        return status;
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus enclosingTypeChanged() {
        StatusInfo status = new StatusInfo();
        fCurrEnclosingType = null;

        IPackageFragmentRoot root = getPackageFragmentRoot();

        fEnclosingTypeDialogField.enableButton(root != null);
        if (root == null) {
            status.setError(""); //$NON-NLS-1$
            return status;
        }

        String enclName = getEnclosingTypeText();
        if (enclName.length() == 0) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeEnterName);
            return status;
        }
        try {
            IType type = findType(root.getJavaProject(), enclName);
            if (type == null) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeNotExists);
                return status;
            }

            if (type.getCompilationUnit() == null) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingNotInCU);
                return status;
            }
            if (!JavaModelUtil.isEditable(type.getCompilationUnit())) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingNotEditable);
                return status;
            }

            fCurrEnclosingType = type;
            IPackageFragmentRoot enclosingRoot = JavaModelUtil.getPackageFragmentRoot(type);
            if (!enclosingRoot.equals(root)) {
                status.setWarning(NewWizardMessages.NewTypeWizardPage_warning_EnclosingNotInSourceFolder);
            }
            return status;
        } catch (JavaModelException e) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_EnclosingTypeNotExists);
            JavaPlugin.log(e);
            return status;
        }
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus typeNameChanged() {
        StatusInfo status = new StatusInfo();
        fCurrType = null;
        String typeNameWithParameters = getTypeName();
        // must not be empty
        if (typeNameWithParameters.length() == 0) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_EnterTypeName);
            return status;
        }

        String typeName = getTypeNameWithoutParameters();
        if (typeName.indexOf('.') != -1) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_QualifiedName);
            return status;
        }

        IJavaProject project = getJavaProject();
        IStatus val = validateJavaTypeName(typeName, project);
        if (val.getSeverity() == IStatus.ERROR) {
            status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, val.getMessage()));
            return status;
        } else if (val.getSeverity() == IStatus.WARNING) {
            status.setWarning(Messages.format(NewWizardMessages.NewTypeWizardPage_warning_TypeNameDiscouraged, val.getMessage()));
            // continue checking
        }

        // must not exist
        if (!isEnclosingTypeSelected()) {
            IPackageFragment pack = getPackageFragment();
            if (pack != null) {
                ICompilationUnit cu = pack.getCompilationUnit(getCompilationUnitName(typeName));
                fCurrType = cu.getType(typeName);
                IResource resource = cu.getResource();

                if (resource.exists()) {
                    status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExists);
                    return status;
                }
                if (!ResourcesPlugin.getWorkspace().validateFiltered(resource).isOK()) {
                    status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameFiltered);
                    return status;
                }
                URI location = resource.getLocationURI();
                if (location != null) {
                    try {
                        IFileStore store = EFS.getStore(location);
                        if (store.fetchInfo().exists()) {
                            status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExistsDifferentCase);
                            return status;
                        }
                    } catch (CoreException e) {
                        status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_uri_location_unkown, BasicElementLabels.getURLPart(Resources.getLocationString(resource))));
                    }
                }
            }
        } else {
            IType type = getEnclosingType();
            if (type != null) {
                fCurrType = type.getType(typeName);
                if (fCurrType.exists()) {
                    status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeNameExists);
                    return status;
                }
            }
        }

        if (!typeNameWithParameters.equals(typeName) && project != null) {
            if (!JavaModelUtil.is50OrHigher(project)) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_TypeParameters);
                return status;
            }
            String typeDeclaration = "class " + typeNameWithParameters + " {}"; //$NON-NLS-1$//$NON-NLS-2$
            ASTParser parser = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
            parser.setSource(typeDeclaration.toCharArray());
            parser.setProject(project);
            CompilationUnit compilationUnit = (CompilationUnit) parser.createAST(null);
            IProblem[] problems = compilationUnit.getProblems();
            if (problems.length > 0) {
                status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidTypeName, problems[0].getMessage()));
                return status;
            }
        }
        return status;
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus superClassChanged() {
        StatusInfo status = new StatusInfo();
        IPackageFragmentRoot root = getPackageFragmentRoot();
        fSuperClassDialogField.enableButton(root != null);

        fSuperClassStubTypeContext = null;

        String sclassName = getSuperClass();
        if (sclassName.length() == 0) {
            // accept the empty field (stands for java.lang.Object)
            return status;
        }

        if (root != null) {
            Type type = TypeContextChecker.parseSuperClass(sclassName);
            if (type == null) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperClassName);
                return status;
            }
            if (type instanceof ParameterizedType && !JavaModelUtil.is50OrHigher(root.getJavaProject())) {
                status.setError(NewWizardMessages.NewTypeWizardPage_error_SuperClassNotParameterized);
                return status;
            }
        } else {
            status.setError(""); //$NON-NLS-1$
        }
        return status;
    }
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus superInterfacesChanged() {
        StatusInfo status = new StatusInfo();

        IPackageFragmentRoot root = getPackageFragmentRoot();
        fSuperInterfacesDialogField.enableButton(0, root != null);

        if (root != null) {
            List<InterfaceWrapper> elements = fSuperInterfacesDialogField.getElements();
            int nElements = elements.size();
            for (int i = 0; i < nElements; i++) {
                String intfname = elements.get(i).interfaceName;
                Type type = TypeContextChecker.parseSuperInterface(intfname);
                if (type == null) {
                    status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_InvalidSuperInterfaceName, BasicElementLabels.getJavaElementName(intfname)));
                    return status;
                }
                if (type instanceof ParameterizedType && !JavaModelUtil.is50OrHigher(root.getJavaProject())) {
                    status.setError(Messages.format(NewWizardMessages.NewTypeWizardPage_error_SuperInterfaceNotParameterized, BasicElementLabels.getJavaElementName(intfname)));
                    return status;
                }
            }
        }
        return status;
View Full Code Here

Examples of org.eclipse.jdt.internal.ui.dialogs.StatusInfo

     * </p>
     *
     * @return the status of the validation
     */
    protected IStatus modifiersChanged() {
        StatusInfo status = new StatusInfo();
        int modifiers = getModifiers();
        if (Flags.isFinal(modifiers) && Flags.isAbstract(modifiers)) {
            status.setError(NewWizardMessages.NewTypeWizardPage_error_ModifiersFinalAndAbstract);
        }
        return status;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.