Search in sources :

Example 11 with AttributeAppender

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

the class MultiButtonPanel method initLayout.

protected void initLayout() {
    RepeatingView buttons = new RepeatingView(ID_BUTTONS);
    add(buttons);
    for (int id = 0; id < numberOfButtons; id++) {
        final int finalId = getButtonId(id);
        AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
            }

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);
                attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
            }

            @Override
            public boolean isEnabled() {
                return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
            }

            @Override
            public boolean isVisible() {
                return MultiButtonPanel.this.isButtonVisible(finalId, MultiButtonPanel.this.getModel());
            }
        };
        button.add(new AttributeAppender("class", getButtonCssClass(finalId)));
        button.add(new AttributeAppender("title", getButtonTitle(finalId)));
        buttons.add(button);
        buttons.add(new Label("label" + finalId, " "));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 12 with AttributeAppender

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

the class TargetUserSelectorComponent method initLayout.

private void initLayout() {
    AjaxLink<String> targetUserButton = new AjaxLink<String>(ID_TARGET_USER_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (showUserSelectionPopup) {
                initUserSelectionPopup(createStringResource("AssignmentCatalogPanel.selectTargetUser"), true, target);
            }
            showUserSelectionPopup = true;
        }
    };
    targetUserButton.add(new AttributeAppender("class", "btn btn-default" + (StringUtils.isEmpty(additionalButtonStyle) ? "" : " " + additionalButtonStyle)));
    targetUserButton.setOutputMarkupId(true);
    targetUserButton.add(new AttributeAppender("title", getTargetUsersButtonTitle()));
    add(targetUserButton);
    Label label = new Label(ID_TARGET_USER_LABEL, createStringResource("AssignmentCatalogPanel.selectTargetUser"));
    label.setRenderBodyOnly(true);
    targetUserButton.add(label);
    AjaxLink deleteButton = new AjaxLink(ID_DELETE_TARGET_USER_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            showUserSelectionPopup = false;
            getRoleCatalogStorage().setTargetUserList(null);
            target.add(pageBase);
        }
    };
    deleteButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getRoleCatalogStorage().getTargetUserList() != null && getRoleCatalogStorage().getTargetUserList().size() > 0;
        }
    });
    targetUserButton.add(deleteButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 13 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender 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 14 with AttributeAppender

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

the class ProcessInstancesPanel method initLayout.

private void initLayout(UserProfileStorage.TableId tableId, int pageSize, View view, final IModel<String> currentInstanceIdModel) {
    BoxedTablePanel<ProcessInstanceDto> table = new BoxedTablePanel<ProcessInstanceDto>(ID_REQUESTS_TABLE, provider, initColumns(view), tableId, pageSize) {

        @Override
        protected Item<ProcessInstanceDto> customizeNewRowItem(Item<ProcessInstanceDto> item, final IModel<ProcessInstanceDto> rowModel) {
            item.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (currentInstanceIdModel == null || currentInstanceIdModel.getObject() == null) {
                        return "";
                    }
                    ProcessInstanceDto rowDto = rowModel.getObject();
                    if (currentInstanceIdModel.getObject().equals(rowDto.getProcessInstanceId())) {
                        return "info";
                    } else {
                        return "";
                    }
                }
            }));
            return item;
        }
    };
    table.setOutputMarkupId(true);
    table.setAdditionalBoxCssClasses("without-box-header-top-border");
    add(table);
}
Also used : Item(org.apache.wicket.markup.repeater.Item) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IModel(org.apache.wicket.model.IModel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 15 with AttributeAppender

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

the class OrgUnitAddDeletePopup method initLayout.

public void initLayout(WebMarkupContainer content) {
    List<IColumn<SelectableBean<ObjectType>, String>> columns = initColumns();
    ObjectDataProvider provider = new ObjectDataProvider(getPageBase(), OrgType.class);
    provider.setQuery(getDataProviderQuery());
    TablePanel table = new TablePanel<SelectableBean<ObjectType>>(ID_TABLE, provider, columns);
    table.setOutputMarkupId(true);
    content.add(table);
    AjaxButton cancelButton = new AjaxButton(ID_BUTTON_CANCEL, createStringResource("orgUnitAddDeletePopup.button.cancel")) {

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            cancelPerformed(ajaxRequestTarget);
        }
    };
    content.add(cancelButton);
    AjaxButton actionButton = new AjaxButton(ID_BUTTON_ACTION, createActionButtonStringResource()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            actionPerformed(target);
        }
    };
    actionButton.add(new AttributeAppender("class", getActionButtonClass()));
    content.add(actionButton);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

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