Search in sources :

Example 91 with AjaxRequestTarget

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

the class PageAuditLogDetails method initLayoutBackButton.

protected void initLayoutBackButton() {
    AjaxButton back = new AjaxButton(ID_BUTTON_BACK, createStringResource("PageBase.button.back")) {

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

Example 92 with AjaxRequestTarget

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

the class OrgTreePanel method initLayout.

private void initLayout() {
    WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER);
    treeHeader.setOutputMarkupId(true);
    add(treeHeader);
    String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey;
    Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title));
    treeHeader.add(treeTitle);
    InlineMenu treeMenu = new InlineMenu(ID_TREE_MENU, new Model<>((Serializable) createTreeMenuInternal()));
    treeHeader.add(treeMenu);
    ISortableTreeProvider provider = new OrgTreeProvider(this, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected List<InlineMenuItem> createInlineMenuItems(OrgType org) {
            return createTreeChildrenMenu(org);
        }
    };
    List<IColumn<SelectableBean<OrgType>, String>> columns = new ArrayList<>();
    if (selectable) {
        columns.add(new CheckBoxHeaderColumn<SelectableBean<OrgType>>());
    }
    columns.add(new TreeColumn<SelectableBean<OrgType>, String>(createStringResource("TreeTablePanel.hierarchy")));
    columns.add(new InlineMenuHeaderColumn(createTreeChildrenMenu(null)));
    WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {

        private static final long serialVersionUID = 1L;

        @Override
        public void renderHead(IHeaderResponse response) {
            super.renderHead(response);
            // method computes height based on document.innerHeight() -
            // screen height;
            Component form = OrgTreePanel.this.getParent().get("memberPanel");
            if (form != null) {
                response.render(OnDomReadyHeaderItem.forScript("updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#" + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
            }
        }
    };
    add(treeContainer);
    TreeStateModel treeStateMode = new TreeStateModel(this, provider) {

        private static final long serialVersionUID = 1L;

        @Override
        public Set<SelectableBean<OrgType>> getExpandedItems() {
            return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
        }

        @Override
        public SelectableBean<OrgType> getCollapsedItem() {
            return OrgTreePanel.this.getCollapsedItem(getOrgTreeStateStorage());
        }

        @Override
        public void setCollapsedItem(SelectableBean<OrgType> item) {
            OrgTreePanel.this.setCollapsedItem(null, getOrgTreeStateStorage());
        }
    };
    TableTree<SelectableBean<OrgType>, String> tree = new TableTree<SelectableBean<OrgType>, String>(ID_TREE, columns, provider, Integer.MAX_VALUE, treeStateMode) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Component newContentComponent(String id, IModel<SelectableBean<OrgType>> model) {
            return new SelectableFolderContent(id, this, model, selected) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClick(AjaxRequestTarget target) {
                    super.onClick(target);
                    OrgTreePanel.this.setSelectedItem(selected.getObject(), getOrgTreeStateStorage());
                    selectTreeItemPerformed(selected.getObject(), target);
                }
            };
        }

        @Override
        protected Item<SelectableBean<OrgType>> newRowItem(String id, int index, final IModel<SelectableBean<OrgType>> model) {
            Item<SelectableBean<OrgType>> item = super.newRowItem(id, index, model);
            item.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    SelectableBean<OrgType> itemObject = model.getObject();
                    if (itemObject != null && itemObject.equals(selected.getObject())) {
                        return "success";
                    }
                    return null;
                }
            }));
            return item;
        }

        @Override
        public void collapse(SelectableBean<OrgType> collapsedItem) {
            super.collapse(collapsedItem);
            Set<SelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
            if (items != null && items.contains(collapsedItem)) {
                items.remove(collapsedItem);
            }
            OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage());
            OrgTreePanel.this.setCollapsedItem(collapsedItem, getOrgTreeStateStorage());
        }

        @Override
        protected void onModelChanged() {
            super.onModelChanged();
            TreeStateSet<SelectableBean<OrgType>> items = (TreeStateSet) getModelObject();
            if (!items.isInverse()) {
                OrgTreePanel.this.setExpandedItems(items, getOrgTreeStateStorage());
            }
        }
    };
    tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
    tree.getTable().add(AttributeModifier.replace("class", "table table-striped table-condensed"));
    tree.add(new WindowsTheme());
    // tree.add(AttributeModifier.replace("class", "tree-midpoint"));
    treeContainer.add(tree);
}
Also used : AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Serializable(java.io.Serializable) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) TableTree(org.apache.wicket.extensions.markup.html.repeater.tree.TableTree) Label(org.apache.wicket.markup.html.basic.Label) WindowsTheme(org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ReuseIfModelsEqualStrategy(org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy) InlineMenu(com.evolveum.midpoint.web.component.menu.cog.InlineMenu) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) OrgTreeProvider(com.evolveum.midpoint.web.page.admin.users.component.OrgTreeProvider) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IHeaderResponse(org.apache.wicket.markup.head.IHeaderResponse) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) SelectableFolderContent(com.evolveum.midpoint.web.page.admin.users.component.SelectableFolderContent) TreeStateSet(com.evolveum.midpoint.web.page.admin.users.dto.TreeStateSet) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) ISortableTreeProvider(org.apache.wicket.extensions.markup.html.repeater.tree.ISortableTreeProvider) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)

Example 93 with AjaxRequestTarget

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

the class PageReports method initColumns.

private List<IColumn<ReportType, String>> initColumns() {
    List<IColumn<ReportType, String>> columns = new ArrayList<IColumn<ReportType, String>>();
    IColumn column;
    column = new LinkColumn<SelectableBean<ReportType>>(createStringResource("PageReports.table.name"), ReportType.F_NAME.getLocalPart(), "value.name") {

        @Override
        public void onClick(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> rowModel) {
            ReportType report = rowModel.getObject().getValue();
            if (report != null) {
                reportTypeFilterPerformed(target, report.getOid());
            }
        }

        @Override
        public boolean isEnabled(IModel<SelectableBean<ReportType>> rowModel) {
            return rowModel.getObject().getValue() != null && rowModel.getObject().getValue().isParent();
        }
    };
    columns.add(column);
    column = new PropertyColumn(createStringResource("PageReports.table.description"), "value.description");
    columns.add(column);
    column = new DoubleButtonColumn<SelectableBean<ReportType>>(new Model(), null) {

        @Override
        public String getFirstCap() {
            return PageReports.this.createStringResource("PageReports.button.run").getString();
        }

        @Override
        public String getSecondCap() {
            return PageReports.this.createStringResource("PageReports.button.configure").getString();
        }

        @Override
        public String getFirstColorCssClass() {
            if (getRowModel().getObject().getValue() != null && getRowModel().getObject().getValue().isParent()) {
                return BUTTON_COLOR_CLASS.PRIMARY.toString();
            } else {
                return BUTTON_COLOR_CLASS.PRIMARY.toString() + " " + BUTTON_DISABLED;
            }
        }

        @Override
        public void firstClicked(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> model) {
            runReportPerformed(target, model.getObject().getValue());
        }

        @Override
        public void secondClicked(AjaxRequestTarget target, IModel<SelectableBean<ReportType>> model) {
            configurePerformed(target, model.getObject().getValue());
        }

        @Override
        public boolean isFirstButtonEnabled(IModel<SelectableBean<ReportType>> rowModel) {
            return getRowModel().getObject().getValue() != null && rowModel.getObject().getValue().isParent();
        }
    };
    columns.add(column);
    return columns;
}
Also used : PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 94 with AjaxRequestTarget

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

the class RunReportPopupPanel method createInputMarkup.

private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
    param.setEditing(true);
    WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
    paramValueMarkup.setOutputMarkupId(true);
    InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
    paramValueMarkup.add(input);
    //buttons
    AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValue(paramValueMarkup, param, target);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible(param);
        }
    });
    paramValueMarkup.add(addButton);
    AjaxLink<String> removeButton = new AjaxLink<String>(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValue(paramValueMarkup, param, valueModel.getObject(), target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    paramValueMarkup.add(removeButton);
    return paramValueMarkup;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 95 with AjaxRequestTarget

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

the class PageReports method runReportPerformed.

protected void runReportPerformed(AjaxRequestTarget target, ReportType report) {
    RunReportPopupPanel runReportPopupPanel = new RunReportPopupPanel(getMainPopupBodyId(), report) {

        private static final long serialVersionUID = 1L;

        protected void runConfirmPerformed(AjaxRequestTarget target, ReportType reportType, PrismContainer<ReportParameterType> reportParam) {
            OperationResult result = new OperationResult(OPERATION_RUN_REPORT);
            try {
                Task task = createSimpleTask(OPERATION_RUN_REPORT);
                getReportManager().runReport(reportType.asPrismObject(), reportParam, task, result);
            } catch (Exception ex) {
                result.recordFatalError(ex);
            } finally {
                result.computeStatusIfUnknown();
            }
            showResult(result);
            target.add(getFeedbackPanel(), get(createComponentPath(ID_MAIN_FORM)));
            hideMainPopup(target);
        }

        ;
    };
    showMainPopup(runReportPopupPanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Task(com.evolveum.midpoint.task.api.Task) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RunReportPopupPanel(com.evolveum.midpoint.web.page.admin.reports.component.RunReportPopupPanel) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)393 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)108 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)105 ArrayList (java.util.ArrayList)91 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)82 Form (org.apache.wicket.markup.html.form.Form)78 IModel (org.apache.wicket.model.IModel)73 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)71 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)56 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 ListItem (org.apache.wicket.markup.html.list.ListItem)43 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)34 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 ListView (org.apache.wicket.markup.html.list.ListView)32 TextField (org.apache.wicket.markup.html.form.TextField)30