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.ui.client;
029
030import org.opencms.gwt.client.util.CmsEmbeddedDialogFrameWrapper;
031import org.opencms.gwt.client.util.I_CmsEmbeddedDialogLoader;
032import org.opencms.ui.components.extensions.CmsEmbeddedDialogExtension;
033import org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC;
034import org.opencms.ui.shared.rpc.I_CmsEmbeddingServerRpc;
035
036import com.vaadin.client.ServerConnector;
037import com.vaadin.client.extensions.AbstractExtensionConnector;
038import com.vaadin.shared.ui.Connect;
039
040/**
041 * The embedded dialog connector.<p>
042 */
043@Connect(CmsEmbeddedDialogExtension.class)
044public class CmsEmbeddedDialogConnector extends AbstractExtensionConnector
045implements I_CmsEmbeddedDialogClientRPC, I_CmsEmbeddedDialogLoader {
046
047    /** The serial version id. */
048    private static final long serialVersionUID = -7984262078804717197L;
049
050    /**
051     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#finish(java.lang.String)
052     */
053    public void finish(String resourceIds) {
054
055        CmsEmbedWrapper.connector.finish(resourceIds);
056    }
057
058    /**
059     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#finishForProjectOrSiteChange(java.lang.String, java.lang.String)
060     */
061    public void finishForProjectOrSiteChange(String sitePath, String serverLink) {
062
063        CmsEmbedWrapper.connector.finishForProjectOrSiteChange(sitePath, serverLink);
064    }
065
066    /**
067     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#initServerRpc()
068     */
069    public void initServerRpc() {
070
071        // we only should get here if there *is* an embedded frame in the window
072        CmsEmbeddedDialogFrameWrapper parentWindow = CmsEmbeddedDialogFrameWrapper.parent;
073        parentWindow.embeddedDialogFrameInstance.installEmbeddedDialogLoader(this);
074    }
075
076    /**
077     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#leavePage(java.lang.String)
078     */
079    public void leavePage(String targetUri) {
080
081        CmsEmbedWrapper.connector.leavePage(targetUri);
082    }
083
084    /**
085     * @see org.opencms.gwt.client.util.I_CmsEmbeddedDialogLoader#loadDialog(java.lang.String)
086     */
087    @Override
088    public void loadDialog(String dialogInfo) {
089
090        getRpcProxy(I_CmsEmbeddingServerRpc.class).loadDialog(dialogInfo);
091        // in Chrome, the RPC request does not get sent until the user moves the mouse unless we manually trigger a heartbeat request
092        getConnection().getHeartbeat().send();
093    }
094
095    /**
096     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#reloadParent()
097     */
098    public void reloadParent() {
099
100        CmsEmbedWrapper.connector.reload();
101    }
102
103    /**
104     * @see org.opencms.ui.shared.rpc.I_CmsEmbeddedDialogClientRPC#selectString(java.lang.String)
105     */
106    public void selectString(String principal) {
107
108        CmsEmbedWrapper.connector.selectString(principal);
109
110    }
111
112    /**
113     * @see com.vaadin.client.extensions.AbstractExtensionConnector#extend(com.vaadin.client.ServerConnector)
114     */
115    @Override
116    protected void extend(ServerConnector target) {
117
118        registerRpc(I_CmsEmbeddedDialogClientRPC.class, this);
119    }
120}