Example usage for org.eclipse.jdt.core IJavaProject getOption

List of usage examples for org.eclipse.jdt.core IJavaProject getOption

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaProject getOption.

Prototype

String getOption(String optionName, boolean inheritJavaCoreOptions);

Source Link

Document

Helper method for returning one option value only.

Usage

From source file:org.eclipse.wb.internal.core.model.property.converter.AbstractNumberConverter.java

License:Open Source License

/**
 * @return <code>true</code> if context {@link IJavaProject} supports auto-boxing.
 *//*from   w  w  w . j av a 2 s . com*/
protected final boolean isBoxingEnabled(JavaInfo javaInfo) {
    if (javaInfo == null) {
        return false;
    }
    IJavaProject javaProject = javaInfo.getEditor().getJavaProject();
    // we need Java 5+
    if (!ProjectUtils.isJDK15(javaProject)) {
        return false;
    }
    // ...auto-boxing enabled?
    String option = javaProject.getOption(JavaCore.COMPILER_PB_AUTOBOXING, true);
    if (!"ignore".equals(option)) {
        return false;
    }
    // OK
    return true;
}

From source file:org.eclipse.wb.internal.core.utils.jdt.core.ProjectUtils.java

License:Open Source License

/**
 * @return the {@link String} name of Java version.
 *///from   w  w w. j  a v a2 s  .c o m
public static String getJavaVersionString(IJavaProject javaProject) {
    return javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true);
}

From source file:org.eclipse.xtend.ide.javaconverter.EclipseASTParserFactory.java

License:Open Source License

@Override
public ASTParserFactory.ASTParserWrapper createJavaParser(final Object context) {
    if ((context instanceof IJavaElement)) {
        final IJavaProject project = ((IJavaElement) context).getJavaProject();
        final String projlevel = project.getOption(JavaCore.COMPILER_SOURCE, true);
        final ASTParser parser = this.createDefaultJavaParser(projlevel);
        if ((context instanceof IJavaProject)) {
            parser.setProject(project);//ww w.j a v a  2s .c om
            this.tweakOptions(parser, project);
        } else {
            if ((context instanceof ICompilationUnit)) {
                parser.setSource(((ICompilationUnit) context));
                this.tweakOptions(parser, ((ICompilationUnit) context).getJavaProject());
            }
        }
        return new ASTParserFactory.ASTParserWrapper(projlevel, parser);
    }
    return super.createJavaParser(context);
}

From source file:org.eclipse.xtext.xbase.ui.builder.XbaseBuilderConfigurationBlock.java

License:Open Source License

protected String javaValue(final String javaPreference) {
    IJavaProject javaProject = JavaCore.create(getProject());
    if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) {
        return javaProject.getOption(javaPreference, true);
    } else {/*from w w  w . j a  va  2s  . co m*/
        return JavaCore.getOption(javaPreference);
    }
}

From source file:org.eclipse.xtext.xbase.ui.builder.XbaseBuilderPreferenceAccess.java

License:Open Source License

public JavaVersion getJavaVersion(Object context, IPreferenceStore preferenceStore) {
    boolean useCompilerSource = preferenceStore.getBoolean(PREF_USE_COMPILER_SOURCE);
    if (useCompilerSource) {
        IJavaProject javaProject = JavaCore.create(context instanceof IProject ? (IProject) context : null);
        String compilerSource;/*from   www.  j a v  a 2  s .c om*/
        if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) {
            compilerSource = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
        } else {
            compilerSource = JavaCore.getOption(JavaCore.COMPILER_SOURCE);
        }
        return fromCompilerSourceLevel(compilerSource);
    } else {
        String stringValue = preferenceStore.getString(PREF_JAVA_VERSION);
        try {
            return JavaVersion.valueOf(stringValue);
        } catch (IllegalArgumentException exception) {
            // Fall back to default value
        }
    }
    return JavaVersion.JAVA5;
}

From source file:org.eclipse.xtext.xbase.ui.validation.XbaseIssueSeveritiesProvider.java

License:Open Source License

@Override
public IssueSeverities getIssueSeverities(final Resource context) {
    IPreferenceValues preferenceValues = getValuesProvider().getPreferenceValues(context);
    return new IssueSeverities(preferenceValues, configurableIssueCodes.getConfigurableIssueCodes(),
            new XbaseSeverityConverter() {

                final IJavaProject project = projectProvider.getJavaProject(context.getResourceSet());

                @Override//  w  ww  .  j a v  a  2s .c o m
                protected String delegatedValue(Pair<String, String> pair) {
                    String jdtSeverity = jdtSeverity(project, pair.getFirst());
                    if (jdtSeverity == null || "".equals(jdtSeverity)) {
                        return super.delegatedValue(pair);
                    }
                    return jdtSeverity;
                }

                private String jdtSeverity(final IJavaProject project, String severityAsString) {
                    if (project == null) {
                        return null;
                    }
                    return project.getOption(severityAsString, true);
                }
            });
}

From source file:org.eclipse.xtext.xbase.ui.validation.XbaseValidationConfigurationBlock.java

License:Open Source License

protected String javaValue(final String javaIssueCode) {
    String delegatedValue;// w  ww .j a v a  2 s  .  c  om
    String decodedDelegateKey = XbaseSeverityConverter.decodeDelegationKey(javaIssueCode).getFirst();
    IJavaProject javaProject = JavaCore.create(getProject());
    if (javaProject != null && javaProject.exists() && javaProject.getProject().isAccessible()) {
        delegatedValue = javaProject.getOption(decodedDelegateKey, true);
    } else {
        delegatedValue = JavaCore.getOption(decodedDelegateKey);
    }
    return delegatedValue;
}

From source file:org.entirej.ide.cf.rwt.RWTClientFrameworkProvider.java

License:Apache License

private byte[] getFactesSource(IJavaProject project) {
    String option = project.getOption("org.eclipse.jdt.core.compiler.source", true);
    if (option == null) {
        option = "1.6";// default
    }/*  ww  w  .  java2 s.c  o  m*/
    StringBuilder builder = new StringBuilder();
    builder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    builder.append("<faceted-project>");
    builder.append("<fixed facet=\"wst.jsdt.web\"/>");
    builder.append(String.format("<installed facet=\"java\" version=\"%s\"/>", option));
    builder.append("<installed facet=\"jst.web\" version=\"3.0\"/>");
    builder.append("<installed facet=\"wst.jsdt.web\" version=\"1.0\"/>");
    builder.append("</faceted-project>");
    return builder.toString().getBytes();
}

From source file:org.gololang.gldt.jdt.internal.GoloProject.java

License:Apache License

/**
 * Exclude all Golo files from compilation
 * /*from w  ww  . j  a  v a 2s  .c  o  m*/
 * @param javaProject
 */
public static void excludeGoloFilesFromOutput(final IProject project) {
    // make sure .golo files are not copied to the output dir
    IJavaProject javaProject = JavaCore.create(project);
    if (javaProject != null) {
        String excludedResources = javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
        if (excludedResources.indexOf(GoloJdtConstants.GOLO_FILE_FILTER) == -1) {
            excludedResources = excludedResources.length() == 0 ? GoloJdtConstants.GOLO_FILE_FILTER
                    : excludedResources + ',' + GoloJdtConstants.GOLO_FILE_FILTER;
            javaProject.setOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, excludedResources);
        }
    }
}

From source file:org.gololang.gldt.jdt.internal.GoloProject.java

License:Apache License

/**
 * Include all Golo files for compilation
 * /*w  w  w . jav  a 2 s . c  o m*/
 * @param project
 */
public static void includeGoloFilesInOutput(final IProject project) {
    // make sure .golo files are not copied to the output dir
    IJavaProject javaProject = JavaCore.create(project);
    if (javaProject != null) {
        final String[] excludedResourcesArray = javaProject
                .getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true).split(",");
        final List<String> excludedResources = new ArrayList<String>();
        for (int i = 0; i < excludedResourcesArray.length; i++) {
            final String excluded = excludedResourcesArray[i].trim();
            if (excluded.endsWith(GoloJdtConstants.GOLO_FILE_FILTER))
                continue;
            excludedResources.add(excluded);
        }
        javaProject.setOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER,
                Joiner.on(',').join(excludedResources));
    }
}