Java Code Examples for org.apache.wicket.markup.html.form.DropDownChoice#setNullValid()

The following examples show how to use org.apache.wicket.markup.html.form.DropDownChoice#setNullValid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalSearchAnnotationSidebar.java    From inception with Apache License 2.0 6 votes vote down vote up
public DocumentRepositorySelectionForm(String aId)
{
    super(aId);

    DropDownChoice<DocumentRepository> repositoryCombo =
        new BootstrapSelect<DocumentRepository>("repositoryCombo",
        new PropertyModel<DocumentRepository>(ExternalSearchAnnotationSidebar.this,
            "currentRepository"), repositoriesModel);

    repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name"));
    repositoryCombo.setNullValid(false);

    // Just update the selection
    repositoryCombo.add(new LambdaAjaxFormComponentUpdatingBehavior("change"));
    add(repositoryCombo);

}
 
Example 2
Source File: SearchPage.java    From inception with Apache License 2.0 6 votes vote down vote up
public SearchForm(String id)
{
    super(id);
    
    setModel(CompoundPropertyModel.of(new SearchFormModel()));
    
    DropDownChoice<DocumentRepository> repositoryCombo = 
            new BootstrapSelect<DocumentRepository>("repository");
    repositoryCombo.setChoices(LoadableDetachableModel
            .of(() -> externalSearchService.listDocumentRepositories(project)));
    repositoryCombo.setChoiceRenderer(new ChoiceRenderer<DocumentRepository>("name"));
    repositoryCombo.setNullValid(false);
    add(repositoryCombo);
    
    if (!repositoryCombo.getChoices().isEmpty()) {
        repositoryCombo.setModelObject(repositoryCombo.getChoices().get(0));
    }
    
    add(new TextField<>("query", String.class));
    
    LambdaAjaxSubmitLink searchLink = new LambdaAjaxSubmitLink("submitSearch",
            this::actionSearch);
    add(searchLink);
    setDefaultButton(searchLink);
}
 
Example 3
Source File: UserEditForm.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
private static void addDateFormatCombobox(final GridBuilder gridBuilder, final PFUserDO user, final String labelKey,
    final String property, final String[] dateFormats, final boolean convertExcelFormat)
{
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString(labelKey));
  final LabelValueChoiceRenderer<String> dateFormatChoiceRenderer = new LabelValueChoiceRenderer<String>();
  for (final String str : dateFormats) {
    String dateString = "???";
    final String pattern = convertExcelFormat == true ? str.replace('Y', 'y').replace('D', 'd') : str;
    try {
      final SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
      dateString = dateFormat.format(new Date());
    } catch (final Exception ex) {
      log.warn("Invalid date format in config.xml: " + pattern);
    }
    dateFormatChoiceRenderer.addValue(str, str + ": " + dateString);
  }
  final DropDownChoice<String> dateFormatChoice = new DropDownChoice<String>(fs.getDropDownChoiceId(), new PropertyModel<String>(user,
      property), dateFormatChoiceRenderer.getValues(), dateFormatChoiceRenderer);
  dateFormatChoice.setNullValid(true);
  fs.add(dateFormatChoice);
}
 
Example 4
Source File: TeamEventEditForm.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * if has access: create drop down with teamCals else create label
 * 
 * @param fieldSet
 */
private void initTeamCalPicker(final FieldsetPanel fieldSet)
{
  if (access == false) {
    final TeamCalDO calendar = data.getCalendar();
    final Label teamCalTitle = new Label(fieldSet.newChildId(), calendar != null ? new PropertyModel<String>(data.getCalendar(), "title")
        : "");
    fieldSet.add(teamCalTitle);
  } else {
    final List<TeamCalDO> list = teamCalDao.getAllCalendarsWithFullAccess();
    calendarsWithFullAccess = list.toArray(new TeamCalDO[0]);
    final LabelValueChoiceRenderer<TeamCalDO> calChoiceRenderer = new LabelValueChoiceRenderer<TeamCalDO>();
    for (final TeamCalDO cal : list) {
      calChoiceRenderer.addValue(cal, cal.getTitle());
    }
    final DropDownChoice<TeamCalDO> calDropDownChoice = new DropDownChoice<TeamCalDO>(fieldSet.getDropDownChoiceId(),
        new PropertyModel<TeamCalDO>(data, "calendar"), calChoiceRenderer.getValues(), calChoiceRenderer);
    calDropDownChoice.setNullValid(false);
    calDropDownChoice.setRequired(true);
    fieldSet.add(calDropDownChoice);
  }
}
 
Example 5
Source File: AbstractListForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static DropDownChoice<Integer> getPageSizeDropDownChoice(final String id, final Locale locale, final IModel<Integer> model,
  final int minValue, final int maxValue)
  {
final LabelValueChoiceRenderer<Integer> pageSizeChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
final NumberFormat nf = NumberFormat.getInstance(locale);
for (final int size : PAGE_SIZES) {
  if (size >= minValue && size <= maxValue) {
    pageSizeChoiceRenderer.addValue(size, nf.format(size));
  }
}
final DropDownChoice<Integer> pageSizeChoice = new DropDownChoice<Integer>(id, model, pageSizeChoiceRenderer.getValues(),
    pageSizeChoiceRenderer);
pageSizeChoice.setNullValid(false);
return pageSizeChoice;
  }
 
Example 6
Source File: AddAnalysisPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public AddAnalysisPanel() {
	super(FormPanel.CONTENT_ID);

	DropDownChoice<String> selectedTable = new DropDownChoice<String>("tableChoice", new PropertyModel<String>(this, "selectedTable"), new TablesModel());
	selectedTable.setOutputMarkupPlaceholderTag(true);
	selectedTable.setNullValid(false);		
	selectedTable.setRequired(true);
	selectedTable.setLabel(new StringResourceModel("Analysis.source", null));
		add(selectedTable);  		
}
 
Example 7
Source File: GroupListForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel, org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel)
{
  if (Login.getInstance().hasExternalUsermanagementSystem() == true) {
    // DropDownChoice localGroup
    final LabelValueChoiceRenderer<Boolean> localGroupRenderer = new LabelValueChoiceRenderer<Boolean>();
    localGroupRenderer.addValue(false, getString("group.localGroup.not"));
    localGroupRenderer.addValue(true, getString("group.localGroup"));
    final DropDownChoice<Boolean> localGroupChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(),
        new PropertyModel<Boolean>(getSearchFilter(), "localGroup"), localGroupRenderer.getValues(), localGroupRenderer);
    localGroupChoice.setNullValid(true);
    optionsFieldsetPanel.add(localGroupChoice, true).setTooltip(getString("group.localGroup"));
  }
}
 
Example 8
Source File: UserEditForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void addRights()
{
  final List<UserRightVO> userRights = userRightDao.getUserRights(data);
  boolean first = true;
  boolean odd = true;
  for (final UserRightVO rightVO : userRights) {
    final UserRight right = rightVO.getRight();
    final UserRightValue[] availableValues = right.getAvailableValues(((UserDao) getBaseDao()).getUserGroupCache(), data);
    if (right.isConfigurable(((UserDao) getBaseDao()).getUserGroupCache(), data) == false) {
      continue;
    }
    if (first == true) {
      gridBuilder.newGridPanel();
      gridBuilder.newFormHeading(getString("access.rights"));
      rightsData = new UserRightsEditData();
      first = false;
    }
    if (odd == true) {
      // gridBuilder.newNestedRowPanel();
    }
    odd = !odd;
    gridBuilder.newSplitPanel(GridSize.COL50);
    rightsData.addRight(rightVO);
    final String label = getString(right.getId().getI18nKey());
    final FieldsetPanel fs = gridBuilder.newFieldset(label);
    if (right.isBooleanType() == true) {
      fs.addCheckBox(new PropertyModel<Boolean>(rightVO, "booleanValue"), null);
    } else {
      final LabelValueChoiceRenderer<UserRightValue> valueChoiceRenderer = new LabelValueChoiceRenderer<UserRightValue>(fs,
          availableValues);
      final DropDownChoice<UserRightValue> valueChoice = new DropDownChoice<UserRightValue>(fs.getDropDownChoiceId(),
          new PropertyModel<UserRightValue>(rightVO, "value"), valueChoiceRenderer.getValues(), valueChoiceRenderer);
      valueChoice.setNullValid(true);
      fs.add(valueChoice);
    }
  }
}
 
Example 9
Source File: UserEditForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static void createTimeNotation(final GridBuilder gridBuilder, final PFUserDO user)
{
  // Time notation
  final FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("timeNotation"));
  final LabelValueChoiceRenderer<TimeNotation> timeNotationChoiceRenderer = new LabelValueChoiceRenderer<TimeNotation>();
  timeNotationChoiceRenderer.addValue(TimeNotation.H12, gridBuilder.getString("timeNotation.12"));
  timeNotationChoiceRenderer.addValue(TimeNotation.H24, gridBuilder.getString("timeNotation.24"));
  final DropDownChoice<TimeNotation> timeNotationChoice = new DropDownChoice<TimeNotation>(fs.getDropDownChoiceId(),
      new PropertyModel<TimeNotation>(user, "timeNotation"), timeNotationChoiceRenderer.getValues(), timeNotationChoiceRenderer);
  timeNotationChoice.setNullValid(true);
  fs.add(timeNotationChoice);
}
 
Example 10
Source File: AccountingRecordListForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel,
 *      org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel)
{
  // DropDownChoices from
  final YearListCoiceRenderer yearListChoiceRenderer = new YearListCoiceRenderer(buchungssatzDao.getYears(), false);
  final DropDownChoice<Integer> fromYearChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(),
      new PropertyModel<Integer>(this, "fromYear"), yearListChoiceRenderer.getYears(), yearListChoiceRenderer);
  fromYearChoice.setNullValid(false).setRequired(true);
  optionsFieldsetPanel.add(fromYearChoice);
  final LabelValueChoiceRenderer<Integer> monthChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
  for (int i = 0; i <= 11; i++) {
    monthChoiceRenderer.addValue(i, StringHelper.format2DigitNumber(i + 1));
  }
  final DropDownChoice<Integer> fromMonthChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(),
      new PropertyModel<Integer>(this, "fromMonth"), monthChoiceRenderer.getValues(), monthChoiceRenderer);
  fromMonthChoice.setNullValid(true);
  optionsFieldsetPanel.add(fromMonthChoice);

  optionsFieldsetPanel.add(new DivTextPanel(optionsFieldsetPanel.newChildId(), " - "));

  // DropDownChoices to
  final DropDownChoice<Integer> toYearChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(),
      new PropertyModel<Integer>(this, "toYear"), yearListChoiceRenderer.getYears(), yearListChoiceRenderer);
  toYearChoice.setNullValid(false).setRequired(true);
  optionsFieldsetPanel.add(toYearChoice);

  final DropDownChoice<Integer> toMonthChoice = new DropDownChoice<Integer>(optionsFieldsetPanel.getDropDownChoiceId(),
      new PropertyModel<Integer>(this, "toMonth"), monthChoiceRenderer.getValues(), monthChoiceRenderer);
  toMonthChoice.setNullValid(true);
  optionsFieldsetPanel.add(toMonthChoice);
}
 
Example 11
Source File: TimesheetEditForm.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
protected static DropDownChoice<Integer> createCost2ChoiceRenderer(final String id, final TimesheetDao timesheetDao,
    final TaskTree taskTree, final LabelValueChoiceRenderer<Integer> kost2ChoiceRenderer, final TimesheetDO data,
    final List<Kost2DO> kost2List)
    {
  final DropDownChoice<Integer> choice = new DropDownChoice<Integer>(id, new Model<Integer>() {
    @Override
    public Integer getObject()
    {
      return data.getKost2Id();
    }

    @Override
    public void setObject(final Integer kost2Id)
    {
      if (kost2Id != null) {
        timesheetDao.setKost2(data, kost2Id);
      } else {
        data.setKost2(null);
      }
    }
  }, kost2ChoiceRenderer.getValues(), kost2ChoiceRenderer);
  choice.setNullValid(true);
  choice.add(new IValidator<Integer>() {
    @Override
    public void validate(final IValidatable<Integer> validatable)
    {
      final Integer value = validatable.getValue();
      if (value != null && value >= 0) {
        return;
      }
      if (CollectionUtils.isNotEmpty(kost2List) == true) {
        // Kost2 available but not selected.
        choice.error(PFUserContext.getLocalizedString("timesheet.error.kost2Required"));
      }
    }
  });
  return choice;
    }
 
Example 12
Source File: GanttChartEditTreeTablePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
private void addRelationTypeColumns(final Item<GanttTreeTableNode> item, final GanttTreeTableNode node, final GanttTask ganttObject,
    final TaskDO task)
{
  final LabelValueChoiceRenderer<GanttRelationType> relationTypeChoiceRenderer = new LabelValueChoiceRenderer<GanttRelationType>();
  relationTypeChoiceRenderer.addValue(GanttRelationType.START_START, getString(GanttRelationType.START_START.getI18nKey() + ".short"));
  relationTypeChoiceRenderer.addValue(GanttRelationType.START_FINISH, getString(GanttRelationType.START_FINISH.getI18nKey() + ".short"));
  relationTypeChoiceRenderer.addValue(GanttRelationType.FINISH_START, getString(GanttRelationType.FINISH_START.getI18nKey() + ".short"));
  relationTypeChoiceRenderer
  .addValue(GanttRelationType.FINISH_FINISH, getString(GanttRelationType.FINISH_FINISH.getI18nKey() + ".short"));
  final DropDownChoice<GanttRelationType> relationTypeChoice = new DropDownChoice<GanttRelationType>("relationType",
      new PropertyModel<GanttRelationType>(ganttObject, "relationType"), relationTypeChoiceRenderer.getValues(),
      relationTypeChoiceRenderer);
  relationTypeChoice.setNullValid(true);
  addColumn(item, relationTypeChoice, null);
  final GanttRelationType relationType = task != null ? task.getGanttRelationType() : null;
  new RejectSaveLinksFragment("rejectSaveRelationType", item, relationTypeChoice, task,
      relationType != null ? getString(relationType.getI18nKey()) : "") {
    @Override
    protected void onSave()
    {
      task.setGanttRelationType(ganttObject.getRelationType());
      taskDao.update(task);
    }

    @Override
    protected void onReject()
    {
      ganttObject.setRelationType(task.getGanttRelationType());
    }
  };
}
 
Example 13
Source File: BooleanFilterPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public BooleanFilterPanel(String id, final IModel<Boolean> valueModel) {
    super(id, valueModel);
    List<Boolean> list = Lists.newArrayList();
    list.add(Boolean.TRUE);
    list.add(Boolean.FALSE);
    final DropDownChoice<Boolean> choice = new DropDownChoice<>("booleanChoice", valueModel, list);
    choice.add(new AjaxFormSubmitBehavior("change") {});
    choice.setNullValid(true);
    add(choice);
    this.choiceComponent = choice;
}
 
Example 14
Source File: ODateTimeField.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private DropDownChoice<String> createChoice(String id, int mode) {
    DropDownChoice<String> choice = new DropDownChoice<>(id, new Model<>(), Arrays.asList(AM, PM));
    boolean support = isSupportAmPm();
    choice.setOutputMarkupId(true);
    choice.setNullValid(false);
    if (mode != -1) choice.setModelObject(mode == Calendar.AM ? choice.getChoices().get(0) : choice.getChoices().get(1));
    else choice.setModelObject(choice.getChoices().get(0));
    choice.setVisible(support);
    choice.setEnabled(support);
    return choice;
}
 
Example 15
Source File: AbstractListForm.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
private void addExtendedFilter()
{
  gridBuilder.newSplitPanel(GridSize.COL66);
  extendedFilter = gridBuilder.getRowPanel();
  extendedFilter.setMarkupId("extendedFilter");
  if (searchFilter.isUseModificationFilter() == false) {
    extendedFilter.add(AttributeModifier.append("style", "display: none;"));
  }
  {
    final FieldsetPanel fieldset = gridBuilder.newFieldset(getString("search.periodOfModification"));
    fieldset.add(new HiddenInputPanel(fieldset.newChildId(), new HiddenField<Boolean>(InputPanel.WICKET_ID, new PropertyModel<Boolean>(
        searchFilter, "useModificationFilter"))).setHtmlId("useModificationFilter"));

    startDateTimePanel = new DateTimePanel(fieldset.newChildId(), new PropertyModel<Date>(searchFilter, "startTimeOfModification"),
        (DateTimePanelSettings) DateTimePanelSettings.get().withSelectProperty("startDateOfModification").withSelectPeriodMode(true),
        DatePrecision.MINUTE);
    fieldset.add(startDateTimePanel);
    fieldset.setLabelFor(startDateTimePanel);
    stopDateTimePanel = new DateTimePanel(fieldset.newChildId(), new PropertyModel<Date>(searchFilter, "stopTimeOfModification"),
        (DateTimePanelSettings) DateTimePanelSettings.get().withSelectProperty("stopDateOfModification").withSelectPeriodMode(true),
        DatePrecision.MINUTE);
    stopDateTimePanel.setRequired(false);
    fieldset.add(stopDateTimePanel);
    final HtmlCommentPanel comment = new HtmlCommentPanel(fieldset.newChildId(), new DatesAsUTCModel() {
      @Override
      public Date getStartTime()
      {
        return searchFilter.getStartTimeOfModification();
      }

      @Override
      public Date getStopTime()
      {
        return searchFilter.getStopTimeOfModification();
      }
    });
    fieldset.add(comment);
    // DropDownChoice for convenient selection of time periods.
    final LabelValueChoiceRenderer<String> timePeriodChoiceRenderer = new LabelValueChoiceRenderer<String>();
    timePeriodChoiceRenderer.addValue("lastMinute", getString("search.lastMinute"));
    timePeriodChoiceRenderer.addValue("lastMinutes:10", PFUserContext.getLocalizedMessage("search.lastMinutes", 10));
    timePeriodChoiceRenderer.addValue("lastMinutes:30", PFUserContext.getLocalizedMessage("search.lastMinutes", 30));
    timePeriodChoiceRenderer.addValue("lastHour", getString("search.lastHour"));
    timePeriodChoiceRenderer.addValue("lastHours:4", PFUserContext.getLocalizedMessage("search.lastHours", 4));
    timePeriodChoiceRenderer.addValue("today", getString("search.today"));
    timePeriodChoiceRenderer.addValue("sinceYesterday", getString("search.sinceYesterday"));
    timePeriodChoiceRenderer.addValue("lastDays:3", PFUserContext.getLocalizedMessage("search.lastDays", 3));
    timePeriodChoiceRenderer.addValue("lastDays:7", PFUserContext.getLocalizedMessage("search.lastDays", 7));
    timePeriodChoiceRenderer.addValue("lastDays:14", PFUserContext.getLocalizedMessage("search.lastDays", 14));
    timePeriodChoiceRenderer.addValue("lastDays:30", PFUserContext.getLocalizedMessage("search.lastDays", 30));
    timePeriodChoiceRenderer.addValue("lastDays:60", PFUserContext.getLocalizedMessage("search.lastDays", 60));
    timePeriodChoiceRenderer.addValue("lastDays:90", PFUserContext.getLocalizedMessage("search.lastDays", 90));
    final DropDownChoice<String> modificationSinceChoice = new DropDownChoice<String>(fieldset.getDropDownChoiceId(),
        new PropertyModel<String>(this, "modificationSince"), timePeriodChoiceRenderer.getValues(), timePeriodChoiceRenderer);
    modificationSinceChoice.setNullValid(true);
    modificationSinceChoice.setRequired(false);
    fieldset.add(modificationSinceChoice, true);
  }

  {
    gridBuilder.newSplitPanel(GridSize.COL33);
    final FieldsetPanel fs = gridBuilder.newFieldset(getString("modifiedBy"), getString("user"));

    final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new Model<PFUserDO>() {
      @Override
      public PFUserDO getObject()
      {
        return userGroupCache.getUser(searchFilter.getModifiedByUserId());
      }

      @Override
      public void setObject(final PFUserDO object)
      {
        if (object == null) {
          searchFilter.setModifiedByUserId(null);
        } else {
          searchFilter.setModifiedByUserId(object.getId());
        }
      }
    }, parentPage, "modifiedByUserId");
    fs.add(userSelectPanel);
    userSelectPanel.setDefaultFormProcessing(false);
    userSelectPanel.init().withAutoSubmit(true);
  }
  gridBuilder.setCurrentLevel(0); // Go back to main row panel.
}
 
Example 16
Source File: StringFeatureTraitsEditor.java    From webanno with Apache License 2.0 4 votes vote down vote up
public StringFeatureTraitsEditor(String aId,
        UimaPrimitiveFeatureSupport_ImplBase<StringFeatureTraits> aFS,
        IModel<AnnotationFeature> aFeature)
{
    super(aId, aFeature);

    // We cannot retain a reference to the actual SlotFeatureSupport instance because that
    // is not serializable, but we can retain its ID and look it up again from the registry
    // when required.
    featureSupportId = aFS.getId();
    feature = aFeature;

    traits = CompoundPropertyModel.of(getFeatureSupport().readTraits(feature.getObject()));

    keyBindings = newKeyBindingsConfigurationPanel(aFeature);
    add(keyBindings);

    Form<StringFeatureTraits> form = new Form<StringFeatureTraits>(MID_FORM, traits)
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();

            // Tagsets only are allowed for single-row input fields, not for textareas
            if (traits.getObject().isMultipleRows()) {
                feature.getObject().setTagset(null);
            } else {
                traits.getObject().setDynamicSize(false);
            }

            getFeatureSupport().writeTraits(feature.getObject(), traits.getObject());
        }
    };
    form.setOutputMarkupPlaceholderTag(true);
    add(form);

    NumberTextField<Integer> collapsedRows = new NumberTextField<>("collapsedRows",
            Integer.class);
    collapsedRows.setModel(PropertyModel.of(traits, "collapsedRows"));
    collapsedRows.setMinimum(1);
    collapsedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows()
            && !traits.getObject().isDynamicSize()));
    form.add(collapsedRows);

    NumberTextField<Integer> expandedRows = new NumberTextField<>("expandedRows",
            Integer.class);
    expandedRows.setModel(PropertyModel.of(traits, "expandedRows"));
    expandedRows.setMinimum(1);
    expandedRows.add(visibleWhen(() -> traits.getObject().isMultipleRows() 
            && !traits.getObject().isDynamicSize()));
    form.add(expandedRows);

    DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset");
    tagset.setOutputMarkupPlaceholderTag(true);
    tagset.setChoiceRenderer(new ChoiceRenderer<>("name"));
    tagset.setNullValid(true);
    tagset.setModel(PropertyModel.of(aFeature, "tagset"));
    tagset.setChoices(LoadableDetachableModel
            .of(() -> annotationService.listTagSets(aFeature.getObject().getProject())));
    tagset.add(visibleWhen(() -> !traits.getObject().isMultipleRows()));
    // If we change the tagset, the input component for the key bindings may change, so we need
    // to re-generate the key bindings
    tagset.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
        KeyBindingsConfigurationPanel newKeyBindings = newKeyBindingsConfigurationPanel(
                aFeature);
        keyBindings.replaceWith(newKeyBindings);
        keyBindings = newKeyBindings;
        _target.add(keyBindings);
    }));
    form.add(tagset);

    CheckBox multipleRows = new CheckBox("multipleRows");
    multipleRows.setModel(PropertyModel.of(traits, "multipleRows"));
    multipleRows.add(
            new LambdaAjaxFormComponentUpdatingBehavior("change", target -> target.add(form)));
    form.add(multipleRows);

    CheckBox dynamicSize = new CheckBox("dynamicSize");
    dynamicSize.setModel(PropertyModel.of(traits, "dynamicSize"));
    dynamicSize.add(new LambdaAjaxFormComponentUpdatingBehavior("change",
        target -> target.add(form)
    ));
    dynamicSize.add(visibleWhen(() -> traits.getObject().isMultipleRows()));
    form.add(dynamicSize);
}
 
Example 17
Source File: LinkFeatureTraitsEditor.java    From webanno with Apache License 2.0 4 votes vote down vote up
public LinkFeatureTraitsEditor(String aId, SlotFeatureSupport aFS,
        IModel<AnnotationFeature> aFeatureModel)
{
    super(aId, aFeatureModel);
    
    // We cannot retain a reference to the actual SlotFeatureSupport instance because that
    // is not serializable, but we can retain its ID and look it up again from the registry
    // when required.
    featureSupportId = aFS.getId();
    feature = aFeatureModel;
    
    traits = Model.of(readTraits());
    
    Form<Traits> form = new Form<Traits>(MID_FORM, CompoundPropertyModel.of(traits))
    {
        private static final long serialVersionUID = -3109239605783291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            // when saving reset the selected tagset if role labels are not enabled
            if (!traits.getObject().isEnableRoleLabels()) {
                feature.getObject().setTagset(null);
            }
            writeTraits();
        }
    };
    form.setOutputMarkupPlaceholderTag(true);
    add(form);
    
    MultiSelect<Tag> defaultSlots  = new MultiSelect<Tag>("defaultSlots") {
        private static final long serialVersionUID = 8231304829756188352L;
        
        @Override
        public void onConfigure(JQueryBehavior aBehavior)
        {
            super.onConfigure(aBehavior);
            //aBehavior.setOption("placeholder", Options.asString(getString("placeholder")));
            aBehavior.setOption("filter", Options.asString("contains"));
            aBehavior.setOption("autoClose", false);
        }
    };
    defaultSlots.setChoices(LambdaModel.of(this::listTags));
    defaultSlots.setChoiceRenderer(new ChoiceRenderer<>("name"));
    defaultSlots.add(visibleWhen(() -> traits.getObject().isEnableRoleLabels()
            && feature.getObject().getTagset() != null));
    form.add(defaultSlots);

    CheckBox enableRoleLabels = new CheckBox("enableRoleLabels");
    enableRoleLabels.setModel(PropertyModel.of(traits, "enableRoleLabels"));
    enableRoleLabels.add(new LambdaAjaxFormComponentUpdatingBehavior("change", 
        target -> target.add(form)
    ));
    form.add(enableRoleLabels);
    
    DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset");
    tagset.setOutputMarkupPlaceholderTag(true);
    tagset.setOutputMarkupId(true);
    tagset.setChoiceRenderer(new ChoiceRenderer<>("name"));
    tagset.setNullValid(true);
    tagset.setModel(PropertyModel.of(aFeatureModel, "tagset"));
    tagset.setChoices(LambdaModel.of(() -> annotationService
            .listTagSets(aFeatureModel.getObject().getProject())));
    tagset.add(new LambdaAjaxFormComponentUpdatingBehavior("change", target -> {
        traits.getObject().setDefaultSlots(new ArrayList<>());
        target.add(form);
    }));
    tagset.add(visibleWhen(() -> traits.getObject().isEnableRoleLabels()));
    form.add(tagset);
}
 
Example 18
Source File: FieldListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newFieldsView(Class<?> fieldBeanClass) {
	RepeatingView fieldsView = new RepeatingView("fields");
	fieldsView.setDefaultModel(Model.of(fieldBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(fieldBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			if (getFieldSpecs().containsKey(property.getDisplayName())) {
				WebMarkupContainer container = new WebMarkupContainer(fieldsView.newChildId());
				FieldSupply field = fields.get(property.getDisplayName());
				if (field != null) {
					container.add(newValueEditor("value", property, field.getValueProvider()));
					container.setDefaultModel(Model.of(field.getValueProvider().getClass()));
				} else {
					container.add(newValueEditor("value", property, newSpecifiedValueProvider(property)));
					container.setDefaultModel(Model.of(SpecifiedValue.class));
				}
				
				container.add(new Label("name", property.getDisplayName()));

				String required;
				if (property.isPropertyRequired() 
						&& property.getPropertyClass() != boolean.class
						&& property.getPropertyClass() != Boolean.class) {
					required = "*";
				} else {
					required = "&nbsp;";
				}
				
				container.add(new Label("required", required).setEscapeModelStrings(false));
				
				boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

				List<String> choices = new ArrayList<>();
				if (isSecret) {
					choices.add(SpecifiedValue.SECRET_DISPLAY_NAME);
					choices.add(ScriptingValue.SECRET_DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				} else {
					choices.add(SpecifiedValue.DISPLAY_NAME);
					choices.add(ScriptingValue.DISPLAY_NAME);
					choices.add(Ignore.DISPLAY_NAME);
				}
				DropDownChoice<String> valueProviderChoice = new DropDownChoice<String>("valueProvider", new IModel<String>() {
					
					@Override
					public void detach() {
					}

					@Override
					public String getObject() {
						Class<?> valueProviderClass = (Class<?>) container.getDefaultModelObject();
						if (valueProviderClass == SpecifiedValue.class)
							return isSecret?SpecifiedValue.SECRET_DISPLAY_NAME:SpecifiedValue.DISPLAY_NAME;
						else if (valueProviderClass == ScriptingValue.class)
							return isSecret?ScriptingValue.SECRET_DISPLAY_NAME:ScriptingValue.DISPLAY_NAME;
						else
							return Ignore.DISPLAY_NAME;
					}

					@Override
					public void setObject(String object) {
						ValueProvider valueProvider;
						if (object.equals(SpecifiedValue.DISPLAY_NAME) || object.equals(SpecifiedValue.SECRET_DISPLAY_NAME))  
							valueProvider = newSpecifiedValueProvider(property);
						else if (object.equals(ScriptingValue.DISPLAY_NAME) || object.equals(ScriptingValue.SECRET_DISPLAY_NAME))
							valueProvider = new ScriptingValue();
						else
							valueProvider = new Ignore();
						container.replace(newValueEditor("value", property, valueProvider));
						container.setDefaultModelObject(valueProvider.getClass());
					}
					
				}, choices);
				
				valueProviderChoice.setNullValid(false);
				
				valueProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

					@Override
					protected void onUpdate(AjaxRequestTarget target) {
						onPropertyUpdating(target);
						target.add(container);
					}
					
				});
				container.add(valueProviderChoice);
				
				container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
				container.add(new FencedFeedbackPanel("feedback", container));
				container.setOutputMarkupId(true);
				fieldsView.add(container);
			}
		}
	}
	
	return fieldsView;
}
 
Example 19
Source File: ParamListEditPanel.java    From onedev with MIT License 4 votes vote down vote up
private Component newParamsView(Class<?> paramBeanClass) {
	RepeatingView paramsView = new RepeatingView("params");
	paramsView.setDefaultModel(Model.of(paramBeanClass.getName()));
	BeanDescriptor beanDescriptor = new BeanDescriptor(paramBeanClass);
	for (List<PropertyDescriptor> groupProperties: beanDescriptor.getProperties().values()) {
		for (PropertyDescriptor property: groupProperties) {
			WebMarkupContainer container = new WebMarkupContainer(paramsView.newChildId());
			container.add(new Label("name", property.getDisplayName()));

			ParamSupply param = params.get(property.getDisplayName());
			if (param != null) {
				container.add(newValuesEditor("values", property, param.getValuesProvider()));
				container.setDefaultModel(Model.of(param.getValuesProvider().getClass()));
			} else {
				container.add(newValuesEditor("values", property, newSpecifiedValuesProvider(property)));
				container.setDefaultModel(Model.of(SpecifiedValues.class));
			}

			String required;
			if (property.isPropertyRequired() 
					&& property.getPropertyClass() != boolean.class
					&& property.getPropertyClass() != Boolean.class) {
				required = "*";
			} else {
				required = "&nbsp;";
			}
			
			container.add(new Label("required", required).setEscapeModelStrings(false));
			
			boolean isSecret = property.getPropertyGetter().getAnnotation(Password.class) != null;

			List<String> choices = new ArrayList<>();
			if (isSecret) {
				choices.add(SpecifiedValues.SECRET_DISPLAY_NAME);
				choices.add(ScriptingValues.SECRET_DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			} else {
				choices.add(SpecifiedValues.DISPLAY_NAME);
				choices.add(ScriptingValues.DISPLAY_NAME);
				choices.add(Ignore.DISPLAY_NAME);
			}
			DropDownChoice<String> valuesProviderChoice = new DropDownChoice<String>("valuesProvider", new IModel<String>() {
				
				@Override
				public void detach() {
				}

				@Override
				public String getObject() {
					Class<?> valuesProviderClass = (Class<?>) container.getDefaultModelObject();
					if (valuesProviderClass == SpecifiedValues.class)
						return isSecret?SpecifiedValues.SECRET_DISPLAY_NAME:SpecifiedValues.DISPLAY_NAME;
					else if (valuesProviderClass == ScriptingValues.class)
						return isSecret?ScriptingValues.SECRET_DISPLAY_NAME:ScriptingValues.DISPLAY_NAME;
					else
						return Ignore.DISPLAY_NAME;
				}

				@Override
				public void setObject(String object) {
					ValuesProvider valuesProvider;
					if (object.equals(SpecifiedValues.DISPLAY_NAME) || object.equals(SpecifiedValues.SECRET_DISPLAY_NAME))  
						valuesProvider = newSpecifiedValuesProvider(property);
					else if (object.equals(ScriptingValues.DISPLAY_NAME) || object.equals(ScriptingValues.SECRET_DISPLAY_NAME))
						valuesProvider = new ScriptingValues();
					else
						valuesProvider = new Ignore();
					container.replace(newValuesEditor("values", property, valuesProvider));
					container.setDefaultModelObject(valuesProvider.getClass());
				}
									
			}, choices);
			
			valuesProviderChoice.setNullValid(false);
			
			valuesProviderChoice.add(new AjaxFormComponentUpdatingBehavior("change"){

				@Override
				protected void onUpdate(AjaxRequestTarget target) {
					onPropertyUpdating(target);
					target.add(container);
				}
				
			});
			container.add(valuesProviderChoice);
			container.add(new Label("description", property.getDescription()).setEscapeModelStrings(false));
			container.add(new FencedFeedbackPanel("feedback", container));
			container.setOutputMarkupId(true);
			paramsView.add(container);
		}
	}
	
	return paramsView;
}
 
Example 20
Source File: UserListForm.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel, org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel)
{
  {
    // DropDownChoice deactivated
    final LabelValueChoiceRenderer<Boolean> deactivatedRenderer = new LabelValueChoiceRenderer<Boolean>();
    deactivatedRenderer.addValue(false, getString("user.activated"));
    deactivatedRenderer.addValue(true, getString("user.deactivated"));
    final DropDownChoice<Boolean> deactivatedChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Boolean>(
        getSearchFilter(), "deactivatedUser"), deactivatedRenderer.getValues(), deactivatedRenderer);
    deactivatedChoice.setNullValid(true);
    optionsFieldsetPanel.add(deactivatedChoice, true).setTooltip(getString("user.activated"));
  }
  {
    // DropDownChoice admin-user
    final LabelValueChoiceRenderer<Boolean> isAdminRenderer = new LabelValueChoiceRenderer<Boolean>();
    isAdminRenderer.addValue(true, getString("user.adminUsers"));
    isAdminRenderer.addValue(false, getString("user.adminUsers.none"));
    final DropDownChoice<Boolean> isAdminChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Boolean>(
        getSearchFilter(), "isAdminUser"), isAdminRenderer.getValues(), isAdminRenderer);
    isAdminChoice.setNullValid(true);
    optionsFieldsetPanel.add(isAdminChoice, true).setTooltip(getString("user.adminUsers"));
  }
  if (Login.getInstance().hasExternalUsermanagementSystem() == true) {
    {
      // DropDownChoice restricted
      final LabelValueChoiceRenderer<Boolean> restrictedRenderer = new LabelValueChoiceRenderer<Boolean>();
      restrictedRenderer.addValue(false, getString("user.restricted.not"));
      restrictedRenderer.addValue(true, getString("user.restricted"));
      final DropDownChoice<Boolean> restrictedChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(),
          new PropertyModel<Boolean>(getSearchFilter(), "restrictedUser"), restrictedRenderer.getValues(), restrictedRenderer);
      restrictedChoice.setNullValid(true);
      optionsFieldsetPanel.add(restrictedChoice, true).setTooltip(getString("user.restrictedUser"));
    }
    {
      // DropDownChoice localUser
      final LabelValueChoiceRenderer<Boolean> localUserRenderer = new LabelValueChoiceRenderer<Boolean>();
      localUserRenderer.addValue(false, getString("user.localUser.not"));
      localUserRenderer.addValue(true, getString("user.localUser"));
      final DropDownChoice<Boolean> localUserChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(),
          new PropertyModel<Boolean>(getSearchFilter(), "localUser"), localUserRenderer.getValues(), localUserRenderer);
      localUserChoice.setNullValid(true);
      optionsFieldsetPanel.add(localUserChoice, true).setTooltip(getString("user.localUser"));
    }
  }
  {
    // DropDownChoice hrPlanning
    final LabelValueChoiceRenderer<Boolean> hrPlanningRenderer = new LabelValueChoiceRenderer<Boolean>();
    hrPlanningRenderer.addValue(false, getString("user.hrPlanningEnabled.not"));
    hrPlanningRenderer.addValue(true, getString("user.hrPlanningEnabled"));
    final DropDownChoice<Boolean> hrPlanningChoice = new DropDownChoice<Boolean>(optionsFieldsetPanel.getDropDownChoiceId(), new PropertyModel<Boolean>(
        getSearchFilter(), "hrPlanning"), hrPlanningRenderer.getValues(), hrPlanningRenderer);
    hrPlanningChoice.setNullValid(true);
    optionsFieldsetPanel.add(hrPlanningChoice, true).setTooltip(getString("user.hrPlanningEnabled"));
  }
}