Search in sources :

Example 1 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class WindowStatesPossibleValueService method refreshValues.

private void refreshValues() {
    PortletApp portletApp = context(PortletApp.class);
    if ((portletApp != null) && !portletApp.disposed()) {
        Set<String> newValues = new TreeSet<>();
        for (int i = 0; i < DEFAULT_STATES.length; i++) {
            newValues.add(DEFAULT_STATES[i]);
        }
        List<CustomWindowState> customWindowStates = portletApp.getCustomWindowStates();
        for (CustomWindowState iCustomWindowState : customWindowStates) {
            String customWindowState = iCustomWindowState.getWindowState().text(false);
            if (customWindowState != null) {
                newValues.add(customWindowState);
            }
        }
        if (!this.values.equals(newValues)) {
            this.values = Collections.unmodifiableSet(newValues);
        }
        if (this.initialized || this.readPriorToInit) {
            refresh();
        }
    }
}
Also used : CustomWindowState(com.liferay.ide.portlet.core.model.CustomWindowState) TreeSet(java.util.TreeSet) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 2 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class PublicRenderParameterValuesService method compute.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
 *      util.SortedSet)
 */
@Override
protected void compute(Set<String> values) {
    PortletApp portletApp = context(PortletApp.class);
    ElementList<PublicRenderParameter> publicRenderParameters = portletApp.getPublicRenderParameters();
    for (PublicRenderParameter renderParameter : publicRenderParameters) {
        String indentifer = renderParameter.getIdentifier().content();
        values.add(indentifer);
    }
}
Also used : PublicRenderParameter(com.liferay.ide.portlet.core.model.PublicRenderParameter) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 3 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class CreatePortletActionHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    PortletApp rootModel = (PortletApp) context.part().getModelElement();
    Portlet portlet = rootModel.getPortlets().insert();
    // Open the dialog to capture the mandatory properties
    SapphireDialog dialog = new SapphireDialog(((SwtPresentation) context).shell(), portlet, DefinitionLoader.sdef(PortletXmlEditor.class).dialog());
    if ((dialog != null) && (Dialog.OK == dialog.open())) {
        // Select the node
        MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class);
        MasterDetailsContentNodePart root = page.outline().getRoot();
        MasterDetailsContentNodePart node = root.findNode(portlet);
        if (node != null) {
            node.select();
        }
        try {
            rootModel.resource().save();
        } catch (ResourceStoreException rse) {
        // Log it in PorletUI Plugin
        }
        return portlet;
    } else {
        rootModel.getPortlets().remove(portlet);
        portlet = null;
        try {
            rootModel.resource().save();
        } catch (ResourceStoreException rse) {
        // Log it in PorletUI Plugin
        }
        return null;
    }
}
Also used : ResourceStoreException(org.eclipse.sapphire.modeling.ResourceStoreException) Portlet(com.liferay.ide.portlet.core.model.Portlet) MasterDetailsContentNodePart(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart) MasterDetailsEditorPagePart(org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart) SapphireDialog(org.eclipse.sapphire.ui.forms.swt.SapphireDialog) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 4 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class DefinePortletEventHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    PortletApp rootModel = (PortletApp) context.part().getModelElement();
    EventDefinition eventDefintion = rootModel.getEventDefinitions().insert();
    // Select the node
    MasterDetailsEditorPagePart page = getPart().nearest(MasterDetailsEditorPagePart.class);
    MasterDetailsContentNodePart root = page.outline().getRoot();
    MasterDetailsContentNodePart node = root.findNode(eventDefintion);
    if (node != null) {
        node.select();
    }
    return eventDefintion;
}
Also used : MasterDetailsContentNodePart(org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart) MasterDetailsEditorPagePart(org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart) EventDefinition(com.liferay.ide.portlet.core.model.EventDefinition) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Example 5 with PortletApp

use of com.liferay.ide.portlet.core.model.PortletApp in project liferay-ide by liferay.

the class PortletXmlTests method portletXmlRead.

@Test
public void portletXmlRead() throws Exception {
    final PortletApp portletApp = portletApp(PORTLET_XML);
    assertNotNull(portletApp);
    final ElementList<Portlet> portlets = portletApp.getPortlets();
    assertNotNull(portlets);
    assertEquals(1, portlets.size());
    final Portlet portlet = portlets.get(0);
    assertNotNull(portlet);
    assertEquals("1", portlet.getPortletName().content());
    assertEquals("Sample JSP", portlet.getDisplayName().content());
    assertEquals("com.liferay.samplejsp.portlet.JSPPortlet", portlet.getPortletClass().text());
    final Param param = portlet.getInitParams().get(0);
    assertNotNull(param);
    assertEquals("view-jsp", param.getName().content());
    assertEquals("/view.jsp", param.getValue().content());
    assertEquals(new Integer(0), portlet.getExpirationCache().content());
    final Supports supports = portlet.getSupports();
    assertNotNull(supports);
    assertEquals("text/html", supports.getMimeType().content());
    final PortletInfo info = portlet.getPortletInfo();
    assertEquals("Sample JSP", info.getTitle().content());
    assertEquals("Sample JSP", info.getShortTitle().content());
    assertEquals("Sample JSP", info.getKeywords().content());
    final ElementList<SecurityRoleRef> roles = portlet.getSecurityRoleRefs();
    assertEquals(4, roles.size());
    final SecurityRoleRef role = roles.get(1);
    assertNotNull(role);
    assertEquals("guest", role.getRoleName().content());
}
Also used : Portlet(com.liferay.ide.portlet.core.model.Portlet) Supports(com.liferay.ide.portlet.core.model.Supports) Param(com.liferay.ide.portlet.core.model.Param) PortletInfo(com.liferay.ide.portlet.core.model.PortletInfo) SecurityRoleRef(com.liferay.ide.portlet.core.model.SecurityRoleRef) PortletApp(com.liferay.ide.portlet.core.model.PortletApp) Test(org.junit.Test)

Aggregations

PortletApp (com.liferay.ide.portlet.core.model.PortletApp)9 EventDefinition (com.liferay.ide.portlet.core.model.EventDefinition)2 Portlet (com.liferay.ide.portlet.core.model.Portlet)2 PublicRenderParameter (com.liferay.ide.portlet.core.model.PublicRenderParameter)2 Element (org.eclipse.sapphire.Element)2 MasterDetailsContentNodePart (org.eclipse.sapphire.ui.forms.MasterDetailsContentNodePart)2 MasterDetailsEditorPagePart (org.eclipse.sapphire.ui.forms.MasterDetailsEditorPagePart)2 CustomPortletMode (com.liferay.ide.portlet.core.model.CustomPortletMode)1 CustomWindowState (com.liferay.ide.portlet.core.model.CustomWindowState)1 EventDefinitionRef (com.liferay.ide.portlet.core.model.EventDefinitionRef)1 Param (com.liferay.ide.portlet.core.model.Param)1 PortletInfo (com.liferay.ide.portlet.core.model.PortletInfo)1 SecurityRoleRef (com.liferay.ide.portlet.core.model.SecurityRoleRef)1 SupportedPublicRenderParameter (com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter)1 Supports (com.liferay.ide.portlet.core.model.Supports)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1