Search in sources :

Example 1 with Satellite

use of org.rstudio.studio.client.common.satellite.Satellite in project rstudio by rstudio.

the class AppCommand method doExecute.

private void doExecute() {
    assert enabled_ : "AppCommand executed when it was not enabled";
    if (!enabled_)
        return;
    assert visible_ : "AppCommand executed when it was not visible";
    if (!visible_)
        return;
    // if this window is a satellite but the command only wants to be handled
    // in the a different window, execute the command there instead
    Satellite satellite = RStudioGinjector.INSTANCE.getSatellite();
    if (getWindowMode() != WINDOW_MODE_ANY && Satellite.isCurrentWindowSatellite() && satellite.getSatelliteName() != getWindowMode()) {
        if (getWindowMode().equals(WINDOW_MODE_MAIN)) {
            // raise the main window if it's not a background command
            satellite.focusMainWindow();
        } else if (getWindowMode().equals(WINDOW_MODE_BACKGROUND) && Desktop.isDesktop()) {
            // for background commands, we still want the main window to be
            // as visible as possible, so bring it up behind the current window
            // (this is of course only possible in desktop mode)
            Desktop.getFrame().bringMainFrameBehindActive();
        }
        // satellites don't fire commands peer-to-peer--route it to the main
        // window for processing
        SatelliteManager mgr = RStudioGinjector.INSTANCE.getSatelliteManager();
        mgr.dispatchCommand(this, null);
        return;
    }
    if (enableNoHandlerAssertions_) {
        assert handlers_.getHandlerCount(CommandEvent.TYPE) > 0 : "AppCommand executed but nobody was listening";
    }
    handlers_.fireEvent(new CommandEvent(this));
}
Also used : SatelliteManager(org.rstudio.studio.client.common.satellite.SatelliteManager) Satellite(org.rstudio.studio.client.common.satellite.Satellite)

Aggregations

Satellite (org.rstudio.studio.client.common.satellite.Satellite)1 SatelliteManager (org.rstudio.studio.client.common.satellite.SatelliteManager)1