use of org.eclipse.jdt.core.IClasspathEntry in project lwjgl by LWJGL.
the class LWJGLClasspathContainerInitializer method rebindClasspathEntries.
private static void rebindClasspathEntries(IJavaModel model, IPath containerPath) throws JavaModelException {
List<IJavaProject> affectedProjects = new ArrayList<IJavaProject>();
IJavaProject[] projects = model.getJavaProjects();
for (int i = 0; i < projects.length; i++) {
IJavaProject project = projects[i];
IClasspathEntry[] entries = project.getRawClasspath();
for (int k = 0; k < entries.length; k++) {
IClasspathEntry curr = entries[k];
if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER && containerPath.equals(curr.getPath())) {
affectedProjects.add(project);
}
}
}
if (!affectedProjects.isEmpty()) {
IJavaProject[] affected = (IJavaProject[]) affectedProjects.toArray(new IJavaProject[affectedProjects.size()]);
IClasspathContainer[] containers = new IClasspathContainer[affected.length];
for (int i = 0; i < containers.length; i++) {
containers[i] = getNewContainer(containerPath);
}
JavaCore.setClasspathContainer(containerPath, affected, containers, null);
}
}
use of org.eclipse.jdt.core.IClasspathEntry in project lwjgl by LWJGL.
the class LWJGLClasspathContainerPage method update.
protected void update() {
IStatus status = null;
IClasspathEntry[] libEntries = BuildPathSupport.getLWJGLLibraryEntries();
IPath containerPath = LWJGLClasspathContainerInitializer.LWJGL_LIBRARY_PATH;
containerEntryResult = JavaCore.newContainerEntry(containerPath);
if (libEntries == null) {
status = new Status(ERROR, Activator.PLUGIN_ID, "No LWJGL library found");
} else if (labelResolvedPath != null && !labelResolvedPath.isDisposed()) {
// implies all other labels to be created and not yet disposed
if (libEntries != null) {
Set<String> setLines = new TreeSet<String>();
IPath path;
for (IClasspathEntry entry : libEntries) {
path = entry.getPath();
if (path != null) {
setLines.add(getPathLabel(path));
}
}
setLabel(labelResolvedPath, setLines);
setLines.clear();
for (IClasspathEntry entry : libEntries) {
path = entry.getSourceAttachmentPath();
if (path != null) {
setLines.add(getPathLabel(path));
}
}
setLabel(labelResolvedSourcePath, setLines);
setLines.clear();
for (IClasspathEntry entry : libEntries) {
if (entry.getExtraAttributes() != null) {
for (IClasspathAttribute attr : entry.getExtraAttributes()) {
if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attr.getName())) {
setLines.add(attr.getValue());
break;
}
if (JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY.equals(attr.getName())) {
}
}
}
}
setLabel(labelResolvedDocPath, setLines);
setLines.clear();
for (IClasspathEntry entry : libEntries) {
if (entry.getExtraAttributes() != null) {
for (IClasspathAttribute attr : entry.getExtraAttributes()) {
if (JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY.equals(attr.getName())) {
setLines.add(attr.getValue());
}
}
}
}
setLabel(labelNativePath, setLines);
} else {
labelResolvedPath.setText("not found");
labelResolvedSourcePath.setText("not found");
labelResolvedDocPath.setText("not found");
}
}
if (status != null)
updateStatus(status);
}
use of org.eclipse.jdt.core.IClasspathEntry in project azure-tools-for-java by Microsoft.
the class CreateProjectUtil method createResourceStructForLocalRunScalaProject.
private static void createResourceStructForLocalRunScalaProject(IFolder sourceRootFolder, String rootPath, IProject project) throws CoreException {
copyFileTo(Scala_Local_Run_Sample, rootPath);
final IFolder dataFolder = sourceRootFolder.getParent().getFolder(new Path("data"));
if (!dataFolder.exists()) {
dataFolder.create(false, true, null);
}
copyFileTo(Scala_Local_Run_Sample_Data, dataFolder.getLocation().toFile().getAbsolutePath());
IJavaProject javaProject = JavaCore.create(project);
IClasspathEntry[] entries = javaProject.getRawClasspath();
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length + 1];
System.arraycopy(entries, 0, newEntries, 0, entries.length);
IPath dataPath = javaProject.getPath().append("data");
IClasspathEntry dataEntry = JavaCore.newSourceEntry(dataPath, null);
newEntries[entries.length] = JavaCore.newSourceEntry(dataEntry.getPath());
javaProject.setRawClasspath(newEntries, null);
}
use of org.eclipse.jdt.core.IClasspathEntry in project azure-tools-for-java by Microsoft.
the class SDKJarsFilter method getClasspathEntries.
/**
* Returns the classpath entries.
*/
@Override
public IClasspathEntry[] getClasspathEntries() {
Bundle bundle = Platform.getBundle(Messages.sdkID);
//Search the available SDKs
Bundle[] bundles = Platform.getBundles(Messages.sdkID, null);
List<IClasspathEntry> listEntries = new ArrayList<IClasspathEntry>();
if (bundles != null) {
for (Bundle bundle2 : bundles) {
if (bundle2.getVersion().toString().startsWith(containerPath.segment(1))) {
bundle = bundle2;
break;
}
}
//Get the SDK jar.
URL sdkJar = FileLocator.find(bundle, new Path(Messages.sdkJar), null);
URL resSdkJar = null;
IClasspathAttribute[] attr = null;
try {
if (sdkJar != null) {
resSdkJar = FileLocator.resolve(sdkJar);
//create classpath attribute for java doc, if present
}
if (resSdkJar == null) {
/* if sdk jar is not present then create an place holder
for sdk jar so that it would be shown as missing file */
URL bundleLoc = new URL(bundle.getLocation());
StringBuffer strBfr = new StringBuffer(bundleLoc.getPath());
strBfr.append(File.separator).append(Messages.sdkJar);
URL jarLoc = new URL(strBfr.toString());
IPath jarPath = new Path(FileLocator.resolve(jarLoc).getPath());
File jarFile = jarPath.toFile();
listEntries.add(JavaCore.newLibraryEntry(new Path(jarFile.getAbsolutePath()), null, null, null, attr, true));
} else {
File directory = new File(resSdkJar.getPath());
//create the library entry for sdk jar
listEntries.add(JavaCore.newLibraryEntry(new Path(directory.getAbsolutePath()), null, null, null, attr, true));
FilenameFilter sdkJarsFilter = new SDKJarsFilter();
File[] jars = new File(String.format("%s%s%s", directory.getParent(), File.separator, Messages.depLocation)).listFiles(sdkJarsFilter);
for (int i = 0; i < jars.length; i++) {
if (jars[i].getName().contains(Messages.appInsightMng) || jars[i].getName().contains(Messages.adAuth) || jars[i].getName().contains(Messages.srvExp)) {
/*
* Do not add them as they are not part of Azure SDK.
* They are just used for coding purpose.
*/
} else {
listEntries.add(JavaCore.newLibraryEntry(new Path(jars[i].getAbsolutePath()), null, null, null, attr, true));
}
}
}
} catch (Exception e) {
listEntries = new ArrayList<IClasspathEntry>();
Activator.getDefault().log(Messages.excp, e);
}
}
IClasspathEntry[] entries = new IClasspathEntry[listEntries.size()];
//Return the classpath entries.
return listEntries.toArray(entries);
}
use of org.eclipse.jdt.core.IClasspathEntry in project azure-tools-for-java by Microsoft.
the class ClasspathContainer method getClasspathEntries.
/**
* Returns the classpath entries.
*/
@Override
public IClasspathEntry[] getClasspathEntries() {
Bundle bundle = Platform.getBundle(Messages.sdkID);
//Search the available SDKs
Bundle[] bundles = Platform.getBundles(Messages.sdkID, null);
List<IClasspathEntry> listEntries = new ArrayList<IClasspathEntry>();
if (bundles != null) {
for (Bundle bundle2 : bundles) {
if (bundle2.getVersion().toString().startsWith(containerPath.segment(1))) {
bundle = bundle2;
break;
}
}
//Get the SDK jar.
URL sdkJar = FileLocator.find(bundle, new Path(Messages.sdkJar), null);
URL resSdkJar = null;
try {
if (sdkJar != null) {
resSdkJar = FileLocator.resolve(sdkJar);
//create classpath attribute for java doc, if present
}
if (resSdkJar == null) {
//if sdk jar is not present then create an place holder
//for sdk jar so that it would be shown as missing file
URL bundleLoc = new URL(bundle.getLocation());
StringBuffer strBfr = new StringBuffer(bundleLoc.getPath());
strBfr.append(File.separator).append(Messages.sdkJar);
URL jarLoc = new URL(strBfr.toString());
IPath jarPath = new Path(FileLocator.resolve(jarLoc).getPath());
File jarFile = jarPath.toFile();
listEntries.add(JavaCore.newLibraryEntry(new Path(jarFile.getAbsolutePath()), null, null, null, null, true));
} else {
File directory = new File(resSdkJar.getPath());
//create the library entry for sdk jar
listEntries.add(JavaCore.newLibraryEntry(new Path(directory.getAbsolutePath()), null, null, null, null, true));
}
} catch (Exception e) {
listEntries = new ArrayList<IClasspathEntry>();
Activator.getDefault().log(Messages.excp, e);
}
}
IClasspathEntry[] entries = new IClasspathEntry[listEntries.size()];
//Return the classpath entries.
return listEntries.toArray(entries);
}
Aggregations