use of org.eclipse.jdt.core.IClasspathContainer in project liferay-ide by liferay.
the class PluginPackageResourceListener method processRequiredDeploymentContexts.
protected void processRequiredDeploymentContexts(Properties props, IProject project) {
IVirtualComponent rootComponent = ComponentCore.createComponent(project);
if (rootComponent == null) {
return;
}
List<IVirtualReference> removeRefs = new ArrayList<>();
IClasspathContainer webAppLibrariesContainer = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
if (webAppLibrariesContainer == null) {
return;
}
IClasspathEntry[] existingEntries = webAppLibrariesContainer.getClasspathEntries();
for (IClasspathEntry entry : existingEntries) {
IPath path = entry.getPath();
String archiveName = path.lastSegment();
if (archiveName.endsWith("-service.jar")) {
IFile file = _getWorkspaceFile(path);
if (file.exists() && ProjectUtil.isLiferayFacetedProject(file.getProject())) {
for (IVirtualReference ref : rootComponent.getReferences()) {
if (archiveName.equals(ref.getArchiveName())) {
removeRefs.add(ref);
}
}
}
}
}
List<IVirtualReference> addRefs = new ArrayList<>();
String requiredDeploymenContexts = props.getProperty("required-deployment-contexts");
if (requiredDeploymenContexts != null) {
String[] contexts = requiredDeploymenContexts.split(StringPool.COMMA);
if (ListUtil.isNotEmpty(contexts)) {
for (String context : contexts) {
IVirtualReference ref = processContext(rootComponent, context);
if (ref != null) {
addRefs.add(ref);
}
}
}
}
new WorkspaceJob("Update virtual component.") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
updateVirtualComponent(rootComponent, removeRefs, addRefs);
updateWebClasspathContainer(rootComponent, addRefs);
return Status.OK_STATUS;
}
}.schedule();
}
use of org.eclipse.jdt.core.IClasspathContainer in project liferay-ide by liferay.
the class PluginPackageResourceListener method processPropertiesFile.
protected void processPropertiesFile(IFile pluginPackagePropertiesFile) throws CoreException {
IProject project = pluginPackagePropertiesFile.getProject();
IJavaProject javaProject = JavaCore.create(project);
IPath containerPath = null;
IClasspathEntry[] entries = javaProject.getRawClasspath();
for (IClasspathEntry entry : entries) {
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
String segment = entry.getPath().segment(0);
if (segment.equals(PluginClasspathContainerInitializer.ID) || segment.equals(SDKClasspathContainer.ID)) {
containerPath = entry.getPath();
break;
}
}
}
if (containerPath != null) {
IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(containerPath, javaProject);
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 ioe) {
// ignore, this is best effort
}
}
}
}
use of org.eclipse.jdt.core.IClasspathContainer 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);
}
}
use of org.eclipse.jdt.core.IClasspathContainer in project liferay-ide by liferay.
the class ClasspathUtil method updateRequestContainer.
public static void updateRequestContainer(IProject project) throws CoreException {
IJavaProject javaProject = JavaCore.create(project);
IPath containerPath = null;
IClasspathEntry[] entries = javaProject.getRawClasspath();
for (IClasspathEntry entry : entries) {
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
String segment = entry.getPath().segment(0);
if (segment.equals(SDKClasspathContainer.ID)) {
containerPath = entry.getPath();
break;
}
}
}
if (containerPath != null) {
IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(containerPath, javaProject);
String id = containerPath.segment(0);
if (id.equals(SDKClasspathContainer.ID)) {
ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id);
initializer.requestClasspathContainerUpdate(containerPath, javaProject, classpathContainer);
}
}
}
use of org.eclipse.jdt.core.IClasspathContainer in project eclipse.jdt.ls by eclipse.
the class JavaElementLabels method getContainerEntryLabel.
/**
* Returns the label of a classpath container.
* The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
*
* @param containerPath the path of the container
* @param project the project the container is resolved in
* @return the label of the classpath container
* @throws JavaModelException when resolving of the container failed
*/
public static String getContainerEntryLabel(IPath containerPath, IJavaProject project) throws JavaModelException {
IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, project);
if (container != null) {
return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(container.getDescription());
}
ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
if (initializer != null) {
return org.eclipse.jdt.internal.core.manipulation.util.Strings.markLTR(initializer.getDescription(containerPath, project));
}
return BasicElementLabels.getPathLabel(containerPath, false);
}
Aggregations