Java Code Examples for org.eclipse.jdt.core.JavaCore#newContainerEntry()
The following examples show how to use
org.eclipse.jdt.core.JavaCore#newContainerEntry() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReorgCorrectionsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private boolean updateClasspath(IPath newPath, IProgressMonitor monitor) throws JavaModelException { boolean updated= false; IClasspathEntry[] classpath= fProject.getRawClasspath(); IPath jreContainerPath= new Path(JavaRuntime.JRE_CONTAINER); for (int i= 0; i < classpath.length; i++) { IClasspathEntry curr= classpath[i]; if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && curr.getPath().matchingFirstSegments(jreContainerPath) > 0) { if (! newPath.equals(curr.getPath())) { updated= true; classpath[i]= JavaCore.newContainerEntry(newPath, curr.getAccessRules(), curr.getExtraAttributes(), curr.isExported()); } } } if (updated) { fProject.setRawClasspath(classpath, monitor); } return updated; }
Example 2
Source File: Importer.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
/** * Sometimes the project configuration is corrupt and a Java runtime is not on the classpath * @param monitor * @param javaProject * @throws JavaModelException */ private void fixMissingJavaRuntime(IProgressMonitor monitor, IJavaProject javaProject) throws JavaModelException { if (!javaProject.getProject().getName().equals("config")) { IClasspathEntry[] classPathEntries = javaProject.getRawClasspath(); boolean found = false; for (IClasspathEntry classpathEntry : classPathEntries) { // fix missing runtime if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { if (classpathEntry.getPath().toString().startsWith("org.eclipse.jdt.launching.JRE_CONTAINER")) { found = true; break; } } } if (!found) { IClasspathEntry entry = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER"), false); Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>(Arrays.asList(classPathEntries)); entries.add(entry); FixProjectsUtils.setClasspath(entries.toArray(new IClasspathEntry[entries.size()]), javaProject, monitor); } } }
Example 3
Source File: IDEOpenSampleReportAction.java From birt with Eclipse Public License 1.0 | 5 votes |
private IClasspathEntry[] getClassPathEntries( IProject project ) { IClasspathEntry[] internalClassPathEntries = getInternalClassPathEntries( project ); IClasspathEntry[] entries = new IClasspathEntry[internalClassPathEntries.length + 1]; System.arraycopy( internalClassPathEntries, 0, entries, 0, internalClassPathEntries.length ); entries[entries.length - 1] = JavaCore.newContainerEntry( new Path( "org.eclipse.jdt.launching.JRE_CONTAINER" ) ); //$NON-NLS-1$ return entries; }
Example 4
Source File: UserLibraryWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IClasspathEntry getSelection() { if (fEditResult != null) { if (fOldClasspathEntry != null && fOldClasspathEntry.getPath().equals(fEditResult.getPath())) { return JavaCore.newContainerEntry(fEditResult.getPath(), fOldClasspathEntry.getAccessRules(), fOldClasspathEntry.getExtraAttributes(), fOldClasspathEntry.isExported()); } else { return JavaCore.newContainerEntry(fEditResult.getPath(), false); } } return null; }
Example 5
Source File: NewReportProjectWizard.java From birt with Eclipse Public License 1.0 | 5 votes |
private IClasspathEntry[] getClassPathEntries( IProject project ) { IClasspathEntry[] internalClassPathEntries = getInternalClassPathEntries( project ); IClasspathEntry[] entries = new IClasspathEntry[internalClassPathEntries.length + 1]; System.arraycopy( internalClassPathEntries, 0, entries, 0, internalClassPathEntries.length ); entries[entries.length - 1] = JavaCore.newContainerEntry( new Path( "org.eclipse.jdt.launching.JRE_CONTAINER" ) ); //$NON-NLS-1$ return entries; }
Example 6
Source File: RuntimeLibraryContainerWizardPage.java From txtUML with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("restriction") public RuntimeLibraryContainerWizardPage() { super("RuntimeLibraryContainer"); //$NON-NLS-1$ setTitle(Messages.RuntimeLibraryContainerWizardPage_classpathLibraryTitle); setImageDescriptor(org.eclipse.jdt.internal.ui.JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY); setDescription(Messages.RuntimeLibraryContainerWizardPage_classpathLibraryDescription); this.containerEntry = JavaCore .newContainerEntry(RuntimeLibraryContainerInitializer.LIBRARY_PATH); }
Example 7
Source File: ProjectTestUtil.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Creates a Java project with the given name and a "src" folder and the default JRE library on * its classpath. */ public static IJavaProject createProject(String projectName) throws CoreException { IClasspathEntry[] classpath = new IClasspathEntry[] { JavaCore.newSourceEntry(Path.fromOSString("/" + projectName + "/" + SOURCE_FOLDER)), JavaCore.newContainerEntry(Path.fromOSString("org.eclipse.jdt.launching.JRE_CONTAINER"))}; return ProjectTestUtil.createProject(projectName, classpath); }
Example 8
Source File: SdkClasspathContainerPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
public final IClasspathEntry getSelection() { SdkSelection<T> sdkSelection = sdkSelectionBlock.getSdkSelection(); IPath containerPath = SdkClasspathContainer.computeContainerPath( containerID, sdkSelection.getSelectedSdk(), sdkSelection.isDefault() ? Type.DEFAULT : Type.NAMED); return JavaCore.newContainerEntry(containerPath); }
Example 9
Source File: JanusContainerWizardPage.java From sarl with Apache License 2.0 | 5 votes |
/** Construct a wizard page for defining the SARL library container. */ public JanusContainerWizardPage() { super("JanusClassPathContainer"); //$NON-NLS-1$ setTitle(Messages.JanusClasspathContainer_0); setImageDescriptor(JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY); setDescription(Messages.JanusContainerWizardPage_0); this.containerEntry = JavaCore.newContainerEntry( JanusClasspathContainerInitializer.CONTAINER_ID); }
Example 10
Source File: XtendContainerWizardPage.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("restriction") public XtendContainerWizardPage() { super("XtendClassPathContainer"); //$NON-NLS-1$ setTitle(Messages.XtendClasspathContainer_Description); setImageDescriptor(org.eclipse.jdt.internal.ui.JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY); setDescription(Messages.XtendContainerWizardPage_Desc); this.containerEntry = JavaCore.newContainerEntry(XtendContainerInitializer.XTEND_LIBRARY_PATH); }
Example 11
Source File: UserLibraryWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public IClasspathEntry[] getNewContainers() { List<CPUserLibraryElement> selected= fLibrarySelector.getCheckedElements(); IClasspathEntry[] res= new IClasspathEntry[selected.size()]; for (int i= 0; i < res.length; i++) { CPUserLibraryElement curr= selected.get(i); res[i]= JavaCore.newContainerEntry(curr.getPath(), false); } return res; }
Example 12
Source File: JREContainerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.9 */ public static IClasspathEntry getJREContainerEntry(String bree) { IClasspathEntry jreContainerEntry = getDefaultJREContainerEntry(); IExecutionEnvironment ee = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(bree); if (ee != null) { return JavaCore.newContainerEntry(newJREContainerPath(ee)); } return jreContainerEntry; }
Example 13
Source File: BuildPath.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static IClasspathEntry makeClasspathEntry(Library library) throws CoreException { IClasspathAttribute[] classpathAttributes = new IClasspathAttribute[1]; if (library.isExport()) { boolean isWebApp = true; classpathAttributes[0] = UpdateClasspathAttributeUtil.createDependencyAttribute(isWebApp); } else { classpathAttributes[0] = UpdateClasspathAttributeUtil.createNonDependencyAttribute(); } // in practice, this method will only be called for the master library IPath containerPath = new Path(LibraryClasspathContainer.CONTAINER_PATH_PREFIX) .append(library.getId()); return JavaCore.newContainerEntry(containerPath, new IAccessRule[0], classpathAttributes, false); }
Example 14
Source File: ClasspathUtilTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testAddClasspathEntries() throws JavaModelException { IClasspathEntry entry1 = JavaCore.newSourceEntry(new Path("/my/src")); IClasspathEntry entry2 = JavaCore.newContainerEntry(new Path("/my/container")); List<IClasspathEntry> toAdd = Lists.newArrayList(entry1, entry2); assertFalse(classpathExists(entry1)); assertFalse(classpathExists(entry2)); ClasspathUtil.addClasspathEntries(project, toAdd, monitor); assertTrue(classpathExists(entry1)); assertTrue(classpathExists(entry2)); }
Example 15
Source File: CreateAppEngineWtpProject.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
private static void addJunit4ToClasspath(IProject newProject, IProgressMonitor monitor) throws CoreException { IClasspathAttribute nonDependencyAttribute = UpdateClasspathAttributeUtil.createNonDependencyAttribute(); IClasspathEntry junit4Container = JavaCore.newContainerEntry( JUnitCore.JUNIT4_CONTAINER_PATH, new IAccessRule[0], new IClasspathAttribute[] {nonDependencyAttribute}, false); ClasspathUtil.addClasspathEntry(newProject, junit4Container, monitor); }
Example 16
Source File: Junit5LibClasspathAdder.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override protected IClasspathEntry createContainerClasspathEntry() { return JavaCore.newContainerEntry(JUNIT5_LIBRARY_PATH); }
Example 17
Source File: XtendLibClasspathAdder.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
@Override protected IClasspathEntry createContainerClasspathEntry() { return JavaCore.newContainerEntry(XtendContainerInitializer.XTEND_LIBRARY_PATH); }
Example 18
Source File: JREContainerProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.6 */ public static IClasspathEntry getDefaultJREContainerEntry() { IPath jreContainerPath = getDefaultJREContainerPath(); return JavaCore.newContainerEntry(jreContainerPath); }
Example 19
Source File: IDECPListElement.java From birt with Eclipse Public License 1.0 | 4 votes |
private IClasspathEntry newClasspathEntry( ) { IClasspathAttribute[] extraAttributes = new IClasspathAttribute[0]; switch ( fEntryKind ) { case IClasspathEntry.CPE_SOURCE : return JavaCore.newSourceEntry( fPath, null, null, null, extraAttributes ); case IClasspathEntry.CPE_LIBRARY : { return JavaCore.newLibraryEntry( fPath, null, null, null, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_PROJECT : { return JavaCore.newProjectEntry( fPath, null, false, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_CONTAINER : { return JavaCore.newContainerEntry( fPath, null, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_VARIABLE : { return JavaCore.newVariableEntry( fPath, null, null, null, extraAttributes, isExported( ) ); } default : return null; } }
Example 20
Source File: ClasspathContainerDefaultPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public IClasspathEntry getSelection() { return JavaCore.newContainerEntry(new Path(fEntryField.getText())); }