Example usage for com.liferay.portal.kernel.theme ThemeDisplay getLayoutTypePortlet

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getLayoutTypePortlet

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getLayoutTypePortlet.

Prototype

public LayoutTypePortlet getLayoutTypePortlet() 

Source Link

Usage

From source file:com.liferay.journal.content.search.web.internal.portlet.JournalContentSearchPortlet.java

License:Open Source License

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    String portletId = _portal.getPortletId(renderRequest);

    if (!layoutTypePortlet.hasPortletId(portletId)) {
        renderResponse.setTitle(themeDisplay.translate("search"));
    }/*from w w  w .ja  v  a 2  s  .c  o m*/

    super.doView(renderRequest, renderResponse);
}

From source file:com.liferay.layout.admin.web.internal.control.menu.CustomizationSettingsProductNavigationControlMenuEntry.java

License:Open Source License

protected boolean isCustomizableLayout(ThemeDisplay themeDisplay) throws PortalException {

    Layout layout = themeDisplay.getLayout();

    Group group = layout.getGroup();

    if (group.isLayoutPrototype() || group.isLayoutSetPrototype() || group.isStagingGroup()
            || group.isUserGroup()) {/*from   w ww .j  a va2s . c o m*/

        return false;
    }

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    if (!layout.isTypePortlet() || (layoutTypePortlet == null)) {
        return false;
    }

    if (layout.isCustomizable() && hasUpdateLayoutPermission(themeDisplay)) {

        return true;
    }

    if (!layoutTypePortlet.isCustomizable()) {
        return false;
    }

    if (!LayoutPermissionUtil.containsWithoutViewableGroup(themeDisplay.getPermissionChecker(), layout, false,
            ActionKeys.CUSTOMIZE)) {

        return false;
    }

    return true;
}

From source file:com.liferay.layout.admin.web.internal.control.menu.ToggleControlsProductNavigationControlMenuEntry.java

License:Open Source License

protected boolean hasCustomizePermission(ThemeDisplay themeDisplay) throws PortalException {

    Layout layout = themeDisplay.getLayout();
    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    if (!layout.isTypePortlet() || (layoutTypePortlet == null)) {
        return false;
    }//from  w  ww.  j a va  2s . c om

    if (!layoutTypePortlet.isCustomizable() || !layoutTypePortlet.isCustomizedView()) {

        return false;
    }

    if (LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.CUSTOMIZE)) {

        return true;
    }

    return false;
}

From source file:com.liferay.layout.admin.web.internal.portlet.action.ResetCustomizationViewMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), themeDisplay.getLayout(),
            ActionKeys.CUSTOMIZE)) {//from w ww .  j a v a 2s. com

        throw new PrincipalException();
    }

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable()
            && layoutTypePortlet.isCustomizedView()) {

        layoutTypePortlet.resetUserPreferences();
    }

    MultiSessionMessages.add(actionRequest, _portal.getPortletId(actionRequest) + "requestProcessed");

    Layout layout = themeDisplay.getLayout();

    actionResponse.sendRedirect(layout.getRegularURL(_portal.getHttpServletRequest(actionRequest)));
}

From source file:com.liferay.nested.portlets.web.internal.portlet.action.NestedPortletsConfigurationAction.java

License:Open Source License

protected void reorganizeNestedColumns(ActionRequest actionRequest, String portletResource,
        String newLayoutTemplateId, String oldLayoutTemplateId) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Layout layout = themeDisplay.getLayout();
    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();
    Theme theme = themeDisplay.getTheme();

    LayoutTemplate newLayoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(newLayoutTemplateId, false,
            theme.getThemeId());//from w ww .j ava  2s .co m

    List<String> newColumns = getColumnNames(newLayoutTemplate.getContent(), portletResource);

    LayoutTemplate oldLayoutTemplate = _layoutTemplateLocalService.getLayoutTemplate(oldLayoutTemplateId, false,
            theme.getThemeId());

    List<String> oldColumns = getColumnNames(oldLayoutTemplate.getContent(), portletResource);

    layoutTypePortlet.reorganizePortlets(newColumns, oldColumns);

    layoutTypePortlet.setStateMax(StringPool.BLANK);

    _layoutLocalService.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(),
            layout.getTypeSettings());
}

From source file:com.liferay.portlet.configuration.icon.maximize.internal.MaximizePortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!GetterUtil.getBoolean(themeDisplay.getThemeSetting("show-maximize-minimize-application-links"))) {

        return false;
    }/*from   ww  w .  java  2s . c  om*/

    Layout layout = themeDisplay.getLayout();

    if (!layout.isTypePortlet()) {
        return false;
    }

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    LayoutTypeController layoutTypeController = layoutTypePortlet.getLayoutTypeController();

    if (layoutTypeController.isFullPageDisplayable()) {
        return false;
    }

    Portlet portlet = (Portlet) portletRequest.getAttribute(WebKeys.RENDER_PORTLET);

    if (!portlet.hasWindowState(portletRequest.getResponseContentType(), WindowState.MAXIMIZED)) {

        return false;
    }

    Group group = themeDisplay.getScopeGroup();

    if (!themeDisplay.isSignedIn() || (group.hasStagingGroup() && !group.isStagingGroup())
            || !hasUpdateLayoutPermission(themeDisplay)) {

        if (!PropsValues.LAYOUT_GUEST_SHOW_MAX_ICON) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.portlet.configuration.icon.minimize.internal.MinimizePortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!GetterUtil.getBoolean(themeDisplay.getThemeSetting("show-maximize-minimize-application-links"))) {

        return false;
    }//from ww  w  . j  a va  2 s  .c om

    Layout layout = themeDisplay.getLayout();

    if (!layout.isTypePortlet()) {
        return false;
    }

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    LayoutTypeController layoutTypeController = layoutTypePortlet.getLayoutTypeController();

    if (layoutTypeController.isFullPageDisplayable()) {
        return false;
    }

    Portlet portlet = (Portlet) portletRequest.getAttribute(WebKeys.RENDER_PORTLET);

    if (!portlet.hasWindowState(portletRequest.getResponseContentType(), WindowState.MINIMIZED)) {

        return false;
    }

    Group group = themeDisplay.getScopeGroup();

    if (!themeDisplay.isSignedIn() || (group.hasStagingGroup() && !group.isStagingGroup())
            || !hasUpdateLayoutPermission(themeDisplay)) {

        if (!PropsValues.LAYOUT_GUEST_SHOW_MIN_ICON) {
            return false;
        }
    }

    return true;
}

From source file:com.liferay.product.navigation.control.menu.web.internal.AddContentProductNavigationControlMenuEntry.java

License:Open Source License

@Override
public boolean isShow(HttpServletRequest request) throws PortalException {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (themeDisplay.isStateMaximized()) {
        return false;
    }/*from   ww w .j a  v a  2 s.c  o  m*/

    Layout layout = themeDisplay.getLayout();

    if (!layout.isTypePortlet()) {
        return false;
    }

    if (_staging.isIncomplete(layout)) {
        return false;
    }

    LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

    LayoutTypeController layoutTypeController = layoutTypePortlet.getLayoutTypeController();

    if (layoutTypeController.isFullPageDisplayable()) {
        return false;
    }

    if (!hasAddContentOrApplicationPermission(themeDisplay)) {
        return false;
    }

    if (!(hasUpdateLayoutPermission(themeDisplay) || hasCustomizePermission(themeDisplay))) {

        return false;
    }

    return super.isShow(request);
}