use of org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer in project webtools.servertools by eclipse.
the class GenericServerSourcePathComputerDelegate method processModules.
private void processModules(List<ISourceContainer> sourcefolderList, IModule[] modules, List<IJavaProject> 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
}
}
}
}
}
use of org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer in project webtools.servertools by eclipse.
the class PreviewSourcePathComputerDelegate method computeSourceContainers.
/* (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 {
List<IRuntimeClasspathEntry> classpaths = new ArrayList<IRuntimeClasspathEntry>();
classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedSourceLookupPath(configuration)));
List<ISourceContainer> sourcefolderList = new ArrayList<ISourceContainer>();
IServer server = ServerUtil.getServer(configuration);
if (server != null) {
List<IJavaProject> list = new ArrayList<IJavaProject>();
IModule[] modules = server.getModules();
for (IModule module : modules) {
IProject project = module.getProject();
if (project != null) {
IFolder moduleFolder = project.getFolder(module.getName());
if (moduleFolder.exists()) {
sourcefolderList.add(new FolderSourceContainer(moduleFolder, true));
}
try {
if (project.hasNature(JavaCore.NATURE_ID)) {
IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
if (!list.contains(javaProject))
list.add(javaProject);
}
} catch (Exception e) {
// ignore
}
}
}
int size = list.size();
IJavaProject[] projects = new IJavaProject[size];
list.toArray(projects);
for (IJavaProject project : projects) classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedRuntimeClasspath(project)));
}
IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[classpaths.size()];
classpaths.toArray(entries);
IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
ISourceContainer[] sourceContainers = JavaRuntime.getSourceContainers(resolved);
if (!sourcefolderList.isEmpty()) {
ISourceContainer[] combinedSourceContainers = new ISourceContainer[sourceContainers.length + sourcefolderList.size()];
sourcefolderList.toArray(combinedSourceContainers);
System.arraycopy(sourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), sourceContainers.length);
sourceContainers = combinedSourceContainers;
}
return sourceContainers;
}
use of org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer in project webtools.sourceediting by eclipse.
the class XSLTSourcePathComputerDelegate method computeSourceContainers.
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
List<ISourceContainer> containers = new ArrayList<ISourceContainer>();
String sourceFileExpr = configuration.getAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, (String) null);
IPath sourceFile = getSubstitutedPath(sourceFileExpr);
LaunchPipeline pipeline = hydratePipeline(configuration);
// TODO have some way of knowing whether it is an IResource or not
containers.add(new DirectorySourceContainer(sourceFile, false));
for (Iterator<?> iter = pipeline.getTransformDefs().iterator(); iter.hasNext(); ) {
LaunchTransform transform = (LaunchTransform) iter.next();
IPath path = transform.getPath();
ISourceContainer sourceContainer = null;
if (transform.getPathType().equals(LaunchTransform.RESOURCE_TYPE)) {
IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
IContainer container = resource.getParent();
if (container.getType() == IResource.PROJECT) {
sourceContainer = new ProjectSourceContainer((IProject) container, false);
} else if (container.getType() == IResource.FOLDER) {
sourceContainer = new FolderSourceContainer(container, false);
}
} else {
sourceContainer = new DirectorySourceContainer(path, false);
}
containers.add(sourceContainer);
}
return containers.toArray(new ISourceContainer[0]);
}
use of org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer in project mdw-designer by CenturyLinkCloud.
the class JavaSourcePathComputer method addProjectsFromModules.
private void addProjectsFromModules(List<ISourceContainer> sourcefolderList, IModule[] modules, List<IJavaProject> 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)
addProjectsFromModules(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
}
}
}
}
}
Aggregations