use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class OperationResultPanel method createMessage.
private Label createMessage() {
Label message = null;
if (StringUtils.isNotBlank(getModelObject().getMessage())) {
PropertyModel<String> messageModel = new PropertyModel<String>(getModel(), "message");
message = new Label(ID_MESSAGE_LABEL, messageModel);
} else {
message = new Label(ID_MESSAGE_LABEL, new LoadableModel<Object>() {
private static final long serialVersionUID = 1L;
@Override
protected Object load() {
OpResult result = OperationResultPanel.this.getModelObject();
String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
return getPage().getString(resourceKey, null, resourceKey);
}
});
}
//message.setRenderBodyOnly(true);
message.setOutputMarkupId(true);
return message;
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class OperationResultPanel method initDetails.
private void initDetails(WebMarkupContainer box, Page parentPage) {
final WebMarkupContainer details = new WebMarkupContainer("details", getModel());
details.setOutputMarkupId(true);
details.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModel().getObject().isShowMore();
}
});
box.add(details);
WebMarkupContainer operationPanel = new WebMarkupContainer("type");
operationPanel.setOutputMarkupId(true);
operationPanel.add(new AttributeAppender("class", new LoadableModel<String>() {
private static final long serialVersionUID = 1L;
@Override
protected String load() {
return getLabelCss(getModel());
}
}, " "));
details.add(operationPanel);
Label operationLabel = new Label("operationLabel", parentPage.getString("FeedbackAlertMessageDetails.operation"));
operationLabel.setOutputMarkupId(true);
operationPanel.add(operationLabel);
Label operation = new Label("operation", new LoadableModel<Object>() {
private static final long serialVersionUID = 1L;
@Override
protected Object load() {
OpResult result = getModelObject();
String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
return getPage().getString(resourceKey, null, resourceKey);
}
});
operation.setOutputMarkupId(true);
operationPanel.add(operation);
Label count = new Label("countLabel", parentPage.getString("FeedbackAlertMessageDetails.count"));
count.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
OpResult result = getModelObject();
return result.getCount() > 1;
}
});
operationPanel.add(count);
operationPanel.add(initCountPanel(getModel()));
Label message = new Label("resultMessage", // PageBase.new
new PropertyModel<String>(getModel(), "message").getObject());
// PropertyModel<String>(model,
// "message"));
message.setOutputMarkupId(true);
message.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return StringUtils.isNotBlank(getModelObject().getMessage());
}
});
operationPanel.add(message);
Label messageLabel = new Label("messageLabel", parentPage.getString("FeedbackAlertMessageDetails.message"));
messageLabel.setOutputMarkupId(true);
messageLabel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return StringUtils.isNotBlank(getModelObject().getMessage());
}
});
operationPanel.add(messageLabel);
initParams(operationPanel, getModel(), parentPage);
initContexts(operationPanel, getModel(), parentPage);
initError(operationPanel, getModel(), parentPage);
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class Wizard method initLayout.
protected void initLayout() {
Form form = new Form(ID_FORM);
add(form);
IModel<List<WizardStepDto>> stepsModel = new LoadableModel<List<WizardStepDto>>() {
@Override
protected List<WizardStepDto> load() {
return loadSteps();
}
};
WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel) {
@Override
public IWizardStep getActiveStep() {
if (Wizard.this.getModel() != null && Wizard.this.getModel().getObject() != null) {
return Wizard.this.getModel().getObject().getActiveStep();
}
return null;
}
@Override
public void changeStepPerformed(AjaxRequestTarget target, WizardStepDto dto) {
changeStep(target, dto);
}
};
steps.setOutputMarkupId(true);
steps.setVisible(hasMoreThanOneStep());
form.add(steps);
WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
form.add(header);
WebMarkupContainer view = new WebMarkupContainer(ID_VIEW);
form.add(view);
WizardIssuesPanel issuesPanel = new WizardIssuesPanel(ID_ISSUES, issuesModel);
issuesPanel.setOutputMarkupId(true);
form.add(issuesPanel);
WizardButtonBar buttons = new WizardButtonBar(ID_BUTTONS, this);
buttons.setOutputMarkupId(true);
form.add(buttons);
WebMarkupContainer autoSaveNote = new WebMarkupContainer(ID_AUTO_SAVE_NOTE);
autoSaveNote.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
return !wizardPage.isConfigurationOnly() && !wizardPage.isReadOnly();
}
});
form.add(autoSaveNote);
WebMarkupContainer readOnlyNote = new WebMarkupContainer(ID_READ_ONLY_NOTE);
readOnlyNote.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
return wizardPage.isReadOnly();
}
});
form.add(readOnlyNote);
readOnlyNote.add(new AjaxFallbackLink<String>(ID_READ_ONLY_SWITCH) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
// e.g. to switch configuration models to read-write
wizardPage.resetModels();
wizardPage.setReadOnly(false);
ajaxRequestTarget.add(wizardPage);
}
});
IWizardModel wizard = getWizardModel();
wizard.addListener(this);
wizard.reset();
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class AbstractOrgTabPanel method initLayout.
private void initLayout() {
final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {
private static final long serialVersionUID = 1L;
@Override
protected List<ITab> load() {
LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
roots = loadOrgRoots();
final List<ITab> tabs = new ArrayList<>();
for (PrismObject<OrgType> root : roots) {
final String oid = root.getOid();
tabs.add(new AbstractTab(createTabTitle(root)) {
private static final long serialVersionUID = 1L;
private int tabId = tabs.size();
@Override
public WebMarkupContainer getPanel(String panelId) {
add(new AjaxEventBehavior("load") {
private static final long serialVersionUID = 1L;
protected void onEvent(final AjaxRequestTarget target) {
SessionStorage storage = getPageBase().getSessionStorage();
storage.getUsers().setSelectedTabId(tabId);
}
});
Panel panel = createTreePanel(panelId, new Model(oid), getPageBase());
panel.setOutputMarkupId(true);
return panel;
}
});
}
LOGGER.debug("Tab count is {}", new Object[] { tabs.size() });
return tabs;
}
};
final SessionStorage storage = getPageBase().getSessionStorage();
int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
List<ITab> tabsList = tabModel.getObject();
if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
storage.getUsers().setSelectedTabId(0);
selectedTab = 0;
}
AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<ITab>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {
private static final long serialVersionUID = 1L;
@Override
public TabbedPanel<ITab> setSelectedTab(int index) {
changeTabPerformed(index);
return super.setSelectedTab(index);
}
};
tabbedPanel.setOutputMarkupId(true);
if (tabsList == null || tabsList.size() == 0) {
tabbedPanel.setVisible(false);
}
add(tabbedPanel);
}
use of com.evolveum.midpoint.gui.api.model.LoadableModel in project midpoint by Evolveum.
the class AbstractTreeTablePanel method refreshTabbedPanel.
protected void refreshTabbedPanel(AjaxRequestTarget target) {
PageBase page = getPageBase();
TabbedPanel tabbedPanel = findParent(TabbedPanel.class);
IModel<List<ITab>> tabs = tabbedPanel.getTabs();
if (tabs instanceof LoadableModel) {
((LoadableModel) tabs).reset();
}
if (tabs.getObject() != null && tabs.getObject().size() > 0) {
tabbedPanel.setSelectedTab(0);
}
target.add(tabbedPanel);
target.add(page.getFeedbackPanel());
}
Aggregations