Search in sources :

Example 1 with SwitchToTerminalEvent

use of org.rstudio.studio.client.workbench.views.terminal.events.SwitchToTerminalEvent in project rstudio by rstudio.

the class TerminalPopupMenu method getDynamicPopupMenu.

@Override
public void getDynamicPopupMenu(final DynamicPopupMenuCallback callback) {
    // clean out existing entries
    clearItems();
    addItem(commands_.newTerminal().createMenuItem(false));
    addSeparator();
    if (terminals_.terminalCount() > 0) {
        for (final String handle : terminals_) {
            Scheduler.ScheduledCommand cmd = new Scheduler.ScheduledCommand() {

                @Override
                public void execute() {
                    eventBus_.fireEvent(new SwitchToTerminalEvent(handle));
                }
            };
            String caption = trimCaption(terminals_.getCaption(handle));
            if (caption == null) {
                continue;
            }
            // visual indicator that terminal has processes running
            caption = addBusyIndicator(caption, terminals_.getHasSubprocs(handle));
            String menuHtml = AppCommand.formatMenuLabel(null, /*icon*/
            caption, /*label*/
            false, /*html*/
            null, /*shortcut*/
            null, /*rightImage*/
            null);
            /*rightImageDesc*/
            addItem(new MenuItem(menuHtml, true, cmd));
        }
        addSeparator();
        addItem(commands_.renameTerminal().createMenuItem(false));
        addItem(commands_.clearTerminalScrollbackBuffer().createMenuItem(false));
        addSeparator();
        addItem(commands_.previousTerminal().createMenuItem(false));
        addItem(commands_.nextTerminal().createMenuItem(false));
        addSeparator();
        addItem(commands_.closeTerminal().createMenuItem(false));
    }
    callback.onPopupMenu(this);
}
Also used : SwitchToTerminalEvent(org.rstudio.studio.client.workbench.views.terminal.events.SwitchToTerminalEvent) Scheduler(com.google.gwt.core.client.Scheduler) MenuItem(com.google.gwt.user.client.ui.MenuItem)

Example 2 with SwitchToTerminalEvent

use of org.rstudio.studio.client.workbench.views.terminal.events.SwitchToTerminalEvent in project rstudio by rstudio.

the class TerminalPane method onTerminalSessionStopped.

@Override
public void onTerminalSessionStopped(TerminalSessionStoppedEvent event) {
    // Figure out which terminal to switch to, send message to do so,
    // and remove the stopped terminal.
    TerminalSession currentTerminal = event.getTerminalWidget();
    String handle = currentTerminal.getHandle();
    String newTerminalHandle = terminalToShowWhenClosing(handle);
    if (newTerminalHandle != null) {
        events_.fireEvent(new SwitchToTerminalEvent(newTerminalHandle));
    }
    terminals_.removeTerminal(handle);
    terminalSessionsPanel_.remove(currentTerminal);
    if (newTerminalHandle == null) {
        activeTerminalToolbarButton_.setNoActiveTerminal();
        setTerminalTitle("");
    }
}
Also used : SwitchToTerminalEvent(org.rstudio.studio.client.workbench.views.terminal.events.SwitchToTerminalEvent)

Aggregations

SwitchToTerminalEvent (org.rstudio.studio.client.workbench.views.terminal.events.SwitchToTerminalEvent)2 Scheduler (com.google.gwt.core.client.Scheduler)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1