Search in sources :

Example 6 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class WarModuleAssembler method assemble.

public IPath assemble(IProgressMonitor monitor) throws CoreException {
    IPath parent = copyModule(fModule, monitor);
    IWebModule webModule = (IWebModule) fModule.loadAdapter(IWebModule.class, monitor);
    IModule[] childModules = webModule.getModules();
    for (int i = 0; i < childModules.length; i++) {
        IModule module = childModules[i];
        String uri = webModule.getURI(module);
        if (uri == null) {
            // The bad memories of WTP 1.0
            // $NON-NLS-1$
            IStatus status = new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, "unable to assemble module null uri", null);
            throw new CoreException(status);
        }
        IJ2EEModule jeeModule = (IJ2EEModule) module.loadAdapter(IJ2EEModule.class, monitor);
        if (jeeModule != null && jeeModule.isBinary()) {
            // Binary module
            ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
            IModuleResource[] resources = pm.members();
            publishHelper.publishToPath(resources, parent.append(uri), monitor);
        } else {
            // Project module
            packModule(module, uri, parent);
        }
    }
    return parent;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) IJ2EEModule(org.eclipse.jst.server.core.IJ2EEModule) IPath(org.eclipse.core.runtime.IPath) IWebModule(org.eclipse.jst.server.core.IWebModule) ProjectModule(org.eclipse.wst.server.core.util.ProjectModule) CoreException(org.eclipse.core.runtime.CoreException)

Example 7 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class ModuleHelper method getModuleFile.

public static IModuleFile getModuleFile(IModule module, IPath path) throws CoreException {
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
    IModuleResource[] mr = pm.members();
    int size = mr.length;
    for (int i = 0; i < size; i++) {
        if (mr[i].getModuleRelativePath().equals(path)) {
            if (mr[i] instanceof IModuleFile)
                return (IModuleFile) mr[i];
            return null;
        } else if (mr[i].getModuleRelativePath().isPrefixOf(path))
            return getModuleFile((IModuleFolder) mr[i], path);
    }
    return null;
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule)

Example 8 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class ModuleHelper method countFilesInModule.

public static int countFilesInModule(IModule module) throws CoreException {
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
    IModuleResource[] mr = pm.members();
    int count = 0;
    int size = mr.length;
    for (int i = 0; i < size; i++) {
        if (mr[i] instanceof IModuleFolder)
            count += countFilesInFolder((IModuleFolder) mr[i]);
        else
            count++;
    }
    return count;
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule)

Example 9 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class ModuleHelper method getModuleFile.

public static IModuleFile getModuleFile(IModule module, IPath path) throws CoreException {
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
    IModuleResource[] mr = pm.members();
    for (IModuleResource m : mr) {
        if (m.getModuleRelativePath().append(m.getName()).equals(path)) {
            if (m instanceof IModuleFile)
                return (IModuleFile) m;
            return null;
        } else if (m.getModuleRelativePath().isPrefixOf(path) && m instanceof IModuleFolder) {
            IModuleFile mf2 = getModuleFile((IModuleFolder) m, path);
            if (mf2 != null)
                return mf2;
        }
    }
    return null;
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule)

Example 10 with ProjectModule

use of org.eclipse.wst.server.core.util.ProjectModule in project webtools.servertools by eclipse.

the class ModuleHelper method getModuleFolder.

public static IModuleFolder getModuleFolder(IModule module, IPath path) throws CoreException {
    ProjectModule pm = (ProjectModule) module.loadAdapter(ProjectModule.class, null);
    IModuleResource[] mr = pm.members();
    for (IModuleResource m : mr) {
        if (m.getModuleRelativePath().append(m.getName()).equals(path)) {
            if (m instanceof IModuleFolder)
                return (IModuleFolder) m;
            return null;
        } else if (m.getModuleRelativePath().isPrefixOf(path) && m instanceof IModuleFolder) {
            IModuleFolder mf2 = getModuleFolder((IModuleFolder) m, path);
            if (mf2 != null)
                return mf2;
        }
    }
    return null;
}
Also used : ProjectModule(org.eclipse.wst.server.core.util.ProjectModule)

Aggregations

ProjectModule (org.eclipse.wst.server.core.util.ProjectModule)10 CoreException (org.eclipse.core.runtime.CoreException)5 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)3 IModule (org.eclipse.wst.server.core.IModule)3 IModuleResource (org.eclipse.wst.server.core.model.IModuleResource)3 IPath (org.eclipse.core.runtime.IPath)2 IJ2EEModule (org.eclipse.jst.server.core.IJ2EEModule)2 IOException (java.io.IOException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IEnterpriseApplication (org.eclipse.jst.server.core.IEnterpriseApplication)1 IWebModule (org.eclipse.jst.server.core.IWebModule)1 IChildModuleReference (org.eclipse.wst.common.componentcore.internal.flat.IChildModuleReference)1 IFlatVirtualComponent (org.eclipse.wst.common.componentcore.internal.flat.IFlatVirtualComponent)1