示例#1
0
  public void showFile(FileSystemItem file, String commitId, String contents) {
    commitId_ = commitId;
    targetFile_ = file;

    docDisplay_.setCode(contents, false);

    adaptToFileType(fileTypeRegistry_.getTextTypeForFile(file));

    // header widget has icon + label
    HorizontalPanel panel = new HorizontalPanel();

    Image imgFile = new Image(fileTypeRegistry_.getIconForFile(file));
    imgFile.addStyleName(RES.styles().captionIcon());
    panel.add(imgFile);

    Label lblCaption = new Label(file.getPath() + " @ " + commitId);
    lblCaption.addStyleName(RES.styles().captionLabel());
    panel.add(lblCaption);

    popupPanel_ = new FullscreenPopupPanel(panel, asWidget(), false);
    popupPanel_.center();

    // set focus to the doc display after 100ms
    Timer timer =
        new Timer() {
          public void run() {
            docDisplay_.focus();
          }
        };
    timer.schedule(100);
  }
示例#2
0
  public final int compareTo(FileSystemItem other) {
    // If we ever need to compare files that don't share the same
    // parent, then maybe we would need to compare parent directory
    // before anything else.

    if (isDirectory() ^ other.isDirectory()) return isDirectory() ? -1 : 1;
    return String.CASE_INSENSITIVE_ORDER.compare(getPath(), other.getPath());
  }
示例#3
0
 public void setDirectory(FileSystemItem directoryItem) {
   if (directoryItem.equalTo(FileSystemItem.home())) {
     image_.setResource(FileDialogResources.INSTANCE.homeImage());
     name_.setHTML("Home");
   } else {
     image_.setResource(FileIconResources.INSTANCE.iconFolder());
     name_.setHTML(" " + directoryItem.getPath());
   }
 }
示例#4
0
 @Override
 public void onOpenProjectNewWindow(OpenProjectNewWindowEvent event) {
   // call the desktop to open the project (since it is
   // a conventional foreground gui application it has
   // less chance of running afowl of desktop app creation
   // & activation restrictions)
   FileSystemItem project = FileSystemItem.createFile(event.getProject());
   if (Desktop.isDesktop()) Desktop.getFrame().openProjectInNewWindow(project.getPath());
   else serverOpenProjectInNewWindow(project, null);
 }
示例#5
0
  public void openFile(final FileSystemItem file, final boolean canUseBrowser) {
    FileType fileType = getTypeForFile(file);
    if (fileType != null) {
      fileType.openFile(file, eventBus_);
    } else {
      // build default command to use if we have an error or the
      // file is not a text file
      final Command defaultCommand =
          new Command() {
            @Override
            public void execute() {
              if (canUseBrowser) {
                if (session_.getSessionInfo().getAllowFileDownloads()) {
                  BROWSER.openFile(file, eventBus_);
                } else {
                  globalDisplay_.showErrorMessage(
                      "File Download Error",
                      "Unable to show file because file downloads are "
                          + "restricted on this server.\n");
                }
              }
            }
          };

      // check with the server to see if this is likely to be a text file
      server_.isTextFile(
          file.getPath(),
          new ServerRequestCallback<Boolean>() {
            @Override
            public void onResponseReceived(Boolean isText) {
              if (isText) TEXT.openFile(file, eventBus_);
              else defaultCommand.execute();
            }

            @Override
            public void onError(ServerError error) {
              defaultCommand.execute();
            }
          });
    }
  }
示例#6
0
  @Override
  public void onOpenProjectFile(final OpenProjectFileEvent event) {
    // project options for current project
    FileSystemItem projFile = event.getFile();
    if (projFile.getPath().equals(session_.getSessionInfo().getActiveProjectFile())) {
      onProjectOptions();
      return;
    }

    // prompt to confirm
    String projectPath = projFile.getParentPathString();
    globalDisplay_.showYesNoMessage(
        GlobalDisplay.MSG_QUESTION,
        "Confirm Open Project",
        "Do you want to open the project " + projectPath + "?",
        new Operation() {
          public void execute() {
            switchToProject(event.getFile().getPath());
          }
        },
        true);
  }
示例#7
0
 @Override
 public Object getKey(FileSystemItem item) {
   return item.getPath();
 }