Author: rob.stryker(a)jboss.com
Date: 2007-08-16 15:48:07 -0400 (Thu, 16 Aug 2007)
New Revision: 3194
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ServerSourcePathComputerDelegate.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
Log:
JBIDE-687
Initial fix involved copying the standard source locator from generic server.
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ServerSourcePathComputerDelegate.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ServerSourcePathComputerDelegate.java
(rev 0)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/xpl/ServerSourcePathComputerDelegate.java 2007-08-16
19:48:07 UTC (rev 3194)
@@ -0,0 +1,103 @@
+/***************************************************************************************************
+ * Copyright (c) 2005 Eteration A.S. and Gorkem Ercan. All rights reserved. This program
and the
+ * accompanying materials are 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: Gorkem Ercan - initial API and implementation
+ *
+
**************************************************************************************************/
+package org.jboss.ide.eclipse.as.core.server.xpl;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+/**
+ * SourcePathComputer for the GenericLaunchConfiguration.
+ *
+ * @author Gorkem Ercan
+ */
+public class ServerSourcePathComputerDelegate implements ISourcePathComputerDelegate {
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration,
org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration,
IProgressMonitor monitor) throws CoreException {
+
+ IRuntimeClasspathEntry[] unresolvedEntries =
JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
+ List sourcefolderList = new ArrayList();
+
+ IServer server = ServerUtil.getServer(configuration);
+ IModule[] modules = server.getModules();
+
+ List javaProjectList = new ArrayList();
+
+ processModules(sourcefolderList, modules, javaProjectList, server,monitor);
+
+
+ IRuntimeClasspathEntry[] projectEntries = new
IRuntimeClasspathEntry[javaProjectList.size()];
+ for (int i = 0; i < javaProjectList.size(); i++) {
+ projectEntries[i] =
JavaRuntime.newProjectRuntimeClasspathEntry((IJavaProject)javaProjectList.get(i));
+ }
+ IRuntimeClasspathEntry[] entries = new
IRuntimeClasspathEntry[projectEntries.length+unresolvedEntries.length];
+ System.arraycopy(unresolvedEntries,0,entries,0,unresolvedEntries.length);
+ System.arraycopy(projectEntries,0,entries,unresolvedEntries.length,projectEntries.length);
+
+ IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries,
configuration);
+ ISourceContainer[] javaSourceContainers = JavaRuntime.getSourceContainers(resolved);
+
+ if (!sourcefolderList.isEmpty()) {
+ ISourceContainer[] combinedSourceContainers = new
ISourceContainer[javaSourceContainers.length + sourcefolderList.size()];
+ sourcefolderList.toArray(combinedSourceContainers);
+ System.arraycopy(javaSourceContainers, 0, combinedSourceContainers,
sourcefolderList.size(), javaSourceContainers.length);
+ javaSourceContainers = combinedSourceContainers;
+ }
+
+ return javaSourceContainers;
+
+ }
+
+ private void processModules(List sourcefolderList, IModule[] modules, List
javaProjectList, IServer server, IProgressMonitor monitor) {
+ for (int i = 0; i < modules.length; i++) {
+ IProject project = modules[i].getProject();
+ IModule[] pModule = new IModule[1];
+ pModule[0]=modules[i];
+ IModule[] cModule = server.getChildModules(pModule, monitor);
+ if(cModule != null && cModule.length>0)
+ {
+ processModules(sourcefolderList, cModule, javaProjectList, server, monitor);
+ }
+ if (project != null) {
+ IFolder moduleFolder = project.getFolder(modules[i].getName());
+ if (moduleFolder.exists()) {
+ sourcefolderList.add(new FolderSourceContainer(moduleFolder, true));
+ } else {
+ try {
+ if (project.hasNature(JavaCore.NATURE_ID)) {
+ IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
+ if(!javaProjectList.contains(javaProject)){
+ javaProjectList.add(javaProject);
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2007-08-16 19:39:31 UTC (rev
3193)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/plugin.xml 2007-08-16 19:48:07 UTC (rev
3194)
@@ -204,16 +204,25 @@
modes="run,debug"
name="JBoss Application Server"
public="true"
-
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
+
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
+
sourcePathComputerId="org.jboss.ide.eclipse.as.core.serverSourcePathComputer"/>
<launchConfigurationType
delegate="org.jboss.ide.eclipse.as.core.server.stripped.DeployableLaunchConfiguration"
id="org.jboss.ide.eclipse.as.core.server.stripped.launchConfiguration"
modes="run,debug"
name="Stripped Server Launch Configuration"
- public="false"
-
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
+ public="true"
+
sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"
+
sourcePathComputerId="org.jboss.ide.eclipse.as.core.serverSourcePathComputer"/>
</extension>
+ <extension
+ point="org.eclipse.debug.core.sourcePathComputers">
+ <sourcePathComputer
+
class="org.jboss.ide.eclipse.as.core.server.xpl.ServerSourcePathComputerDelegate"
+ id="org.jboss.ide.eclipse.as.core.serverSourcePathComputer">
+ </sourcePathComputer>
+ </extension>
<!-- Module Factory Stuff -->