List of usage examples for org.eclipse.jdt.core ClasspathContainerInitializer requestClasspathContainerUpdate
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException
From source file:com.cisco.surf.jenkow.ide.config.UserLibConfigurator.java
License:Open Source License
public void configure(final String name, final File jarFileOrDir) throws CoreException { ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(JavaCore.USER_LIBRARY_CONTAINER_ID); IPath containerPath = new Path(JavaCore.USER_LIBRARY_CONTAINER_ID); initializer.requestClasspathContainerUpdate(containerPath.append(name), null, getClasspathContainer(name, jarFileOrDir)); }
From source file:com.liferay.ide.adt.core.ADTUtil.java
License:Open Source License
public static void addLibsToAndroidProject(final IProject project, List<File[]> filesList, IProgressMonitor monitor) throws CoreException { final IFolder libsFolder = project.getFolder("libs"); CoreUtil.makeFolders(libsFolder);//from w w w .j a v a2 s .c om final IFolder srcFolder = libsFolder.getFolder("src"); CoreUtil.makeFolders(srcFolder); for (File[] files : filesList) { monitor.worked(1); monitor.subTask("Added file " + files[0].getName()); FileUtil.copyFileToIFolder(files[0], libsFolder, monitor); FileUtil.copyFileToIFolder(files[1], srcFolder, monitor); final String propsFilename = files[0].getName() + ".properties"; final String content = "src=src/" + files[1].getName(); final IFile propsFile = libsFolder.getFile(propsFilename); if (propsFile.exists()) { propsFile.setContents(new ByteArrayInputStream(content.getBytes()), true, true, monitor); } else { propsFile.create(new ByteArrayInputStream(content.getBytes()), true, monitor); } } project.refreshLocal(IResource.DEPTH_INFINITE, monitor); try { final IJavaProject javaProject = JavaCore.create(project); final IPath path = new Path("com.android.ide.eclipse.adt.LIBRARIES"); final IClasspathContainer container = JavaCore.getClasspathContainer(path, javaProject); final ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer("org.eclipse.jst.j2ee.internal.web.container"); //$NON-NLS-1$ initializer.requestClasspathContainerUpdate(container.getPath(), javaProject, container); } catch (Exception e) { // ignore errors since this is best effort } }
From source file:com.liferay.ide.project.core.PluginPackageResourceListener.java
License:Open Source License
protected void processPropertiesFile(IFile pluginPackagePropertiesFile) throws CoreException { IProject project = pluginPackagePropertiesFile.getProject(); IJavaProject javaProject = JavaCore.create(project); IPath containerPath = null;/*w w w .j av a 2 s .co m*/ IClasspathEntry[] entries = javaProject.getRawClasspath(); for (IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().segment(0).equals(PluginClasspathContainerInitializer.ID) || entry.getPath().segment(0).equals(SDKClasspathContainer.ID)) { containerPath = entry.getPath(); break; } } } if (containerPath != null) { IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(containerPath, javaProject); final String id = containerPath.segment(0); if (id.equals(PluginClasspathContainerInitializer.ID) || id.equals(SDKClasspathContainer.ID)) { ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id); initializer.requestClasspathContainerUpdate(containerPath, javaProject, classpathContainer); } } Properties props = new Properties(); InputStream contents = null; try { contents = pluginPackagePropertiesFile.getContents(); props.load(contents); // processPortalDependencyTlds(props, pluginPackagePropertiesFile.getProject()); processRequiredDeploymentContexts(props, pluginPackagePropertiesFile.getProject()); } catch (Exception e) { ProjectCore.logError(e); } finally { if (contents != null) { try { contents.close(); } catch (IOException e) { // ignore, this is best effort } } } }
From source file:com.liferay.ide.project.core.PluginPackageResourceListener.java
License:Open Source License
protected void updateWebClasspathContainer(IVirtualComponent rootComponent, List<IVirtualReference> addRefs) throws CoreException { IProject project = rootComponent.getProject(); IJavaProject javaProject = JavaCore.create(project); FlexibleProjectContainer container = J2EEComponentClasspathContainerUtils .getInstalledWebAppLibrariesContainer(project); // If the container is present, refresh it if (container == null) { return;//from w w w . j a v a 2 s .c o m } container.refresh(); // need to regrab this to get newest container container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project); if (container == null) { return; } IClasspathEntry[] webappEntries = container.getClasspathEntries(); for (IClasspathEntry entry : webappEntries) { String archiveName = entry.getPath().lastSegment(); for (IVirtualReference ref : addRefs) { if (ref.getArchiveName().equals(archiveName)) { IFile referencedFile = (IFile) ref.getReferencedComponent().getAdapter(IFile.class); IProject referencedFileProject = referencedFile.getProject(); // IDE-110 IDE-648 ((ClasspathEntry) entry).sourceAttachmentPath = referencedFileProject .getFolder(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/service").getFullPath(); //$NON-NLS-1$ } } } ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer("org.eclipse.jst.j2ee.internal.web.container"); //$NON-NLS-1$ initializer.requestClasspathContainerUpdate(container.getPath(), javaProject, container); }
From source file:com.liferay.ide.project.core.SDKProjectBuilder.java
License:Open Source License
protected IStatus updateClasspath(IProject project) throws CoreException { FlexibleProjectContainer container = J2EEComponentClasspathContainerUtils .getInstalledWebAppLibrariesContainer(project); if (container == null) { return Status.OK_STATUS; }/* w w w .j a va2s . c o m*/ container.refresh(); container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project); IClasspathEntry[] webappEntries = container.getClasspathEntries(); for (IClasspathEntry entry2 : webappEntries) { if (entry2.getPath().lastSegment().equals(getProject().getName() + "-service.jar")) //$NON-NLS-1$ { ((ClasspathEntry) entry2).sourceAttachmentPath = getProject() .getFolder(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/service").getFullPath(); //$NON-NLS-1$ break; } } ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer("org.eclipse.jst.j2ee.internal.web.container"); //$NON-NLS-1$ IJavaProject javaProject = JavaCore.create(project); initializer.requestClasspathContainerUpdate(container.getPath(), javaProject, container); return Status.OK_STATUS; }
From source file:com.liferay.ide.project.core.util.ClasspathUtil.java
License:Open Source License
public static void updateRequestContainer(IProject project) throws CoreException { final IJavaProject javaProject = JavaCore.create(project); IPath containerPath = null;// ww w .j a va2 s . com final IClasspathEntry[] entries = javaProject.getRawClasspath(); for (final IClasspathEntry entry : entries) { if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (entry.getPath().segment(0).equals(SDKClasspathContainer.ID)) { containerPath = entry.getPath(); break; } } } if (containerPath != null) { final IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(containerPath, javaProject); final String id = containerPath.segment(0); if (id.equals(SDKClasspathContainer.ID)) { ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id); initializer.requestClasspathContainerUpdate(containerPath, javaProject, classpathContainer); } } }
From source file:org.apache.felix.sigil.eclipse.internal.model.project.SigilProject.java
License:Apache License
public void resetClasspath(IProgressMonitor monitor, boolean forceResolve) throws CoreException { if (forceResolve) { processRequirementsChanges(monitor); }/*from w ww . ja v a 2 s. c o m*/ Path containerPath = new Path(SigilCore.CLASSPATH_CONTAINER_PATH); IJavaProject java = getJavaModel(); ClasspathContainerInitializer init = JavaCore .getClasspathContainerInitializer(SigilCore.CLASSPATH_CONTAINER_PATH); ThreadProgressMonitor.setProgressMonitor(monitor); try { init.requestClasspathContainerUpdate(containerPath, java, null); } finally { ThreadProgressMonitor.setProgressMonitor(null); } }
From source file:org.ebayopensource.turmeric.eclipse.maven.core.utils.MavenCoreUtils.java
License:Open Source License
/** * Update maven classpath container./*from w w w.j a va 2 s. c o m*/ * * @param project the project * @param dependentName the dependent name * @param type the type * @throws CoreException the core exception * @throws InterruptedException the interrupted exception */ public static void updateMavenClasspathContainer(final IProject project, final String dependentName, final String type) throws CoreException, InterruptedException { final IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID); final IPath containerPath = new Path(SOAMavenConstants.MAVEN_CLASSPATH_CONTAINER_ID); final ClasspathContainerInitializer containerInitializer = JavaCore .getClasspathContainerInitializer(SOAMavenConstants.MAVEN_CLASSPATH_CONTAINER_ID); if (containerInitializer.canUpdateClasspathContainer(containerPath, javaProject)) { final IClasspathContainer mavenContainer = getMaven2ClasspathContainer(javaProject); containerInitializer.requestClasspathContainerUpdate(containerPath, javaProject, mavenContainer); containerInitializer.initialize(containerPath, javaProject); /* * project.build(IncrementalProjectBuilder.FULL_BUILD, * ProgressUtil.getDefaultMonitor(null)); */ // TODO this is a hot fix for the Maven class path issue // it will continuously wait until the newly added service is // available in the classpath String tlGroupId = getMavenOrgProviderInstance().getProjectGroupId(SupportedProjectType.TYPE_LIBRARY); if (IAssetInfo.TYPE_SERVICE_LIBRARY.equals(type)) { waitForClasspathContainerToUpdate( getMavenOrgProviderInstance().getProjectGroupId(SupportedProjectType.INTERFACE), javaProject, dependentName); } else if (tlGroupId.equals(type)) { waitForClasspathContainerToUpdate(tlGroupId, javaProject, dependentName); } } }
From source file:org.eclipse.buildship.core.workspace.GradleClasspathContainer.java
License:Open Source License
/** * Updates the content of the Gradle classpath container asynchronously on the target project. * <p/>//from w w w . j av a 2 s .c om * This method finds the Gradle classpath container on the project and requests the content * update. * * @throws GradlePluginsRuntimeException if the classpath container update request fails * @param project the target project */ public static void requestUpdateOf(IJavaProject project) { ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(CONTAINER_ID); try { IPath containerPath = new Path(CONTAINER_ID); initializer.requestClasspathContainerUpdate(containerPath, project, null); } catch (CoreException e) { throw new GradlePluginsRuntimeException(e); } }
From source file:org.eclipse.buildship.ui.workspace.RefreshGradleClasspathContainerHandler.java
License:Open Source License
private void updateClasspathContainer(IJavaProject project) { ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(ClasspathDefinition.GRADLE_CLASSPATH_CONTAINER_ID); org.eclipse.core.runtime.Path containerPath = new org.eclipse.core.runtime.Path( ClasspathDefinition.GRADLE_CLASSPATH_CONTAINER_ID); try {//from www. j a va 2s. c o m initializer.requestClasspathContainerUpdate(containerPath, project, null); } catch (CoreException e) { throw new GradlePluginsRuntimeException(e); } }