org.robbins.flashcards.client.activity.NavigationActivity.java Source code

Java tutorial

Introduction

Here is the source code for org.robbins.flashcards.client.activity.NavigationActivity.java

Source

/*
 * Copyright 2010
 *
 * 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 org.robbins.flashcards.client.activity;

import org.robbins.flashcards.client.factory.ClientFactory;
import org.robbins.flashcards.client.mvp.AppPlaceHistoryMapper;
import org.robbins.flashcards.client.place.ListFlashCardsPlace;
import org.robbins.flashcards.client.place.ListTagsPlace;
import org.robbins.flashcards.client.place.NewFlashCardPlace;
import org.robbins.flashcards.client.place.NewTagPlace;
import org.robbins.flashcards.client.ui.NavigationView;
import org.robbins.flashcards.util.ConstsUtil;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;

public class NavigationActivity extends AbstractActivity {

    private final NavigationView navigationView;

    public NavigationActivity(final ClientFactory clientFactory) {
        GWT.log("Creating 'NavigationActivity'");

        this.navigationView = clientFactory.getNavigationView();

        bind();
    }

    @Override
    public void start(final AcceptsOneWidget panel, final EventBus eventBus) {
        panel.setWidget(navigationView.asWidget());
    }

    public void bind() {

        AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);

        navigationView
                .setNewFlashCardToken(historyMapper.getToken(new NewFlashCardPlace(ConstsUtil.FLASHCARD_FORM)));
        navigationView.setListFlashCardsToken(
                historyMapper.getToken(new ListFlashCardsPlace(ConstsUtil.LIST_FLASHCARDS)));
        navigationView.setNewTagToken(historyMapper.getToken(new NewTagPlace(ConstsUtil.TAG_FORM)));
        navigationView.setListTagsToken(historyMapper.getToken(new ListTagsPlace(ConstsUtil.LIST_TAGS)));
    }
}