Search in sources :

Example 16 with ILiferayPortal

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

the class AddServiceBuilderOperation method createDefaultServiceBuilderFile.

public void createDefaultServiceBuilderFile(IFile serviceBuilderFile, IProgressMonitor monitor) throws CoreException {
    String descriptorVersion = null;
    try {
        ILiferayProject liferayProject = LiferayCore.create(serviceBuilderFile.getProject());
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        Version portalVersion = new Version(portal.getVersion());
        descriptorVersion = portalVersion.getMajor() + "." + portalVersion.getMinor() + ".0";
    } catch (Exception e) {
        ProjectCore.logError("Could not determine liferay runtime version", e);
        descriptorVersion = "6.0.0";
    }
    WizardUtil.createDefaultServiceBuilderFile(serviceBuilderFile, descriptorVersion, getDataModel().getBooleanProperty(USE_SAMPLE_TEMPLATE), getDataModel().getStringProperty(PACKAGE_PATH), getDataModel().getStringProperty(NAMESPACE), getDataModel().getStringProperty(AUTHOR), monitor);
    getDataModel().setProperty(CREATED_SERVICE_FILE, serviceBuilderFile);
}
Also used : Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 17 with ILiferayPortal

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

the class PortalResourcesProvider method getResources.

@Override
public File[] getResources(IWebResourcesContext context) {
    File[] retval = null;
    IFile htmlFile = context.getHtmlFile();
    ILiferayProject project = LiferayCore.create(htmlFile.getProject());
    if ((htmlFile != null) && (project != null)) {
        ILiferayPortal portal = project.adapt(ILiferayPortal.class);
        if ((portal != null) && ProjectUtil.isPortletProject(htmlFile.getProject())) {
            IPath portalDir = portal.getAppServerPortalDir();
            if (portalDir != null) {
                IPath cssPath = portalDir.append("html/themes/_unstyled/css");
                if (FileUtil.exists(cssPath)) {
                    synchronized (_fileCache) {
                        Collection<File> cachedFiles = _fileCache.get(cssPath);
                        if (cachedFiles != null) {
                            retval = cachedFiles.toArray(new File[0]);
                        } else {
                            String types = new String[] { "css", "scss" };
                            Collection<File> files = FileUtils.listFiles(cssPath.toFile(), types, true);
                            Collection<File> cached = new HashSet<>();
                            for (File file : files) {
                                if (file.getName().endsWith("scss")) {
                                    File cachedFile = new File(file.getParent(), ".sass-cache/" + file.getName().replaceAll("scss$", "css"));
                                    if (FileUtil.exists(cachedFile)) {
                                        cached.add(file);
                                    }
                                }
                            }
                            files.removeAll(cached);
                            if (files != null) {
                                retval = files.toArray(new File[0]);
                            }
                            _fileCache.put(cssPath, files);
                        }
                    }
                }
            }
        } else if ((portal != null) && ProjectUtil.isLayoutTplProject(htmlFile.getProject())) {
            // return the static css resource for layout template names based on the version
            String version = portal.getVersion();
            try {
                if ((version != null) && (version.startsWith("6.0") || version.startsWith("6.1"))) {
                    retval = _createLayoutHelperFiles("resources/layouttpl-6.1.css");
                } else if (version != null) {
                    retval = _createLayoutHelperFiles("resources/layouttpl-6.2.css");
                }
            } catch (IOException ioe) {
                AlloyCore.logError("Unable to load layout template helper css files", ioe);
            }
        }
    }
    return retval;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) IOException(java.io.IOException) File(java.io.File) IFile(org.eclipse.core.resources.IFile) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) HashSet(java.util.HashSet)

Example 18 with ILiferayPortal

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

the class AddLayoutTplOperation method _isBootstrapStyle.

private boolean _isBootstrapStyle() {
    ILiferayProject lrproject = LiferayCore.create(getTargetProject());
    ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
    if (portal != null) {
        Version version = new Version(portal.getVersion());
        if (CoreUtil.compareVersions(version, ILiferayConstants.V620) >= 0) {
            return true;
        }
        return false;
    }
    return true;
}
Also used : Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 19 with ILiferayPortal

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

the class LayoutTplEditor method _isBootstrapStyle.

private boolean _isBootstrapStyle() {
    boolean retval = true;
    try {
        ILiferayProject lrproject = LiferayCore.create(getFile().getProject());
        ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
        Version version = new Version(portal.getVersion());
        if (CoreUtil.compareVersions(version, ILiferayConstants.V620) < 0) {
            retval = false;
        }
    } catch (Exception e) {
    }
    return retval;
}
Also used : Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) PartInitException(org.eclipse.ui.PartInitException)

Example 20 with ILiferayPortal

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

the class PortalFilterNamesPossibleValuesService method compute.

@Override
protected void compute(Set<String> values) {
    if (_servletFilterNames == null) {
        Element element = context().find(Element.class);
        IFile hookFile = element.adapt(IFile.class);
        if (hookFile != null) {
            try {
                ILiferayProject liferayProject = LiferayCore.create(hookFile.getProject());
                if (liferayProject != null) {
                    ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
                    if (portal != null) {
                        IPath appServerPortalDir = portal.getAppServerPortalDir();
                        if (appServerPortalDir != null) {
                            _servletFilterNames = ServerUtil.getServletFilterNames(appServerPortalDir);
                        }
                    }
                }
            } catch (Exception e) {
            }
        }
    }
    if (_servletFilterNames != null) {
        Collections.addAll(values, _servletFilterNames);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) Element(org.eclipse.sapphire.Element) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Aggregations

ILiferayPortal (com.liferay.ide.core.ILiferayPortal)32 ILiferayProject (com.liferay.ide.core.ILiferayProject)29 IPath (org.eclipse.core.runtime.IPath)13 IFile (org.eclipse.core.resources.IFile)10 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)8 IOException (java.io.IOException)7 Version (org.osgi.framework.Version)7 ArrayList (java.util.ArrayList)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 File (java.io.File)3 Properties (java.util.Properties)3 JarFile (java.util.jar.JarFile)3 Path (org.eclipse.core.runtime.Path)3 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ZipEntry (java.util.zip.ZipEntry)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2