use of org.apache.wicket.ajax.AbstractAjaxTimerBehavior in project midpoint by Evolveum.
the class PageFocusDetails method onConfigure.
@Override
protected void onConfigure() {
super.onConfigure();
if (saveOnConfigure) {
saveOnConfigure = false;
add(new AbstractAjaxTimerBehavior(Duration.ofMillis(100)) {
@Override
protected void onTimer(AjaxRequestTarget target) {
stop(target);
savePerformed(target);
}
});
}
}
use of org.apache.wicket.ajax.AbstractAjaxTimerBehavior in project hale by halestudio.
the class StatusPage method addControls.
@Override
protected void addControls(boolean loggedIn) {
super.addControls(loggedIn);
final String workspaceId = getPageParameters().get(PARAMETER_WORKSPACE).toOptionalString();
if (workspaceId == null || workspaceId.isEmpty()) {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Workspace ID not specified.");
}
try {
workspaces.getWorkspaceFolder(workspaceId);
} catch (FileNotFoundException e) {
throw new AbortWithHttpErrorCodeException(HttpServletResponse.SC_NOT_FOUND, "Workspace does not exist.");
}
final IModel<TransformationWorkspace> workspace = new LoadableDetachableModel<TransformationWorkspace>() {
private static final long serialVersionUID = 2600444242247550094L;
@Override
protected TransformationWorkspace load() {
return new TransformationWorkspace(workspaceId);
}
};
// job panel
final Serializable family = AbstractTransformationJob.createFamily(workspaceId);
final JobPanel jobs = new JobPanel("jobs", family, true);
add(jobs);
// status
final Label status = new Label("status", new LoadableDetachableModel<String>() {
private static final long serialVersionUID = -4351763182104835300L;
@Override
protected String load() {
if (workspace.getObject().isTransformationFinished()) {
if (workspace.getObject().isTransformationSuccessful()) {
return "Transformation completed.";
} else {
return "Transformation failed.";
}
} else {
if (Job.getJobManager().find(family).length > 0) {
return "Transformation is running:";
} else {
return "No transformation running.";
}
}
}
});
status.setOutputMarkupId(true);
add(status);
// result
final WebMarkupContainer result = new WebMarkupContainer("result");
result.setOutputMarkupId(true);
add(result);
final WebMarkupContainer update = new WebMarkupContainer("update") {
private static final long serialVersionUID = -2591480922683644827L;
@Override
public boolean isVisible() {
return workspace.getObject().isTransformationFinished();
}
};
result.add(update);
// result : report
File reportFile = workspace.getObject().getReportFile();
DownloadLink report = new DownloadLink("log", reportFile, reportFile.getName());
update.add(report);
// result : file list
IModel<? extends List<File>> resultFilesModel = new LoadableDetachableModel<List<File>>() {
private static final long serialVersionUID = -7971872898614031331L;
@Override
protected List<File> load() {
return Arrays.asList(workspace.getObject().getTargetFolder().listFiles());
}
};
final ListView<File> fileList = new ListView<File>("file", resultFilesModel) {
private static final long serialVersionUID = -8045643864251639540L;
@Override
protected void populateItem(ListItem<File> item) {
// download link
DownloadLink download = new DownloadLink("download", item.getModelObject(), item.getModelObject().getName());
item.add(download);
// file name
download.add(new Label("name", item.getModelObject().getName()));
}
};
update.add(fileList);
// leaseEnd
String leaseEnd;
try {
leaseEnd = workspaces.getLeaseEnd(workspaceId).toString(DateTimeFormat.mediumDateTime());
} catch (IOException e) {
leaseEnd = "unknown";
}
add(new Label("leaseEnd", leaseEnd));
boolean transformationFinished = workspace.getObject().isTransformationFinished();
if (transformationFinished) {
// disable job timer
jobs.getTimer().stopOnNextUpdate();
} else {
// timer
add(new AbstractAjaxTimerBehavior(Duration.milliseconds(1500)) {
private static final long serialVersionUID = -3726349470723024150L;
@Override
protected void onTimer(AjaxRequestTarget target) {
if (workspace.getObject().isTransformationFinished()) {
// update status and result
target.add(status);
target.add(result);
// stop timers
stop(target);
jobs.getTimer().stopOnNextUpdate();
}
}
});
}
}
use of org.apache.wicket.ajax.AbstractAjaxTimerBehavior in project wicket by apache.
the class AjaxLazyLoadPanel method initTimer.
/**
* Initialize a timer - default implementation installs an {@link AbstractAjaxTimerBehavior} on the page,
* if it is not already present.
*/
protected void initTimer() {
// when the timer is not yet installed add it
List<AjaxLazyLoadTimer> behaviors = getPage().getBehaviors(AjaxLazyLoadTimer.class);
if (behaviors.isEmpty()) {
AbstractAjaxTimerBehavior timer = new AjaxLazyLoadTimer();
getPage().add(timer);
getRequestCycle().find(AjaxRequestTarget.class).ifPresent(target -> {
// the timer will not be rendered, so restart it immediately on the Ajax target
timer.restart(target);
});
}
}
use of org.apache.wicket.ajax.AbstractAjaxTimerBehavior in project midpoint by Evolveum.
the class PageAdminObjectDetails method onConfigure.
@Override
protected void onConfigure() {
super.onConfigure();
if (saveOnConfigure) {
saveOnConfigure = false;
add(new AbstractAjaxTimerBehavior(Duration.ofMillis(100)) {
@Override
protected void onTimer(AjaxRequestTarget target) {
stop(target);
savePerformed(target);
}
});
}
}
Aggregations