use of com.google.gwt.event.dom.client.ChangeHandler in project perun by CESNET.
the class GroupManagersTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": managers");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
final ListBox box = new ListBox();
box.addItem("Users");
box.addItem("Groups");
box.setSelectedIndex(selectedDropDownIndex);
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
// menu
final TabMenu menu = new TabMenu();
// group members
final GetRichAdminsWithAttributes admins = new GetRichAdminsWithAttributes(PerunEntity.GROUP, groupId, null);
final GetAdminGroups adminGroups = new GetAdminGroups(PerunEntity.GROUP, groupId);
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (box.getSelectedIndex() == 0) {
selectedDropDownIndex = 0;
sp.setWidget(fillContentUsers(admins, menu));
} else {
selectedDropDownIndex = 1;
sp.setWidget(fillContentGroups(adminGroups, menu));
}
}
});
if (selectedDropDownIndex == 0) {
sp.setWidget(fillContentUsers(admins, menu));
} else {
sp.setWidget(fillContentGroups(adminGroups, menu));
}
menu.addWidget(3, new HTML("<strong>Select mode: </strong>"));
menu.addWidget(4, box);
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(menu);
vp.setCellHeight(menu, "30px");
vp.add(sp);
sp.setStyleName("perun-tableScrollPanel");
this.contentWidget.setWidget(vp);
return getWidget();
}
use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.
the class DTCellValueWidgetFactory method makeListBoxForColumn.
private ListBox makeListBoxForColumn(final DropDownData dd, final Pattern52 basePattern, final BaseColumn baseCondition, final DTCellValue52 dcv, final boolean isMultipleSelect) {
final ListBox lb = makeListBox(dd, isMultipleSelect, dcv);
// Wire up update handler
lb.setEnabled(!isReadOnly);
if (!isReadOnly) {
lb.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String value = null;
if (lb.isMultipleSelect()) {
for (int i = 0; i < lb.getItemCount(); i++) {
if (lb.isItemSelected(i)) {
if (value == null) {
value = lb.getValue(i);
} else {
value = value + "," + lb.getValue(i);
}
}
}
} else {
int index = lb.getSelectedIndex();
if (index > -1) {
// Set base column value
value = lb.getValue(index);
}
}
dcv.setStringValue(value);
// Update any dependent enumerations
final LimitedEntryDropDownManager.Context context = new LimitedEntryDropDownManager.Context(basePattern, baseCondition);
Set<Integer> dependentColumnIndexes = dropDownManager.getDependentColumnIndexes(context);
for (Integer iCol : dependentColumnIndexes) {
BaseColumn column = model.getExpandedColumns().get(iCol);
if (column instanceof LimitedEntryCol) {
((LimitedEntryCol) column).setValue(null);
} else if (column instanceof DTColumnConfig52) {
((DTColumnConfig52) column).setDefaultValue(null);
}
}
}
});
}
return lb;
}
use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.
the class EditActionInsertPopup method initialiseClassNames.
private void initialiseClassNames() {
// Extract all class names available
final String[] classNames = oracle.getFactTypes();
classNameListBox.setEnabled(!(classNames == null || classNames.length == 0));
if (classNames == null || classNames.length == 0) {
classNameListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noBindings());
return;
}
// Add them to the ListBox
int selectedIndex = 0;
for (String className : classNames) {
classNameListBox.addItem(className);
if (className.equals(clone.getClassName())) {
selectedIndex = classNameListBox.getItemCount() - 1;
}
}
// Attach event handler before we set the selected index in case we're selecting the first item
classNameListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
final String className = classNameListBox.getItemText(classNameListBox.getSelectedIndex());
clone.setClassName(className);
clone.getFieldValues().clear();
initialiseFieldValues();
}
});
classNameListBox.setSelectedIndex(selectedIndex);
}
use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.
the class EditConstraintPopup method initialiseOperators.
private void initialiseOperators() {
oracle.getOperatorCompletions(clone.getClassName(), clone.getFieldName(), new Callback<String[]>() {
@Override
public void callback(final String[] operators) {
operatorListBox.clear();
operatorListBox.setEnabled(false);
if (operators == null) {
return;
}
int selectedIndex = 0;
operatorListBox.setEnabled(true);
operatorListBox.addItem(GuidedDecisionTreeConstants.INSTANCE.noOperator());
for (int index = 0; index < operators.length; index++) {
final String operator = operators[index];
if (operator.equals(clone.getOperator())) {
selectedIndex = index + 1;
}
operatorListBox.addItem(HumanReadable.getOperatorDisplayName(operator), operator);
}
operatorListBox.setSelectedIndex(selectedIndex);
initialiseValue();
}
});
operatorListBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(final ChangeEvent event) {
final int selectedIndex = operatorListBox.getSelectedIndex();
if (selectedIndex == 0) {
clone.setOperator(null);
} else {
clone.setOperator(operatorListBox.getValue(selectedIndex));
}
initialiseValue();
}
});
}
use of com.google.gwt.event.dom.client.ChangeHandler in project drools-wb by kiegroup.
the class ActionValueEditor method boundVariable.
private Widget boundVariable() {
// If there is a bound variable that is the same type of the current variable type, then display a list
ListBox listVariable = new ListBox();
listVariable.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
List<String> bindings = getApplicableBindings();
for (String v : bindings) {
listVariable.addItem(v);
}
// Pre-select applicable item
if (value.getValue().equals("=")) {
listVariable.setSelectedIndex(0);
} else {
for (int i = 0; i < listVariable.getItemCount(); i++) {
if (listVariable.getItemText(i).equals(value.getValue().substring(1))) {
listVariable.setSelectedIndex(i);
}
}
}
// Add event handler
if (listVariable.getItemCount() > 0) {
listVariable.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
ListBox w = (ListBox) event.getSource();
value.setValue("=" + w.getValue(w.getSelectedIndex()));
executeOnChangeCommand();
refresh();
}
});
}
if (this.readOnly) {
return new SmallLabel(listVariable.getItemText(listVariable.getSelectedIndex()));
}
return listVariable;
}
Aggregations