Search in sources :

Example 11 with ILiferayRuntime

use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.

the class PropertiesContentProvider method getPipelinedChildren.

@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getPipelinedChildren(Object parent, Set currentChildren) {
    if (shouldAddChildren(parent)) {
        final IServer server = (IServer) parent;
        PropertiesFile[] propertiesFiles = this.propertiesFilesMap.get(server.getId());
        if (ListUtil.isEmpty(propertiesFiles)) {
            final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(server);
            if (runtime != null) {
                File[] files = getExtPropertiesFiles(runtime);
                final List<PropertiesFile> newFiles = new ArrayList<PropertiesFile>();
                for (File file : files) {
                    newFiles.add(new PropertiesFile(file));
                }
                propertiesFiles = newFiles.toArray(new PropertiesFile[0]);
                this.propertiesFilesMap.put(server.getId(), propertiesFiles);
            }
        }
        if (ListUtil.isNotEmpty(propertiesFiles)) {
            for (PropertiesFile propertiesFile : propertiesFiles) {
                currentChildren.add(propertiesFile);
            }
        }
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) ArrayList(java.util.ArrayList) File(java.io.File)

Example 12 with ILiferayRuntime

use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.

the class PropertiesContentProvider method hasChildren.

@Override
public boolean hasChildren(Object element) {
    boolean retVal = false;
    if (element instanceof IServer) {
        final IServer server = (IServer) element;
        ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(server);
        if (liferayRuntime != null) {
            File[] files = getExtPropertiesFiles(liferayRuntime);
            return ListUtil.isNotEmpty(files);
        }
    }
    return retVal;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) File(java.io.File)

Example 13 with ILiferayRuntime

use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.

the class PluginClasspathContainerInitializer method requestClasspathContainerUpdate.

@Override
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
    String key = PluginClasspathContainer.getDecorationManagerKey(project.getProject(), containerPath.toString());
    IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();
    cpDecorations.clearAllDecorations(key);
    for (int i = 0; i < entries.length; i++) {
        IClasspathEntry entry = entries[i];
        IPath srcpath = entry.getSourceAttachmentPath();
        IPath srcrootpath = entry.getSourceAttachmentRootPath();
        IClasspathAttribute[] attrs = entry.getExtraAttributes();
        if ((srcpath != null) || ListUtil.isNotEmpty(attrs)) {
            String eid = entry.getPath().toString();
            ClasspathDecorations dec = new ClasspathDecorations();
            dec.setSourceAttachmentPath(srcpath);
            dec.setSourceAttachmentRootPath(srcrootpath);
            dec.setExtraAttributes(attrs);
            cpDecorations.setDecorations(key, eid, dec);
        }
    }
    cpDecorations.save();
    IPath portalDir = null;
    String javadocURL = null;
    IPath sourceLocation = null;
    if (containerSuggestion instanceof PluginClasspathContainer) {
        portalDir = ((PluginClasspathContainer) containerSuggestion).getPortalDir();
        javadocURL = ((PluginClasspathContainer) containerSuggestion).getJavadocURL();
        sourceLocation = ((PluginClasspathContainer) containerSuggestion).getSourceLocation();
    } else {
        portalDir = ServerUtil.getPortalDir(project);
        try {
            ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project.getProject());
            if (liferayRuntime != null) {
                javadocURL = liferayRuntime.getJavadocURL();
                sourceLocation = liferayRuntime.getSourceLocation();
            }
        } catch (Exception e) {
            ProjectCore.logError(e);
        }
    }
    if (portalDir != null) {
        IClasspathContainer newContainer = getCorrectContainer(containerPath, containerPath.segment(1), project, portalDir, javadocURL, sourceLocation);
        IJavaProject[] projects = { project };
        IClasspathContainer[] containers = { newContainer };
        JavaCore.setClasspathContainer(containerPath, projects, containers, null);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) CoreException(org.eclipse.core.runtime.CoreException) IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IJavaProject(org.eclipse.jdt.core.IJavaProject) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) ClasspathDecorations(org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 14 with ILiferayRuntime

use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.

the class PluginsSDKProjectProvider method provide.

@Override
public ILiferayProject provide(Object type) {
    if (type instanceof IProject) {
        IProject project = (IProject) type;
        if (!SDKUtil.isSDKProject(project)) {
            return null;
        }
        try {
            IJavaProject javaProject = JavaCore.create(project);
            boolean hasNewSdk = ClasspathUtil.hasNewLiferaySDKContainer(javaProject.getRawClasspath());
            if (hasNewSdk) {
                PortalBundle portalBundle = ServerUtil.getPortalBundle(project);
                if (portalBundle != null) {
                    return new PluginsSDKBundleProject(project, portalBundle);
                }
            } else {
                ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project);
                if (liferayRuntime != null) {
                    return new PluginsSDKRuntimeProject(project, liferayRuntime);
                }
            }
        } catch (CoreException ce) {
        }
    } else if (type instanceof IRuntime) {
        try {
            IRuntime runtime = (IRuntime) type;
            ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(runtime);
            if (liferayRuntime != null) {
                return new PluginsSDKRuntimeProject(null, liferayRuntime);
            }
        } catch (Exception e) {
        }
    }
    return null;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) PortalBundle(com.liferay.ide.server.core.portal.PortalBundle) CoreException(org.eclipse.core.runtime.CoreException) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 15 with ILiferayRuntime

use of com.liferay.ide.server.core.ILiferayRuntime in project liferay-ide by liferay.

the class CustomJspConverter method _convertToCoreJspHook.

private void _convertToCoreJspHook(String sourcePath, String customJspPath, String targetPath, boolean liferayWorkspace) throws Exception {
    File commonDir = _getMovedDir(sourcePath, customJspPath, "common");
    File portalDir = _getMovedDir(sourcePath, customJspPath, "portal");
    File taglibDir = _getMovedDir(sourcePath, customJspPath, "taglib");
    if ((commonDir != null) || (portalDir != null) || (taglibDir != null)) {
        File[] dirs = new File[3];
        dirs[0] = commonDir;
        dirs[1] = portalDir;
        dirs[2] = taglibDir;
        File location = new File(targetPath);
        Bundle bundle = ProjectUI.getDefault().getBundle();
        final URL projectZipUrl = bundle.getEntry("resources/codeupgrade.corejsphook.zip");
        final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
        ZipUtil.unzip(projectZipFile, location);
        // File jspDir = new File( location, coreJspHookResourcesPath + "html" );
        File ignoreFolder = new File(location, _coreJspHookResourcesPath + ".ignore/");
        File destFolder = new File(location, _coreJspHookResourcesPath);
        ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getLiferay70Runtime());
        for (File dir : dirs) {
            if (dir != null) {
                // File dest = new File( jspDir, dir.getName() );
                // dest.mkdirs();
                // IOUtil.copyDirToDir( dir, dest );
                // copy 70 original jsp file to converted project ignore folder
                List<String> fileRelativizePaths = _getAllRelativizeFilePaths(dir);
                for (String fileRelativizePath : fileRelativizePaths) {
                    File original62File = new File(_get62HtmlDir() + dir.getName() + "/" + fileRelativizePath);
                    IPath appServerPortalDir = liferayRuntime.getAppServerPortalDir().removeLastSegments(1);
                    File original70File = appServerPortalDir.append("ROOT/html/" + dir.getName() + "/" + fileRelativizePath).toFile();
                    if (original62File.exists() && original70File.exists()) {
                        File target62File = new File(ignoreFolder, "html/" + dir.getName() + "/" + fileRelativizePath + ".62");
                        File target70File = new File(destFolder, "html/" + dir.getName() + "/" + fileRelativizePath);
                        _makeParentDir(target62File);
                        _makeParentDir(target70File);
                        FileUtil.copyFile(original62File, target62File);
                        FileUtil.copyFile(original70File, target70File);
                    }
                }
            }
        }
        String sourceProjectName = (new File(sourcePath)).getName();
        File projectFolder = new File(location, "codeupgrade.corejsphook");
        File gradleWsFile = new File(projectFolder, "build-ws.gradle");
        File gradleFile = new File(projectFolder, "build.gradle");
        if (liferayWorkspace) {
            gradleFile.delete();
            gradleWsFile.renameTo(gradleFile);
        } else {
            gradleWsFile.delete();
        }
        File newFolder = new File(location, sourceProjectName + ".corejsphook");
        projectFolder.renameTo(newFolder);
        _resultProp.setProperty(resultPrefix + "." + sourceProjectName + "/portalCore", newFolder.getAbsolutePath().replace("\\\\", "/"));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Bundle(org.osgi.framework.Bundle) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL)

Aggregations

ILiferayRuntime (com.liferay.ide.server.core.ILiferayRuntime)18 CoreException (org.eclipse.core.runtime.CoreException)10 File (java.io.File)9 IPath (org.eclipse.core.runtime.IPath)7 Version (org.osgi.framework.Version)6 IRuntime (org.eclipse.wst.server.core.IRuntime)5 URL (java.net.URL)4 ArrayList (java.util.ArrayList)3 JarFile (java.util.jar.JarFile)3 IStatus (org.eclipse.core.runtime.IStatus)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IServer (org.eclipse.wst.server.core.IServer)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 Path (org.eclipse.core.runtime.Path)2 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)2 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1