Search in sources :

Example 1 with CustomPortletMode

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

the class PortletModeImageService method compute.

@Override
protected ImageData compute() {
    String portletMode = null;
    Element element = context(Element.class);
    ImageData imageData = null;
    if (element instanceof CustomPortletMode) {
        CustomPortletMode iCustomPortletMode = (CustomPortletMode) element;
        portletMode = String.valueOf(iCustomPortletMode.getPortletMode().content());
    } else if (element instanceof PortletMode) {
        PortletMode iPortletMode = (PortletMode) element;
        portletMode = iPortletMode.getPortletMode().content();
    }
    if (portletMode != null) {
        if ("VIEW".equalsIgnoreCase(portletMode)) {
            imageData = IMG_VIEW;
        } else if ("EDIT".equalsIgnoreCase(portletMode)) {
            imageData = IMG_EDIT;
        } else if ("HELP".equalsIgnoreCase(portletMode)) {
            imageData = IMG_HELP;
        }
    }
    if (imageData == null) {
        imageData = IMG_DEFAULT;
    }
    return imageData;
}
Also used : ImageData(org.eclipse.sapphire.ImageData) Element(org.eclipse.sapphire.Element) CustomPortletMode(com.liferay.ide.portlet.core.model.CustomPortletMode) CustomPortletMode(com.liferay.ide.portlet.core.model.CustomPortletMode) PortletMode(com.liferay.ide.portlet.core.model.PortletMode)

Example 2 with CustomPortletMode

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

the class PortletModePossibleValueService method compute.

// provided by Portlet Specification and Liferay
/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
 *      util.SortedSet)
 */
@Override
protected void compute(Set<String> values) {
    PortletApp portletApp = context(PortletApp.class);
    for (int i = 0; i < DEFAULT_MODES.length; i++) {
        values.add(DEFAULT_MODES[i]);
    }
    // Add the ones defined in portlet.xml
    List<CustomPortletMode> customPortletModes = portletApp.getCustomPortletModes();
    for (CustomPortletMode iCustomPortletMode : customPortletModes) {
        String customPortletMode = iCustomPortletMode.getPortletMode().text(false);
        if (customPortletMode != null) {
            values.add(customPortletMode);
        }
    }
}
Also used : CustomPortletMode(com.liferay.ide.portlet.core.model.CustomPortletMode) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Aggregations

CustomPortletMode (com.liferay.ide.portlet.core.model.CustomPortletMode)2 PortletApp (com.liferay.ide.portlet.core.model.PortletApp)1 PortletMode (com.liferay.ide.portlet.core.model.PortletMode)1 Element (org.eclipse.sapphire.Element)1 ImageData (org.eclipse.sapphire.ImageData)1