Java Code Examples for org.apache.wicket.markup.html.form.CheckBox#add()

The following examples show how to use org.apache.wicket.markup.html.form.CheckBox#add() . 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: AbstractFilterPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
public AbstractFilterPanel(String id, IModel<T> model, String filterId,
                           IModel<V> entityModel,
                           IVisualizer visualizer,
                           IFilterCriteriaManager manager, IModel<Boolean> join) {
    super(id, model);
    this.filterId = filterId;
    this.entityModel = entityModel;
    this.visualizer = visualizer;
    this.joinModel = join;
    this.manager = manager;
    setOutputMarkupPlaceholderTag(true);
    add(new Label("title", getTitle()));
    CheckBox checkBox = new CheckBox("join", join);
    checkBox.add(new AjaxFormSubmitBehavior("change") {});
    checkBox.setOutputMarkupId(true);
    add(checkBox);
    add(new Label("joinTitle", new ResourceModel("widget.document.filter.join"))
            .setOutputMarkupPlaceholderTag(true));
}
 
Example 2
Source File: AjaxCheckBoxPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public AjaxCheckBoxPanel(
        final String id, final String name, final IModel<Boolean> model, final boolean enableOnChange) {

    super(id, name, model);

    field = new CheckBox("checkboxField", model);
    add(field.setLabel(new ResourceModel(name, name)).setOutputMarkupId(true));

    if (enableOnChange && !isReadOnly()) {
        field.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

            private static final long serialVersionUID = -1107858522700306810L;

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                // nothing to do
            }
        });
    }
}
 
Example 3
Source File: LayerSelectionPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
/**
 * Part of <i>forward annotation</i> mode: creates the checkbox to toggle forward annotation
 * mode.
 */
private CheckBox createForwardAnnotationCheckBox()
{
    CheckBox checkbox = new CheckBox("forwardAnnotation");
    checkbox.setOutputMarkupId(true);
    checkbox.add(LambdaBehavior.onConfigure(_this -> {
        // Force-disable forward annotation mode if current layer is not forwardable
        if (!isForwardable()) {
            getModelObject().setForwardAnnotation(false);
        }
    }));
    checkbox.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> 
            owner.getFeatureEditorListPanel().focusForwardAnnotationComponent(_target, true)));
    
    return checkbox;
}
 
Example 4
Source File: UserSelectionPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
public UserSelectionPanel(String id, IModel<User> aModel)
{
    super(id);
    setOutputMarkupPlaceholderTag(true);

    overviewList = new OverviewListChoice<>("user");
    overviewList.setChoiceRenderer(new ChoiceRenderer<User>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(User aUser)
        {
            return aUser.getUsername() + (aUser.isEnabled() ? "" : " (disabled)");
        }
    });
    overviewList.setModel(aModel);
    overviewList.setChoices(this::listUsers);
    overviewList.add(new LambdaAjaxFormComponentUpdatingBehavior("change", this::onChange));
    add(overviewList);

    add(new LambdaAjaxLink("create", this::actionCreate));
    showDisabled = new CheckBox("showDisabled", Model.of(false));
    showDisabled.add(
            new LambdaAjaxFormComponentUpdatingBehavior("change", this::toggleShowDisabled));
    add(showDisabled);
}
 
Example 5
Source File: ChainLayerTraitsEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeForm(Form<ChainLayerTraits> aForm)
{
    aForm.add(new ValidationModeSelect("validationMode", getLayerModel()));
    
    aForm.add(new AnchoringModeSelect("anchoringMode", getLayerModel()));
    
    aForm.add(new OverlapModeSelect("overlapMode", getLayerModel()));
    
    CheckBox linkedListBehavior = new CheckBox("linkedListBehavior");
    linkedListBehavior.setModel(PropertyModel.of(getLayerModel(), "linkedListBehavior"));
    aForm.add(linkedListBehavior);
    
    CheckBox crossSentence = new CheckBox("crossSentence");
    crossSentence.setOutputMarkupPlaceholderTag(true);
    crossSentence.setModel(PropertyModel.of(getLayerModel(), "crossSentence"));
    crossSentence.add(visibleWhen(() -> !isBlank(getLayerModelObject().getType())));
    aForm.add(crossSentence);
    
    TextArea<String> onClickJavascriptAction = new TextArea<String>("onClickJavascriptAction");
    onClickJavascriptAction.setModel(PropertyModel.of(getLayerModel(), "onClickJavascriptAction"));
    onClickJavascriptAction.add(new AttributeModifier("placeholder",
            "alert($PARAM.PID + ' ' + $PARAM.PNAME + ' ' + $PARAM.DOCID + ' ' + "
                    + "$PARAM.DOCNAME + ' ' + $PARAM.fieldname);"));
    aForm.add(onClickJavascriptAction);
}
 
Example 6
Source File: RelationLayerTraitsEditor.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
protected void initializeForm(Form<RelationLayerTraits> aForm)
{
    aForm.add(new ValidationModeSelect("validationMode", getLayerModel()));
    
    OverlapModeSelect overlapMode = new OverlapModeSelect("overlapMode", getLayerModel());
    // Not configurable for layers that attach to tokens (currently that is the only layer on
    // which we use the attach feature)
    overlapMode.add(enabledWhen(() -> getLayerModelObject().getAttachFeature() == null));
    aForm.add(overlapMode);
    
    aForm.add(new ColoringRulesConfigurationPanel("coloringRules",
            getLayerModel(), getTraitsModel().bind("coloringRules.rules")));
    
    CheckBox crossSentence = new CheckBox("crossSentence");
    crossSentence.setOutputMarkupPlaceholderTag(true);
    crossSentence.setModel(PropertyModel.of(getLayerModel(), "crossSentence"));
    // Not configurable for layers that attach to tokens (currently that is the only layer on
    // which we use the attach feature)
    crossSentence.add(enabledWhen(() -> getLayerModelObject().getAttachFeature() == null));
    aForm.add(crossSentence);

    TextArea<String> onClickJavascriptAction = new TextArea<String>("onClickJavascriptAction");
    onClickJavascriptAction.setModel(PropertyModel.of(getLayerModel(), "onClickJavascriptAction"));
    onClickJavascriptAction.add(new AttributeModifier("placeholder",
            "alert($PARAM.PID + ' ' + $PARAM.PNAME + ' ' + $PARAM.DOCID + ' ' + "
                    + "$PARAM.DOCNAME + ' ' + $PARAM.fieldname);"));
    aForm.add(onClickJavascriptAction);
}
 
Example 7
Source File: DynamicParameterRuntimePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected void createItem(final ListItem<QueryParameter> item) {
    super.createItem(item);

    // add dynamic label and checkbox only for scheduler
    final QueryParameter parameter = item.getModelObject();
    boolean hasDefaultSource = (parameter.getDefaultSource() != null) && (parameter.getDefaultSource().trim().length() > 0);
    boolean hasSource = (parameter.getSource() != null) && (parameter.getSource().trim().length() > 0);

    final IModel dynamicModel = new PropertyModel(runtimeModel.getParameters(), parameter.getName() + ".dynamic");

    enableItem(item, dynamicModel, null);

    final CheckBox dynamicChkBox = new CheckBox("dynamicChkBox", dynamicModel);
    dynamicChkBox.setVisible(!runNow && (hasDefaultSource || hasSource));
    dynamicChkBox.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        protected void onUpdate(AjaxRequestTarget target) {
            enableItem(item, dynamicModel, target);
        }
    });
    item.add(dynamicChkBox.setOutputMarkupId(true));

    Label dynamicLabel = new Label("dynamicLabel", getString("DynamicParameterRuntimePanel.dynamic"));
    dynamicLabel.setVisible(!runNow && (hasDefaultSource || hasSource));
    item.add(dynamicLabel.setOutputMarkupId(true));

}
 
Example 8
Source File: SearchAnnotationSidebar.java    From inception with Apache License 2.0 5 votes vote down vote up
private CheckBox createLowLevelPagingCheckBox()
{
    CheckBox checkbox = new CheckBox("lowLevelPaging");
    checkbox.setOutputMarkupId(true);
    checkbox.add(enabledWhen(() -> searchOptions.getObject().getGroupingLayer() == null
            && searchOptions.getObject().getGroupingFeature() == null));
    checkbox.add(AttributeModifier.append("title",
        new StringResourceModel("lowLevelPagingMouseover", this)));
    return checkbox;
}
 
Example 9
Source File: ExternalRecommenderTraitsEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
public ExternalRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);
    
    traits = toolFactory.readTraits(aRecommender.getObject());

    Form<ExternalRecommenderTraits> form = new Form<ExternalRecommenderTraits>(MID_FORM,
            CompoundPropertyModel.of(Model.of(traits)))
    {
        private static final long serialVersionUID = -3109239605742291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            toolFactory.writeTraits(aRecommender.getObject(), traits);
        }
    };

    TextField<String> remoteUrl = new TextField<>("remoteUrl");
    remoteUrl.setRequired(true);
    remoteUrl.add(new UrlValidator());
    form.add(remoteUrl);

    CheckBox trainable = new CheckBox("trainable");
    trainable.setOutputMarkupId(true);
    trainable.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> 
            _target.add(getTrainingStatesChoice())));
    form.add(trainable);
    
    getTrainingStatesChoice().add(visibleWhen(() -> trainable.getModelObject() == true));
    
    add(form);
}
 
Example 10
Source File: AnnotationPreferencesDialogContent.java    From webanno with Apache License 2.0 4 votes vote down vote up
private ListView<AnnotationLayer> createLayerContainer()
{
    return new ListView<AnnotationLayer>("annotationLayers")
    {
        private static final long serialVersionUID = -4040731191748923013L;

        @Override
        protected void populateItem(ListItem<AnnotationLayer> aItem)
        {
            Preferences prefs = form.getModelObject();
            AnnotationLayer layer = aItem.getModelObject();
            Set<Long> hiddenLayerIds = stateModel.getObject().getPreferences()
                    .getHiddenAnnotationLayerIds();
            
            // add visibility checkbox
            CheckBox layerVisible = new CheckBox("annotationLayerActive",
                    Model.of(!hiddenLayerIds.contains(layer.getId())));

            layerVisible.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target -> {
                if (!layerVisible.getModelObject()) {
                    hiddenLayerIds.add(layer.getId());
                }
                else {
                    hiddenLayerIds.remove(layer.getId());
                }
            }));
            aItem.add(layerVisible);

            // add coloring strategy choice
            DropDownChoice<ColoringStrategyType> layerColor = new BootstrapSelect<>(
                    "layercoloring");
            layerColor.setModel(Model.of(prefs.colorPerLayer.get(layer.getId())));
            layerColor.setChoiceRenderer(new ChoiceRenderer<>("descriptiveName"));
            layerColor.setChoices(asList(ColoringStrategyType.values()));
            layerColor.add(new LambdaAjaxFormComponentUpdatingBehavior("change", _target ->
                    prefs.colorPerLayer.put(layer.getId(), layerColor.getModelObject())));
            aItem.add(layerColor);

            // add label
            aItem.add(new Label("annotationLayerDesc", layer.getUiName()));
        }
    };
}
 
Example 11
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 12
Source File: ElasticSearchProviderTraitsEditor.java    From inception with Apache License 2.0 4 votes vote down vote up
public ElasticSearchProviderTraitsEditor(String aId,
        IModel<DocumentRepository> aDocumentRepository)
{
    super(aId, aDocumentRepository);
    documentRepository = aDocumentRepository.getObject();
    properties = externalSearchProviderFactory.readTraits(documentRepository);

    Form<ElasticSearchProviderTraits> form = new Form<ElasticSearchProviderTraits>(
            MID_FORM, CompoundPropertyModel.of(Model.of(properties)))
    {
        private static final long serialVersionUID = -3109239608742291123L;

        @Override
        protected void onSubmit()
        {
            super.onSubmit();
            externalSearchProviderFactory.writeTraits(documentRepository, properties);
        }
    };

    TextField<String> remoteUrl = new TextField<>("remoteUrl");
    remoteUrl.setRequired(true);
    remoteUrl.add(new UrlValidator());
    form.add(remoteUrl);

    TextField<String> indexName = new TextField<>("indexName");
    indexName.setRequired(true);
    form.add(indexName);

    TextField<String> searchPath = new TextField<>("searchPath");
    searchPath.setRequired(true);
    form.add(searchPath);

    TextField<String> objectType = new TextField<>("objectType");
    objectType.setRequired(true);
    form.add(objectType);

    TextField<String> defaultField = new TextField<>("defaultField");
    objectType.setRequired(true);
    form.add(defaultField);

    NumberTextField<Integer> resultSize =
            new NumberTextField<>("resultSize", Integer.class);
    resultSize.setMinimum(1);
    resultSize.setMaximum(10000);
    resultSize.setRequired(true);
    form.add(resultSize);

    NumberTextField<Integer> seed = new NumberTextField<Integer>("seed", Integer.class);
    seed.setMinimum(0);
    seed.setMaximum(Integer.MAX_VALUE);
    seed.add(visibleWhen(() -> properties.isRandomOrder()));
    seed.add(new AttributeModifier("title", new ResourceModel("seedTooltip")));
    seed.setOutputMarkupPlaceholderTag(true);
    seed.setRequired(true);
    form.add(seed);

    CheckBox randomOrder = new CheckBox("randomOrder");
    randomOrder.add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> 
            t.add(seed, randomOrder)));
    form.add(randomOrder);

    add(form);
}
 
Example 13
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 14
Source File: LinkedAccountPlainAttrsPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
protected FormComponent<?> checkboxToggle(
        final Attr attrTO,
        final AbstractFieldPanel<?> panel,
        final boolean isMultivalue) {

    LinkedAccountPlainAttrProperty property = accountPlainAttrProperties.stream().filter(
            existingProperty -> {
                return existingProperty.getSchema().equals(attrTO.getSchema());
            }).findFirst().orElseGet(() -> {
                LinkedAccountPlainAttrProperty newProperty = new LinkedAccountPlainAttrProperty();
                newProperty.setOverridable(linkedAccountTO.getPlainAttr(attrTO.getSchema()).isPresent());
                newProperty.setSchema(attrTO.getSchema());
                newProperty.getValues().addAll(attrTO.getValues());
                accountPlainAttrProperties.add(newProperty);
                return newProperty;
            });

    final BootstrapToggleConfig config = new BootstrapToggleConfig().
            withOnStyle(BootstrapToggleConfig.Style.success).
            withOffStyle(BootstrapToggleConfig.Style.danger).
            withSize(BootstrapToggleConfig.Size.mini);

    return new BootstrapToggle("externalAction", new PropertyModel<Boolean>(property, "overridable"), config) {

        private static final long serialVersionUID = -875219845189261873L;

        @Override
        protected CheckBox newCheckBox(final String id, final IModel<Boolean> model) {
            final CheckBox checkBox = super.newCheckBox(id, model);
            checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

                private static final long serialVersionUID = -1107858522700306810L;

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                    if (isMultivalue) {
                        MultiFieldPanel.class.cast(panel).setFormReadOnly(!model.getObject());
                    } else {
                        FieldPanel.class.cast(panel).setReadOnly(!model.getObject());
                    }

                    updateAccountPlainSchemas(property, model.getObject());
                    target.add(panel);
                }
            });
            return checkBox;
        }

        @Override
        protected IModel<String> getOnLabel() {
            return Model.of("Override");
        }

        @Override
        protected IModel<String> getOffLabel() {
            return Model.of("Override?");
        }

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            tag.append("class", "overridable", " ");
        }
    };
}
 
Example 15
Source File: LinkedAccountCredentialsPanel.java    From syncope with Apache License 2.0 4 votes vote down vote up
private FormComponent<?> checkboxToggle(
        final LinkedAccountPlainAttrProperty property, final FieldPanel<?> panel) {

    final BootstrapToggleConfig config = new BootstrapToggleConfig().
            withOnStyle(BootstrapToggleConfig.Style.success).
            withOffStyle(BootstrapToggleConfig.Style.danger).
            withSize(BootstrapToggleConfig.Size.mini);

    return new BootstrapToggle("externalAction", new PropertyModel<Boolean>(property, "overridable"), config) {

        private static final long serialVersionUID = -875219845189261873L;

        @Override
        protected CheckBox newCheckBox(final String id, final IModel<Boolean> model) {
            final CheckBox checkBox = super.newCheckBox(id, model);
            checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

                private static final long serialVersionUID = -1107858522700306810L;

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                    FieldPanel.class.cast(panel).setReadOnly(!model.getObject());
                    if (model.getObject()) {
                        if (property.getSchema().equals("password")) {
                            linkedAccountTO.setPassword(passwordValue);
                        } else if (property.getSchema().equals("username")) {
                            linkedAccountTO.setUsername(usernameValue);
                        }
                    } else {
                        if (property.getSchema().equals("password")) {
                            passwordValue = linkedAccountTO.getPassword();
                            linkedAccountTO.setPassword(null);
                        } else if (property.getSchema().equals("username")) {
                            usernameValue = linkedAccountTO.getUsername();
                            linkedAccountTO.setUsername(null);
                        }
                    }
                    target.add(panel);
                }
            });
            return checkBox;
        }

        @Override
        protected IModel<String> getOnLabel() {
            return Model.of("Override");
        }

        @Override
        protected IModel<String> getOffLabel() {
            return Model.of("Override?");
        }

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            tag.append("class", "overridable", " ");
        }
    };
}
 
Example 16
Source File: ConnConfPropertyListView.java    From syncope with Apache License 2.0 4 votes vote down vote up
private static FormComponent<?> addCheckboxToggle(final ConnConfProperty property) {
    final BootstrapToggleConfig config = new BootstrapToggleConfig().
            withOnStyle(BootstrapToggleConfig.Style.success).
            withOffStyle(BootstrapToggleConfig.Style.danger).
            withSize(BootstrapToggleConfig.Size.mini);

    return new BootstrapToggle("externalAction", new PropertyModel<Boolean>(property, "overridable"), config) {

        private static final long serialVersionUID = -875219845189261873L;

        @Override
        protected CheckBox newCheckBox(final String id, final IModel<Boolean> model) {
            final CheckBox checkBox = super.newCheckBox(id, model);
            checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

                private static final long serialVersionUID = -1107858522700306810L;

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                }
            });
            return checkBox;
        }

        @Override
        protected IModel<String> getOnLabel() {
            return Model.of("Override");
        }

        @Override
        protected IModel<String> getOffLabel() {
            return Model.of("Override?");
        }

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            super.onComponentTag(tag);
            tag.append("class", "overridable", " ");
        }
    };
}
 
Example 17
Source File: DisabledBootstrapCheckbox.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
protected CheckBox newCheckBox(String id, IModel<Boolean> model) {
    CheckBox checkBox = super.newCheckBox(id, model);
    checkBox.add(new AttributeAppender("disabled", "disabled"));
    return checkBox;
}
 
Example 18
Source File: InstanceListPanel.java    From inception with Apache License 2.0 4 votes vote down vote up
public InstanceListPanel(String aId, IModel<KnowledgeBase> aKbModel, IModel<KBObject> aConcept,
        IModel<KBObject> aInstance) {
    super(aId, aInstance);

    setOutputMarkupId(true);

    kbModel = aKbModel;
    conceptModel = aConcept;
    showAll = Model.of(Boolean.FALSE);
    
    IModel<List<KBHandle>> instancesModel = LoadableDetachableModel.of(this::getInstances);

    OverviewListChoice<KBObject> overviewList = new OverviewListChoice<KBObject>("instances") {
        private static final long serialVersionUID = -122960232588575731L;

        @Override
        protected void onConfigure()
        {
            super.onConfigure();
            
            setVisible(!instancesModel.getObject().isEmpty());
        }
    };
    overviewList.setChoiceRenderer(new ChoiceRenderer<>("uiLabel"));
    overviewList.setModel(aInstance);
    overviewList.setChoices(instancesModel);
    overviewList
            .add(new LambdaAjaxFormComponentUpdatingBehavior("change",
                target -> send(getPage(), Broadcast.BREADTH,
                            new AjaxInstanceSelectionEvent(target, aInstance.getObject()))));
    add(overviewList);

    add(new Label("count", LambdaModel.of(() -> overviewList.getChoices().size())));

    LambdaAjaxLink addLink = new LambdaAjaxLink("add",
        target -> send(getPage(), Broadcast.BREADTH, new AjaxNewInstanceEvent(target)));
    addLink.add(new Label("label", new ResourceModel("instance.add")));
    addLink.add(new WriteProtectionBehavior(kbModel));
    add(addLink);

    add(new Label("noInstancesNotice", new ResourceModel("instance.nonedefined")) {
        private static final long serialVersionUID = 2252854898212441711L;

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

            setVisible(instancesModel.getObject().isEmpty());
        }
    });

    CheckBox showAllCheckBox = new CheckBox("showAllInstances", showAll);
    showAllCheckBox
            .add(new LambdaAjaxFormComponentUpdatingBehavior("change", t -> t.add(this)));
    add(showAllCheckBox);
}