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

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

Introduction

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

Prototype

public static void newItem(String historyToken, boolean issueEvent) 

Source Link

Document

Adds a new browser history entry.

Usage

From source file:TaskListPresenter.java

License:Open Source License

private void updateCurrentUrlForQuery(QueryRequest request) {
    // FIXME / TODO use the logic in ProjectTasksPlace.
    // Get our current page URL

    SortInfo sortInfo = request.getSortInfo();
    // Get our current parameters.
    Map<String, List<String>> urlParamMap = Navigation.getNavigationParameterMap();

    // Append our parameters as appropriate
    if (sortInfo != null) {
        updateParamInMap(urlParamMap, ProjectTasksPlace.SORTFIELD_URLPARAM, sortInfo.getSortField(),
                sortInfo.getSortField() != null);
        updateParamInMap(urlParamMap, ProjectTasksPlace.SORTORDER_URLPARAM,
                String.valueOf(sortInfo.getSortOrder()), sortInfo.getSortOrder() != null);
    }/*from w w w . j  av  a2s. c  o m*/

    Region requestRegion = request.getPageInfo();
    updateParamInMap(urlParamMap, ProjectTasksPlace.NUMRESULTS_URLPARAM,
            String.valueOf(requestRegion.getSize()),
            requestRegion.getSize() != ProjectTasksPlace.DEFAULT_PAGESIZE);
    updateParamInMap(urlParamMap, ProjectTasksPlace.STARTINDEX_URLPARAM,
            String.valueOf(requestRegion.getOffset()), requestRegion.getOffset() > 0);

    String updatedUrl = History.getToken();

    // Strip off the set of URL parameters on the current history token if they exist.
    if (updatedUrl.indexOf('?') > 0) {
        updatedUrl = updatedUrl.substring(0, updatedUrl.indexOf('?'));
    }

    // Now, loop through and write all of our parameters to our URL.
    for (String curParamName : urlParamMap.keySet()) {
        for (String curParamValue : urlParamMap.get(curParamName)) {
            updatedUrl = Navigation.appendQueryParameterToUrl(updatedUrl, curParamName, curParamValue);
        }
    }

    // Update our URL, but don't trigger a page navigation - it's already in progress.
    History.newItem(updatedUrl, false);
}

From source file:br.com.pegasus.solutions.smartgwt.lib.client.rpc.impl.GenericGwtRpcDataSource.java

License:Apache License

public GenericGwtRpcDataSource() {
    super();//from w  w w.j  a  va2 s . c o m
    setDataSourceFields();
    serviceAsync = getServiceAsync();
    this.sessionTimeOutCallback = new BooleanCallback() {
        @Override
        public void execute(Boolean value) {
            History.newItem("main", false);
            com.google.gwt.user.client.Window.Location.reload();
        }
    };
}

From source file:bz.davide.dmweb.shared.view.DMHashNavigationPanel.java

License:Open Source License

void newPage(DivViewChildElement widget, PageChangeHandler changeHandler, boolean history) {
    // Remove all the pages after the current index
    while (this.pages.size() - 1 > this.index) {
        int idx = this.pages.size() - 1;
        this.pages.remove(idx);
    }/*w w w .j  a  va2s.com*/
    if (this.pages.size() > 0) {
        int idx = this.pages.size() - 1;
        DivViewChildElement currPage = this.pages.get(idx);
        this.remove((AbstractHtmlElementView) currPage);
        PageChangeHandler tmpChangeHandler = this.changeHandlers.get(idx);
        if (tmpChangeHandler != null) {
            tmpChangeHandler.pageHide();
        }
    }
    this.pages.add(widget);
    this.changeHandlers.add(changeHandler);
    this.appendChild(widget);
    if (changeHandler != null) {
        changeHandler.pageShow();
    }
    this.index++;

    if (history) {
        History.newItem(String.valueOf(this.index), false);
    }

}

From source file:cc.alcina.framework.extras.history.client.HistoryConverterPushState.java

License:Apache License

@Override
public void convertHistoryToken() {
    String hash = Window.Location.getHash();
    if (hash == null || hash.isEmpty()) {
        if (LogConfiguration.loggingIsEnabled()) {
            LOG.fine("Hash is '" + hash + "'. Nothing to do.");
        }//w  ww.j a va  2s.  c  o m
        return;
    }
    // remove the '#' character
    if (hash.startsWith("#")) {
        hash = hash.substring(1);
    }
    // navigate to the token using pushState
    if (LogConfiguration.loggingIsEnabled()) {
        LOG.fine("Hash is '" + hash + "'. Navigating to '" + hash + "'.");
    }
    History.newItem(hash, false);
}

From source file:cc.kune.core.client.state.impl.HistoryWrapperDefault.java

License:GNU Affero Public License

@Override
public void checkHashbang() {
    final String currentToken = History.getToken();
    if (!currentToken.startsWith("!")) {
        History.newItem(HistoryUtils.hashbang(currentToken), false);
    }/*w  w w .  ja v a  2  s  .  co m*/
}

From source file:cc.kune.core.client.state.impl.HistoryWrapperDefault.java

License:GNU Affero Public License

@Override
public void newItem(final String historyToken, final boolean issueEvent) {
    History.newItem(HistoryUtils.hashbang(historyToken), issueEvent);
}

From source file:cc.kune.wave.client.WebClient.java

License:Apache License

/**
 * Shows a wave in a wave panel./*  www.  ja va  2s  . c  o m*/
 *
 * @param waveRef wave id to open
 * @param isNewWave whether the wave is being created by this client session.
 * @param participants the participants to add to the newly created wave.
 *        {@code null} if only the creator should be added
 */
private void openWaveImpl(final WaveRef waveRef, final boolean isNewWave,
        final Set<ParticipantId> participants) {
    LOG.info("WebClient.openWave()");
    NotifyUser.showProgress();

    final String waveUri = GwtWaverefEncoder.encodeToUriPathSegment(waveRef);

    contentService.getContentByWaveRef(kuneSession.getUserHash(), waveUri,
            new AsyncCallbackSimple<StateAbstractDTO>() {

                @Override
                public void onSuccess(StateAbstractDTO result) {
                    // It's a group content
                    if (result instanceof StateContentDTO) {
                        final StateContentDTO state = (StateContentDTO) result;
                        stateManager.setRetrievedStateAndGo(state);
                        SpaceSelectEvent.fire(eventBus, Space.groupSpace);
                        // If narrow, show
                        // PolymerUtils.hideInboxWithDelay();
                    } else {
                        // PolymerUtils.hideInboxCancel();;
                        // Not a group content
                        SpaceSelectEvent.fire(eventBus, Space.userSpace);
                        if (currentOpenedWaveUri.equals(waveUri)) {
                            // Trying to open twice, skip for the first time...
                            cc.kune.common.client.log.Log.info("Trying to open the same wave twice");
                            currentOpenedWaveUri = null;
                            return;
                        } else {
                            currentOpenedWaveUri = waveUri;
                        }
                        WaveClientClearEvent.fire(eventBus);
                        clear();
                        eventBus.fireEvent(new BeforeOpenWaveEvent(waveUri));
                        ;

                        // Release the display:none.
                        UIObject.setVisible(flow.getElement(), true);
                        waveHolder.getElement().appendChild(loading);
                        final Element holder = waveHolder.getElement()
                                .appendChild(Document.get().createDivElement());
                        final CustomStagesProvider wave = new CustomStagesProvider(holder, waveUnsavedIndicator,
                                waveHolder, title, waveRef, channel, idGenerator, profiles, waveStore,
                                isNewWave, Session.get().getDomain(), participants, eventBus, colorPicker,
                                customEditToolbar, ViewFactories.FIXED);
                        WebClient.this.wave = wave;

                        wave.load(new Command() {
                            @Override
                            public void execute() {
                                loading.removeFromParent();

                                NotifyUser.hideProgress();
                            }
                        });

                        eventBus.fireEvent(new AfterOpenWaveEvent(waveUri));
                        ;

                        PolymerUtils.setMainSelected();
                        if (PolymerUtils.isXSmall() || PolymerUtils.isMainDrawerNarrow())
                            PolymerUtils.setNarrowVisible(false);

                        // We can now open again the same wave without errors
                        currentOpenedWaveUri = null;
                        final String encodedToken = HistoryUtils.undoHashbang(History.getToken());

                        if (encodedToken != null && !encodedToken.isEmpty()
                                && !TokenMatcher.isInboxToken(encodedToken)
                                && !TokenMatcher.isGroupToken(encodedToken)) {
                            WaveRef fromWaveRef;
                            try {
                                fromWaveRef = GwtWaverefEncoder.decodeWaveRefFromPath(encodedToken);
                            } catch (final InvalidWaveRefException e) {
                                cc.kune.common.client.log.Log
                                        .info("History token contains invalid path: " + encodedToken);
                                return;
                            }
                            if (fromWaveRef.getWaveId().equals(waveRef.getWaveId())) {
                                // History change was caused by clicking on a link, it's already
                                // updated by browser.
                                cc.kune.common.client.log.Log.info(
                                        "History change by clicking a link, should be already in the browser bar");
                                SpaceConfEvent.fire(eventBus, Space.userSpace, encodedToken);
                                return;
                            }
                        }
                        final String tokenFromWaveref = HistoryUtils.hashbang(waveUri);
                        cc.kune.common.client.log.Log.info("Token from opened wave: " + tokenFromWaveref);
                        SpaceConfEvent.fire(eventBus, Space.userSpace, tokenFromWaveref);
                        History.newItem(tokenFromWaveref, false);
                    }
                }

            });

}

From source file:client.managers.history.HistoryManager.java

License:Open Source License

/**
 * Change the current {@link HistoryState}.
 *
 * @param state New history state./* w  w w  .j  a va  2 s . co m*/
 */
public void setState(HistoryState state) {
    currentState = state;
    History.newItem(state.getHistoryToken(), false);
}

From source file:com.agnie.gwt.common.client.mvp.AppController.java

License:Open Source License

public void onValueChange(ValueChangeEvent<String> event) {
    if (checkIfWeCanProceed()) {
        String token = event.getValue();
        GWT.log("AppContorller on value change Stringtoken==" + token);
        if (token != null) {
            Presenter presenter = getPresenterForPlace(placeMgr.getTokenToPlace(placeType, token));
            if (presenter != null) {
                presenter.go();/* w  ww  . j  ava2s.  co m*/
                presenter.postRender();
            }
        }
    } else {
        // Just roll back the history token to the one from which page change action is initiated.
        History.newItem(lastPlace.toString(), false);
    }
}

From source file:com.brainz.wokhei.client.about.AboutModulePart.java

private Label addMenuItem(Panel menu, final String title, final Panel panel, final String token) {
    Label menuItem = new Label();
    menuItem.setStyleName("labelButton");
    menuItem.addStyleName("menuItem");

    menuItem.setText(title);/* w  w w .jav  a 2  s.co m*/
    menuItem.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            _title.setText(title);
            hideAllPanels();
            panel.setVisible(true);
            _text.setVisible(false);
            History.newItem(token, false);
            applyCufon();
        }
    });

    menu.add(menuItem);

    return menuItem;

}