001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.gwt.client.ui.contextmenu;
029
030import org.opencms.gwt.client.CmsCoreProvider;
031import org.opencms.gwt.client.Messages;
032import org.opencms.gwt.client.ui.CmsPopup;
033import org.opencms.gwt.client.ui.CmsPushButton;
034import org.opencms.gwt.client.ui.I_CmsButton.ButtonColor;
035import org.opencms.gwt.client.ui.I_CmsButton.ButtonStyle;
036import org.opencms.gwt.shared.CmsContextMenuEntryBean;
037import org.opencms.util.CmsUUID;
038
039import com.google.gwt.event.dom.client.ClickEvent;
040import com.google.gwt.event.dom.client.ClickHandler;
041import com.google.gwt.user.client.Window;
042import com.google.gwt.user.client.ui.FlowPanel;
043import com.google.gwt.user.client.ui.Frame;
044
045/**
046 * Dialog used to display the "About" information in an iframe.<p>
047 */
048public class CmsAbout implements I_CmsHasContextMenuCommand, I_CmsContextMenuCommand {
049
050    /**
051     * Creates a new context menu command.<p>
052     *
053     * @return the context menu command created
054     */
055    public static I_CmsContextMenuCommand getContextMenuCommand() {
056
057        return new CmsAbout();
058    }
059
060    /**
061     * Shows the OpenCms about dialog.<p>
062     */
063    public static void showAbout() {
064
065        final CmsPopup popup = new CmsPopup(Messages.get().key(Messages.GUI_ABOUT_DIALOG_TITLE_0));
066        FlowPanel container = new FlowPanel();
067        int height = 450;
068        if (Window.getClientHeight() < height) {
069            height = Math.max(300, Window.getClientHeight() - 50);
070        }
071        container.setHeight(height + "px");
072        Frame frame = new Frame();
073
074        frame.setWidth("100%");
075        frame.setHeight("100%");
076        frame.setUrl(CmsCoreProvider.get().getAboutLink());
077        container.add(frame);
078        popup.setMainContent(container);
079        popup.center();
080        popup.addDialogClose(null);
081        CmsPushButton closeButton = new CmsPushButton();
082        closeButton.setText(Messages.get().key(Messages.GUI_CLOSE_0));
083        closeButton.setUseMinWidth(true);
084
085        closeButton.setButtonStyle(ButtonStyle.TEXT, ButtonColor.BLUE);
086        closeButton.addClickHandler(new ClickHandler() {
087
088            /**
089             * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
090             */
091            public void onClick(ClickEvent event) {
092
093                popup.hide();
094            }
095        });
096        popup.addButton(closeButton);
097        popup.addDialogClose(null);
098    }
099
100    /**
101     * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#execute(org.opencms.util.CmsUUID, org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler, org.opencms.gwt.shared.CmsContextMenuEntryBean)
102     */
103    public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {
104
105        showAbout();
106    }
107
108    /**
109     * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#getItemWidget(org.opencms.util.CmsUUID, org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler, org.opencms.gwt.shared.CmsContextMenuEntryBean)
110     */
111    public A_CmsContextMenuItem getItemWidget(
112        CmsUUID structureId,
113        I_CmsContextMenuHandler handler,
114        CmsContextMenuEntryBean bean) {
115
116        return null;
117    }
118
119    /**
120     * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#hasItemWidget()
121     */
122    public boolean hasItemWidget() {
123
124        return false;
125    }
126
127}