use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class AbstractOrgTabPanel method changeTabPerformed.
protected void changeTabPerformed(int index) {
if (roots != null && index >= 0 && index <= roots.size()) {
SessionStorage storage = getPageBase().getSessionStorage();
SelectableBean<OrgType> selected = new SelectableBean<OrgType>();
selected.setValue(roots.get(index).asObjectable());
storage.getUsers().setSelectedItem(selected);
storage.getUsers().setSelectedTabId(index);
}
}
use of com.evolveum.midpoint.web.component.util.SelectableBean 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);
}
use of com.evolveum.midpoint.web.component.util.SelectableBean 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;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class PageCreatedReports method initColumns.
//TODO - consider adding Author name, File Type and ReportType to columns
private List<IColumn<SelectableBean<ReportOutputType>, String>> initColumns(final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior) {
List<IColumn<SelectableBean<ReportOutputType>, String>> columns = new ArrayList<>();
IColumn column;
column = new CheckBoxHeaderColumn();
columns.add(column);
column = new PropertyColumn(createStringResource("pageCreatedReports.table.name"), "name", "value.name");
columns.add(column);
column = new PropertyColumn(createStringResource("pageCreatedReports.table.description"), "value.description");
columns.add(column);
column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(createStringResource("pageCreatedReports.table.time"), "createTimestamp") {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> rowModel) {
cellItem.add(new DateLabelComponent(componentId, new AbstractReadOnlyModel<Date>() {
@Override
public Date getObject() {
ReportOutputType object = rowModel.getObject().getValue();
MetadataType metadata = object != null ? object.getMetadata() : null;
if (metadata == null) {
return null;
}
return XmlTypeConverter.toDate(metadata.getCreateTimestamp());
}
}, DateLabelComponent.LONG_MEDIUM_STYLE));
}
};
columns.add(column);
column = new AbstractColumn<SelectableBean<ReportOutputType>, String>(new Model(), null) {
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ReportOutputType>>> cellItem, String componentId, final IModel<SelectableBean<ReportOutputType>> model) {
DownloadButtonPanel panel = new DownloadButtonPanel(componentId) {
@Override
protected void deletePerformed(AjaxRequestTarget target) {
deleteSelectedPerformed(target, ReportDeleteDialogDto.Operation.DELETE_SINGLE, model.getObject().getValue());
}
@Override
protected void downloadPerformed(AjaxRequestTarget target) {
currentReport = model.getObject().getValue();
PageCreatedReports.this.downloadPerformed(target, model.getObject().getValue(), ajaxDownloadBehavior);
}
};
cellItem.add(panel);
}
};
columns.add(column);
column = new InlineMenuHeaderColumn<InlineMenuable>(initInlineMenu()) {
@Override
public void populateItem(Item<ICellPopulator<InlineMenuable>> cellItem, String componentId, IModel<InlineMenuable> rowModel) {
cellItem.add(new Label(componentId));
}
};
columns.add(column);
return columns;
}
use of com.evolveum.midpoint.web.component.util.SelectableBean in project midpoint by Evolveum.
the class RoleGovernanceRelationsPanel method createMembersColumns.
@Override
protected List<IColumn<SelectableBean<ObjectType>, String>> createMembersColumns() {
List<IColumn<SelectableBean<ObjectType>, String>> columns = super.createMembersColumns();
IColumn<SelectableBean<ObjectType>, String> column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("roleMemberPanel.relation")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
cellItem.add(new Label(componentId, getRelationValue((FocusType) rowModel.getObject().getValue())));
}
@Override
public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
return Model.of(getRelationValue((FocusType) rowModel.getObject().getValue()));
}
};
columns.add(column);
return columns;
}
Aggregations