List of usage examples for org.springframework.ide.eclipse.core.java JdtUtils getJavaProject
public static IJavaProject getJavaProject(IResource config)
From source file:org.eclipse.virgo.ide.jdt.core.ServerClasspathContainerPropertyTester.java
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof IResource && "isEnabled".equals(property)) { if (JdtUtils.isJavaProject((IResource) receiver)) return ClasspathUtils.hasClasspathContainer(JdtUtils.getJavaProject((IResource) receiver)); }/*w ww . j a va2s . co m*/ return false; }
From source file:org.eclipse.virgo.ide.manifest.internal.core.validation.rules.AbstractBundleManifestHeaderRule.java
@Override protected boolean supportsContext(BundleManifestValidationContext context) { IResource resource = context.getRootElement().getElementResource(); IJavaProject javaProject = JdtUtils.getJavaProject(resource); return FacetUtils.isBundleProject(context.getRootElement().getElementResource()) && (resource.equals(BundleManifestUtils.locateManifest(javaProject, false)) || resource.equals(BundleManifestUtils.locateManifest(javaProject, true))); }
From source file:org.eclipse.virgo.ide.manifest.internal.core.validation.rules.ExportPackageRule.java
private void validateExportPackage(BundleManifestHeader header, ManifestElement element, BundleManifestValidationContext context) { boolean found = false; try {/* w ww.ja v a 2s . com*/ IPackageFragmentRoot[] roots = JdtUtils.getJavaProject(context.getRootElement().getElementResource()) .getPackageFragmentRoots(); for (IPackageFragmentRoot root : roots) { int kind = root.getKind(); if (kind == IPackageFragmentRoot.K_SOURCE || (kind == IPackageFragmentRoot.K_BINARY && !root.isExternal())) { IJavaElement[] javaElements = root.getChildren(); for (int j = 0; j < javaElements.length; j++) if (javaElements[j] instanceof IPackageFragment) { IPackageFragment fragment = (IPackageFragment) javaElements[j]; String name = fragment.getElementName(); if (name.length() == 0) { name = "."; } if (fragment.containsJavaResources() || fragment.getNonJavaResources().length > 0) { if (name.equals(element.getValue())) { found = true; } } } } } } catch (JavaModelException e) { } // if we actually have packages to add if (!found) { context.warning("MISSING_PACKAGE_EXPORT", "Bundle does export non-existing package", header.getLineNumber() + 1); } }
From source file:org.eclipse.virgo.ide.jdt.internal.ui.actions.RefreshServerClasspathContainerActionDelegate.java
public void run(IAction action) { Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>(); Iterator<IProject> iter = selected.iterator(); while (iter.hasNext()) { IProject project = iter.next();//from w w w . j a va 2 s . c o m if (FacetUtils.isBundleProject(project)) { projects.add(JdtUtils.getJavaProject(project)); } else if (FacetUtils.isParProject(project)) { for (IProject bundle : FacetUtils.getBundleProjects(project)) { projects.add(JdtUtils.getJavaProject(bundle)); } } } for (IJavaProject javaProject : projects) { ServerClasspathContainerUpdateJob.scheduleClasspathContainerUpdateJob(javaProject, BundleManifestManager.IMPORTS_CHANGED); } }
From source file:org.eclipse.virgo.ide.bundlor.ui.internal.actions.RunBundlorActionDelegate.java
public void run(IAction action) { Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>(); Iterator<IProject> iter = selected.iterator(); while (iter.hasNext()) { IProject project = iter.next();/*w ww. j a v a2 s.c om*/ if (FacetUtils.isBundleProject(project)) { projects.add(JdtUtils.getJavaProject(project)); } } for (final IJavaProject javaProject : projects) { BundlorUiPlugin.runBundlorOnProject(javaProject); } }
From source file:org.eclipse.virgo.ide.runtime.internal.ui.actions.OpenManifestAction.java
public void run(IAction action) { IProject project = selectedModule.getProject(); if (FacetUtils.isBundleProject(project)) { openResource(BundleManifestUtils.locateManifest(JdtUtils.getJavaProject(project), false)); } else if (FacetUtils.isParProject(project)) { openResource(project.findMember(BundleManifestCorePlugin.MANIFEST_FILE_LOCATION)); } else if (SpringCoreUtils.hasProjectFacet(project, FacetCorePlugin.WEB_FACET_ID)) { openResource(BundleManifestUtils.locateManifest(JdtUtils.getJavaProject(project), false)); }/*from w ww . j a va2 s . c o m*/ }
From source file:org.eclipse.virgo.ide.manifest.internal.core.validation.BundleManifestValidator.java
/** * {@inheritDoc}//w w w .ja va 2 s . c o m */ public Set<IResource> getAffectedResources(IResource resource, int kind, int deltaKind) throws CoreException { IJavaProject javaProject = JdtUtils.getJavaProject(resource); IResource bundleManifest = BundleManifestUtils.locateManifest(javaProject, false); Set<IResource> resources = new LinkedHashSet<IResource>(); if ((FacetUtils.isBundleProject(resource) && resource.equals(bundleManifest)) || (FacetUtils.isParProject(resource) && SpringCoreUtils.isManifest(resource))) { resources.add(resource); } else if (FacetUtils.isBundleProject(resource) && resource.getProjectRelativePath().toString().equals("template.mf")) { resources.add(resource); } return resources; }
From source file:org.eclipse.virgo.ide.jdt.internal.ui.actions.EnableServerClasspathContainerActionDelegate.java
public void run(IAction action) { Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>(); Iterator<IProject> iter = selected.iterator(); while (iter.hasNext()) { IProject project = iter.next();//from ww w . j ava 2s .c o m if (FacetUtils.isBundleProject(project)) { projects.add(JdtUtils.getJavaProject(project)); } else if (FacetUtils.isParProject(project)) { for (IProject bundle : FacetUtils.getBundleProjects(project)) { projects.add(JdtUtils.getJavaProject(bundle)); } } } for (IJavaProject javaProject : projects) { try { if (ClasspathUtils.hasClasspathContainer(javaProject)) { removeFromClasspath(javaProject, JavaCore.newContainerEntry(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH, null, ServerClasspathContainer.CLASSPATH_CONTAINER_ATTRIBUTE, false), new NullProgressMonitor()); // Remove any error markers that might hang around javaProject.getProject().deleteMarkers(JdtCorePlugin.DEPENDENCY_PROBLEM_MARKER_ID, true, IResource.DEPTH_INFINITE); } else { addToClasspath(javaProject, JavaCore.newContainerEntry(ServerClasspathContainer.CLASSPATH_CONTAINER_PATH, null, ServerClasspathContainer.CLASSPATH_CONTAINER_ATTRIBUTE, false), new NullProgressMonitor()); } } catch (CoreException e) { JdtCorePlugin.log(e); } } }
From source file:org.eclipse.virgo.ide.bundlor.ui.internal.actions.AutomaticRunBundlorActionDelegate.java
public void run(IAction action) { final Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>(); Iterator<IProject> iter = selected.iterator(); while (iter.hasNext()) { IProject project = iter.next();// w ww . java2 s . co m if (FacetUtils.isBundleProject(project)) { projects.add(JdtUtils.getJavaProject(project)); } } IRunnableWithProgress op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { for (final IJavaProject javaProject : projects) { try { if (BundlorUiPlugin.isBundlorBuilderEnabled(javaProject.getProject())) { SpringCoreUtils.removeProjectBuilder(javaProject.getProject(), BundlorCorePlugin.BUILDER_ID, new NullProgressMonitor()); } else { SpringCoreUtils.addProjectBuilder(javaProject.getProject(), BundlorCorePlugin.BUILDER_ID, new NullProgressMonitor()); } } catch (CoreException e) { SpringCore.log(e); } } } }; try { PlatformUI.getWorkbench().getProgressService().runInUI( PlatformUI.getWorkbench().getActiveWorkbenchWindow(), op, ResourcesPlugin.getWorkspace().getRoot()); } catch (InvocationTargetException e) { SpringCore.log(e); } catch (InterruptedException e) { } }
From source file:org.eclipse.virgo.ide.beans.core.internal.locate.SpringOsgiBeansConfigLocator.java
/** * This implementation only supports {@link IJavaProject} and SpringSource bundle projects. * <p>//from ww w. j av a 2s . c o m * This method calculates the {@link #contextLocations} for this particular bundle. */ @Override protected boolean canLocateInProject(IProject project) { if (!super.canLocateInProject(project) || !FacetUtils.isBundleProject(project)) { return false; } BundleManifest bundleManifest = BundleManifestCorePlugin.getBundleManifestManager() .getBundleManifest(JdtUtils.getJavaProject(project)); if (bundleManifest != null) { Dictionary<String, String> manifest = bundleManifest.toDictionary(); contextLocations = getConfigLocationPattern(manifest); return true; } return false; }