Search in sources :

Example 1 with WebMarkupContainer

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

the class PasswordPanel method initLayout.

private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
    setOutputMarkupId(true);
    final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) {

        @Override
        public boolean isVisible() {
            return passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    add(inputContainer);
    final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model));
    password1.setRequired(false);
    password1.setResetPassword(false);
    password1.setOutputMarkupId(true);
    password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password1);
    final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>());
    password2.setRequired(false);
    password2.setResetPassword(false);
    password2.setOutputMarkupId(true);
    password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    inputContainer.add(password2);
    password1.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            boolean required = !StringUtils.isEmpty(password1.getModel().getObject());
            password2.setRequired(required);
        //fix of MID-2463
        //				target.add(password2);
        //				target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()");
        }
    });
    password2.add(new PasswordValidator(password1, password2));
    final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) {

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    inputContainer.setOutputMarkupId(true);
    linkContainer.setOutputMarkupId(true);
    add(linkContainer);
    final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet"));
    linkContainer.add(passwordSetLabel);
    final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel"));
    passwordRemoveLabel.setVisible(false);
    linkContainer.add(passwordRemoveLabel);
    AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onLinkClick(target);
        }

        @Override
        public boolean isVisible() {
            return !passwordInputVisble;
        }
    };
    link.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isReadOnly;
        }
    });
    link.setBody(new ResourceModel("passwordPanel.passwordChange"));
    link.setOutputMarkupId(true);
    linkContainer.add(link);
    final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER);
    AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onRemovePassword(model, target);
        }
    };
    removePassword.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            PageBase pageBase = (PageBase) getPage();
            if (pageBase == null) {
                return false;
            }
            if (pageBase instanceof PageSelfProfile) {
                return false;
            }
            if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
                return true;
            }
            return false;
        }
    });
    removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
    removePassword.setOutputMarkupId(true);
    removeButtonContainer.add(removePassword);
    add(removeButtonContainer);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Label(org.apache.wicket.markup.html.basic.Label) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) PageSelfProfile(com.evolveum.midpoint.web.page.self.PageSelfProfile) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceModel(org.apache.wicket.model.ResourceModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with WebMarkupContainer

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

the class DropdownButtonPanel method initMenuItem.

private void initMenuItem(ListItem<InlineMenuItem> menuItem) {
    final InlineMenuItem item = menuItem.getModelObject();
    WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, menuItem.getModel());
    menuItemBody.setRenderBodyOnly(true);
    menuItem.add(menuItemBody);
}
Also used : MenuLinkPanel(com.evolveum.midpoint.web.component.menu.cog.MenuLinkPanel) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 3 with WebMarkupContainer

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

the class DropdownButtonPanel method initLayout.

private void initLayout(DropdownButtonDto model) {
    Label info = new Label(ID_INFO, model.getInfo());
    add(info);
    Label label = new Label(ID_LABEL, model.getLabel());
    add(label);
    WebMarkupContainer icon = new WebMarkupContainer(ID_ICON);
    icon.add(AttributeModifier.append("class", model.getIcon()));
    add(icon);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, new Model((Serializable) model.getMenuItems())) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            initMenuItem(item);
        }
    };
    add(li);
}
Also used : Serializable(java.io.Serializable) ListView(org.apache.wicket.markup.html.list.ListView) Label(org.apache.wicket.markup.html.basic.Label) Model(org.apache.wicket.model.Model) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ListItem(org.apache.wicket.markup.html.list.ListItem) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 4 with WebMarkupContainer

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

the class ObjectBrowserPanel method initLayout.

private void initLayout(Class<? extends O> type, final List<QName> supportedTypes, final boolean multiselect) {
    WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
    typePanel.setOutputMarkupId(true);
    typePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return supportedTypes.size() != 1;
        }
    });
    add(typePanel);
    DropDownChoice<QName> typeSelect = new DropDownChoice<QName>(ID_TYPE, typeModel, new ListModel<QName>(supportedTypes), new QNameChoiceRenderer());
    typeSelect.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
            listPanel = createObjectListPanel(qnameToCompileTimeClass(typeModel.getObject()), multiselect);
            addOrReplace(listPanel);
            target.add(listPanel);
        }
    });
    typePanel.add(typeSelect);
    ObjectListPanel<O> listPanel = createObjectListPanel(type, multiselect);
    add(listPanel);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedObjects();
            QName type = ObjectBrowserPanel.this.typeModel.getObject();
            ObjectBrowserPanel.this.addPerformed(target, type, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
}
Also used : QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 5 with WebMarkupContainer

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

the class ObjectListPanel method createTable.

private BoxedTablePanel<SelectableBean<O>> createTable() {
    List<IColumn<SelectableBean<O>, String>> columns;
    if (isCustomColumnsListConfigured()) {
        columns = initCustomColumns();
    } else {
        columns = initColumns();
    }
    BaseSortableDataProvider<SelectableBean<O>> provider = initProvider();
    BoxedTablePanel<SelectableBean<O>> table = new BoxedTablePanel<SelectableBean<O>>(ID_TABLE, provider, columns, tableId, tableId == null ? 10 : parentPage.getSessionStorage().getUserProfile().getPagingSize(tableId)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return initSearch(headerId);
        }

        @Override
        public String getAdditionalBoxCssClasses() {
            return ObjectListPanel.this.getAdditionalBoxCssClasses();
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            WebMarkupContainer bar = ObjectListPanel.this.createTableButtonToolbar(id);
            return bar != null ? bar : super.createButtonToolbar(id);
        }
    };
    table.setOutputMarkupId(true);
    String storageKey = getStorageKey();
    if (StringUtils.isNotEmpty(storageKey)) {
        PageStorage storage = getPageStorage(storageKey);
        if (storage != null) {
            table.setCurrentPage(storage.getPaging());
        }
    }
    return table;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Aggregations

WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)539 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)197 Label (org.apache.wicket.markup.html.basic.Label)187 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)147 IModel (org.apache.wicket.model.IModel)86 ArrayList (java.util.ArrayList)76 ListItem (org.apache.wicket.markup.html.list.ListItem)70 ListView (org.apache.wicket.markup.html.list.ListView)65 Test (org.junit.Test)65 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)64 List (java.util.List)61 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)60 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)50 PropertyModel (org.apache.wicket.model.PropertyModel)49 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)47 WebComponent (org.apache.wicket.markup.html.WebComponent)46 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)40 AttributeModifier (org.apache.wicket.AttributeModifier)35 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)34 TextField (org.apache.wicket.markup.html.form.TextField)31