Search in sources :

Example 11 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project rstudio by rstudio.

the class RmdTemplateOptionsWidget method addFormatOptions.

private void addFormatOptions(RmdTemplateFormat format) {
    if (format.getNotes().length() > 0 && allowFormatChange_) {
        labelFormatNotes_.setText(format.getNotes());
        labelFormatNotes_.setVisible(true);
    } else {
        labelFormatNotes_.setVisible(false);
    }
    optionWidgets_ = new ArrayList<RmdFormatOption>();
    JsArrayString options = format.getOptions();
    for (int i = 0; i < options.length(); i++) {
        RmdFormatOption optionWidget;
        RmdTemplateFormatOption option = findOption(format.getName(), options.get(i));
        if (option == null)
            continue;
        String initialValue = option.getDefaultValue();
        // check to see whether a value for this format and option were
        // specified in the front matter
        String frontMatterValue = getFrontMatterDefault(format.getName(), option.getName());
        if (frontMatterValue != null)
            initialValue = frontMatterValue;
        optionWidget = createWidgetForOption(option, initialValue);
        if (optionWidget == null)
            continue;
        optionWidget.asWidget().addStyleName(style.optionWidget());
        FlowPanel panel = null;
        String category = option.getCategory();
        if (tabs_.containsKey(category)) {
            panel = tabs_.get(category);
        } else {
            ScrollPanel scrollPanel = new ScrollPanel();
            panel = new FlowPanel();
            scrollPanel.add(panel);
            optionsTabs_.add(scrollPanel, new Label(category));
            tabs_.put(category, panel);
        }
        panel.add(optionWidget);
        optionWidgets_.add(optionWidget);
    }
    // we need to center the tabs and overlay them on the top edge of the
    // content; to do this, it is necessary to nuke a couple of the inline
    // styles used by the default GWT tab panel. 
    Element tabOuter = (Element) optionsTabs_.getElement().getChild(1);
    tabOuter.getStyle().setOverflow(Overflow.VISIBLE);
    Element tabInner = (Element) tabOuter.getFirstChild();
    tabInner.getStyle().clearWidth();
}
Also used : RmdTemplateFormatOption(org.rstudio.studio.client.rmarkdown.model.RmdTemplateFormatOption) Element(com.google.gwt.dom.client.Element) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Label(com.google.gwt.user.client.ui.Label) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 12 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project rstudio by rstudio.

the class FindOutputPane method createMainWidget.

@Override
protected Widget createMainWidget() {
    context_ = new FindResultContext();
    FindOutputResources resources = GWT.create(FindOutputResources.class);
    resources.styles().ensureInjected();
    table_ = new FastSelectTable<FindResult, CodeNavigationTarget, Object>(new FindOutputCodec(resources), resources.styles().selectedRow(), true, false);
    FontSizer.applyNormalFontSize(table_);
    table_.addStyleName(resources.styles().findOutput());
    table_.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (event.getNativeButton() != NativeEvent.BUTTON_LEFT)
                return;
            if (dblClick_.checkForDoubleClick(event.getNativeEvent()))
                fireSelectionCommitted();
        }

        private final DoubleClickState dblClick_ = new DoubleClickState();
    });
    table_.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                fireSelectionCommitted();
            event.stopPropagation();
            event.preventDefault();
        }
    });
    container_ = new SimplePanel();
    container_.setSize("100%", "100%");
    statusPanel_ = new StatusPanel();
    statusPanel_.setSize("100%", "100%");
    scrollPanel_ = new ScrollPanel(table_);
    scrollPanel_.setSize("100%", "100%");
    container_.setWidget(scrollPanel_);
    return container_;
}
Also used : CodeNavigationTarget(org.rstudio.core.client.CodeNavigationTarget) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) FindResult(org.rstudio.studio.client.workbench.views.output.find.model.FindResult)

Example 13 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project perun by CESNET.

the class SelfSponsoredUsersTabItem method draw.

@Override
public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    if (user.isSponsoredUser()) {
        // SERVICE TYPE user
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsors");
        // request
        final GetUsersBySpecificUser request = new GetUsersBySpecificUser(userId);
        // menu
        TabMenu menu = new TabMenu();
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
        menu.addWidget(UiElements.getRefreshButton(this));
        // table
        CellTable<User> table;
        if (session.isPerunAdmin()) {
            table = request.getTable(new FieldUpdater<User, String>() {

                public void update(int i, User user, String s) {
                    session.getTabManager().addTab(new SelfDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
        session.getUiElements().resizePerunTable(sp, 350, this);
    } else {
        // PERSON TYPE user
        this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsored users");
        // request
        final GetSpecificUsersByUser request = new GetSpecificUsersByUser(userId);
        request.setHideService(true);
        // menu
        TabMenu menu = new TabMenu();
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
        menu.addWidget(UiElements.getRefreshButton(this));
        // table
        CellTable<User> table;
        if (session.isPerunAdmin()) {
            table = request.getTable(new FieldUpdater<User, String>() {

                public void update(int i, User user, String s) {
                    session.getTabManager().addTab(new SelfDetailTabItem(user));
                }
            });
        } else {
            table = request.getTable();
        }
        table.addStyleName("perun-table");
        table.setWidth("100%");
        ScrollPanel sp = new ScrollPanel(table);
        sp.addStyleName("perun-tableScrollPanel");
        vp.add(sp);
        session.getUiElements().resizePerunTable(sp, 350, this);
    }
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) GetSpecificUsersByUser(cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser) GetUsersBySpecificUser(cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 14 with ScrollPanel

use of com.google.gwt.user.client.ui.ScrollPanel in project gerrit by GerritCodeReview.

the class NavigationTable method scrollIntoView.

protected void scrollIntoView(final Element tr) {
    if (!computedScrollType) {
        parentScrollPanel = null;
        Widget w = getParent();
        while (w != null) {
            if (w instanceof ScrollPanel) {
                parentScrollPanel = (ScrollPanel) w;
                break;
            }
            w = w.getParent();
        }
        computedScrollType = true;
    }
    if (parentScrollPanel != null) {
        parentScrollPanel.ensureVisible(new UIObject() {

            {
                setElement(tr);
            }
        });
    } else {
        int rt = tr.getAbsoluteTop();
        int rl = tr.getAbsoluteLeft();
        int rb = tr.getAbsoluteBottom();
        int wt = Window.getScrollTop();
        int wl = Window.getScrollLeft();
        int wh = Window.getClientHeight();
        int ww = Window.getClientWidth();
        int wb = wt + wh;
        // wb < rb: Row bottom is below bottom of window.
        if (rl < wl || rt < wt || wb < rt || wb < rb) {
            if (rl < wl) {
                // If the row fully fits in the window, set 0.
                if (tr.getAbsoluteRight() < ww) {
                    wl = 0;
                } else {
                    wl = Math.max(tr.getAbsoluteLeft() - 5, 0);
                }
            }
            // Vertically center the row in the window.
            int h = (wh - (rb - rt)) / 2;
            Window.scrollTo(wl, Math.max(rt - h, 0));
        }
    }
}
Also used : UIObject(com.google.gwt.user.client.ui.UIObject) Widget(com.google.gwt.user.client.ui.Widget) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Aggregations

ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)14 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)3 HTML (com.google.gwt.user.client.ui.HTML)3 Label (com.google.gwt.user.client.ui.Label)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ArrayList (java.util.ArrayList)3 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsArray (com.google.gwt.core.client.JsArray)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 GetGroupUnions (cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions)2 GetSpecificUsersByUser (cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser)2 GetUsersBySpecificUser (cz.metacentrum.perun.webgui.json.usersManager.GetUsersBySpecificUser)2 Group (cz.metacentrum.perun.webgui.model.Group)2