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

com.gwtplatform.mvp.client.proxy.NonLeafTabContentProxyImpl Maven / Gradle / Ivy

There is a newer version: 1.6
Show newest version
/**
 * Copyright 2011 ArcBees Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.gwtplatform.mvp.client.proxy;

import com.google.gwt.event.shared.GwtEvent.Type;
import com.gwtplatform.mvp.client.ChangeTabEvent;
import com.gwtplatform.mvp.client.ChangeTabHandler;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.RequestTabsEvent;
import com.gwtplatform.mvp.client.RequestTabsHandler;
import com.gwtplatform.mvp.client.Tab;
import com.gwtplatform.mvp.client.TabData;

/**
 * @param  The Presenter's type.
 * @author Philippe Beaudoin
 */
public class NonLeafTabContentProxyImpl> extends ProxyImpl
        implements NonLeafTabContentProxy {

    protected TabData tabData;
    protected String targetHistoryToken;
    protected Type requestTabsEventType;
    protected Type changeTabEventType;

    private Tab tab;

    /**
     * Creates a {@link Proxy} for a {@link Presenter} that is meant to be contained within a
     * {@link com.gwtplatform.mvp.client.TabContainerPresenter} but not as a leaf. As such, these
     * proxy hold information that can be displayed on the tab together with the target history
     * token of the leaf page to display when the tab is clicked.
     */
    public NonLeafTabContentProxyImpl() {
    }

    @Override
    public TabData getTabData() {
        return tabData;
    }

    @Override
    public String getTargetHistoryToken() {
        return targetHistoryToken;
    }

    @Override
    public Tab getTab() {
        return tab;
    }

    @Override
    public void changeTab(TabData tabData) {
        this.tabData = tabData;
        if (changeTabEventType != null) {
            ChangeTabEvent.fire(this, changeTabEventType, this);
        }
    }

    protected void addRequestTabsHandler() {
        eventBus.addHandler(requestTabsEventType, new RequestTabsHandler() {
            @Override
            public void onRequestTabs(RequestTabsEvent event) {
                tab = event.getTabContainer().addTab(NonLeafTabContentProxyImpl.this);
            }
        });
    }

    @Override
    public void changeTab(TabData tabData, String targetHistoryToken) {
        this.targetHistoryToken = targetHistoryToken;
        changeTab(tabData);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy