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

The following examples show how to use com.google.gwt.user.client.History. These examples are extracted from open source projects. 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 Project: unitime   Source File: TeachingRequestsPage.java    License: 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 2
Source Project: unitime   Source File: TeachingAssignmentsPage.java    License: 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 3
Source Project: unitime   Source File: CurriculaPage.java    License: 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 4
Source Project: unitime   Source File: PointInTimeDataReportsPage.java    License: 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 5
Source Project: unitime   Source File: SavedHQLPage.java    License: 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 6
Source Project: caja   Source File: Playground.java    License: 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 7
Source Project: caja   Source File: Playground.java    License: 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 8
Source Project: swellrt   Source File: HistoryChangeListener.java    License: 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 9
Source Project: swellrt   Source File: EventPreviewAutoHiderRegistrar.java    License: 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 10
Source Project: gwt-ol   Source File: GwtOLPlayground.java    License: 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 11
/**
 * 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 12
@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 13
Source Project: core   Source File: Header.java    License: 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 14
Source Project: core   Source File: LoadMainApp.java    License: 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 15
Source Project: EasyML   Source File: AppController.java    License: 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 16
Source Project: appinventor-extensions   Source File: Ode.java    License: 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 17
Source Project: demo-gwt-springboot   Source File: DemoGwtWebApp.java    License: 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 18
Source Project: cuba   Source File: HistoryGwtApi.java    License: 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 19
Source Project: cuba   Source File: HistoryGwtApi.java    License: 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 20
Source Project: gwt-material   Source File: AbstractButton.java    License: 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 21
Source Project: shortyz   Source File: Game.java    License: 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 22
Source Project: unitime   Source File: MobileUniTimeFrameDialogImpl.java    License: 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 23
Source Project: unitime   Source File: EventResourceTimetable.java    License: Apache License 2.0 5 votes vote down vote up
public HistoryToken(PageType type) {
	iType = type.name();
	
	// 1. take page type defaults --> DEFAULTS
	if (type.getParams() != null)
		for (int i = 0; 1 + i < type.getParams().length; i += 2)
			iDefaults.put(type.getParams()[i], type.getParams()[i + 1]);

	// 2. take page parameters --> DEFAULTS (on top of the page type defaults)
	for (Map.Entry<String, List<String>> params: Window.Location.getParameterMap().entrySet())
		iDefaults.put(params.getKey(), params.getValue().get(0));
	
	// 3. take cookie --> PARAMS (override defaults)
	String cookie = EventCookie.getInstance().getHash(iType);
	if (cookie != null) {
		for (String pair: cookie.split("\\&")) {
			int idx = pair.indexOf('=');
			if (idx >= 0) {
				String key = pair.substring(0, idx);
				if (Location.getParameter(key) == null)
					iParams.put(key, URL.decodeQueryString(pair.substring(idx + 1)));
			}
		}
	}			
	
	// 4. take page token (hash) --> PARAMS (override cookie)
	parse(History.getToken());
}
 
Example 24
Source Project: unitime   Source File: PointInTimeDataReportsPage.java    License: 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 PITDQueriesRpcRequest(), new AsyncCallback<GwtRpcResponseList<Report>>() {
		@Override
		public void onFailure(Throwable caught) {
			iHeader.setErrorMessage(caught.getMessage());
			LoadingWidget.getInstance().hide();
		}
		@Override
		public void onSuccess(GwtRpcResponseList<Report> result) {
			String selected = (select == null ? null : select.toString());
			if (selected == null && iReportSelector.getWidget().getSelectedIndex() >= 0) {
				selected = iReportSelector.getWidget().getValue(iReportSelector.getWidget().getSelectedIndex());
			}
			iReportSelector.getWidget().clear();
			if (result.isEmpty()) {
				iHeader.setErrorMessage(MESSAGES.errorNoReportsAvailable());
			} else {
				iReportSelector.getWidget().addItem(MESSAGES.itemSelect(), "-1");
				iReports = result;
				for (int i = 0; i < result.size(); i++) {
					iReportSelector.getWidget().addItem(result.get(i).getName(), result.get(i).getId().toString());
					if (selected != null && selected.equals(result.get(i).getId().toString()))
						iReportSelector.getWidget().setSelectedIndex(1 + i);
				}
				queryChanged();
			}
			LoadingWidget.getInstance().hide();
			if (reload) reload(History.getToken());
		}
	});
}
 
Example 25
Source Project: unitime   Source File: UniTimeBack.java    License: 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 26
Source Project: unitime   Source File: SavedHQLPage.java    License: 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());
		}
	});
}
 
Example 27
Source Project: unitime   Source File: ReservationsPage.java    License: 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 28
Source Project: swellrt   Source File: WebClient.java    License: 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 29
Source Project: gwt-ol   Source File: GwtOLPlayground.java    License: 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 30
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);
		}
	}
}