Search in sources :

Example 1 with FolderSourceContainer

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
                }
            }
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IJavaProject(org.eclipse.jdt.core.IJavaProject) FolderSourceContainer(org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with FolderSourceContainer

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;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) FolderSourceContainer(org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer) ArrayList(java.util.ArrayList) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IJavaProject(org.eclipse.jdt.core.IJavaProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IFolder(org.eclipse.core.resources.IFolder)

Example 3 with FolderSourceContainer

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]);
}
Also used : LaunchTransform(org.eclipse.wst.xsl.launching.config.LaunchTransform) IPath(org.eclipse.core.runtime.IPath) LaunchPipeline(org.eclipse.wst.xsl.launching.config.LaunchPipeline) FolderSourceContainer(org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer) ArrayList(java.util.ArrayList) DirectorySourceContainer(org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer) ProjectSourceContainer(org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer) IProject(org.eclipse.core.resources.IProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 4 with FolderSourceContainer

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
                }
            }
        }
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IJavaProject(org.eclipse.jdt.core.IJavaProject) FolderSourceContainer(org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IProject (org.eclipse.core.resources.IProject)4 FolderSourceContainer (org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer)4 IFolder (org.eclipse.core.resources.IFolder)3 CoreException (org.eclipse.core.runtime.CoreException)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IModule (org.eclipse.wst.server.core.IModule)3 ArrayList (java.util.ArrayList)2 ISourceContainer (org.eclipse.debug.core.sourcelookup.ISourceContainer)2 IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 DirectorySourceContainer (org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer)1 ProjectSourceContainer (org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer)1 IRuntimeClasspathEntry (org.eclipse.jdt.launching.IRuntimeClasspathEntry)1 IServer (org.eclipse.wst.server.core.IServer)1 LaunchPipeline (org.eclipse.wst.xsl.launching.config.LaunchPipeline)1 LaunchTransform (org.eclipse.wst.xsl.launching.config.LaunchTransform)1