Search in sources :

Example 21 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class DropDownFormGroup method initLayout.

private void initLayout(IModel<List<T>> choices, IChoiceRenderer<T> renderer, IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize, final boolean required) {
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
    add(labelContainer);
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        labelContainer.add(AttributeAppender.prepend("class", labelSize));
    }
    labelContainer.add(l);
    Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
    tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getString(tooltipKey);
        }
    }));
    tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal));
    tooltipLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return tooltipKey != null;
        }
    });
    tooltipLabel.setOutputMarkupId(true);
    tooltipLabel.setOutputMarkupPlaceholderTag(true);
    labelContainer.add(tooltipLabel);
    WebMarkupContainer requiredContainer = new WebMarkupContainer(ID_REQUIRED);
    requiredContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return required;
        }
    });
    labelContainer.add(requiredContainer);
    WebMarkupContainer selectWrapper = new WebMarkupContainer(ID_SELECT_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        selectWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(selectWrapper);
    DropDownChoice select = createDropDown(ID_SELECT, choices, renderer, required);
    select.setLabel(label);
    selectWrapper.add(select);
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(select));
    feedback.setOutputMarkupId(true);
    selectWrapper.add(feedback);
    Component additionalInfo = createAdditionalInfoComponent(ID_ADDITIONAL_INFO);
    if (additionalInfo == null) {
        additionalInfo = new Label(ID_ADDITIONAL_INFO, "");
    }
    selectWrapper.add(additionalInfo);
}
Also used : InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) Component(org.apache.wicket.Component) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 22 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class AssignmentCatalogPanel method addOrReplaceLayout.

public void addOrReplaceLayout(AjaxRequestTarget target, WebMarkupContainer panelContainer) {
    WebMarkupContainer treePanelContainer = new WebMarkupContainer(ID_TREE_PANEL_CONTAINER);
    treePanelContainer.setOutputMarkupId(true);
    panelContainer.addOrReplace(treePanelContainer);
    if (AssignmentViewType.ROLE_CATALOG_VIEW.equals(AssignmentViewType.getViewTypeFromSession(pageBase)) && StringUtils.isNotEmpty(rootOid)) {
        // not let tree panel initializing in case of empty role catalog oid
        OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, Model.of(rootOid), false, "AssignmentShoppingCartPanel.treeTitle") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void selectTreeItemPerformed(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
                AssignmentCatalogPanel.this.selectTreeItemPerformed(selected, target);
            }

            protected List<InlineMenuItem> createTreeMenu() {
                return new ArrayList<>();
            }

            @Override
            protected List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
                return new ArrayList<>();
            }

            @Override
            protected OrgTreeStateStorage getOrgTreeStateStorage() {
                return getRoleCatalogStorage();
            }
        };
        treePanel.setOutputMarkupId(true);
        treePanelContainer.add(new AttributeAppender("class", "col-md-3"));
        treePanelContainer.add(new VisibleEnableBehaviour() {

            private static final long serialVersionUID = 1L;

            @Override
            public boolean isVisible() {
                return !isCatalogOidEmpty();
            }
        });
        treePanelContainer.addOrReplace(treePanel);
    } else {
        WebMarkupContainer treePanel = new WebMarkupContainer(ID_TREE_PANEL);
        treePanel.setVisible(false);
        treePanel.setOutputMarkupId(true);
        treePanelContainer.addOrReplace(treePanel);
    }
    WebMarkupContainer catalogItemsPanelContainer = new WebMarkupContainer(ID_CATALOG_ITEMS_PANEL_CONTAINER);
    catalogItemsPanelContainer.setOutputMarkupId(true);
    panelContainer.addOrReplace(catalogItemsPanelContainer);
    String assignmentsOwnerName = getRoleCatalogStorage().getAssignmentsUserOwner() != null ? getRoleCatalogStorage().getAssignmentsUserOwner().getName().getOrig() : "";
    Label assignmentsOwnerLabel = new Label(ID_ASSIGNMENTS_OWNER_NAME, createStringResource("AssignmentCatalogPanel.assignmentsOwner", assignmentsOwnerName));
    assignmentsOwnerLabel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return AssignmentViewType.USER_TYPE.equals(getRoleCatalogStorage().getViewType());
        }
    });
    catalogItemsPanelContainer.add(assignmentsOwnerLabel);
    CatalogItemsPanel catalogItemsPanel;
    if (AssignmentViewType.USER_TYPE.equals(viewModel.getObject())) {
        PrismObject<UserType> assignmentsOwner = getRoleCatalogStorage().getAssignmentsUserOwner();
        listProviderData = new ArrayList<>();
        if (assignmentsOwner != null) {
            List<AssignmentType> assignments = assignmentsOwner.asObjectable().getAssignment();
            for (AssignmentType assignment : assignments) {
                if (assignment.getTargetRef() == null || !UserType.COMPLEX_TYPE.equals(assignment.getTargetRef().getType())) {
                    assignment.setId(null);
                    listProviderData.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, pageBase));
                }
            }
            Collections.sort(listProviderData);
        }
        ListDataProvider listDataProvider = new ListDataProvider(this, Model.ofList(listProviderData));
        catalogItemsPanel = new CatalogItemsPanel(ID_CATALOG_ITEMS_PANEL, pageBase, itemsPerRow, listDataProvider);
    } else {
        catalogItemsPanel = new CatalogItemsPanel(ID_CATALOG_ITEMS_PANEL, selectedTreeItemOidModel, pageBase, itemsPerRow, objectProvider);
    }
    if (AssignmentViewType.ROLE_CATALOG_VIEW.equals(AssignmentViewType.getViewTypeFromSession(pageBase))) {
        catalogItemsPanelContainer.add(new AttributeAppender("class", "col-md-9"));
    } else {
        catalogItemsPanelContainer.add(new AttributeAppender("class", "col-md-12"));
    }
    catalogItemsPanel.setOutputMarkupId(true);
    catalogItemsPanelContainer.addOrReplace(catalogItemsPanel);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OrgTreePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 23 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class NotificationConfigPanel method initLayout.

@Override
protected void initLayout() {
    TextField<String> defaultFromField = WebComponentUtil.createAjaxTextField(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "defaultFrom"));
    CheckBox debugCheck = WebComponentUtil.createAjaxCheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "debug"));
    DropDownChoice mailServerConfigChooser = new DropDownChoice<>(ID_MAIL_SERVER, new PropertyModel<MailServerConfigurationTypeDto>(getModel(), NotificationConfigurationDto.F_SELECTED_SERVER), new AbstractReadOnlyModel<List<MailServerConfigurationTypeDto>>() {

        @Override
        public List<MailServerConfigurationTypeDto> getObject() {
            return getModel().getObject().getServers();
        }
    }, new ChoiceableChoiceRenderer<MailServerConfigurationTypeDto>());
    mailServerConfigChooser.setNullValid(true);
    mailServerConfigChooser.add(new AjaxFormSubmitBehavior("click") {

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            getForm().onFormSubmitted();
        }
    });
    mailServerConfigChooser.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this);
        }
    });
    add(mailServerConfigChooser);
    Label serverConfigTooltip = new Label(ID_MAIL_SERVER_TOOLTIP);
    serverConfigTooltip.add(new InfoTooltipBehavior());
    add(serverConfigTooltip);
    WebMarkupContainer serverConfigContainer = new WebMarkupContainer(ID_MAIL_SERVER_CONFIG_CONTAINER);
    serverConfigContainer.setOutputMarkupId(true);
    serverConfigContainer.setOutputMarkupPlaceholderTag(true);
    serverConfigContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject() != null) {
                return getModelObject().getSelectedServer() != null;
            }
            return false;
        }
    });
    add(serverConfigContainer);
    TextField<String> hostField = WebComponentUtil.createAjaxTextField(ID_HOST, new PropertyModel<String>(getModel(), "selectedServer.host"));
    TextField<Integer> portField = WebComponentUtil.createAjaxTextField(ID_PORT, new PropertyModel<Integer>(getModel(), "selectedServer.port"));
    TextField<String> userNameField = WebComponentUtil.createAjaxTextField(ID_USERNAME, new PropertyModel<String>(getModel(), "selectedServer.username"));
    PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "selectedServer.password"));
    passwordField.setRequired(false);
    passwordField.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    TextField<String> redirectToFileField = WebComponentUtil.createAjaxTextField(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "redirectToFile"));
    DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(), "selectedServer.mailTransportSecurityType"), WebComponentUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class), new EnumChoiceRenderer<MailTransportSecurityType>(this), createStringResource("SystemConfigPanel.mail.transportSecurity"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
    // transportSecurity.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
    serverConfigContainer.add(hostField);
    serverConfigContainer.add(portField);
    serverConfigContainer.add(userNameField);
    serverConfigContainer.add(passwordField);
    serverConfigContainer.add(transportSecurity);
    add(defaultFromField);
    add(debugCheck);
    add(redirectToFileField);
    AjaxSubmitLink buttonAddNewMailServerConfig = new AjaxSubmitLink(ID_BUTTON_ADD_NEW_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            MailServerConfigurationTypeDto newConfig = new MailServerConfigurationTypeDto();
            newConfig.setHost(getString("SystemConfigPanel.mail.config.placeholder"));
            if (getModelObject() != null) {
                getModelObject().getServers().add(newConfig);
                getModelObject().setSelectedServer(newConfig);
            }
            preparePasswordFieldPlaceholder();
            target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    add(buttonAddNewMailServerConfig);
    AjaxSubmitLink removeMailServerConfig = new AjaxSubmitLink(ID_BUTTON_REMOVE_MAIL_SERVER_CONFIG) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            if (getModelObject() != null) {
                NotificationConfigurationDto notificationConfig = getModelObject();
                MailServerConfigurationTypeDto selected = notificationConfig.getSelectedServer();
                if (notificationConfig.getServers().contains(selected)) {
                    notificationConfig.getServers().remove(selected);
                    notificationConfig.setSelectedServer(null);
                } else {
                    warn(getString("SystemConfigPanel.mail.server.remove.warn"));
                }
                target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
            target.add(getPageBase().getFeedbackPanel());
        }
    };
    removeMailServerConfig.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (getModelObject() != null && getModelObject().getSelectedServer() != null) {
                return null;
            } else {
                return " disabled";
            }
        }
    }));
    add(removeMailServerConfig);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxFormSubmitBehavior(org.apache.wicket.ajax.form.AjaxFormSubmitBehavior) MailServerConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.MailServerConfigurationTypeDto) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) NotificationConfigurationDto(com.evolveum.midpoint.web.page.admin.configuration.dto.NotificationConfigurationDto) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) MailTransportSecurityType(com.evolveum.midpoint.xml.ns._public.common.common_3.MailTransportSecurityType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox)

Example 24 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project ocvn by devgateway.

the class PercentageFieldBootstrapFormComponent method onInitialize.

@Override
protected void onInitialize() {
    decimal();
    getField().add(new RangeValidator<>(BigDecimal.ZERO, BigDecimal.valueOf(PERCENT_MAX)));
    super.onInitialize();
    label = new Label("label", "%");
    label.add(new AttributeAppender("for", new Model<>(getField().getMarkupId())));
    border.add(label);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 25 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project ocvn by devgateway.

the class BootstrapDeleteButton method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(new AttributeAppender("onclick", new Model<String>("window.onbeforeunload = null;"), " "));
    setDefaultFormProcessing(false);
    setIconType(FontAwesomeIconType.trash_o);
    if (ComponentUtil.isViewMode()) {
        setVisibilityAllowed(false);
    }
}
Also used : Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)51 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)29 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)25 Label (org.apache.wicket.markup.html.basic.Label)24 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)24 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)23 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)17 IModel (org.apache.wicket.model.IModel)10 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)8 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)7 ListItem (org.apache.wicket.markup.html.list.ListItem)7 ListView (org.apache.wicket.markup.html.list.ListView)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AttributeModifier (org.apache.wicket.AttributeModifier)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5 TextField (org.apache.wicket.markup.html.form.TextField)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)4