use of com.google.gwt.event.logical.shared.ValueChangeHandler 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.event.logical.shared.ValueChangeHandler in project rstudio by rstudio.
the class EditSnippetsDialog method createMainWidget.
@Override
protected Widget createMainWidget() {
panel_ = new DockLayoutPanel(Unit.PX);
// compute the widget size and set it
Size size = new Size(900, 900);
size = DomMetrics.adjustedElementSize(size, null, // pad
70, // client margin
100);
panel_.setWidth(size.width + "px");
panel_.setHeight(size.height + "px");
// snippet types
snippetTypes_ = new WidgetListBox<EditableSnippets>();
snippetTypes_.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
updateEditor(snippetTypes_.getSelectedItem());
}
});
snippetTypes_.addItem(new EditableSnippets("R", FileTypeRegistry.R));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.CPP));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.MARKDOWN));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.TEX));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.JS));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.HTML));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.CSS));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.SQL));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.JAVA));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.PYTHON));
snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.STAN));
panel_.addWest(snippetTypes_, 150);
// editor
docDisplay_ = new AceEditor();
docDisplay_.setUseSoftTabs(false);
docDisplay_.setTabSize(uiPrefs_.numSpacesForTab().getValue());
docDisplay_.addValueChangeHandler(new ValueChangeHandler<Void>() {
@Override
public void onValueChange(ValueChangeEvent<Void> event) {
editorDirty_ = true;
}
});
docDisplay_.setFileType(FileTypeRegistry.SNIPPETS);
SimplePanel panel = new SimplePanel();
panel.addStyleName("EditDialog");
panel.getElement().getStyle().setMarginLeft(8, Unit.PX);
panel.setWidget(docDisplay_.asWidget());
panel_.add(panel);
TextEditingTarget.syncFontSize(releaseOnDismiss_, events_, this, fontSizeManager_);
snippetTypes_.setSelectedIndex(0, true);
return panel_;
}
use of com.google.gwt.event.logical.shared.ValueChangeHandler in project rstudio by rstudio.
the class DataImportOptionsUiCsv method initEvents.
void initEvents() {
ValueChangeHandler<String> valueChangeHandler = new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> arg0) {
updateEnabled();
triggerChange();
}
};
ChangeHandler changeHandler = new ChangeHandler() {
@Override
public void onChange(ChangeEvent arg0) {
updateEnabled();
triggerChange();
}
};
ChangeHandler delimChangeHandler = new ChangeHandler() {
@Override
public void onChange(ChangeEvent arg0) {
if (delimiterListBox_.getSelectedValue() == "other") {
globalDisplay_.promptForTextWithOption("Other Delimiter", "Please enter a single character delimiter.", "", false, "", false, new ProgressOperationWithInput<PromptWithOptionResult>() {
private void dismissAndUpdate(ProgressIndicator indicator, int newSelectIndex) {
lastDelimiterListBoxIndex_ = newSelectIndex;
delimiterListBox_.setSelectedIndex(newSelectIndex);
indicator.onCompleted();
updateEnabled();
triggerChange();
}
@Override
public void execute(PromptWithOptionResult result, ProgressIndicator indicator) {
String otherDelimiter = result.input;
if (otherDelimiter.length() != 1) {
globalDisplay_.showErrorMessage("Incorrect Delimiter", "The specified delimiter is not valid.");
} else {
for (int idxDelimiter = 0; idxDelimiter < delimiterListBox_.getItemCount(); idxDelimiter++) {
if (delimiterListBox_.getValue(idxDelimiter) == otherDelimiter) {
dismissAndUpdate(indicator, idxDelimiter);
return;
}
}
int selectedIndex = delimiterListBox_.getSelectedIndex();
delimiterListBox_.insertItem("Character " + otherDelimiter, otherDelimiter, selectedIndex - 1);
dismissAndUpdate(indicator, selectedIndex - 1);
}
}
}, new Operation() {
@Override
public void execute() {
delimiterListBox_.setSelectedIndex(lastDelimiterListBoxIndex_);
updateEnabled();
triggerChange();
}
});
} else {
lastDelimiterListBoxIndex_ = delimiterListBox_.getSelectedIndex();
updateEnabled();
triggerChange();
}
}
};
ValueChangeHandler<Boolean> booleanValueChangeHandler = new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> arg0) {
updateEnabled();
triggerChange();
}
};
nameTextBox_.addValueChangeHandler(valueChangeHandler);
delimiterListBox_.addChangeHandler(delimChangeHandler);
quotesListBox_.addChangeHandler(changeHandler);
escapeListBox_.addChangeHandler(changeHandler);
columnNamesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
trimSpacesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
openDataViewerCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
naListBox_.addChangeHandler(changeHandler);
commentListBox_.addChangeHandler(changeHandler);
skipTextBox_.addValueChangeHandler(valueChangeHandler);
localeButton_.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
new DataImportOptionsUiCsvLocale(new OperationWithInput<DataImportOptionsCsvLocale>() {
@Override
public void execute(final DataImportOptionsCsvLocale result) {
localeInfo_ = result;
updateEnabled();
triggerChange();
}
}, localeInfo_).showModal();
}
});
}
use of com.google.gwt.event.logical.shared.ValueChangeHandler in project rstudio by rstudio.
the class DataImportOptionsUiSav method initEvents.
void initEvents() {
ValueChangeHandler<String> valueChangeHandler = new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> arg0) {
updateEnabled();
triggerChange();
}
};
ChangeHandler changeHandler = new ChangeHandler() {
@Override
public void onChange(ChangeEvent arg0) {
updateEnabled();
triggerChange();
}
};
ValueChangeHandler<Boolean> booleanValueChangeHandler = new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> arg0) {
updateEnabled();
triggerChange();
}
};
nameTextBox_.addValueChangeHandler(valueChangeHandler);
formatListBox_.addChangeHandler(changeHandler);
openDataViewerCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
}
use of com.google.gwt.event.logical.shared.ValueChangeHandler in project rstudio by rstudio.
the class ImportFileSettingsDialog method hookChangeEvents.
private void hookChangeEvents() {
ValueChangeHandler<Boolean> valueChangeHandler = new ValueChangeHandler<Boolean>() {
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
updateOutput();
}
};
headingYes_.addValueChangeHandler(valueChangeHandler);
headingNo_.addValueChangeHandler(valueChangeHandler);
ChangeHandler changeHandler = new ChangeHandler() {
public void onChange(ChangeEvent event) {
updateOutput();
}
};
separator_.addChangeHandler(changeHandler);
decimal_.addChangeHandler(changeHandler);
quote_.addChangeHandler(changeHandler);
encoding_.addChangeHandler(changeHandler);
comment_.addChangeHandler(changeHandler);
}
Aggregations