Search in sources :

Example 1 with ComponentTag

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

the class MultipleAssignmentSelector method createRowLink.

private Component createRowLink(String id, final IModel<SelectableBean<AssignmentEditorDto>> rowModel) {
    AjaxLink<SelectableBean<AssignmentEditorDto>> button = new AjaxLink<SelectableBean<AssignmentEditorDto>>(id, rowModel) {

        @Override
        public IModel<?> getBody() {
            AssignmentEditorDto dto = (AssignmentEditorDto) rowModel.getObject();
            String name = StringUtils.isNotEmpty(dto.getNameForTargetObject()) ? dto.getNameForTargetObject() : dto.getName();
            return new Model<>(name);
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            LOGGER.trace("{} CLICK: {}", this, rowModel.getObject());
            toggleRow(rowModel);
            target.add(this);
        }

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            if (rowModel.getObject().isSelected()) {
                tag.put("class", "list-group-item active");
                tag.put("style", "background-color: #eee; border-color: #d6d6d6; color: #000;");
            } else {
                tag.put("class", "list-group-item");
            }
            String description = ((AssignmentEditorDto) rowModel.getObject()).getDescription();
            if (description != null) {
                tag.put("title", description);
            }
        }
    };
    button.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ((AssignmentEditorDto) rowModel.getObject()).getStatus() != UserDtoStatus.DELETE;
        }
    });
    button.setOutputMarkupId(true);
    return button;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with ComponentTag

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

the class TableHeadersToolbar method newSortableHeader.

@Override
protected WebMarkupContainer newSortableHeader(String headerId, final String property, final ISortStateLocator locator) {
    return new AjaxFallbackOrderByBorder(headerId, property, locator) {

        @Override
        protected void onSortChanged() {
            getTable().setCurrentPage(0);
        }

        @Override
        protected void onAjaxClick(AjaxRequestTarget target) {
            target.add(getTable());
        }

        @Override
        public void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            ISortState sortState = locator.getSortState();
            SortOrder dir = sortState.getPropertySortOrder(property);
            String cssClass;
            if (dir == SortOrder.ASCENDING) {
                cssClass = "sortable asc";
            } else if (dir == SortOrder.DESCENDING) {
                cssClass = "sortable desc";
            } else {
                cssClass = "sortable";
            }
            if (!Strings.isEmpty(cssClass)) {
                tag.append("class", cssClass, " ");
            }
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) SortOrder(org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder) AjaxFallbackOrderByBorder(org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder) ISortState(org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)

Example 3 with ComponentTag

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

the class DashboardSearchPanel method initLayout.

@Override
protected void initLayout() {
    final Form searchForm = new Form(ID_SEARCH_FORM);
    add(searchForm);
    searchForm.setOutputMarkupId(true);
    final List<String> accessibleSearchTypes = new ArrayList<>();
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_USERS_ALL_URL, AuthorizationConstants.AUTZ_UI_USERS_URL)) {
        accessibleSearchTypes.add(SEARCH_TYPES.get(USER_INDEX));
    }
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_RESOURCES_ALL_URL, AuthorizationConstants.AUTZ_UI_RESOURCES_URL)) {
        accessibleSearchTypes.add(SEARCH_TYPES.get(RESOURCE_INDEX));
    }
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_TASKS_ALL_URL, AuthorizationConstants.AUTZ_UI_TASKS_URL)) {
        accessibleSearchTypes.add(SEARCH_TYPES.get(TASK_INDEX));
    }
    if (accessibleSearchTypes.size() == 0) {
        searchForm.setVisible(false);
    } else {
        final TextField searchInput = new TextField(ID_SEARCH_INPUT, Model.of("")) {

            @Override
            protected void onComponentTag(final ComponentTag tag) {
                super.onComponentTag(tag);
                tag.put("placeholder", createStringResource("SearchPanel.searchByName").getString());
            }
        };
        searchForm.add(searchInput);
        final Label buttonLabel = new Label(ID_BUTTON_LABEL, new Model<String>() {

            public String getObject() {
                return accessibleSearchTypes.get(selectedSearchType);
            }
        });
        buttonLabel.setOutputMarkupId(true);
        final AjaxSubmitLink searchButton = new AjaxSubmitLink(ID_SEARCH_BUTTON) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
                String searchType = buttonLabel.getDefaultModel().getObject().toString();
                String searchText = searchInput.getValue();
                performSearch(searchType, searchText == null ? "" : searchText);
            }
        };
        searchButton.setOutputMarkupId(true);
        searchButton.add(buttonLabel);
        searchForm.add(searchButton);
        searchForm.setDefaultButton(searchButton);
        //            final WebMarkupContainer list = new WebMarkupContainer(ID_SEARCH_TYPES);
        //            list.setOutputMarkupId(true);
        ListView<String> li = new ListView<String>(ID_SEARCH_TYPES, new IModel<List<String>>() {

            @Override
            public void detach() {
            }

            @Override
            public List<String> getObject() {
                return accessibleSearchTypes;
            }

            @Override
            public void setObject(List<String> list) {
            }
        }) {

            @Override
            protected void populateItem(final ListItem<String> item) {
                final AjaxLink searchTypeLink = new AjaxLink(ID_SEARCH_TYPE_ITEM) {

                    @Override
                    public IModel<?> getBody() {
                        return new Model<String>(item.getModel().getObject());
                    }

                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        selectedSearchType = accessibleSearchTypes.indexOf(item.getModelObject());
                        target.add(DashboardSearchPanel.this.get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_BUTTON)));
                    }

                    @Override
                    protected void onComponentTag(final ComponentTag tag) {
                        super.onComponentTag(tag);
                        tag.put("value", item.getModelObject());
                    }
                };
                searchTypeLink.setOutputMarkupId(true);
                item.add(searchTypeLink);
            }
        };
        li.setOutputMarkupId(true);
        searchForm.add(li);
    //            final RepeatingView searchTypes = new RepeatingView(ID_SEARCH_TYPE_ITEM);
    //            searchTypes.setOutputMarkupId(true);
    //            if (accessibleSearchTypes.size() > 1) {
    //                for (int i = 0; i < accessibleSearchTypes.size(); i++) {
    //                    if (i == selectedSearchType){
    //                        continue;
    //                    }
    //                    final String searchTypeItem = accessibleSearchTypes.get(i);
    //                    final AjaxSubmitLink searchTypeLink = new AjaxSubmitLink(searchTypes.newChildId()) {
    //                        @Override
    //                        public void onSubmit(AjaxRequestTarget target, Form<?> form) {
    //                                selectedSearchType = accessibleSearchTypes.indexOf(searchTypeItem);
    //                                target.add(DashboardSearchPanel.this.get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_BUTTON)));
    //                                target.add(DashboardSearchPanel.this.get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_TYPES)));
    ////                                target.add(DashboardSearchPanel.this.get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_TYPES, ID_SEARCH_TYPE_ITEM)));
    //                        }
    //
    //                        @Override
    //                        protected void onComponentTag(final ComponentTag tag) {
    //                            super.onComponentTag(tag);
    //                            tag.put("value", searchTypeItem);
    //                        }
    //
    //                    };
    //                    searchTypeLink.setOutputMarkupId(true);
    //                    Label linkLabel = new Label(ID_LINK_LABEL, new Model<String>() {
    //                        public String getObject() {
    //                            return searchTypeItem;
    //                        }
    //                    });
    //                    linkLabel.setOutputMarkupId(true);
    //                    searchTypeLink.add(linkLabel);
    //                    searchTypes.add(searchTypeLink);
    //                }
    //            }
    //            list.add(searchTypes);
    //            if (accessibleSearchTypes.size() == 1){
    //                list.setVisible(false);
    //            }
    //            searchForm.add(list);
    }
}
Also used : Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListView(org.apache.wicket.markup.html.list.ListView) ComponentTag(org.apache.wicket.markup.ComponentTag) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) TextField(org.apache.wicket.markup.html.form.TextField) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 4 with ComponentTag

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

the class LinksPanel method initLayout.

@Override
protected void initLayout() {
    final List<RichHyperlinkType> linksList = getModel().getObject();
    RepeatingView rowView = new RepeatingView(ID_LINKS_ROW);
    int linksListSize = linksList == null ? 0 : linksList.size();
    if (linksListSize > 0) {
        int currentColumn = 0;
        RepeatingView columnView = null;
        WebMarkupContainer row = null;
        boolean isRowAdded = false;
        for (int i = 0; i < linksListSize; i++) {
            final RichHyperlinkType link = linksList.get(i);
            if (WebComponentUtil.isAuthorized(link.getAuthorization())) {
                if (currentColumn == 0) {
                    row = new WebMarkupContainer(rowView.newChildId());
                    isRowAdded = false;
                    columnView = new RepeatingView(ID_LINKS_COLUMN);
                }
                WebMarkupContainer column = new WebMarkupContainer(columnView.newChildId());
                Link linkItem = new Link(ID_LINK) {

                    @Override
                    public void onClick() {
                    }

                    @Override
                    protected void onComponentTag(final ComponentTag tag) {
                        super.onComponentTag(tag);
                        String rootContext = "";
                        //TODO: what is this for???
                        if (link.getTargetUrl() != null && !link.getTargetUrl().startsWith("http://") && !link.getTargetUrl().startsWith("https://") && !link.getTargetUrl().startsWith("www://") && !link.getTargetUrl().startsWith("//")) {
                            WebApplication webApplication = WebApplication.get();
                            if (webApplication != null) {
                                ServletContext servletContext = webApplication.getServletContext();
                                if (servletContext != null) {
                                    rootContext = servletContext.getContextPath();
                                }
                            }
                        }
                        tag.put("href", rootContext + (link.getTargetUrl() == null ? "#" : link.getTargetUrl()));
                    }
                };
                linkItem.add(new Label(ID_IMAGE) {

                    @Override
                    protected void onComponentTag(final ComponentTag tag) {
                        super.onComponentTag(tag);
                        String cssClass = ICON_DEFAULT_CSS_CLASS;
                        if (link.getIcon() != null) {
                            cssClass = link.getIcon().getCssClass();
                        }
                        tag.put("class", "info-box-icon " + (link.getColor() != null ? (link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " " + cssClass);
                    }
                });
                linkItem.add(new Label(ID_LABEL, new Model<String>() {

                    public String getObject() {
                        return link.getLabel();
                    }
                }));
                Label description = new Label(ID_DESCRIPTION, new Model<String>() {

                    public String getObject() {
                        return link.getDescription();
                    }
                });
                description.setEnabled(false);
                linkItem.add(description);
                column.add(linkItem);
                columnView.add(column);
                if (currentColumn == 1 || (linksList.indexOf(link) == linksListSize - 1)) {
                    row.add(columnView);
                    rowView.add(row);
                    currentColumn = 0;
                    isRowAdded = true;
                } else {
                    currentColumn++;
                }
            } else {
                LOGGER.trace("Link {} not authorized, skipping", link);
            }
        }
        if (row != null && columnView != null && !isRowAdded) {
            row.add(columnView);
            rowView.add(row);
        }
    }
    add(rowView);
}
Also used : RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ComponentTag(org.apache.wicket.markup.ComponentTag) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) ServletContext(javax.servlet.ServletContext) WebApplication(org.apache.wicket.protocol.http.WebApplication) Link(org.apache.wicket.markup.html.link.Link)

Example 5 with ComponentTag

use of org.apache.wicket.markup.ComponentTag in project ocvn by devgateway.

the class BasePage method newAdminMenu.

protected NavbarDropDownButton newAdminMenu() {
    // admin menu
    NavbarDropDownButton adminMenu = new NavbarDropDownButton(new StringResourceModel("navbar.admin", this, null)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<AbstractLink> newSubMenuButtons(final String arg0) {
            List<AbstractLink> list = new ArrayList<>();
            list.add(new MenuBookmarkablePageLink<ListGroupPage>(ListGroupPage.class, null, new StringResourceModel("navbar.groups", this, null)).setIconType(FontAwesomeIconType.tags));
            // list.add(new
            // MenuBookmarkablePageLink<ListTestFormPage>(ListTestFormPage.class,
            // null,
            // new StringResourceModel("navbar.testcomponents", this, null))
            // .setIconType(FontAwesomeIconType.android));
            list.add(new MenuBookmarkablePageLink<ListVietnamImportSourceFiles>(ListVietnamImportSourceFiles.class, null, new StringResourceModel("navbar.importfiles", this, null)).setIconType(FontAwesomeIconType.file_archive_o));
            list.add(new MenuBookmarkablePageLink<VietnamImportPage>(VietnamImportPage.class, null, new StringResourceModel("navbar.import", this, null)).setIconType(FontAwesomeIconType.cloud_upload));
            list.add(new MenuBookmarkablePageLink<ListUserPage>(ListUserPage.class, null, new StringResourceModel("navbar.users", this, null)).setIconType(FontAwesomeIconType.users));
            list.add(new MenuBookmarkablePageLink<SpringEndpointsPage>(SpringEndpointsPage.class, null, new StringResourceModel("navbar.springendpoints", this, null)).setIconType(FontAwesomeIconType.anchor));
            list.add(new MenuBookmarkablePageLink<JminixRedirectPage>(JminixRedirectPage.class, null, new StringResourceModel("navbar.jminix", this, null)).setIconType(FontAwesomeIconType.bug));
            // MenuBookmarkablePageLink<HALRedirectPage> halBrowserLink =
            // new MenuBookmarkablePageLink<HALRedirectPage>(
            // HALRedirectPage.class, null, new StringResourceModel(
            // "navbar.halbrowser", this, null)) {
            // private static final long serialVersionUID = 1L;
            //
            // @Override
            // protected void onComponentTag(ComponentTag tag) {
            // super.onComponentTag(tag);
            // tag.put("target", "_blank");
            // }
            // };
            // halBrowserLink.setIconType(FontAwesomeIconType.rss).setEnabled(true);
            // list.add(halBrowserLink);
            MenuBookmarkablePageLink<UIRedirectPage> uiBrowserLink = new MenuBookmarkablePageLink<UIRedirectPage>(UIRedirectPage.class, null, new StringResourceModel("navbar.ui", this, null)) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("target", "_blank");
                }
            };
            uiBrowserLink.setIconType(FontAwesomeIconType.dashboard).setEnabled(true);
            list.add(new MenuBookmarkablePageLink<Void>(EditAdminSettingsPage.class, new StringResourceModel("navbar.adminSettings", BasePage.this, null)).setIconType(FontAwesomeIconType.briefcase));
            list.add(new MenuBookmarkablePageLink<Void>(ListAllDashboardsPage.class, new StringResourceModel("navbar.allDashboard", BasePage.this, null)).setIconType(FontAwesomeIconType.filter));
            list.add(uiBrowserLink);
            return list;
        }
    };
    adminMenu.setIconType(GlyphIconType.cog);
    MetaDataRoleAuthorizationStrategy.authorize(adminMenu, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
    return adminMenu;
}
Also used : NavbarDropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton) ComponentTag(org.apache.wicket.markup.ComponentTag) ArrayList(java.util.ArrayList) MenuBookmarkablePageLink(de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

ComponentTag (org.apache.wicket.markup.ComponentTag)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 IModel (org.apache.wicket.model.IModel)3 Model (org.apache.wicket.model.Model)3 ArrayList (java.util.ArrayList)2 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)2 Label (org.apache.wicket.markup.html.basic.Label)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 MenuBookmarkablePageLink (de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.MenuBookmarkablePageLink)1 NavbarDropDownButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarDropDownButton)1 List (java.util.List)1 ServletContext (javax.servlet.ServletContext)1 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)1 AjaxFallbackOrderByBorder (org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByBorder)1 ISortState (org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortState)1 SortOrder (org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Form (org.apache.wicket.markup.html.form.Form)1