Package com.ponysdk.sample.trading.client

Source Code of com.ponysdk.sample.trading.client.TradingSampleEntryPoint

package com.ponysdk.sample.trading.client;

import com.ponysdk.core.UIContext;
import com.ponysdk.core.activity.ActivityManager;
import com.ponysdk.core.event.EventBus;
import com.ponysdk.core.main.EntryPoint;
import com.ponysdk.core.place.DefaultPlaceHistoryMapper;
import com.ponysdk.core.place.PlaceController;
import com.ponysdk.core.place.PlaceHistoryHandler;
import com.ponysdk.core.place.PlaceHistoryMapper;
import com.ponysdk.sample.trading.client.activity.SampleActivityMapper;
import com.ponysdk.sample.trading.client.place.LoginPlace;
import com.ponysdk.ui.server.basic.PPusher;
import com.ponysdk.ui.server.basic.PRootLayoutPanel;
import com.ponysdk.ui.server.basic.PSimpleLayoutPanel;

public class TradingSampleEntryPoint implements EntryPoint {

    public static final String USER = "user";

    @Override
    public void start(final UIContext uiContext) {
        if (uiContext.getApplicationAttribute(USER) == null) uiContext.getHistory().newItem("", false);
        start0(uiContext);
    }

    @Override
    public void restart(final UIContext uiContext) {
        if (uiContext.getApplicationAttribute(USER) == null) uiContext.getHistory().newItem("", false);
        start0(uiContext);
    }

    private void start0(final UIContext uiContext) {

        PPusher.initialize();

        final PSimpleLayoutPanel panel = new PSimpleLayoutPanel();
        PRootLayoutPanel.get().add(panel);

        final EventBus eventBus = UIContext.getRootEventBus();

        final SampleActivityMapper mapper = new SampleActivityMapper();
        final PlaceHistoryMapper historyMapper = new DefaultPlaceHistoryMapper(eventBus);
        final PlaceController placeController = new PlaceController(uiContext.getHistory(), eventBus);

        final ActivityManager activityManager = new ActivityManager(mapper);
        activityManager.setDisplay(panel);

        final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(uiContext.getHistory(), historyMapper, placeController, eventBus);
        historyHandler.setDefaultPlace(new LoginPlace());
        historyHandler.handleCurrentHistory();
    }
}
TOP

Related Classes of com.ponysdk.sample.trading.client.TradingSampleEntryPoint

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.