com.liferay.blade.samples.application.list.BladeSimulationPanelApp.java Source code

Java tutorial

Introduction

Here is the source code for com.liferay.blade.samples.application.list.BladeSimulationPanelApp.java

Source

/**
 * Copyright 2000-present Liferay, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.liferay.blade.samples.application.list;

import com.liferay.application.list.BaseJSPPanelApp;
import com.liferay.application.list.PanelApp;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.Portlet;
import com.liferay.portal.kernel.security.permission.PermissionChecker;
import com.liferay.portal.kernel.util.ResourceBundleUtil;
import com.liferay.product.navigation.simulation.application.list.SimulationPanelCategory;
import com.liferay.product.navigation.simulation.web.constants.ProductNavigationSimulationPortletKeys;

import java.util.Locale;
import java.util.ResourceBundle;

import javax.servlet.ServletContext;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
 * @author Liferay
 */
@Component(immediate = true, property = { "panel.app.order:Integer=500",
        "panel.category.key=" + SimulationPanelCategory.SIMULATION }, service = PanelApp.class)
public class BladeSimulationPanelApp extends BaseJSPPanelApp {

    @Override
    public String getJspPath() {
        return "/simulation_panel.jsp";
    }

    @Override
    public String getLabel(Locale locale) {
        ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", locale, getClass());

        return LanguageUtil.get(resourceBundle, "simulation-sample");
    }

    @Override
    public String getPortletId() {
        return ProductNavigationSimulationPortletKeys.PRODUCT_NAVIGATION_SIMULATION;
    }

    @Override
    public boolean isShow(PermissionChecker permissionChecker, Group group) throws PortalException {

        if (group.isControlPanel()) {
            return false;
        }

        return true;
    }

    @Override
    @Reference(target = "(javax.portlet.name="
            + ProductNavigationSimulationPortletKeys.PRODUCT_NAVIGATION_SIMULATION + ")", unbind = "-")
    public void setPortlet(Portlet portlet) {
        super.setPortlet(portlet);
    }

    @Override
    @Reference(target = "(osgi.web.symbolicname=blade.simulation.panel.app)", unbind = "-")
    public void setServletContext(ServletContext servletContext) {
        super.setServletContext(servletContext);
    }

}