Example usage for com.google.gwt.user.client History back

List of usage examples for com.google.gwt.user.client History back

Introduction

In this page you can find the example usage for com.google.gwt.user.client History back.

Prototype

public static void back() 

Source Link

Document

Programmatic equivalent to the user pressing the browser's 'back' button.

Usage

From source file:com.acme.gwt.client.presenter.CreateShowPresenter.java

License:Apache License

@Override
public void back() {
    History.back();
}

From source file:com.dimdim.conference.ui.envcheck.client.layout.CommonMessagePopup.java

License:Open Source License

protected void drawDialog() {
    vp = new VerticalPanel();
    RoundedPanel rp = new RoundedPanel(vp);

    vp.setStyleName("common-dialog-outer-panel");
    rp.setStyleName("common-dialog-rounded-corner-panel");

    DockPanel buttonPanel = new DockPanel();
    if (this.showCloseButton) {
        closeButton = new Button(closeButtonText, new ClickListener() {
            public void onClick(Widget sender) {
                hide();// www  . j  a  va  2 s.c om
                History.back(); //   TODO move out into a listener.
            }
        });
        closeButton.setStyleName("dm-popup-close-button");
        buttonPanel.add(closeButton, DockPanel.EAST);
        buttonPanel.setSpacing(0);
        HTML filler1 = new HTML(" ");
        buttonPanel.add(filler1, DockPanel.EAST);
    }
    if (this.dialogName != null) {
        //   Create a width adjustment panel.
        String widthStyle = this.dialogName + "-dialog-width";
        String heightStyle1 = this.dialogName + "-dialog-height-one";
        String heightStyle2 = this.dialogName + "-dialog-height-two";
        String contentWidthStyle = this.dialogName + "-dialog-content";

        content.addStyleName(contentWidthStyle);
        HorizontalPanel upperPanel = new HorizontalPanel();

        HTML upperLeftBar = new HTML(" ");
        upperLeftBar.setStyleName(heightStyle1);
        upperPanel.add(upperLeftBar);
        upperPanel.add(content);
        upperPanel.setCellWidth(content, "100%");
        upperPanel.setCellVerticalAlignment(content, VerticalPanel.ALIGN_MIDDLE);

        HorizontalPanel lowerPanel = new HorizontalPanel();
        lowerPanel.setStyleName(widthStyle);

        HTML lowerLeftBar = new HTML(" ");
        lowerLeftBar.setStyleName(heightStyle2);
        lowerPanel.add(lowerLeftBar);
        lowerPanel.add(buttonPanel);
        lowerPanel.setCellWidth(buttonPanel, "100%");
        lowerPanel.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
        lowerPanel.setCellVerticalAlignment(buttonPanel, VerticalPanel.ALIGN_MIDDLE);

        vp.add(upperPanel);
        vp.add(lowerPanel);
        this.addStyleName(this.dialogName + "-dialog-size");
    } else {
        vp.add(content);
        vp.setCellWidth(content, "100%");

        vp.add(buttonPanel);
        vp.setCellWidth(buttonPanel, "100%");
        vp.setCellHorizontalAlignment(buttonPanel, HorizontalPanel.ALIGN_RIGHT);
    }
    this.addPopupListener(this);

    this.add(vp);
}

From source file:com.eduworks.gwt.client.pagebuilder.screen.ScreenDispatch.java

License:Apache License

public void loadHistoryScreen(String token) {
    for (int x = history.size() - 1; x > -1; x--) {
        if (history.get(x).token.equals(token)) {
            if (history.get(x).screen != null)
                history.get(x).screen.display();
            //history.setSize(x+1);
            History.newItem(token, false);
            return;
        }/*  w w  w.ja  va  2  s  .c  o m*/
    }
    if (token.equals("Login") || history.size() == 0) {
        clearHistory();
        loadScreen(defaultScreen, true);
    } else if ((token == "#") || (token.equalsIgnoreCase(history.lastElement().token)))
        History.back();
}

From source file:com.eduworks.gwt.client.pagebuilder.ScreenDispatch.java

License:Apache License

public void loadHistoryScreen(String token) {
    for (int x = history.size() - 1; x > -1; x--) {
        if (history.get(x).token.equals(token)) {
            if (history.get(x).screen != null)
                history.get(x).screen.display();
            history.setSize(x + 1);//from w w  w . j a  va2  s .c  o  m
            return;
        }
    }
    if (token.equals("Login") || history.size() == 0) {
        clearHistory();
        loadScreen(defaultScreen, true);
    } else if ((token == "#") || (token.equalsIgnoreCase(history.lastElement().token)))
        History.back();
}

From source file:com.fullmetalgalaxy.client.creation.MAppGameCreation.java

License:Open Source License

@Override
public void onClick(ClickEvent p_event) {
    if (p_event.getSource() == m_btnCreateGame) {
        AppMain.instance().startLoading();
        if (GameEngine.model().getGame().isTrancient()) {
            createGame();//  www  .j  a v a2  s.  c om
        } else {
            saveGame();
        }
    } else if (p_event.getSource() == m_btnCancel) {
        GameEngine.model().getGame().reinit();
        History.back();
    }
}

From source file:com.goodow.wave.client.wavepanel.title.WaveTitle.java

License:Apache License

public WaveTitle() {
    this.addStyleName(WaveTitleResources.css().waveTitle());
    IconButtonTemplate iconButton = this.addIconClickButton();
    iconButton.setIconElement(//from w w w. j a  v  a2 s. c  om
            AbstractImagePrototype.create(WaveTitleResources.image().waveTitleReturn()).createElement());
    iconButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            History.back();
        }
    });

    text = DOM.createSpan();
    this.getElement().appendChild(text);

    iconButton = this.addIconClickButton();
    iconButton.setIconElement(
            AbstractImagePrototype.create(WaveTitleResources.image().waveTitleClose()).createElement());
    iconButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(final ClickEvent event) {
            WaveTitle.this.getParent().removeFromParent();
        }
    });
}

From source file:com.google.gwt.gwtpages.demo.client.pages.RequestInfoPage.java

private void gotoPage() {
    if (null == backCommand)
        History.back();
    else
        backCommand.execute();
}

From source file:com.google.livingstories.client.lsp.views.PlayerPage.java

License:Apache License

public void load(PlayerContentItem player) {
    this.player = player;

    name.setText(player.getName());/*www.j  ava  2s. c o m*/
    backLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            History.back();
        }
    });

    if (player.hasPhoto()) {
        Image photoWidget = new Image(player.getPhotoContentItem().getContent());
        photoWidget.addStyleName("playerPhoto");
        photo.add(photoWidget);
    }
    content.add(new ContentRenderer(player.getFullContentToRender(), false));

    // For now, we don't attribute contributors to player content items, though in principle we
    // could (using them to describe the authorship of the bio.)

    loadMore();

    onShow();
}

From source file:com.google.mobile.trippy.web.client.Controller.java

License:Apache License

public void bind() {
    final HandlerManager eventBus = singletonComponents.getEventBus();

    eventBus.addHandler(BackEvent.getType(), new BackEventHandler() {
        @Override/*from   w  w  w .ja  v a  2s.  c  o  m*/
        public void onBack(BackEvent event) {
            History.back();
        }
    });

    eventBus.addHandler(ShowHomePageEvent.getType(), new ShowHomePageEventHandler() {
        @Override
        public void showHomePage(ShowHomePageEvent event) {
            showHomeScreen(event);
        }
    });

    eventBus.addHandler(ShowCreateTripEvent.getType(), new ShowCreateTripEventHandler() {
        @Override
        public void onShowCreateTrip(ShowCreateTripEvent event) {
            showCreateTripScreen(event);
        }
    });

    eventBus.addHandler(ShowFilteredTripListEvent.getType(), new ShowFilteredTripListEventHandler() {
        @Override
        public void onShowFilteredTripList(ShowFilteredTripListEvent event) {

            final List<Trip> trips = tripService.getTrips();
            final ArrayList<Trip> filteredTrips = new ArrayList<Trip>();
            final String query = event.getSearchTripQuery();
            String titleString = Constants.MY_TRIPS_STR;

            if (query.equals(Constants.UPCOMING_TRIPS_STR)) {
                final Date currentDate = new Date();
                for (final Trip trip : trips) {
                    final Date startDate = trip.getStartDate();
                    if (startDate.after(currentDate)) {
                        filteredTrips.add(trip);
                    }
                }
                titleString = Constants.UPCOMING_TRIPS_STR;
            } else if (query.equals(Constants.CURRENT_TRIPS_STR)) {
                final Date currentDate = new Date();
                for (final Trip trip : trips) {
                    if (trip.getStartDate().before(currentDate) && currentDate.before(singletonComponents
                            .getUtils().addDaysToDate(trip.getStartDate(), trip.getDuration()))) {
                        filteredTrips.add(trip);
                    }
                }
                titleString = Constants.CURRENT_TRIPS_STR;
            } else if (query.equals(Constants.PAST_TRIPS_STR)) {
                final Date currentDate = new Date();
                for (final Trip trip : trips) {
                    final Date startDate = trip.getStartDate();
                    if ((singletonComponents.getUtils().addDaysToDate(startDate, trip.getDuration()))
                            .before(currentDate) && !startDate.equals(Constants.UNSCHEDULED_DATE)) {
                        filteredTrips.add(trip);
                    }
                }
                titleString = Constants.PAST_TRIPS_STR;
            } else {
                for (Trip trip : trips) {
                    if (trip.getName().toLowerCase().contains(query.toLowerCase())) {
                        filteredTrips.add(trip);
                    }
                }
            }

            showTripListScreen(filteredTrips, titleString, event.isHistoryEvent());

            final Map<String, String[]> listParamMap = new HashMap<String, String[]>();
            listParamMap.put(Page.PAGE, new String[] { "" + Page.PAGE_FILTERED_TRIP_LIST });
            listParamMap.put(Page.SEARCH_QUERY, new String[] { event.getSearchTripQuery() });
            History.newItem(createTokenHash(listParamMap), false);
        }
    });

    eventBus.addHandler(ShowTripListEvent.getType(), new ShowTripListEventHanlder() {
        @Override
        public void onShowTripList(ShowTripListEvent event) {

            showTripListScreen(tripService.getTrips(), Constants.MY_TRIPS_STR, event.isHistoryEvent());

            Map<String, String[]> listParamMap = new HashMap<String, String[]>();
            listParamMap.put(Page.PAGE, new String[] { "" + Page.PAGE_TRIP_LIST });
            History.newItem(createTokenHash(listParamMap), false);
        }
    });

    eventBus.addHandler(ShowTripScheduleEvent.getType(), new ShowTripScheduleEventHandler() {
        @Override
        public void onShowTripSchedule(ShowTripScheduleEvent event) {
            showTripScheduleScreen(event);
        }
    });

    eventBus.addHandler(ShowTripOnMapEvent.getType(), new ShowTripOnMapEventHandler() {
        @Override
        public void onShowTripOnMap(ShowTripOnMapEvent event) {
            showTripOnMapScreen(event);
        }
    });

    eventBus.addHandler(ShareTripEvent.getType(), new ShareTripEventHandler() {
        @Override
        public void onShareTrip(ShareTripEvent event) {
            showTripShareScreen(event);
        }
    });

    eventBus.addHandler(ShowTripItemDetailsEvent.getType(), new ShowTripItemDetailsEventHandler() {
        @Override
        public void onShowTripItemDetails(ShowTripItemDetailsEvent event) {
            showTripItemDetailsScreen(
                    singletonComponents.getTripItemService().getTripItem(event.getTripItem().getKey()),
                    event.isHistoryEvent());
        }
    });

    eventBus.addHandler(SearchQueryEvent.getType(), new SearchQueryEventHandler() {
        @Override
        public void onSearchRequest(SearchQueryEvent event) {
            showSearchResultsMapScreen(event);
        }
    });

    eventBus.addHandler(ShowSearchResultsOnMapEvent.getType(), new ShowSearchResultsOnMapEventHandler() {
        @Override
        public void onShowSearchResultsOnMap(ShowSearchResultsOnMapEvent event) {
            showSearchResultsMapScreen(event);
        }
    });

    eventBus.addHandler(ShowSearchResultsInListEvent.getType(), new ShowSearchResultsInListEventHandler() {
        @Override
        public void onShowSearchResultsInList(ShowSearchResultsInListEvent event) {
            showSearchResultsListScreen(event);
        }
    });

    eventBus.addHandler(ShowSearchItemDetailsEvent.getType(), new ShowSearchItemDetailsEventHandler() {
        @Override
        public void onShowSearchDetails(ShowSearchItemDetailsEvent event) {
            showSearchItemDetailsScreen(event);
        }
    });

    eventBus.addHandler(ShowTripItemCommentsEvent.getType(), new ShowTripItemCommentsEventHandler() {
        @Override
        public void onShowTripItemComments(ShowTripItemCommentsEvent event) {
            showTripItemCommentsScreen(event);
        }
    });
}

From source file:com.google.mobile.trippy.web.client.HistoryTokenHandler.java

License:Apache License

public void showPageForToken(final String token) {
    final Map<String, List<String>> paramMap = buildListParamMap(token);

    if (!paramMap.containsKey(Page.PAGE)) {
        eventBus.fireEvent(new ShowHomePageEvent());
        return;//from   w w w.j  a  va 2 s. c o m
    }
    try {
        switch (Integer.parseInt(paramMap.get(Page.PAGE).get(0))) {
        case Page.PAGE_HOME:
            eventBus.fireEvent(new ShowHomePageEvent(true));
            break;
        case Page.PAGE_CREATE_TRIP:
            eventBus.fireEvent(new ShowCreateTripEvent(true));
            break;
        case Page.PAGE_TRIP_LIST:
            eventBus.fireEvent(new ShowTripListEvent(true));
            break;
        case Page.PAGE_FILTERED_TRIP_LIST:
            String filterQuery = paramMap.get(Page.SEARCH_QUERY).get(0);
            eventBus.fireEvent(new ShowFilteredTripListEvent(filterQuery, true));
            break;
        case Page.PAGE_TRIP_DETAILS:
            Trip trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            if (trip != null) {
                final ShowTripScheduleEvent event = new ShowTripScheduleEvent(trip, false);
                event.setHistoryEvent(true);
                eventBus.fireEvent(event);
            } else {
                // TODO: Show error screen that Trip no more exists and
                // give option to go to home page.
                History.back();
            }
            break;
        case Page.PAGE_TRIP_MAP:
            trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            int tripDay = Integer.parseInt(paramMap.get(Page.TRIP_DAY).get(0));

            ShowTripOnMapEvent showTripOnMapEvent = null;
            if (paramMap.get(Page.TRIP_ITEM_ID) != null) {
                String tripItemkey = paramMap.get(Page.TRIP_ITEM_ID).get(0);
                showTripOnMapEvent = new ShowTripOnMapEvent(trip, tripDay, tripItemkey);
            } else {
                showTripOnMapEvent = new ShowTripOnMapEvent(trip, tripDay, null);
            }
            showTripOnMapEvent.setHistoryEvent(true);
            eventBus.fireEvent(showTripOnMapEvent);
            break;

        case Page.PAGE_TRIP_ITEM_DETAILS:
            TripItem tripItem = tripItemService.getTripItem(paramMap.get(Page.TRIP_ITEM_ID).get(0));
            eventBus.fireEvent(new ShowTripItemDetailsEvent(tripItem, true));
            break;

        case Page.PAGE_SEARCH_RESULT_MAP:
            trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            int day = Integer.parseInt(paramMap.get(Page.TRIP_DAY).get(0));
            String key = paramMap.get(Page.SEARCH_RESULTS_KEY).get(0);

            ShowSearchResultsOnMapEvent showSearchResultsOnMapEvent = new ShowSearchResultsOnMapEvent(trip, day,
                    key);
            showSearchResultsOnMapEvent.setHistoryEvent(true);
            eventBus.fireEvent(showSearchResultsOnMapEvent);
            break;

        case Page.PAGE_SEARCH_RESULT_LIST:
            trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            day = Integer.parseInt(paramMap.get(Page.TRIP_DAY).get(0));
            key = paramMap.get(Page.SEARCH_RESULTS_KEY).get(0);
            ShowSearchResultsInListEvent showSearchResultsInListEvent = new ShowSearchResultsInListEvent(trip,
                    day, key);
            showSearchResultsInListEvent.setHistoryEvent(true);
            eventBus.fireEvent(showSearchResultsInListEvent);
            break;

        case Page.PAGE_SEARCH_ITEM_DETAILS:
            trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            day = Integer.parseInt(paramMap.get(Page.TRIP_DAY).get(0));
            String id = paramMap.get(Page.SEARCH_ITEM_ID).get(0);
            ShowSearchItemDetailsEvent showSearchItemDetailsEvent = new ShowSearchItemDetailsEvent(id, trip,
                    day);
            showSearchItemDetailsEvent.setHistoryEvent(false);
            eventBus.fireEvent(showSearchItemDetailsEvent);
            break;

        case Page.PAGE_TRIP_ITEM_COMMENTS:
            tripItem = tripItemService.getTripItem(paramMap.get(Page.TRIP_ITEM_ID).get(0));
            eventBus.fireEvent(new ShowTripItemCommentsEvent(tripItem, true));
            break;
        case Page.PAGE_TRIP_SHARE:
            trip = tripService.getTrip(paramMap.get(Page.TRIP_ID).get(0));
            eventBus.fireEvent(new ShareTripEvent(trip, true));
            break;
        default:
            eventBus.fireEvent(new ShowHomePageEvent());
        }
    } catch (NumberFormatException e) {
        // TODO: Show error screen
        GWT.log("History token : " + e.getMessage());
        eventBus.fireEvent(new ShowHomePageEvent());
    } catch (Exception e) {
        // TODO: Show error screen
        GWT.log("History token : " + e.getMessage());
        eventBus.fireEvent(new ShowHomePageEvent());
    }
}