Search in sources :

Example 1 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.

the class ObjectListPanel method createTable.

private BoxedTablePanel<SelectableBean<O>> createTable() {
    List<IColumn<SelectableBean<O>, String>> columns;
    if (isCustomColumnsListConfigured()) {
        columns = initCustomColumns();
    } else {
        columns = initColumns();
    }
    BaseSortableDataProvider<SelectableBean<O>> provider = initProvider();
    BoxedTablePanel<SelectableBean<O>> table = new BoxedTablePanel<SelectableBean<O>>(ID_TABLE, provider, columns, tableId, tableId == null ? 10 : parentPage.getSessionStorage().getUserProfile().getPagingSize(tableId)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createHeader(String headerId) {
            return initSearch(headerId);
        }

        @Override
        public String getAdditionalBoxCssClasses() {
            return ObjectListPanel.this.getAdditionalBoxCssClasses();
        }

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            WebMarkupContainer bar = ObjectListPanel.this.createTableButtonToolbar(id);
            return bar != null ? bar : super.createButtonToolbar(id);
        }
    };
    table.setOutputMarkupId(true);
    String storageKey = getStorageKey();
    if (StringUtils.isNotEmpty(storageKey)) {
        PageStorage storage = getPageStorage(storageKey);
        if (storage != null) {
            table.setCurrentPage(storage.getPaging());
        }
    }
    return table;
}
Also used : IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 2 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.

the class TreeTablePanel method moveRootPerformed.

private void moveRootPerformed(SelectableBean<OrgType> root, AjaxRequestTarget target) {
    if (root == null) {
        root = getTreePanel().getRootFromProvider();
    }
    final SelectableBean<OrgType> orgToMove = root;
    OrgTreeAssignablePanel orgAssignablePanel = new OrgTreeAssignablePanel(parentPage.getMainPopupBodyId(), false, parentPage) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onItemSelect(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
            moveConfirmPerformed(orgToMove, selected, target);
        }
    };
    parentPage.showMainPopup(orgAssignablePanel, target);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) OrgTreeAssignablePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreeAssignablePanel)

Example 3 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.

the class OrgTreeProvider method getChildren.

@Override
public Iterator<? extends SelectableBean<OrgType>> getChildren(SelectableBean<OrgType> node) {
    //    	getAvailableData().clear();
    LOGGER.debug("Loading children for {}", new Object[] { node });
    Iterator<SelectableBean<OrgType>> iterator = null;
    ObjectQuery query = QueryBuilder.queryFor(ObjectType.class, getPageBase().getPrismContext()).isDirectChildOf(// TODO what if getValue==null
    node.getValue().getOid()).asc(ObjectType.F_NAME).build();
    OperationResult result = new OperationResult(LOAD_ORG_UNITS);
    try {
        //            Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createOptionsForParentOrgRefs();
        Collection<SelectorOptions<GetOperationOptions>> options = null;
        Task task = getPageBase().createSimpleTask(LOAD_ORG_UNITS);
        List<PrismObject<OrgType>> units = getModelService().searchObjects(OrgType.class, query, options, task, result);
        LOGGER.debug("Found {} units.", units.size());
        List<SelectableBean<OrgType>> list = new ArrayList<SelectableBean<OrgType>>();
        for (PrismObject<OrgType> unit : units) {
            SelectableBean<OrgType> selectable = createObjectWrapper(node, unit);
            list.add(selectable);
        //                if (getAvailableData().contains(selectable)){
        //                	getAvailableData().remove(selectable);
        //                } 
        //                getAvailableData().add(selectable);
        }
        getAvailableData().addAll(list);
        //            Collections.sort(list);
        iterator = list.iterator();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load children", ex);
        result.recordFatalError("Unable to load org unit", ex);
    } finally {
        result.computeStatus();
    }
    if (WebComponentUtil.showResultInPage(result)) {
        getPageBase().showResult(result);
        throw new RestartResponseException(PageOrgTree.class);
    }
    if (iterator == null) {
        iterator = new ArrayList<SelectableBean<OrgType>>().iterator();
    }
    LOGGER.debug("Finished loading children.");
    return iterator;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) PrismObject(com.evolveum.midpoint.prism.PrismObject) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 4 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.

the class TreeTablePanel method initLayout.

protected void initLayout() {
    OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, getModel(), false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void selectTreeItemPerformed(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
            TreeTablePanel.this.selectTreeItemPerformed(selected, target);
        }

        protected List<InlineMenuItem> createTreeMenu() {
            return TreeTablePanel.this.createTreeMenu();
        }

        @Override
        protected List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
            return TreeTablePanel.this.createTreeChildrenMenu(org);
        }
    };
    treePanel.setOutputMarkupId(true);
    add(treePanel);
    add(createMemberPanel(treePanel.getSelected().getValue()));
    setOutputMarkupId(true);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) OrgTreePanel(com.evolveum.midpoint.web.page.admin.orgs.OrgTreePanel) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 5 with SelectableBean

use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.

the class ResourceTasksPanel method initLayout.

private void initLayout(final ListModel<TaskType> tasks) {
    final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<TaskType>(ID_TASKS_TABLE, TaskType.class, TableId.PAGE_RESOURCE_TASKS_PANEL, null, pageBase) {

        private static final long serialVersionUID = 1L;

        @Override
        protected BaseSortableDataProvider<SelectableBean<TaskType>> initProvider() {
            return new ListDataProvider2(pageBase, tasks);
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public void objectDetailsPerformed(AjaxRequestTarget target, TaskType task) {
            // TODO Auto-generated method stub
            //				super.objectDetailsPerformed(target, task);
            PageParameters parameters = new PageParameters();
            parameters.add(OnePageParameterEncoder.PARAMETER, task.getOid());
            getPageBase().navigateToNext(PageTaskEdit.class, parameters);
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            getPageBase().navigateToNext(PageTaskAdd.class);
        }

        @Override
        protected List<IColumn<SelectableBean<TaskType>, String>> createColumns() {
            return ColumnUtils.getDefaultTaskColumns();
        }
    };
    //		final ObjectListPanel<TaskType> tasksPanel = new ObjectListPanel<TaskType>(ID_TASKS_TABLE, TaskType.class, pageBase){
    //			
    //			@Override
    //			protected BaseSortableDataProvider<SelectableBean<TaskType>> getProvider() {
    //				return new ListDataProvider2(pageBase, tasks);
    //			}
    //			
    //			@Override
    //			public boolean isEditable() {
    //				return ResourceTasksPanel.this.editable;
    //			}
    //			
    //			@Override
    //			public void objectDetailsPerformed(AjaxRequestTarget target, TaskType task) {
    //				// TODO Auto-generated method stub
    //				super.objectDetailsPerformed(target, task);
    //				PageParameters parameters = new PageParameters();
    //		        parameters.add(OnePageParameterEncoder.PARAMETER, task.getOid());
    //		        setResponsePage(new PageTaskEdit(parameters));
    //			}
    //		};
    //		tasksPanel.setEditable(false);
    tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
    add(tasksPanel);
    AjaxButton runNow = new AjaxButton(ID_RUN_NOW, pageBase.createStringResource("pageTaskEdit.button.runNow")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.runNowPerformed(pageBase.getTaskService(), oids);
                pageBase.showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(pageBase.getFeedbackPanel());
        }
    };
    add(runNow);
    AjaxButton resume = new AjaxButton(ID_RESUME, pageBase.createStringResource("pageTaskEdit.button.resume")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.resumePerformed(pageBase.getTaskService(), oids);
                pageBase.showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(pageBase.getFeedbackPanel());
        }
    };
    add(resume);
    AjaxButton suspend = new AjaxButton(ID_SUSPEND, pageBase.createStringResource("pageTaskEdit.button.suspend")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<String> oids = createOidList(getTaskListPanel().getSelectedObjects());
            if (!oids.isEmpty()) {
                OperationResult result = TaskOperationUtils.suspendPerformed(pageBase.getTaskService(), oids);
                pageBase.showResult(result);
            } else {
                noTasksSelected();
            }
            target.add(pageBase.getFeedbackPanel());
        }
    };
    add(suspend);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) ListDataProvider2(com.evolveum.midpoint.web.component.util.ListDataProvider2) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Aggregations

SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)73 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)39 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)37 IModel (org.apache.wicket.model.IModel)37 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)32 ArrayList (java.util.ArrayList)31 Label (org.apache.wicket.markup.html.basic.Label)22 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)16 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)15 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)14 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)12 PropertyColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn)12 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)12 Item (org.apache.wicket.markup.repeater.Item)11 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)8 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 List (java.util.List)8 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)7