Search in sources :

Example 1 with Commands

use of org.rstudio.studio.client.workbench.commands.Commands in project rstudio by rstudio.

the class CompilePanel method connectToolbar.

public void connectToolbar(Toolbar toolbar) {
    Commands commands = RStudioGinjector.INSTANCE.getCommands();
    ImageResource stopImage = commands.interruptR().getImageResource();
    stopButton_ = new ToolbarButton(stopImage, null);
    stopButton_.setVisible(false);
    toolbar.addRightWidget(stopButton_);
    showOutputButton_ = new LeftRightToggleButton("Output", "Issues", false);
    showOutputButton_.setVisible(false);
    showOutputButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(false);
            showErrorsButton_.setVisible(true);
            panel_.setWidget(outputDisplay_.asWidget());
            outputDisplay_.scrollToBottom();
        }
    });
    toolbar.addRightWidget(showOutputButton_);
    showErrorsButton_ = new LeftRightToggleButton("Output", "Issues", true);
    showErrorsButton_.setVisible(false);
    showErrorsButton_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showOutputButton_.setVisible(true);
            showErrorsButton_.setVisible(false);
            panel_.setWidget(errorList_);
        }
    });
    toolbar.addRightWidget(showErrorsButton_);
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ImageResource(com.google.gwt.resources.client.ImageResource) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Commands(org.rstudio.studio.client.workbench.commands.Commands) LeftRightToggleButton(org.rstudio.core.client.widget.LeftRightToggleButton)

Example 2 with Commands

use of org.rstudio.studio.client.workbench.commands.Commands in project rstudio by rstudio.

the class ChunkContextToolbar method initChangeChunkEngine.

@SuppressWarnings("unused")
private void initChangeChunkEngine(String engine) {
    chunkTypeLabel_.setText(engine);
    DOM.sinkEvents(chunkTypePanel_.getElement(), Event.ONCLICK);
    DOM.setEventListener(chunkTypePanel_.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) == Event.ONCLICK) {
                Commands commands = RStudioGinjector.INSTANCE.getCommands();
                String engineLabel = chunkTypeLabel_.getText();
                final ToolbarPopupMenu switchChunksMenu = new ToolbarPopupMenu();
                if (engineLabel != "r") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkR(), "r"));
                    switchChunksMenu.addSeparator();
                }
                if (!BrowseCap.isWindowsDesktop() && engineLabel != "bash") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkBash(), "bash"));
                }
                if (engineLabel != "python") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkPython(), "python"));
                }
                if (engineLabel != "rcpp") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkRCPP(), "rcpp"));
                }
                if (engineLabel != "sql") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkSQL(), "sql"));
                }
                if (engineLabel != "stan") {
                    switchChunksMenu.addItem(createMenuItemForType(commands.switchToChunkStan(), "stan"));
                }
                switchChunksMenu.setPopupPositionAndShow(new PositionCallback() {

                    @Override
                    public void setPosition(int offsetWidth, int offsetHeight) {
                        switchChunksMenu.setPopupPosition(chunkTypePanel_.getAbsoluteLeft() + chunkTypePanel_.getOffsetWidth() - offsetWidth + 15, chunkTypePanel_.getAbsoluteTop() + chunkTypePanel_.getOffsetHeight());
                    }
                });
            }
        }
    });
}
Also used : ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) PositionCallback(com.google.gwt.user.client.ui.PopupPanel.PositionCallback) Commands(org.rstudio.studio.client.workbench.commands.Commands) Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener)

Aggregations

Commands (org.rstudio.studio.client.workbench.commands.Commands)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 Event (com.google.gwt.user.client.Event)1 EventListener (com.google.gwt.user.client.EventListener)1 PositionCallback (com.google.gwt.user.client.ui.PopupPanel.PositionCallback)1 LeftRightToggleButton (org.rstudio.core.client.widget.LeftRightToggleButton)1 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)1 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)1