@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public TransitionAnchor provide(Class<?>[] typeargs, Annotation[] qualifiers) { Class<?> toPageType = typeargs[0]; return new TransitionAnchor(navigation, toPageType, htFactory); }
/** * Creates a new TransitionAnchor with the given attributes. * * @param navigation * The navigation system this page transition participates in. * @param toPage * The page type this transition goes to. Not null. * @param state * The page state. Cannot be null (but can be an empty multimap) * @throws NullPointerException * if any of the arguments are null. */ TransitionAnchor(Navigation navigation, final Class<P> toPage, final Multimap<String, String> state, HistoryTokenFactory htFactory) { this.navigation = Assert.notNull(navigation); this.toPageWidgetType = Assert.notNull(toPage); this.state = Assert.notNull(state); this.htFactory = Assert.notNull(htFactory); addClickHandler(this); addAttachHandler(new Handler() { @Override public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) initHref(toPage, state); } }); }
/** * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent) */ @Override public void onClick(ClickEvent event) { if (isEnabled()) navigation.goTo(toPageWidgetType, this.state); event.stopPropagation(); event.preventDefault(); }
/** * Initialize the anchor's href attribute. * * @param toPage * The page type this transition goes to. Not null. * @param state * The page state. Cannot be null (but can be an empty multimap) */ private void initHref(Class<P> toPage, Multimap<String, String> state) { PageNode<P> toPageInstance = navigation.getNavGraph().getPage(toPage); HistoryToken token = htFactory.createHistoryToken(toPageInstance.name(), state); String href = "#" + token.toString(); setHref(href); }
/** * Creates a new TransitionAnchor with the given attributes. * * @param navigation * The navigation system this page transition participates in. * @param toPage * The page type this transition goes to. Not null. * @param state * The page state. Cannot be null (but can be an empty multimap) * @throws NullPointerException * if any of the arguments are null. */ TransitionAnchor(Navigation navigation, final Class<P> toPage, final Multimap<String, String> state, HistoryTokenFactory htFactory) { this.navigation = Assert.notNull(navigation); this.toPageWidgetType = Assert.notNull(toPage); this.state = Assert.notNull(state); this.htFactory = Assert.notNull(htFactory); addClickHandler(this); addAttachHandler(new Handler() { @Override public void onAttachOrDetach(AttachEvent event) { if (event.isAttached()) initHref(toPage, state); } }); }
/** * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent) */ @Override public void onClick(ClickEvent event) { if (isEnabled()) navigation.goTo(toPageWidgetType, this.state); event.stopPropagation(); event.preventDefault(); }
/** * Initialize the anchor's href attribute. * * @param toPage * The page type this transition goes to. Not null. * @param state * The page state. Cannot be null (but can be an empty multimap) */ private void initHref(Class<P> toPage, Multimap<String, String> state) { PageNode<P> toPageInstance = navigation.getNavGraph().getPage(toPage); HistoryToken token = htFactory.createHistoryToken(toPageInstance.name(), state); String href = "#" + token.toString(); setHref(href); }
/** * Gets an instance of a {@link TransitionAnchor} without any additional * {@link PageState}. */ public TransitionAnchor<P> get() { return new TransitionAnchor<P>(navigation, toPageWidgetType, htFactory); }
/** * Gets an instance of a {@link TransitionAnchor} with the given {@link PageState}. * @param state */ public TransitionAnchor<P> get(Multimap<String, String> state) { return new TransitionAnchor<P>(navigation, toPageWidgetType, state, htFactory); }
/** * Gets an instance of a {@link TransitionAnchor} without any additional * {@link PageState}. */ public TransitionAnchor<P> get() { return new TransitionAnchor<P>(navigation, toPageWidgetType, htFactory); }
/** * Gets an instance of a {@link TransitionAnchor} with the given {@link PageState}. * @param state */ public TransitionAnchor<P> get(Multimap<String, String> state) { return new TransitionAnchor<P>(navigation, toPageWidgetType, state, htFactory); }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public TransitionAnchor provide(Class<?>[] typeargs, Annotation[] qualifiers) { Class<?> toPageType = typeargs[0]; return new TransitionAnchor(navigation, toPageType, htFactory); }
/** * Gets an instance of a {@link TransitionAnchor} with the given single piece of * {@link PageState}. This is a convenience for the use-case where the target * {@link Page} has a single piece of state, such as a UUID. * @param stateKey * @param stateValue */ public TransitionAnchor<P> get(String stateKey, String stateValue) { Multimap<String, String> state = HashMultimap.create(); state.put(stateKey, stateValue); return new TransitionAnchor<P>(navigation, toPageWidgetType, state, htFactory); }
/** * Gets an instance of a {@link TransitionAnchor} with the given single piece of * {@link PageState}. This is a convenience for the use-case where the target * {@link Page} has a single piece of state, such as a UUID. * @param stateKey * @param stateValue */ public TransitionAnchor<P> get(String stateKey, String stateValue) { Multimap<String, String> state = HashMultimap.create(); state.put(stateKey, stateValue); return new TransitionAnchor<P>(navigation, toPageWidgetType, state, htFactory); }