Search in sources :

Example 61 with AjaxButton

use of com.evolveum.midpoint.web.component.AjaxButton in project midpoint by Evolveum.

the class TypedAssignablePanel method initLayout.

private void initLayout(Class<T> type, final boolean multiselect) {
    DropDownChoice<QName> typeSelect = new DropDownChoice(ID_TYPE, typeModel, new ListModel(WebComponentUtil.createAssignableTypesList()), new QNameChoiceRenderer());
    typeSelect.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_TABLES_CONTAINER));
            target.add(addOrReplace(createCountContainer()));
        }
    });
    typeSelect.setOutputMarkupId(true);
    add(typeSelect);
    WebMarkupContainer tablesContainer = new WebMarkupContainer(ID_TABLES_CONTAINER);
    tablesContainer.setOutputMarkupId(true);
    add(tablesContainer);
    PopupObjectListPanel<T> listRolePanel = createObjectListPanel(ID_ROLE_TABLE, ID_SELECTED_ROLES, RoleType.COMPLEX_TYPE);
    tablesContainer.add(listRolePanel);
    PopupObjectListPanel<T> listResourcePanel = createObjectListPanel(ID_RESOURCE_TABLE, ID_SELECTED_RESOURCES, ResourceType.COMPLEX_TYPE);
    tablesContainer.add(listResourcePanel);
    PopupObjectListPanel<T> listOrgPanel = createObjectListPanel(ID_ORG_TABLE, ID_SELECTED_ORGS, OrgType.COMPLEX_TYPE);
    tablesContainer.add(listOrgPanel);
    PopupObjectListPanel<T> listServicePanel = createObjectListPanel(ID_SERVICE_TABLE, ID_SELECTED_SERVICES, ServiceType.COMPLEX_TYPE);
    tablesContainer.add(listServicePanel);
    WebMarkupContainer countContainer = createCountContainer();
    add(countContainer);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ASSIGN, createStringResource("userBrowserDialog.button.addButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<T> selected = getSelectedData(ID_ROLE_TABLE);
            selected.addAll(getSelectedData(ID_RESOURCE_TABLE));
            selected.addAll(getSelectedData(ID_ORG_TABLE));
            selected.addAll(getSelectedData(ID_SERVICE_TABLE));
            TypedAssignablePanel.this.addPerformed(target, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

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

Example 62 with AjaxButton

use of com.evolveum.midpoint.web.component.AjaxButton in project midpoint by Evolveum.

the class AbstractObjectMainPanel method initLayoutBackButton.

protected void initLayoutBackButton(PageAdminObjectDetails<O> parentPage) {
    AjaxButton back = new AjaxButton(ID_BACK, parentPage.createStringResource("pageAdminFocus.button.back")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            backPerformed(target);
        }
    };
    mainForm.add(back);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton)

Example 63 with AjaxButton

use of com.evolveum.midpoint.web.component.AjaxButton in project midpoint by Evolveum.

the class UserMenuPanel method initLayout.

private void initLayout() {
    WebMarkupContainer iconBox = new WebMarkupContainer(ID_ICON_BOX);
    add(iconBox);
    NonCachingImage img = new NonCachingImage(ID_PHOTO, new AbstractReadOnlyModel<AbstractResource>() {

        @Override
        public AbstractResource getObject() {
            if (jpegPhoto == null) {
                return null;
            } else {
                return new ByteArrayResource("image/jpeg", jpegPhoto);
            }
        }
    });
    img.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto != null;
        }
    });
    iconBox.add(img);
    ContextImage icon = new ContextImage(ID_ICON, "img/placeholder.png");
    icon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto == null;
        }
    });
    iconBox.add(icon);
    Label usernameLink = new Label(ID_USERNAME_LINK, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getShortUserName();
        }
    });
    add(usernameLink);
    WebMarkupContainer panelIconBox = new WebMarkupContainer(ID_PANEL_ICON_BOX);
    add(panelIconBox);
    NonCachingImage panelImg = new NonCachingImage(ID_PANEL_PHOTO, new AbstractReadOnlyModel<AbstractResource>() {

        @Override
        public AbstractResource getObject() {
            if (jpegPhoto == null) {
                return null;
            } else {
                return new ByteArrayResource("image/jpeg", jpegPhoto);
            }
        }
    });
    panelImg.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto != null;
        }
    });
    panelIconBox.add(panelImg);
    ContextImage panelIcon = new ContextImage(ID_PANEL_ICON, "img/placeholder.png");
    panelIcon.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (userModel != null && userModel.getObject() == null) {
                loadModel(null);
            }
            return jpegPhoto == null;
        }
    });
    panelIconBox.add(panelIcon);
    Label username = new Label(ID_USERNAME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return getShortUserName();
        }
    });
    username.setRenderBodyOnly(true);
    add(username);
    ExternalLink logoutLink = new ExternalLink(ID_LOGOUT_LINK, new Model<>(RequestCycle.get().getRequest().getContextPath() + "/j_spring_security_logout"), createStringResource("UserMenuPanel.logout"));
    add(logoutLink);
    AjaxButton editPasswordQ = new AjaxButton(ID_PASSWORD_QUESTIONS, createStringResource("UserMenuPanel.editPasswordQuestions")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PageMyPasswordQuestions myPasswordQuestions = new PageMyPasswordQuestions(passwordQuestionsDtoIModel);
            setResponsePage(myPasswordQuestions);
        }
    };
    add(editPasswordQ);
    if (!isPasswordModelLoaded) {
        passwordQuestionsDtoIModel = new LoadableModel<PasswordQuestionsDto>(false) {

            private static final long serialVersionUID = 1L;

            @Override
            protected PasswordQuestionsDto load() {
                return loadModel(null);
            }
        };
        isPasswordModelLoaded = true;
    }
    securityPolicyQuestionsModel = new LoadableModel<List<SecurityQuestionDefinitionType>>(false) {

        @Override
        protected List<SecurityQuestionDefinitionType> load() {
            return loadSecurityPloicyQuestionsModel();
        }
    };
    editPasswordQ.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (securityPolicyQuestionsModel == null || securityPolicyQuestionsModel.getObject() == null) {
                loadSecurityPloicyQuestionsModel();
            }
            return hasQuestions() || (securityPolicyQuestionsModel.getObject() != null && securityPolicyQuestionsModel.getObject().size() > 0);
        }
    });
}
Also used : NonCachingImage(org.apache.wicket.markup.html.image.NonCachingImage) Label(org.apache.wicket.markup.html.basic.Label) ContextImage(org.apache.wicket.markup.html.image.ContextImage) PageMyPasswordQuestions(com.evolveum.midpoint.web.page.admin.home.PageMyPasswordQuestions) AbstractResource(org.apache.wicket.request.resource.AbstractResource) ByteArrayResource(org.apache.wicket.request.resource.ByteArrayResource) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ExternalLink(org.apache.wicket.markup.html.link.ExternalLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PasswordQuestionsDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordQuestionsDto)

Example 64 with AjaxButton

use of com.evolveum.midpoint.web.component.AjaxButton in project midpoint by Evolveum.

the class InlineMenu method initLayout.

@Override
protected void initLayout() {
    WebMarkupContainer menuItemContainer = new WebMarkupContainer(ID_MENU_ITEM_CONTAINER);
    menuItemContainer.setOutputMarkupId(true);
    menuItemContainer.add(new AttributeAppender("class", getMenuItemContainerClass()));
    menuItemContainer.add(new AttributeAppender("style", getMenuItemContainerStyle()));
    add(menuItemContainer);
    AjaxButton menuItemButton = new AjaxButton(ID_MENU_ITEM_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
        }
    };
    menuItemButton.setOutputMarkupId(true);
    menuItemButton.add(new AttributeAppender("class", "dropdown-toggle " + getAdditionalButtonClass()));
    menuItemButton.add(new AttributeAppender("style", getMenuItemButtonStyle()));
    menuItemContainer.add(menuItemButton);
    WebMarkupContainer icon = new WebMarkupContainer(ID_MENU_ITEM_ICON);
    icon.setOutputMarkupId(true);
    icon.add(new AttributeAppender("class", getIconClass()));
    menuItemButton.add(icon);
    ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, getModel()) {

        @Override
        protected void populateItem(ListItem<InlineMenuItem> item) {
            initMenuItem(item);
        }
    };
    li.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            List list = InlineMenu.this.getModel().getObject();
            return list != null && !list.isEmpty();
        }
    });
    menuItemContainer.add(li);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 65 with AjaxButton

use of com.evolveum.midpoint.web.component.AjaxButton in project midpoint by Evolveum.

the class PageDebugView method initButtons.

private void initButtons(final Form mainForm) {
    AjaxSubmitButton saveButton = new AjaxSubmitButton("saveButton", createStringResource("pageDebugView.button.save")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }
    };
    mainForm.add(saveButton);
    AjaxButton backButton = new AjaxButton("backButton", createStringResource("pageDebugView.button.back")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(backButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Form(org.apache.wicket.markup.html.form.Form)

Aggregations

AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)67 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)65 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)26 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)20 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)18 Form (org.apache.wicket.markup.html.form.Form)13 Label (org.apache.wicket.markup.html.basic.Label)12 ArrayList (java.util.ArrayList)11 List (java.util.List)10 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)7 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)7 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)7 Form (com.evolveum.midpoint.web.component.form.Form)6 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)6 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)4 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 TextArea (org.apache.wicket.markup.html.form.TextArea)4 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)3