Search in sources :

Example 16 with Component

use of org.apache.wicket.Component in project midpoint by Evolveum.

the class TaskWfChildPanel method getComponentsToUpdate.

public Collection<Component> getComponentsToUpdate() {
    TaskDto curr = parentPage.getCurrentTaskDto();
    TaskDto prev = parentPage.getPreviousTaskDto();
    boolean changesChanged = prev == null || prev.getChangesBeingApproved() == null || !prev.getChangesBeingApproved().equals(curr.getChangesBeingApproved());
    List<Component> rv = new ArrayList<>();
    if (changesChanged) {
        rv.add(get(ID_CHANGES));
    } else {
        curr.getChangesBeingApproved().applyFoldingFrom(prev.getChangesBeingApproved());
    }
    rv.add(get(ID_HISTORY));
    rv.add(get(ID_CURRENT_WORK_ITEMS_CONTAINER));
    rv.add(get(ID_RELATED_REQUESTS_CONTAINER));
    // we exclude 'show parent' link
    return rv;
}
Also used : ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)

Example 17 with Component

use of org.apache.wicket.Component in project midpoint by Evolveum.

the class TaskWfParentPanel method getComponentsToUpdate.

public Collection<Component> getComponentsToUpdate() {
    TaskDto curr = parentPage.getCurrentTaskDto();
    TaskDto prev = parentPage.getPreviousTaskDto();
    List<TaskChangesDto> prevList = prev != null ? prev.getChangesCategorizationList() : null;
    List<TaskChangesDto> currList = curr.getChangesCategorizationList();
    boolean changesChanged = prev == null || !prevList.equals(currList);
    List<Component> rv = new ArrayList<>();
    if (changesChanged) {
        rv.add(changesContainer);
    } else {
        for (int i = 0; i < currList.size(); i++) {
            currList.get(i).applyFoldingFrom(prevList.get(i));
        }
    }
    rv.add(processInstancesPanel);
    return rv;
}
Also used : ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto) TaskChangesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskChangesDto)

Example 18 with Component

use of org.apache.wicket.Component in project midpoint by Evolveum.

the class PageTaskEdit method refresh.

public void refresh(AjaxRequestTarget target) {
    TaskTabsVisibility tabsVisibilityOld = new TaskTabsVisibility();
    tabsVisibilityOld.computeAll(this);
    TaskButtonsVisibility buttonsVisibilityOld = new TaskButtonsVisibility();
    buttonsVisibilityOld.computeAll(this);
    refreshTaskModels();
    TaskTabsVisibility tabsVisibilityNew = new TaskTabsVisibility();
    tabsVisibilityNew.computeAll(this);
    TaskButtonsVisibility buttonsVisibilityNew = new TaskButtonsVisibility();
    buttonsVisibilityNew.computeAll(this);
    if (!buttonsVisibilityNew.equals(buttonsVisibilityOld)) {
        target.add(mainPanel.getButtonPanel());
    }
    if (tabsVisibilityNew.equals(tabsVisibilityOld)) {
        // soft version
        for (Component component : mainPanel.getTabPanel()) {
            if (component instanceof TaskTabPanel) {
                for (Component c : ((TaskTabPanel) component).getComponentsToUpdate()) {
                    target.add(c);
                }
            }
        }
    } else {
        // hard version
        target.add(mainPanel.getTabPanel());
    }
    target.add(getSummaryPanel());
    AutoRefreshDto refreshDto = refreshModel.getObject();
    refreshDto.recordRefreshed();
    if (isEdit() || !refreshDto.isEnabled()) {
        getRefreshPanel().stopRefreshing(this, target);
    } else {
        getRefreshPanel().startRefreshing(this, target);
    }
}
Also used : Component(org.apache.wicket.Component) AutoRefreshDto(com.evolveum.midpoint.web.component.refresh.AutoRefreshDto)

Example 19 with Component

use of org.apache.wicket.Component in project midpoint by Evolveum.

the class NavigatorPanel method changeCurrentPage.

private void changeCurrentPage(AjaxRequestTarget target, long page) {
    pageable.setCurrentPage(page);
    Component container = ((Component) pageable);
    while (container instanceof AbstractRepeater) {
        container = container.getParent();
    }
    target.add(container);
    target.add(this);
    onPageChanged(target, page);
}
Also used : Component(org.apache.wicket.Component) AbstractRepeater(org.apache.wicket.markup.repeater.AbstractRepeater)

Example 20 with Component

use of org.apache.wicket.Component 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)

Aggregations

Component (org.apache.wicket.Component)47 Label (org.apache.wicket.markup.html.basic.Label)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 FormComponent (org.apache.wicket.markup.html.form.FormComponent)12 ArrayList (java.util.ArrayList)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)9 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)7 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)5 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)4 Behavior (org.apache.wicket.behavior.Behavior)4 SimpleAttributeModifier (org.apache.wicket.behavior.SimpleAttributeModifier)4 ListView (org.apache.wicket.markup.html.list.ListView)4 Fragment (org.apache.wicket.markup.html.panel.Fragment)4 Item (org.apache.wicket.markup.repeater.Item)4 PropertyModel (org.apache.wicket.model.PropertyModel)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)3 RepositoryModel (com.gitblit.models.RepositoryModel)3 TextField (org.apache.wicket.markup.html.form.TextField)3