Example usage for org.eclipse.jdt.core JavaCore setOptions

List of usage examples for org.eclipse.jdt.core JavaCore setOptions

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore setOptions.

Prototype

public static void setOptions(Hashtable<String, String> newOptions) 

Source Link

Document

Sets the current table of options.

Usage

From source file:at.bestsolution.fxide.jdt.editor.JDTProposalComputer.java

License:Open Source License

private void restrictVisibility(boolean restrict) {
    Hashtable<String, String> options = JavaCore.getOptions();
    Object value = options.get(VISIBILITY);
    if (value instanceof String) {
        String newValue = restrict ? ENABLED : DISABLED;
        if (!newValue.equals(value)) {
            options.put(VISIBILITY, newValue);
            JavaCore.setOptions(options);
        }//from   w w w  .  j a  va  2  s.c o m
    }
}

From source file:com.javadude.antxr.eclipse.core.AntxrCorePlugin.java

License:Open Source License

/** {@inheritDoc} */
@Override//from w w  w  .j a  v a 2  s.  c o m
@SuppressWarnings("unchecked")
public void start(BundleContext context) throws Exception {
    super.start(context);
    // Add ANTXR grammar files to JDT builder's copy exclusion filter
    Hashtable options = JavaCore.getOptions();
    String filter = (String) options.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
    StringTokenizer st = new StringTokenizer(filter, ",");
    boolean found = false;
    while (st.hasMoreTokens()) {
        if (st.nextToken().equals("*.antxr")) {
            found = true;
            break;
        }
    }
    if (!found) {
        if (AntxrCorePlugin.isDebug()) {
            System.out.println("Adding '*.antxr' to JDT builder's " + "resource filter (" + filter + ")");
        }
        options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, filter + ",*.antxr");
        JavaCore.setOptions(options);
    }
}

From source file:dacapo.eclipse.EclipseBuildTests.java

License:Open Source License

/**
 * Start a build on workspace using given options.
 * @param options//ww  w . j  ava 2s.  co  m
 * @throws IOException
 * @throws CoreException
 */
private void startBuild(IJavaProject project, Hashtable options, boolean noWarning)
        throws IOException, CoreException {
    if (DEBUG)
        System.out.print("\tstart build...");

    JavaCore.setOptions(options);

    if (project == null) {
        System.out.println("\tBuilding: full workspace");
        env.fullBuild();
    } else {
        System.out.print("\t" + project.toString());
        System.out.print(" opening");
        project.getProject().open(null);
        System.out.print(" cleaning");
        project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, null);
        System.out.print(" building");
        project.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
        System.out.println();
    }

    if (VERIFY) {
        // Verify markers
        IMarker[] markers = ResourcesPlugin.getWorkspace().getRoot()
                .findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
        List resources = new ArrayList();
        List messages = new ArrayList();
        int warnings = 0;
        for (int i = 0, length = markers.length; i < length; i++) {
            IMarker marker = markers[i];
            switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) {
            case IMarker.SEVERITY_ERROR:
                resources.add(marker.getResource().getName());
                messages.add(marker.getAttribute(IMarker.MESSAGE));
                break;
            case IMarker.SEVERITY_WARNING:
                warnings++;
                if (noWarning) {
                    resources.add(marker.getResource().getName());
                    messages.add(marker.getAttribute(IMarker.MESSAGE));
                }
                break;
            }
        }

        // Assert result
        int size = messages.size();
        if (size > 0) {
            StringBuffer debugBuffer = new StringBuffer();
            for (int i = 0; i < size; i++) {
                debugBuffer.append(resources.get(i));
                debugBuffer.append(":\n\t");
                debugBuffer.append(messages.get(i));
                debugBuffer.append('\n');
            }
            System.out.println("Unexpected ERROR marker(s):\n" + debugBuffer.toString());
            System.out.println("--------------------");
        }
    }
    if (DEBUG)
        System.out.println("done");
}

From source file:edu.brown.cs.bubbles.bedrock.BedrockProject.java

License:Open Source License

@SuppressWarnings("unchecked")
private boolean setProjectPreferences(IProject ip, Element xml) {
    Map<Object, Object> opts;
    IJavaProject ijp = null;/*  w w  w  .  j a v  a 2s  .c  o  m*/

    if (ip != null) {
        ijp = JavaCore.create(ip);
        if (ijp == null)
            return false;
        opts = ijp.getOptions(false);
    } else
        opts = JavaCore.getOptions();

    for (Element opt : IvyXml.children(xml, "OPTION")) {
        String nm = IvyXml.getAttrString(opt, "NAME");
        String vl = IvyXml.getAttrString(opt, "VALUE");
        opts.put(nm, vl);
    }

    if (ijp != null) {
        ijp.setOptions(opts);
    } else {
        Hashtable<?, ?> nopts = new Hashtable<Object, Object>(opts);
        JavaCore.setOptions(nopts);
    }

    return true;
}

From source file:edu.illinois.compositerefactorings.steps.tests.StepTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    @SuppressWarnings("unchecked")
    Hashtable<String, String> options = TestOptions.getDefaultOptions();
    options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
    options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4");

    JavaCore.setOptions(options);

    IPreferenceStore store = JavaPlugin.getDefault().getPreferenceStore();
    store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
    store.setValue(PreferenceConstants.CODEGEN_KEYWORD_THIS, false);

    StubUtility.setCodeTemplate(CodeTemplateContextType.METHODSTUB_ID, "//TODO\n${body_statement}", null);

    Preferences corePrefs = JavaPlugin.getJavaCorePluginPreferences();
    corePrefs.setValue(JavaCore.CODEASSIST_FIELD_PREFIXES, "");
    corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, "");
    corePrefs.setValue(JavaCore.CODEASSIST_FIELD_SUFFIXES, "");
    corePrefs.setValue(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, "");

    fJProject1 = ProjectTestSetup.getProject();

    fSourceFolder = JavaProjectHelper.addSourceContainer(fJProject1, "src");
}

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.EclipseUtils.java

License:Open Source License

private static void initializeProject() {
    Hashtable<?, ?> options = JavaCore.getOptions();
    JavaCore.setComplianceOptions("1.7", options);
    JavaCore.setOptions(options);

    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceDescription desc = workspace.getDescription();
    desc.setAutoBuilding(false);//from ww w.  ja  v a2 s .c  om
    try {
        workspace.setDescription(desc);
    } catch (CoreException e) {
        logger.log(Level.SEVERE, "Unable to turn off auto-building");
    }

    IWorkspaceRoot root = workspace.getRoot();
    project = root.getProject(projectName);

    try {
        if (project.exists()) {
            project.delete(true, null);
        }

        project.create(null);
        project.open(null);
        IProjectDescription description = project.getDescription();
        String[] prevNatures = description.getNatureIds();
        String[] newNatures = new String[prevNatures.length + 1];
        System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
        newNatures[prevNatures.length] = JavaCore.NATURE_ID;
        description.setNatureIds(newNatures);
        project.setDescription(description, null);
        //      project.setDefaultCharset("UTF-8", null);

        javaProject = JavaCore.create(project);
    } catch (CoreException e) {
        logger.log(Level.SEVERE, "Error in project initialization", e);
    }
}

From source file:fede.workspace.eclipse.java.fields.JDISourceViewer.java

License:Apache License

/**
 * Tells this processor to restrict its proposal to those element
 * visible in the actual invocation context.
 * /*from  w  w w.ja  v  a2 s  . com*/
 * @param restrict <code>true</code> if proposals should be restricted
 */
private static void restrictProposalsToVisibility(boolean restrict) {
    Hashtable options = JavaCore.getOptions();
    Object value = options.get(VISIBILITY);
    if (value instanceof String) {
        String newValue = restrict ? ENABLED : DISABLED;
        if (!newValue.equals(value)) {
            options.put(VISIBILITY, newValue);
            JavaCore.setOptions(options);
        }
    }
}

From source file:org.antlr.eclipse.core.AntlrCorePlugin.java

License:Open Source License

/** {@inheritDoc} */
@Override/*  w w  w . ja v  a 2 s.c  o m*/
public void start(final BundleContext context) throws Exception {
    super.start(context);
    // Add ANTLR grammar files to JDT builder's copy exclusion filter
    Hashtable<String, String> options = JavaCore.getOptions();
    String filter = options.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER);
    StringTokenizer st = new StringTokenizer(filter, ",");
    boolean found = false;
    while (st.hasMoreTokens()) {
        if (st.nextToken().equals("*.g")) {
            found = true;
            break;
        }
    }
    if (!found) {
        if (isDebug()) {
            System.out.println("Adding '*.g' to JDT builder's " + "resource filter (" + filter + ")");
        }
        options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, filter + ",*.g");
        JavaCore.setOptions(options);
    }

    createClasspathVariable("org.antlr", ANTLR_HOME);
}

From source file:org.caesarj.ui.CJDTConfigSettings.java

License:Open Source License

static public void disableUnusedImports() {
    Hashtable map = JavaCore.getOptions();
    map.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.IGNORE);
    JavaCore.setOptions(map);
}

From source file:org.caesarj.ui.CJDTConfigSettings.java

License:Open Source License

static public void enableUnusedImports() {
    Hashtable map = JavaCore.getOptions();
    map.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.IGNORE);
    JavaCore.setOptions(map);
}