use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.
the class AssignmentCatalogPanel method initCartButton.
private void initCartButton(WebMarkupContainer headerPanel) {
AjaxButton cartButton = new AjaxButton(ID_CART_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
pageBase.navigateToNext(PageAssignmentsList.class);
}
};
cartButton.add(new VisibleEnableBehaviour() {
public boolean isVisible() {
return !isCatalogOidEmpty();
}
});
cartButton.setOutputMarkupId(true);
headerPanel.add(cartButton);
Label cartItemsCount = new Label(ID_CART_ITEMS_COUNT, new LoadableModel<String>(true) {
private static final long serialVersionUID = 1L;
@Override
public String load() {
return Integer.toString(getRoleCatalogStorage().getAssignmentShoppingCart().size());
}
});
cartItemsCount.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SessionStorage storage = pageBase.getSessionStorage();
if (storage.getRoleCatalog().getAssignmentShoppingCart().size() == 0) {
return false;
} else {
return true;
}
}
});
cartItemsCount.setOutputMarkupId(true);
cartButton.add(cartItemsCount);
}
use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.
the class AssignmentCatalogPanel method addOrReplaceLayout.
public void addOrReplaceLayout(AjaxRequestTarget target, WebMarkupContainer panelContainer) {
WebMarkupContainer treePanelContainer = new WebMarkupContainer(ID_TREE_PANEL_CONTAINER);
treePanelContainer.setOutputMarkupId(true);
panelContainer.addOrReplace(treePanelContainer);
if (AssignmentViewType.ROLE_CATALOG_VIEW.equals(AssignmentViewType.getViewTypeFromSession(pageBase)) && StringUtils.isNotEmpty(rootOid)) {
// not let tree panel initializing in case of empty role catalog oid
OrgTreePanel treePanel = new OrgTreePanel(ID_TREE_PANEL, Model.of(rootOid), false, "AssignmentShoppingCartPanel.treeTitle") {
private static final long serialVersionUID = 1L;
@Override
protected void selectTreeItemPerformed(SelectableBean<OrgType> selected, AjaxRequestTarget target) {
AssignmentCatalogPanel.this.selectTreeItemPerformed(selected, target);
}
protected List<InlineMenuItem> createTreeMenu() {
return new ArrayList<>();
}
@Override
protected List<InlineMenuItem> createTreeChildrenMenu(OrgType org) {
return new ArrayList<>();
}
@Override
protected OrgTreeStateStorage getOrgTreeStateStorage() {
return getRoleCatalogStorage();
}
};
treePanel.setOutputMarkupId(true);
treePanelContainer.add(new AttributeAppender("class", "col-md-3"));
treePanelContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isCatalogOidEmpty();
}
});
treePanelContainer.addOrReplace(treePanel);
} else {
WebMarkupContainer treePanel = new WebMarkupContainer(ID_TREE_PANEL);
treePanel.setVisible(false);
treePanel.setOutputMarkupId(true);
treePanelContainer.addOrReplace(treePanel);
}
WebMarkupContainer catalogItemsPanelContainer = new WebMarkupContainer(ID_CATALOG_ITEMS_PANEL_CONTAINER);
catalogItemsPanelContainer.setOutputMarkupId(true);
panelContainer.addOrReplace(catalogItemsPanelContainer);
String assignmentsOwnerName = getRoleCatalogStorage().getAssignmentsUserOwner() != null ? getRoleCatalogStorage().getAssignmentsUserOwner().getName().getOrig() : "";
Label assignmentsOwnerLabel = new Label(ID_ASSIGNMENTS_OWNER_NAME, createStringResource("AssignmentCatalogPanel.assignmentsOwner", assignmentsOwnerName));
assignmentsOwnerLabel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return AssignmentViewType.USER_TYPE.equals(getRoleCatalogStorage().getViewType());
}
});
catalogItemsPanelContainer.add(assignmentsOwnerLabel);
CatalogItemsPanel catalogItemsPanel;
if (AssignmentViewType.USER_TYPE.equals(viewModel.getObject())) {
PrismObject<UserType> assignmentsOwner = getRoleCatalogStorage().getAssignmentsUserOwner();
listProviderData = new ArrayList<>();
if (assignmentsOwner != null) {
List<AssignmentType> assignments = assignmentsOwner.asObjectable().getAssignment();
for (AssignmentType assignment : assignments) {
if (assignment.getTargetRef() == null || !UserType.COMPLEX_TYPE.equals(assignment.getTargetRef().getType())) {
assignment.setId(null);
listProviderData.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, pageBase));
}
}
Collections.sort(listProviderData);
}
ListDataProvider listDataProvider = new ListDataProvider(this, Model.ofList(listProviderData));
catalogItemsPanel = new CatalogItemsPanel(ID_CATALOG_ITEMS_PANEL, pageBase, itemsPerRow, listDataProvider);
} else {
catalogItemsPanel = new CatalogItemsPanel(ID_CATALOG_ITEMS_PANEL, selectedTreeItemOidModel, pageBase, itemsPerRow, objectProvider);
}
if (AssignmentViewType.ROLE_CATALOG_VIEW.equals(AssignmentViewType.getViewTypeFromSession(pageBase))) {
catalogItemsPanelContainer.add(new AttributeAppender("class", "col-md-9"));
} else {
catalogItemsPanelContainer.add(new AttributeAppender("class", "col-md-12"));
}
catalogItemsPanel.setOutputMarkupId(true);
catalogItemsPanelContainer.addOrReplace(catalogItemsPanel);
}
use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.
the class AssignmentEditorPanel method initAttributesLayout.
private void initAttributesLayout(WebMarkupContainer constructionContainer) {
WebMarkupContainer attributes = new WebMarkupContainer(ID_ATTRIBUTES);
attributes.setOutputMarkupId(true);
attributes.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
AssignmentEditorDto dto = getModel().getObject();
return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
}
});
attributes.setEnabled(getModel().getObject().isEditable());
constructionContainer.add(attributes);
ListView<ACAttributeDto> attribute = new ListView<ACAttributeDto>(ID_ATTRIBUTE, attributesModel) {
@Override
protected void populateItem(ListItem<ACAttributeDto> listItem) {
final IModel<ACAttributeDto> attrModel = listItem.getModel();
ACAttributePanel acAttribute = new ACAttributePanel(ID_AC_ATTRIBUTE, attrModel, ignoreMandatoryAttributes());
acAttribute.setRenderBodyOnly(true);
listItem.add(acAttribute);
listItem.setOutputMarkupId(true);
listItem.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
AssignmentEditorDto editorDto = AssignmentEditorPanel.this.getModel().getObject();
if (editorDto.isShowEmpty()) {
return true;
}
ACAttributeDto dto = attrModel.getObject();
return !dto.isEmpty();
}
});
}
};
attributes.add(attribute);
// todo extension
}
use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.
the class PageAccounts method initLayout.
private void initLayout() {
Form form = new Form(ID_MAIN_FORM);
form.setOutputMarkupId(true);
add(form);
Form accForm = new Form(ID_FORM_ACCOUNT);
accForm.setOutputMarkupId(true);
add(accForm);
Form searchForm = new Form(ID_SEARCH_FORM);
initSearchForm(searchForm);
searchForm.setOutputMarkupPlaceholderTag(true);
searchForm.setOutputMarkupId(true);
searchForm.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return resourceModel.getObject() != null;
}
});
add(searchForm);
DropDownChoice<ResourceItemDto> resources = new DropDownChoice<>(ID_RESOURCES, resourceModel, resourcesModel, new ChoiceableChoiceRenderer<ResourceItemDto>());
form.add(resources);
initLinks(form, accForm);
initTotals(form);
final AjaxDownloadBehaviorFromFile ajaxDownloadBehavior = new AjaxDownloadBehaviorFromFile(true) {
@Override
protected File initFile() {
return downloadFile;
}
};
ajaxDownloadBehavior.setRemoveFile(false);
form.add(ajaxDownloadBehavior);
WebMarkupContainer filesContainer = new WebMarkupContainer(ID_FILES_CONTAINER);
filesContainer.setOutputMarkupId(true);
accForm.add(filesContainer);
ModalWindow resultPopup = createModalWindow(ID_RESULT_DIALOG, createStringResource("PageAccounts.result.popoup"), 1100, 560);
resultPopup.setContent(new AceEditorDialog(resultPopup.getContentId()));
add(resultPopup);
filesModel = createFilesModel();
ListView<String> files = new ListView<String>(ID_FILES, filesModel) {
@Override
protected void populateItem(final ListItem<String> item) {
AjaxLink file = new AjaxLink(ID_FILE) {
@Override
public void onClick(AjaxRequestTarget target) {
downloadPerformed(target, item.getModelObject(), ajaxDownloadBehavior);
}
};
file.add(new Label(ID_FILE_NAME, item.getModelObject()));
item.add(file);
}
};
files.setRenderBodyOnly(true);
filesContainer.add(files);
WebMarkupContainer accountsContainer = new WebMarkupContainer(ID_ACCOUNTS_CONTAINER);
accountsContainer.setOutputMarkupId(true);
accForm.add(accountsContainer);
ObjectDataProvider provider = new ObjectDataProvider(this, ShadowType.class);
provider.setOptions(SelectorOptions.createCollection(GetOperationOptions.createRaw()));
provider.setQuery(ObjectQuery.createObjectQuery(createResourceQueryFilter()));
TablePanel accounts = new TablePanel(ID_ACCOUNTS, provider, createAccountsColumns(), UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS, getItemsPerPage(UserProfileStorage.TableId.CONF_PAGE_ACCOUNTS));
accounts.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return resourceModel.getObject() != null;
}
});
accounts.setItemsPerPage(50);
accountsContainer.add(accounts);
}
use of com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour in project midpoint by Evolveum.
the class PageCertCampaign method initButtons.
private void initButtons(final Form mainForm) {
AjaxButton backButton = new AjaxButton(ID_BACK_BUTTON, createStringResource("PageCertCampaign.button.back")) {
@Override
public void onClick(AjaxRequestTarget target) {
redirectBack();
}
};
mainForm.add(backButton);
AjaxSubmitButton startCampaignButton = new AjaxSubmitButton(ID_START_CAMPAIGN_BUTTON, createStringResource("PageCertCampaign.button.startCampaign")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
executeCampaignStateOperation(target, OP_OPEN_NEXT_STAGE);
}
};
startCampaignButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return campaignModel.getObject().getState() == AccessCertificationCampaignStateType.CREATED;
}
});
mainForm.add(startCampaignButton);
AjaxButton nextStageButton = new AjaxButton(ID_OPEN_NEXT_STAGE_BUTTON, createStringResource("PageCertCampaign.button.openNextStage")) {
@Override
public void onClick(AjaxRequestTarget target) {
executeCampaignStateOperation(target, OP_OPEN_NEXT_STAGE);
}
};
nextStageButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return campaignModel.getObject().getState() == AccessCertificationCampaignStateType.REVIEW_STAGE_DONE && campaignModel.getObject().getCurrentStageNumber() < campaignModel.getObject().getNumberOfStages();
}
});
mainForm.add(nextStageButton);
AjaxButton closeStageButton = new AjaxButton(ID_CLOSE_STAGE_BUTTON, createStringResource("PageCertCampaign.button.closeStage")) {
@Override
public void onClick(AjaxRequestTarget target) {
executeCampaignStateOperation(target, OP_CLOSE_STAGE);
}
};
closeStageButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return campaignModel.getObject().getState() == AccessCertificationCampaignStateType.IN_REVIEW_STAGE;
}
});
mainForm.add(closeStageButton);
AjaxButton startRemediationButton = new AjaxButton(ID_START_REMEDIATION_BUTTON, createStringResource("PageCertCampaign.button.startRemediation")) {
@Override
public void onClick(AjaxRequestTarget target) {
executeCampaignStateOperation(target, OP_START_REMEDIATION);
}
};
startRemediationButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return campaignModel.getObject().getState() == AccessCertificationCampaignStateType.REVIEW_STAGE_DONE && campaignModel.getObject().getCurrentStageNumber() == campaignModel.getObject().getNumberOfStages();
}
});
mainForm.add(startRemediationButton);
// TODO reenable when confirmation window is implemented
// AjaxButton closeCampaignButton = new AjaxButton(ID_CLOSE_CAMPAIGN_BUTTON,
// createStringResource("PageCertCampaign.button.closeCampaign")) {
//
// @Override
// public void onClick(AjaxRequestTarget target) {
// executeCampaignStateOperation(target, OP_CLOSE_CAMPAIGN);
// }
// };
// closeCampaignButton.add(new VisibleEnableBehaviour() {
// @Override
// public boolean isVisible() {
// return campaignModel.getObject().getState() != AccessCertificationCampaignStateType.CLOSED;
// }
// });
// mainForm.add(closeCampaignButton);
}
Aggregations