Package org.rstudio.core.client.widget

Examples of org.rstudio.core.client.widget.ProgressIndicator


      view_.getCommitDetail().addViewFileRevisionHandler(
                                          new ViewFileRevisionHandler() {
         @Override
         public void onViewFileRevision(final ViewFileRevisionEvent event)
         {
            final ProgressIndicator indicator =
                  new GlobalProgressDelayer(globalDisplay,
                                            500,
                                            "Reading file...").getIndicator();
           
            strategy_.showFile(
                  event.getRevision(),
                  event.getFilename(),
                  new ServerRequestCallback<String>()
                  {

                     @Override
                     public void onResponseReceived(String contents)
                     {
                        indicator.onCompleted();

                        final ViewFilePanel viewFilePanel = pViewFilePanel.get();
                       
                        viewFilePanel.setSaveFileAsHandler(
                                          new ViewFilePanel.SaveFileAsHandler()
                        {
                          
                           @Override
                           public void onSaveFileAs(FileSystemItem source,
                                                    FileSystemItem destination,
                                                    ProgressIndicator indicator)
                           {
                              strategy_.saveFileAs(event.getRevision(),
                                                   source.getPath(),
                                                   destination.getPath(),
                                                   indicator);
                           }
                        });
                       
                        viewFilePanel.getToolbar().addRightWidget(
                                                         new ToolbarButton(
                              "Show History",
                              commands.goToWorkingDir().getImageResource(),
                              new ClickHandler() {

                               @Override
                               public void onClick(ClickEvent event)
                               {
                                  view_.getFileFilter().setValue(
                                              viewFilePanel.getTargetFile());
                                  viewFilePanel.close();
                                
                               }
                                
                              }));
                       
                        viewFilePanel.showFile(
                              event.getFilename() + " @ " + event.getRevision(),
                              FileSystemItem.createFile(event.getFilename()),
                              contents);
                     }

                     @Override
                     public void onError(ServerError error)
                     {
                        if (strategy_.getShowHistoryErrors())
                        {
                           indicator.onError(error.getUserMessage());
                        }
                        else
                        {
                           indicator.onCompleted();
                           Debug.logError(error);
                        }
                     }

                  });
View Full Code Here


                 new Operation() // Yes operation
                 {
                    @Override
                    public void execute()
                    {
                       ProgressIndicator indicator =
                             globalDisplay_.getProgressIndicator(
                                                  "Error Creating Library");
                        server_.initDefaultUserLibrary(
                              new VoidServerRequestCallback(indicator) {
                                 @Override
View Full Code Here

   }
  
   private void withPackageInstallContext(
         final OperationWithInput<PackageInstallContext> operation)
   {
      final ProgressIndicator indicator =
         globalDisplay_.getProgressIndicator("Error");
      indicator.onProgress("Retrieving package installation context...");

      server_.getPackageInstallContext(
         new SimpleRequestCallback<PackageInstallContext>() {

            @Override
            public void onResponseReceived(PackageInstallContext context)
            {
               indicator.onCompleted();
               operation.execute(context);
            }

            @Override
            public void onError(ServerError error)
            {
               indicator.onError(error.getUserMessage());
            }          
         });    
   }
View Full Code Here

     
   }
 
   private void verifyPrerequisites()
   {
      final ProgressIndicator indicator = getProgressIndicator();
     
      indicator.onProgress("Verifying prequisites...");
     
      server_.getPackratPrerequisites(
        new ServerRequestCallback<PackratPrerequisites>() {
           @Override
           public void onResponseReceived(PackratPrerequisites prereqs)
           {
              indicator.onCompleted();
             
              if (prereqs.getBuildToolsAvailable())
              {
                 if (prereqs.getPackageAvailable())
                 {
                    setUsePackrat(true);
                 }
                 else
                 {
                    indicator.onProgress("Installing Packrat...");

                    server_.installPackrat(new ServerRequestCallback<Boolean>() {

                       @Override
                       public void onResponseReceived(Boolean success)
                       {
                          setUsePackrat(success);
                         
                          indicator.onCompleted();
                       }
  
                       @Override
                       public void onError(ServerError error)
                       {
                          setUsePackrat(false);
                         
                          indicator.onError(error.getUserMessage());
                       }
                    });
                 }
              }
              else
              {      
                 setUsePackrat(false);
                
                 // install build tools (with short delay to allow
                 // the progress indicator to clear)
                 new Timer() {
                  @Override
                  public void run()
                  {
                     server_.installBuildTools(
                           "Managing packages with Packrat",
                           new SimpleRequestCallback<Boolean>() {})
                  }  
                 }.schedule(250);
              }
           }

         @Override
         public void onError(ServerError error)
         {
            setUsePackrat(false);
           
            indicator.onError(error.getUserMessage());
         }
        })
   }
View Full Code Here

   }
  
  
   private void confirmGitRepo(final Command onConfirmed)
   {
      final ProgressIndicator indicator = getProgressIndicator();
      indicator.onProgress("Checking for git repository...");
     
      final String projDir =
               session_.getSessionInfo().getActiveProjectDir().getPath();
     
      server_.gitHasRepo(projDir, new ServerRequestCallback<Boolean>() {

         @Override
         public void onResponseReceived(Boolean result)
         {
            indicator.onCompleted();
           
            if (result)
            {
               onConfirmed.execute();
            }
            else
            {
               globalDisplay_.showYesNoMessage(
                  MessageDialog.QUESTION,
                  "Confirm New Git Repository",
                  "Do you want to initialize a new git repository " +
                  "for this project?",
                  false,
                  new Operation() {
                     @Override
                     public void execute()
                     {
                        server_.gitInitRepo(
                          projDir,
                          new VoidServerRequestCallback(indicator) {
                             @Override
                             public void onSuccess()
                             {
                                onConfirmed.execute();
                             }
                             @Override
                             public void onFailure()
                             {
                                setVcsSelection(VCSConstants.NO_ID);
                             }
                          });
                       
                     }
                  },
                  new Operation() {
                     @Override
                     public void execute()
                     {
                        setVcsSelection(VCSConstants.NO_ID);
                        indicator.onCompleted();
                     }
                    
                  },
                  true);
            }
         }
        
         @Override
         public void onError(ServerError error)
         {
            setVcsSelection(VCSConstants.NO_ID);
            indicator.onError(error.getUserMessage())
         }
        
      });
     
   }
View Full Code Here

      // that each may or may not need to be executed, depending on the type
      // of project being created and on whether the previous pieces of logic
      // succeed. Plus we have this ProgressIndicator that needs to be fed
      // properly.

      final ProgressIndicator indicator = globalDisplay_.getProgressIndicator(
                                                      "Error Creating Project");
     
      // Here's the command queue that will hold the various operations.
      final SerializedCommandQueue createProjectCmds =
                                                  new SerializedCommandQueue();

      // WARNING: When calling addCommand, BE SURE TO PASS FALSE as the second
      // argument, to delay running of the commands until they are all
      // scheduled.

      // First, attempt to update the default project location pref
      createProjectCmds.addCommand(new SerializedCommand()
      {
         @Override
         public void onExecute(final Command continuation)
         {
            UIPrefs uiPrefs = pUIPrefs_.get();
           
            // update default project location pref if necessary
            if ((newProject.getNewDefaultProjectLocation() != null) ||
                (newProject.getCreateGitRepo() !=
                 uiPrefs.newProjGitInit().getValue()))
            {
               indicator.onProgress("Saving defaults...");

               if (newProject.getNewDefaultProjectLocation() != null)
               {
                  uiPrefs.defaultProjectLocation().setGlobalValue(
                     newProject.getNewDefaultProjectLocation());
               }
              
               if (newProject.getCreateGitRepo() !=
                   uiPrefs.newProjGitInit().getValue())
               {
                  uiPrefs.newProjGitInit().setGlobalValue(
                                          newProject.getCreateGitRepo());
               }
              
               if (newProject.getUsePackrat() !=
                   uiPrefs.newProjUsePackrat().getValue())
               {
                  uiPrefs.newProjUsePackrat().setGlobalValue(
                                          newProject.getUsePackrat());
               }
              
               // call the server -- in all cases continue on with
               // creating the project (swallow errors updating the pref)
               projServer_.setUiPrefs(
                     session_.getSessionInfo().getUiPrefs(),
                     new VoidServerRequestCallback(indicator) {
                        @Override
                        public void onResponseReceived(Void response)
                        {
                           continuation.execute();
                        }

                        @Override
                        public void onError(ServerError error)
                        {
                           super.onError(error);
                           continuation.execute();
                        }
                     });
            }
            else
            {
               continuation.execute();
            }
         }
      }, false);

      // Next, if necessary, clone a repo
      if (newProject.getVcsCloneOptions() != null)
      {
         createProjectCmds.addCommand(new SerializedCommand()
         {
            @Override
            public void onExecute(final Command continuation)
            {
               VcsCloneOptions cloneOptions = newProject.getVcsCloneOptions();
              
               if (cloneOptions.getVcsName().equals((VCSConstants.GIT_ID)))
                  indicator.onProgress("Cloning Git repoistory...");
               else
                  indicator.onProgress("Checking out SVN repository...");
              
               gitServer_.vcsClone(
                     cloneOptions,
                     new ServerRequestCallback<ConsoleProcess>() {
                        @Override
                        public void onResponseReceived(ConsoleProcess proc)
                        {
                           final ConsoleProgressDialog consoleProgressDialog =
                                 new ConsoleProgressDialog(proc, gitServer_);
                           consoleProgressDialog.showModal();
          
                           proc.addProcessExitHandler(new ProcessExitEvent.Handler()
                           {
                              @Override
                              public void onProcessExit(ProcessExitEvent event)
                              {
                                 if (event.getExitCode() == 0)
                                 {
                                    consoleProgressDialog.hide();
                                    continuation.execute();
                                 }
                                 else
                                 {
                                    indicator.onCompleted();
                                 }
                              }
                           });
                        }

                        @Override
                        public void onError(ServerError error)
                        {
                           Debug.logError(error);
                           indicator.onError(error.getUserMessage());
                        }
                     });
            }
         }, false);
      }

      // Next, create the project file
      createProjectCmds.addCommand(new SerializedCommand()
      {
         @Override
         public void onExecute(final Command continuation)
         {
            indicator.onProgress("Creating project...");

            projServer_.createProject(
                  newProject.getProjectFile(),
                  newProject.getNewPackageOptions(),
                  newProject.getNewShinyAppOptions(),
                  new VoidServerRequestCallback(indicator)
                  {
                     @Override
                     public void onSuccess()
                     {
                        continuation.execute();
                     }
                  });
         }
      }, false);
     
      // Next, initialize a git repo if requested
      if (newProject.getCreateGitRepo())
      {
         createProjectCmds.addCommand(new SerializedCommand()
         {
            @Override
            public void onExecute(final Command continuation)
            {
               indicator.onProgress("Initializing git repository...");

               String projDir = FileSystemItem.createFile(
                     newProject.getProjectFile()).getParentPathString();
              
               gitServer_.gitInitRepo(
                     projDir,
                     new VoidServerRequestCallback(indicator)
                     {
                        @Override
                        public void onSuccess()
                        {
                           continuation.execute();
                        }
                       
                        @Override
                        public void onFailure()
                        {
                           continuation.execute();
                        }
                     });
            }
         }, false);
      }
     
      // Generate a new packrat project
      if (newProject.getUsePackrat()) {
         createProjectCmds.addCommand(new SerializedCommand()
         {
           
            @Override
            public void onExecute(final Command continuation) {
              
               indicator.onProgress("Initializing packrat project...");
              
               String projDir = FileSystemItem.createFile(
                  newProject.getProjectFile()
               ).getParentPathString();
              
               packratServer_.packratBootstrap(
                  projDir,
                  false,
                  new VoidServerRequestCallback(indicator) {
                     @Override
                     public void onSuccess()
                     {
                        continuation.execute();
                     }
                  });
            }
         }, false);
      }
     
      if (newProject.getOpenInNewWindow())
      {
         createProjectCmds.addCommand(new SerializedCommand() {

            @Override
            public void onExecute(Command continuation)
            {
               Desktop.getFrame().openProjectInNewWindow(
                                             newProject.getProjectFile());
               continuation.execute();
              
            }
         }, false);
      }

      // If we get here, dismiss the progress indicator
      createProjectCmds.addCommand(new SerializedCommand()
      {
         @Override
         public void onExecute(Command continuation)
         {
            indicator.onCompleted();
           
            if (!newProject.getOpenInNewWindow())
            {
               applicationQuit_.performQuit(
                                 saveChanges,
View Full Code Here

      showProjectOptions(ProjectPreferencesDialog.PACKRAT);
   }
  
   private void showProjectOptions(final int initialPane)
   {
      final ProgressIndicator indicator = globalDisplay_.getProgressIndicator(
                                                      "Error Reading Options");
      indicator.onProgress("Reading options...");

      projServer_.readProjectOptions(new SimpleRequestCallback<RProjectOptions>() {

         @Override
         public void onResponseReceived(RProjectOptions options)
         {
            indicator.onCompleted();

            ProjectPreferencesDialog dlg = pPrefDialog_.get();
            dlg.initialize(options);
            dlg.activatePane(initialPane);
            dlg.showModal();
View Full Code Here

      saveFileAsHandler_ = handler;
   }
  
   public void showFile(final FileSystemItem file, String encoding)
   {
      final ProgressIndicator indicator = new GlobalProgressDelayer(
            globalDisplay_, 300, "Loading file contents").getIndicator();
                                              
     
      server_.getFileContents(file.getPath(),
                              encoding,
                              new ServerRequestCallback<String>() {

         @Override
         public void onResponseReceived(String contents)
         {
            indicator.onCompleted();
            showFile(file.getPath(), file, contents);
         }

         @Override
         public void onError(ServerError error)
         {
            indicator.onError(error.getUserMessage());
         }
      });
   }
View Full Code Here

   public void onSuspendAndRestart(final SuspendAndRestartEvent event)
   {
      // set restart pending for desktop
      setPendinqQuit(DesktopFrame.PENDING_QUIT_AND_RESTART);
     
      ProgressIndicator progress = new GlobalProgressDelayer(
                                             globalDisplay_,
                                             200,
                                             "Restarting R...").getIndicator();
                                      
      // perform the suspend and restart
View Full Code Here

   }
  
   @Handler
   public void onVersionControlShowRsaKey()
   {
      final ProgressIndicator indicator = new GlobalProgressDelayer(
            globalDisplay_, 500, "Reading RSA public key...").getIndicator();
    
      // compute path to public key
      String sshDir = session_.getSessionInfo().getDefaultSSHKeyDir();
      final String keyPath = FileSystemItem.createDir(sshDir).completePath(
                                                               "id_rsa.pub");
             
      // read it
      server_.gitSshPublicKey(keyPath, new ServerRequestCallback<String> () {
        
         @Override
         public void onResponseReceived(String publicKeyContents)
         {
            indicator.onCompleted();
           
            new ShowPublicKeyDialog("RSA Public Key",
                                    publicKeyContents).showModal();
         }

         @Override
         public void onError(ServerError error)
         {
            String msg = "Error attempting to read key '" + keyPath + "' (" +
                         error.getUserMessage() + ")";
            indicator.onError(msg);
         }
      });
   }
View Full Code Here

TOP

Related Classes of org.rstudio.core.client.widget.ProgressIndicator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.