⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portlettitlebar.java

📁 GridSphere 门户 提供一个基于 portlet 的高级开放源代码门户。GridSphere 是在欧盟提供基金的 GridLab 项目下开发的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a> * @version $Id: PortletTitleBar.java 5032 2006-08-17 18:15:06Z novotny $ */package org.gridsphere.layout;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.gridsphere.layout.event.PortletTitleBarEvent;import org.gridsphere.layout.event.PortletTitleBarListener;import org.gridsphere.layout.event.PortletWindowEvent;import org.gridsphere.layout.event.impl.PortletTitleBarEventImpl;import org.gridsphere.layout.event.impl.PortletWindowEventImpl;import org.gridsphere.layout.view.Render;import org.gridsphere.portlet.impl.SportletProperties;import org.gridsphere.portlet.impl.StoredPortletResponseImpl;import org.gridsphere.portlet.service.spi.PortletServiceFactory;import org.gridsphere.portletcontainer.ApplicationPortlet;import org.gridsphere.portletcontainer.GridSphereEvent;import org.gridsphere.portletcontainer.impl.PortletInvoker;import org.gridsphere.services.core.registry.PortletRegistryService;import org.gridsphere.services.core.security.role.PortletRole;import javax.portlet.*;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.PrintWriter;import java.io.Serializable;import java.io.StringWriter;import java.security.Principal;import java.util.*;/** * A <code>PortletTitleBar</code> represents the visual display of the portlet title bar * within a portlet frame and is contained by {@link PortletFrame}. * The title bar contains portlet mode and window state as well as a title. */public class PortletTitleBar extends BasePortletComponent implements Serializable, Cloneable {    private Log log = LogFactory.getLog(PortletTitleBar.class);    private String title = "unknown title";    private String portletClass = null;    private transient PortletRegistryService portletRegistryService = null;    private transient PortletInvoker portletInvoker = null;    private transient WindowState windowState = WindowState.NORMAL;    private transient PortletMode portletMode = PortletMode.VIEW;    private transient PortletMode previousMode = PortletMode.VIEW;    private transient List<javax.portlet.WindowState> allowedWindowStates = new ArrayList<javax.portlet.WindowState>();    private transient String errorMessage = "";    private transient boolean hasError = false;    private transient boolean isActive = false;    private transient List<PortletTitleBar.PortletModeLink> modeLinks = null;    private transient List<PortletTitleBar.PortletStateLink> windowLinks = null;    private transient Render titleView = null;    // display modes in title bar at all?    private transient boolean displayModes = true;    // display states in title bar at all?    private transient boolean displayStates = true;    /**     * Link is an abstract representation of a hyperlink with an href, image and     * alt tags.     */    abstract class Link {        protected String href = "";        protected String imageSrc = "";        protected String altTag = "";        protected String symbol = "";        protected String cursor = "";        /**         * Returns the image source attribute in the link         *         * @return the image source attribute in the link         */        public String getImageSrc() {            return imageSrc;        }        public String getSymbol() { //WAP 2.0 Extention            return symbol;        }        /**         * Returns the CSS cursor style to use         *         * @return the cursor         */        public String getCursor() {            return cursor;        }        /**         * Sets the CSS cursor style to use         *         * @param cursor the cursor         */        public void setCursor(String cursor) {            this.cursor = cursor;        }        /**         * Sets the href attribute in the link         *         * @param href the href attribute in the link         */        public void setHref(String href) {            this.href = href;        }        /**         * Returns the href attribute in the link         *         * @return the href attribute in the link         */        public String getHref() {            return href;        }        /**         * Returns the alt tag attribute in the link         *         * @return the alt tag attribute in the link         */        public String getAltTag() {            return altTag;        }        /**         * Returns a string containing the image src, href and alt tag attributes         * Used primarily for debugging purposes         */        public String toString() {            StringBuffer sb = new StringBuffer("\n");            sb.append("image src: ").append(imageSrc).append("\n");            sb.append("href: ").append(href).append("\n");            sb.append("alt tag: ").append(altTag).append("\n");            return sb.toString();        }    }    /**     * PortletModeLink is a concrete instance of a Link used for creating     * portlet mode hyperlinks     */    public class PortletModeLink extends Link {        public static final String configImage = "images/window_configure.gif";        public static final String configSymbol = "c";//WAP 2.0 Extention        public static final String editImage = "images/window_edit.gif";        public static final String editSymbol = "/";//WAP 2.0 Extention        public static final String helpImage = "images/window_help.gif";        public static final String helpSymbol = "?";//WAP 2.0 Extention        public static final String viewImage = "images/window_view.gif";        public static final String viewSymbol = "V";//WAP 2.0Extention        /**         * Constructs an instance of PortletModeLink with the supplied portlet mode         *         * @param mode   the portlet mode         * @param locale the locale         * @throws PortletModeException if the mode is not supported         */        public PortletModeLink(PortletMode mode, Locale locale) throws PortletModeException {            if (mode == null) return;            ResourceBundle bundle = ResourceBundle.getBundle("gridsphere.resources.Portlet", locale);            String key = mode.toString().toUpperCase();            altTag = bundle.getString(key);            // Set the image src            if (mode.equals(new PortletMode("CONFIG"))) {                imageSrc = configImage;                symbol = configSymbol;//WAP 2.0            } else if (mode.equals(PortletMode.EDIT)) {                imageSrc = editImage;                symbol = editSymbol;//WAP 2.0            } else if (mode.equals(PortletMode.HELP)) {                imageSrc = helpImage;                symbol = helpSymbol;//WAP 2.0                cursor = "help";            } else if (mode.equals(PortletMode.VIEW)) {                imageSrc = viewImage;                symbol = viewSymbol;//WAP 2.0            } else {                throw new PortletModeException("Unsupported portlet mode: ", mode);            }        }    }    /**     * PortletStateLink is a concrete instance of a Link used for creating     * portlet window state hyperlinks     */    public class PortletStateLink extends Link {        public static final String closeImage = "images/window_close.gif";        public static final String minimizeImage = "images/window_minimize.gif";        public static final String maximizeImage = "images/window_maximize.gif";        public static final String normalImage = "images/window_normal.gif";        public static final String floatImage = "images/window_float.gif";        public static final String closeSymbol = "X"; //WAP 2.0        public static final String minimizeSymbol = "_"; //WAP 2.0        public static final String maximizeSymbol = "="; //WAP 2.0        public static final String normalSymbol = "-"; //WAP 2.0        public static final String floatSymbol = "^"; //WAP 2.0        /**         * Constructs an instance of PortletStateLink with the supplied window state         *         * @param state  the window state         * @param locale the client locale         * @throws WindowStateException if the state is unsupported         */        public PortletStateLink(WindowState state, Locale locale) throws WindowStateException {            if (state == null) return;            // Set the image src            if (state.equals(WindowState.MINIMIZED)) {                imageSrc = minimizeImage;                symbol = minimizeSymbol;            } else if (state.equals(WindowState.MAXIMIZED)) {                imageSrc = maximizeImage;                symbol = maximizeSymbol;            } else if (state.equals(WindowState.NORMAL)) {                imageSrc = normalImage;                symbol = normalSymbol;            } else if (state.equals(new WindowState("closed"))) {                imageSrc = closeImage;                symbol = closeSymbol;            } else if (state.equals(new WindowState("floating"))) {                imageSrc = floatImage;                symbol = floatSymbol;            } else {                throw new WindowStateException("Unsupported window state window mode: ", state);            }            ResourceBundle bundle = ResourceBundle.getBundle("gridsphere.resources.Portlet", locale);            String key = state.toString().toUpperCase();            altTag = bundle.getString(key);        }    }    /**     * Constructs an instance of PortletTitleBar     */    public PortletTitleBar() {    }    /**     * Sets the portlet class used to render the title bar     *     * @param portletClass the concrete portlet class     */    public void setPortletClass(String portletClass) {        this.portletClass = portletClass;    }    /**     * Returns the portlet class used in rendering the title bar     *     * @return the concrete portlet class     */    public String getPortletClass() {        return portletClass;    }    public boolean isActive() {        return isActive;    }    public void setActive(boolean isActive) {        this.isActive = isActive;    }    /**     * Returns the title of the portlet title bar     *     * @return the portlet title bar     */    public String getTitle() {        return title;    }    /**     * Sets the title of the portlet title bar     *     * @param title the portlet title bar     */    public void setTitle(String title) {        this.title = title;    }    /**     * Sets the window state of this title bar     *     * @param state the portlet window state expressed as a string     */    public void setWindowState(WindowState state) {        if (state != null) this.windowState = state;    }    /**     * Returns the window state of this title bar     *     * @return the portlet window state expressed as a string     */    public WindowState getWindowState() {        return windowState;    }    /**     * Sets the window state of this title bar     *     * @param state the portlet window state expressed as a string     */    public void setWindowStateAsString(String state) {        if (state != null) {            try {                this.windowState = new WindowState(state);            } catch (IllegalArgumentException e) {                // do nothing            }        }    }    /**     * Returns the window state of this title bar     *     * @return the portlet window state expressed as a string     */    public String getWindowStateAsString() {        return windowState.toString();    }    /**     * Sets the portlet mode of this title bar     *     * @param mode the portlet mode expressed as a string     */    public void setPortletMode(PortletMode mode) {        if (mode != null) this.portletMode = mode;    }    /**     * Returns the portlet mode of this title bar     *     * @return the portlet mode expressed as a string     */    public PortletMode getPortletMode() {        return portletMode;    }    /**     * Sets the portlet mode of this title bar     *     * @param mode the portlet mode expressed as a string     */    public void setPreviousMode(PortletMode mode) {        if (mode != null) this.previousMode = mode;    }    /**     * Returns the portlet mode of this title bar     *     * @return the portlet mode expressed as a string     */    public PortletMode getPreviousMode() {        return previousMode;    }    /**     * Sets the portlet mode of this title bar     *     * @param mode the portlet mode expressed as a string     */    public void setPortletModeAsString(String mode) {        if (mode == null) return;        try {            this.portletMode = new PortletMode(mode);        } catch (IllegalArgumentException e) {            // do nothing        }    }    /**     * Returns the portlet mode of this title bar     *     * @return the portlet mode expressed as a string     */    public String getPortletModeAsString() {        return portletMode.toString();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -