Search in sources :

Example 41 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class CodeBrowserEditingTargetWidget method createToolbar.

private Toolbar createToolbar() {
    Toolbar toolbar = new EditingTargetToolbar(commands_, true);
    toolbar.addLeftWidget(commands_.printSourceDoc().createToolbarButton());
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(findReplace_.createFindReplaceButton());
    ImageResource icon = new ImageResource2x(ThemeResources.INSTANCE.codeTransform2x());
    ToolbarPopupMenu menu = new ToolbarPopupMenu();
    menu.addItem(commands_.goToHelp().createMenuItem(false));
    menu.addItem(commands_.goToFunctionDefinition().createMenuItem(false));
    ToolbarButton codeTools = new ToolbarButton("", icon, menu);
    codeTools.setTitle("Code Tools");
    toolbar.addLeftWidget(codeTools);
    toolbar.addRightWidget(commands_.executeCode().createToolbarButton());
    toolbar.addRightSeparator();
    toolbar.addRightWidget(commands_.executeLastCode().createToolbarButton());
    return toolbar;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) EditingTargetToolbar(org.rstudio.studio.client.workbench.views.source.editors.EditingTargetToolbar) ImageResource(com.google.gwt.resources.client.ImageResource) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) EditingTargetToolbar(org.rstudio.studio.client.workbench.views.source.editors.EditingTargetToolbar) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar) Toolbar(org.rstudio.core.client.widget.Toolbar)

Example 42 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class ChunkContextToolbar method initOptions.

// Private methods ---------------------------------------------------------
private void initOptions(boolean dark) {
    options_.setResource(new ImageResource2x(dark ? RES.chunkOptionsDark2x() : RES.chunkOptionsLight2x()));
    DOM.sinkEvents(options_.getElement(), Event.ONCLICK);
    DOM.setEventListener(options_.getElement(), new EventListener() {

        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) == Event.ONCLICK) {
                host_.showOptions(event.getClientX(), event.getClientY());
            }
        }
    });
}
Also used : ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Event(com.google.gwt.user.client.Event) EventListener(com.google.gwt.user.client.EventListener)

Example 43 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class CppCompletionSignatureTip method addPagingWidget.

private void addPagingWidget() {
    HorizontalPanel panel = new HorizontalPanel();
    panel.setStyleName(RES.styles().pagingWidget());
    Image upImage = new Image(new ImageResource2x(RES.upArrow2x()));
    upImage.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            setTextIndex(currentTextIndex_ - 1);
            docDisplay_.setFocus(true);
        }
    });
    panel.add(upImage);
    pagingLabel_ = new Label();
    panel.add(pagingLabel_);
    Image downImage = new Image(new ImageResource2x(RES.downArrow2x()));
    downImage.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            setTextIndex(currentTextIndex_ + 1);
            docDisplay_.setFocus(true);
        }
    });
    panel.add(downImage);
    panel.add(downImage);
    addLeftWidget(panel);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Image(com.google.gwt.user.client.ui.Image)

Example 44 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class TextEditingTargetWidget method createToolbar.

private Toolbar createToolbar(TextFileType fileType) {
    Toolbar toolbar = new EditingTargetToolbar(commands_, true);
    toolbar.addLeftWidget(commands_.saveSourceDoc().createToolbarButton());
    sourceOnSave_.getElement().getStyle().setMarginRight(0, Unit.PX);
    toolbar.addLeftWidget(sourceOnSave_);
    srcOnSaveLabel_.getElement().getStyle().setMarginRight(9, Unit.PX);
    toolbar.addLeftWidget(srcOnSaveLabel_);
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(commands_.checkSpelling().createToolbarButton());
    toolbar.addLeftWidget(findReplace_.createFindReplaceButton());
    toolbar.addLeftWidget(createCodeTransformMenuButton());
    notebookSeparatorWidget_ = toolbar.addLeftSeparator();
    toolbar.addLeftWidget(notebookToolbarButton_ = commands_.compileNotebook().createToolbarButton());
    int mod = BrowseCap.hasMetaKey() ? KeyboardShortcut.META : KeyboardShortcut.CTRL;
    String cmdText = new KeyboardShortcut(mod + KeyboardShortcut.SHIFT, 'K').toString(true);
    cmdText = DomUtils.htmlToText(cmdText);
    notebookToolbarButton_.setTitle("Compile Report (" + cmdText + ")");
    texSeparatorWidget_ = toolbar.addLeftSeparator();
    toolbar.addLeftWidget(texToolbarButton_ = createLatexFormatButton());
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(previewHTMLButton_ = commands_.previewHTML().createToolbarButton());
    knitDocumentButton_ = commands_.knitDocument().createToolbarButton(false);
    knitDocumentButton_.getElement().getStyle().setMarginRight(0, Unit.PX);
    toolbar.addLeftWidget(knitDocumentButton_);
    toolbar.addLeftWidget(compilePdfButton_ = commands_.compilePDF().createToolbarButton());
    rmdFormatButton_ = new ToolbarPopupMenuButton(false, true);
    rmdFormatButton_.getMenu().setAutoOpen(true);
    toolbar.addLeftWidget(rmdFormatButton_);
    runDocumentMenuButton_ = new ToolbarPopupMenuButton(false, true);
    addClearKnitrCacheMenu(runDocumentMenuButton_);
    runDocumentMenuButton_.addSeparator();
    runDocumentMenuButton_.addMenuItem(commands_.clearPrerenderedOutput().createMenuItem(false), "");
    toolbar.addLeftWidget(runDocumentMenuButton_);
    runDocumentMenuButton_.setVisible(false);
    ToolbarPopupMenu rmdOptionsMenu = new ToolbarPopupMenu();
    rmdOptionsMenu.addItem(commands_.editRmdFormatOptions().createMenuItem(false));
    rmdOptionsButton_ = new ToolbarButton(null, new ImageResource2x(StandardIcons.INSTANCE.options2x()), rmdOptionsMenu, false);
    toolbar.addLeftWidget(rmdOptionsButton_);
    toolbar.addLeftSeparator();
    toolbar.addLeftWidget(commands_.synctexSearch().createToolbarButton());
    // create menu of chunk skeletons based on common engine types
    ToolbarPopupMenu insertChunksMenu = new ToolbarPopupMenu();
    insertChunksMenu.addItem(commands_.insertChunkR().createMenuItem(false));
    insertChunksMenu.addSeparator();
    if (!BrowseCap.isWindowsDesktop()) {
        insertChunksMenu.addItem(commands_.insertChunkBash().createMenuItem(false));
    }
    insertChunksMenu.addItem(commands_.insertChunkPython().createMenuItem(false));
    insertChunksMenu.addItem(commands_.insertChunkRCPP().createMenuItem(false));
    insertChunksMenu.addItem(commands_.insertChunkSQL().createMenuItem(false));
    insertChunksMenu.addItem(commands_.insertChunkStan().createMenuItem(false));
    insertChunkMenu_ = new ToolbarButton("Insert", commands_.insertChunk().getImageResource(), insertChunksMenu, true);
    toolbar.addRightWidget(insertChunkMenu_);
    // create button that just runs default chunk insertion
    insertChunkButton_ = commands_.insertChunk().createToolbarButton(false);
    toolbar.addRightWidget(insertChunkButton_);
    toolbar.addRightWidget(runButton_ = commands_.executeCode().createToolbarButton(false));
    toolbar.addRightSeparator();
    toolbar.addRightWidget(runLastButton_ = commands_.executeLastCode().createToolbarButton(false));
    toolbar.addRightWidget(goToPrevButton_ = commands_.goToPrevSection().createToolbarButton(false));
    toolbar.addRightWidget(goToNextButton_ = commands_.goToNextSection().createToolbarButton(false));
    toolbar.addRightSeparator();
    final String SOURCE_BUTTON_TITLE = "Source the active document";
    sourceButton_ = new ToolbarButton("Source", commands_.sourceActiveDocument().getImageResource(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (uiPrefs_.sourceWithEcho().getValue())
                commands_.sourceActiveDocumentWithEcho().execute();
            else
                commands_.sourceActiveDocument().execute();
        }
    });
    sourceButton_.setTitle(SOURCE_BUTTON_TITLE);
    toolbar.addRightWidget(sourceButton_);
    uiPrefs_.sourceWithEcho().addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            if (event.getValue())
                sourceButton_.setTitle(SOURCE_BUTTON_TITLE + " (with echo)");
            else
                sourceButton_.setTitle(SOURCE_BUTTON_TITLE);
        }
    });
    ToolbarPopupMenu sourceMenu = new ToolbarPopupMenu();
    sourceMenu.addItem(commands_.sourceActiveDocument().createMenuItem(false));
    sourceMenu.addItem(commands_.sourceActiveDocumentWithEcho().createMenuItem(false));
    sourceMenuButton_ = new ToolbarButton(sourceMenu, true);
    toolbar.addRightWidget(sourceMenuButton_);
    //toolbar.addRightSeparator();
    ToolbarPopupMenu chunksMenu = new ToolbarPopupMenu();
    chunksMenu.addItem(commands_.executeCode().createMenuItem(false));
    chunksMenu.addSeparator();
    chunksMenu.addItem(commands_.executeCurrentChunk().createMenuItem(false));
    chunksMenu.addItem(commands_.executeNextChunk().createMenuItem(false));
    chunksMenu.addSeparator();
    chunksMenu.addItem(commands_.executeSetupChunk().createMenuItem(false));
    chunksMenu.addItem(runSetupChunkOptionMenu_ = new UIPrefMenuItem<Boolean>(uiPrefs_.autoRunSetupChunk(), true, "Run Setup Chunk Automatically", uiPrefs_));
    chunksMenu.addSeparator();
    chunksMenu.addItem(commands_.executePreviousChunks().createMenuItem(false));
    chunksMenu.addItem(commands_.executeSubsequentChunks().createMenuItem(false));
    if (uiPrefs_.showRmdChunkOutputInline().getValue()) {
        chunksMenu.addSeparator();
        chunksMenu.addItem(commands_.restartRRunAllChunks().createMenuItem(false));
        chunksMenu.addItem(commands_.restartRClearOutput().createMenuItem(false));
    }
    chunksMenu.addSeparator();
    chunksMenu.addItem(commands_.executeAllCode().createMenuItem(false));
    chunksButton_ = new ToolbarButton("Run", commands_.executeCode().getImageResource(), chunksMenu, true);
    toolbar.addRightWidget(chunksButton_);
    ToolbarPopupMenu shinyLaunchMenu = shinyViewerMenu_;
    shinyLaunchButton_ = new ToolbarButton(shinyLaunchMenu, true);
    shinyLaunchButton_.setVisible(false);
    toolbar.addRightWidget(shinyLaunchButton_);
    if (SessionUtils.showPublishUi(session_, uiPrefs_)) {
        toolbar.addRightSeparator();
        publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_APP, false, null);
        toolbar.addRightWidget(publishButton_);
    }
    toggleDocOutlineButton_ = new LatchingToolbarButton("", new ImageResource2x(StandardIcons.INSTANCE.outline2x()), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final double initialSize = editorPanel_.getWidgetSize(docOutlineWidget_);
            // Clicking the icon toggles the outline widget's visibility. The
            // 'destination' below is the width we would like to set -- we
            // animate to that position for a slightly nicer visual treatment.
            final double destination = docOutlineWidget_.getOffsetWidth() > 5 ? 0 : Math.min(editorPanel_.getOffsetWidth(), target_.getPreferredOutlineWidgetSize());
            // Update tooltip ('Show'/'Hide' depending on current visibility)
            String title = toggleDocOutlineButton_.getTitle();
            if (destination != 0)
                title = title.replace("Show ", "Hide ");
            else
                title = title.replace("Hide ", "Show ");
            toggleDocOutlineButton_.setTitle(title);
            toggleDocOutlineButton_.setLatched(destination != 0);
            new Animation() {

                @Override
                protected void onUpdate(double progress) {
                    double size = destination * progress + initialSize * (1 - progress);
                    editorPanel_.setWidgetSize(docOutlineWidget_, size);
                    editor_.onResize();
                }

                @Override
                protected void onComplete() {
                    target_.setPreferredOutlineWidgetVisibility(destination != 0);
                }
            }.run(500);
        }
    });
    // Time-out setting the latch just to ensure the document outline
    // has actually been appropriately rendered.
    new Timer() {

        @Override
        public void run() {
            String title = commands_.toggleDocumentOutline().getTooltip();
            title = editorPanel_.getWidgetSize(docOutlineWidget_) > 0 ? title.replace("Show ", "Hide ") : title.replace("Hide ", "Show ");
            toggleDocOutlineButton_.setTitle(title);
            toggleDocOutlineButton_.setLatched(docOutlineWidget_.getOffsetWidth() > 0);
        }
    }.schedule(100);
    toolbar.addRightSeparator();
    toolbar.addRightWidget(toggleDocOutlineButton_);
    return toolbar;
}
Also used : EditingTargetToolbar(org.rstudio.studio.client.workbench.views.source.editors.EditingTargetToolbar) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Timer(com.google.gwt.user.client.Timer) KeyboardShortcut(org.rstudio.core.client.command.KeyboardShortcut) RSConnectPublishButton(org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) Animation(com.google.gwt.animation.client.Animation) EditingTargetToolbar(org.rstudio.studio.client.workbench.views.source.editors.EditingTargetToolbar)

Example 45 with ImageResource2x

use of org.rstudio.core.client.resources.ImageResource2x in project rstudio by rstudio.

the class ViewerPane method createMainToolbar.

@Override
protected Toolbar createMainToolbar() {
    toolbar_ = new Toolbar();
    // add html widget buttons
    toolbar_.addLeftWidget(commands_.viewerBack().createToolbarButton());
    toolbar_.addLeftWidget(commands_.viewerForward().createToolbarButton());
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(commands_.viewerZoom().createToolbarButton());
    // export commands
    exportButtonSeparator_ = toolbar_.addLeftSeparator();
    ToolbarPopupMenu exportMenu = new ToolbarPopupMenu();
    exportMenu.addItem(commands_.viewerSaveAsImage().createMenuItem(false));
    exportMenu.addItem(commands_.viewerCopyToClipboard().createMenuItem(false));
    exportMenu.addSeparator();
    exportMenu.addItem(commands_.viewerSaveAsWebPage().createMenuItem(false));
    exportButton_ = new ToolbarButton("Export", new ImageResource2x(StandardIcons.INSTANCE.export_menu2x()), exportMenu);
    toolbar_.addLeftWidget(exportButton_);
    exportButton_.setVisible(false);
    exportButtonSeparator_.setVisible(false);
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(commands_.viewerClear().createToolbarButton());
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(commands_.viewerClearAll().createToolbarButton());
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(commands_.viewerPopout().createToolbarButton());
    toolbar_.addLeftSeparator();
    toolbar_.addLeftWidget(commands_.viewerStop().createToolbarButton());
    // add publish button 
    publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_DOCUMENT, true, null);
    toolbar_.addRightWidget(publishButton_);
    toolbar_.addRightSeparator();
    toolbar_.addRightWidget(commands_.viewerRefresh().createToolbarButton());
    // create an HTML generator 
    publishButton_.setPublishHtmlSource(new PublishHtmlSource() {

        @Override
        public void generatePublishHtml(final CommandWithArg<String> onCompleted) {
            server_.viewerCreateRPubsHtml(getTitle(), "", new ServerRequestCallback<String>() {

                @Override
                public void onResponseReceived(String htmlFile) {
                    onCompleted.execute(htmlFile);
                }

                @Override
                public void onError(ServerError error) {
                    globalDisplay_.showErrorMessage("Could Not Publish", error.getMessage());
                }
            });
        }

        @Override
        public String getTitle() {
            String title = frame_.getTitle();
            if (StringUtil.isNullOrEmpty(title))
                title = "Viewer Content";
            return title;
        }
    });
    return toolbar_;
}
Also used : ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) RSConnectPublishButton(org.rstudio.studio.client.rsconnect.ui.RSConnectPublishButton) PublishHtmlSource(org.rstudio.studio.client.rsconnect.model.PublishHtmlSource) ServerError(org.rstudio.studio.client.server.ServerError) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) Toolbar(org.rstudio.core.client.widget.Toolbar)

Aggregations

ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)13 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)13 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)11 ToolbarPopupMenu (org.rstudio.core.client.widget.ToolbarPopupMenu)10 ImageResource (com.google.gwt.resources.client.ImageResource)9 Image (com.google.gwt.user.client.ui.Image)7 Toolbar (org.rstudio.core.client.widget.Toolbar)6 Style (com.google.gwt.dom.client.Style)4 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Element (com.google.gwt.dom.client.Element)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 TextColumn (com.google.gwt.user.cellview.client.TextColumn)3 Event (com.google.gwt.user.client.Event)3 HTML (com.google.gwt.user.client.ui.HTML)3 Label (com.google.gwt.user.client.ui.Label)3 MessageDialogImages (org.rstudio.core.client.widget.images.MessageDialogImages)3 TableRowElement (com.google.gwt.dom.client.TableRowElement)2 Column (com.google.gwt.user.cellview.client.Column)2