Java Code Examples for com.google.gwt.core.client.GWT#getHostPageBaseURL()

The following examples show how to use com.google.gwt.core.client.GWT#getHostPageBaseURL() . 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: LinksPanel.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void onDownloadPackage() {
	if (document.getFolder().isDownload()) {
		String url = GWT.getHostPageBaseURL() + "zip-export?folderId=" + document.getFolder().getId();
		url += "&docId=" + document.getId();

		treeGrid.getRecords();

		for (ListGridRecord record : treeGrid.getRecords()) {
			if (record.getAttributeAsBoolean("password")) {
				SC.warn(I18N.message("somedocsprotected"));
				break;
			}

			String docId = record.getAttribute("documentId");
			docId = docId.substring(docId.indexOf('-') + 1);
			url += "&docId=" + docId;
		}
		WindowUtils.openUrl(url);
	}
}
 
Example 2
Source File: Util.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static String webstartURL(String appName, Map<String, String> params) {
	StringBuffer url = new StringBuffer(GWT.getHostPageBaseURL());
	url.append("webstart/");
	url.append(appName);
	url.append(".jsp?random=");
	url.append(new Date().getTime());
	url.append("&language=");
	url.append(I18N.getLocale());
	url.append("&docLanguage=");
	url.append(I18N.getDefaultLocaleForDoc());
	url.append("&sid=");
	url.append(Session.get().getSid());
	if (params != null)
		for (String p : params.keySet()) {
			url.append("&");
			url.append(p);
			url.append("=");
			url.append(URL.encode(params.get(p)));
		}
	return url.toString();
}
 
Example 3
Source File: AppUtils.java    From swcv with MIT License 6 votes vote down vote up
public static DialogBox createLoadingBox()
{
    final DialogBox box = new DialogBox();
    VerticalPanel rows = new VerticalPanel();
    rows.setSpacing(1);

    HTML html = new HTML("<img src=\"" + GWT.getHostPageBaseURL() + "static/imgs/loader.gif\" alt=\"loading\" />");
    rows.add(html);
    rows.addStyleName("whiteWithBorder");
    rows.setCellHeight(html, "100");
    rows.setCellWidth(html, "300");

    rows.setCellHorizontalAlignment(html, HasHorizontalAlignment.ALIGN_CENTER);
    rows.setCellVerticalAlignment(html, HasVerticalAlignment.ALIGN_MIDDLE);

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(rows);
    box.setWidget(hp);
    box.hide();
    return box;
}
 
Example 4
Source File: OpenProjectDialog.java    From geowe-core with GNU General Public License v3.0 6 votes vote down vote up
private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
	return new SelectHandler() {
		@Override
		public void onSelect(SelectEvent event) {
			urlToShareAnchor.setHref(getHref());
			urlToShareAnchor.setText(
					UIMessages.INSTANCE.seeOtherWindow("GeoWE Project"),
					Direction.LTR);

			urlShared.setText(getHref());
			urlPanel.setVisible(true);
			urlShared.setVisible(true);
		}

		private String getHref() {
			String baseUrl = GWT.getHostPageBaseURL();

			baseUrl += "?projectUrl="
					+ URL.encodeQueryString(urlTextField.getValue());

			return baseUrl;
		}
	};
}
 
Example 5
Source File: TimePreferenceCell.java    From unitime with Apache License 2.0 6 votes vote down vote up
@Override
public void refresh() {
	clear();
	RoomCookie cookie = RoomCookie.getInstance();
	if (iPattern != null && !iPattern.isEmpty() && !cookie.isGridAsText()) {
		final Image availability = new Image(GWT.getHostPageBaseURL() + "pattern?pref=" + iPattern + "&v=" + (cookie.areRoomsHorizontal() ? "0" : "1") + (cookie.hasMode() ? "&s=" + cookie.getMode() : ""));
		availability.setStyleName("grid");
		add(availability);
	} else {
		for (PreferenceInfo p: iPreferences) {
			P prf = new P("prf");
			prf.setText(p.getOwnerName());
			PreferenceInterface preference = iProperties.getPreference(p.getPreference());
			if (preference != null) {
				prf.getElement().getStyle().setColor(preference.getColor());
				prf.setTitle(preference.getName() + " " + p.getOwnerName());
			}
			add(prf);
		}
	}
}
 
Example 6
Source File: Log.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Logs a server error and shows a warning to the user
 * 
 * @param message The message to be shown (optional)
 * @param caught The caught exception (if any)
 */
public static void serverError(String message, Throwable caught) {
	try {
		ContactingServer.get().hide();

		// Hide download exceptions that normally are raised on double
		// click.
		if ("0".equals(message.trim()))
			return;

		EventPanel.get().error(I18N.message("servererror") + ": " + message, message);
		GWT.log("Server error: " + message, caught);

		if (caught instanceof RequestTimeoutException) {
			SC.warn(I18N.message("timeout"));
		} else if (caught instanceof InvalidSessionException) {
			// Redirect to the module's login page
			Session.get().close();
			String base = GWT.getHostPageBaseURL();
			Util.redirect(base
					+ (base.endsWith("/") ? GWT.getModuleName() + ".jsp" : "/" + GWT.getModuleName() + ".jsp"));
		} else if (caught instanceof ServerException) {
			SC.warn(caught.getMessage());
		}
	} catch (Throwable t) {
	}
}
 
Example 7
Source File: BlipLinkPopupWidget.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void setLinkInfo(String url) {
  linkInfoBox.setText(url);
  String path =
      GWT.getHostPageBaseURL() + "waveref/"
          + url.substring(WaveRefConstants.WAVE_URI_PREFIX.length());
  waverefLink.setText(path);
}
 
Example 8
Source File: RoomDetail.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected P getPopupWidget() {
	if (iPopupWidget == null) {
		iPopupWidget = new P("unitime-RoomPictureHint");
		Image image = new Image(GWT.getHostPageBaseURL() + "picture?id=" + iPicture.getUniqueId());
		image.setStyleName("picture");
		iPopupWidget.add(image);
		P caption = new P("caption");
		caption.setText(iPicture.getName() + (iPicture.getPictureType() == null ? "" : " (" + iPicture.getPictureType().getAbbreviation() + ")"));
		iPopupWidget.add(caption);
	}
	return iPopupWidget;
}
 
Example 9
Source File: RoomsTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
LinkCell(RoomPictureInterface picture) {
super(new Image(RESOURCES.download()), GWT.getHostPageBaseURL() + "picture?id=" + picture.getUniqueId());
setStyleName("link");
setTitle(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getLabel() + ")"));
setText(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getAbbreviation() + ")"));
      setTarget("_blank");
      sinkEvents(Event.ONCLICK);
  }
 
Example 10
Source File: RoomsTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected P getPopupWidget() {
	if (iPopupWidget == null) {
		iPopupWidget = new P("unitime-RoomPictureHint");
		Image image = new Image(GWT.getHostPageBaseURL() + "picture?id=" + iPicture.getUniqueId());
		image.setStyleName("picture");
		iPopupWidget.add(image);
		P caption = new P("caption");
		caption.setText(iPicture.getName() + (iPicture.getPictureType() == null ? "" : " (" + iPicture.getPictureType().getAbbreviation() + ")"));
		iPopupWidget.add(caption);
	}
	return iPopupWidget;
}
 
Example 11
Source File: BootstrapServerSetup.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
String getBaseUrl() {
    String hostUrl = GWT.getHostPageBaseURL();
    int schemeIndex = hostUrl.indexOf("://");
    int slash = hostUrl.indexOf('/', schemeIndex + 3);
    if (slash != -1) {
        return hostUrl.substring(0, slash);
    }
    return hostUrl;
}
 
Example 12
Source File: GeoDataImportDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private SelectHandler createUrlToShare(final VerticalPanel geoDataContainer) {
	return new SelectHandler() {
		@Override
		public void onSelect(SelectEvent event) {
			urlToShareAnchor.setHref(getHref());
			urlToShareAnchor.setText(
					UIMessages.INSTANCE.seeOtherWindow(getLayerName()),
					Direction.LTR);

			urlShared.setText(getHref());
			urlPanel.setVisible(true);
			urlShared.setVisible(true);
		}

		private String getHref() {
			String baseUrl = GWT.getHostPageBaseURL();

			baseUrl += "?layerUrl="
					+ URL.encodeQueryString(urlTextField.getValue())
					+ "&layerName=" + getLayerName() + "&layerProj="
					+ getProjectionName() + "&layerFormat="
					+ getDataFormat();

			return baseUrl;
		}
	};
}
 
Example 13
Source File: JoinDataTool.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private void lodaDataFromURL(final String url) {
	final String urlBase = GWT.getHostPageBaseURL() + "gwtOpenLayersProxy";
	try {
		autoMessageBox.show();
		RestClient.create(URLFileRestService.class, urlBase,
				new RemoteCallback<String>() {
					@Override
					public void callback(String response) {
						parseCsvData(response);
						autoMessageBox.hide();
					}
				}, new RestErrorCallback() {
					@Override
					public boolean error(Request message,
							Throwable throwable) {
						autoMessageBox.hide();

						showAlert("Error"
								+ UIMessages.INSTANCE.unexpectedError());
						return false;
					}
				}, Response.SC_OK).getContent(url);
	} catch (Exception e) {
		autoMessageBox.hide();
		showAlert("Error loading data..." + e.getMessage());
	}
}
 
Example 14
Source File: ShowBarcodeCommand.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(final ProjectNode node) {
  // Display a barcode for an url pointing at our server's download servlet
  String barcodeUrl = GWT.getHostPageBaseURL()
    + "b/" + Ode.getInstance().getNonce();
  OdeLog.log("Barcode url is: " + barcodeUrl);
  new BarcodeDialogBox(node.getName(), barcodeUrl).center();
}
 
Example 15
Source File: Util.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void redirectToRoot(String moduleName, String parameters) {
	String base = GWT.getHostPageBaseURL();
	String module = GWT.getModuleName();
	if (moduleName != null)
		module = moduleName;
	String url = base + (base.endsWith("/") ? module + ".jsp" : "/" + module + ".jsp");
	url += "?locale=" + I18N.getLocale() + "&tenant=" + Session.get().getTenantName();
	if (parameters != null)
		url += "&" + parameters;
	Util.redirect(url);
}
 
Example 16
Source File: RoomDetail.java    From unitime with Apache License 2.0 4 votes vote down vote up
LinkCell(RoomPictureInterface picture) {
	super(new Image(RESOURCES.download()), GWT.getHostPageBaseURL() + "picture?id=" + picture.getUniqueId());
	setStyleName("link");
	setTitle(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getLabel() + ")"));
	setText(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getAbbreviation() + ")"));
}
 
Example 17
Source File: ToolBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static void print(String title, String user, String session, Widget... widgets) {
	String content = "";
	for (Widget w: widgets)
		content += "<div class=\"unitime-PrintedComponent\">" + w.getElement().getString() + "</div>";
	String html = "<html><header>" +
		"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" +
		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "unitime/gwt/standard/standard.css\">" +
		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "styles/unitime.css\">" +
	    "<link rel=\"shortcut icon\" href=\"" + GWT.getHostPageBaseURL() + "images/timetabling.ico\">" +
	    "<title>UniTime " + CONSTANTS.version() + "| University Timetabling Application</title>" +
		"</header><body class='unitime-Body'>" + 
	    "<span class='unitime-Page'>" +
			"<span class='body'>"+
				"<span class='unitime-PageHeader'>" +
					"<span class='row'>"+
						"<span class='logo'><img src='" + GWT.getHostPageBaseURL() + "images/unitime.png' border='0'/></span>"+
						"<span class='content'>"+
							"<span id='UniTimeGWT:Title' class='title'>" + title + "</span>"+
							"<span class='unitime-Header'>" +
								"<span class='unitime-InfoPanel'>"+
									"<span class='row'>" +
										"<span class='cell middle'>" + user + "</span>" +
										"<span class='cell right'>" + session + "</span>" +
									"</span>" +
								"</span>" +
							"</span>" +
						"</span>" +
					"</span>" +
				"</span>" +
				"<span class='content'>" + content + "</span>" +
			"</span>" +
			"<span class='footer'>" +
				"<span class='unitime-Footer'>" +
					"<span class='row'>" +
						"<span class='cell left'>Printed from UniTime " + CONSTANTS.version() + " | University Timetabling Application</span>" +
						"<span class='cell middle'>" + CONSTANTS.copyright() + "</span>" +
						"<span class='cell right'>" + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(new Date()) + "</span>" +
					"</span>" +
				"</span>" +
			"</span>" +
		"</span></body></html>";
	printf(html);
}
 
Example 18
Source File: ToolBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static void print(List<Page> pages) {
	String html = "<html><header>" +
    		"<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">" +
    		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "unitime/gwt/standard/standard.css\">" +
    		"<link type=\"text/css\" rel=\"stylesheet\" href=\"" + GWT.getHostPageBaseURL() + "styles/unitime.css\">" +
    	    "<link rel=\"shortcut icon\" href=\"" + GWT.getHostPageBaseURL() + "images/timetabling.ico\">" +
    	    "<title>UniTime " + CONSTANTS.version() + "| University Timetabling Application</title>" +
    		"</header><body class='unitime-Body'>";
	for (Page p: pages) {
		html += "<span class='unitime-PrintedPage'>" +
					"<span class='unitime-Page'>" +
						"<span class='body'>"+
							"<span class='unitime-PageHeader'>" +
								"<span class='row'>"+
									"<span class='logo'><img src='" + GWT.getHostPageBaseURL() + "images/unitime.png' border='0'/></span>"+
									"<span class='content'>"+
										"<span id='UniTimeGWT:Title' class='title'>" + p.getName() + "</span>"+
										"<span class='unitime-Header'>" +
											"<span class='unitime-InfoPanel'>"+
												"<span class='row'>" +
													"<span class='cell middle'>" + p.getUser() + "</span>" +
													"<span class='cell right'>" + p.getSession() + "</span>" +
												"</span>" +
											"</span>" +
										"</span>" +
									"</span>" +
								"</span>" +
							"</span>" +
							"<span class='content'>" + p.getBody().getString() + "</span>" +
						"</span>" +
						"<span class='footer'>" +
							"<span class='unitime-Footer'>" +
								"<span class='row'>" +
									"<span class='cell left'>Printed from UniTime " + CONSTANTS.version() + " | University Timetabling Application</span>" +
									"<span class='cell middle'>" + CONSTANTS.copyright() + "</span>" +
									"<span class='cell right'>" + DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM).format(new Date()) + "</span>" +
								"</span>" +
							"</span>" +
						"</span>" +
					"</span>" +
				"</span>";
	}
	html += "</body></html>";
	printf(html);
}
 
Example 19
Source File: Util.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String thumbnailUrl(long docId, String fileVersion) {
	String url = GWT.getHostPageBaseURL() + "thumbnail?docId=" + docId + "&random=" + new Date().getTime();
	if (fileVersion != null)
		url += "&fileVersion=" + fileVersion;
	return url;
}
 
Example 20
Source File: DefaultCommandController.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private DefaultCommandController() {
	this.moduleBaseURL = GWT.getHostPageBaseURL();
	this.remoteServiceURL = this.moduleBaseURL + "commandService";
	ErrorManager.get().registerErrorHandlers(new ClientErrorHandler(), new ServerErrorHandler(),
		new DefaultCommandExceptionErrorHandler());
}