Author: dennyxu
Date: 2008-11-11 00:13:42 -0500 (Tue, 11 Nov 2008)
New Revision: 11648
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
Log:
JBIDE-3152:apply the patch for the issue: ESB classpath container should allow
modification for source and JavaDoc locations
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-11-10
21:48:54 UTC (rev 11647)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-11-11
05:13:42 UTC (rev 11648)
@@ -22,9 +22,10 @@
org.eclipse.jdt.launching,
org.eclipse.jst.j2ee,
org.eclipse.jst.ws.consumption.ui,
- org.eclipse.jst.common.frameworks;bundle-version="1.1.200",
+ org.eclipse.jst.common.frameworks,
org.eclipse.wst.server.core,
- org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0"
+ org.eclipse.jst.common.project.facet.core,
+ org.jboss.ide.eclipse.as.classpath.core
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Export-Package: org.jboss.tools.esb.core,
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java 2008-11-10
21:48:54 UTC (rev 11647)
+++
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java 2008-11-11
05:13:42 UTC (rev 11648)
@@ -1,167 +1,202 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.esb.core.runtime;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ClasspathContainerInitializer;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.ServerCore;
-import org.jboss.tools.esb.core.ESBProjectCorePlugin;
-import org.jboss.tools.esb.core.StatusUtils;
-import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
-
-/**
- * @author Denny Xu
- */
-public class JBossRuntimeClassPathInitializer extends
- ClasspathContainerInitializer {
-
- public final static String JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID =
"org.jboss.esb.runtime.classpath";
- public final static String JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED =
"server.supplied";
- public JBossRuntimeClassPathInitializer() {
- }
-
- private String segment;
- private boolean isServerSupplied = false;
- private IJavaProject javaProject;
-
- @Override
- public void initialize(IPath containerPath, IJavaProject project)
- throws CoreException {
- this.javaProject = project;
- if (containerPath.segment(0).equals(
- JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)) {
- if(containerPath.segmentCount() == 3
- &&
containerPath.segment(1).equals(JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED)){
- segment = containerPath.segment(2);
- isServerSupplied = true;
- }else{
- segment = containerPath.segment(1);
- isServerSupplied = false;
- }
-
- JBossRuntimeClasspathContainer container = new JBossRuntimeClasspathContainer(
- containerPath, project, isServerSupplied);
- JavaCore.setClasspathContainer(containerPath,
- new IJavaProject[] { project },
- new IClasspathContainer[] { container }, null);
- }
- }
-
- public IClasspathEntry[] getEntries(IPath path) {
- return new JBossRuntimeClasspathContainer(path, javaProject,
isServerSupplied).getClasspathEntries();
- }
-
- public class JBossRuntimeClasspathContainer implements
- IClasspathContainer {
- private IPath path;
- private boolean isFromServer = false;
- private IClasspathEntry[] entries = null;
- private IJavaProject jproject;
- private List<String> jars;
-
- public JBossRuntimeClasspathContainer(IPath path, IJavaProject project, boolean
isFromServer) {
- this.path = path;
- this.isFromServer = isFromServer;
- this.jproject = project;
- }
-
- public String getDescription() {
- return JBossFacetCoreMessages.JBoss_Runtime;
- }
-
- public int getKind() {
- return IClasspathContainer.K_APPLICATION;
- }
-
- public IPath getPath() {
- return path;
- }
-
- public IClasspathEntry[] getClasspathEntries() {
- if (entries == null) {
- ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
- if (isFromServer) {
- IRuntime serverRuntime = ServerCore.findRuntime(segment);
-
- if(serverRuntime == null){
- IStatus status = StatusUtils.errorStatus("Can not find the runtime: "+
segment);
- ESBProjectCorePlugin.getDefault().getLog().log(status);
- }
- String runtimeLocation = serverRuntime.getLocation().toOSString();
- jars = JBossRuntimeManager.getInstance().getAllRuntimeJars(runtimeLocation);
-
- } else {
-
- JBossRuntime jbws = JBossRuntimeManager.getInstance()
- .findRuntimeByName(segment);
- if (jbws != null) {
- jars = JBossRuntimeManager.getInstance()
- .getAllRuntimeJars(jbws);
- }
- }
-
- if(jars == null) return new IClasspathEntry[0];
-
- for (String jar : jars) {
- entryList.add(getEntry(new Path(jar)));
- }
- entries = entryList.toArray(new IClasspathEntry[entryList
- .size()]);
- if (entries == null)
- return new IClasspathEntry[0];
- }
- return entries;
- }
-
- protected IClasspathEntry getEntry(IPath path) {
- return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
- .getClasspathEntry();
- }
-
- public void removeEntry(String jarName) {
- if (entries == null) {
- return;
- }
- IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
- int i = 0;
- for (IClasspathEntry entry : entries) {
- if (!entry.toString().contains(jarName)) {
- newEntries[i++] = entry;
- }
- }
- entries = newEntries;
- }
-
- }
-
- public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
- for (IClasspathEntry entry : list) {
- if (entry.getPath().lastSegment().equals(jarName)) {
- return false;
- }
- }
- return true;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.ServerCore;
+import org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainer;
+import
org.jboss.ide.eclipse.as.classpath.core.jee.AbstractClasspathContainerInitializer;
+import org.jboss.ide.eclipse.as.classpath.core.xpl.ClasspathDecorations;
+import org.jboss.tools.esb.core.ESBProjectCorePlugin;
+import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+
+/**
+ * @author Denny Xu
+ */
+public class JBossRuntimeClassPathInitializer extends
+ AbstractClasspathContainerInitializer {
+
+ public final static String JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID =
"org.jboss.esb.runtime.classpath";
+ public final static String JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED =
"server.supplied";
+
+ public JBossRuntimeClassPathInitializer() {
+ }
+
+ private String segment;
+ private boolean isServerSupplied = false;
+ private IJavaProject javaProject;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+ this.javaProject = project;
+ if (containerPath.segment(0).equals(
+ JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)) {
+ if (containerPath.segmentCount() == 3
+ && containerPath.segment(1).equals(
+ JBOSS_ESB_RUNTIME_CLASSPATH_SERVER_SUPPLIED)) {
+ segment = containerPath.segment(2);
+ isServerSupplied = true;
+ } else {
+ segment = containerPath.segment(1);
+ isServerSupplied = false;
+ }
+
+ JBossRuntimeClasspathContainer container = new JBossRuntimeClasspathContainer(
+ containerPath, project, isServerSupplied);
+ JavaCore.setClasspathContainer(containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
+ }
+ }
+
+ public IClasspathEntry[] getEntries(IPath path) {
+ return new JBossRuntimeClasspathContainer(path, javaProject,
+ isServerSupplied).getClasspathEntries();
+ }
+
+ public class JBossRuntimeClasspathContainer extends
+ AbstractClasspathContainer {
+ private IPath path;
+ private boolean isFromServer = false;
+ private IClasspathEntry[] entries = null;
+ private IJavaProject jproject;
+ private List<String> jars;
+
+ public JBossRuntimeClasspathContainer(IPath path, IJavaProject project,
+ boolean isFromServer) {
+ super(path, JBossFacetCoreMessages.JBoss_Runtime, null);
+ this.path = path;
+ this.isFromServer = isFromServer;
+ this.jproject = project;
+ }
+
+ public String getDescription() {
+ return JBossFacetCoreMessages.JBoss_Runtime;
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ public IClasspathEntry[] computeEntries() {
+ ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
+ if (isFromServer) {
+ IRuntime serverRuntime = ServerCore.findRuntime(segment);
+
+ if (serverRuntime == null) {
+ IStatus status = StatusUtils
+ .errorStatus("Can not find the runtime: " + segment);
+ ESBProjectCorePlugin.getDefault().getLog().log(status);
+ }
+ String runtimeLocation = serverRuntime.getLocation()
+ .toOSString();
+ jars = JBossRuntimeManager.getInstance().getAllRuntimeJars(
+ runtimeLocation);
+
+ } else {
+
+ JBossRuntime jbws = JBossRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ if (jbws != null) {
+ jars = JBossRuntimeManager.getInstance().getAllRuntimeJars(
+ jbws);
+ }
+ }
+
+ if (jars == null)
+ return new IClasspathEntry[0];
+
+ for (String jar : jars) {
+
+ IPath entryPath = new Path(jar);
+
+ IPath sourceAttachementPath = null;
+ IPath sourceAttachementRootPath = null;
+
+ final ClasspathDecorations dec = decorations.getDecorations(
+ getDecorationManagerKey(getPath().toString()),
+ entryPath.toString());
+
+ IClasspathAttribute[] attrs = {};
+ if (dec != null) {
+ sourceAttachementPath = dec.getSourceAttachmentPath();
+ sourceAttachementRootPath = dec
+ .getSourceAttachmentRootPath();
+ attrs = dec.getExtraAttributes();
+ }
+
+ IAccessRule[] access = {};
+ IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath,
+ sourceAttachementPath, sourceAttachementRootPath,
+ access, attrs, false);
+ entryList.add(entry);
+ }
+ entries = entryList.toArray(new IClasspathEntry[entryList.size()]);
+ return entries;
+ }
+
+ public void removeEntry(String jarName) {
+ if (entries == null) {
+ return;
+ }
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
+ }
+ }
+ entries = newEntries;
+ }
+
+ }
+
+ public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
+ for (IClasspathEntry entry : list) {
+ if (entry.getPath().lastSegment().equals(jarName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ protected AbstractClasspathContainer createClasspathContainer(IPath path) {
+ return new JBossRuntimeClasspathContainer(path, javaProject,
+ isServerSupplied);
+ }
+
+ @Override
+ protected String getClasspathContainerID() {
+ return JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID;
+ }
+
+}