Java Code Examples for org.apache.wicket.markup.html.form.TextField#setEnabled()

The following examples show how to use org.apache.wicket.markup.html.form.TextField#setEnabled() . 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: StringEditor.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Construct simple text editor.
 *
 * @param id         editor id.
 * @param markupProvider markup object.
 * @param model      model.
 * @param labelModel label model
 * @param errorLabelModel error label model
 * @param attrValue  {@link org.yes.cart.domain.entity.AttrValue}
 * @param readOnly  if true this component is read only
 */
public StringEditor(final String id,
                    final MarkupContainer markupProvider,
                    final IModel<String> model,
                    final IModel<String> labelModel,
                    final IModel<String> errorLabelModel,
                    final AttrValueWithAttribute attrValue,
                    final boolean readOnly) {

    super(id, "stringEditor", markupProvider);

    final TextField textField = new TextField(EDIT, model);

    textField.setLabel(labelModel);
    textField.setRequired(attrValue.getAttribute().isMandatory());
    textField.setEnabled(!readOnly);

    if (StringUtils.isNotBlank(attrValue.getAttribute().getRegexp())) {
        textField.add(new CustomPatternValidator(attrValue.getAttribute().getRegexp(), errorLabelModel));
    }
    textField.add(new AttributeModifier("placeholder", labelModel));
    add(textField);
}
 
Example 2
Source File: RootConceptsPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
private TextField<String> buildTextField(String id, IModel<IRI> model) {
    IModel<String> adapter = new LambdaModelAdapter<String>(
        () -> model.getObject().stringValue(),
        str -> model.setObject(SimpleValueFactory.getInstance().createIRI(str)));

    TextField<String> iriTextfield = new TextField<>(id, adapter);
    iriTextfield.setOutputMarkupId(true);
    iriTextfield.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> {
        // Do nothing just update the model values
    }));
    iriTextfield.setEnabled(false);
    return iriTextfield;
}
 
Example 3
Source File: NewPollOverviewPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();

  if (model.isNew() == false) {
    isModified = isModelModified();
  }

  final FieldsetPanel fsTitle = gridBuilder.newFieldset(getString("plugins.poll.new.title"));
  final TextField<String> title = new TextField<String>(fsTitle.getTextFieldId(), new PropertyModel<String>(model.getPollDo(), "title"));
  title.setEnabled(this.model.isNew());
  fsTitle.add(title);

  final FieldsetPanel fsLocation = gridBuilder.newFieldset(getString("plugins.poll.new.location")).setLabelFor(this);
  final TextField<String> location = new TextField<String>(fsLocation.getTextFieldId(),
      new PropertyModel<String>(model.getPollDo(), "location"));
  location.setEnabled(this.model.isNew());
  fsLocation.add(location);

  final FieldsetPanel fsDescription = gridBuilder.newFieldset(getString("plugins.poll.new.description"));
  final TextArea<String> description = new TextArea<String>(fsDescription.getTextAreaId(), new PropertyModel<String>(this.model.getPollDo(),
      "description"));
  description.setEnabled(this.model.isNew());
  fsDescription.add(description);

  gridBuilder.newGridPanel();

  //    if (this.model.isNew() == true) {
  final FieldsetPanel fsUsers = gridBuilder.newFieldset(getString("plugins.poll.attendee.users"));

  //    if (model.isNew() == false && isModified == false) {
  createDisabledChoices(fsUsers, model.getPollAttendeeList(), true);
  //    } else {
  //      createDisabledChoices(fsUsers, model.getCalculatedAttendeeList(), true);
  //    }
  //    } else {
  //      createEnabledChoices();
  //    }

  final FieldsetPanel fsEMails = gridBuilder.newFieldset(getString("plugins.poll.attendee.emails"));
  //    if (model.isNew() == false && isModified == false) {
  createDisabledChoices(fsEMails, model.getPollAttendeeList(), false);
  //    } else {
  //      createDisabledChoices(fsEMails, model.getCalculatedAttendeeList(), false);
  //    }

  final FieldsetPanel fsEvents = gridBuilder.newFieldset(getString("plugins.poll.attendee.events"));
  createDisabledChoices(fsEvents, model.getAllEvents());
}
 
Example 4
Source File: MonthlyJobPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
private void enableComponents(int monthlyType, Label mLabel, DropDownChoice minuteChoice, Label label, TextField<Integer> minuteText,
                              IntervalFieldPanel hoursPanel, IntervalFieldPanel monthsPanel,
                              DropDownChoice<Integer> noChoice, DropDownChoice<String> dayChoice,
                              Label everyLabel) {
    if (ScheduleConstants.MONTHLY_GENERAL_TYPE == monthlyType) {
    	mLabel.setEnabled(true);
        minuteChoice.setEnabled(true);
        label.setEnabled(true);
        minuteText.setEnabled(true);
        hoursPanel.setEnabled(true);
        daysPanel.setEnabled(true);
        monthsPanel.setEnabled(true);
        weekdaysPanel.setEnabled(true);

        noChoice.setEnabled(false);
        dayChoice.setEnabled(false);
        everyLabel.setEnabled(false);
    } else if (ScheduleConstants.MONTHLY_DAY_OF_WEEK_TYPE == monthlyType) {
    	mLabel.setEnabled(false);
        minuteChoice.setEnabled(false);
        label.setEnabled(false);
        minuteText.setEnabled(false);
        hoursPanel.setEnabled(false);
        daysPanel.setEnabled(false);
        monthsPanel.setEnabled(false);
        weekdaysPanel.setEnabled(false);

        noChoice.setEnabled(true);
        dayChoice.setEnabled(true);
        everyLabel.setEnabled(true);
    } else {
    	mLabel.setEnabled(false);
        minuteChoice.setEnabled(false);
        label.setEnabled(false);
        minuteText.setEnabled(false);
        hoursPanel.setEnabled(false);
        daysPanel.setEnabled(false);
        monthsPanel.setEnabled(false);
        weekdaysPanel.setEnabled(false);

        noChoice.setEnabled(false);
        dayChoice.setEnabled(false);
        everyLabel.setEnabled(false);
    }
}