use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class AssignmentPanel method initLayout.
private void initLayout() {
MultivalueContainerListPanelWithDetailsPanel<AssignmentType> multivalueContainerListPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_ASSIGNMENTS, AssignmentType.class) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isCreateNewObjectVisible() {
return isNewObjectButtonVisible(getFocusObject());
}
@Override
protected IModel<PrismContainerWrapper<AssignmentType>> getContainerModel() {
return AssignmentPanel.this.getModel();
}
@Override
protected void cancelItemDetailsPerformed(AjaxRequestTarget target) {
AssignmentPanel.this.cancelAssignmentDetailsPerformed(target);
}
protected List<IColumn<PrismContainerValueWrapper<AssignmentType>, String>> createDefaultColumns() {
if (AssignmentPanel.this.getModelObject() == null) {
return new ArrayList<>();
}
return initBasicColumns();
}
@Override
protected List<Component> createToolbarButtonsList(String idButton) {
List<Component> bar = new ArrayList<>();
AjaxIconButton newObjectButton = new AjaxIconButton(idButton, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON), createStringResource("MainObjectListPanel.newObject")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
newAssignmentClickPerformed(target);
}
};
newObjectButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
bar.add(newObjectButton);
newObjectButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isNewObjectButtonVisible(getFocusObject());
}
@Override
public boolean isEnabled() {
return !isAssignmentsLimitReached();
}
});
return bar;
}
@Override
public void deleteItemPerformed(AjaxRequestTarget target, List<PrismContainerValueWrapper<AssignmentType>> toDeleteList) {
int countAddedAssignments = 0;
for (PrismContainerValueWrapper<AssignmentType> assignment : toDeleteList) {
if (ValueStatus.ADDED.equals(assignment.getStatus())) {
countAddedAssignments++;
}
}
boolean isLimitReached = isAssignmentsLimitReached(toDeleteList.size() - countAddedAssignments, true);
if (isLimitReached) {
warn(getParentPage().getString("AssignmentPanel.assignmentsLimitReachedWarning", assignmentsRequestsLimit));
target.add(getPageBase().getFeedbackPanel());
return;
}
super.deleteItemPerformed(target, toDeleteList);
}
@Override
protected AssignmentListProvider createProvider() {
PageStorage pageStorage = getPageStorage(getAssignmentsTabStorageKey());
return createAssignmentProvider(pageStorage, getSearchModel(), loadValuesModel());
}
@Override
protected MultivalueContainerDetailsPanel<AssignmentType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<AssignmentType>> item) {
return createMultivalueContainerDetailsPanel(item);
}
@Override
protected UserProfileStorage.TableId getTableId() {
return AssignmentPanel.this.getTableId();
}
@Override
protected List<SearchItemDefinition> initSearchableItems(PrismContainerDefinition<AssignmentType> containerDef) {
return createSearchableItems(containerDef);
}
@Override
public void refreshTable(AjaxRequestTarget ajaxRequestTarget) {
super.refreshTable(ajaxRequestTarget);
AssignmentPanel.this.refreshTable(ajaxRequestTarget);
}
@Override
protected boolean isCollectionViewPanel() {
return config != null && config.getListView() != null;
}
@Override
protected CompiledObjectCollectionView getObjectCollectionView() {
if (config == null) {
return super.getObjectCollectionView();
}
GuiObjectListViewType listView = config.getListView();
if (listView == null) {
return null;
}
CollectionRefSpecificationType collectionRefSpecificationType = listView.getCollection();
if (collectionRefSpecificationType == null) {
return null;
}
Task task = getPageBase().createSimpleTask("Compile collection");
OperationResult result = task.getResult();
try {
return getPageBase().getModelInteractionService().compileObjectCollectionView(collectionRefSpecificationType, AssignmentType.class, task, result);
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
};
multivalueContainerListPanel.add(new VisibleBehaviour(() -> getModel() != null && getModelObject() != null));
add(multivalueContainerListPanel);
setOutputMarkupId(true);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class DelegationEditorPanel method addPrivilegesPanel.
private void addPrivilegesPanel(WebMarkupContainer body) {
privilegesNames = getPrivilegesNamesList();
ListView<String> privilegesListComponent = new ListView<String>(ID_PRIVILEGES_LIST, privilegesNames) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> item) {
Label privilageNameLabel = new Label(ID_PRIVILEGE, item.getModel());
item.add(privilageNameLabel);
}
};
privilegesListComponent.setOutputMarkupId(true);
privilegesListComponent.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
return true;
}
return false;
}
});
body.addOrReplace(privilegesListComponent);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class MultiCompositedButtonPanel method initLayout.
private void initLayout() {
ListView<CompositedIconButtonDto> buttonsPanel = new ListView<>(ID_BUTTONS_PANEL, getModel()) {
@Override
protected void populateItem(ListItem<CompositedIconButtonDto> item) {
CompositedButtonPanel additionalButton = new CompositedButtonPanel(ID_ADDITIONAL_BUTTON, item.getModel()) {
@Override
protected void onButtonClicked(AjaxRequestTarget target, CompositedIconButtonDto buttonDescription) {
buttonClickPerformed(target, buttonDescription.getAssignmentObjectRelation(), buttonDescription.getCollectionView(), buttonDescription.getPage());
}
};
// AjaxCompositedIconButton additionalButton = new AjaxCompositedIconButton(ID_COMPOSITED_BUTTON, item.getModel()) {
//
// @Override
// public void onClick(AjaxRequestTarget target) {
// buttonClickPerformed(target, item.getModelObject().getAssignmentObjectRelation(), item.getModelObject().getCollectionView(), item.getModelObject().getPage());
// }
// };
item.add(additionalButton);
//
// item.add(new Label(ID_BUTTON_DESCRIPTION, getButtonDescription(item.getModelObject())));
}
};
buttonsPanel.add(new VisibleBehaviour(() -> getModelObject() != null));
add(buttonsPanel);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class ApplicablePolicyGroupPanel method initLayout.
private void initLayout() {
Label policyGroupName = new Label(ID_POLICY_GROUP_NAME, Model.of(WebComponentUtil.getDisplayNameOrName(getModelObject(), getPageBase(), OPERATION_LOAD_POLICY_GROUP_NAME)));
policyGroupName.setOutputMarkupId(true);
add(policyGroupName);
ListView<PrismObject<AbstractRoleType>> policiesPanel = new ListView<PrismObject<AbstractRoleType>>(ID_POLICIES_CONTAINER, policiesListModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<PrismObject<AbstractRoleType>> listItem) {
PrismObject<AbstractRoleType> abstractRole = listItem.getModelObject();
CheckBoxPanel policyCheckBox = new CheckBoxPanel(ID_POLICY_CHECK_BOX, getCheckboxModel(abstractRole), // label
Model.of(WebComponentUtil.getDisplayNameOrName(abstractRole)), // tooltip
null) {
private static final long serialVersionUID = 1L;
@Override
public void onUpdate(AjaxRequestTarget target) {
onPolicyAddedOrRemoved(listItem.getModelObject(), getValue());
}
};
policyCheckBox.setOutputMarkupId(true);
listItem.add(policyCheckBox);
}
};
policiesPanel.setOutputMarkupId(true);
add(policiesPanel);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class PageAbout method initLayout.
private void initLayout() {
Label branch = new Label(ID_BRANCH, createStringResource("midpoint.system.branch"));
branch.setRenderBodyOnly(true);
add(branch);
Label revision = new Label(ID_BUILD, createStringResource("midpoint.system.build"));
revision.setRenderBodyOnly(true);
add(revision);
Label build = new Label(ID_BUILD_TIMESTAMP, createStringResource("midpoint.system.buildTimestamp"));
build.setRenderBodyOnly(true);
add(build);
ListView<SystemItem> listSystemItems = new ListView<SystemItem>(ID_LIST_SYSTEM_ITEMS, getItems()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<SystemItem> item) {
SystemItem systemItem = item.getModelObject();
Label property = new Label(ID_PROPERTY, systemItem.getProperty());
property.setRenderBodyOnly(true);
item.add(property);
Label value = new Label(ID_VALUE, systemItem.getValue());
value.setRenderBodyOnly(true);
item.add(value);
}
};
add(listSystemItems);
addLabel(ID_IMPLEMENTATION_SHORT_NAME, "implementationShortName");
addLabel(ID_IMPLEMENTATION_DESCRIPTION, "implementationDescription");
addLabel(ID_IS_EMBEDDED, "isEmbedded");
addLabel(ID_DRIVER_SHORT_NAME, "driverShortName");
addLabel(ID_DRIVER_VERSION, "driverVersion");
addLabel(ID_REPOSITORY_URL, "repositoryUrl");
ListView<LabeledString> additionalDetails = new ListView<LabeledString>(ID_ADDITIONAL_DETAILS, new PropertyModel<>(repoDiagModel, "additionalDetails")) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<LabeledString> item) {
LabeledString labeledString = item.getModelObject();
Label property = new Label(ID_DETAIL_NAME, labeledString.getLabel());
property.setRenderBodyOnly(true);
item.add(property);
Label value = new Label(ID_DETAIL_VALUE, labeledString.getData());
value.setRenderBodyOnly(true);
item.add(value);
}
};
add(additionalDetails);
ListView<LabeledString> provisioningAdditionalDetails = new ListView<LabeledString>(ID_PROVISIONING_ADDITIONAL_DETAILS, new PropertyModel<>(provisioningDiagModel, "additionalDetails")) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<LabeledString> item) {
LabeledString labeledString = item.getModelObject();
Label property = new Label(ID_PROVISIONING_DETAIL_NAME, labeledString.getLabel());
property.setRenderBodyOnly(true);
item.add(property);
Label value = new Label(ID_PROVISIONING_DETAIL_VALUE, labeledString.getData());
value.setRenderBodyOnly(true);
item.add(value);
}
};
add(provisioningAdditionalDetails);
String nodeId = getTaskManager().getNodeId();
OperationResult result = new OperationResult(OPERATION_LOAD_NODE);
List<PrismObject<NodeType>> nodes = WebModelServiceUtils.searchObjects(NodeType.class, getPrismContext().queryFor(NodeType.class).item(NodeType.F_NODE_IDENTIFIER).eq(nodeId).build(), result, PageAbout.this);
if (nodes.isEmpty()) {
throw new IllegalArgumentException("Couldn't find NodeType with identifier '" + nodeId + "'");
}
if (nodes.size() > 1) {
throw new IllegalArgumentException("Found more as one NodeType with identifier '" + nodeId + "'");
}
PrismObject<NodeType> node = nodes.get(0);
if (node == null) {
throw new IllegalArgumentException("Found NodeType with identifier '" + nodeId + "' is null");
}
NodeType nodeType = node.asObjectable();
Label nodeName = new Label(ID_NODE_NAME, nodeType.getName() != null ? nodeType.getName() : "");
nodeName.setRenderBodyOnly(true);
add(nodeName);
Label nodeIdValue = new Label(ID_NODE_ID, nodeType.getNodeIdentifier());
nodeIdValue.setRenderBodyOnly(true);
add(nodeIdValue);
Label nodeUrl = new Label(ID_NODE_URL, nodeType.getUrl() != null ? nodeType.getUrl() : "");
nodeUrl.setRenderBodyOnly(true);
add(nodeUrl);
Label jvmProperties = new Label(ID_JVM_PROPERTIES, new LoadableModel<String>(false) {
private static final long serialVersionUID = 1L;
@Override
protected String load() {
try {
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = runtimeMxBean.getInputArguments();
return StringUtils.join(arguments, "<br/>");
} catch (Exception ex) {
return PageAbout.this.getString("PageAbout.message.couldntObtainJvmParams");
}
}
});
jvmProperties.setEscapeModelStrings(false);
add(jvmProperties);
initButtons();
}
Aggregations