Search in sources :

Example 6 with Widget

use of com.google.gwt.user.client.ui.Widget in project opentsdb by OpenTSDB.

the class QueryUi method ensureSameWidgetSize.

/**
   * Ensures all the widgets in the given panel have the same size.
   * Otherwise by default the panel will automatically resize itself to the
   * contents of the currently active panel's widget, which is annoying
   * because it makes a number of things move around in the UI.
   * @param panel The panel containing the widgets to resize.
   */
private static void ensureSameWidgetSize(final DecoratedTabPanel panel) {
    if (!panel.isAttached()) {
        throw new IllegalArgumentException("panel not attached: " + panel);
    }
    int maxw = 0;
    int maxh = 0;
    for (final Widget widget : panel) {
        final int w = widget.getOffsetWidth();
        final int h = widget.getOffsetHeight();
        if (w > maxw) {
            maxw = w;
        }
        if (h > maxh) {
            maxh = h;
        }
    }
    if (maxw == 0 || maxh == 0) {
        throw new IllegalArgumentException("maxw=" + maxw + " maxh=" + maxh);
    }
    for (final Widget widget : panel) {
        setOffsetWidth(widget, maxw);
        setOffsetHeight(widget, maxh);
    }
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) EntryPoint(com.google.gwt.core.client.EntryPoint)

Example 7 with Widget

use of com.google.gwt.user.client.ui.Widget in project opentsdb by OpenTSDB.

the class QueryUi method addAllMetrics.

private boolean addAllMetrics(final StringBuilder url) {
    boolean found_metric = false;
    for (final Widget widget : metrics) {
        if (!(widget instanceof MetricForm)) {
            continue;
        }
        final MetricForm metric = (MetricForm) widget;
        found_metric |= metric.buildQueryString(url);
    }
    if (!found_metric) {
        graphstatus.setText("Please specify a metric.");
    }
    return found_metric;
}
Also used : Widget(com.google.gwt.user.client.ui.Widget)

Example 8 with Widget

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

the class WorkbenchTabPanel method add.

private void add(final WorkbenchTab tab) {
    if (tab.isSuppressed())
        return;
    tabs_.add(tab);
    final Widget widget = tab.asWidget();
    tabPanel_.add(widget, tab.getTitle(), false, !tab.closeable() ? null : new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tab.confirmClose(new Command() {

                @Override
                public void execute() {
                    tab.ensureHidden();
                }
            });
        }
    }, tab instanceof ProvidesBusy ? (ProvidesBusy) tab : null);
    tab.addEnsureVisibleHandler(new EnsureVisibleHandler() {

        public void onEnsureVisible(EnsureVisibleEvent event) {
            // First ensure that we ourselves are visible
            fireEvent(new EnsureVisibleEvent(event.getActivate()));
            if (event.getActivate())
                tabPanel_.selectTab(widget);
        }
    });
    tab.addEnsureHeightHandler(new EnsureHeightHandler() {

        @Override
        public void onEnsureHeight(EnsureHeightEvent event) {
            fireEvent(event);
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Widget(com.google.gwt.user.client.ui.Widget) ProvidesBusy(org.rstudio.core.client.widget.model.ProvidesBusy)

Example 9 with Widget

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

the class DelayLoadTabShim method onDelayLoadSuccess.

@Override
protected void onDelayLoadSuccess(T obj) {
    super.onDelayLoadSuccess(obj);
    final Widget child = obj.asWidget();
    if (child instanceof HasEnsureVisibleHandlers) {
        ((HasEnsureVisibleHandlers) child).addEnsureVisibleHandler(new EnsureVisibleHandler() {

            public void onEnsureVisible(EnsureVisibleEvent event) {
                parentTab_.ensureVisible(event.getActivate());
            }
        });
    }
    if (child instanceof HasEnsureHeightHandlers) {
        ((HasEnsureHeightHandlers) child).addEnsureHeightHandler(new EnsureHeightHandler() {

            @Override
            public void onEnsureHeight(EnsureHeightEvent event) {
                parentTab_.ensureHeight(event.getHeight());
            }
        });
    }
    if (child instanceof HasEnsureHiddenHandlers) {
        ((HasEnsureHiddenHandlers) child).addEnsureHiddenHandler(new EnsureHiddenHandler() {

            public void onEnsureHidden(EnsureHiddenEvent event) {
                parentTab_.ensureHidden();
            }
        });
    }
    child.setSize("100%", "100%");
    parentTab_.getPanel().add(child);
}
Also used : Widget(com.google.gwt.user.client.ui.Widget) IsWidget(com.google.gwt.user.client.ui.IsWidget)

Example 10 with Widget

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

the class Application method go.

public void go(final RootLayoutPanel rootPanel, final Command dismissLoadingProgress) {
    Widget w = view_.getWidget();
    rootPanel.add(w);
    rootPanel.setWidgetTopBottom(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
    rootPanel.setWidgetLeftRight(w, 0, Style.Unit.PX, 0, Style.Unit.PX);
    // attempt init
    pClientInit_.get().execute(new ServerRequestCallback<SessionInfo>() {

        public void onResponseReceived(final SessionInfo sessionInfo) {
            // initialize workbench after verifying agreement
            verifyAgreement(sessionInfo, new Operation() {

                public void execute() {
                    // directly to the user
                    if (ApplicationAction.isSwitchProject()) {
                        new Timer() {

                            @Override
                            public void run() {
                                dismissLoadingProgress.execute();
                            }
                        }.schedule(10000);
                    } else {
                        dismissLoadingProgress.execute();
                    }
                    session_.setSessionInfo(sessionInfo);
                    // initialize workbench
                    initializeWorkbench();
                }
            });
        }

        public void onError(ServerError error) {
            Debug.logError(error);
            dismissLoadingProgress.execute();
            globalDisplay_.showErrorMessage("RStudio Initialization Error", error.getUserMessage());
        }
    });
}
Also used : Timer(com.google.gwt.user.client.Timer) Widget(com.google.gwt.user.client.ui.Widget) InvalidSessionInfo(org.rstudio.studio.client.application.model.InvalidSessionInfo) SessionInfo(org.rstudio.studio.client.workbench.model.SessionInfo) Operation(org.rstudio.core.client.widget.Operation)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)56 FixedRatioWidget (org.rstudio.core.client.widget.FixedRatioWidget)5 PreWidget (org.rstudio.core.client.widget.PreWidget)5 Command (com.google.gwt.user.client.Command)4 HTML (com.google.gwt.user.client.ui.HTML)4 Timer (com.google.gwt.user.client.Timer)3 IsWidget (com.google.gwt.user.client.ui.IsWidget)3 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)3 Test (org.junit.Test)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsArrayString (com.google.gwt.core.client.JsArrayString)2 Element (com.google.gwt.dom.client.Element)2 Style (com.google.gwt.dom.client.Style)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JSONString (com.google.gwt.json.client.JSONString)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 Label (com.google.gwt.user.client.ui.Label)2 TabPanel (com.google.gwt.user.client.ui.TabPanel)2