com.google.gwt.user.client.Window.Location Java Examples

The following examples show how to use com.google.gwt.user.client.Window.Location. 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: TimetablePage.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected void init() {
	iFilter.getFooter().showLoading();
	RPC.execute(new TimetableGridFilterRequest(), new AsyncCallback<TimetableGridFilterResponse>() {
		@Override
		public void onFailure(Throwable caught) {
			iFilter.getFooter().setErrorMessage(MESSAGES.failedToInitialize(caught.getMessage()));
			UniTimeNotifications.error(MESSAGES.failedToInitialize(caught.getMessage()), caught);
			ToolBox.checkAccess(caught);
		}

		@Override
		public void onSuccess(TimetableGridFilterResponse result) {
			iFilter.getFooter().clearMessage();
			iFilter.setValue(result);
			iFilter.getFooter().setEnabled("search", true);
			createTriggers();
			if (!iFilter.getHeader().isCollapsible() || "1".equals(Location.getParameter("search")))
				search(null);
		}
	});
}
 
Example #2
Source File: JTSWebAppEntry.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void onLoad() {
	String mode = Location.getParameter("mode");
	
	if(mode == null) {
		new SimpleDemo().start();
		return;
	}
	
	switch(mode) {
	case "test":
		new TestRunner().run();
		break;
	case "geojson":
		new GeoJson().check();
		break;
	default:
		new SimpleDemo().start();
		break;
	}
}
 
Example #3
Source File: SolverPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
public SolverPage() {
	addStyleName("unitime-SolverPage");
	iType = SolverType.valueOf(Location.getParameter("type").toUpperCase());
	switch (iType) {
	case COURSE:
		UniTimePageLabel.getInstance().setPageName(MESSAGES.pageCourseTimetablingSolver());
		break;
	case EXAM:
		UniTimePageLabel.getInstance().setPageName(MESSAGES.pageExaminationTimetablingSolver());
		break;
	case INSTRUCTOR:
		UniTimePageLabel.getInstance().setPageName(MESSAGES.pageInstructorSchedulingSolver());
		break;
	case STUDENT:
		UniTimePageLabel.getInstance().setPageName(MESSAGES.pageStudentSchedulingSolver());
		break;
	}
	iSolverHeader = new UniTimeHeaderPanel(CONSTANTS.solverType()[iType.ordinal()]);
	addHeaderRow(iSolverHeader);
	iSolverButtons = new UniTimeHeaderPanel();
	iSolverButtons.addButton("load", MESSAGES.opSolverLoad(), createClickHandler(SolverOperation.LOAD));
	iSolverButtons.addButton("start", MESSAGES.opSolverStart(), createClickHandler(SolverOperation.START));
	iSolverButtons.addButton("stop", MESSAGES.opSolverStop(), createClickHandler(SolverOperation.STOP));
	iSolverButtons.addButton("sectioning", MESSAGES.opSolverStudentSectioning(), createClickHandler(SolverOperation.STUDENT_SECTIONING));
	iSolverButtons.addButton("reload", MESSAGES.opSolverReload(), createClickHandler(SolverOperation.RELOAD));
	iSolverButtons.addButton("validate", MESSAGES.opSolverValidate(), createClickHandler(SolverOperation.VALIDATE));
	iSolverButtons.addButton("publish", MESSAGES.opSolverPublish(), createClickHandler(SolverOperation.PUBLISH));
	iSolverButtons.addButton("clone", MESSAGES.opSolverClone(), createClickHandler(SolverOperation.CLONE));
	iSolverButtons.addButton("save", MESSAGES.opSolverSave(), createClickHandler(SolverOperation.SAVE));
	iSolverButtons.addButton("save new", MESSAGES.opSolverSaveAsNew(), createClickHandler(SolverOperation.SAVE_AS_NEW));
	iSolverButtons.addButton("commit", MESSAGES.opSolverSaveCommit(), createClickHandler(SolverOperation.SAVE_COMMIT));
	iSolverButtons.addButton("uncommit", MESSAGES.opSolverSaveUncommit(), createClickHandler(SolverOperation.SAVE_UNCOMMIT));
	iSolverButtons.addButton("clear", MESSAGES.opSolverClear(), createClickHandler(SolverOperation.CLEAR));
	iSolverButtons.addButton("csv", MESSAGES.opSolverExportCSV(), createClickHandler(SolverOperation.EXPORT_CSV));
	iSolverButtons.addButton("unload", MESSAGES.opSolverUnload(), createClickHandler(SolverOperation.UNLOAD));
	iSolverButtons.addButton("unpublish", MESSAGES.opSolverUnpublish(), createClickHandler(SolverOperation.UNPUBLISH));
	iSolverButtons.addButton("refresh", MESSAGES.opSolverRefresh(), createClickHandler(SolverOperation.CHECK));
	
	execute(SolverOperation.INIT);
}
 
Example #4
Source File: SuggestionsPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
public SelectedAssignment getLocationAssignment() {
	SelectedAssignment ret = new SelectedAssignment();
	if (Location.getParameter("id") != null)
		ret.setClassId(Long.valueOf(Location.getParameter("id")));
	else
		return null;
	if (Location.getParameter("days") != null)
		ret.setDays(Integer.valueOf(Location.getParameter("days")));
	else
		return null;
	if (Location.getParameter("slot") != null)
		ret.setStartSlot(Integer.valueOf(Location.getParameter("slot")));
	else
		return null;
	if (Location.getParameter("pid") != null)
		ret.setPatternId(Long.valueOf(Location.getParameter("pid")));
	else
		return null;
	if (Location.getParameter("did") != null)
		ret.setDatePatternId(Long.valueOf(Location.getParameter("did")));
	else
		return null;
	if (Location.getParameter("room") != null) {
		for (String id: Location.getParameter("room").split(","))
			ret.addRoomId(Long.valueOf(id));
	}
	return ret;
}
 
Example #5
Source File: EventResourceTimetable.java    From unitime with 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 #6
Source File: WebClient.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById("lang");
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }
  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
              "locale", select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
Example #7
Source File: GadgetWidget.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void requestNavigateTo(String url) {
  log("Requested navigate to: ", url);
  // NOTE(user): Currently only allow the gadgets to change the fragment part of the URL.
  String newFragment = url.replaceFirst(BEFORE_FRAGMENT_PATTERN, "");
  if (newFragment.matches(FRAGMENT_VALIDATION_PATTERN)) {
    Location.replace(Location.getHref().replaceFirst(FRAGMENT_PATTERN, "") + "#" + newFragment);
  } else {
    log("Navigate request denied.");
  }
}
 
Example #8
Source File: GadgetNonEditorGwtTest.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the IFrame URI generator of Gadget class.
 */
public void testIframeUri() {
  String xmlSource = "http://test.com/gadget.xml";
  String href = "http://" + Location.getHost();
  String hrefEscaped = href.replace("?", "%3F");
  if (hrefEscaped.endsWith("/")) {
    hrefEscaped = hrefEscaped.substring(0, hrefEscaped.length() - 1);
  }
  int clientInstanceId = 1234;
  GadgetUserPrefs userPrefs = GadgetUserPrefs.create();
  userPrefs.put("pref1", "value1");
  userPrefs.put("pref2", "value2");
  GadgetMetadata metadata = getTestMetadata(xmlSource);
  WaveId waveId = WaveId.of("wave.google.com", "123");
  WaveletId waveletId = WaveletId.of("wave.google.com", "conv+root");
  WaveletName name = WaveletName.of(waveId, waveletId);
  String securityToken = "SECURITY";
  GadgetWidget gadget = GadgetWidget.createForTesting(
      clientInstanceId, userPrefs, name, securityToken, new FakeLocale());
  int gadgetInstanceId = -12345;
  String url = gadget.buildIframeUrl(gadgetInstanceId, metadata.getIframeUrl(VIEW_NAME));
  String expectedValue =
      "//0" + GADGET_SERVER + "/gadgets"
          + "/ifr?url=http://test.com/gadget.xml&view=canvas&nocache=1&mid=" + gadgetInstanceId
          + "&lang=wizard&country=OZ&parent=" + hrefEscaped + "&wave=1&waveId="
          + URL.encodeQueryString(ModernIdSerialiser.INSTANCE.serialiseWaveId(waveId))
          + "#rpctoken=" + gadget.getRpcToken() + "&st=" + securityToken
          + "&up_pref1=value1&up_pref2=value2";
  assertEquals(expectedValue, url);
}
 
Example #9
Source File: WebClient.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void setupLocaleSelect() {
  final SelectElement select = (SelectElement) Document.get().getElementById("lang");
  String currentLocale = LocaleInfo.getCurrentLocale().getLocaleName();
  String[] localeNames = LocaleInfo.getAvailableLocaleNames();
  for (String locale : localeNames) {
    if (!DEFAULT_LOCALE.equals(locale)) {
      String displayName = LocaleInfo.getLocaleNativeDisplayName(locale);
      OptionElement option = Document.get().createOptionElement();
      option.setValue(locale);
      option.setText(displayName);
      select.add(option, null);
      if (locale.equals(currentLocale)) {
        select.setSelectedIndex(select.getLength() - 1);
      }
    }
  }
  EventDispatcherPanel.of(select).registerChangeHandler(null, new WaveChangeHandler() {

    @Override
    public boolean onChange(ChangeEvent event, Element context) {
      UrlBuilder builder = Location.createUrlBuilder().setParameter(
              "locale", select.getValue());
      Window.Location.replace(builder.buildString());
      localeService.storeLocale(select.getValue());
      return true;
    }
  });
}
 
Example #10
Source File: GadgetWidget.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public void requestNavigateTo(String url) {
  log("Requested navigate to: ", url);
  // NOTE(user): Currently only allow the gadgets to change the fragment part of the URL.
  String newFragment = url.replaceFirst(BEFORE_FRAGMENT_PATTERN, "");
  if (newFragment.matches(FRAGMENT_VALIDATION_PATTERN)) {
    Location.replace(Location.getHref().replaceFirst(FRAGMENT_PATTERN, "") + "#" + newFragment);
  } else {
    log("Navigate request denied.");
  }
}
 
Example #11
Source File: GadgetNonEditorGwtTest.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the IFrame URI generator of Gadget class.
 */
public void testIframeUri() {
  String xmlSource = "http://test.com/gadget.xml";
  String href = "http://" + Location.getHost();
  String hrefEscaped = href.replace("?", "%3F");
  if (hrefEscaped.endsWith("/")) {
    hrefEscaped = hrefEscaped.substring(0, hrefEscaped.length() - 1);
  }
  int clientInstanceId = 1234;
  GadgetUserPrefs userPrefs = GadgetUserPrefs.create();
  userPrefs.put("pref1", "value1");
  userPrefs.put("pref2", "value2");
  GadgetMetadata metadata = getTestMetadata(xmlSource);
  WaveId waveId = WaveId.of("wave.google.com", "123");
  WaveletId waveletId = WaveletId.of("wave.google.com", "conv+root");
  WaveletName name = WaveletName.of(waveId, waveletId);
  String securityToken = "SECURITY";
  GadgetWidget gadget = GadgetWidget.createForTesting(
      clientInstanceId, userPrefs, name, securityToken, new FakeLocale());
  int gadgetInstanceId = -12345;
  String url = gadget.buildIframeUrl(gadgetInstanceId, metadata.getIframeUrl(VIEW_NAME));
  String expectedValue =
      "//0" + GADGET_SERVER + "/gadgets"
          + "/ifr?url=http://test.com/gadget.xml&view=canvas&nocache=1&mid=" + gadgetInstanceId
          + "&lang=wizard&country=OZ&parent=" + hrefEscaped + "&wave=1&waveId="
          + URL.encodeQueryString(ModernIdSerialiser.INSTANCE.serialiseWaveId(waveId))
          + "#rpctoken=" + gadget.getRpcToken() + "&st=" + securityToken
          + "&up_pref1=value1&up_pref2=value2";
  assertEquals(expectedValue, url);
}
 
Example #12
Source File: SuggestionsPage.java    From unitime with Apache License 2.0 4 votes vote down vote up
public SuggestionsPage() {
	this(Long.valueOf(Location.getParameter("id")));
}
 
Example #13
Source File: GadgetWidget.java    From swellrt with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the URL of the client including protocol and host.
 *
 * @return URL of the client.
 */
private String getUrlPrefix() {
  return Location.getProtocol() + "//" + Location.getHost();
}
 
Example #14
Source File: GadgetWidget.java    From incubator-retired-wave with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the URL of the client including protocol and host.
 *
 * @return URL of the client.
 */
private String getUrlPrefix() {
  return Location.getProtocol() + "//" + Location.getHost();
}