Search in sources :

Example 1 with SecondaryToolbar

use of org.rstudio.core.client.widget.SecondaryToolbar in project rstudio by rstudio.

the class EnvironmentPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    environmentMenu_ = new EnvironmentPopupMenu();
    environmentButton_ = new ToolbarButton(friendlyEnvironmentName(), imageOfEnvironment(environmentName_, environmentIsLocal_), environmentMenu_);
    toolbar.addLeftWidget(environmentButton_);
    SearchWidget searchWidget = new SearchWidget(new SuggestOracle() {

        @Override
        public void requestSuggestions(Request request, Callback callback) {
            // no suggestions
            callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>()));
        }
    });
    searchWidget.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            objects_.setFilterText(event.getValue());
        }
    });
    searchWidget.getElement().getStyle().setMarginTop(1, Unit.PX);
    toolbar.addRightWidget(searchWidget);
    return toolbar;
}
Also used : SearchWidget(org.rstudio.core.client.widget.SearchWidget) JsArrayString(com.google.gwt.core.client.JsArrayString) ToolbarButton(org.rstudio.core.client.widget.ToolbarButton) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) SuggestOracle(com.google.gwt.user.client.ui.SuggestOracle) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

Example 2 with SecondaryToolbar

use of org.rstudio.core.client.widget.SecondaryToolbar in project rstudio by rstudio.

the class ConnectionsPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    secondaryToolbar_ = new SecondaryToolbar();
    secondaryToolbar_.addLeftWidget(connectionName_ = new ToolbarLabel());
    return secondaryToolbar_;
}
Also used : ToolbarLabel(org.rstudio.core.client.widget.ToolbarLabel) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

Example 3 with SecondaryToolbar

use of org.rstudio.core.client.widget.SecondaryToolbar in project rstudio by rstudio.

the class HelpPane method createSecondaryToolbar.

@Override
protected SecondaryToolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    toolbar.addLeftPopupMenu(title_ = new Label(), history_.getMenu());
    if (isFindSupported()) {
        final SmallButton btnNext = new SmallButton("&gt;", true);
        btnNext.setTitle("Find next (Enter)");
        btnNext.setVisible(false);
        btnNext.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findNext();
            }
        });
        final SmallButton btnPrev = new SmallButton("&lt;", true);
        btnPrev.setTitle("Find previous");
        btnPrev.setVisible(false);
        btnPrev.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                findPrev();
            }
        });
        findTextBox_ = new FindTextBox("Find in Topic");
        findTextBox_.setOverrideWidth(90);
        toolbar.addLeftWidget(findTextBox_);
        findTextBox_.addKeyUpHandler(new KeyUpHandler() {

            @Override
            public void onKeyUp(KeyUpEvent event) {
                // ignore modifier key release
                if (event.getNativeKeyCode() == KeyCodes.KEY_CTRL || event.getNativeKeyCode() == KeyCodes.KEY_ALT || event.getNativeKeyCode() == KeyCodes.KEY_SHIFT) {
                    return;
                }
                WindowEx contentWindow = getContentWindow();
                if (contentWindow != null) {
                    // into the main content window
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
                        event.preventDefault();
                        event.stopPropagation();
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE)
                            clearTerm();
                        contentWindow.focus();
                    } else {
                        // minimizing or maximizing the help pane
                        if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                            event.preventDefault();
                            event.stopPropagation();
                        }
                        // check for term
                        String term = findTextBox_.getValue().trim();
                        int modifier = KeyboardShortcut.getModifierValue(event.getNativeEvent());
                        boolean isShift = modifier == KeyboardShortcut.SHIFT;
                        // if there is a term then search for it
                        if (term.length() > 0) {
                            // make buttons visible
                            setButtonVisibility(true);
                            // perform the find (check for incremental)
                            if (isIncrementalFindSupported()) {
                                boolean incremental = !event.isAnyModifierKeyDown() && (event.getNativeKeyCode() != KeyCodes.KEY_ENTER);
                                performFind(term, !isShift, incremental);
                            } else {
                                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                                    performFind(term, !isShift, false);
                            }
                        } else // no term means clear term and remove selection
                        {
                            if (isIncrementalFindSupported()) {
                                clearTerm();
                                contentWindow.removeSelection();
                            }
                        }
                    }
                }
            }

            private void clearTerm() {
                findTextBox_.setValue("");
                setButtonVisibility(false);
            }

            private void setButtonVisibility(final boolean visible) {
                Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    @Override
                    public void execute() {
                        btnNext.setVisible(visible);
                        btnPrev.setVisible(visible);
                    }
                });
            }
        });
        findTextBox_.addKeyDownHandler(new KeyDownHandler() {

            @Override
            public void onKeyDown(KeyDownEvent event) {
                // from handling them
                if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE || event.getNativeKeyCode() == KeyCodes.KEY_TAB || event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    event.preventDefault();
                    event.stopPropagation();
                }
            }
        });
        if (isIncrementalFindSupported()) {
            btnPrev.getElement().getStyle().setMarginRight(3, Unit.PX);
            toolbar.addLeftWidget(btnPrev);
            toolbar.addLeftWidget(btnNext);
        }
    }
    return toolbar;
}
Also used : KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) NativeKeyDownEvent(org.rstudio.core.client.events.NativeKeyDownEvent) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SmallButton(org.rstudio.core.client.widget.SmallButton) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar) WindowEx(org.rstudio.core.client.dom.WindowEx) FindTextBox(org.rstudio.core.client.widget.FindTextBox)

Example 4 with SecondaryToolbar

use of org.rstudio.core.client.widget.SecondaryToolbar in project rstudio by rstudio.

the class CodeBrowserEditingTargetWidget method createSecondaryToolbar.

private Toolbar createSecondaryToolbar() {
    SecondaryToolbar toolbar = new SecondaryToolbar();
    contextWidget_ = new CodeBrowserContextWidget(RES.styles());
    contextWidget_.addSelectionHandler(new SelectionHandler<String>() {

        @Override
        public void onSelection(SelectionEvent<String> event) {
            server_.getMethodDefinition(event.getSelectedItem(), new FunctionSearchRequestCallback(false));
        }
    });
    toolbar.addLeftWidget(contextWidget_);
    Label readOnlyLabel = new Label("(Read-only)");
    readOnlyLabel.addStyleName(RES.styles().readOnly());
    toolbar.addRightWidget(readOnlyLabel);
    return toolbar;
}
Also used : Label(com.google.gwt.user.client.ui.Label) SecondaryToolbar(org.rstudio.core.client.widget.SecondaryToolbar)

Aggregations

SecondaryToolbar (org.rstudio.core.client.widget.SecondaryToolbar)4 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)1 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)1 Label (com.google.gwt.user.client.ui.Label)1 SuggestOracle (com.google.gwt.user.client.ui.SuggestOracle)1 WindowEx (org.rstudio.core.client.dom.WindowEx)1 NativeKeyDownEvent (org.rstudio.core.client.events.NativeKeyDownEvent)1 FindTextBox (org.rstudio.core.client.widget.FindTextBox)1 SearchWidget (org.rstudio.core.client.widget.SearchWidget)1 SmallButton (org.rstudio.core.client.widget.SmallButton)1 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)1 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)1 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)1