Search in sources :

Example 41 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class LoggingConfigPanel method initAudit.

private void initAudit() {
    CheckBox auditLog = WebComponentUtil.createAjaxCheckBox("auditLog", new PropertyModel<Boolean>(getModel(), "auditLog"));
    add(auditLog);
    CheckBox auditDetails = WebComponentUtil.createAjaxCheckBox("auditDetails", new PropertyModel<Boolean>(getModel(), "auditDetails"));
    add(auditDetails);
    DropDownChoice<String> auditAppender = new DropDownChoice<>("auditAppender", new PropertyModel<String>(getModel(), "auditAppender"), createAppendersListModel());
    auditAppender.setNullValid(true);
    auditAppender.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    add(auditAppender);
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox)

Example 42 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project webanno by webanno.

the class AnnotationPreferencesDialogContent method createLayerContainer.

private ListView<AnnotationLayer> createLayerContainer() {
    return new ListView<AnnotationLayer>("annotationLayers") {

        private static final long serialVersionUID = -4040731191748923013L;

        @Override
        protected void populateItem(ListItem<AnnotationLayer> item) {
            // add checkbox
            // get initial state
            AnnotationPreference pref = stateModel.getObject().getPreferences();
            List<Long> hiddenLayerIds = pref.getHiddenAnnotationLayerIds();
            boolean isPreferredToShow = !hiddenLayerIds.contains(item.getModelObject().getId());
            CheckBox layer_cb = new CheckBox("annotationLayerActive", Model.of(isPreferredToShow));
            layer_cb.add(new AjaxEventBehavior("change") {

                private static final long serialVersionUID = 8378489004897115519L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    // check state & live update preferences
                    List<Long> hiddenLayerIds = stateModel.getObject().getPreferences().getHiddenAnnotationLayerIds();
                    // get and switch state of checkbox
                    boolean isPreferredToShow = layer_cb.getModelObject();
                    layer_cb.setModelObject(!isPreferredToShow);
                    // live update preferences
                    if (isPreferredToShow) {
                        // prefer to deactivate layer
                        hiddenLayerIds.add(item.getModelObject().getId());
                    } else {
                        // prefer to activate layer
                        hiddenLayerIds.remove(item.getModelObject().getId());
                    }
                }
            });
            item.add(layer_cb);
            // add coloring strategy combobox
            ChoiceRenderer<ColoringStrategyType> choiceRenderer = new ChoiceRenderer<>("descriptiveName");
            List<ColoringStrategyType> choices = new ArrayList<ColoringStrategyType>(EnumSet.allOf(ColoringStrategyType.class));
            Model<ColoringStrategyType> initialSelected = Model.of(form.getModelObject().colorPerLayer.get(item.getModelObject().getId()));
            DropDownChoice<ColoringStrategyType> layer_color = new DropDownChoice<ColoringStrategyType>("layercoloring", initialSelected, choices, choiceRenderer);
            layer_color.add(new AjaxFormComponentUpdatingBehavior("change") {

                private static final long serialVersionUID = 1060397773470276585L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    AnnotationLayer current_layer = item.getModelObject();
                    ColoringStrategyType selectedColor = layer_color.getModelObject();
                    form.getModelObject().colorPerLayer.put(current_layer.getId(), selectedColor);
                }
            });
            item.add(layer_color);
            // add label
            Label lbl = new Label("annotationLayerDesc", item.getModelObject().getUiName());
            item.add(lbl);
        }
    };
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AnnotationLayer(de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ChoiceRenderer(org.apache.wicket.markup.html.form.ChoiceRenderer) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) AnnotationPreference(de.tudarmstadt.ukp.clarin.webanno.api.annotation.model.AnnotationPreference) ColoringStrategyType(de.tudarmstadt.ukp.clarin.webanno.api.annotation.coloring.ColoringStrategy.ColoringStrategyType)

Example 43 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class WebComponentUtil method createTriStateCombo.

public static DropDownChoice<Boolean> createTriStateCombo(String id, IModel<Boolean> model) {
    final IChoiceRenderer<Boolean> renderer = new IChoiceRenderer<Boolean>() {

        @Override
        public Boolean getObject(String id, IModel<? extends List<? extends Boolean>> choices) {
            return id != null ? choices.getObject().get(Integer.parseInt(id)) : null;
        }

        @Override
        public String getDisplayValue(Boolean object) {
            String key;
            if (object == null) {
                key = KEY_BOOLEAN_NULL;
            } else {
                key = object ? KEY_BOOLEAN_TRUE : KEY_BOOLEAN_FALSE;
            }
            StringResourceModel model = PageBase.createStringResourceStatic(null, key);
            return model.getString();
        }

        @Override
        public String getIdValue(Boolean object, int index) {
            return Integer.toString(index);
        }
    };
    DropDownChoice<Boolean> dropDown = new DropDownChoice<Boolean>(id, model, createChoices(), renderer) {

        @Override
        protected CharSequence getDefaultChoice(String selectedValue) {
            StringResourceModel model = PageBase.createStringResourceStatic(null, KEY_BOOLEAN_NULL);
            return model.getString();
        }
    };
    dropDown.setNullValid(true);
    return dropDown;
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) IModel(org.apache.wicket.model.IModel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 44 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class MultiValueDropDownPanel method initLayout.

private void initLayout(final boolean nullValid, final NonEmptyModel<Boolean> readOnlyModel) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);
    AjaxLink<Void> placeholderAdd = new AjaxLink<Void>(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new IModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    placeholderContainer.add(placeholderAdd);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            DropDownChoice choice = new DropDownChoice<>(ID_INPUT, createDropDownItemModel(item.getModel()), createChoiceList(), createRenderer());
            choice.setNullValid(nullValid);
            choice.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
            item.add(choice);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ListView(org.apache.wicket.markup.html.list.ListView) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 45 with DropDownChoice

use of org.apache.wicket.markup.html.form.DropDownChoice in project midpoint by Evolveum.

the class QNameEditorPanel method initLayout.

private void initLayout(String localPartTooltipKey, String namespaceTooltipKey, boolean markLocalPartAsRequired, boolean markNamespaceAsRequired) {
    Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString("SchemaHandlingStep.association.label.associationName"));
    localPartLabel.setOutputMarkupId(true);
    localPartLabel.setOutputMarkupPlaceholderTag(true);
    localPartLabel.add(getSpecificLabelStyleAppender());
    add(localPartLabel);
    WebMarkupContainer localPartRequired = new WebMarkupContainer(ID_LOCAL_PART_REQUIRED);
    localPartRequired.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return markLocalPartAsRequired;
        }
    });
    add(localPartRequired);
    Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString("SchemaHandlingStep.association.label.associationNamespace"));
    namespaceLabel.setOutputMarkupId(true);
    namespaceLabel.setOutputMarkupPlaceholderTag(true);
    namespaceLabel.add(getSpecificLabelStyleAppender());
    add(namespaceLabel);
    WebMarkupContainer namespaceRequired = new WebMarkupContainer(ID_NAMESPACE_REQUIRED);
    namespaceRequired.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return markNamespaceAsRequired;
        }
    });
    add(namespaceRequired);
    TextField<?> localPart = new TextField<>(ID_LOCAL_PART, localPartModel);
    localPart.setOutputMarkupId(true);
    localPart.setOutputMarkupPlaceholderTag(true);
    localPart.setRequired(isLocalPartRequired());
    localPart.add(new UpdateBehavior());
    add(localPart);
    DropDownChoice<?> namespace = new DropDownChoice<>(ID_NAMESPACE, namespaceModel, prepareNamespaceList());
    namespace.setOutputMarkupId(true);
    namespace.setOutputMarkupPlaceholderTag(true);
    namespace.setNullValid(false);
    namespace.setRequired(isNamespaceRequired());
    namespace.add(new UpdateBehavior());
    add(namespace);
    Label localPartTooltip = new Label(ID_T_LOCAL_PART);
    localPartTooltip.add(new AttributeAppender("data-original-title", getString(localPartTooltipKey)));
    localPartTooltip.add(new InfoTooltipBehavior());
    localPartTooltip.setOutputMarkupPlaceholderTag(true);
    localPartTooltip.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return localPartTooltipKey != null;
        }
    });
    add(localPartTooltip);
    Label namespaceTooltip = new Label(ID_T_NAMESPACE);
    namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey)));
    namespaceTooltip.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return namespaceTooltipKey != null;
        }
    });
    namespaceTooltip.add(new InfoTooltipBehavior());
    namespaceTooltip.setOutputMarkupPlaceholderTag(true);
    add(namespaceTooltip);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Label(org.apache.wicket.markup.html.basic.Label) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)52 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)30 List (java.util.List)18 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)17 Label (org.apache.wicket.markup.html.basic.Label)17 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)16 CheckBox (org.apache.wicket.markup.html.form.CheckBox)14 IModel (org.apache.wicket.model.IModel)14 ArrayList (java.util.ArrayList)12 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)11 Form (org.apache.wicket.markup.html.form.Form)11 TextField (org.apache.wicket.markup.html.form.TextField)11 PropertyModel (org.apache.wicket.model.PropertyModel)11 QName (javax.xml.namespace.QName)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)7 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)6 ListItem (org.apache.wicket.markup.html.list.ListItem)6 ListView (org.apache.wicket.markup.html.list.ListView)6 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)5