Search in sources :

Example 6 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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

ILiferayProject (com.liferay.ide.core.ILiferayProject)45 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)29 IProject (org.eclipse.core.resources.IProject)21 IPath (org.eclipse.core.runtime.IPath)18 IFile (org.eclipse.core.resources.IFile)17 CoreException (org.eclipse.core.runtime.CoreException)15 ArrayList (java.util.ArrayList)9 IFolder (org.eclipse.core.resources.IFolder)8 Version (org.osgi.framework.Version)8 IOException (java.io.IOException)7 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 Path (org.eclipse.core.runtime.Path)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3