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.objectteams.otdt.tests.AbstractJavaModelTests.java

License:Open Source License

protected void setUpProjectCompliance(IJavaProject javaProject, String compliance)
        throws JavaModelException, IOException {
    // Look for version to set and return if that's already done
    String version = compliance; // assume that the values of CompilerOptions.VERSION_* are used
    if (version.equals(javaProject.getOption(CompilerOptions.OPTION_Compliance, false))) {
        return;/* w w  w. ja va 2 s.  c om*/
    }
    String jclLibString;
    String newJclLibString;
    String newJclSrcString;
    if (compliance.charAt(2) > '4') {
        jclLibString = "JCL_LIB";
        newJclLibString = "JCL15_LIB";
        newJclSrcString = "JCL15_SRC";
    } else {
        jclLibString = "JCL15_LIB";
        newJclLibString = "JCL_LIB";
        newJclSrcString = "JCL_SRC";
    }

    // ensure variables are set
    setUpJCLClasspathVariables(compliance);

    // set options
    Map options = new HashMap();
    options.put(CompilerOptions.OPTION_Compliance, version);
    options.put(CompilerOptions.OPTION_Source, version);
    options.put(CompilerOptions.OPTION_TargetPlatform, version);
    javaProject.setOptions(options);

    // replace JCL_LIB with JCL15_LIB, and JCL_SRC with JCL15_SRC
    IClasspathEntry[] classpath = javaProject.getRawClasspath();
    IPath jclLib = new Path(jclLibString);
    for (int i = 0, length = classpath.length; i < length; i++) {
        IClasspathEntry entry = classpath[i];
        if (entry.getPath().equals(jclLib)) {
            classpath[i] = JavaCore.newVariableEntry(new Path(newJclLibString), new Path(newJclSrcString),
                    entry.getSourceAttachmentRootPath(), entry.getAccessRules(), new IClasspathAttribute[0],
                    entry.isExported());
            break;
        }
    }
    javaProject.setRawClasspath(classpath, null);
}

From source file:org.eclipse.pde.api.tools.builder.tests.usage.UsageTest.java

License:Open Source License

/**
 * Makes sure the compliance for the project is what the test says it should
 * be//from  ww  w  .j  a va  2s.co  m
 * 
 * @param projectnames
 */
protected void ensureCompliance(String[] projectnames) {
    IJavaProject project = null;
    String compliance = null;
    for (int i = 0; i < projectnames.length; i++) {
        project = getEnv().getJavaProject(projectnames[i]);
        compliance = getTestCompliance();
        if (!compliance.equals(project.getOption(JavaCore.COMPILER_COMPLIANCE, true))) {
            getEnv().setProjectCompliance(project, compliance);
        }
    }
}

From source file:org.eclipse.pde.api.tools.internal.util.Util.java

License:Open Source License

/**
 * Returns all of the API projects in the workspace
 * /* www  . j av  a  2  s  .  c  o m*/
 * @param sourcelevel
 * @return all of the API projects in the workspace or <code>null</code> if
 *         there are none.
 */
public static IProject[] getApiProjectsMinSourceLevel(String sourcelevel) {
    IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    ArrayList<IProject> temp = new ArrayList<IProject>();
    IProject project = null;
    for (int i = 0, max = allProjects.length; i < max; i++) {
        project = allProjects[i];
        if (project.isAccessible()) {
            try {
                if (project.hasNature(org.eclipse.pde.api.tools.internal.provisional.ApiPlugin.NATURE_ID)) {
                    IJavaProject jp = JavaCore.create(project);
                    String src = jp.getOption(JavaCore.COMPILER_SOURCE, true);
                    if (src != null && src.compareTo(sourcelevel) >= 0) {
                        temp.add(project);
                    }
                }
            } catch (CoreException e) {
            }
        }
    }
    IProject[] projects = null;
    if (temp.size() != 0) {
        projects = new IProject[temp.size()];
        temp.toArray(projects);
    }
    return projects;
}

From source file:org.eclipse.pde.internal.core.builders.BuildErrorReporter.java

License:Open Source License

/**
 * Matches the javacSource, javacTarget, javacWarnings, javacErrors and jre.compilation.prile entries in build.properties with the 
 * project specific Java Compiler properties and reports the errors found.
 * /*  w ww  . j  a v  a2  s .  c o m*/
 * @param javacSourceEntry
 * @param javacTargetEntry
 * @param jreCompilationProfileEntry
 * @param javacWarningsEntries
 * @param javacErrorsEntries 
 * @param libraryNames list of library names (javacWarnings/javacErrors require an entry for each source library)
 */
private void validateExecutionEnvironment(IBuildEntry javacSourceEntry, IBuildEntry javacTargetEntry,
        IBuildEntry jreCompilationProfileEntry, ArrayList<IBuildEntry> javacWarningsEntries,
        ArrayList<IBuildEntry> javacErrorsEntries, List<String> libraryNames) {
    // if there is no source to compile, don't worry about compiler settings
    IJavaProject project = JavaCore.create(fProject);
    if (project.exists()) {
        IClasspathEntry[] classpath = null;
        try {
            classpath = project.getRawClasspath();
        } catch (JavaModelException e) {
            PDECore.log(e);
            return;
        }
        boolean source = false;
        for (int i = 0; i < classpath.length; i++) {
            IClasspathEntry cpe = classpath[i];
            if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
                source = true;
            }
        }
        if (!source) {
            return;
        }

        String projectComplianceLevel = project.getOption(JavaCore.COMPILER_COMPLIANCE, false);

        if (projectComplianceLevel != null) {

            IPluginModelBase model = PluginRegistry.findModel(fProject);
            String[] execEnvs = null;
            if (model != null) {
                BundleDescription bundleDesc = model.getBundleDescription();
                if (bundleDesc != null) {
                    execEnvs = bundleDesc.getExecutionEnvironments();
                }
            }

            if (execEnvs == null || execEnvs.length == 0) {
                return;
            }

            //PDE Build uses top most entry to build the plug-in
            String execEnv = execEnvs[0];

            String projectSourceCompatibility = project.getOption(JavaCore.COMPILER_SOURCE, true);
            String projectClassCompatibility = project.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM,
                    true);
            if (projectComplianceLevel
                    .equals(findMatchingEE(projectSourceCompatibility, projectClassCompatibility, false))
                    && execEnv.equals(
                            findMatchingEE(projectSourceCompatibility, projectClassCompatibility, true))) {
                return; //The project compliance settings matches the BREE
            }

            Map<?, ?> defaultComplianceOptions = new HashMap<Object, Object>();
            JavaCore.setComplianceOptions(projectComplianceLevel, defaultComplianceOptions);

            //project compliance does not match the BREE
            String projectJavaCompatibility = findMatchingEE(projectSourceCompatibility,
                    projectClassCompatibility, true);
            String message = null;
            if (projectJavaCompatibility != null) {
                if (jreCompilationProfileEntry == null) {
                    message = NLS.bind(
                            PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                            PROPERTY_JRE_COMPILATION_PROFILE,
                            PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel);
                    prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message,
                            PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                            PDEMarkerFactory.CAT_EE);
                } else {
                    if (!projectJavaCompatibility.equalsIgnoreCase(jreCompilationProfileEntry.getTokens()[0])) {
                        message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                PROPERTY_JRE_COMPILATION_PROFILE,
                                PDECoreMessages.BuildErrorReporter_CompilercomplianceLevel);
                        prepareError(PROPERTY_JRE_COMPILATION_PROFILE, projectJavaCompatibility, message,
                                PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE);
                    }
                }
            } else {
                // Check source level setting
                if (projectSourceCompatibility.equals(defaultComplianceOptions.get(JavaCore.COMPILER_SOURCE))) {
                    if (javacSourceEntry != null) {
                        message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault,
                                PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility);
                        prepareError(PROPERTY_JAVAC_SOURCE, null, message, PDEMarkerFactory.B_REMOVAL,
                                fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE);
                    }
                } else {
                    if (javacSourceEntry == null) {
                        message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                                PROPERTY_JAVAC_SOURCE, PDECoreMessages.BuildErrorReporter_SourceCompatibility);
                        prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message,
                                PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                PDEMarkerFactory.CAT_EE);
                    } else {
                        if (!projectSourceCompatibility.equalsIgnoreCase(javacSourceEntry.getTokens()[0])) {
                            message = NLS.bind(
                                    PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                    PROPERTY_JAVAC_SOURCE,
                                    PDECoreMessages.BuildErrorReporter_SourceCompatibility);
                            prepareError(PROPERTY_JAVAC_SOURCE, projectSourceCompatibility, message,
                                    PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity,
                                    PDEMarkerFactory.CAT_EE);
                        }
                    }
                }

                // Check target level setting
                if (projectClassCompatibility
                        .equals(defaultComplianceOptions.get(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM))) {
                    if (javacTargetEntry != null) {
                        message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_BuildEntryNotRequiredMatchesDefault,
                                PROPERTY_JAVAC_TARGET,
                                PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                        prepareError(PROPERTY_JAVAC_TARGET, null, message, PDEMarkerFactory.B_REMOVAL,
                                fJavaComplianceSeverity, PDEMarkerFactory.CAT_EE);
                    }
                } else {
                    if (javacTargetEntry == null) {
                        message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                                PROPERTY_JAVAC_TARGET,
                                PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                        prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message,
                                PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                PDEMarkerFactory.CAT_EE);
                    } else {
                        if (!projectClassCompatibility.equalsIgnoreCase(javacTargetEntry.getTokens()[0])) {
                            message = NLS.bind(
                                    PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                    PROPERTY_JAVAC_TARGET,
                                    PDECoreMessages.BuildErrorReporter_GeneratedClassFilesCompatibility);
                            prepareError(PROPERTY_JAVAC_TARGET, projectClassCompatibility, message,
                                    PDEMarkerFactory.B_REPLACE, fJavaComplianceSeverity,
                                    PDEMarkerFactory.CAT_EE);
                        }
                    }
                }
            }

            boolean warnForJavacWarnings = message != null || javacSourceEntry != null
                    || javacTargetEntry != null || jreCompilationProfileEntry != null;
            if (warnForJavacWarnings == false) {
                return;
            }

            checkJavaComplianceSettings(projectComplianceLevel, javacWarningsEntries, javacErrorsEntries,
                    libraryNames);
        }
    }
}

From source file:org.eclipse.pde.internal.core.builders.BuildErrorReporter.java

License:Open Source License

/**
 * Matches the javacWarnings and javacErrors entries in build.properties with the 
 * project specific Java compliance properties and reports the errors found.  Since java
 * compiler settings are set on a per project basis, any special javacWarnings/javacErrors
 * must be set for each library.//from   w  w w  .  j a  v  a2 s. co m
 * 
 * @param complianceLevel the compliance level to check settings against, used to get default values
 * @param javacWarningsEntries list of build entries with the java compiler warnings prefix javacWarnings.
 * @param javacErrorsEntries list of build entries with the java compiler errors prefix javacErrors.
 * @param libraryNames list of String library names
 */
private void checkJavaComplianceSettings(String complianceLevel, ArrayList<IBuildEntry> javacWarningsEntries,
        ArrayList<IBuildEntry> javacErrorsEntries, List<String> libraryNames) {
    List<String> complianceWarnSettings = new ArrayList<String>(3);
    List<String> complianceErrorSettings = new ArrayList<String>(3);

    IJavaProject project = JavaCore.create(fProject);
    if (project.exists()) {

        Map<?, ?> defaultComplianceOptions = new HashMap<Object, Object>();
        JavaCore.setComplianceOptions(complianceLevel, defaultComplianceOptions);

        //look for assertIdentifier and enumIdentifier entries in javacWarnings. If any is present let it be, if not warn.
        String assertIdentifier = project.getOption(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, false);
        String defaultAssert = (String) defaultComplianceOptions.get(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER);
        if (assertIdentifier != null && !assertIdentifier.equalsIgnoreCase(defaultAssert)) {
            if (JavaCore.ERROR.equalsIgnoreCase(assertIdentifier)) {
                complianceErrorSettings.add(ASSERT_IDENTIFIER);
            } else if (JavaCore.WARNING.equalsIgnoreCase(assertIdentifier)) {
                complianceWarnSettings.add(ASSERT_IDENTIFIER);
            }
        }

        String enumIdentifier = project.getOption(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, false);
        String defaultEnum = (String) defaultComplianceOptions.get(JavaCore.COMPILER_PB_ENUM_IDENTIFIER);
        if (enumIdentifier != null && !enumIdentifier.equalsIgnoreCase(defaultEnum)) {
            if (JavaCore.ERROR.equalsIgnoreCase(enumIdentifier)) {
                complianceErrorSettings.add(ENUM_IDENTIFIER);
            } else if (JavaCore.WARNING.equalsIgnoreCase(enumIdentifier)) {
                complianceWarnSettings.add(ENUM_IDENTIFIER);
            }
        }

        // If a warnings entry is required, make sure there is one for each library with the correct content
        if (complianceWarnSettings.size() > 0) {
            for (Iterator<String> iterator = libraryNames.iterator(); iterator.hasNext();) {
                String libName = iterator.next();
                IBuildEntry matchingEntry = null;
                for (Iterator<IBuildEntry> iterator2 = javacWarningsEntries.iterator(); iterator2.hasNext();) {
                    IBuildEntry candidate = iterator2.next();
                    if (candidate.getName().equals(PROPERTY_JAVAC_WARNINGS_PREFIX + libName)) {
                        matchingEntry = candidate;
                        break;
                    }
                }
                if (matchingEntry == null) {
                    String missingTokens = ""; //$NON-NLS-1$
                    for (Iterator<String> iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) {
                        String currentIdentifier = iterator2.next();
                        missingTokens = join(missingTokens, '-' + currentIdentifier);
                    }
                    String message = NLS.bind(
                            PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                            PROPERTY_JAVAC_WARNINGS_PREFIX + libName);
                    prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message,
                            PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                            PDEMarkerFactory.CAT_EE);
                } else {
                    String missingTokens = ""; //$NON-NLS-1$
                    for (Iterator<String> iterator2 = complianceWarnSettings.iterator(); iterator2.hasNext();) {
                        String currentIdentifier = iterator2.next();
                        if (!matchingEntry.contains(currentIdentifier)
                                && !matchingEntry.contains('+' + currentIdentifier)
                                && !matchingEntry.contains('-' + currentIdentifier)) {
                            join(missingTokens, '-' + currentIdentifier);
                        }
                    }
                    if (missingTokens.length() > 0) {
                        String message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                PROPERTY_JAVAC_WARNINGS_PREFIX + libName);
                        prepareError(PROPERTY_JAVAC_WARNINGS_PREFIX + libName, missingTokens, message,
                                PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                PDEMarkerFactory.CAT_EE);
                    }
                }
            }
        }

        // If a warnings entry is required, make sure there is one for each library with the correct content
        if (complianceErrorSettings.size() > 0) {
            for (Iterator<String> iterator = libraryNames.iterator(); iterator.hasNext();) {
                String libName = iterator.next();
                IBuildEntry matchingEntry = null;
                for (Iterator<IBuildEntry> iterator2 = javacErrorsEntries.iterator(); iterator2.hasNext();) {
                    IBuildEntry candidate = iterator2.next();
                    if (candidate.getName().equals(PROPERTY_JAVAC_ERRORS_PREFIX + libName)) {
                        matchingEntry = candidate;
                        break;
                    }
                }
                if (matchingEntry == null) {
                    String missingTokens = ""; //$NON-NLS-1$
                    for (Iterator<String> iterator2 = complianceErrorSettings.iterator(); iterator2
                            .hasNext();) {
                        String currentIdentifier = iterator2.next();
                        missingTokens = join(missingTokens, '-' + currentIdentifier);
                    }
                    String message = NLS.bind(
                            PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceMissingEntry,
                            PROPERTY_JAVAC_ERRORS_PREFIX + libName);
                    prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message,
                            PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                            PDEMarkerFactory.CAT_EE);
                } else {
                    String missingTokens = ""; //$NON-NLS-1$
                    for (Iterator<String> iterator2 = complianceErrorSettings.iterator(); iterator2
                            .hasNext();) {
                        String currentIdentifier = iterator2.next();
                        if (!matchingEntry.contains(currentIdentifier)
                                && !matchingEntry.contains('+' + currentIdentifier)
                                && !matchingEntry.contains('-' + currentIdentifier)) {
                            missingTokens = join(missingTokens, '-' + currentIdentifier);
                        }
                    }
                    if (missingTokens.length() > 0) {
                        String message = NLS.bind(
                                PDECoreMessages.BuildErrorReporter_ProjectSpecificJavaComplianceDifferentToken,
                                PROPERTY_JAVAC_ERRORS_PREFIX + libName);
                        prepareError(PROPERTY_JAVAC_ERRORS_PREFIX + libName, missingTokens, message,
                                PDEMarkerFactory.B_JAVA_ADDDITION, fJavaComplianceSeverity,
                                PDEMarkerFactory.CAT_EE);
                    }
                }
            }
        }
    }
}

From source file:org.eclipse.pde.internal.core.util.PDEJavaHelper.java

License:Open Source License

/**
 * Precedence order from high to low:  (1) Project specific option;
 * (2) General preference option; (3) Default option; (4) Java 1.3
 * @param project//from w w w .  j  ava  2 s. c  o m
 * @param optionName
 */
public static String getJavaLevel(IProject project, String optionName) {
    // Returns the corresponding java project
    // No need to check for null, will return null      
    IJavaProject javaProject = JavaCore.create(project);
    String value = null;
    // Preferred to use the project
    if ((javaProject != null) && javaProject.exists()) {
        // Get the project specific option if one exists. Rolls up to the 
        // general preference option if no project specific option exists.
        value = javaProject.getOption(optionName, true);
        if (value != null) {
            return value;
        }
    }
    // Get the general preference option
    value = new PDEPreferencesManager(JavaCore.PLUGIN_ID).getString(optionName);
    if (value != null) {
        return value;
    }
    // Get the default option
    value = JavaCore.getOption(optionName);
    if (value != null) {
        return value;
    }
    // Return the default
    return JavaCore.VERSION_1_3;
}

From source file:org.eclipse.pde.internal.ui.build.BaseBuildAction.java

License:Open Source License

public static void setDefaultValues(IFile generatedFile) {
    try {/*from  w w  w  . ja  va 2 s  .  com*/
        List<?> configs = AntLaunchShortcut.findExistingLaunchConfigurations(generatedFile);
        ILaunchConfigurationWorkingCopy launchCopy;
        if (configs.size() == 0) {
            ILaunchConfiguration config = AntLaunchShortcut.createDefaultLaunchConfiguration(generatedFile);
            launchCopy = config.getWorkingCopy();
        } else {
            launchCopy = ((ILaunchConfiguration) configs.get(0)).getWorkingCopy();
        }
        if (launchCopy == null)
            return;

        Map<String, String> properties = new HashMap<String, String>();
        properties = launchCopy.getAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
        properties.put(IXMLConstants.PROPERTY_BASE_WS, TargetPlatform.getWS());
        properties.put(IXMLConstants.PROPERTY_BASE_OS, TargetPlatform.getOS());
        properties.put(IXMLConstants.PROPERTY_BASE_ARCH, TargetPlatform.getOSArch());
        properties.put(IXMLConstants.PROPERTY_BASE_NL, TargetPlatform.getNL());
        properties.put("eclipse.running", "true"); //$NON-NLS-1$ //$NON-NLS-2$

        properties.put(IXMLConstants.PROPERTY_JAVAC_FAIL_ON_ERROR, "false"); //$NON-NLS-1$
        properties.put(IXMLConstants.PROPERTY_JAVAC_DEBUG_INFO, "on"); //$NON-NLS-1$  
        properties.put(IXMLConstants.PROPERTY_JAVAC_VERBOSE, "false"); //$NON-NLS-1$

        IProject project = generatedFile.getProject();
        if (!project.hasNature(JavaCore.NATURE_ID)) {
            PDEPreferencesManager pref = new PDEPreferencesManager(JavaCore.PLUGIN_ID);
            properties.put(IXMLConstants.PROPERTY_JAVAC_SOURCE, pref.getString(JavaCore.COMPILER_SOURCE));
            properties.put(IXMLConstants.PROPERTY_JAVAC_TARGET,
                    pref.getString(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM));
        } else {
            IJavaProject jProject = JavaCore.create(project);
            properties.put(IXMLConstants.PROPERTY_JAVAC_SOURCE,
                    jProject.getOption(JavaCore.COMPILER_SOURCE, true));
            properties.put(IXMLConstants.PROPERTY_JAVAC_TARGET,
                    jProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));
        }
        properties.put(IXMLConstants.PROPERTY_BOOTCLASSPATH, BuildUtilities.getBootClasspath());

        launchCopy.setAttribute(IAntLaunchConstants.ATTR_ANT_PROPERTIES, properties);
        launchCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, (String) null);
        launchCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null);
        launchCopy.setAttribute(IAntLaunchConstants.ATTR_DEFAULT_VM_INSTALL, (String) null);
        launchCopy.doSave();
    } catch (CoreException e) {
    }
}

From source file:org.eclipse.pde.ui.tests.ee.ExecutionEnvironmentTests.java

License:Open Source License

/**
 * Validates that the project's option is as expected
 * //from  ww w  . ja  v a2  s. com
 * @param optionName
 * @param expectedValue
 */
protected void validateOption(IJavaProject project, String optionName, String expectedValue) {
    String option = project.getOption(optionName, true);
    assertEquals("Wrong value for option " + optionName, expectedValue, option);
}

From source file:org.eclipse.scout.sdk.saml.importer.internal.jdt.imports.OrganizeImportsHelper.java

License:Open Source License

/**
 * Checks if the given project or workspace has source compliance 1.5 or greater.
 * /*from w  ww .j  a  v  a  2 s .com*/
 * @param project
 *          the project to test or <code>null</code> to test the workspace settings
 * @return <code>true</code> if the given project or workspace has source compliance 1.5 or greater.
 */
public static boolean is50OrHigher(IJavaProject project) {
    String source = project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true)
            : JavaCore.getOption(JavaCore.COMPILER_SOURCE);
    return is50OrHigher(source);
}

From source file:org.eclipse.wb.internal.core.databinding.utils.CoreUtils.java

License:Open Source License

public static boolean useGenerics(IJavaProject javaProject) {
    try {/*from w  ww.j  a  va2 s.co m*/
        String versionValue = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
        Version version = new Version(versionValue);
        return version.getMinor() >= 5;
    } catch (Throwable e) {
    }
    return false;
}