use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class CountToolbar method createModel.
private IModel<String> createModel() {
return new LoadableModel<String>() {
@Override
protected String load() {
long from = 0;
long to = 0;
long count = 0;
IPageable pageable = getTable();
if (pageable instanceof DataViewBase) {
DataViewBase view = (DataViewBase) pageable;
from = view.getFirstItemOffset() + 1;
to = from + view.getItemsPerPage() - 1;
long itemCount = view.getItemCount();
if (to > itemCount) {
to = itemCount;
}
count = itemCount;
} else if (pageable instanceof DataTable) {
DataTable table = (DataTable) pageable;
from = table.getCurrentPage() * table.getItemsPerPage() + 1;
to = from + table.getItemsPerPage() - 1;
long itemCount = table.getItemCount();
if (to > itemCount) {
to = itemCount;
}
count = itemCount;
}
if (count > 0) {
PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.label", new Object[] { from, to, count });
}
return PageBase.createStringResourceStatic(CountToolbar.this, "CountToolbar.noFound").getString();
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class PageResourceEdit method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
final IModel<Boolean> editable = new LoadableModel<Boolean>(false) {
@Override
protected Boolean load() {
return !isEditing();
}
};
mainForm.add(new AjaxCheckBox(ID_EDIT, editable) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
editPerformed(target, editable.getObject());
}
});
AceEditor editor = new AceEditor(ID_ACE_EDITOR, new PropertyModel<String>(model, ObjectViewDto.F_XML));
editor.setReadonly(new LoadableModel<Boolean>(false) {
@Override
protected Boolean load() {
return isEditing();
}
});
mainForm.add(editor);
initButtons(mainForm);
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class ObjectListPanel method initSearchModel.
private LoadableModel<Search> initSearchModel() {
return new LoadableModel<Search>(false) {
private static final long serialVersionUID = 1L;
@Override
public Search load() {
String storageKey = getStorageKey();
Search search = null;
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
search = storage.getSearch();
}
}
if (search == null) {
search = createSearch();
}
return search;
}
};
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class PrismPropertyPanel method initLayout.
private void initLayout(final IModel<IW> model, final Form form) {
WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER);
labelContainer.setOutputMarkupId(true);
labelContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return labelContainerVisible;
}
});
add(labelContainer);
final IModel<String> label = createDisplayName(model);
labelContainer.add(new Label(ID_LABEL, label));
final IModel<String> helpText = new LoadableModel<String>(false) {
private static final long serialVersionUID = 1L;
@Override
protected String load() {
return loadHelpText(model);
}
};
Label help = new Label(ID_HELP);
help.add(AttributeModifier.replace("title", helpText));
help.add(new InfoTooltipBehavior());
help.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return StringUtils.isNotEmpty(helpText.getObject());
}
});
labelContainer.add(help);
WebMarkupContainer required = new WebMarkupContainer("required");
required.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
IW wrapper = model.getObject();
ItemDefinition def = wrapper.getItemDefinition();
if (ObjectType.F_NAME.equals(def.getName())) {
//fix for "name as required" MID-789
return true;
}
return def.isMandatory();
}
});
labelContainer.add(required);
WebMarkupContainer hasOutbound = new WebMarkupContainer("hasOutbound");
hasOutbound.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return hasOutbound(model);
}
});
labelContainer.add(hasOutbound);
WebMarkupContainer hasPendingModification = new WebMarkupContainer(ID_HAS_PENDING_MODIFICATION);
hasPendingModification.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return hasPendingModification(model);
}
});
labelContainer.add(hasPendingModification);
ListView<ValueWrapper> values = new ListView<ValueWrapper>("values", new PropertyModel<List<ValueWrapper>>(model, "values")) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<ValueWrapper> item) {
PrismValuePanel panel = new PrismValuePanel("value", item.getModel(), label, form, getValueCssClass(), getInputCssClass(), pageBase);
item.add(panel);
item.add(AttributeModifier.append("class", createStyleClassModel(item.getModel())));
item.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isVisibleValue(item.getModel());
}
});
}
};
values.add(new AttributeModifier("class", getValuesClass()));
values.setReuseItems(true);
add(values);
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class FocusPersonasTabPanel method initLayout.
private void initLayout() {
WebMarkupContainer container = new WebMarkupContainer(ID_PERSONAS_CONTAINER);
container.setOutputMarkupId(true);
add(container);
RepeatingView view = new RepeatingView(ID_PERSONAS_TABLE);
view.setOutputMarkupId(true);
container.add(view);
LoadableModel<List<PrismObject<FocusType>>> personasListModel = loadModel();
if (personasListModel.getObject() == null || personasListModel.getObject().size() == 0) {
WebMarkupContainer viewChild = new WebMarkupContainer(view.newChildId());
viewChild.setOutputMarkupId(true);
view.add(viewChild);
WebMarkupContainer emptyContainer = new WebMarkupContainer(ID_PERSONAS_SUMMARY);
emptyContainer.setOutputMarkupId(true);
viewChild.add(emptyContainer);
return;
}
Task task = pageBase.createSimpleTask(OPERATION_LOAD_PERSONAS);
for (PrismObject<FocusType> personaObject : personasListModel.getObject()) {
ObjectWrapper<FocusType> personaWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(personaObject, RoleType.F_DISPLAY_NAME), "", personaObject, ContainerStatus.MODIFYING, task, getPageBase());
WebMarkupContainer personaPanel = new WebMarkupContainer(view.newChildId());
personaPanel.setOutputMarkupId(true);
view.add(personaPanel);
if (personaObject.getCompileTimeClass().equals(UserType.class)) {
personaPanel.add(new UserSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(RoleType.class)) {
personaPanel.add(new RoleSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(OrgType.class)) {
personaPanel.add(new OrgSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) personaWrapper)));
} else if (personaObject.getCompileTimeClass().equals(ServiceType.class)) {
personaPanel.add(new ServiceSummaryPanel(ID_PERSONAS_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) personaWrapper)));
}
}
}
Aggregations