use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class PageAbout method initLayout.
private void initLayout() {
Label revision = new Label(ID_REVISION, createStringResource("PageAbout.midPointRevision"));
revision.setRenderBodyOnly(true);
add(revision);
Label build = new Label(ID_BUILD, createStringResource("PageAbout.build"));
build.setRenderBodyOnly(true);
add(build);
ListView<SystemItem> listSystemItems = new ListView<SystemItem>(ID_LIST_SYSTEM_ITEMS, getItems()) {
@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<List<LabeledString>>(repoDiagModel, "additionalDetails")) {
@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<List<LabeledString>>(provisioningDiagModel, "additionalDetails")) {
@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);
Label jvmProperties = new Label(ID_JVM_PROPERTIES, new LoadableModel<String>(false) {
@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();
}
use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class PrismValuePanel method removeValue.
private void removeValue(AjaxRequestTarget target) {
ValueWrapper wrapper = valueWrapperModel.getObject();
ItemWrapper propertyWrapper = wrapper.getItem();
LOGGER.debug("Removing value of {}", propertyWrapper);
List<ValueWrapper> values = propertyWrapper.getValues();
Component inputPanel = this.get(ID_VALUE_CONTAINER).get(ID_INPUT);
switch(wrapper.getStatus()) {
case ADDED:
values.remove(wrapper);
break;
case DELETED:
error("Couldn't delete already deleted item: " + wrapper.toString());
target.add(((PageBase) getPage()).getFeedbackPanel());
case NOT_CHANGED:
if (inputPanel instanceof AssociationValueChoicePanel) {
((PropertyWrapper) propertyWrapper).setStatus(ValueStatus.DELETED);
}
wrapper.setStatus(ValueStatus.DELETED);
break;
}
// wrapper.getItem().getContainer().
int count = countUsableValues(propertyWrapper);
if (count == 0 && !hasEmptyPlaceholder(propertyWrapper)) {
if (inputPanel instanceof ValueChoosePanel) {
values.add(new ValueWrapper(propertyWrapper, new PrismReferenceValue(null), ValueStatus.ADDED));
} else if (inputPanel instanceof AssociationValueChoicePanel) {
Item item = propertyWrapper.getItem();
ItemPath path = item.getPath();
if (path != null) {
}
// values.add(new ValueWrapper(propertyWrapper, new PrismPropertyValue(null), ValueStatus.ADDED));
} else {
values.add(new ValueWrapper(propertyWrapper, new PrismPropertyValue(null), ValueStatus.ADDED));
}
}
ListView parent = findParent(ListView.class);
target.add(parent.getParent());
}
use of org.apache.wicket.markup.html.list.ListView in project midpoint by Evolveum.
the class ScenePanel method initLayout.
private void initLayout() {
final IModel<SceneDto> model = getModel();
WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
box.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.getBoxClassOverride() != null) {
return dto.getBoxClassOverride();
}
if (dto.getChangeType() == null) {
return null;
}
switch(dto.getChangeType()) {
case ADD:
return "box-success";
case DELETE:
return "box-danger";
case MODIFY:
return "box-info";
default:
return null;
}
}
}));
add(box);
WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
box.add(headerPanel);
headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {
@Override
public void minimizeOnClick(AjaxRequestTarget target) {
headerOnClickPerformed(target, model);
}
});
Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
//headerChangeType.setRenderBodyOnly(true);
Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
//headerObjectType.setRenderBodyOnly(true);
IModel<String> nameModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getName(ScenePanel.this);
}
};
Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
LinkPanel headerNameLink = new LinkPanel(ID_HEADER_NAME_LINK, nameModel) {
@Override
public void onClick(AjaxRequestTarget target) {
PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
if (value != null && value.getParent() instanceof PrismObject) {
PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object), getPageBase(), false);
}
}
};
Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getDescription(ScenePanel.this);
}
});
Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
}
});
headerPanel.add(headerChangeType);
headerPanel.add(headerObjectType);
headerPanel.add(headerNameLabel);
headerPanel.add(headerNameLink);
headerPanel.add(headerDescription);
headerPanel.add(headerWrapperDisplayName);
headerChangeType.add(createHeaderOnClickBehaviour(model));
headerObjectType.add(createHeaderOnClickBehaviour(model));
headerNameLabel.add(createHeaderOnClickBehaviour(model));
headerDescription.add(createHeaderOnClickBehaviour(model));
headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return isExistingViewableObject();
}
};
VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return !isExistingViewableObject();
}
};
headerChangeType.add(visibleIfNotWrapper);
headerObjectType.add(visibleIfNotWrapper);
headerNameLabel.add(visibleIfNotWrapperAndNotExistingObject);
headerNameLink.add(visibleIfExistingObject);
headerDescription.add(visibleIfNotWrapper);
headerWrapperDisplayName.add(visibleIfWrapper);
WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneDto wrapper = model.getObject();
return !wrapper.isMinimized();
}
});
box.add(body);
WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
itemsTable.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().getItems().isEmpty();
}
});
WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
oldValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(oldValueLabel);
WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
newValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(newValueLabel);
WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
valueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().containsDeltaItems();
}
});
itemsTable.add(valueLabel);
ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<List<SceneItemDto>>(model, SceneDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SceneItemDto> item) {
SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
panel.setRenderBodyOnly(true);
item.add(panel);
}
};
items.setReuseItems(true);
itemsTable.add(items);
body.add(itemsTable);
ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<List<SceneDto>>(model, SceneDto.F_PARTIAL_SCENES)) {
@Override
protected void populateItem(ListItem<SceneDto> item) {
ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel());
panel.setOutputMarkupPlaceholderTag(true);
item.add(panel);
}
};
partialScenes.setReuseItems(true);
body.add(partialScenes);
}
use of org.apache.wicket.markup.html.list.ListView in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.
/**
* pending files section
*/
private void addPendingFilesComponent() {
pendingFiles = new WebMarkupContainer("pendingFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
if (filesModel != null && filesModel.size() > 0) {
for (FileMetadata file : filesModel) {
if (file.isNew()) {
setVisibilityAllowed(true);
return;
}
}
}
setVisibilityAllowed(false);
}
};
pendingFiles.setOutputMarkupPlaceholderTag(true);
pendingFiles.setOutputMarkupId(true);
add(pendingFiles);
pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// upload)
for (FileMetadata file : filesModel) {
if (file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
item.add(new Label("fileTitle", item.getModelObject().getName()));
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(pendingFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
}
};
pendingFiles.add(list);
}
use of org.apache.wicket.markup.html.list.ListView in project oc-explorer by devgateway.
the class FileInputBootstrapFormComponentWrapper method addAlreadyUploadedFilesComponent.
/**
* already uploaded files section
*/
private void addAlreadyUploadedFilesComponent() {
alreadyUploadedFiles = new WebMarkupContainer("alreadyUploadedFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onInitialize() {
super.onInitialize();
setVisibilityAllowed(isVisibleAlreadyUploadedFiles());
}
};
alreadyUploadedFiles.setOutputMarkupPlaceholderTag(true);
alreadyUploadedFiles.setOutputMarkupId(true);
add(alreadyUploadedFiles);
alreadyUploadedFiles.add(new Label("uploadedFilesTitle", new StringResourceModel("uploadedFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> alreadyUploadedFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// get only the already uploaded files
for (FileMetadata file : filesModel) {
if (!file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", alreadyUploadedFilesModel) {
private static final long serialVersionUID = 1L;
private List<IndicatingAjaxLink<Void>> deleteButtons = new ArrayList<>();
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
// make file name clickable
Link<FileMetadata> downloadLink = new Link<FileMetadata>("downloadLink", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
final FileMetadata modelObject = getModelObject();
AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {
private static final long serialVersionUID = 1L;
@Override
public void write(final OutputStream output) throws IOException {
output.write(modelObject.getContent().getBytes());
}
@Override
public String getContentType() {
return modelObject.getContentType();
}
};
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, modelObject.getName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
};
downloadLink.add(new Label("downloadText", item.getModelObject().getName()));
downloadLink.add(new TooltipBehavior(new StringResourceModel("downloadUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
item.add(downloadLink);
Link<FileMetadata> download = new CustomDownloadLink("download", item.getModel());
item.add(download);
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(alreadyUploadedFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
deleteButtons.add(delete);
// only to admins
if (visibleOnlyToAdmin) {
MetaDataRoleAuthorizationStrategy.authorize(delete, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
}
if (disableDeleteButton) {
delete.setVisibilityAllowed(false);
}
}
@Override
public void onEvent(final IEvent<?> event) {
/*
* disable 'delete' buttons based on the form state
*/
if (event.getPayload() instanceof EditingDisabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(false);
}
}
if (event.getPayload() instanceof EditingEnabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(true);
}
}
}
};
alreadyUploadedFiles.add(list);
}
Aggregations