Java Code Examples for org.eclipse.jdt.ui.PreferenceConstants#getDefaultJRELibrary()

The following examples show how to use org.eclipse.jdt.ui.PreferenceConstants#getDefaultJRELibrary() . 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: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private List<CPListElement> getDefaultClassPath(IJavaProject jproj) {
	List<CPListElement> list= new ArrayList<CPListElement>();
	IResource srcFolder;
	IPreferenceStore store= PreferenceConstants.getPreferenceStore();
	String sourceFolderName= store.getString(PreferenceConstants.SRCBIN_SRCNAME);
	if (store.getBoolean(PreferenceConstants.SRCBIN_FOLDERS_IN_NEWPROJ) && sourceFolderName.length() > 0) {
		srcFolder= jproj.getProject().getFolder(sourceFolderName);
	} else {
		srcFolder= jproj.getProject();
	}

	list.add(new CPListElement(jproj, IClasspathEntry.CPE_SOURCE, srcFolder.getFullPath(), srcFolder));

	IClasspathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary();
	list.addAll(getCPListElements(jreEntries, null));
	return list;
}
 
Example 2
Source File: MainProjectWizardPage.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void putDefaultClasspathEntriesIn(Collection<IClasspathEntry> classpathEntries) {
	final IPath newPath = this.jreGroup.getJREContainerPath();
	if (newPath != null) {
		classpathEntries.add(JavaCore.newContainerEntry(newPath));
	} else {
		final IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();
		classpathEntries.addAll(Arrays.asList(entries));
	}

	final IClasspathEntry sarlClasspathEntry = JavaCore.newContainerEntry(
			SARLClasspathContainerInitializer.CONTAINER_ID,
			new IAccessRule[0],
			new IClasspathAttribute[0],
			true);
	classpathEntries.add(sarlClasspathEntry);
}
 
Example 3
Source File: NewJavaProjectWizardPageOne.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the default class path entries to be added on new projects. By default this is the JRE container as
 * selected by the user.
 *
 * @return returns the default class path entries
 */
public IClasspathEntry[] getDefaultClasspathEntries() {
	IPath newPath= fJREGroup.getJREContainerPath();
	if (newPath != null) {
		return new IClasspathEntry[] { JavaCore.newContainerEntry(newPath) };
	}
	return PreferenceConstants.getDefaultJRELibrary();
}
 
Example 4
Source File: ClassPathDetector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Method detectClasspath.
 * 
 * @param monitor The progress monitor (not null)
 * @throws CoreException in case of any failure
 */
private void detectClasspath(IProgressMonitor monitor) throws CoreException {
	try {
		monitor.beginTask(NewWizardMessages.ClassPathDetector_operation_description, 4);

		fMonitor= monitor;
		fProject.accept(this, IResource.NONE);
		monitor.worked(1);

		ArrayList<IClasspathEntry> cpEntries= new ArrayList<IClasspathEntry>();

		detectSourceFolders(cpEntries);
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		monitor.worked(1);


		IPath outputLocation= detectOutputFolder();
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		monitor.worked(1);

		detectLibraries(cpEntries, outputLocation);
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		monitor.worked(1);

		if (cpEntries.isEmpty() && fClassFiles.isEmpty()) {
			return;
		}
		IClasspathEntry[] jreEntries= PreferenceConstants.getDefaultJRELibrary();
		for (int i= 0; i < jreEntries.length; i++) {
			cpEntries.add(jreEntries[i]);
		}

		IClasspathEntry[] entries= cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
		if (!JavaConventions.validateClasspath(JavaCore.create(fProject), entries, outputLocation).isOK()) {
			return;
		}

		fResultClasspath= entries;
		fResultOutputFolder= outputLocation;
	} finally {
		monitor.done();
	}
}