Search in sources :

Example 26 with CheckBox

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

the class LiveSyncHandlerPanel method initLayout.

private void initLayout(final PageTaskEdit parentPage) {
    WebMarkupContainer tokenContainer = new WebMarkupContainer(ID_TOKEN_CONTAINER);
    tokenContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            //TODO
            return true;
        }
    });
    tokenContainer.add(new Label(ID_TOKEN, new PropertyModel<>(getModel(), LiveSyncHandlerDto.F_TOKEN)));
    LinkIconPanel deleteTokenPanel = new LinkIconPanel(ID_DELETE_TOKEN, new Model("fa fa-fw fa-trash-o fa-lg text-danger"), createStringResource("LiveSyncHandlerPanel.deleteToken")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            parentPage.getController().deleteSyncTokenPerformed(target);
        }
    };
    deleteTokenPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            // TODO ... and security
            return !parentPage.isEdit() && getModelObject().hasToken();
        }
    });
    deleteTokenPanel.setRenderBodyOnly(true);
    tokenContainer.add(deleteTokenPanel);
    add(tokenContainer);
    WebMarkupContainer retryContainer = new WebMarkupContainer(ID_TOKEN_RETRY_CONTAINER);
    add(retryContainer);
    WebMarkupContainer retryCheckboxContainer = new WebMarkupContainer(ID_TOKEN_RETRY_CHECKBOX_CONTAINER);
    retryContainer.add(retryCheckboxContainer);
    CheckBox retryCheckbox = new CheckBox(ID_TOKEN_RETRY_CHECKBOX, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_TOKEN_RETRY_UNHANDLED_ERR));
    retryCheckbox.add(enabledIfEdit);
    retryCheckboxContainer.add(retryCheckbox);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkIconPanel(com.evolveum.midpoint.web.component.data.column.LinkIconPanel)

Example 27 with CheckBox

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

the class AnnotationFeatureForm method createForwardAnnotationCheckBox.

private CheckBox createForwardAnnotationCheckBox() {
    return new CheckBox("forwardAnnotation") {

        private static final long serialVersionUID = 8908304272310098353L;

        {
            setOutputMarkupId(true);
            add(new AjaxFormComponentUpdatingBehavior("change") {

                private static final long serialVersionUID = 5179816588460867471L;

                @Override
                protected void onUpdate(AjaxRequestTarget aTarget) {
                    if (AnnotationFeatureForm.this.getModelObject().isForwardAnnotation()) {
                        List<AnnotationFeature> features = getEnabledFeatures(AnnotationFeatureForm.this.getModelObject().getSelectedAnnotationLayer());
                        if (features.size() > 1) {
                            // forward annotation process checking)
                            return;
                        }
                        // forward annotations
                        if (!features.isEmpty() && features.get(0).getTagset() == null) {
                            FeatureEditor editor = getFirstFeatureEditor();
                            if (editor != null) {
                                aTarget.focusComponent(editor.getFocusComponent());
                            }
                        } else {
                            aTarget.appendJavaScript(JavascriptUtils.getFocusScript(forwardAnnotationText));
                            selectedTag = "";
                        }
                    }
                }
            });
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            setEnabled(isForwardable());
            if (!isForwardable()) {
                AnnotationFeatureForm.this.getModelObject().setForwardAnnotation(false);
            }
        }
    };
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBox(org.apache.wicket.markup.html.form.CheckBox) List(java.util.List) ArrayList(java.util.ArrayList) LinkFeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.LinkFeatureEditor) FeatureEditor(de.tudarmstadt.ukp.clarin.webanno.api.annotation.feature.editor.FeatureEditor)

Example 28 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox 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 29 with CheckBox

use of org.apache.wicket.markup.html.form.CheckBox in project syncope by apache.

the class ConnConfPropertyListView method addCheckboxToggle.

private 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", " ");
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) BootstrapToggleConfig(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggleConfig) BootstrapToggle(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggle) IndicatorAjaxFormComponentUpdatingBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ComponentTag(org.apache.wicket.markup.ComponentTag)

Example 30 with CheckBox

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

the class DeleteAllPanel method initLayout.

private void initLayout(WebMarkupContainer content) {
    CheckBox deleteUsersCheckbox = new CheckBox(ID_CHB_USERS, new PropertyModel<>(model, DeleteAllDto.F_USERS));
    deleteUsersCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_USERS);
        }
    });
    content.add(deleteUsersCheckbox);
    CheckBox deleteOrgsCheckbox = new CheckBox(ID_CHB_ORG, new PropertyModel<>(model, DeleteAllDto.F_ORGS));
    deleteOrgsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_ORGS);
        }
    });
    content.add(deleteOrgsCheckbox);
    CheckBox deleteAccountShadowsCheckbox = new CheckBox(ID_CHB_ACCOUNT_SHADOW, new PropertyModel<>(model, DeleteAllDto.F_ACC_SHADOW));
    deleteAccountShadowsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_ACC_SHADOWS);
        }
    });
    content.add(deleteAccountShadowsCheckbox);
    CheckBox deleteNonAccountShadowsCheckbox = new CheckBox(ID_CHB_NON_ACCOUNT_SHADOW, new PropertyModel<>(model, DeleteAllDto.F_NON_ACC_SHADOW));
    deleteNonAccountShadowsCheckbox.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateLabelModel(target, ID_TEXT_NON_ACC_SHADOW);
        }
    });
    content.add(deleteNonAccountShadowsCheckbox);
    Label usersLabel = new Label(ID_TEXT_USERS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteUsersMessage();
        }
    });
    usersLabel.setOutputMarkupId(true);
    content.add(usersLabel);
    Label orgsLabel = new Label(ID_TEXT_ORGS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteOrgUnitsMessage();
        }
    });
    orgsLabel.setOutputMarkupId(true);
    content.add(orgsLabel);
    Label accShadowsLabel = new Label(ID_TEXT_ACC_SHADOWS, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteAccountShadowsMessage();
        }
    });
    accShadowsLabel.setOutputMarkupId(true);
    content.add(accShadowsLabel);
    Label nonAccShadowsLabel = new Label(ID_TEXT_NON_ACC_SHADOW, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createDeleteNonAccountShadowsMessage();
        }
    });
    nonAccShadowsLabel.setOutputMarkupId(true);
    content.add(nonAccShadowsLabel);
    Label countLabel = new Label(ID_TOTAL, new LoadableModel<String>() {

        @Override
        protected String load() {
            return createTotalMessage();
        }
    });
    countLabel.setOutputMarkupId(true);
    content.add(countLabel);
    AjaxButton yesButton = new AjaxButton(ID_YES, new StringResourceModel("deleteAllDialog.yes", this, null)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            yesPerformed(target);
        }
    };
    content.add(yesButton);
    AjaxButton noButton = new AjaxButton(ID_NO, new StringResourceModel("deleteAllDialog.no", this, null)) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            noPerformed(target);
        }
    };
    content.add(noButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) StringResourceModel(org.apache.wicket.model.StringResourceModel) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior)

Aggregations

CheckBox (org.apache.wicket.markup.html.form.CheckBox)39 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)24 Label (org.apache.wicket.markup.html.basic.Label)20 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)16 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)14 ArrayList (java.util.ArrayList)12 List (java.util.List)12 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)11 PropertyModel (org.apache.wicket.model.PropertyModel)11 Form (org.apache.wicket.markup.html.form.Form)10 TextField (org.apache.wicket.markup.html.form.TextField)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)9 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)8 IModel (org.apache.wicket.model.IModel)7 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)5 Model (org.apache.wicket.model.Model)5 EmptyOnChangeAjaxFormUpdatingBehavior (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior)4 StringChoiceRenderer (com.gitblit.wicket.StringChoiceRenderer)4 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)4 ListItem (org.apache.wicket.markup.html.list.ListItem)4