use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ObjectPolicyPanel method createObjectTemplateList.
protected IModel<List<ObjectTemplateConfigTypeReferenceDto>> createObjectTemplateList() {
return new AbstractReadOnlyModel<List<ObjectTemplateConfigTypeReferenceDto>>() {
@Override
public List<ObjectTemplateConfigTypeReferenceDto> getObject() {
List<PrismObject<ObjectTemplateType>> templateList = null;
List<ObjectTemplateConfigTypeReferenceDto> list = new ArrayList<>();
OperationResult result = new OperationResult(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_ALL_OBJECT_TEMPLATES);
try {
templateList = getPageBase().getModelService().searchObjects(ObjectTemplateType.class, new ObjectQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception e) {
result.recordFatalError("Could not get list of object templates", e);
LoggingUtils.logUnexpectedException(LOGGER, "Could not get list of object templates", e);
// TODO - show this error in GUI
}
if (templateList != null) {
ObjectTemplateType template;
for (PrismObject<ObjectTemplateType> obj : templateList) {
template = obj.asObjectable();
list.add(new ObjectTemplateConfigTypeReferenceDto(template.getOid(), WebComponentUtil.getName(template)));
}
}
return list;
}
};
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class ProfilingConfigPanel method createAppendersListModel.
private IModel<List<String>> createAppendersListModel() {
return new AbstractReadOnlyModel<List<String>>() {
@Override
public List<String> getObject() {
List<String> list = new ArrayList<>();
ProfilingDto dto = getModel().getObject();
for (AppenderConfiguration appender : dto.getAppenders()) {
list.add(appender.getName());
}
return list;
}
};
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class H3Header method initLayout.
@Override
protected void initLayout() {
Label title = new Label(ID_TITLE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getDisplayName();
}
});
add(title);
final IModel<List<InlineMenuItem>> items = new Model((Serializable) createMenuItems());
BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("H3Header.label.error"), new Model(BootstrapLabel.State.DANGER));
status.add(createFetchErrorVisibleBehaviour());
add(status);
AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {
@Override
public void onClick(AjaxRequestTarget target) {
onShowMorePerformed(target);
}
};
showMore.add(createFetchErrorVisibleBehaviour());
add(showMore);
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project midpoint by Evolveum.
the class PrismOptionButtonPanel method initButtons.
private void initButtons(final IModel<ObjectWrapper> model) {
AjaxLink showEmpty = new AjaxLink("showEmptyButton") {
@Override
public void onClick(AjaxRequestTarget target) {
showEmptyOnClick(target);
}
};
add(showEmpty);
showEmpty.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().isReadonly();
}
});
Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isShowEmpty()) {
return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
}
return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
}
});
showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isShowEmpty()) {
return getString("prismOptionButtonPanel.hideEmpty");
}
return getString("prismOptionButtonPanel.showEmpty");
}
}, ""));
showEmpty.add(showEmptyImg);
AjaxLink minimize = new AjaxLink("minimizeButton") {
@Override
public void onClick(AjaxRequestTarget target) {
minimizeOnClick(target);
}
};
add(minimize);
Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isMinimalized()) {
return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
}
return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
}
});
minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isMinimalized()) {
return getString("prismOptionButtonPanel.maximize");
}
return getString("prismOptionButtonPanel.minimize");
}
}, ""));
minimize.add(minimizeImg);
}
use of org.apache.wicket.model.AbstractReadOnlyModel in project ocvn by devgateway.
the class BootstrapPagingNavigation method populateItem.
@Override
protected void populateItem(final LoopItem loopItem) {
super.populateItem(loopItem);
final long pageIndex = getStartIndex() + loopItem.getIndex();
// Add disabled class to enclosing list item.
loopItem.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (pageable.getCurrentPage() == pageIndex) {
return "active";
} else {
return "";
}
}
}));
// Do not mask disabled link by em tag.
// ((AbstractLink)
// loopItem.get("pageLink")).setBeforeDisabledLink("").setAfterDisabledLink("");
}
Aggregations