use of com.google.gwt.event.logical.shared.ValueChangeEvent in project perun by CESNET.
the class SuggestBox method addEventsToTextBox.
private void addEventsToTextBox() {
class TextBoxEvents extends HandlesAllKeyEvents implements ValueChangeHandler<String> {
public void onKeyDown(KeyDownEvent event) {
switch(event.getNativeKeyCode()) {
case KeyCodes.KEY_DOWN:
display.moveSelectionDown();
break;
case KeyCodes.KEY_UP:
display.moveSelectionUp();
break;
case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
Suggestion suggestion = display.getCurrentSelection();
if (suggestion == null) {
display.hideSuggestions();
} else {
setNewSelection(suggestion);
}
break;
}
delegateEvent(SuggestBox.this, event);
}
public void onKeyPress(KeyPressEvent event) {
delegateEvent(SuggestBox.this, event);
}
public void onKeyUp(KeyUpEvent event) {
// After every user key input, refresh the popup's suggestions.
refreshSuggestions();
delegateEvent(SuggestBox.this, event);
}
public void onValueChange(ValueChangeEvent<String> event) {
delegateEvent(SuggestBox.this, event);
}
}
TextBoxEvents events = new TextBoxEvents();
events.addKeyHandlersTo(box);
box.addValueChangeHandler(events);
}
use of com.google.gwt.event.logical.shared.ValueChangeEvent in project perun by CESNET.
the class AddFacilityDestinationTabItem method draw.
public Widget draw() {
titleWidget.setText("Add destination");
final VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexTable.FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
layout.setWidth("350px");
final ExtendedSuggestBox destination = new ExtendedSuggestBox();
final ListBox type = new ListBox();
type.addItem("HOST", "host");
type.addItem("USER@HOST", "user@host");
type.addItem("USER@HOST:PORT", "user@host:port");
type.addItem("URL", "url");
type.addItem("MAIL", "email");
type.addItem("SIGNED MAIL", "semail");
type.addItem("SERVICE SPECIFIC", "service-specific");
final ListBoxWithObjects<Service> services = new ListBoxWithObjects<Service>();
final CheckBox useHosts = new CheckBox(WidgetTranslation.INSTANCE.useFacilityHostnames(), false);
useHosts.setTitle(WidgetTranslation.INSTANCE.useFacilityHostnamesTitle());
final CheckBox onlyAssignedServices = new CheckBox("Show only services on facility", false);
onlyAssignedServices.setTitle("Click to show all possible services");
onlyAssignedServices.setValue(true);
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addDestination());
// fill oracle with hosts of facility
GetHosts getHosts = new GetHosts(facilityId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<Host> ho = JsonUtils.jsoAsList(jso);
for (Host h : ho) {
hosts.addAll(ho);
destination.getSuggestOracle().add(h.getName());
}
}
});
getHosts.retrieveData();
JsonCallbackEvents fillAssignedServices = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
services.removeAllOption();
services.clear();
ArrayList<Service> ses = JsonUtils.jsoAsList(jso);
if (ses != null && !ses.isEmpty()) {
ses = new TableSorter<Service>().sortByName(ses);
services.addAllItems(ses);
services.addAllOption();
services.setSelectedIndex(0);
} else {
services.addItem("No service available");
}
addButton.setEnabled(true);
type.setEnabled(true);
}
@Override
public void onError(PerunError error) {
services.removeAllOption();
services.clear();
services.addItem("Error while loading");
addButton.setEnabled(true);
type.setEnabled(true);
}
@Override
public void onLoadingStart() {
services.removeAllOption();
services.clear();
services.addItem("Loading...");
addButton.setEnabled(false);
type.setEnabled(false);
}
};
final GetFacilityAssignedServices getAssignedServices = new GetFacilityAssignedServices(facility.getId(), fillAssignedServices);
getAssignedServices.retrieveData();
final GetServices getAllServices = new GetServices(fillAssignedServices);
onlyAssignedServices.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
if (onlyAssignedServices.getValue() == false) {
onlyAssignedServices.setTitle("Click to show only services on facility");
getAllServices.retrieveData();
} else {
onlyAssignedServices.setTitle("Click to show all possible services");
getAssignedServices.retrieveData();
}
}
});
final Label destinationLabel = new Label();
destinationLabel.getElement().setInnerHTML("<strong>Host:</strong>");
final ExtendedSuggestBox.SuggestBoxValidator validator = new ExtendedSuggestBox.SuggestBoxValidator() {
@Override
public boolean validateSuggestBox() {
if (destination.getSuggestBox().getText().trim().isEmpty() && useHosts.getValue() == false) {
destination.setError("Destination value can't be empty.");
return false;
}
// check as email
if (type.getSelectedIndex() > 3 && type.getSelectedIndex() < 6) {
if (!JsonUtils.isValidEmail(destination.getSuggestBox().getText().trim())) {
destination.setError("Not valid email address.");
return false;
} else {
destination.setOk();
return true;
}
}
destination.setOk();
return true;
}
};
destination.setValidator(validator);
type.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
// if hosts - checkbox visible
if (type.getSelectedIndex() == 0) {
useHosts.setVisible(true);
} else {
useHosts.setVisible(false);
useHosts.setValue(false);
destination.getSuggestBox().setEnabled(true);
}
if (type.getSelectedIndex() < 3) {
destination.getSuggestOracle().clear();
for (Host h : hosts) {
destination.getSuggestOracle().add(h.getName());
}
} else {
destination.getSuggestOracle().clear();
}
// set label
if (type.getSelectedIndex() == 0) {
destinationLabel.getElement().setInnerHTML("<strong>Host:</strong>");
} else if (type.getSelectedIndex() == 1) {
destinationLabel.getElement().setInnerHTML("<strong>User@host:</strong>");
} else if (type.getSelectedIndex() == 2) {
destinationLabel.getElement().setInnerHTML("<strong>User@host:port:</strong>");
} else if (type.getSelectedIndex() == 3) {
destinationLabel.getElement().setInnerHTML("<strong>URL:</strong>");
} else if (type.getSelectedIndex() == 4) {
destinationLabel.getElement().setInnerHTML("<strong>Mail:</strong>");
} else if (type.getSelectedIndex() == 5) {
destinationLabel.getElement().setInnerHTML("<strong>Signed mail:</strong>");
} else if (type.getSelectedIndex() == 6) {
destinationLabel.getElement().setInnerHTML("<strong>Service specific:</strong>");
}
// run validation
validator.validateSuggestBox();
}
});
useHosts.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (useHosts.getValue() == true) {
destination.getSuggestBox().setEnabled(false);
destination.setOk();
} else {
destination.getSuggestBox().setEnabled(true);
}
}
});
cellFormatter.setColSpan(0, 0, 2);
HTML text = new HTML("Please add destinations for service configuration delivery. New service configuration can be performed directly on facility (dest. type HOST) or sent to URL or by an email.");
text.setStyleName("inputFormInlineComment");
layout.setWidget(0, 0, text);
layout.setHTML(1, 0, "Service:");
layout.setWidget(1, 1, services);
layout.setWidget(2, 1, onlyAssignedServices);
layout.setHTML(3, 0, "Type:");
layout.setWidget(3, 1, type);
layout.setWidget(4, 0, destinationLabel);
layout.setWidget(4, 1, destination);
layout.setWidget(5, 1, useHosts);
for (int i = 1; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
final TabItem tab = this;
TabMenu menu = new TabMenu();
menu.addWidget(addButton);
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (services.isEmpty()) {
// no services available
addButton.setEnabled(false);
}
if (validator.validateSuggestBox()) {
if (services.getSelectedIndex() == 0) {
// selected all
if (useHosts.getValue() == true) {
// auto by hosts
AddDestinationsByHostsOnFacility request = new AddDestinationsByHostsOnFacility(facility, JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addDestinationByHosts(services.getAllObjects());
} else {
// default
AddDestination request = new AddDestination(facility, JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addDestination(destination.getSuggestBox().getText().trim(), type.getValue(type.getSelectedIndex()), services.getAllObjects());
}
} else {
// selected one
if (useHosts.getValue() == true) {
// auto by hosts
AddDestinationsByHostsOnFacility request = new AddDestinationsByHostsOnFacility(facility, JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addDestinationByHosts(services.getSelectedObject());
} else {
// default
AddDestination request = new AddDestination(facility, JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
request.addDestination(destination.getSuggestBox().getText().trim(), type.getValue(type.getSelectedIndex()), services.getSelectedObject());
}
}
}
}
});
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, false);
}
}));
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.logical.shared.ValueChangeEvent in project drools-wb by kiegroup.
the class AuditLogViewImpl method makeEventTypeCheckBox.
private Widget makeEventTypeCheckBox(final String eventType, final Boolean isEnabled) {
final CheckBox chkEventType = new CheckBox(AuditLogEntryCellHelper.getEventTypeDisplayText(eventType));
chkEventType.setValue(Boolean.TRUE.equals(isEnabled));
chkEventType.addValueChangeHandler((ValueChangeEvent<Boolean> event) -> {
auditLog.getAuditLogFilter().getAcceptedTypes().put(eventType, event.getValue());
});
// BZ-996942: Use one column layout.
chkEventType.setWordWrap(false);
return new Column(ColumnSize.MD_2) {
{
add(chkEventType);
}
};
}
use of com.google.gwt.event.logical.shared.ValueChangeEvent in project drools-wb by kiegroup.
the class ConstraintValueEditor method returnValueEditor.
/**
* An editor for the retval "formula" (expression).
*/
private Widget returnValueEditor() {
TextBox box = new BoundTextBox(constraint);
if (this.readOnly) {
return new SmallLabel(box.getText());
}
String msg = GuidedRuleEditorResources.CONSTANTS.FormulaEvaluateToAValue();
Image img = new Image(GuidedRuleEditorResources.INSTANCE.images().functionAssets());
img.setTitle(msg);
box.setTitle(msg);
box.addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(final ValueChangeEvent event) {
executeOnValueChangeCommand();
}
});
Widget ed = widgets(img, box);
return ed;
}
use of com.google.gwt.event.logical.shared.ValueChangeEvent in project drools-wb by kiegroup.
the class Connectives method connectiveOperatorDropDown.
private void connectiveOperatorDropDown(final ConnectiveConstraint cc, final Callback<Widget> callback) {
if (!isReadOnly) {
final String factType = cc.getFactType();
final String fieldName = cc.getFieldName();
this.getDataModelOracle().getConnectiveOperatorCompletions(factType, fieldName, new Callback<String[]>() {
@Override
public void callback(final String[] operators) {
final CEPOperatorsDropdown dropdown = getDropdown(operators, cc);
dropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), "");
dropdown.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() {
public void onValueChange(ValueChangeEvent<OperatorSelection> event) {
OperatorSelection selection = event.getValue();
String selected = selection.getValue();
cc.setOperator(selected);
}
});
callback.callback(dropdown);
}
});
} else {
final SmallLabel w = new SmallLabel("<b>" + (cc.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(cc.getOperator())) + "</b>");
callback.callback(w);
}
}
Aggregations