Search in sources :

Example 41 with IWebProject

use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.

the class AbstractRemoteServerPublisher method processResourceDeltas.

protected void processResourceDeltas(IModuleResourceDelta[] deltas, ZipOutputStream zip, Map<ZipEntry, String> deleteEntries, String deletePrefix, String deltaPrefix, boolean adjustGMTOffset) throws IOException, CoreException {
    for (IModuleResourceDelta delta : deltas) {
        final int deltaKind = delta.getKind();
        final IResource deltaResource = (IResource) delta.getModuleResource().getAdapter(IResource.class);
        final IProject deltaProject = deltaResource.getProject();
        // IDE-110 IDE-648
        final IWebProject lrproject = LiferayCore.create(IWebProject.class, deltaProject);
        if (lrproject != null) {
            final IFolder webappRoot = lrproject.getDefaultDocrootFolder();
            IPath deltaPath = null;
            if (webappRoot != null && webappRoot.exists()) {
                final IPath deltaFullPath = deltaResource.getFullPath();
                final IPath containerFullPath = webappRoot.getFullPath();
                deltaPath = new Path(deltaPrefix + deltaFullPath.makeRelativeTo(containerFullPath));
                if (deltaPath != null && deltaPath.segmentCount() > 0) {
                    break;
                }
            }
            if (deltaKind == IModuleResourceDelta.ADDED || deltaKind == IModuleResourceDelta.CHANGED) {
                addToZip(deltaPath, deltaResource, zip, adjustGMTOffset);
            } else if (deltaKind == IModuleResourceDelta.REMOVED) {
                addRemoveProps(deltaPath, deltaResource, zip, deleteEntries, deletePrefix);
            } else if (deltaKind == IModuleResourceDelta.NO_CHANGE) {
                IModuleResourceDelta[] children = delta.getAffectedChildren();
                processResourceDeltas(children, zip, deleteEntries, deletePrefix, deltaPrefix, adjustGMTOffset);
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) IModuleResourceDelta(org.eclipse.wst.server.core.model.IModuleResourceDelta) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 42 with IWebProject

use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.

the class AddServiceBuilderOperation method _createServiceBuilderFile.

private IStatus _createServiceBuilderFile(IProject project, IProgressMonitor monitor) {
    // IDE-110 IDE-648
    IWebProject webproject = LiferayCore.create(IWebProject.class, project);
    if ((webproject == null) || (webproject.getDefaultDocrootFolder() == null)) {
        return ServiceCore.createErrorStatus("Could not find webapp root folder.");
    }
    IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
    Path path = new Path("WEB-INF/" + getDataModel().getStringProperty(SERVICE_FILE));
    IFile serviceBuilderFile = defaultDocroot.getFile(path);
    if (FileUtil.notExists(serviceBuilderFile)) {
        try {
            createDefaultServiceBuilderFile(serviceBuilderFile, monitor);
        } catch (Exception ex) {
            return ServiceCore.createErrorStatus(ex);
        }
    }
    return Status.OK_STATUS;
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) IFolder(org.eclipse.core.resources.IFolder)

Example 43 with IWebProject

use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.

the class ThemeDiffResourceListener method shouldProcessResourceDelta.

protected boolean shouldProcessResourceDelta(IResourceDelta delta) {
    IPath fullPath = delta.getFullPath();
    // IDE-110 IDE-648
    IWebProject webproject = LiferayCore.create(IWebProject.class, delta.getResource().getProject());
    if ((webproject == null) || (webproject.getDefaultDocrootFolder() == null)) {
        return false;
    }
    IFolder webappRoot = webproject.getDefaultDocrootFolder();
    IPath diffPath = webappRoot.getFolder(new Path("_diffs")).getFullPath();
    return diffPath.isPrefixOf(fullPath);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) IFolder(org.eclipse.core.resources.IFolder)

Example 44 with IWebProject

use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.

the class NewServiceBuilderDataModelProvider method getServiceFile.

protected IFile getServiceFile() {
    String serviceFileProperty = getStringProperty(SERVICE_FILE);
    IWebProject webproject = LiferayCore.create(IWebProject.class, getTargetProject());
    if (CoreUtil.isNullOrEmpty(serviceFileProperty) || (webproject == null)) {
        return null;
    }
    // IDE-110 IDE-648
    IResource serviceXmlResource = webproject.findDocrootResource(new Path("WEB-INF/" + serviceFileProperty));
    if (FileUtil.exists(serviceXmlResource) && (serviceXmlResource instanceof IFile)) {
        return (IFile) serviceXmlResource;
    }
    return null;
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) IResource(org.eclipse.core.resources.IResource)

Example 45 with IWebProject

use of com.liferay.ide.core.IWebProject in project liferay-ide by liferay.

the class HasServiceFilePropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if (receiver instanceof IResource) {
        IResource resource = (IResource) receiver;
        IWebProject webproject = LiferayCore.create(IWebProject.class, resource.getProject());
        if (webproject != null) {
            try {
                // IDE-110 IDE-648
                IResource serviceResource = webproject.findDocrootResource(new Path("WEB-INF/" + ILiferayConstants.SERVICE_XML_FILE));
                if (FileUtil.exists(serviceResource)) {
                    return true;
                }
            } catch (Throwable t) {
            }
        }
    }
    return false;
}
Also used : Path(org.eclipse.core.runtime.Path) IWebProject(com.liferay.ide.core.IWebProject) IResource(org.eclipse.core.resources.IResource)

Aggregations

IWebProject (com.liferay.ide.core.IWebProject)46 IFolder (org.eclipse.core.resources.IFolder)31 IFile (org.eclipse.core.resources.IFile)27 IProject (org.eclipse.core.resources.IProject)25 IPath (org.eclipse.core.runtime.IPath)24 Path (org.eclipse.core.runtime.Path)20 CoreException (org.eclipse.core.runtime.CoreException)15 IResource (org.eclipse.core.resources.IResource)10 IStatus (org.eclipse.core.runtime.IStatus)6 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)5 IOException (java.io.IOException)5 Test (org.junit.Test)5 SDK (com.liferay.ide.sdk.core.SDK)4 Path (org.eclipse.sapphire.modeling.Path)4 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)3 InputStream (java.io.InputStream)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 HookDescriptorHelper (com.liferay.ide.hook.core.dd.HookDescriptorHelper)2 Hook (com.liferay.ide.hook.core.model.Hook)2 File (java.io.File)2