use of org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations in project liferay-ide by liferay.
the class PluginClasspathContainer method createClasspathEntry.
protected IClasspathEntry createClasspathEntry(IPath entryPath, IPath sourceLocation, String javadocURL) {
IPath sourceRootPath = null;
IPath sourcePath = null;
IAccessRule[] rules = {};
IClasspathAttribute[] attrs = new IClasspathAttribute[0];
ClasspathDecorations dec = cpDecorations.getDecorations(getDecorationManagerKey(javaProject.getProject(), getPath().toString()), entryPath.toString());
if (dec != null) {
sourcePath = dec.getSourceAttachmentPath();
sourceRootPath = dec.getSourceAttachmentRootPath();
attrs = dec.getExtraAttributes();
}
if (javadocURL != null) {
if (ListUtil.isEmpty(attrs)) {
attrs = new IClasspathAttribute[] { newJavadocAttr(javadocURL) };
} else {
List<IClasspathAttribute> newAttrs = new ArrayList<>();
for (IClasspathAttribute attr : attrs) {
if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attr.getName())) {
newAttrs.add(newJavadocAttr(javadocURL));
} else {
newAttrs.add(attr);
}
}
attrs = newAttrs.toArray(new IClasspathAttribute[0]);
}
}
if ((sourcePath == null) && (sourceLocation != null)) {
sourcePath = sourceLocation;
}
return JavaCore.newLibraryEntry(entryPath, sourcePath, sourceRootPath, rules, attrs, false);
}
use of org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations in project liferay-ide by liferay.
the class PluginClasspathContainerInitializer method requestClasspathContainerUpdate.
@Override
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
String key = PluginClasspathContainer.getDecorationManagerKey(project.getProject(), containerPath.toString());
IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();
cpDecorations.clearAllDecorations(key);
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
IPath srcpath = entry.getSourceAttachmentPath();
IPath srcrootpath = entry.getSourceAttachmentRootPath();
IClasspathAttribute[] attrs = entry.getExtraAttributes();
if ((srcpath != null) || ListUtil.isNotEmpty(attrs)) {
String eid = entry.getPath().toString();
ClasspathDecorations dec = new ClasspathDecorations();
dec.setSourceAttachmentPath(srcpath);
dec.setSourceAttachmentRootPath(srcrootpath);
dec.setExtraAttributes(attrs);
cpDecorations.setDecorations(key, eid, dec);
}
}
cpDecorations.save();
IPath portalDir = null;
String javadocURL = null;
IPath sourceLocation = null;
if (containerSuggestion instanceof PluginClasspathContainer) {
portalDir = ((PluginClasspathContainer) containerSuggestion).getPortalDir();
javadocURL = ((PluginClasspathContainer) containerSuggestion).getJavadocURL();
sourceLocation = ((PluginClasspathContainer) containerSuggestion).getSourceLocation();
} else {
portalDir = ServerUtil.getPortalDir(project);
try {
ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project.getProject());
if (liferayRuntime != null) {
javadocURL = liferayRuntime.getJavadocURL();
sourceLocation = liferayRuntime.getSourceLocation();
}
} catch (Exception e) {
ProjectCore.logError(e);
}
}
if (portalDir != null) {
IClasspathContainer newContainer = getCorrectContainer(containerPath, containerPath.segment(1), project, portalDir, javadocURL, sourceLocation);
IJavaProject[] projects = { project };
IClasspathContainer[] containers = { newContainer };
JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
}
use of org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations in project liferay-ide by liferay.
the class SDKClasspathContainerInitializer method requestClasspathContainerUpdate.
@Override
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
String key = SDKClasspathContainer.getDecorationManagerKey(project.getProject(), containerPath.toString());
IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();
cpDecorations.clearAllDecorations(key);
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
IPath srcpath = entry.getSourceAttachmentPath();
IPath srcrootpath = entry.getSourceAttachmentRootPath();
IClasspathAttribute[] attrs = entry.getExtraAttributes();
if ((srcpath != null) || ListUtil.isNotEmpty(attrs)) {
String eid = entry.getPath().toString();
ClasspathDecorations dec = new ClasspathDecorations();
dec.setSourceAttachmentPath(srcpath);
dec.setSourceAttachmentRootPath(srcrootpath);
dec.setExtraAttributes(attrs);
cpDecorations.setDecorations(key, eid, dec);
}
}
cpDecorations.save();
IPath portalDir = null;
IPath portalGlobalDir = null;
String javadocURL = null;
IPath sourceLocation = null;
IPath bundleDir = null;
IPath[] bundleDependencyJarPaths = null;
PortalBundle bundle = ServerUtil.getPortalBundle(project.getProject());
boolean containerChanged = true;
if (containerSuggestion instanceof SDKClasspathContainer) {
portalDir = ((SDKClasspathContainer) containerSuggestion).getPortalDir();
bundleDir = ((SDKClasspathContainer) containerSuggestion).getBundleDir();
portalGlobalDir = ((SDKClasspathContainer) containerSuggestion).getPortalGlobalDir();
javadocURL = ((SDKClasspathContainer) containerSuggestion).getJavadocURL();
sourceLocation = ((SDKClasspathContainer) containerSuggestion).getSourceLocation();
bundleDependencyJarPaths = ((SDKClasspathContainer) containerSuggestion).getBundleLibDependencyPath();
if ((bundle != null) && bundle.getAppServerPortalDir().equals(portalDir)) {
containerChanged = false;
}
}
if (containerChanged == true) {
if (bundle == null) {
return;
}
portalDir = bundle.getAppServerPortalDir();
portalGlobalDir = bundle.getAppServerLibGlobalDir();
bundleDependencyJarPaths = bundle.getBundleDependencyJars();
}
IPath[] sdkDependencyPaths = _getSDKDependencies(project);
if ((portalDir != null) && (portalGlobalDir != null)) {
IClasspathContainer newContainer = new SDKClasspathContainer(containerPath, project, portalDir, javadocURL, sourceLocation, portalGlobalDir, bundleDir, bundleDependencyJarPaths, sdkDependencyPaths);
IJavaProject[] projects = { project };
IClasspathContainer[] containers = { newContainer };
JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
}
Aggregations