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.ade.sitemap.client.toolbar;
029
030import org.opencms.ade.sitemap.client.CmsSitemapView;
031import org.opencms.ade.sitemap.client.attributes.CmsAttributesDialog;
032import org.opencms.ade.sitemap.shared.CmsSitemapAttributeData;
033import org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapServiceAsync;
034import org.opencms.gwt.client.I_CmsDisableable;
035import org.opencms.gwt.client.rpc.CmsRpcAction;
036import org.opencms.gwt.client.ui.contextmenu.A_CmsContextMenuItem;
037import org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand;
038import org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler;
039import org.opencms.gwt.client.ui.contextmenu.I_CmsHasContextMenuCommand;
040import org.opencms.gwt.shared.CmsContextMenuEntryBean;
041import org.opencms.util.CmsUUID;
042
043/**
044 * Context menu entry for the sitemap attribute editor.
045 */
046public class CmsSitemapAttributeEditor
047implements I_CmsHasContextMenuCommand, I_CmsContextMenuCommand, I_CmsDisableable {
048
049    /**
050     * Returns the context menu command according to
051     * {@link org.opencms.gwt.client.ui.contextmenu.I_CmsHasContextMenuCommand}.<p>
052     *
053     * @return the context menu command
054     */
055    public static I_CmsContextMenuCommand getContextMenuCommand() {
056
057        return new CmsSitemapAttributeEditor();
058    }
059
060    /**
061     * Gets the service to use for validating/saving aliases.<p>
062     *
063     * @return the service used for validating/saving aliases
064     */
065    protected static I_CmsSitemapServiceAsync getService() {
066
067        return CmsSitemapView.getInstance().getController().getService();
068    }
069
070    /**
071     * @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)
072     */
073    public void execute(CmsUUID structureId, I_CmsContextMenuHandler handler, CmsContextMenuEntryBean bean) {
074
075        CmsRpcAction<CmsSitemapAttributeData> action = new CmsRpcAction<CmsSitemapAttributeData>() {
076
077            @Override
078            public void execute() {
079
080                start(0, true);
081                CmsUUID rootId = CmsSitemapView.getInstance().getController().getData().getRoot().getId();
082                getService().editAttributeData(rootId, this);
083            }
084
085            @Override
086            protected void onResponse(CmsSitemapAttributeData result) {
087
088                stop(false);
089                CmsAttributesDialog dialog = new CmsAttributesDialog(result);
090                dialog.centerHorizontally(50);
091
092            }
093        };
094        action.execute();
095    }
096
097    /**
098     * @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)
099     */
100    public A_CmsContextMenuItem getItemWidget(
101        CmsUUID structureId,
102        I_CmsContextMenuHandler handler,
103        CmsContextMenuEntryBean bean) {
104
105        return null;
106    }
107
108    /**
109     * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand#hasItemWidget()
110     */
111    public boolean hasItemWidget() {
112
113        return false;
114    }
115
116    /**
117     * @see org.opencms.gwt.client.I_CmsDisableable#isDisabled()
118     */
119    public boolean isDisabled() {
120
121        return false;
122    }
123
124}