Example usage for com.google.gwt.user.client.ui ValueListBox ValueListBox

List of usage examples for com.google.gwt.user.client.ui ValueListBox ValueListBox

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui ValueListBox ValueListBox.

Prototype

public ValueListBox(Renderer<T> renderer) 

Source Link

Usage

From source file:com.google.gerrit.client.admin.AccessSectionEditor.java

License:Apache License

public AccessSectionEditor(ProjectAccess access) {
    projectAccess = access;/*  w w  w.  j  a va2s.com*/

    permissionSelector = new ValueListBox<String>(PermissionNameRenderer.INSTANCE);
    permissionSelector.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            if (!Util.C.addPermission().equals(event.getValue())) {
                onAddPermission(event.getValue());
            }
        }
    });

    initWidget(uiBinder.createAndBindUi(this));
    permissions = ListEditor.of(new PermissionEditorSource());
}

From source file:com.google.gerrit.client.admin.PermissionRuleEditor.java

License:Apache License

public PermissionRuleEditor(boolean readOnly, AccessSection section, Permission permission,
        PermissionRange.WithDefaults validRange) {
    action = new ValueListBox<PermissionRule.Action>(actionRenderer);

    if (validRange != null && 10 < validRange.getRangeSize()) {
        min = new RangeBox.Box();
        max = new RangeBox.Box();

    } else if (validRange != null) {
        RangeBox.List minList = new RangeBox.List();
        RangeBox.List maxList = new RangeBox.List();
        List<Integer> valueList = validRange.getValuesAsList();

        minList.list.setValue(validRange.getMin());
        maxList.list.setValue(validRange.getMax());

        minList.list.setAcceptableValues(valueList);
        maxList.list.setAcceptableValues(valueList);

        min = minList;//from w  ww. java 2 s.co m
        max = maxList;

    } else {
        min = new RangeBox.Box();
        max = new RangeBox.Box();

        if (GlobalCapability.PRIORITY.equals(permission.getName())) {
            action.setValue(PermissionRule.Action.INTERACTIVE);
            action.setAcceptableValues(
                    Arrays.asList(PermissionRule.Action.INTERACTIVE, PermissionRule.Action.BATCH));

        } else {
            action.setValue(PermissionRule.Action.ALLOW);
            action.setAcceptableValues(Arrays.asList(PermissionRule.Action.ALLOW, PermissionRule.Action.DENY,
                    PermissionRule.Action.BLOCK));
        }
    }

    initWidget(uiBinder.createAndBindUi(this));

    String name = permission.getName();
    boolean canForce = PUSH.equals(name) || PUSH_TAG.equals(name);
    if (canForce) {
        String ref = section.getName();
        canForce = !ref.startsWith("refs/for/") && !ref.startsWith("^refs/for/");
        force.setText(PermissionRule.FORCE_PUSH);
    } else {
        canForce = EDIT_TOPIC_NAME.equals(name);
        force.setText(PermissionRule.FORCE_EDIT);
    }
    force.setVisible(canForce);
    force.setEnabled(!readOnly);

    if (validRange != null) {
        min.setEnabled(!readOnly);
        max.setEnabled(!readOnly);
        action.getElement().getStyle().setDisplay(Display.NONE);

    } else {
        rangeEditor.getStyle().setDisplay(Display.NONE);
        DOM.setElementPropertyBoolean(action.getElement(), "disabled", readOnly);
    }

    if (readOnly) {
        deleteRule.removeFromParent();
        deleteRule = null;
    }
}

From source file:com.gwtplatform.carstore.client.application.cars.car.CarMobileView.java

License:Apache License

@Inject
CarMobileView(Binder uiBinder, Driver driver) {
    manufacturer = new ValueListBox<ManufacturerDto>(new ManufacturerRenderer());
    this.driver = driver;

    initWidget(uiBinder.createAndBindUi(this));

    driver.initialize(this);

    model.getElement().setAttribute("placeholder", "Model");
}

From source file:com.gwtplatform.carstore.client.application.cars.car.CarView.java

License:Apache License

@Inject
CarView(Binder uiBinder, Driver driver) {
    manufacturer = new ValueListBox<ManufacturerDto>(new ManufacturerRenderer());
    this.driver = driver;

    initWidget(uiBinder.createAndBindUi(this));

    driver.initialize(this);
}

From source file:com.gwtplatform.carstore.client.application.rating.RatingDetailView.java

License:Apache License

@Inject
public RatingDetailView(Binder uiBinder, Driver driver) {
    this.driver = driver;

    car = new ValueListBox<CarDto>(new CarRenderer());

    initWidget(uiBinder.createAndBindUi(this));

    driver.initialize(this);

    rating.getElement().setAttribute("placeholder", "Your rating");
}

From source file:com.gwtplatform.carstore.client.application.rating.ui.EditRatingView.java

License:Apache License

@Inject
EditRatingView(Binder uiBinder, Driver driver, EventBus eventBus) {
    super(eventBus);

    car = new ValueListBox<CarDto>(new CarRenderer());
    this.driver = driver;

    initWidget(uiBinder.createAndBindUi(this));

    driver.initialize(this);
}

From source file:com.redspr.redquerybuilder.core.client.expression.SelectEditorWidget.java

License:Open Source License

SelectEditorWidget(Session session, final Column col, boolean multi) {
    if (multi) {/*from  w w w .j ava  2  s  . com*/
        box = new ValueMultiListBox<Object>(renderer);
    } else {
        box = new ValueListBox<Object>(renderer);
    }
    tableName = col.getTable().getName();
    columnName = col.getName();
    columnType = col.getType().getName();

    initWidget((Widget) box);

    Object v = col.getEditor().getDefault();
    box.setValue(v);

    EnumerateRequest er = new EnumerateRequest();
    er.setTableName(tableName);
    er.setColumnName(columnName);
    er.setColumnTypeName(columnType);

    // XXX make all async?
    session.getConfig().fireEnumerate(er, new AsyncCallback<SuggestOracle.Response>() {

        @Override
        public void onFailure(Throwable caught) {
            throw new RuntimeException("not AsyncCallback<Response>.onFailure implemented", caught);
        }

        @Override
        public void onSuccess(SuggestOracle.Response result) {
            Object v = col.getEditor().getDefault();

            if (box instanceof ValueListBox) {
                keyToTitle.put(v, "Please select...");
            }
            for (Suggestion s : result.getSuggestions()) {
                keyToTitle.put(s.getReplacementString(), s.getDisplayString());
            }

            if (box instanceof HasConstrainedValue) {
                ((HasConstrainedValue) box).setAcceptableValues(keyToTitle.keySet());
            } else {
                ((ValueMultiListBox) box).setAcceptableValues(keyToTitle.keySet());
            }
        }
    });
}

From source file:com.vividcode.imap.app.client.web.application.admin.users.ui.UserEditor.java

License:Apache License

@Inject
UserEditor(Binder uiBinder, Driver driver) {
    this.driver = driver;
    this.authority = new ValueListBox<Authority>(new EnumRenderer<Authority>());

    initWidget(uiBinder.createAndBindUi(this));
    driver.initialize(this);

    authority.setAcceptableValues(Arrays.asList(Authority.values()));
}

From source file:jdramaix.client.ScrollListSample.java

License:Apache License

private Widget createEffectSelector() {
    ValueListBox<Effect> listBox = new ValueListBox<Effect>(new AbstractRenderer<Effect>() {
        @Override//from w  ww . j a v a  2  s  . co  m
        public String render(Effect object) {
            return object != null ? object.name().toLowerCase() : "";
        }
    });

    listBox.setValue(currentEffect);
    listBox.setAcceptableValues(Arrays.asList(Effect.values()));
    listBox.addValueChangeHandler(new ValueChangeHandler<Effect>() {
        @Override
        public void onValueChange(ValueChangeEvent<Effect> event) {
            Effect effect = event.getValue();

            if (currentEffect != Effect.NONE) {
                effectContainer.removeClassName(currentEffect.getEffectStyle());
            }

            if (effect != Effect.NONE) {
                effectContainer.addClassName(effect.getEffectStyle());
            }

            currentEffect = effect;
        }
    });
    return listBox;
}

From source file:org.javahispano.javaleague.client.application.cars.car.CarMobileView.java

License:Apache License

@Inject
CarMobileView(Binder uiBinder, Driver driver, CarPropertiesEditor carProperties) {
    this.driver = driver;
    this.carProperties = carProperties;
    manufacturer = new ValueListBox<>(new ManufacturerRenderer());

    initWidget(uiBinder.createAndBindUi(this));

    driver.initialize(this);

    model.getElement().setAttribute("placeholder", "Model");
}