Search in sources :

Example 1 with AjaxEventBehavior

use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.

the class InfoBoxPanel method initLayout.

private void initLayout(final IModel<InfoBoxType> model, final Class<? extends IRequestablePage> linkPage) {
    WebMarkupContainer infoBox = new WebMarkupContainer(ID_INFO_BOX);
    add(infoBox);
    infoBox.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.BOX_BACKGROUND_COLOR)));
    WebMarkupContainer infoBoxIcon = new WebMarkupContainer(ID_INFO_BOX_ICON);
    infoBox.add(infoBoxIcon);
    infoBoxIcon.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.ICON_BACKGROUND_COLOR)));
    WebMarkupContainer image = new WebMarkupContainer(ID_IMAGE_ID);
    image.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.IMAGE_ID)));
    infoBoxIcon.add(image);
    Label message = new Label(ID_MESSAGE, new PropertyModel<String>(model, InfoBoxType.MESSAGE));
    infoBox.add(message);
    Label number = new Label(ID_NUMBER, new PropertyModel<String>(model, InfoBoxType.NUMBER));
    infoBox.add(number);
    WebMarkupContainer progress = new WebMarkupContainer(ID_PROGRESS);
    infoBox.add(progress);
    progress.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return model.getObject().getProgress() != null;
        }
    });
    ProgressbarPanel progressBar = new ProgressbarPanel(ID_PROGRESS_BAR, new PropertyModel<Integer>(model, InfoBoxType.PROGRESS));
    progress.add(progressBar);
    Label description = new Label(ID_DESCRIPTION, new PropertyModel<String>(model, InfoBoxType.DESCRIPTION));
    infoBox.add(description);
    if (linkPage != null) {
        add(new AjaxEventBehavior("click") {

            private static final long serialVersionUID = 1L;

            @Override
            protected void onEvent(AjaxRequestTarget target) {
                setResponsePage(linkPage);
            }
        });
    }
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ProgressbarPanel(com.evolveum.midpoint.gui.api.component.progressbar.ProgressbarPanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 2 with AjaxEventBehavior

use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.

the class ChangePasswordPanel method initColumns.

private List<IColumn<PasswordAccountDto, String>> initColumns() {
    List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<IColumn<PasswordAccountDto, String>>();
    IColumn column = new IconColumn<PasswordAccountDto>(new Model<String>()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createIconModel(final IModel<PasswordAccountDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    PasswordAccountDto item = rowModel.getObject();
                    if (item.getCssClass() == null || item.getCssClass().trim().equals("")) {
                        if (item.isMidpoint()) {
                            item.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (item.isPasswordOutbound()) {
                            item.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else {
                            item.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        }
                    }
                    return item.getCssClass();
                }
            };
        }

        @Override
        public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            final ImagePanel imagePanel = (ImagePanel) item.get(0);
            final PasswordAccountDto passwordAccountDto = rowModel.getObject();
            imagePanel.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                protected void onEvent(final AjaxRequestTarget target) {
                    if (!passwordAccountDto.isMidpoint()) {
                        if (passwordAccountDto.getCssClass().equals(PROPAGATED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS) && passwordAccountDto.isPasswordOutbound() && midpointAccountSelected) {
                            passwordAccountDto.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                        }
                        target.add(imagePanel);
                    } else {
                        midpointAccountSelected = !midpointAccountSelected;
                        if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(DESELECTED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        } else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
                            passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
                            updatePropagatedAccountIconsCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
                            target.add(imagePanel.findParent(SelectableDataTable.class));
                        }
                    }
                }
            });
        }
    };
    columns.add(column);
    columns.add(new AbstractColumn<PasswordAccountDto, String>(createStringResource("ChangePasswordPanel.name")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Object getObject() {
                    PasswordAccountDto dto = rowModel.getObject();
                    return dto.getDisplayName();
                }
            }));
        }
    });
    column = new PropertyColumn(createStringResource("ChangePasswordPanel.resourceName"), PasswordAccountDto.F_RESOURCE_NAME);
    columns.add(column);
    CheckBoxColumn enabled = new CheckBoxColumn(createStringResource("ChangePasswordPanel.enabled"), PasswordAccountDto.F_ENABLED);
    enabled.setEnabled(false);
    columns.add(enabled);
    return columns;
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) Item(org.apache.wicket.markup.repeater.Item) IconColumn(com.evolveum.midpoint.web.component.data.column.IconColumn) PasswordAccountDto(com.evolveum.midpoint.web.page.admin.home.dto.PasswordAccountDto) IModel(org.apache.wicket.model.IModel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) CheckBoxColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableDataTable(com.evolveum.midpoint.web.component.data.SelectableDataTable) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ImagePanel(com.evolveum.midpoint.web.component.data.column.ImagePanel)

Example 3 with AjaxEventBehavior

use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.

the class AbstractOrgTabPanel method initLayout.

private void initLayout() {
    final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<ITab> load() {
            LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
            roots = loadOrgRoots();
            final List<ITab> tabs = new ArrayList<>();
            for (PrismObject<OrgType> root : roots) {
                final String oid = root.getOid();
                tabs.add(new AbstractTab(createTabTitle(root)) {

                    private static final long serialVersionUID = 1L;

                    private int tabId = tabs.size();

                    @Override
                    public WebMarkupContainer getPanel(String panelId) {
                        add(new AjaxEventBehavior("load") {

                            private static final long serialVersionUID = 1L;

                            protected void onEvent(final AjaxRequestTarget target) {
                                SessionStorage storage = getPageBase().getSessionStorage();
                                storage.getUsers().setSelectedTabId(tabId);
                            }
                        });
                        Panel panel = createTreePanel(panelId, new Model(oid), getPageBase());
                        panel.setOutputMarkupId(true);
                        return panel;
                    }
                });
            }
            LOGGER.debug("Tab count is {}", new Object[] { tabs.size() });
            return tabs;
        }
    };
    final SessionStorage storage = getPageBase().getSessionStorage();
    int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
    List<ITab> tabsList = tabModel.getObject();
    if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
        storage.getUsers().setSelectedTabId(0);
        selectedTab = 0;
    }
    AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<ITab>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {

        private static final long serialVersionUID = 1L;

        @Override
        public TabbedPanel<ITab> setSelectedTab(int index) {
            changeTabPerformed(index);
            return super.setSelectedTab(index);
        }
    };
    tabbedPanel.setOutputMarkupId(true);
    if (tabsList == null || tabsList.size() == 0) {
        tabbedPanel.setVisible(false);
    }
    add(tabbedPanel);
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) ArrayList(java.util.ArrayList) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) TabbedPanel(com.evolveum.midpoint.web.component.TabbedPanel) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ArrayList(java.util.ArrayList) List(java.util.List) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage)

Example 4 with AjaxEventBehavior

use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.

the class PageAuditLogDetails method initAuditLogHistoryPanel.

private void initAuditLogHistoryPanel(WebMarkupContainer eventPanel) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(PageAuditLogDetails.this) {

        private static final long serialVersionUID = 1L;

        public Map<String, Object> getParameters() {
            Map<String, Object> parameters = new HashMap<String, Object>();
            parameters.put(TASK_IDENTIFIER_PARAMETER, recordModel.getObject().getTaskIdentifier());
            return parameters;
        }
    };
    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_HISTORY_PANEL, provider, initColumns(), UserProfileStorage.TableId.TASK_EVENTS_TABLE, TASK_EVENTS_TABLE_SIZE) {

        @Override
        protected Item<AuditEventRecordType> customizeNewRowItem(final Item<AuditEventRecordType> item, final IModel<AuditEventRecordType> rowModel) {
            if (rowModel.getObject().getTimestamp().equals(recordModel.getObject().getTimestamp())) {
                item.add(new AttributeAppender("style", "background-color: #eee; border-color: #d6d6d6; color: #000"));
            }
            item.add(new AjaxEventBehavior("click") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    PageAuditLogDetails.this.rowItemClickPerformed(target, item, rowModel);
                }
            });
            return item;
        }
    };
    table.getFooterMenu().setVisible(false);
    table.getFooterCountLabel().setVisible(false);
    //TODO hidden temporarily
    table.setVisible(false);
    table.setOutputMarkupId(true);
    table.setAdditionalBoxCssClasses("without-box-header-top-border");
    eventPanel.addOrReplace(table);
}
Also used : IModel(org.apache.wicket.model.IModel) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem) Item(org.apache.wicket.markup.repeater.Item) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 IModel (org.apache.wicket.model.IModel)3 ArrayList (java.util.ArrayList)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 Label (org.apache.wicket.markup.html.basic.Label)2 Item (org.apache.wicket.markup.repeater.Item)2 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 ProgressbarPanel (com.evolveum.midpoint.gui.api.component.progressbar.ProgressbarPanel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 AjaxTabbedPanel (com.evolveum.midpoint.web.component.AjaxTabbedPanel)1 TabbedPanel (com.evolveum.midpoint.web.component.TabbedPanel)1 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)1 SelectableDataTable (com.evolveum.midpoint.web.component.data.SelectableDataTable)1 CheckBoxColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxColumn)1 IconColumn (com.evolveum.midpoint.web.component.data.column.IconColumn)1 ImagePanel (com.evolveum.midpoint.web.component.data.column.ImagePanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1