Java Code Examples for com.google.gwt.user.client.History#addValueChangeHandler()

The following examples show how to use com.google.gwt.user.client.History#addValueChangeHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Playground.java    From caja with Apache License 2.0 6 votes vote down vote up
public void onModuleLoad() {
  gui = new PlaygroundView(this);
  gui.setLoading(true);
  cajolingService.getBuildInfo(new AsyncCallback<String>() {
    public void onFailure(Throwable caught) {
      gui.setLoading(false);
      gui.addRuntimeMessage(caught.getMessage());
      gui.setVersion("Unknown");
    }

    public void onSuccess(String result) {
      gui.setLoading(false);
      gui.setVersion(result);
    }
  });
  History.addValueChangeHandler(this);
  History.fireCurrentHistoryState();
}
 
Example 2
Source File: HistoryChangeListener.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Commonly we start to listen history changes when webclient starts calling this
 * method. If you are using wave client integrated with other different GWT application
 * and with a different History management, you can avoid to use this and just
 * call to the {@link WaveSelectionEvent} events (for example) or other uses.
 */
public static void init() {
  History.addValueChangeHandler(new ValueChangeHandler<String>() {
    @Override
    public void onValueChange(ValueChangeEvent<String> event) {
      String encodedToken = event.getValue();
      if (encodedToken == null || encodedToken.length() == 0) {
        return;
      }
      WaveRef waveRef;
      try {
        waveRef = GwtWaverefEncoder.decodeWaveRefFromPath(encodedToken);
      } catch (InvalidWaveRefException e) {
        LOG.info("History token contains invalid path: " + encodedToken);
        return;
      }
      LOG.info("Changing selected wave based on history event to " + waveRef.toString());
      ClientEvents.get().fireEvent(new WaveSelectionEvent(waveRef));
    }
  });
}
 
Example 3
Source File: EventPreviewAutoHiderRegistrar.java    From swellrt with Apache License 2.0 6 votes vote down vote up
@Override
public void registerAutoHider(final AutoHider autoHider) {
  autoHider.setRegistered(true);
  autoHiders.add(autoHider);

  if (eventPreviewRegistration == null) {
    eventPreviewRegistration = Event.addNativePreviewHandler(this);
  }

  if (onResizeRegistration == null) {
    onResizeRegistration = Window.addResizeHandler(this);
  }

  if (onHistoryRegistration == null) {
    onHistoryRegistration = History.addValueChangeHandler(this);
  }
}
 
Example 4
Source File: HistoryChangeListener.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Commonly we start to listen history changes when webclient starts calling this
 * method. If you are using wave client integrated with other different GWT application
 * and with a different History management, you can avoid to use this and just
 * call to the {@link WaveSelectionEvent} events (for example) or other uses.
 */
public static void init() {
  History.addValueChangeHandler(new ValueChangeHandler<String>() {
    @Override
    public void onValueChange(ValueChangeEvent<String> event) {
      String encodedToken = event.getValue();
      if (encodedToken == null || encodedToken.length() == 0) {
        return;
      }
      WaveRef waveRef;
      try {
        waveRef = GwtWaverefEncoder.decodeWaveRefFromPath(encodedToken);
      } catch (InvalidWaveRefException e) {
        LOG.info("History token contains invalid path: " + encodedToken);
        return;
      }
      LOG.info("Changing selected wave based on history event to " + waveRef.toString());
      ClientEvents.get().fireEvent(new WaveSelectionEvent(waveRef));
    }
  });
}
 
Example 5
Source File: EventPreviewAutoHiderRegistrar.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
@Override
public void registerAutoHider(final AutoHider autoHider) {
  autoHider.setRegistered(true);
  autoHiders.add(autoHider);

  if (eventPreviewRegistration == null) {
    eventPreviewRegistration = Event.addNativePreviewHandler(this);
  }

  if (onResizeRegistration == null) {
    onResizeRegistration = Window.addResizeHandler(this);
  }

  if (onHistoryRegistration == null) {
    onHistoryRegistration = History.addValueChangeHandler(this);
  }
}
 
Example 6
Source File: Header.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Inject
public Header(final FeatureSet featureSet, final ToplevelTabs toplevelTabs, MessageCenter messageCenter,
              ProductConfig productConfig, BootstrapContext bootstrap, PlaceManager placeManager,
              Harvest harvest, Index index, PerspectiveStore perspectiveStore) {
    this.featureSet = featureSet;
    this.toplevelTabs = toplevelTabs;
    this.messageCenter = messageCenter;
    this.productConfig = productConfig;
    this.bootstrap = bootstrap;
    this.placeManager = placeManager;
    this.harvest = harvest;
    this.index = index;
    this.perspectiveStore = perspectiveStore;
    History.addValueChangeHandler(this);

    placeManager.getEventBus().addHandler(BreadcrumbEvent.TYPE, this);
}
 
Example 7
Source File: DemoGwtWebApp.java    From demo-gwt-springboot with Apache License 2.0 5 votes vote down vote up
private void setupHistory() {
	History.newItem(HISTORY_MAIN);

	// Add history listener
	History.addValueChangeHandler(new ValueChangeHandler<String>() {
		@Override
		public void onValueChange(ValueChangeEvent<String> event) {
			String token = event.getValue();
			if (!token.equals(HISTORY_MAIN)) {
				History.newItem(HISTORY_MAIN);
			}
		}
	});
}
 
Example 8
Source File: HistoryGwtApi.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void initHandler() {
    handlerRegistration = History.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            String historyToken = event.getValue();
            if (isForward) {
                isForward = false;
                // here we assume that "forward" action was performed
                // and if current history token equals to TOP_HISTORY_TOKEN
                // then this is true, otherwise we ignore
                if (TOP_HISTORY_TOKEN.equals(historyToken)) {
                    handleHistoryStep();
                }
            } else {
                if (!TOP_HISTORY_TOKEN.equals(historyToken)) {
                    // if current history token equals to previous history token
                    // then we assume that "back" action was performed
                    if (previousHistoryToken.equals(historyToken)) {
                        isForward = true;
                    } else {
                        // otherwise we assume that some handmade token was processed
                        // and replace it with PREVIOUS_HISTORY_TOKEN
                        previousHistoryToken = historyToken;
                        History.newItem(PREVIOUS_HISTORY_TOKEN);
                    }
                }
                // we always must have TOP_HISTORY_TOKEN on top of history stack
                // if it is, then History will ignore the call of newItem method.
                History.newItem(TOP_HISTORY_TOKEN);
            }
        }
    });
    if (isFireHistoryState)
        History.fireCurrentHistoryState();
}
 
Example 9
Source File: UniTimeBack.java    From unitime with Apache License 2.0 5 votes vote down vote up
public UniTimeBack() {
	History.addValueChangeHandler(new ValueChangeHandler<String>() {
		@Override
		public void onValueChange(ValueChangeEvent<String> event) {
			if (event.getValue() == null || event.getValue().isEmpty() || "back".equals(event.getValue())) {
				open(GWT.getHostPageBaseURL() + "back.do?uri=" + iBackUrl);
			} else {
				String uri = token2uri(event.getValue().replace("%20", " "));
				if (uri != null)
					open(GWT.getHostPageBaseURL() + "back.do?uri=" + uri);
			}
		}
	});
}
 
Example 10
Source File: ToDoPresenter.java    From blog with MIT License 5 votes vote down vote up
/**
 * Set up the history changed handler, which provides routing.
 */
private void setupHistoryHandler() {
	History.addValueChangeHandler(new ValueChangeHandler<String>() {
		public void onValueChange(ValueChangeEvent<String> event) {
			String historyToken = event.getValue();
			routing = parseRoutingToken(historyToken);
			view.setRouting(routing);
			updateFilteredList();
		}
	});
}
 
Example 11
Source File: Game.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
@Inject
public Game(RootPanel rootPanel, PuzzleServiceProxy service,
    Resources resources, final PuzzleListView plv, Renderer renderer) {
    this.service = service;
    this.plv = plv;
    this.renderer = renderer;
    this.css = resources.css();

    History.newItem("list", false);
    History.addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                if (event.getValue().equals("list")) {
                    if (closingRegistration != null) {
                        closingRegistration.removeHandler();
                        closingRegistration = null;
                    }

                    if (autoSaveTimer != null) {
                        autoSaveTimer.cancel();
                        autoSaveTimer.run();
                        autoSaveTimer = null;
                    }

                    mainPanel.setWidget(plv);
                    keyboardIntercept.removeKeyboardListener(l);

                    getDisplayChangeListener().onDisplayChange();
                } else if (event.getValue().startsWith("play=")) {
                    Long id = Long.parseLong(event.getValue().split("=")[1]);
                    loadPuzzle(id);
                }
            }
        });
    verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.setWidth("100%");
    StyleInjector.inject(resources.css().getText());
    keyboardIntercept.setWidth("1px");
    keyboardIntercept.setHeight("1px");
    keyboardIntercept.setStyleName(css.keyboardIntercept());
    rootPanel.add(keyboardIntercept);

    verticalPanel.add(status);
    verticalPanel.setCellHorizontalAlignment(status,
        HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(mainPanel);
    verticalPanel.setCellHorizontalAlignment(mainPanel,
        HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(below);
    display.add(verticalPanel);
    display.setWidth("97%");
    rootPanel.add(display);
}
 
Example 12
Source File: DefaultHistoryProxy.java    From mvp4g with Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<String> handler) {
  return History.addValueChangeHandler(handler);
}