Search in sources :

Example 1 with ModelPropertyRenderer

use of com.extjs.gxt.ui.client.widget.ModelPropertyRenderer in project activityinfo by bedatadriven.

the class AddLockedPeriodDialog method initializeComponent.

private void initializeComponent() {
    setWidth(400);
    setHeight(280);
    setHeaderVisible(false);
    fieldsetContainer = new FieldSet();
    fieldsetContainer.setHeadingHtml(SafeHtmlUtils.htmlEscape(I18N.CONSTANTS.type()));
    comboboxProjects = new ComboBox<>();
    storeProjects = new ListStore<>();
    comboboxProjects.setStore(storeProjects);
    comboboxProjects.setDisplayField("name");
    comboboxProjects.setForceSelection(true);
    comboboxProjects.setTriggerAction(TriggerAction.ALL);
    comboboxProjects.setEditable(false);
    comboboxProjects.setItemRenderer(new MultilineRenderer<>(new ModelPropertyRenderer<>("name")));
    comboBoxFolder = new ComboBox<>();
    storeFolders = new ListStore<>();
    comboBoxFolder.setStore(storeFolders);
    comboBoxFolder.setDisplayField("name");
    comboBoxFolder.setForceSelection(true);
    comboBoxFolder.setTriggerAction(TriggerAction.ALL);
    comboBoxFolder.setEditable(false);
    comboboxProjects.setItemRenderer(new MultilineRenderer<>(new ModelPropertyRenderer<>("name")));
    comboboxActivities = new ComboBox<>();
    storeActivities = new ListStore<>();
    comboboxActivities.setStore(storeActivities);
    comboboxActivities.setDisplayField("name");
    comboboxActivities.setForceSelection(true);
    comboboxActivities.setTriggerAction(TriggerAction.ALL);
    comboboxActivities.setEditable(false);
    comboboxActivities.setItemRenderer(new MultilineRenderer<>(new ModelPropertyRenderer<>("name")));
    radiogroupContainer = new RadioGroup();
    radiogroupContainer.setFieldLabel(I18N.CONSTANTS.type());
    labelDatabase = new LabelField(I18N.CONSTANTS.database());
    labelDatabase.setWidth(100);
    labelDatabaseName = new LabelField();
    radioDatabase = new Radio();
    radioDatabase.setFieldLabel(I18N.CONSTANTS.database());
    radioDatabase.addListener(Events.Change, be -> setState());
    radiogroupContainer.add(radioDatabase);
    panelDatabase = new HorizontalPanel();
    panelDatabase.add(labelDatabase);
    panelDatabase.add(radioDatabase);
    panelDatabase.add(labelDatabaseName);
    fieldsetContainer.add(panelDatabase);
    radioFolder = new Radio();
    radioFolder.setFieldLabel(I18N.CONSTANTS.folder());
    radioFolder.addListener(Events.Change, be -> setState());
    labelFolder = new LabelField(I18N.CONSTANTS.folder());
    labelFolder.setWidth(100);
    panelFolder = new HorizontalPanel();
    panelFolder.add(labelFolder);
    panelFolder.add(radioFolder);
    panelFolder.add(comboBoxFolder);
    panelFolder.add(panelFolder);
    fieldsetContainer.add(panelFolder);
    radiogroupContainer.add(radioFolder);
    radioActivity = new Radio();
    radioActivity.setFieldLabel(I18N.CONSTANTS.activity());
    radioActivity.addListener(Events.Change, be -> setState());
    labelActivity = new LabelField(I18N.CONSTANTS.activity());
    labelActivity.setWidth(100);
    panelActivity = new HorizontalPanel();
    panelActivity.add(labelActivity);
    panelActivity.add(radioActivity);
    panelActivity.add(comboboxActivities);
    fieldsetContainer.add(panelActivity);
    radiogroupContainer.add(radioActivity);
    radioProject = new Radio();
    radioProject.setFieldLabel(I18N.CONSTANTS.project());
    radioProject.addListener(Events.Change, be -> setState());
    labelProject = new LabelField(I18N.CONSTANTS.project());
    labelProject.setWidth(100);
    panelProject = new HorizontalPanel();
    panelProject.add(labelProject);
    panelProject.add(radioProject);
    panelProject.add(comboboxProjects);
    fieldsetContainer.add(panelProject);
    radiogroupContainer.add(radioProject);
    add(fieldsetContainer);
    textfieldName = new TextField<>();
    textfieldName.setFieldLabel(I18N.CONSTANTS.name());
    textfieldName.setAllowBlank(false);
    add(textfieldName);
    checkboxEnabled = new CheckBox();
    checkboxEnabled.setFieldLabel(I18N.CONSTANTS.enabledColumn());
    add(checkboxEnabled);
    datefieldToDate = new DateField();
    datefieldFromDate = new DateField();
    datefieldFromDate.setFieldLabel(I18N.CONSTANTS.fromDate());
    datefieldFromDate.setAllowBlank(false);
    datefieldFromDate.setValidator((field, value) -> {
        if (datefieldFromDate.getValue().after(datefieldToDate.getValue())) {
            return I18N.CONSTANTS.fromDateIsBeforeToDate();
        }
        return null;
    });
    add(datefieldFromDate);
    datefieldToDate.setFieldLabel(I18N.CONSTANTS.toDate());
    datefieldToDate.setAllowBlank(false);
    add(datefieldToDate);
    radiogroupContainer.addListener(Events.Change, be -> {
        comboboxActivities.setAllowBlank(!radioActivity.getValue());
        comboboxProjects.setAllowBlank(!radioProject.getValue());
        comboboxActivities.clearInvalid();
        comboboxProjects.clearInvalid();
    });
    Scheduler.get().scheduleDeferred(this::setState);
}
Also used : ModelPropertyRenderer(com.extjs.gxt.ui.client.widget.ModelPropertyRenderer) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel)

Aggregations

HorizontalPanel (com.extjs.gxt.ui.client.widget.HorizontalPanel)1 ModelPropertyRenderer (com.extjs.gxt.ui.client.widget.ModelPropertyRenderer)1