Examples of IJavaProject


Examples of org.eclipse.jdt.core.IJavaProject

   
    public static boolean parseResource(IResource res) {
        if (res instanceof IFile && "drl".equals(res.getFileExtension())) {
            removeProblemsFor(res);
            try {
                IJavaProject project = JavaCore.create(res.getProject());
                // exclude files that are located in the output directory,
                // unless the ouput directory is the same as the project location
                if (!project.getOutputLocation().equals(project.getPath())
                        && project.getOutputLocation().isPrefixOf(res.getFullPath())) {
                    return false;
                }
            } catch (JavaModelException e) {
                // do nothing
            }

            RuleBaseContext factoryContext = new RuleBaseContext();
            RuleSetReaderWithErrors reader = new RuleSetReaderWithErrors(factoryContext);
            try {
                ClassLoader oldLoader = Thread.currentThread()
                        .getContextClassLoader();
                ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
                if (res.getProject().getNature("org.eclipse.jdt.core.javanature") != null) {
                    IJavaProject project = JavaCore.create(res.getProject());
                    newLoader = ProjectClassLoader.getProjectClassLoader(project);
                }
                try {
                    Thread.currentThread().setContextClassLoader(newLoader);
                    reader.read(new StringReader(new String(Util.getResourceContentsAsCharArray((IFile) res))));
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

                for (Container runbundle : runbundles) {
                    if (runbundle.getType() == TYPE.PROJECT) {
                        String targetProjName = runbundle.getProject().getName();
                        IProject targetProj = ResourcesPlugin.getWorkspace().getRoot().getProject(targetProjName);
                        if (targetProj != null) {
                            IJavaProject targetJavaProj = JavaCore.create(targetProj);
                            result.add(new JavaProjectSourceContainer(targetJavaProj));
                        }
                    }
                }
            } catch (Exception e) {
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

    public void launch(IEditorPart editor, String mode) {
        IEditorInput input = editor.getEditorInput();
        IJavaElement element = (IJavaElement) input.getAdapter(IJavaElement.class);
        if (element != null) {
            IJavaProject jproject = element.getJavaProject();
            if (jproject != null) {
                launch(jproject.getProject().getFullPath(), mode);
            }
        } else {
            IFile file = ResourceUtil.getFile(input);
            if (file != null) {
                if (file.getName().endsWith(LaunchConstants.EXT_BNDRUN)) {
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        IFormPage page = (IFormPage) getManagedForm().getContainer();
        IWorkbenchWindow window = page.getEditorSite().getWorkbenchWindow();

        // Prepare the package lister from the Java project
        IProject project = ResourceUtil.getResource(page.getEditorInput()).getProject();
        IJavaProject javaProject = JavaCore.create(project);

        IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[] {
            javaProject
        });
        JavaSearchScopePackageLister packageLister = new JavaSearchScopePackageLister(searchScope, window);
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        }
        desc.setBuildSpec(nu.toArray(new ICommand[nu.size()]));
    }

    private void installBndClasspath() throws CoreException {
        IJavaProject javaProject = JavaCore.create(project);
        IClasspathEntry[] classpath = javaProject.getRawClasspath();
        for (IClasspathEntry entry : classpath) {
            if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && BndtoolsConstants.BND_CLASSPATH_ID.equals(entry.getPath()))
                return; // already installed
        }

        IClasspathEntry[] newEntries = new IClasspathEntry[classpath.length + 1];
        System.arraycopy(classpath, 0, newEntries, 0, classpath.length);
        newEntries[classpath.length] = JavaCore.newContainerEntry(BndtoolsConstants.BND_CLASSPATH_ID);

        javaProject.setRawClasspath(newEntries, null);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        javaProject.setRawClasspath(newEntries, null);
    }

    private void removeBndClasspath() throws CoreException {
        IJavaProject javaProject = JavaCore.create(project);
        IClasspathEntry[] classpath = javaProject.getRawClasspath();
        List<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>(classpath.length);

        boolean changed = false;
        for (IClasspathEntry entry : classpath) {
            if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER && BndtoolsConstants.BND_CLASSPATH_ID.equals(entry.getPath())) {
                changed = true;
            } else {
                newEntries.add(entry);
            }
        }

        if (changed)
            javaProject.setRawClasspath(newEntries.toArray(new IClasspathEntry[newEntries.size()]), null);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

        progress.setWorkRemaining(3);

        IProject cnfProject = ResourcesPlugin.getWorkspace().getRoot().getProject(Workspace.CNFDIR);
        URI location = operation.getLocation() != null ? operation.getLocation().toFile().toURI() : null;
        JavaCapabilityConfigurationPage.createProject(cnfProject, location, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
        IJavaProject cnfJavaProject = JavaCore.create(cnfProject);

        configureJavaProject(cnfJavaProject, progress.newChild(1, SubMonitor.SUPPRESS_NONE));

        String bsn = templateConfig.getContributor().getName();
        Bundle bundle = BundleUtils.findBundle(Plugin.getDefault().getBundleContext(), bsn, null);
        String paths = templateConfig.getAttribute("paths");
        if (paths == null)
            throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Template is missing 'paths' property.", null));

        StringTokenizer tokenizer = new StringTokenizer(paths, ",");
        progress.setWorkRemaining(tokenizer.countTokens());

        while (tokenizer.hasMoreTokens()) {
            String path = tokenizer.nextToken().trim();
            if (!path.endsWith("/"))
                path = path + "/";

            copyBundleEntries(bundle, path, new Path(path), cnfProject, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
        }

        try {
            Central.getWorkspace().refresh();
        } catch (Exception e) {
            logger.logError("Unable to refresh Bnd workspace", e);
        }

        /* Version control ignores */
        VersionControlIgnoresPluginTracker versionControlIgnoresPluginTracker = Plugin.getDefault().getVersionControlIgnoresPluginTracker();
        Set<String> enabledIgnorePlugins = new BndPreferences().getVersionControlIgnoresPluginsEnabled(versionControlIgnoresPluginTracker, cnfJavaProject, null);
        versionControlIgnoresPluginTracker.createProjectIgnores(enabledIgnorePlugins, cnfJavaProject, ProjectPaths.get(ProjectLayout.BND));
        String templateIgnores = null;
        try {
            templateIgnores = templateConfig.getAttribute("ignores");
        } catch (Exception e) {
            logger.logError("Could not retrieve the 'ignores' property from the cnf template " + bsn, e);
        }
        if (templateIgnores != null && !templateIgnores.isEmpty()) {
            versionControlIgnoresPluginTracker.addIgnores(enabledIgnorePlugins, cnfJavaProject.getProject().getLocation().toFile(), templateIgnores);
        }

        /* Headless build files */
        HeadlessBuildPluginTracker headlessBuildPluginTracker = Plugin.getDefault().getHeadlessBuildPluginTracker();
        Set<String> enabledPlugins = new BndPreferences().getHeadlessBuildPluginsEnabled(headlessBuildPluginTracker, null);
        headlessBuildPluginTracker.setup(enabledPlugins, true, cnfJavaProject.getProject().getLocation().toFile(), true, enabledIgnorePlugins);

        /* refresh the project; files were created outside of Eclipse API */
        cnfProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
    }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

            if (projects == null || projects.isEmpty())
                return Status.OK_STATUS;

            SubMonitor progress = SubMonitor.convert(monitor, projects.size());
            for (Project project : projects) {
                IJavaProject eclipseProject = Central.getJavaProject(project);
                eclipseProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, progress.newChild(1, SubMonitor.SUPPRESS_NONE));
            }
            return Status.OK_STATUS;
        }
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

    public List<MarkerData> generateMarkerData(IProject project, Project model, Location location) throws Exception {
        List<MarkerData> result = new ArrayList<MarkerData>();

        BundleActivatorError baError = (BundleActivatorError) location.details;

        IJavaProject javaProject = JavaCore.create(project);

        Map<String,Object> attribs = createMessageMarkerAttributes(baError, location.message);
        //Eclipse line numbers are 1 indexed
        attribs.put(IMarker.LINE_NUMBER, location.line + 1);
View Full Code Here

Examples of org.eclipse.jdt.core.IJavaProject

    }

    public static IJavaProject getJavaProject(Project model) {
        for (IProject iproj : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            if (iproj.getName().equals(model.getName())) {
                IJavaProject ij = JavaCore.create(iproj);
                if (ij != null && ij.exists()) {
                    return ij;
                }
                // current project is not a Java project
            }
        }
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.