Search in sources :

Example 6 with ILiferayPortal

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

the class CustomJspsBindingImpl method init.

@Override
public void init(Property property) {
    super.init(property);
    ILiferayProject liferayProject = LiferayCore.create(project());
    if (liferayProject != null) {
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            _portalDir = portal.getAppServerPortalDir();
        }
    }
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 7 with ILiferayPortal

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

the class NewPortletClassDataModelProvider method getCategories.

protected Properties getCategories() {
    if (categories == null) {
        ILiferayProject liferayProject = LiferayCore.create(getProject());
        if (liferayProject == null) {
            try {
                liferayProject = LiferayCore.create(getRuntime());
            } catch (CoreException ce) {
                PortletCore.logError(ce);
            }
        }
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            categories = portal.getPortletCategories();
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IProject[] workspaceProjects = workspace.getRoot().getProjects();
            for (IProject workspaceProject : workspaceProjects) {
                if (ProjectUtil.isPortletProject(workspaceProject)) {
                    LiferayDisplayDescriptorHelper liferayDisplayDH = new LiferayDisplayDescriptorHelper(workspaceProject);
                    String[] portletCategories = liferayDisplayDH.getAllPortletCategories();
                    if (ListUtil.isNotEmpty(portletCategories)) {
                        for (String portletCategory : portletCategories) {
                            if (_findExistingCategory(portletCategory) == null) {
                                categories.put(portletCategory, portletCategory);
                            }
                        }
                    }
                }
            }
        }
    }
    return categories;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) IWorkspace(org.eclipse.core.resources.IWorkspace) LiferayDisplayDescriptorHelper(com.liferay.ide.portlet.core.dd.LiferayDisplayDescriptorHelper) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 8 with ILiferayPortal

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

the class NewPortletClassDataModelProvider method getPropertyDescriptor.

@Override
public DataModelPropertyDescriptor getPropertyDescriptor(String propertyName) {
    if (VIEW_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "view");
    } else if (EDIT_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "edit");
    } else if (HELP_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "help");
    } else if (ABOUT_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "about");
    } else if (CONFIG_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "config");
    } else if (EDITDEFAULTS_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "edit_defaults");
    } else if (EDITGUEST_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "edit_guest");
    } else if (PREVIEW_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "preview");
    } else if (PRINT_MODE.equals(propertyName)) {
        return new DataModelPropertyDescriptor(getProperty(propertyName), "print");
    } else if (CATEGORY.equals(propertyName)) {
        if (getProperty(CATEGORY).equals("category.sample")) {
            return new DataModelPropertyDescriptor("category.sample", "Sample");
        }
    } else if (ENTRY_CATEGORY.equals(propertyName)) {
        // following if block is for modifying portlet class name will resynch the model
        // and lose the user choice
        // check for null is for switching projects of different portal versions
        Object entryCategory = getProperty(ENTRY_CATEGORY);
        if ((entryCategory != null) && (getEntryCategories() != null) && (getEntryCategories().get(entryCategory) != null)) {
            Properties entryCategories = getEntryCategories();
            DataModelPropertyDescriptor descriptor = new DataModelPropertyDescriptor(entryCategory, entryCategories.get(entryCategory).toString());
            return descriptor;
        }
        ILiferayProject liferayProject = LiferayCore.create(getProject());
        if (liferayProject == null) {
            try {
                liferayProject = LiferayCore.create(getRuntime());
            } catch (CoreException ce) {
                PortletCore.logError(ce);
            }
        }
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            Version portalVersion = Version.parseVersion(portal.getVersion());
            if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V620) < 0) {
                return new DataModelPropertyDescriptor("category.my", "My Account Section");
            }
        }
        return new DataModelPropertyDescriptor("category.my", "My Account Administration");
    }
    return super.getPropertyDescriptor(propertyName);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) IPluginWizardFragmentProperties(com.liferay.ide.project.core.IPluginWizardFragmentProperties) Properties(java.util.Properties) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) DataModelPropertyDescriptor(org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor)

Example 9 with ILiferayPortal

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

the class NewPortletClassDataModelProvider method getInitParams.

protected Object getInitParams() {
    List<ParamValue> initParams = new ArrayList<>();
    if (/* getStringProperty(SUPERCLASS).equals(QUALIFIED_MVC_PORTLET) && */
    getBooleanProperty(CREATE_JSPS)) {
        String[] modes = ALL_PORTLET_MODES;
        ParamValue[] paramVals = null;
        try {
            ILiferayProject liferayProject = LiferayCore.create(getProject());
            ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
            String version = portal.getVersion();
            Version portalVersion = Version.parseVersion(version);
            if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V610) >= 0) {
                paramVals = createDefaultParamValuesForModes(modes, initNames61, initValues);
            }
        } catch (Exception e) {
        }
        if (paramVals == null) {
            paramVals = createDefaultParamValuesForModes(modes, initNames60, initValues);
        }
        Collections.addAll(initParams, paramVals);
    }
    return initParams;
}
Also used : Version(org.osgi.framework.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) ArrayList(java.util.ArrayList) ParamValue(org.eclipse.jst.j2ee.common.ParamValue) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException)

Example 10 with ILiferayPortal

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

the class PluginPackageEditor method getPortalDir.

public IPath getPortalDir() {
    try {
        IFile file = getEditorInput().getFile();
        ILiferayProject liferayProject = LiferayCore.create(file.getProject());
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        return portal.getAppServerPortalDir();
    } catch (Exception e) {
        return null;
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

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