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

The following examples show how to use com.google.gwt.core.client.GWT#getModuleBaseURL() . 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: ServiceEntryPoint.java    From swellrt with Apache License 2.0 6 votes vote down vote up
private static String getServerURL() {
  String url = GWT.getModuleBaseURL();

  int c = 3;
  String s = url;
  int index = -1;
  while (c > 0) {
    index = s.indexOf("/", index + 1);
    if (index == -1)
      break;
    c--;
  }

  if (c == 0)
    url = url.substring(0, index);

  return url;
}
 
Example 2
Source File: GwtMqlEditor.java    From mql-editor with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setService( MQLEditorService service ) {
  this.service = service;
  previewController.setService( service );
  mainController.setService( service );

  for ( MqlDialogListener listener : listeners ) {
    listener.onDialogReady();
  }

  try {
    bundle = new ResourceBundle( GWT.getModuleBaseURL(), "mainFrame", true, GwtMqlEditor.this );
  } catch ( Exception e ) {
    e.printStackTrace();
  }

}
 
Example 3
Source File: CirSim.java    From circuitjs1 with GNU General Public License v2.0 5 votes vote down vote up
void readSetupFile(String str, String title, boolean centre) {
	t = 0;
	System.out.println(str);
	// TODO: Maybe think about some better approach to cache management!
	String url=GWT.getModuleBaseURL()+"circuits/"+str+"?v="+random.nextInt(); 
	loadFileFromURL(url, centre);
	if (title != null)
	    titleLabel.setText(title);
}
 
Example 4
Source File: ProfilePage.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Main method to validify and upload the app image
 */
private void uploadImage() {
  String uploadFilename = imageUpload.getFilename();
  if (!uploadFilename.isEmpty()) {
    String filename = makeValidFilename(uploadFilename);
    // Forge the request URL for gallery servlet
    String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.GALLERY_SERVLET +
        "/user/" + userId + "/" + filename;
    Uploader.getInstance().upload(imageUpload, uploadUrl,
        new OdeAsyncCallback<UploadResponse>(MESSAGES.fileUploadError()) {
      @Override
      public void onSuccess(UploadResponse uploadResponse) {
        switch (uploadResponse.getStatus()) {
          case SUCCESS:
            ErrorReporter.hide();
            imageUploadBoxInner.clear();
            updateUserImage(gallery.getUserImageURL(userId), imageUploadBoxInner);
            break;
          case FILE_TOO_LARGE:
            // The user can resolve the problem by uploading a smaller file.
            ErrorReporter.reportInfo(MESSAGES.fileTooLargeError());
            break;
          default:
            ErrorReporter.reportError(MESSAGES.fileUploadError());
            break;
        }
      }
    });
  }
}
 
Example 5
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 imagePrefix() {
	String base = GWT.getModuleBaseURL();
	if (!base.endsWith("/"))
		base = base + "/";
	return base + "sc/skins/" + currentSkin() + "/images/";
}
 
Example 6
Source File: StorageUtil.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the URL for the given project file.
 */
public static String getFileUrl(long projectId, String fileId) {
  return GWT.getModuleBaseURL() + getFilePath(projectId, fileId);
}
 
Example 7
Source File: GalleryPage.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
/**
 * Main method to validify and upload the app image
 */
private void uploadImage() {
  String uploadFilename = upload.getFilename();
  if (!uploadFilename.isEmpty()) {
    // Grab and validify the filename
    final String filename = makeValidFilename(uploadFilename);
    // Forge the request URL for gallery servlet
    // we used to send the gallery id to the servlet, now the project id as
    // the servlet just stores image temporarily before publish
    /* String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.GALLERY_SERVLET +
        "/apps/" + String.valueOf(app.getGalleryAppId()) + "/"+ filename; */
    // send the project id as the id, to store image temporarily until published
    String uploadUrl = GWT.getModuleBaseURL() + ServerLayout.GALLERY_SERVLET +
        "/apps/" + String.valueOf(app.getProjectId()) + "/"+ filename;
    Uploader.getInstance().upload(upload, uploadUrl,
        new OdeAsyncCallback<UploadResponse>(MESSAGES.fileUploadError()) {
        @Override
        public void onSuccess(UploadResponse uploadResponse) {
          switch (uploadResponse.getStatus()) {
          case SUCCESS:
            // Update the app image preview after a success upload
            imageUploadBoxInner.clear();
            // updateAppImage(app.getCloudImageURL(), imageUploadBoxInner);
            updateAppImage(gallery.getProjectImageURL(app.getProjectId()),imageUploadBoxInner);
            imageUploaded=true;
            ErrorReporter.hide();
            break;
          case FILE_TOO_LARGE:
            // The user can resolve the problem by uploading a smaller file.
            ErrorReporter.reportInfo(MESSAGES.fileTooLargeError());
            break;
          default:
            ErrorReporter.reportError(MESSAGES.fileUploadError());
            break;
          }
        }
     });
  } else {
    if (editStatus == NEWAPP) {
      Window.alert(MESSAGES.noFileSelected());
    }
  }
}
 
Example 8
Source File: PathUrlFactory.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Returns the download URL for a given file provided by a servlet method.</p>
 * @param path The path of the file.
 */
public String getDownloadFileUrl(final Path path) {
    final StringBuilder sb = new StringBuilder(GWT.getModuleBaseURL() + EXPORT_SERVLET_URL);
    sb.append("?").append("path").append("=").append(URL.encode(path.toURI()));
    return sb.toString();
}
 
Example 9
Source File: PathUrlFactory.java    From dashbuilder with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Returns the upload URL for a given file provided by a servlet method.</p>
 * @param path The path of the file.
 */
public String getUploadFileUrl(String path) {
    final StringBuilder sb = new StringBuilder(GWT.getModuleBaseURL() + UPLOAD_SERVLET_URL);
    sb.append("?").append("path").append("=").append(URL.encode(path));
    return sb.toString();
}
 
Example 10
Source File: AuthImpl.java    From requestor with Apache License 2.0 4 votes vote down vote up
AuthImpl() {
    super(getTokenStore(), new RealClock(), new RealUrlCodex(), Scheduler.get(),
            // Default to use the bundled oauthWindow.html
            GWT.getModuleBaseURL() + "oauthWindow.html");
    register();
}