Package org.rstudio.studio.client.workbench.model

Examples of org.rstudio.studio.client.workbench.model.SessionInfo


      });
       
      eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
         public void onSessionInit(SessionInitEvent sie)
         {
            SessionInfo sessionInfo = session.getSessionInfo();

            // remove devtools commands if it isn't installed
            if (!sessionInfo.isDevtoolsInstalled())
            {
               commands.devtoolsLoadAll().remove();
            }
           
            // adapt or remove package commands if this isn't a package
            String type = sessionInfo.getBuildToolsType();
            if (!type.equals(SessionInfo.BUILD_TOOLS_PACKAGE))
            {
               commands.devtoolsLoadAll().remove();
               commands.buildSourcePackage().remove();
               commands.buildBinaryPackage().remove();
               commands.roxygenizePackage().remove();
               commands.checkPackage().remove();
               commands.testPackage().remove();
               commands.buildAll().setImageResource(
                                 BuildPaneResources.INSTANCE.iconBuild());
               commands.buildAll().setMenuLabel("_Build All");
               commands.buildAll().setButtonLabel("Build All");
               commands.buildAll().setDesc("Build all");
              
            }
           
            // remove makefile commands if this isn't a makefile
            if (type.equals(SessionInfo.BUILD_TOOLS_CUSTOM))
            {
               commands.rebuildAll().remove();
            }
           
            if (!type.equals(SessionInfo.BUILD_TOOLS_MAKEFILE))
            {
               commands.cleanAll().remove();
            }
           
            // remove all other commands if there are no build tools
            if (type.equals(SessionInfo.BUILD_TOOLS_NONE))
            {
               commands.buildAll().remove();
               commands.rebuildAll().remove();
               commands.cleanAll().remove();
               commands.stopBuild().remove();
               commands.activateBuild().remove();
            }
           
            // initialize from build state if necessary
            BuildState buildState = sessionInfo.getBuildState();
            if (buildState != null)
               shim.initialize(buildState);          
         }
      });
     
View Full Code Here


      sessionInit(session);
   }
  
   private void sessionInit(Session session)
   {
      SessionInfo sessionInfo = session.getSessionInfo();
      ClientInitState clientState = sessionInfo.getClientState();

      new StringStateValue(GROUP_CONSOLE, STATE_INPUT, ClientState.TEMPORARY, clientState) {
         @Override
         protected void onInit(String value)
         {
            initialInput_ = value;
         }
         @Override
         protected String getValue()
         {
            return view_.getInputEditorDisplay().getText();
         }
      };

      JsArrayString history = sessionInfo.getConsoleHistory();
      if (history != null)
         setHistory(history);

      RpcObjectList<ConsoleAction> actions = sessionInfo.getConsoleActions();
      if (actions != null)
      {
         view_.playbackActions(actions);
      }

      if (sessionInfo.getResumed())
      {
         // no special UI for this (resuming session with all console
         // history and other UI state preserved deemed adequate feedback)
      }
   }
View Full Code Here

   public static PackageLibraryType typeOfLibrary(Session session,
                                                  String library)
   {
      FileSystemItem projectDir = null;
      SessionInfo sessionInfo = session.getSessionInfo();
      if (sessionInfo != null)
         projectDir = sessionInfo.getActiveProjectDir();

      // if there's an active project and this package is in its library or
      // the package has no recorded library (i.e. it's not installed), it
      // belongs in the project library
      if (StringUtil.isNullOrEmpty(library) ||
View Full Code Here

      initSession();
   }

   private void initSession()
   {
      final SessionInfo sessionInfo = session_.getSessionInfo();
      ClientInitState state = sessionInfo.getClientState();

      // make the column sort order persistent
      new JSObjectStateValue(MODULE_FILES, KEY_SORT_ORDER, ClientState.PROJECT_PERSISTENT, state, false)
      {
         @Override
         protected void onInit(JsObject value)
         {
            if (value != null)
               columnSortOrder_ = value.cast();
            else
               columnSortOrder_ = null;
           
            lastKnownState_ = columnSortOrder_;
           
            view_.setColumnSortOrder(columnSortOrder_);
         }

         @Override
         protected JsObject getValue()
         {
            if (columnSortOrder_ != null)
               return columnSortOrder_.cast();
            else
               return null;
         }

         @Override
         protected boolean hasChanged()
         {
            if (lastKnownState_ != columnSortOrder_)
            {
               lastKnownState_ = columnSortOrder_;
               return true;
            }
            else
            {
               return false;
            }
         }

         private JsArray<ColumnSortInfo> lastKnownState_ = null;
      };
     
     
      // navigate to previous directory (works for resumed case)
      new StringStateValue(MODULE_FILES, KEY_PATH, ClientState.PROJECT_PERSISTENT, state) {
         @Override
         protected void onInit(final String value)
         {
            Scheduler.get().scheduleDeferred(new ScheduledCommand()
            {
               public void execute()
               {
                  // if we've already navigated to a directory then
                  // we don't need to initialize from client state
                  if (hasNavigatedToDirectory_)
                     return;

                  // compute start dir
                  String path = transformPathStateValue(value);
                  FileSystemItem start = path != null
                                    ? FileSystemItem.createDir(path)
                                    : FileSystemItem.createDir(
                                          sessionInfo.getInitialWorkingDir());
                  navigateToDirectory(start);
               }
            });
         }
View Full Code Here

     
      events.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
         @Override
         public void onSessionInit(SessionInitEvent sie)
         {   
            SessionInfo sessionInfo = session.getSessionInfo();
            CompilePdfState compilePdfState = sessionInfo.getCompilePdfState();
            if (compilePdfState.isTabVisible())
               shim_.initialize(compilePdfState);
         }
      });
   }
View Full Code Here

   }
  
   @Handler
   public void onNewRMarkdownDoc()
   {
      SessionInfo sessionInfo = session_.getSessionInfo();
      boolean useRMarkdownV2 = sessionInfo.getRMarkdownPackageAvailable();
     
      if (useRMarkdownV2)
         newRMarkdownV2Doc();
      else
         newRMarkdownV1Doc();
View Full Code Here

                                    prefs_.defaultSweaveEngine().getValue());
         }    
      }
           
      
      final SessionInfo sessionInfo = session_.getSessionInfo();
      TexCapabilities texCap = sessionInfo.getTexCapabilities();

      final boolean checkForTeX = fileType.canCompilePDF() &&
                                  !texCap.isTexInstalled();
     
      final boolean checkForRnwWeave = (rnwWeave != null) &&
                                       !texCap.isRnwWeaveAvailable(rnwWeave);
                                
      if (checkForTeX || checkForRnwWeave)
      {
         // alias variables to finals
         final boolean hasRnwWeaveDirective = rnwWeaveDirective != null;
         final RnwWeave fRnwWeave = rnwWeave;
        
         server_.getTexCapabilities(new ServerRequestCallback<TexCapabilities>()
         {
            @Override
            public void onResponseReceived(TexCapabilities response)
            {
               if (checkForTeX && !response.isTexInstalled())
               {
                  String warning;
                  if (Desktop.isDesktop())
                     warning = "No TeX installation detected. Please install " +
                               "TeX before compiling.";
                  else
                     warning = "This server does not have TeX installed. You " +
                               "may not be able to compile.";
                  display.showWarningBar(warning);
               }
               else if (checkForRnwWeave &&
                        !response.isRnwWeaveAvailable(fRnwWeave))
               {
                  String forContext = "";
                  if (hasRnwWeaveDirective)
                     forContext = "this file";
                  else if (sessionInfo.getActiveProjectFile() != null)
                     forContext = "Rnw files for this project";
                  else
                     forContext = "Rnw files";
                 
                  display.showWarningBar(
View Full Code Here

      eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler()
      {
         public void onSessionInit(SessionInitEvent sie)
         {
            SessionInfo sessionInfo = session.getSessionInfo();
           
            // only show the user identity if we are in server mode
           if (sessionInfo.getShowIdentity())
               initCommandsPanel(sessionInfo);
           
            // complete toolbar initialization
            toolbar_.completeInitialization(sessionInfo);
           
View Full Code Here

   }
  
   private FileSystemItem getSaveFileDefaultDir()
   {
      FileSystemItem fsi = null;
      SessionInfo si = session_.getSessionInfo();
       
      if (si.getBuildToolsType() == SessionInfo.BUILD_TOOLS_PACKAGE)
      {
         FileSystemItem pkg = FileSystemItem.createDir(si.getBuildTargetDir());
        
         if (fileType_.isR())
         {
            fsi = FileSystemItem.createDir(pkg.completePath("R"));
         }
         else if (fileType_.isC() && si.getHasPackageSrcDir())
         {
            fsi = FileSystemItem.createDir(pkg.completePath("src"));
         }
         else if (fileType_.isRd())
         {
            fsi = FileSystemItem.createDir(pkg.completePath("man"));
         }
         else if ((fileType_.isRnw() || fileType_.isRmd()) &&
                   si.getHasPackageVignetteDir())
         {
            fsi = FileSystemItem.createDir(pkg.completePath("vignettes"));
         }
      }
     
View Full Code Here

         previewHTML();
   }
  
   void previewRpresentation()
   {
      SessionInfo sessionInfo = session_.getSessionInfo();
      if (!fileTypeCommands_.getHTMLCapabiliites().isRMarkdownSupported())
      {
         globalDisplay_.showMessage(
               MessageDisplay.MSG_WARNING,
               "Unable to Preview",
               "R Presentations require the knitr package " +
               "(version 1.2 or higher)");
         return;
      }
     
      PresentationState state = sessionInfo.getPresentationState();
     
      // if we are showing a tutorial then don't allow preview
      if (state.isTutorial())
      {
         globalDisplay_.showMessage(
View Full Code Here

TOP

Related Classes of org.rstudio.studio.client.workbench.model.SessionInfo

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.