use of com.haulmont.cuba.web.toolkit.ui.CubaComboBox in project cuba by cuba-platform.
the class WebUserIndicator method refreshUserSubstitutions.
@Override
public void refreshUserSubstitutions() {
component.removeAllComponents();
UserSessionSource uss = AppBeans.get(UserSessionSource.NAME);
List<UserSubstitution> substitutions = getUserSubstitutions();
User user = uss.getUserSession().getUser();
AppUI ui = AppUI.getCurrent();
String substitutedUserCaption = getSubstitutedUserCaption(user);
if (substitutions.isEmpty()) {
userComboBox = null;
userNameLabel = new Label(substitutedUserCaption);
userNameLabel.setStyleName("c-user-select-label");
userNameLabel.setSizeUndefined();
if (ui.isTestMode()) {
userNameLabel.setCubaId("currentUserLabel");
}
component.addComponent(userNameLabel);
component.setDescription(substitutedUserCaption);
} else {
userNameLabel = null;
userComboBox = new CubaComboBox();
userComboBox.setFilteringMode(FilteringMode.CONTAINS);
userComboBox.setNullSelectionAllowed(false);
userComboBox.setImmediate(true);
if (ui.isTestMode()) {
userComboBox.setCubaId("substitutedUserSelect");
userComboBox.setId(ui.getTestIdManager().getTestId("substitutedUserSelect"));
}
userComboBox.setStyleName("c-user-select-combobox");
userComboBox.addItem(user);
userComboBox.setItemCaption(user, substitutedUserCaption);
for (UserSubstitution substitution : substitutions) {
User substitutedUser = substitution.getSubstitutedUser();
userComboBox.addItem(substitutedUser);
userComboBox.setItemCaption(substitutedUser, getSubstitutedUserCaption(substitutedUser));
}
UserSession session = uss.getUserSession();
userComboBox.select(session.getSubstitutedUser() == null ? session.getUser() : session.getSubstitutedUser());
userComboBox.addValueChangeListener(new SubstitutedUserChangeListener(userComboBox));
component.addComponent(userComboBox);
component.setDescription(null);
}
adjustWidth();
adjustHeight();
}
use of com.haulmont.cuba.web.toolkit.ui.CubaComboBox in project cuba by cuba-platform.
the class WebLookupField method createComponent.
protected void createComponent() {
this.component = new CubaComboBox() {
@Override
public void setPropertyDataSource(Property newDataSource) {
if (newDataSource == null)
super.setPropertyDataSource(null);
else
super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
}
@Override
public void setComponentError(ErrorMessage componentError) {
boolean handled = false;
if (componentErrorHandler != null)
handled = componentErrorHandler.handleError(componentError);
if (!handled)
super.setComponentError(componentError);
}
};
}
Aggregations