com.google.gwt.user.client.History Java Examples

The following examples show how to use com.google.gwt.user.client.History. 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: LoadMainApp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void execute() {
    String initialToken = History.getToken();
   /* if (!initialToken.isEmpty() && !isBlackListed(initialToken)) {
        List<PlaceRequest> hierarchy = formatter.toPlaceRequestHierarchy(initialToken);
        final PlaceRequest placeRequest = hierarchy.get(hierarchy.size() - 1);

        Scheduler.get().scheduleDeferred(() -> placeManager.revealPlace(placeRequest, true));
        bootstrapContext.setInitialPlace(placeRequest.getNameToken());
    } else {
        placeManager.revealDefaultPlace();
    }*/

    String title = productConfig.getProfile() == PRODUCT ? "JBoss EAP" : "WildFly";
    Browser.getDocument().setTitle(title + " Management");
    // TODO (hbraun): disabled until we now how this should work on a finder access (relative url's)
    placeManager.revealDefaultPlace();
}
 
Example #2
Source File: SavedHQLPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	HQLSetBackRpcRequest request = new HQLSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setAppearance(iAppearance);
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example #3
Source File: Playground.java    From caja with Apache License 2.0 6 votes vote down vote up
public void loadSource(String base, String url) {
  gui.setLoading(true);
  gui.setUrl(url);
  if (!url.equals(History.getToken())) {
    History.newItem(url);
  }
  cajolingService.fetch(base, url, new AsyncCallback<String>() {
    public void onFailure(Throwable caught) {
      gui.setLoading(false);
      gui.addRuntimeMessage(caught.getMessage());
      gui.selectTab(PlaygroundView.Tabs.RUNTIME_WARNINGS);
    }

    public void onSuccess(String result) {
      gui.setLoading(false);
      gui.setOriginalSource(result);
      gui.selectTab(PlaygroundView.Tabs.SOURCE);
    }
  });
}
 
Example #4
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 #5
Source File: PointInTimeDataReportsPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void setBack() {
	if (iFirstField == null || !iFirstField.startsWith("__") || iTable.getRowCount() <= 1) return;
	PITDSetBackRpcRequest request = new PITDSetBackRpcRequest();
	for (int i = 1; i < iTable.getRowCount(); i++) {
		String[] row = iTable.getData(i);
		if (row != null) {
			Long id = Long.valueOf(row[0]);
			request.addId(id);
		}
	}
	request.setHistory(History.getToken());
	request.setType(iFirstField);
	RPC.execute(request, new AsyncCallback<GwtRpcResponseNull>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
		}

		@Override
		public void onSuccess(GwtRpcResponseNull result) {
		}
	});
}
 
Example #6
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 #7
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 #8
Source File: GwtOLPlayground.java    From gwt-ol with Apache License 2.0 6 votes vote down vote up
@Override
public void onModuleLoad() {

    Map<String, Integer> exampleIndexMap = new HashMap<>();

    // choose your example
    TabLayoutPanel tabs = new TabLayoutPanel(27, Style.Unit.PX);

    int index = 0;

    for (OLExampleType example : OLExampleType.values()) {
        tabs.add(new LazyExampleWidget(example), example.name().replace("Example", ""));
        exampleIndexMap.put(example.name(), index);
        index++;
    }
    RootLayoutPanel.get().add(tabs);

    String token = History.getToken();

    if (token != null && exampleIndexMap.containsKey(token)) {
        tabs.selectTab(exampleIndexMap.get(token));
    }
}
 
Example #9
Source File: CurriculaPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
private void loadCurricula() {
	if (!iSearch.isEnabled()) return;
	iSearch.setEnabled(false);
	iPrint.setEnabled(false);
	iCurriculaTable.getOperations().setEnabled(false);
	final boolean newEnabled = iNew.isEnabled();
	if (newEnabled)
		iNew.setEnabled(false);
	History.newItem(iFilter.getValue(), false);
	iCurriculaTable.query(iFilter.getElementsRequest(), new AsyncCallback<TreeSet<CurriculumInterface>>() {
		@Override
		public void onFailure(Throwable caught) {
		}

		@Override
		public void onSuccess(TreeSet<CurriculumInterface> result) {
			iCurriculaTable.setVisible(true);
			iSearch.setEnabled(true);
			iPrint.setEnabled(true);
			iCurriculaTable.getOperations().setEnabled(true);
			if (newEnabled)
				iNew.setEnabled(true);
		}
	});
}
 
Example #10
Source File: TeachingAssignmentsPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
void search() {
	History.newItem(iFilterBox.getValue(), false);
	InstructorCookie.getInstance().setQuery(null, iFilterBox.getValue());
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingTeachingAssignments());
	final TeachingRequestsFilterRpcRequest filter = iFilterBox.getElementsRequest();
	RPC.execute(new TeachingAssignmentsPageRequest(filter), new AsyncCallback<GwtRpcResponseList<InstructorInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iFilterBox.setErrorHint(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingAssignments(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<InstructorInfo> result) {
			LoadingWidget.getInstance().hide();
			iTable.populate(result);
			iTable.setVisible(true);
		}
	});
}
 
Example #11
Source File: TeachingRequestsPage.java    From unitime with Apache License 2.0 6 votes vote down vote up
void search() {
	History.newItem(iFilterBox.getValue(), false);
	InstructorCookie.getInstance().setQuery(iAssigned, iFilterBox.getValue());
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingTeachingRequests());
	final TeachingRequestsFilterRpcRequest filter = iFilterBox.getElementsRequest();
	RPC.execute(new TeachingRequestsPageRequest(filter), new AsyncCallback<GwtRpcResponseList<TeachingRequestInfo>>() {
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iFilterBox.setErrorHint(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadTeachingRequests(caught.getMessage()), caught);
		}

		@Override
		public void onSuccess(GwtRpcResponseList<TeachingRequestInfo> result) {
			LoadingWidget.getInstance().hide();
			iTable.populate(result, filter);
			iTable.setVisible(true);
		}
	});
}
 
Example #12
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 #13
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 #14
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 #15
Source File: DocumentationDisplay.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void redraw(boolean autoScroll) {
	if (autoScroll) {
		String historyToken = History.getToken();
		if (!Strings.isNullOrEmpty(historyToken)) {
			int top = this.affixMenu.getPinnedOffset();
			Window.scrollTo(Window.getScrollLeft(), top);
		} else {
			Window.scrollTo(Window.getScrollLeft(), 0);
		}
	}
}
 
Example #16
Source File: GwtOLPlayground.java    From gwt-ol with Apache License 2.0 5 votes vote down vote up
@Override public void setVisible(boolean visible) {
    if (visible && !initialized) {
        Scheduler.get().scheduleDeferred(() -> example.getExample().show(example.getExample().toString()));
        initialized = true;
    }
    super.setVisible(visible);

    if (visible) {
        History.newItem(example.name());
    }
}
 
Example #17
Source File: WebClient.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * This is the entry point method.
 */
@Override
public void onModuleLoad() {

  ErrorHandler.install();

  ClientEvents.get().addWaveCreationEventHandler(
      new WaveCreationEventHandler() {

        @Override
        public void onCreateRequest(WaveCreationEvent event, Set<ParticipantId> participantSet) {
          LOG.info("WaveCreationEvent received");
          if (channel == null) {
            throw new RuntimeException("Spaghetti attack.  Create occured before login");
          }
          openWave(WaveRef.of(idGenerator.newWaveId()), true, participantSet);
        }
      });

  setupLocaleSelect();
  setupConnectionIndicator();

  HistorySupport.init(new HistoryProviderDefault());
  HistoryChangeListener.init();

  websocket = new WaveWebSocketClient(websocketNotAvailable(), getWebSocketBaseUrl());
  websocket.connect();

  if (Session.get().isLoggedIn()) {
    loggedInUser = new ParticipantId(Session.get().getAddress());
    idGenerator = ClientIdGenerator.create();
    loginToServer();
  }

  setupUi();
  setupStatistics();

  History.fireCurrentHistoryState();
  LOG.info("SimpleWebClient.onModuleLoad() done");
}
 
Example #18
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 #19
Source File: WebClient.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * This is the entry point method.
 */
@Override
public void onModuleLoad() {

  ErrorHandler.install();

  ClientEvents.get().addWaveCreationEventHandler(
      new WaveCreationEventHandler() {

        @Override
        public void onCreateRequest(WaveCreationEvent event, Set<ParticipantId> participantSet) {
          LOG.info("WaveCreationEvent received");
          if (channel == null) {
            throw new RuntimeException("Spaghetti attack.  Create occured before login");
          }
          openWave(WaveRef.of(idGenerator.newWaveId()), true, participantSet);
        }
      });

  setupLocaleSelect();
  setupConnectionIndicator();

  HistorySupport.init(new HistoryProviderDefault());
  HistoryChangeListener.init();

  websocket = new WaveWebSocketClient(websocketNotAvailable(), getWebSocketBaseUrl());
  websocket.connect();

  if (Session.get().isLoggedIn()) {
    loggedInUser = new ParticipantId(Session.get().getAddress());
    idGenerator = ClientIdGenerator.create();
    loginToServer();
  }

  setupUi();
  setupStatistics();

  History.fireCurrentHistoryState();
  LOG.info("SimpleWebClient.onModuleLoad() done");
}
 
Example #20
Source File: PagedView.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void showPage(int index) {


        // notify callbacks
        for(PageCallback callback : callbacks)
            callback.onRevealPage(index);


        if(!navOnFirstPage && navigationBar!=null)
        {
            // navigation only on subsequent pages
            if(index>0)
            {

                layout.setWidgetHidden(navigationBar, false);
            }
            else
            {
                layout.setWidgetHidden(navigationBar, true);
            }
        }

         // TODO: clear history tokens
        if(index==0)
        {
            PlaceManager placeManager = Console.getPlaceManager();
            String nameToken = placeManager.getCurrentPlaceRequest().getNameToken();
            History.newItem(nameToken, false);
        }

        deck.showWidget(index);
        bar.setActive(index);
    }
 
Example #21
Source File: ReservationsPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void loadReservations() {
	if (!iSearch.isEnabled()) return;
	iSearch.setEnabled(false);
	iPrint.setEnabled(false);
	final boolean newEnabled = iNew.isEnabled();
	if (newEnabled)
		iNew.setEnabled(false);
	History.newItem(iFilter.getValue(), false);
	LoadingWidget.getInstance().show(MESSAGES.waitLoadingReservations());
	iReservationTable.query(iFilter.getElementsRequest(), new AsyncCallback<List<ReservationInterface>>() {
		@Override
		public void onSuccess(List<ReservationInterface> result) {
			LoadingWidget.getInstance().hide();
			iSearch.setEnabled(true);
			iPrint.setEnabled(true);
			if (newEnabled)
				iNew.setEnabled(true);
			if (iLastReservationId != null) {
				iReservationTable.select(iLastReservationId);
				iReservationTable.scrollIntoView(iLastReservationId);
			}
		}
		
		@Override
		public void onFailure(Throwable caught) {
			LoadingWidget.getInstance().hide();
			iReservationTable.setErrorMessage(MESSAGES.failedToLoadReservations(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToLoadReservations(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}
	});
}
 
Example #22
Source File: Ode.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public void openYoungAndroidProjectInDesigner(final Project project) {
  ProjectRootNode projectRootNode = project.getRootNode();
  if (projectRootNode == null) {
    // The project nodes haven't been loaded yet.
    // Add a ProjectChangeListener so we'll be notified when they have been loaded.
    project.addProjectChangeListener(new ProjectChangeAdapter() {
      @Override
      public void onProjectLoaded(Project glass) {
        project.removeProjectChangeListener(this);
        openYoungAndroidProjectInDesigner(project);
      }
    });
    project.loadProjectNodes();

  } else {
    // The project nodes have been loaded. Tell the viewer to open
    // the project. This will cause the projects source files to be fetched
    // asynchronously, and loaded into file editors.
    ViewerBox.getViewerBox().show(projectRootNode);
    // Note: we can't call switchToDesignView until the Screen1 file editor
    // finishes loading. We leave that to setCurrentFileEditor(), which
    // will get called at the appropriate time.
    String projectIdString = Long.toString(project.getProjectId());
    if (!History.getToken().equals(projectIdString)) {
      // insert token into history but do not trigger listener event
      History.newItem(projectIdString, false);
    }
    if (assetManager == null) {
      assetManager = AssetManager.getInstance();
    }
    assetManager.loadAssets(project.getProjectId());
  }
  getTopToolbar().updateFileMenuButtons(1);
}
 
Example #23
Source File: MobileUniTimeFrameDialogImpl.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void openDialog(String title, String source, String width, String height, boolean noCacheTS) {
	if (isShowing()) hideDialog();
	GwtHint.hideHint();
	
	iScrollLeft = Window.getScrollLeft(); iScrollTop = Window.getScrollTop();
	Window.scrollTo(0, 0);

	LoadingWidget.getInstance().show("Loading " + title + " ...");
	setText(title);
	if (noCacheTS) {
		String hash = null;
		int hashIdx = source.lastIndexOf('#');
		if (hashIdx >= 0) {
			hash = source.substring(hashIdx);
			source = source.substring(0, hashIdx);
		}
		iFrame.setUrl(source + (source.indexOf('?') >= 0 ? "&" : "?") + "noCacheTS=" + new Date().getTime() + (hash == null ? "" : hash));
	} else {
		iFrame.setUrl(source);
	}
	iCheckLoadingWidgetIsShowing.schedule(30000);
	
	History.newItem(title, false);
	iPopup.setPopupPosition(0, 0);
	iPopup.show();
	RootPanel.getBodyElement().getStyle().setOverflow(Overflow.HIDDEN);
}
 
Example #24
Source File: AppController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
public void go(final HasWidgets container) {
	logger.info("app view going...");
	this.container = container;

	if ("".equals(History.getToken())) {
		History.newItem("monitor");
	} else {
		History.fireCurrentHistoryState();
	}
}
 
Example #25
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 #26
Source File: HistoryGwtApi.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected void initStartState() {
    // we need to add new history tokens BEFORE ValueChangeHandler will added
    if (urlHasToken(TOP_HISTORY_TOKEN)) {
        History.newItem(PREVIOUS_HISTORY_TOKEN);
        // if init url has TOP_HISTORY_TOKEN, we inform what PREVIOUS_HISTORY_TOKEN should be fired,
        // otherwise not all state variables will have proper values
        isFireHistoryState = true;
    } else {
        History.newItem(TOP_HISTORY_TOKEN);
    }
}
 
Example #27
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 #28
Source File: AbstractButton.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Set the target history token for the widget. Note, that you should use either
 * {@link #setTargetHistoryToken(String)} or {@link #setHref(String)}, but not both as
 * {@link #setHref(String)} resets the target history token.
 *
 * @param targetHistoryToken String target history token of the widget
 */
@Override
public void setTargetHistoryToken(final String targetHistoryToken) {
    this.targetHistoryToken = targetHistoryToken;
    if (targetHistoryToken != null) {
        setHref("#" + History.encodeHistoryToken(targetHistoryToken));
    }
}
 
Example #29
Source File: Game.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
public void loadPuzzle(final Long id) {
    status.setText("Loading puzzle...");
    status.setStyleName(css.statusInfo());

    if (request == null) {
        request = service.findPuzzle(id,
                new AsyncCallback<Puzzle>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        Window.alert(caught.toString());
                    }

                    @Override
                    public void onSuccess(Puzzle result) {
                        History.newItem("play=" + id, false);
                        startPuzzle(id, result);
                        request = null;
                        status.setStyleName(css.statusHidden());
                        status.setText(" ");
                    }
                });
    } else {
        request.cancel();
        request = null;
        loadPuzzle(id);
    }
}
 
Example #30
Source File: SavedHQLPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void loadQueries(final Long select, final boolean reload) {
	if (!LoadingWidget.getInstance().isShowing())
		LoadingWidget.getInstance().show(MESSAGES.waitLoadingReports());
	RPC.execute(new HQLQueriesRpcRequest(iAppearance), new AsyncCallback<GwtRpcResponseList<Query>>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
			LoadingWidget.getInstance().hide();
		}
		@Override
		public void onSuccess(GwtRpcResponseList<Query> result) {
			String selected = (select == null ? null : select.toString());
			if (selected == null && iQuerySelector.getWidget().getSelectedIndex() >= 0) {
				selected = iQuerySelector.getWidget().getValue(iQuerySelector.getWidget().getSelectedIndex());
			}
			iQuerySelector.getWidget().clear();
			if (result.isEmpty()) {
				iHeader.setErrorMessage(MESSAGES.errorNoReportsAvailable());
			} else {
				iQuerySelector.getWidget().addItem(MESSAGES.itemSelect(), "-1");
				iQueries = result;
				for (int i = 0; i < result.size(); i++) {
					iQuerySelector.getWidget().addItem(result.get(i).getName(), result.get(i).getId().toString());
					if (selected != null && selected.equals(result.get(i).getId().toString()))
						iQuerySelector.getWidget().setSelectedIndex(1 + i);
				}
				queryChanged();
			}
			LoadingWidget.getInstance().hide();
			if (reload) reload(History.getToken());
		}
	});
}