use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class ProgressPanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
PageBase page = getPageBase();
WebApplicationConfiguration config = page.getWebApplicationConfiguration();
ProgressReporter reporter = new ProgressReporter(MidPointApplication.get());
reporter.setRefreshInterval(config.getProgressRefreshInterval());
reporter.setAsynchronousExecution(config.isProgressReportingEnabled());
reporter.setAbortEnabled(config.isAbortEnabled());
reporterModel = new AsyncWebProcessModel<>(reporter);
initLayout();
addRefreshingProgressPanel();
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class OrgTreeAssignablePanel method initLayout.
private void initLayout() {
if (getPreselectedOrgsList() != null) {
allTabsSelectedOrgs.addAll(getPreselectedOrgsList());
}
AbstractOrgTabPanel tabbedPanel = new AbstractOrgTabPanel(ID_ORG_TABS, getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
protected Panel createTreePanel(String id, Model<String> model, PageBase pageBase) {
OrgTreePanel panel = new OrgTreePanel(id, model, selectable, pageBase, "", allTabsSelectedOrgs) {
private static final long serialVersionUID = 1L;
private final OrgStructurePanelStorage storage = new OrgStructurePanelStorage();
@Override
protected IModel<Boolean> getCheckBoxValueModel(IModel<TreeSelectableBean<OrgType>> rowModel) {
return new LoadableModel<>(true) {
@Override
public Boolean load() {
for (OrgType org : allTabsSelectedOrgs) {
if (rowModel.getObject().getValue().getOid().equals(org.getOid())) {
return true;
}
}
return false;
}
};
}
@Override
protected void onOrgTreeCheckBoxSelectionPerformed(AjaxRequestTarget target, IModel<TreeSelectableBean<OrgType>> rowModel) {
if (rowModel != null && rowModel.getObject() != null) {
boolean isAlreadyInList = false;
Iterator<OrgType> it = allTabsSelectedOrgs.iterator();
while (it.hasNext()) {
OrgType org = it.next();
if (org.getOid().equals(rowModel.getObject().getValue().getOid())) {
isAlreadyInList = true;
it.remove();
}
}
if (!isAlreadyInList) {
allTabsSelectedOrgs.add(rowModel.getObject().getValue());
}
}
OrgTreeAssignablePanel.this.onOrgTreeCheckBoxSelectionPerformed(target, rowModel);
}
@Override
protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
onItemSelect(selected, target);
}
@Override
public OrgTreeStateStorage getOrgTreeStateStorage() {
return storage;
}
@Override
protected ObjectFilter getCustomFilter() {
return OrgTreeAssignablePanel.this.getCustomFilter();
}
};
panel.setOutputMarkupId(true);
panel.setOutputMarkupPlaceholderTag(true);
return panel;
}
@Override
protected boolean isWarnMessageVisible() {
return false;
}
@Override
protected ObjectFilter getAssignableItemsFilter() {
return OrgTreeAssignablePanel.this.getCustomFilter();
}
@Override
protected OrgStructurePanelStorage getOrgStructurePanelStorage() {
return null;
}
};
tabbedPanel.setOutputMarkupId(true);
tabbedPanel.setOutputMarkupPlaceholderTag(true);
add(tabbedPanel);
AjaxButton assignButton = new AjaxButton(ID_ASSIGN, getPageBase().createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
assignSelectedOrgPerformed(getAllTabPanelsSelectedOrgs(), target);
}
};
assignButton.setOutputMarkupId(true);
assignButton.setOutputMarkupPlaceholderTag(true);
assignButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isAssignButtonVisible();
}
});
add(assignButton);
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class PageDebugDownloadBehaviour method initFile.
@Override
protected File initFile() {
PageBase page = getPage();
OperationResult result = new OperationResult(OPERATION_CREATE_DOWNLOAD_FILE);
MidPointApplication application = page.getMidpointApplication();
WebApplicationConfiguration config = application.getWebApplicationConfiguration();
File folder = new File(config.getExportFolder());
if (!folder.exists() || !folder.isDirectory()) {
folder.mkdir();
}
String suffix = isUseZip() ? "zip" : "xml";
String currentTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_m_s"));
String fileName = "ExportedData_" + getType().getSimpleName() + "_" + currentTime + "." + suffix;
File file = new File(folder, fileName);
LOGGER.debug("Creating file '{}'.", file.getAbsolutePath());
try (Writer writer = createWriter(file)) {
LOGGER.debug("Exporting objects.");
dumpHeader(writer);
dumpObjectsToStream(writer, result);
dumpFooter(writer);
LOGGER.debug("Export finished.");
result.recomputeStatus();
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't init download link", ex);
result.recordFatalError(getPage().createStringResource("PageDebugDownloadBehaviour.message.initFile.fatalError").getString(), ex);
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
page.showResult(result);
page.getSession().error(page.getString("pageDebugList.message.createFileException"));
LOGGER.debug("Removing file '{}'.", file.getAbsolutePath());
Files.remove(file);
throw new RestartResponseException(PageDebugList.class);
}
return file;
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class PageDebugDownloadBehaviour method dumpObjectsToStream.
private void dumpObjectsToStream(final Writer writer, OperationResult result) throws Exception {
final PageBase page = getPage();
ResultHandler handler = (object, parentResult) -> {
try {
String xml = page.getPrismContext().xmlSerializer().options(createSerializeForExport()).serialize(object);
writer.write('\t');
writer.write(xml);
writer.write('\n');
} catch (IOException | SchemaException ex) {
throw new SystemException(ex.getMessage(), ex);
}
return true;
};
ModelService service = page.getModelService();
GetOperationOptionsBuilder optionsBuilder = page.getSchemaService().getOperationOptionsBuilder().raw().resolveNames();
if (showAllItems) {
optionsBuilder = optionsBuilder.retrieve();
}
service.searchObjectsIterative(type, query, handler, optionsBuilder.build(), page.createSimpleTask(OPERATION_SEARCH_OBJECT), result);
}
use of com.evolveum.midpoint.gui.api.page.PageBase in project midpoint by Evolveum.
the class AsyncDashboardPanel method onUpdateError.
@Override
protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
String message = "Error occurred while fetching data: " + ex.getMessage();
Label errorLabel = new Label(ID_CONTENT, message);
WebMarkupContainer dashboardContent = getDashboardContent();
dashboardContent.replace(errorLabel);
PageBase page = (PageBase) getPage();
showResultIfError(page);
target.add(this, page.getFeedbackPanel());
}
Aggregations