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

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

Introduction

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

Prototype

public static HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) 

Source Link

Document

Adds a ValueChangeEvent handler to be informed of changes to the browser's history stack.

Usage

From source file:asquare.gwt.tests.history.client.Demo.java

License:Apache License

public void onModuleLoad() {
    TabCollection tabSet = new TabCollection();
    tabSet.add("grains", "Grains", createGrains());
    tabSet.add("vegetables", "Vegetables", createVegetables());
    tabSet.add("fruit", "Fruit", createFruit());
    tabSet.add("stimulants", "Stimulants", createStimulants());

    TabPanel tabPanel = new TabPanel();
    for (int i = 0; i < tabSet.size(); i++) {
        tabPanel.add(tabSet.getWidget(i), tabSet.getDescription(i));
    }//from w  w  w  .j  a v a 2 s .  c om

    String initialTabToken = History.getToken();
    if (initialTabToken.length() == 0) {
        initialTabToken = tabSet.getToken(0);
    }
    TabController controller = new TabController(tabSet, tabPanel, initialTabToken);
    tabPanel.addSelectionHandler(controller);
    History.addValueChangeHandler(controller);

    RootPanel.get().add(tabPanel);
}

From source file:asquare.gwt.tkdemo.client.Demo.java

License:Apache License

public void onModuleLoad() {
    Debug.enableSilently();//from   www  .j a  v a2 s .com

    final AppPanelCollection panels = new DemoPanelCollection();

    String initialTabToken = History.getToken();
    int initialIndex = panels.getIndexForToken(initialTabToken);
    if (initialIndex == -1) {
        initialIndex = 0;
    }

    // use a table for border to work around bugs with 100% child width
    RowPanel outer = new RowPanel();
    DomUtil.setAttribute(outer, "id", "main");
    outer.setWidth("100%");

    ExposedCellPanel tabPanel = new ColumnPanel();
    tabPanel.setSize("100%", "100%");

    CTabBar tabbar = new CTabBar(new ListWidgetVTable(), new SideTabRenderer3());
    tabbar.removeController(tabbar.getController(CompositeCellViewHoverController.class));
    tabbar.setStyleName("DemoTabBar");
    History.addValueChangeHandler(new TabModelUpdateController(panels, tabbar.getListModel()));
    tabPanel.add(tabbar);
    tabPanel.setCellStyleName("DemoTabPanel-tabBar");

    tabPanel.add(new HTML("<h2 style='text-align: center; width: 100%; height: 100%;'>Loading...</h2>"));
    tabPanel.setCellStyleName("DemoTabPanel-tabBody");
    tabPanel.setCellWidth("100%");
    new TabBodyUpdateController(tabbar.getListModel(), tabPanel, panels);

    outer.add(tabPanel);
    RootPanel.get().add(outer);

    BrowserInfo browserInfo = (BrowserInfo) GWT.create(BrowserInfo.class);
    String compatMode = describeCompatMode();
    Label env = new Label(compatMode + " (" + browserInfo.getUserAgent() + ")");
    env.setStyleName("compatMode");
    outer.add(env);

    new DebugElementDumpInspector().install();

    /**
    * Incrementally add tabs to TabBar, allowing the UI to redraw to show
    * progress.
    */
    DeferredCommand.addCommand(new LoadUICommand(panels, tabbar, initialIndex));
}

From source file:burrito.client.crud.CrudPanel.java

License:Apache License

public CrudPanel() {
    History.addValueChangeHandler(this);
    wrapper.add(top, DockPanel.NORTH);// w w  w. j  a va  2  s  .  c  o m
    content.addStyleName("k5-CrudPanel-content");
    top.addStyleName("k5-CrudPanel-top");
    wrapper.add(content, DockPanel.CENTER);

    initWidget(wrapper);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            History.fireCurrentHistoryState();
        }
    });
    addStyleName("k5-CrudPanel");
    setWidth("100%");
}

From source file:burrito.client.sitelet.SiteletAdminPanel.java

License:Apache License

public SiteletAdminPanel(String containerName) {
    this.containerName = containerName;
    wrapper.add(new VerticalSpacer(20));
    wrapper.add(contentPlaceHolder);/*from  w  w w .j av a  2  s.  c om*/
    contentPlaceHolder.addStyleName("k5-SiteletAdminPanel-content");
    initWidget(wrapper);
    addStyleName("k5-SiteletAdminPanel");
    setWidth("100%");
    History.addValueChangeHandler(this);
    History.fireCurrentHistoryState();
}

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

License:Open Source License

@Override
public void onAttachOrDetach(AttachEvent event) {
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override/*from ww  w  . j a v  a 2  s.  c o  m*/
        public void onValueChange(ValueChangeEvent<String> event) {
            String pageIndex = event.getValue();
            if (pageIndex == null || pageIndex.length() == 0) {
                pageIndex = "0";
            }
            DMHashNavigationPanelAttachHandler.this.navigationPanel.navigate(Integer.parseInt(pageIndex));
        }
    });

}

From source file:cc.alcina.framework.gwt.client.ClientBase.java

License:Apache License

protected void initInitialTokenHandler0() {
    initialHistoryToken = History.getToken();
    isFirstHistoryTokenHandlerRegistration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override/*  ww  w . ja v a  2 s  .c  o m*/
        public void onValueChange(ValueChangeEvent<String> event) {
            if (History.getToken().equals(initialHistoryToken)) {
                return;
            }
            isFirstHistoryToken = false;
            if (isFirstHistoryTokenHandlerRegistration != null) {
                isFirstHistoryTokenHandlerRegistration.removeHandler();
                isFirstHistoryTokenHandlerRegistration = null;
            }
        }
    });
}

From source file:cc.alcina.framework.gwt.client.stdlayout.MainCmpBase.java

License:Apache License

@Override
protected void onAttach() {
    this.historyHandlerRegistration = History.addValueChangeHandler(this);
    super.onAttach();
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java

License:Apache License

/**
 * Set the showing state of the popup. If maybeAnimate is true, the
 * animation will be used to set the state. If it is false, the animation
 * will be cancelled./*from   w  ww . jav  a2s .co m*/
 * 
 * @param showing
 *            the new state
 * @param maybeAnimate
 *            true to possibly run the animation
 */
private void setState(boolean showing, boolean maybeAnimate) {
    if (maybeAnimate) {
        resizeAnimation.setState(showing);
    } else {
        resizeAnimation.cancel();
    }
    this.showing = showing;
    // Create or remove the native preview handler
    if (showing) {
        nativePreviewHandlerRegistration = Event.addNativePreviewHandler(new NativePreviewHandler() {
            public void onPreviewNativeEvent(NativePreviewEvent event) {
                previewNativeEvent(event);
            }
        });
        historyHandlerRegistration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                if (autoHideOnHistoryEvents) {
                    hide();
                }
            }
        });
    } else {
        if (nativePreviewHandlerRegistration != null) {
            nativePreviewHandlerRegistration.removeHandler();
            nativePreviewHandlerRegistration = null;
        }
        if (historyHandlerRegistration != null) {
            historyHandlerRegistration.removeHandler();
            historyHandlerRegistration = null;
        }
    }
}

From source file:cc.kune.core.client.ws.CoreViewImpl.java

License:GNU Affero Public License

/**
 * Instantiates a new core view.//w  w w  . ja v  a 2  s .  c o m
 *
 * @param armor
 *          the body
 * @param stateManager
 *          the state manager
 */
@Inject
public CoreViewImpl(final GSpaceArmorPolymer armor, final StateManagerDefault stateManager) {
    CommonResources.INSTANCE.commonStyle().ensureInjected();
    GWT.<CoreResources>create(CoreResources.class).coreCss().ensureInjected();
    GWT.<GSpaceArmorResources>create(GSpaceArmorResources.class).style().ensureInjected();
    History.addValueChangeHandler(stateManager);
}

From source file:ch.unifr.pai.twice.widgets.mpproxy.client.navig.Navigation.java

License:Apache License

public Navigation() {
    super();/*from  w ww  .ja va  2 s  . com*/
    element = DOM.getElementById("miceUrlBox");
    if (element != null) {
        urlBox = TextBox.wrap(element);
        History.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                updateAddressBar();
            }
        });

        urlBox.setHeight("25px");
        urlBox.getElement().getStyle().setFontSize(20, Unit.PX);
        urlBox.setWidth("100%");
        urlBox.addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                // Window.alert(Window.Location.getProtocol()+"//"+Window.Location.getHost()+"/"+event.getValue());
                Window.Location.replace(Window.Location.getProtocol() + "//" + Window.Location.getHost() + "/"
                        + event.getValue());
                // TODO Auto-generated method stub

            }
        });
        urlBox.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent event) {
            }
        });
    }
}