Search in sources :

Example 26 with AjaxLink

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

the class PageBase method initLayout.

private void initLayout() {
    WebMarkupContainer mainHeader = new WebMarkupContainer(ID_MAIN_HEADER);
    mainHeader.setOutputMarkupId(true);
    add(mainHeader);
    AjaxLink logo = new AjaxLink(ID_LOGO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            Class<? extends Page> page = MidPointApplication.get().getHomePage();
            setResponsePage(page);
        }
    };
    logo.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isCustomLogoVisible();
        }
    });
    mainHeader.add(logo);
    AjaxLink customLogo = new AjaxLink(ID_CUSTOM_LOGO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            //TODO may be this should lead to customerUrl ?
            Class<? extends Page> page = MidPointApplication.get().getHomePage();
            setResponsePage(page);
        }
    };
    customLogo.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return isCustomLogoVisible();
        }
    });
    mainHeader.add(customLogo);
    WebMarkupContainer navigation = new WebMarkupContainer(ID_NAVIGATION);
    mainHeader.add(navigation);
    WebMarkupContainer customLogoImgSrc = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_SRC);
    WebMarkupContainer customLogoImgCss = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_CSS);
    if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && deploymentInfoModel.getObject().getLogo() != null) {
        if (StringUtils.isNotEmpty(deploymentInfoModel.getObject().getLogo().getCssClass())) {
            customLogoImgCss.add(new AttributeAppender("class", deploymentInfoModel.getObject().getLogo().getCssClass()));
            customLogoImgSrc.setVisible(false);
        } else {
            customLogoImgSrc.add(new AttributeAppender("src", deploymentInfoModel.getObject().getLogo().getImageUrl()));
            customLogoImgCss.setVisible(false);
        }
        mainHeader.add(new AttributeAppender("style", "background-color: " + GuiStyleConstants.DEFAULT_BG_COLOR + "; !important;"));
    }
    customLogo.add(customLogoImgSrc);
    customLogo.add(customLogoImgCss);
    Label title = new Label(ID_TITLE, createPageTitleModel());
    title.setRenderBodyOnly(true);
    add(title);
    initHeaderLayout(navigation);
    initTitleLayout(navigation);
    if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null && StringUtils.isNotEmpty(deploymentInfoModel.getObject().getHeaderColor())) {
        logo.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        customLogo.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        mainHeader.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
        navigation.add(new AttributeAppender("style", "background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
    }
    initDebugBarLayout();
    List<SideBarMenuItem> menuItems = createMenuItems();
    SideBarMenuPanel sidebarMenu = new SideBarMenuPanel(ID_SIDEBAR_MENU, new Model((Serializable) menuItems));
    sidebarMenu.add(createUserStatusBehaviour(true));
    add(sidebarMenu);
    WebMarkupContainer footerContainer = new WebMarkupContainer(ID_FOOTER_CONTAINER);
    footerContainer.setOutputMarkupId(true);
    footerContainer.add(getFooterVisibleBehaviour());
    add(footerContainer);
    WebMarkupContainer version = new WebMarkupContainer(ID_VERSION) {

        private static final long serialVersionUID = 1L;

        @Deprecated
        public String getDescribe() {
            return PageBase.this.getDescribe();
        }
    };
    version.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return RuntimeConfigurationType.DEVELOPMENT.equals(getApplication().getConfigurationType());
        }
    });
    footerContainer.add(version);
    WebMarkupContainer copyrightMessage = new WebMarkupContainer(ID_COPYRIGHT_MESSAGE);
    copyrightMessage.add(getFooterVisibleBehaviour());
    footerContainer.add(copyrightMessage);
    Label subscriptionMessage = new Label(ID_SUBSCRIPTION_MESSAGE, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            String subscriptionId = getSubscriptionId();
            if (!WebComponentUtil.isSubscriptionIdCorrect(subscriptionId)) {
                return " " + createStringResource("PageBase.nonActiveSubscriptionMessage").getString();
            }
            if (SubscriptionType.DEMO_SUBSRIPTION.getSubscriptionType().equals(subscriptionId.substring(0, 2))) {
                return " " + createStringResource("PageBase.demoSubscriptionMessage").getString();
            }
            return "";
        }
    });
    subscriptionMessage.setOutputMarkupId(true);
    subscriptionMessage.add(getFooterVisibleBehaviour());
    footerContainer.add(subscriptionMessage);
    WebMarkupContainer feedbackContainer = new WebMarkupContainer(ID_FEEDBACK_CONTAINER);
    feedbackContainer.setOutputMarkupId(true);
    add(feedbackContainer);
    FeedbackAlerts feedbackList = new FeedbackAlerts(ID_FEEDBACK);
    feedbackList.setOutputMarkupId(true);
    feedbackContainer.add(feedbackList);
    MainPopupDialog mainPopup = new MainPopupDialog(ID_MAIN_POPUP);
    mainPopup.setOutputMarkupId(true);
    add(mainPopup);
}
Also used : Serializable(java.io.Serializable) MainPopupDialog(com.evolveum.midpoint.web.component.dialog.MainPopupDialog) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) FeedbackAlerts(com.evolveum.midpoint.web.component.message.FeedbackAlerts) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 27 with AjaxLink

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

the class SynchronizationActionEditorDialog method initButtons.

private void initButtons(Form form) {
    AjaxLink cancel = new AjaxLink(ID_BUTTON_CANCEL) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);
    AjaxSubmitLink save = new AjaxSubmitLink(ID_BUTTON_SAVE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    form.add(save);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Form(org.apache.wicket.markup.html.form.Form) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 28 with AjaxLink

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

the class ResourceDependencyEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    ListView repeater = new ListView<ResourceObjectTypeDependencyType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectTypeDependencyType> item) {
            WebMarkupContainer linkContainer = new WebMarkupContainer(ID_DEPENDENCY_LINK);
            linkContainer.setOutputMarkupId(true);
            linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkContainer);
            Label linkLabel = new Label(ID_DEPENDENCY_LINK_NAME, createDependencyLabelModel(item));
            linkContainer.add(linkLabel);
            AjaxLink delete = new AjaxLink(ID_DELETE_BUTTON) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteDependencyPerformed(target, item);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            linkContainer.add(delete);
            WebMarkupContainer dependencyBody = new WebMarkupContainer(ID_DEPENDENCY_BODY);
            dependencyBody.setOutputMarkupId(true);
            dependencyBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                dependencyBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(dependencyBody);
            TextField order = new TextField<>(ID_ORDER, new PropertyModel<Integer>(item.getModelObject(), "order"));
            order.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(order);
            dependencyBody.add(order);
            DropDownChoice strictness = new DropDownChoice<>(ID_STRICTNESS, new PropertyModel<ResourceObjectTypeDependencyStrictnessType>(item.getModelObject(), "strictness"), WebComponentUtil.createReadonlyModelFromEnum(ResourceObjectTypeDependencyStrictnessType.class), new EnumChoiceRenderer<ResourceObjectTypeDependencyStrictnessType>(this));
            strictness.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(strictness);
            dependencyBody.add(strictness);
            DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(item.getModelObject(), "kind"), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
            kind.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(kind);
            dependencyBody.add(kind);
            TextField intent = new TextField<>(ID_INTENT, new PropertyModel<String>(item.getModelObject(), "intent"));
            intent.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(intent);
            dependencyBody.add(intent);
            DropDownChoice resource = new DropDownChoice<>(ID_REF, new PropertyModel<ObjectReferenceType>(item.getModelObject(), "resourceRef"), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return WebModelServiceUtils.createObjectReferenceList(ResourceType.class, getPageBase(), resourceMap);
                }
            }, new ObjectReferenceChoiceRenderer(resourceMap));
            resource.add(prepareAjaxOnComponentTagUpdateBehavior());
            parentPage.addEditingEnabledBehavior(resource);
            dependencyBody.add(resource);
            Label orderTooltip = new Label(ID_T_ORDER);
            orderTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(orderTooltip);
            Label strictnessTooltip = new Label(ID_T_STRICTNESS);
            strictnessTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(strictnessTooltip);
            Label kindTooltip = new Label(ID_T_KIND);
            kindTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(kindTooltip);
            Label intentTooltip = new Label(ID_T_INTENT);
            intentTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(intentTooltip);
            Label resourceRefTooltip = new Label(ID_T_RESOURCE_REF);
            resourceRefTooltip.add(new InfoTooltipBehavior());
            dependencyBody.add(resourceRefTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);
    AjaxLink add = new AjaxLink(ID_ADD_BUTTON) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addDependencyPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
}
Also used : ObjectReferenceChoiceRenderer(com.evolveum.midpoint.web.component.input.ObjectReferenceChoiceRenderer) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 29 with AjaxLink

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

the class ResourceProtectedEditor method initLayout.

protected void initLayout(final PageResourceWizard parentPage) {
    WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    add(container);
    ListView repeater = new ListView<ResourceObjectPatternType>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<ResourceObjectPatternType> item) {
            WebMarkupContainer linkCont = new WebMarkupContainer(ID_ACCOUNT_LINK);
            linkCont.setOutputMarkupId(true);
            linkCont.add(new AttributeModifier("href", createCollapseItemId(item, true)));
            item.add(linkCont);
            Label accountLabel = new Label(ID_ACCOUNT_NAME, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    StringBuilder sb = new StringBuilder();
                    ResourceObjectPatternType account = item.getModelObject();
                    sb.append("#").append(item.getIndex() + 1).append(" - ");
                    if (account.getUid() != null) {
                        sb.append(account.getUid()).append(":");
                    }
                    if (account.getName() != null) {
                        sb.append(account.getName());
                    }
                    return sb.toString();
                }
            });
            linkCont.add(accountLabel);
            AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE) {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    deleteProtectedAccountPerformed(target, item);
                }
            };
            parentPage.addEditingVisibleBehavior(delete);
            linkCont.add(delete);
            WebMarkupContainer accountBody = new WebMarkupContainer(ID_ACCOUNT_BODY);
            accountBody.setOutputMarkupId(true);
            accountBody.setMarkupId(createCollapseItemId(item, false).getObject());
            if (changeState != ChangeState.SKIP) {
                accountBody.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                    @Override
                    public String getObject() {
                        if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
                            return "panel-collapse collapse in";
                        } else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
                            return "panel-collapse collapse in";
                        } else {
                            return "panel-collapse collapse";
                        }
                    }
                }));
            }
            item.add(accountBody);
            //TODO - maybe add some validator and auto-complete functionality?
            TextField name = new TextField<>(ID_NAME, new PropertyModel<String>(item.getModel(), "name"));
            name.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            parentPage.addEditingEnabledBehavior(name);
            accountBody.add(name);
            //TODO - maybe add some validator and auto-complete functionality?
            TextField uid = new TextField<>(ID_UID, new PropertyModel<String>(item.getModel(), "uid"));
            uid.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            parentPage.addEditingEnabledBehavior(uid);
            accountBody.add(uid);
            SearchFilterPanel searchFilterPanel = new SearchFilterPanel<>(ID_FILTER_EDITOR, new NonEmptyPropertyModel<SearchFilterType>(item.getModel(), "filter"), parentPage.getReadOnlyModel());
            accountBody.add(searchFilterPanel);
            Label nameTooltip = new Label(ID_T_NAME);
            nameTooltip.add(new InfoTooltipBehavior());
            accountBody.add(nameTooltip);
            Label uidTooltip = new Label(ID_T_UID);
            uidTooltip.add(new InfoTooltipBehavior());
            accountBody.add(uidTooltip);
            Label filterTooltip = new Label(ID_T_FILTER);
            filterTooltip.add(new InfoTooltipBehavior());
            accountBody.add(filterTooltip);
        }
    };
    repeater.setOutputMarkupId(true);
    container.add(repeater);
    AjaxLink add = new AjaxLink(ID_BUTTON_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addProtectedAccountPerformed(target);
        }
    };
    parentPage.addEditingVisibleBehavior(add);
    add(add);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) ResourceObjectPatternType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectPatternType) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) SearchFilterPanel(com.evolveum.midpoint.web.component.input.SearchFilterPanel) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 30 with AjaxLink

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

the class ValueChoosePanel method initLayout.

private void initLayout(final IModel<T> value, final List<PrismReferenceValue> values, final boolean required, Collection<Class<? extends O>> types) {
    WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
    textWrapper.setOutputMarkupId(true);
    TextField<String> text = new TextField<String>(ID_TEXT, createTextModel(value));
    text.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
        }
    });
    text.setRequired(required);
    text.setEnabled(false);
    textWrapper.add(text);
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
    textWrapper.add(feedback);
    AjaxLink<String> edit = new AjaxLink<String>(ID_EDIT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            editValuePerformed(values, target);
        }
    };
    textWrapper.add(edit);
    add(textWrapper);
    initButtons();
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) TextField(org.apache.wicket.markup.html.form.TextField) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)81 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)80 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)50 Label (org.apache.wicket.markup.html.basic.Label)48 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)44 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)28 ListItem (org.apache.wicket.markup.html.list.ListItem)21 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)17 ListView (org.apache.wicket.markup.html.list.ListView)17 TextField (org.apache.wicket.markup.html.form.TextField)15 ArrayList (java.util.ArrayList)13 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)13 AttributeModifier (org.apache.wicket.AttributeModifier)12 List (java.util.List)11 Form (org.apache.wicket.markup.html.form.Form)11 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)10 IModel (org.apache.wicket.model.IModel)9 Model (org.apache.wicket.model.Model)8 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)6