Пример #1
0
  @Inject
  public ApplicationQuit(
      ApplicationServerOperations server,
      GlobalDisplay globalDisplay,
      EventBus eventBus,
      WorkbenchContext workbenchContext,
      SourceShim sourceShim,
      Provider<UIPrefs> pUiPrefs,
      Commands commands,
      Binder binder) {
    // save references
    server_ = server;
    globalDisplay_ = globalDisplay;
    eventBus_ = eventBus;
    workbenchContext_ = workbenchContext;
    sourceShim_ = sourceShim;
    pUiPrefs_ = pUiPrefs;

    // bind to commands
    binder.bind(commands, this);

    // subscribe to events
    eventBus.addHandler(SaveActionChangedEvent.TYPE, this);
    eventBus.addHandler(HandleUnsavedChangesEvent.TYPE, this);
    eventBus.addHandler(SuspendAndRestartEvent.TYPE, this);
  }
Пример #2
0
  @Inject
  public UIPrefs(Session session, EventBus eventBus, PrefsServerOperations server) {
    super(session.getSessionInfo().getUiPrefs(), session.getSessionInfo().getProjectUIPrefs());

    session_ = session;
    server_ = server;

    eventBus.addHandler(UiPrefsChangedEvent.TYPE, this);
  }
Пример #3
0
 @Inject
 public HTMLPreview(EventBus eventBus, final SatelliteManager satelliteManager) {
   eventBus.addHandler(
       ShowHTMLPreviewEvent.TYPE,
       new ShowHTMLPreviewHandler() {
         @Override
         public void onShowHTMLPreview(ShowHTMLPreviewEvent event) {
           // open the window
           satelliteManager.openSatellite(
               HTMLPreviewApplication.NAME, event.getParams(), new Size(950, 1200));
         }
       });
 }
Пример #4
0
  @Inject
  public WorkbenchListManager(
      EventBus events, Session session, WorkbenchListsServerOperations server) {
    session_ = session;
    server_ = server;

    listContexts_.put(FILE_MRU, new ListContext(FILE_MRU));
    listContexts_.put(PROJECT_MRU, new ListContext(PROJECT_MRU));
    listContexts_.put(PLOT_PUBLISH_MRU, new ListContext(PLOT_PUBLISH_MRU));
    listContexts_.put(HELP_HISTORY, new ListContext(HELP_HISTORY));
    listContexts_.put(USER_DICTIONARY, new ListContext(USER_DICTIONARY));
    listContexts_.put(ADDINS_MRU, new ListContext(ADDINS_MRU));

    events.addHandler(
        SessionInitEvent.TYPE,
        new SessionInitHandler() {
          @Override
          public void onSessionInit(SessionInitEvent sie) {
            WorkbenchLists lists = session_.getSessionInfo().getLists();
            updateList(FILE_MRU, lists);
            updateList(PROJECT_MRU, lists);
            updateList(PLOT_PUBLISH_MRU, lists);
            updateList(HELP_HISTORY, lists);
            updateList(USER_DICTIONARY, lists);
            updateList(ADDINS_MRU, lists);
          }
        });

    events.addHandler(
        ListChangedEvent.TYPE,
        new ListChangedHandler() {
          @Override
          public void onListChanged(ListChangedEvent event) {
            updateList(event.getName(), event.getList());
          }
        });
  }
Пример #5
0
  @Inject
  public Shell(
      ConsoleServerOperations server,
      EventBus eventBus,
      Display display,
      Session session,
      GlobalDisplay globalDisplay,
      Commands commands,
      UIPrefs uiPrefs,
      ErrorManager errorManager) {
    super();

    ((Binder) GWT.create(Binder.class)).bind(commands, this);

    server_ = server;
    eventBus_ = eventBus;
    view_ = display;
    globalDisplay_ = globalDisplay;
    commands_ = commands;
    errorManager_ = errorManager;
    input_ = view_.getInputEditorDisplay();
    historyManager_ = new CommandLineHistory(input_);
    browseHistoryManager_ = new CommandLineHistory(input_);
    prefs_ = uiPrefs;

    inputAnimator_ = new ShellInputAnimator(view_.getInputEditorDisplay());

    view_.setMaxOutputLines(session.getSessionInfo().getConsoleActionsLimit());

    keyDownPreviewHandlers_ = new ArrayList<KeyDownPreviewHandler>();
    keyPressPreviewHandlers_ = new ArrayList<KeyPressPreviewHandler>();

    InputKeyDownHandler handler = new InputKeyDownHandler();
    // This needs to be a capturing key down handler or else Ace will have
    // handled the event before we had a chance to prevent it
    view_.addCapturingKeyDownHandler(handler);
    view_.addKeyPressHandler(handler);

    eventBus.addHandler(ConsoleInputEvent.TYPE, this);
    eventBus.addHandler(ConsoleWriteOutputEvent.TYPE, this);
    eventBus.addHandler(ConsoleWriteErrorEvent.TYPE, this);
    eventBus.addHandler(ConsoleWritePromptEvent.TYPE, this);
    eventBus.addHandler(ConsoleWriteInputEvent.TYPE, this);
    eventBus.addHandler(ConsolePromptEvent.TYPE, this);
    eventBus.addHandler(ConsoleResetHistoryEvent.TYPE, this);
    eventBus.addHandler(ConsoleRestartRCompletedEvent.TYPE, this);
    eventBus.addHandler(ConsoleExecutePendingInputEvent.TYPE, this);
    eventBus.addHandler(SendToConsoleEvent.TYPE, this);
    eventBus.addHandler(DebugModeChangedEvent.TYPE, this);
    eventBus.addHandler(RunCommandWithDebugEvent.TYPE, this);
    eventBus.addHandler(UnhandledErrorEvent.TYPE, this);

    final CompletionManager completionManager =
        new RCompletionManager(
            view_.getInputEditorDisplay(), null, new CompletionPopupPanel(), server, null, null);
    addKeyDownPreviewHandler(completionManager);
    addKeyPressPreviewHandler(completionManager);

    addKeyDownPreviewHandler(new HistoryCompletionManager(view_.getInputEditorDisplay(), server));

    uiPrefs
        .insertMatching()
        .bind(
            new CommandWithArg<Boolean>() {
              public void execute(Boolean arg) {
                AceEditorNative.setInsertMatching(arg);
              }
            });

    sessionInit(session);
  }
Пример #6
0
  @Inject
  public Projects(
      GlobalDisplay globalDisplay,
      final Session session,
      Provider<ProjectMRUList> pMRUList,
      SharedProject sharedProject,
      FileDialogs fileDialogs,
      RemoteFileSystemContext fsContext,
      ApplicationQuit applicationQuit,
      ProjectsServerOperations projServer,
      PackratServerOperations packratServer,
      ApplicationServerOperations appServer,
      GitServerOperations gitServer,
      EventBus eventBus,
      Binder binder,
      final Commands commands,
      Provider<ProjectPreferencesDialog> pPrefDialog,
      Provider<UIPrefs> pUIPrefs) {
    globalDisplay_ = globalDisplay;
    eventBus_ = eventBus;
    pMRUList_ = pMRUList;
    applicationQuit_ = applicationQuit;
    projServer_ = projServer;
    packratServer_ = packratServer;
    appServer_ = appServer;
    gitServer_ = gitServer;
    fileDialogs_ = fileDialogs;
    fsContext_ = fsContext;
    session_ = session;
    pPrefDialog_ = pPrefDialog;
    pUIPrefs_ = pUIPrefs;

    binder.bind(commands, this);

    eventBus.addHandler(OpenProjectErrorEvent.TYPE, this);
    eventBus.addHandler(SwitchToProjectEvent.TYPE, this);
    eventBus.addHandler(OpenProjectFileEvent.TYPE, this);
    eventBus.addHandler(OpenProjectNewWindowEvent.TYPE, this);

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

            // ensure mru is initialized
            ProjectMRUList mruList = pMRUList_.get();

            // enable/disable commands
            String activeProjectFile = sessionInfo.getActiveProjectFile();
            boolean hasProject = activeProjectFile != null;
            commands.closeProject().setEnabled(hasProject);
            commands.projectOptions().setEnabled(hasProject);
            if (!hasProject) {
              commands.setWorkingDirToProjectDir().remove();
              commands.showDiagnosticsProject().remove();
            }
            boolean enableProjectSharing =
                hasProject
                    && pUIPrefs_.get().enableSharedProjectUi().getValue()
                    && sessionInfo.projectSupportsSharing();
            commands.shareProject().setEnabled(enableProjectSharing);
            commands.shareProject().setVisible(enableProjectSharing);

            // remove version control commands if necessary
            if (!sessionInfo.isVcsEnabled()) {
              commands.activateVcs().remove();
              commands.vcsCommit().remove();
              commands.vcsShowHistory().remove();
              commands.vcsPull().remove();
              commands.vcsPush().remove();
              commands.vcsCleanup().remove();
            } else {
              commands.activateVcs().setMenuLabel("Show _" + sessionInfo.getVcsName());

              // customize for svn if necessary
              if (sessionInfo.getVcsName().equals(VCSConstants.SVN_ID)) {
                commands.vcsPush().remove();
                commands.vcsPull().setButtonLabel("Update");
                commands.vcsPull().setMenuLabel("_Update");
              }

              // customize for git if necessary
              if (sessionInfo.getVcsName().equals(VCSConstants.GIT_ID)) {
                commands.vcsCleanup().remove();
              }
            }

            // disable the open project in new window if necessary
            if (!sessionInfo.getMultiSession()) commands.openProjectInNewWindow().remove();

            // maintain mru
            if (hasProject) mruList.add(activeProjectFile);
          }
        });
  }
Пример #7
0
  public DocUpdateSentinel(
      SourceServerOperations server,
      DocDisplay docDisplay,
      SourceDocument sourceDoc,
      ProgressIndicator progress,
      DirtyState dirtyState,
      EventBus events) {
    server_ = server;
    docDisplay_ = docDisplay;
    sourceDoc_ = sourceDoc;
    progress_ = progress;
    dirtyState_ = dirtyState;
    changeTracker_ = docDisplay.getChangeTracker();

    bufferedCommand_ =
        new TimeBufferedCommand(2000) {
          @Override
          protected void performAction(boolean shouldSchedulePassive) {
            assert !shouldSchedulePassive;
            maybeAutoSave();
          }
        };

    docDisplay_.addValueChangeHandler(this);

    // Web only
    closeHandlerReg_ =
        Window.addWindowClosingHandler(
            new ClosingHandler() {
              public void onWindowClosing(ClosingEvent event) {
                if (changesPending_)
                  event.setMessage(
                      "Some of your source edits are still being "
                          + "synchronized with the server. If you "
                          + "continue, your latest changes may be lost.");
              }
            });

    // Desktop only
    lastChanceSaveHandlerReg_ =
        events.addHandler(
            LastChanceSaveEvent.TYPE,
            new LastChanceSaveHandler() {
              public void onLastChanceSave(LastChanceSaveEvent event) {
                // We're quitting. Save one last time.

                final Token token = event.acquire();
                boolean saving =
                    doSave(
                        null,
                        null,
                        null,
                        new ProgressIndicator() {
                          public void onProgress(String message) {}

                          public void onCompleted() {
                            // We saved successfully. We're safe to quit now.
                            token.release();
                          }

                          public void onError(String message) {
                            // The save didn't succeed. Oh well. Nothing we can
                            // do but quit.
                            token.release();
                          }
                        });

                if (!saving) {
                  // No save was performed (not needed). We're safe to quit
                  // now, no need to wait for server requests to complete.
                  token.release();
                }
              }
            });
  }
Пример #8
0
  @Inject
  public WorkbenchScreen(
      EventBus eventBus,
      Session session,
      Provider<PaneManager> pPaneManager,
      final Edit.Shim edit,
      Commands commands,
      final Provider<MRUList> mruList,
      FontSizeManager fontSizeManager,
      OptionsLoader.Shim optionsLoader) {
    eventBus_ = eventBus;
    session_ = session;
    edit_ = edit;
    optionsLoader_ = optionsLoader;

    eventBus_.addHandler(ShowEditorEvent.TYPE, edit);
    eventBus_.addHandler(
        ChangeFontSizeEvent.TYPE,
        new ChangeFontSizeHandler() {
          public void onChangeFontSize(ChangeFontSizeEvent event) {
            FontSizer.setNormalFontSize(Document.get(), event.getFontSize());
            Scheduler.get()
                .scheduleDeferred(
                    new ScheduledCommand() {
                      public void execute() {
                        // Causes the console width to be remeasured
                        doOnPaneSizesChanged();
                      }
                    });
          }
        });
    FontSizer.setNormalFontSize(Document.get(), fontSizeManager.getSize());

    paneManager_ = pPaneManager.get();
    tabsPanel_ = paneManager_.getPanel();
    tabsPanel_.setSize("100%", "100%");
    tabsPanel_.addStyleDependentName("Workbench");

    // Prevent doOnPaneSizesChanged() from being called more than once
    // every N milliseconds. Note that the act of sending the client metrics
    // to the server also has its own buffer, so this one only needs to
    // minimize the expense of doing the calculation, not of sending data to
    // the server.
    paneSizesChangedCommand_ =
        new TimeBufferedCommand(200) {
          @Override
          protected void performAction(boolean shouldSchedulePassive) {
            assert !shouldSchedulePassive;
            doOnPaneSizesChanged();
          }
        };

    eventBus.addHandler(
        SessionInitEvent.TYPE,
        new SessionInitHandler() {
          public void onSessionInit(SessionInitEvent sie) {
            prefetch();
            mruList.get();
          }
        });

    eventBus.addHandler(
        LastSourceDocClosedEvent.TYPE,
        new LastSourceDocClosedHandler() {
          public void onLastSourceDocClosed(LastSourceDocClosedEvent event) {
            paneManager_
                .getSourceLogicalWindow()
                .onWindowStateChange(new WindowStateChangeEvent(WindowState.HIDE));
          }
        });

    eventBus.addHandler(
        WorkingDirChangedEvent.TYPE,
        new WorkingDirChangedHandler() {
          public void onWorkingDirChanged(WorkingDirChangedEvent event) {
            updateWorkingDirectory(event.getPath());
          }
        });

    ((PlotsTab) paneManager_.getTab(Tab.Plots))
        .addResizeHandler(
            new ResizeHandler() {
              public void onResize(ResizeEvent event) {
                onPaneSizesChanged();
              }
            });
    tabsPanel_.addSplitterResizedHandler(
        new SplitterResizedHandler() {
          public void onSplitterResized(SplitterResizedEvent event) {
            onPaneSizesChanged();
          }
        });

    // init widget
    initWidget(tabsPanel_);

    commandBinder.bind(commands, this);
  }
Пример #9
0
 @Inject
 public HelpTab(Shim shim, Binder binder, Commands commands, EventBus events) {
   super("Help", shim);
   binder.bind(commands, shim);
   events.addHandler(ShowHelpEvent.TYPE, shim);
 }