All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.ade.editprovider.client.CmsDirectEditToolbarHandler Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.ade.editprovider.client;

import org.opencms.ade.publish.client.CmsPublishDialog;
import org.opencms.gwt.client.CmsCoreProvider;
import org.opencms.gwt.client.rpc.CmsRpcAction;
import org.opencms.gwt.client.ui.A_CmsToolbarHandler;
import org.opencms.gwt.client.ui.CmsToolbarContextButton;
import org.opencms.gwt.client.ui.I_CmsToolbarButton;
import org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommand;
import org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuCommandInitializer;
import org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuEntry;
import org.opencms.gwt.shared.CmsContextMenuEntryBean;
import org.opencms.gwt.shared.CmsCoreData.AdeContext;
import org.opencms.util.CmsUUID;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.PopupPanel;

/**
 * A toolbar handler for the Toolbar direct edit provider.

* * @since 8.0.0 */ public class CmsDirectEditToolbarHandler extends A_CmsToolbarHandler { /** The currently active button. */ private I_CmsToolbarButton m_activeButton; /** The context menu button. */ private CmsToolbarContextButton m_contextButton; /** The context menu commands. */ private Map m_contextMenuCommands; /** * @see org.opencms.gwt.client.ui.I_CmsToolbarHandler#activateSelection() */ public void activateSelection() { // do nothing } /** * De-activates the current button.

*/ public void deactivateCurrentButton() { if (m_activeButton != null) { m_activeButton.setActive(false); m_activeButton = null; } } /** * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler#ensureLockOnResource(org.opencms.util.CmsUUID) */ public boolean ensureLockOnResource(CmsUUID structureId) { return CmsCoreProvider.get().lock(structureId); } /** * @see org.opencms.gwt.client.ui.I_CmsToolbarHandler#getActiveButton() */ public I_CmsToolbarButton getActiveButton() { return m_activeButton; } /** * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler#getContextMenuCommands() */ public Map getContextMenuCommands() { if (m_contextMenuCommands == null) { I_CmsContextMenuCommandInitializer initializer = GWT.create(I_CmsContextMenuCommandInitializer.class); m_contextMenuCommands = initializer.initCommands(); } return m_contextMenuCommands; } /** * Inserts the context menu.

* * @param menuBeans the menu beans from the server * @param structureId the structure id of the resource at which the workplace should be opened */ public void insertContextMenu(List menuBeans, CmsUUID structureId) { List menuEntries = transformEntries(menuBeans, structureId); m_contextButton.showMenu(menuEntries); } /** * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler#leavePage(java.lang.String) */ public void leavePage(String targetUri) { Window.Location.replace(targetUri); } /** * @see org.opencms.gwt.client.ui.I_CmsToolbarHandler#loadContextMenu(org.opencms.util.CmsUUID, org.opencms.gwt.shared.CmsCoreData.AdeContext) */ public void loadContextMenu(final CmsUUID structureId, final AdeContext context) { /** The RPC menu action for the container page dialog. */ CmsRpcAction> menuAction = new CmsRpcAction>() { /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute() */ @Override public void execute() { CmsCoreProvider.getService().getContextMenuEntries(structureId, context, this); } /** * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object) */ @Override public void onResponse(List menuBeans) { insertContextMenu(menuBeans, structureId); } }; menuAction.execute(); } /** * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler#refreshResource(org.opencms.util.CmsUUID) */ public void refreshResource(CmsUUID structureId) { Window.Location.reload(); } /** * Sets the currently active tool-bar button.

* * @param button the button */ public void setActiveButton(I_CmsToolbarButton button) { m_activeButton = button; } /** * Sets the context menu button.

* * @param button the context menu button */ public void setContextMenuButton(CmsToolbarContextButton button) { m_contextButton = button; } /** * Opens the publish dialog.

*/ public void showPublishDialog() { CmsPublishDialog.showPublishDialog(new HashMap(), new CloseHandler() { /** * @see com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt.event.logical.shared.CloseEvent) */ public void onClose(CloseEvent event) { deactivateCurrentButton(); } }); } /** * @see org.opencms.gwt.client.ui.contextmenu.I_CmsContextMenuHandler#unlockResource(org.opencms.util.CmsUUID) */ public void unlockResource(CmsUUID structureId) { CmsCoreProvider.get().unlock(structureId); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy