editLink.setTitle("Edit Job");
addControl(editLink);
pauseLink.setAttribute("class", "actionIcon");
pauseLink.setTitle("Pause Job");
pauseLink.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
String name = pauseLink.getValue();
getSchedulerService().pauseJob(name);
setFlashMessage("Paused job '" + name + "'");
return true;
}
});
addControl(pauseLink);
interruptLink.setAttribute("class", "actionIcon");
interruptLink.setTitle("Interrupt Running Job");
interruptLink.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
String name = interruptLink.getValue();
if (getSchedulerService().interruptJob(name)) {
setFlashMessage("Interrupted job '" + name + "'");
} else {
setFlashMessage("Could not interrupt job '" + name + "'");
}
return true;
}
});
addControl(interruptLink);
triggerLink.setAttribute("class", "actionIcon");
triggerLink.setTitle("Trigger Job");
triggerLink.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
String name = triggerLink.getValue();
getSchedulerService().triggerJob(name);
setFlashMessage("Triggered job '" + name + "'");
return true;
}
});
addControl(triggerLink);
resumeLink.setAttribute("class", "actionIcon");
resumeLink.setTitle("Resume Job");
resumeLink.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
String name = resumeLink.getValue();
getSchedulerService().resumeJob(name);
setFlashMessage("Resumed job '" + name + "'");
return true;
}
});
addControl(resumeLink);
deleteLink.setAttribute("class", "actionIcon");
deleteLink.setTitle("Delete Job");
String confirmMessage = getMessage("deleteConfirm", "Job");
deleteLink.setAttribute("onclick", "return window.confirm('" + confirmMessage + "')");
deleteLink.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
String name = deleteLink.getValue();
if (getSchedulerService().deleteJob(name)) {
setFlashMessage("Deleted job '" + name + "'");
} else {
setFlashMessage("Could not delete " + name);
}
return true;
}
});
addControl(deleteLink);
// Add table action column if user has edit or delete permissions
final Column actionColumn = new Column("action");
// Render action controls based on users permission
actionColumn.setDecorator(new Decorator() {
public String render(Object object, Context context) {
JobAndSimpleTrigger jobAndTrigger = (JobAndSimpleTrigger) object;
HtmlStringBuffer buffer = new HtmlStringBuffer();
editLink.setParameter("job.name", jobAndTrigger.getJob().getName());
editLink.render(buffer);
buffer.append(" | ");
deleteLink.setValue(jobAndTrigger.getJob().getName());
deleteLink.render(buffer);
if (!getSchedulerService().isPaused()) {
if (jobAndTrigger.getTriggerState() == Trigger.STATE_PAUSED) {
buffer.append(" | ");
resumeLink.setValue(jobAndTrigger.getJob().getName());
resumeLink.render(buffer);
} else {
buffer.append(" | ");
pauseLink.setValue(jobAndTrigger.getJob().getName());
pauseLink.render(buffer);
}
buffer.append(" | ");
triggerLink.setValue(jobAndTrigger.getJob().getName());
triggerLink.render(buffer);
if (jobAndTrigger.getTriggerState() == Trigger.STATE_BLOCKED) {
buffer.append(" | ");
interruptLink.setValue(jobAndTrigger.getJob().getName());
interruptLink.render(buffer);
}
}
return buffer.toString();
}
});
actionColumn.setSortable(false);
table.addColumn(actionColumn);
// Add Control Buttons.
newJob.setActionListener(new ActionListener(){
private static final long serialVersionUID = 1L;
public boolean onAction(Control source) {
setRedirect(QuartzJobAndTriggerPage.class);
return false;