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);
}
}
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;
}
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);
}
});
}
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);
}
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());
}
});
}
Aggregations