コード例 #1
0
ファイル: Projects.java プロジェクト: honglianglu/rstudio
  private void serverOpenProjectInNewWindow(FileSystemItem project, final Command onSuccess) {
    appServer_.getNewSessionUrl(
        GWT.getHostPageBaseURL(),
        true,
        project.getParentPathString(),
        new SimpleRequestCallback<String>() {

          @Override
          public void onResponseReceived(String url) {
            if (onSuccess != null) onSuccess.execute();

            globalDisplay_.openWindow(url);
          }
        });
  }
コード例 #2
0
ファイル: Projects.java プロジェクト: honglianglu/rstudio
  @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);
  }
コード例 #3
0
  // rebuilds the popup menu--this can happen when the menu is invoked; it can
  // also happen when the button is created if we're aggressively checking
  // publish status
  private void rebuildPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
    final ToolbarPopupMenu menu = publishMenu_;

    // prevent reentrancy
    if (populating_) {
      if (callback != null) callback.onPopupMenu(menu);
      return;
    }

    // handle case where we don't have a content path (i.e. plots)
    if (contentPath_ == null) {
      setPreviousDeployments(null);
      if (callback != null) callback.onPopupMenu(menu);
      return;
    }

    // avoid populating if we've already set the deployments for this path
    // (unless we're forcefully repopulating)
    if (populatedPath_ != null && populatedPath_.equals(contentPath_)) {
      if (callback != null) callback.onPopupMenu(menu);
      return;
    }

    String contentPath = contentPath_;
    boolean parent = false;

    // if this is a Shiny application and an .R file is being invoked, check
    // for deployments of its parent path (single-file apps have
    // CONTENT_TYPE_APP_SINGLE and their own deployment records)
    if (contentType_ == RSConnect.CONTENT_TYPE_APP
        && StringUtil.getExtension(contentPath_).equalsIgnoreCase("r")) parent = true;

    // if this is a document in a website, use the parent path
    if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE) parent = true;

    // apply parent path if needed
    if (parent) {
      FileSystemItem fsiContent = FileSystemItem.createFile(contentPath_);
      contentPath = fsiContent.getParentPathString();
    }

    populating_ = true;
    server_.getRSConnectDeployments(
        contentPath,
        outputPath_ == null ? "" : outputPath_,
        new ServerRequestCallback<JsArray<RSConnectDeploymentRecord>>() {
          @Override
          public void onResponseReceived(JsArray<RSConnectDeploymentRecord> recs) {
            populatedPath_ = contentPath_;
            populating_ = false;

            // if publishing a website but not content, filter deployments
            // that are static (as we can't update them)
            if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE
                && (docPreview_ == null || StringUtil.isNullOrEmpty(docPreview_.getOutputFile()))) {
              JsArray<RSConnectDeploymentRecord> codeRecs = JsArray.createArray().cast();
              for (int i = 0; i < recs.length(); i++) {
                if (!recs.get(i).getAsStatic()) codeRecs.push(recs.get(i));
              }
              recs = codeRecs;
            }

            setPreviousDeployments(recs);
            if (callback != null) callback.onPopupMenu(menu);
          }

          @Override
          public void onError(ServerError error) {
            populating_ = false;
            if (callback != null) callback.onPopupMenu(menu);
          }
        });
  }