use of com.google.gwt.user.client.ui.FlexTable in project perun by CESNET.
the class GetApplicationForm method createWidget.
/**
* Create approval style change widget
*
* @param form
*/
private void createWidget(final ApplicationForm form) {
final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
if (form != null) {
// create click handler
ClickHandler ch = new ClickHandler() {
public void onClick(ClickEvent event) {
// layout
FlexTable ft = new FlexTable();
ft.setCellSpacing(10);
ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
ft.setHTML(2, 0, "<strong>Module name: </strong>");
// widgets
final ListBox lbInit = new ListBox();
final ListBox lbExt = new ListBox();
final TextBox className = new TextBox();
lbInit.addItem("Automatic", "true");
lbInit.addItem("Manual", "false");
lbExt.addItem("Automatic", "true");
lbExt.addItem("Manual", "false");
if (form.getAutomaticApproval() == true) {
lbInit.setSelectedIndex(0);
} else {
lbInit.setSelectedIndex(1);
}
if (form.getAutomaticApprovalExtension() == true) {
lbExt.setSelectedIndex(0);
} else {
lbExt.setSelectedIndex(1);
}
className.setText(form.getModuleClassName());
ft.setWidget(0, 1, lbInit);
ft.setWidget(1, 1, lbExt);
ft.setWidget(2, 1, className);
// click on save
ClickHandler click = new ClickHandler() {
public void onClick(ClickEvent event) {
// switch and send request
UpdateForm request = new UpdateForm(new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// recreate same widget
content.clear();
ApplicationForm newForm = jso.cast();
createWidget(newForm);
}
;
});
form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
form.setModuleClassName(className.getText().trim());
request.updateForm(form);
}
};
Confirm c = new Confirm("Change application form settings", ft, click, true);
c.show();
}
};
button.addClickHandler(ch);
String appStyle = "<strong>Approval style: </strong>";
String module = "</br><strong>Module name: </strong>" + form.getModuleClassName();
if (form.getAutomaticApproval() == true) {
appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
} else {
appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
}
if (form.getAutomaticApprovalExtension() == true) {
appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
} else {
appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
}
if (form.getGroup() == null && !session.isVoAdmin(form.getVo().getId()))
button.setEnabled(false);
if (form.getGroup() != null && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
button.setEnabled(false);
content.setHTML(0, 0, appStyle + module);
content.setWidget(0, 1, button);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
} else {
button.setEnabled(false);
String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
String module = "</br><strong>Module name: </strong> Form doesn't exists.";
content.setHTML(0, 0, appStyle + module);
content.setWidget(0, 1, button);
content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
}
}
use of com.google.gwt.user.client.ui.FlexTable in project opentsdb by OpenTSDB.
the class QueryUi method onModuleLoad.
/**
* This is the entry point method.
*/
public void onModuleLoad() {
asyncGetJson(AGGREGATORS_URL, new GotJsonCallback() {
public void got(final JSONValue json) {
// Do we need more manual type checking? Not sure what will happen
// in the browser if something other than an array is returned.
final JSONArray aggs = json.isArray();
for (int i = 0; i < aggs.size(); i++) {
aggregators.add(aggs.get(i).isString().stringValue());
}
((MetricForm) metrics.getWidget(0)).setAggregators(aggregators);
refreshFromQueryString();
refreshGraph();
}
});
// All UI elements need to regenerate the graph when changed.
{
final ValueChangeHandler<Date> vch = new ValueChangeHandler<Date>() {
public void onValueChange(final ValueChangeEvent<Date> event) {
refreshGraph();
}
};
TextBox tb = start_datebox.getTextBox();
tb.addBlurHandler(refreshgraph);
tb.addKeyPressHandler(refreshgraph);
start_datebox.addValueChangeHandler(vch);
tb = end_datebox.getTextBox();
tb.addBlurHandler(refreshgraph);
tb.addKeyPressHandler(refreshgraph);
end_datebox.addValueChangeHandler(vch);
}
autoreoload_interval.addBlurHandler(refreshgraph);
autoreoload_interval.addKeyPressHandler(refreshgraph);
yrange.addBlurHandler(refreshgraph);
yrange.addKeyPressHandler(refreshgraph);
y2range.addBlurHandler(refreshgraph);
y2range.addKeyPressHandler(refreshgraph);
ylog.addClickHandler(new AdjustYRangeCheckOnClick(ylog, yrange));
y2log.addClickHandler(new AdjustYRangeCheckOnClick(y2log, y2range));
ylog.addClickHandler(refreshgraph);
y2log.addClickHandler(refreshgraph);
ylabel.addBlurHandler(refreshgraph);
ylabel.addKeyPressHandler(refreshgraph);
y2label.addBlurHandler(refreshgraph);
y2label.addKeyPressHandler(refreshgraph);
yformat.addBlurHandler(refreshgraph);
yformat.addKeyPressHandler(refreshgraph);
y2format.addBlurHandler(refreshgraph);
y2format.addKeyPressHandler(refreshgraph);
wxh.addBlurHandler(refreshgraph);
wxh.addKeyPressHandler(refreshgraph);
global_annotations.addBlurHandler(refreshgraph);
global_annotations.addKeyPressHandler(refreshgraph);
horizontalkey.addClickHandler(refreshgraph);
keybox.addClickHandler(refreshgraph);
nokey.addClickHandler(refreshgraph);
smooth.addClickHandler(refreshgraph);
styles.addChangeHandler(refreshgraph);
yrange.setValidationRegexp(// Nothing or
"^(" + // "[start
"|\\[([-+.0-9eE]+|\\*)?" + // :end]"
":([-+.0-9eE]+|\\*)?\\])$");
yrange.setVisibleLength(5);
// MAX=2^26=20 chars: "[-$MAX:$MAX]"
yrange.setMaxLength(44);
yrange.setText("[0:]");
y2range.setValidationRegexp(// Nothing or
"^(" + // "[start
"|\\[([-+.0-9eE]+|\\*)?" + // :end]"
":([-+.0-9eE]+|\\*)?\\])$");
y2range.setVisibleLength(5);
// MAX=2^26=20 chars: "[-$MAX:$MAX]"
y2range.setMaxLength(44);
y2range.setText("[0:]");
y2range.setEnabled(false);
y2log.setEnabled(false);
ylabel.setVisibleLength(10);
// Arbitrary limit.
ylabel.setMaxLength(50);
y2label.setVisibleLength(10);
// Arbitrary limit.
y2label.setMaxLength(50);
y2label.setEnabled(false);
// Nothing or at least one %?
yformat.setValidationRegexp("^(|.*%..*)$");
yformat.setVisibleLength(10);
// Arbitrary limit.
yformat.setMaxLength(16);
// Nothing or at least one %?
y2format.setValidationRegexp("^(|.*%..*)$");
y2format.setVisibleLength(10);
// Arbitrary limit.
y2format.setMaxLength(16);
y2format.setEnabled(false);
// 100x100
wxh.setValidationRegexp("^[1-9][0-9]{2,}x[1-9][0-9]{2,}$");
wxh.setVisibleLength(9);
// 99999x99999
wxh.setMaxLength(11);
wxh.setText((Window.getClientWidth() - 20) + "x" + (Window.getClientHeight() * 4 / 5));
final FlexTable table = new FlexTable();
table.setText(0, 0, "From");
{
final HorizontalPanel hbox = new HorizontalPanel();
hbox.add(new InlineLabel("To"));
final Anchor now = new Anchor("(now)");
now.addClickHandler(new ClickHandler() {
public void onClick(final ClickEvent event) {
end_datebox.setValue(new Date());
refreshGraph();
}
});
hbox.add(now);
hbox.add(autoreload);
hbox.setWidth("100%");
table.setWidget(0, 1, hbox);
}
autoreload.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(final ValueChangeEvent<Boolean> event) {
if (autoreload.getValue()) {
final HorizontalPanel hbox = new HorizontalPanel();
hbox.setWidth("100%");
hbox.add(new InlineLabel("Every:"));
hbox.add(autoreoload_interval);
hbox.add(new InlineLabel("seconds"));
table.setWidget(1, 1, hbox);
if (autoreoload_interval.getValue().isEmpty()) {
autoreoload_interval.setValue("15");
}
autoreoload_interval.setFocus(true);
// Force refreshGraph.
lastgraphuri = "";
// Trigger the 1st auto-reload
refreshGraph();
} else {
table.setWidget(1, 1, end_datebox);
}
}
});
// >=5s
autoreoload_interval.setValidationRegexp("^([5-9]|[1-9][0-9]+)$");
autoreoload_interval.setMaxLength(4);
autoreoload_interval.setVisibleLength(8);
table.setWidget(1, 0, start_datebox);
table.setWidget(1, 1, end_datebox);
{
final HorizontalPanel hbox = new HorizontalPanel();
hbox.add(new InlineLabel("WxH:"));
hbox.add(wxh);
table.setWidget(0, 3, hbox);
}
{
final HorizontalPanel hbox = new HorizontalPanel();
hbox.add(global_annotations);
table.setWidget(0, 4, hbox);
}
{
addMetricForm("metric 1", 0);
metrics.selectTab(0);
metrics.add(new InlineLabel("Loading..."), "+");
metrics.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) {
final int item = event.getItem();
final int nitems = metrics.getWidgetCount();
if (item == nitems - 1) {
// Last item: the "+" was clicked.
event.cancel();
final MetricForm metric = addMetricForm("metric " + nitems, item);
metrics.selectTab(item);
metric.setFocus(true);
}
}
});
table.setWidget(2, 0, metrics);
}
table.getFlexCellFormatter().setColSpan(2, 0, 2);
table.getFlexCellFormatter().setRowSpan(1, 3, 2);
final DecoratedTabPanel optpanel = new DecoratedTabPanel();
optpanel.add(makeAxesPanel(), "Axes");
optpanel.add(makeKeyPanel(), "Key");
optpanel.add(makeStylePanel(), "Style");
optpanel.selectTab(0);
table.setWidget(1, 3, optpanel);
table.getFlexCellFormatter().setColSpan(1, 3, 2);
final DecoratorPanel decorator = new DecoratorPanel();
decorator.setWidget(table);
final VerticalPanel graphpanel = new VerticalPanel();
graphpanel.add(decorator);
{
final VerticalPanel graphvbox = new VerticalPanel();
graphvbox.add(graphstatus);
graph.setVisible(false);
// Put the graph image element and the zoombox elements inside the absolute panel
graphbox.add(graph, 0, 0);
zoom_box.setVisible(false);
graphbox.add(zoom_box, 0, 0);
graph.addMouseOverHandler(new MouseOverHandler() {
public void onMouseOver(final MouseOverEvent event) {
final Style style = graphbox.getElement().getStyle();
style.setCursor(Cursor.CROSSHAIR);
}
});
graph.addMouseOutHandler(new MouseOutHandler() {
public void onMouseOut(final MouseOutEvent event) {
final Style style = graphbox.getElement().getStyle();
style.setCursor(Cursor.AUTO);
}
});
graphvbox.add(graphbox);
graph.addErrorHandler(new ErrorHandler() {
public void onError(final ErrorEvent event) {
graphstatus.setText("Oops, failed to load the graph.");
}
});
graph.addLoadHandler(new LoadHandler() {
public void onLoad(final LoadEvent event) {
graphbox.setWidth(graph.getWidth() + "px");
graphbox.setHeight(graph.getHeight() + "px");
}
});
graphpanel.add(graphvbox);
}
final DecoratedTabPanel mainpanel = new DecoratedTabPanel();
mainpanel.setWidth("100%");
mainpanel.add(graphpanel, "Graph");
mainpanel.add(stats_table, "Stats");
mainpanel.add(logs, "Logs");
mainpanel.add(build_data, "Version");
mainpanel.selectTab(0);
mainpanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
public void onBeforeSelection(final BeforeSelectionEvent<Integer> event) {
clearError();
final int item = event.getItem();
switch(item) {
case 1:
refreshStats();
return;
case 2:
refreshLogs();
return;
case 3:
refreshVersion();
return;
}
}
});
final VerticalPanel root = new VerticalPanel();
root.setWidth("100%");
root.add(current_error);
current_error.setVisible(false);
current_error.addStyleName("dateBoxFormatError");
root.add(mainpanel);
RootPanel.get("queryuimain").add(root);
// Must be done at the end, once all the widgets are attached.
ensureSameWidgetSize(optpanel);
History.addHistoryListener(this);
}
use of com.google.gwt.user.client.ui.FlexTable in project perun by CESNET.
the class UserExtSourceDetailTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(userExtSource.getLogin().trim()));
// MAIN TAB PANEL
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// The table
AbsolutePanel dp = new AbsolutePanel();
//dp.setStyleName("decoration");
final FlexTable menu = new FlexTable();
menu.setCellSpacing(5);
menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.worldIcon()));
Label memberName = new Label();
memberName.setText(Utils.getStrippedStringWithEllipsis(userExtSource.getLogin(), 40));
memberName.setStyleName("now-managing");
memberName.setTitle(userExtSource.getLogin());
menu.setWidget(0, 1, memberName);
int column = 2;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
if (JsonUtils.isExtendedInfoVisible()) {
menu.setHTML(0, column, "<strong>UES ID:</strong><br/><span class=\"inputFormInlineComment\">" + userExtSource.getId() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>ES name:</strong><br/><span class=\"inputFormInlineComment\">" + userExtSource.getExtSource().getName() + "</span>");
column++;
menu.setHTML(0, column, " ");
menu.getFlexCellFormatter().setWidth(0, column, "25px");
column++;
menu.setHTML(0, column, "<strong>ES type:</strong><br/><span class=\"inputFormInlineComment\">" + userExtSource.getExtSource().getType() + "</span>");
}
dp.add(menu);
vp.add(dp);
vp.setCellHeight(dp, "30px");
tabPanel.clear();
tabPanel.add(new UserExtSourceSettingsTabItem(userExtSource), "Settings");
// Resize must be called after page fully displays
Scheduler.get().scheduleDeferred(new Command() {
@Override
public void execute() {
tabPanel.finishAdding();
}
});
vp.add(tabPanel);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.user.client.ui.FlexTable in project drools-wb by kiegroup.
the class ActionInsertFactWidget method doLayout.
private void doLayout() {
layout.clear();
layout.setWidget(0, 0, getAssertLabel());
layout.setWidget(1, 0, new HTML(" "));
layout.getFlexCellFormatter().setColSpan(0, 0, 2);
FlexTable inner = new FlexTable();
int col = 0;
for (int i = 0; i < model.getFieldValues().length; i++) {
ActionFieldValue val = model.getFieldValues()[i];
inner.setWidget(i, 0 + col, fieldSelector(val));
inner.setWidget(i, 1 + col, valueEditor(val));
final int idx = i;
Image remove = GuidedRuleEditorImages508.INSTANCE.DeleteItemSmall();
remove.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisItem())) {
model.removeField(idx);
setModified(true);
getModeller().refreshWidget();
// Signal possible change in Template variables
TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent(getModeller().getModel());
getEventBus().fireEventFromSource(tvce, getModeller().getModel());
}
}
});
if (!this.readOnly) {
inner.setWidget(i, 2 + col, remove);
}
}
layout.setWidget(1, 1, inner);
}
use of com.google.gwt.user.client.ui.FlexTable in project drools-wb by kiegroup.
the class FromCollectCompositeFactPatternWidget method getCompositeLabel.
@Override
protected Widget getCompositeLabel() {
ClickHandler leftPatternclick = new ClickHandler() {
public void onClick(ClickEvent event) {
showFactTypeSelector();
}
};
ClickHandler rightPatternclick = new ClickHandler() {
public void onClick(ClickEvent event) {
Widget w = (Widget) event.getSource();
showRightPatternSelector(w);
}
};
String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from collect") + "</div>";
FlexTable panel = new FlexTable();
int r = 0;
if (pattern.getFactPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", leftPatternclick, !this.readOnly));
}
panel.setWidget(r++, 0, new HTML(lbl));
if (this.getFromCollectPattern().getRightPattern() == null) {
panel.setWidget(r++, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", rightPatternclick, !this.readOnly));
} else {
IPattern rPattern = this.getFromCollectPattern().getRightPattern();
RuleModellerWidget patternWidget = null;
if (rPattern instanceof FactPattern) {
patternWidget = new FactPatternWidget(this.getModeller(), this.getEventBus(), rPattern, true, true, this.readOnly);
} else if (rPattern instanceof FromAccumulateCompositeFactPattern) {
patternWidget = new FromAccumulateCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromAccumulateCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCollectCompositeFactPattern) {
patternWidget = new FromCollectCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCollectCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromEntryPointFactPattern) {
patternWidget = new FromEntryPointFactPatternWidget(this.getModeller(), this.getEventBus(), (FromEntryPointFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FromCompositeFactPattern) {
patternWidget = new FromCompositeFactPatternWidget(this.getModeller(), this.getEventBus(), (FromCompositeFactPattern) rPattern, this.readOnly);
} else if (rPattern instanceof FreeFormLine) {
patternWidget = new FreeFormLineWidget(this.getModeller(), this.getEventBus(), (FreeFormLine) rPattern, this.readOnly);
} else {
throw new IllegalArgumentException("Unsupported pattern " + rPattern + " for right side of FROM COLLECT");
}
patternWidget.addOnModifiedCommand(new Command() {
public void execute() {
setModified(true);
}
});
panel.setWidget(r++, 0, addRemoveButton(patternWidget, new ClickHandler() {
public void onClick(ClickEvent event) {
if (Window.confirm(GuidedRuleEditorResources.CONSTANTS.RemoveThisBlockOfData())) {
setModified(true);
getFromCollectPattern().setRightPattern(null);
getModeller().refreshWidget();
}
}
}));
}
return panel;
}
Aggregations