Example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_7

List of usage examples for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_7

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_7.

Prototype

String VERSION_1_7

To view the source code for org.eclipse.jdt.internal.compiler.impl CompilerOptions VERSION_1_7.

Click Source Link

Usage

From source file:com.liferay.ide.hook.ui.wizard.NewEventActionClassDialog.java

License:Open Source License

protected void updateQualifiedClassname() {
    int packageNameStatus = JavaConventions.validatePackageName(packageText.getText(),
            CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7).getSeverity();

    int classNameStatus = JavaConventions
            .validateJavaTypeName(classText.getText(), CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7)
            .getSeverity();/*from   www  .  j  av a  2 s .  com*/
    ;

    if (!CoreUtil.isNullOrEmpty(packageText.getText())) {
        this.qualifiedClassname = packageText.getText() + "." + classText.getText(); //$NON-NLS-1$
    } else {
        this.qualifiedClassname = classText.getText();
        packageNameStatus = IStatus.WARNING;
    }

    if (classText.getText().indexOf('.') != -1) {
        classNameStatus = IStatus.ERROR;
    }

    boolean isPackageNameAndClassNameValid = ((packageNameStatus != IStatus.ERROR)
            && (classNameStatus != IStatus.ERROR));

    this.getButton(IDialogConstants.OK_ID).setEnabled(isPackageNameAndClassNameValid);

    if (classNameStatus == IStatus.ERROR && packageNameStatus == IStatus.ERROR) {
        this.errorMessageLabel.setText("Invalid package and class name");
    } else if (classNameStatus == IStatus.ERROR) {
        this.errorMessageLabel.setText("Invalid class name");
    } else if (packageNameStatus == IStatus.ERROR) {
        this.errorMessageLabel.setText("Invalid package name");
    }

    this.errorMessageLabel.setVisible(!isPackageNameAndClassNameValid);

}

From source file:com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider.java

License:Open Source License

@Override
public IStatus validate(String propertyName) {
    if (LAYOUT_TEMPLATE_ID.equals(propertyName)) {
        // first check to see if an existing property exists.
        LayoutTplDescriptorHelper helper = new LayoutTplDescriptorHelper(getTargetProject());

        if (helper.hasTemplateId(getStringProperty(propertyName))) {
            return LayoutTplCore.createErrorStatus(Msgs.templateIdExists);
        }/*  w  w w  .ja  v a 2 s  . c o m*/

        // to avoid marking text like "this" as bad add a z to the end of the string
        String idValue = getStringProperty(propertyName) + "z"; //$NON-NLS-1$

        if (CoreUtil.isNullOrEmpty(idValue)) {
            return super.validate(propertyName);
        }

        IStatus status = JavaConventions.validateFieldName(idValue, CompilerOptions.VERSION_1_7,
                CompilerOptions.VERSION_1_7);

        if (!status.isOK()) {
            return LayoutTplCore.createErrorStatus(Msgs.templateIdInvalid);
        }

        String idText = getStringProperty(propertyName);

        if (CoreUtil.isNullOrEmpty(idText)) {
            return LayoutTplCore.createErrorStatus("Id can't be empty.");
        }
    } else if (LAYOUT_TEMPLATE_FILE.equals(propertyName)) {
        String filename = getStringProperty(propertyName);

        if (!checkoutDocrootFileNameCorrect(filename, "tpl")) {
            return LayoutTplCore.createErrorStatus("Template file name is invalid.");
        }

        final IPath filePath = new Path(getStringProperty(LAYOUT_TEMPLATE_FILE));

        if (checkDocrootFileExists(filePath)) {
            return LayoutTplCore.createWarningStatus(Msgs.templateFileExists);
        }
    } else if (LAYOUT_WAP_TEMPLATE_FILE.equals(propertyName)) {
        String filename = getStringProperty(propertyName);

        if (!checkoutDocrootFileNameCorrect(filename, "tpl")) {
            return LayoutTplCore.createErrorStatus("WAP template file name is invalid.");
        }

        final IPath filePath = new Path(getStringProperty(LAYOUT_WAP_TEMPLATE_FILE));

        if (checkDocrootFileExists(filePath)) {
            return LayoutTplCore.createWarningStatus(Msgs.wapTemplateFileExists);
        }
    } else if (LAYOUT_THUMBNAIL_FILE.equals(propertyName)) {
        String filename = getStringProperty(propertyName);

        if (!checkoutDocrootFileNameCorrect(filename, "")) {
            return LayoutTplCore.createErrorStatus("Thumbnail file name is invalid.");
        }

        final IPath filePath = new Path(getStringProperty(LAYOUT_THUMBNAIL_FILE));

        if (checkDocrootFileExists(filePath)) {
            return LayoutTplCore.createWarningStatus(Msgs.thumbnailFileExists);
        }
    }

    return super.validate(propertyName);
}

From source file:com.liferay.ide.project.core.model.internal.GroupIdValidationService.java

License:Open Source License

@Override
protected Status compute() {
    if ("maven".equals(op().getProjectProvider().content(true).getShortName())) {
        final String groupId = op().getGroupId().content(true);

        final IStatus javaStatus = JavaConventions.validatePackageName(groupId, CompilerOptions.VERSION_1_7,
                CompilerOptions.VERSION_1_7);

        return StatusBridge.create(javaStatus);
    }// w w w.j  a  v  a  2s .  c  o m

    return StatusBridge.create(org.eclipse.core.runtime.Status.OK_STATUS);
}

From source file:com.liferay.ide.project.core.modules.ComponentNameValidationService.java

License:Open Source License

@Override
protected Status compute() {
    final String className = op().getComponentName().content(true);

    Status retval = Status.createOkStatus();

    if (!CoreUtil.isNullOrEmpty(className)) {
        int classNameStatus = JavaConventions
                .validateJavaTypeName(className, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7)
                .getSeverity();//from  www. j  a v a  2s  . c  om
        ;

        if (className.indexOf('.') != -1) {
            classNameStatus = IStatus.ERROR;
        }

        if (classNameStatus == IStatus.ERROR) {
            retval = Status.createErrorStatus("Invalid class name");
        }
    }

    return retval;
}

From source file:com.liferay.ide.project.core.modules.fragment.ModuleFragmentProjectGroupIdValidationService.java

License:Open Source License

@Override
protected Status compute() {
    if ("maven-module-fragment".equals(op().getProjectProvider().content(true).getShortName())) {
        final String groupId = op().getGroupId().content(true);

        final IStatus javaStatus = JavaConventions.validatePackageName(groupId, CompilerOptions.VERSION_1_7,
                CompilerOptions.VERSION_1_7);

        if (!javaStatus.isOK()) {
            return StatusBridge.create(javaStatus);
        }//from  w  w w  . java  2s .  c  o  m
    }

    return Status.createOkStatus();
}

From source file:com.liferay.ide.project.core.modules.JavaPackageNameValidationService.java

License:Open Source License

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();

    final JavaPackageName packageName = op().getPackageName().content(true);

    if (packageName != null) {
        int packageNameStatus = JavaConventions.validatePackageName(packageName.toString(),
                CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7).getSeverity();

        if (packageNameStatus == IStatus.ERROR) {
            retval = Status.createErrorStatus("Invalid package name");
        }// www.j a v a2 s .  c  o m
    }

    return retval;
}

From source file:com.liferay.ide.project.core.modules.ModuleProjectGroupIdValidationService.java

License:Open Source License

@Override
protected Status compute() {
    if ("maven-module".equals(op().getProjectProvider().content(true).getShortName())) {
        final String groupId = op().getGroupId().content(true);

        final IStatus javaStatus = JavaConventions.validatePackageName(groupId, CompilerOptions.VERSION_1_7,
                CompilerOptions.VERSION_1_7);

        if (!javaStatus.isOK()) {
            return StatusBridge.create(javaStatus);
        }/*from   w  ww .j  a v  a 2s  .c o  m*/
    }

    return Status.createOkStatus();
}

From source file:com.liferay.ide.project.core.modules.NewLiferayComponentValidationService.java

License:Open Source License

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();

    final String className = op().getComponentClassName().content(true);

    if (!CoreUtil.isNullOrEmpty(className)) {
        int classNameStatus = JavaConventions
                .validateJavaTypeName(className, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7)
                .getSeverity();//www.  j  av  a 2  s.c  o m
        ;

        if (className.indexOf('.') != -1) {
            classNameStatus = IStatus.ERROR;
        }

        if (classNameStatus == IStatus.ERROR) {
            retval = Status.createErrorStatus("Invalid class name");
        }
    }

    String projectName = op().getProjectName().content(true);

    if (projectName != null) {
        IProject project = CoreUtil.getProject(projectName);

        if (project != null) {
            try {
                JavaPackageName pack = op().getPackageName().content(true);

                if (pack != null) {
                    String packageName = op().getPackageName().content(true).toString();
                    IType type = JavaCore.create(project).findType(packageName + "." + className);

                    if (type != null) {
                        retval = Status.createErrorStatus(packageName + "." + className + " already existed.");
                    }
                }
            } catch (Exception e) {
                ProjectCore.logError("Checking component class name failed.", e);
            }

        }
    }

    return retval;
}

From source file:com.liferay.ide.project.core.modules.PackageNameValidationService.java

License:Open Source License

@Override
protected Status compute() {
    final String packageName = op().getPackageName().content(true);
    Status retval = Status.createOkStatus();

    int packageNameStatus = IStatus.OK;

    if (!CoreUtil.isNullOrEmpty(packageName)) {
        packageNameStatus = JavaConventions
                .validatePackageName(packageName, CompilerOptions.VERSION_1_7, CompilerOptions.VERSION_1_7)
                .getSeverity();/*w  w  w. ja  v a  2s.c om*/

        if (packageNameStatus == IStatus.ERROR) {
            retval = Status.createErrorStatus("Invalid package name");
        }
    }

    return retval;
}

From source file:com.liferay.ide.service.core.model.internal.PackagePathValidationService.java

License:Open Source License

@Override
public Status compute() {
    final Value<String> packagePath = context().find(ServiceBuilder.class).getPackagePath();
    String packPathVal = packagePath.content();

    if (packPathVal == null) {
        return Status.createErrorStatus(Msgs.packagePathNotEmpty);
    }//from   w ww .ja  v  a 2  s .  co m

    // Use standard java conventions to validate the package name
    IStatus javaStatus = JavaConventions.validatePackageName(packPathVal, CompilerOptions.VERSION_1_7,
            CompilerOptions.VERSION_1_7);

    if (javaStatus.getSeverity() == IStatus.ERROR) {
        return Status
                .createErrorStatus(J2EECommonMessages.ERR_JAVA_PACAKGE_NAME_INVALID + javaStatus.getMessage());
    }

    if (javaStatus.getSeverity() == IStatus.WARNING) {
        return Status.createWarningStatus(
                J2EECommonMessages.ERR_JAVA_PACKAGE_NAME_WARNING + javaStatus.getMessage());
    }

    return Status.createOkStatus();
}