use of com.evolveum.midpoint.web.component.menu.cog.InlineMenu in project midpoint by Evolveum.
the class OrgMemberPanel method createManagerContainer.
private WebMarkupContainer createManagerContainer() {
WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
managerContainer.setOutputMarkupId(true);
managerContainer.setOutputMarkupPlaceholderTag(true);
RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
view.setOutputMarkupId(true);
ObjectQuery managersQuery = createManagerQuery();
OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
for (PrismObject<FocusType> manager : managers) {
ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
detailsPerformed(target, summary.getModelObject());
}
};
link.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
if (manager.getCompileTimeClass().equals(UserType.class)) {
managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(RoleType.class)) {
managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(OrgType.class)) {
managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
}
link.setOutputMarkupId(true);
managerMarkup.setOutputMarkupId(true);
managerMarkup.add(link);
view.add(managerMarkup);
AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
removeManagerPerformed(summary.getModelObject(), target);
getParent().setVisible(false);
target.add(OrgMemberPanel.this);
}
};
removeManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
removeManager.setOutputMarkupId(true);
managerMarkup.add(removeManager);
AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
deleteManagerPerformed(summary.getModelObject(), this, target);
}
};
deleteManager.setOutputMarkupId(true);
deleteManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
managerMarkup.add(deleteManager);
}
managerContainer.add(view);
InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
add(menupanel);
menupanel.setOutputMarkupId(true);
managerContainer.add(menupanel);
return managerContainer;
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenu in project midpoint by Evolveum.
the class MenuMultiButtonPanel method initLayout.
@Override
protected void initLayout() {
super.initLayout();
InlineMenu inlineMenu = new InlineMenu(ID_INLINE_MENU_PANEL, menuItemsModel) {
@Override
protected String getIconClass() {
return "fa fa-ellipsis-h";
}
@Override
protected String getAdditionalButtonClass() {
return "btn btn-default btn-xs";
}
@Override
protected String getMenuItemContainerClass() {
return "none";
}
@Override
protected String getMenuItemButtonStyle() {
return "";
}
@Override
protected String getMenuItemContainerStyle() {
return "margin-left: -37px; margin-bottom: -3px; list-style: none;";
}
};
inlineMenu.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !(numberOfButtons < 2);
}
});
add(inlineMenu);
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenu 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.menu.cog.InlineMenu in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method initLayout.
private void initLayout(final PageBase page) {
final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
shadows.setOutputMarkupId(true);
add(shadows);
InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
accountMenu.setVisible(!getObjectWrapper().isReadonly());
shadows.add(accountMenu);
final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(ID_SHADOW_LIST, projectionModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
PackageResourceReference packageRef;
final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
final PropertyModel<ObjectWrapper<F>> objectWrapperModel = new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object");
final Panel shadowPanel;
if (dto.isLoadedOK()) {
packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
shadowPanel = new PrismObjectPanel<F>(ID_SHADOW, new PropertyModel<ObjectWrapper<F>>(item.getModel(), "object"), packageRef, getMainForm(), getPageBase());
} else {
shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onShowMorePerformed(AjaxRequestTarget target) {
OperationResult fetchResult = dto.getResult();
if (fetchResult != null) {
showResult(fetchResult);
target.add(page.getFeedbackPanel());
}
}
};
}
shadowPanel.setOutputMarkupId(true);
shadowPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
return !shadowWrapper.isMinimalized();
}
});
item.add(shadowPanel);
CheckTableHeader<F> shadowHeader = new CheckTableHeader<F>(ID_SHADOW_HEADER, objectWrapperModel) {
private static final long serialVersionUID = 1L;
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
super.onClickPerformed(target);
onExpandCollapse(target, item.getModel());
target.add(shadows);
}
};
if (item.getModel().getObject().getStatus().equals(UserDtoStatus.DELETE)) {
shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
}
item.add(shadowHeader);
}
};
AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
if (dto.isLoadedOK()) {
ObjectWrapper<ShadowType> accModel = dto.getObject();
accModel.setSelected(getModelObject());
}
}
target.add(shadows);
}
};
shadows.add(accountCheckAll);
shadows.add(projectionList);
}
use of com.evolveum.midpoint.web.component.menu.cog.InlineMenu in project midpoint by Evolveum.
the class AssignmentTablePanel method initLayout.
private void initLayout(IModel<String> labelText) {
final WebMarkupContainer assignments = new WebMarkupContainer(ID_ASSIGNMENTS);
assignments.setOutputMarkupId(true);
add(assignments);
Label label = new Label(ID_HEADER, labelText);
assignments.add(label);
InlineMenu assignmentMenu = new InlineMenu(ID_MENU, new Model((Serializable) createAssignmentMenu()));
assignmentMenu.setVisible(getAssignmentMenuVisibility());
assignments.add(assignmentMenu);
ListView<AssignmentEditorDto> list = new ListView<AssignmentEditorDto>(ID_LIST, getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<AssignmentEditorDto> item) {
AssignmentTablePanel.this.populateAssignmentDetailsPanel(item);
}
};
list.setOutputMarkupId(true);
assignments.add(list);
AjaxCheckBox checkAll = new AjaxCheckBox(ID_CHECK_ALL, new Model()) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
List<AssignmentEditorDto> assignmentEditors = getAssignmentModel().getObject();
for (AssignmentEditorDto dto : assignmentEditors) {
dto.setSelected(this.getModelObject());
}
target.add(assignments);
}
};
checkAll.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
int count = 0;
for (AssignmentEditorDto dto : getModelObject()) {
if (dto.isSimpleView()) {
count++;
}
}
if (count == getModelObject().size()) {
return false;
} else {
return true;
}
}
});
assignments.add(checkAll);
}
Aggregations