remove = new ToolButton("Remove", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final SingleSelectionModel<WorkmanagerPool> selectionModel = (SingleSelectionModel<WorkmanagerPool>) table.getSelectionModel();
final WorkmanagerPool pool = selectionModel.getSelectedObject();
if (pool.isShortRunning()) {
Console.error("Pool cannot be removed", "A short running pool is mandatory!");
} else {
Feedback.confirm(
"Remove Pool Configuration",
"Really remove this pool configuration?",
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
presenter.onRemovePoolConfig(
contextName, pool
);
}
}
});
}
}
});
topLevelTools.addToolButtonRight(remove);
// ---
attributesForm = new Form<WorkmanagerPool>(WorkmanagerPool.class);
attributesForm.setNumColumns(2);
attributesForm.setEnabled(false);
TextItem nameItem = new TextItem("name", "Name");
CheckBoxItem blocking = new CheckBoxItem ("blocking", "Is Blocking?");
CheckBoxItem allowCore = new CheckBoxItem ("allowCoreTimeout", "Allow Core Timeout?");
NumberBoxItem keepAliveTimeout = new NumberBoxItem("keepaliveTimeout", "Keep Alive Timeout (ms)") {
{
isRequired = false;
}
};
TextBoxItem threadFactory = new TextBoxItem("threadFactory", "Thread Factory") {
{
isRequired = false;
}
};
TextBoxItem handoff = new TextBoxItem("handoffExecutor", "Handoff Executor") {
{
isRequired = false;
}
};
attributesForm.setFields(nameItem, keepAliveTimeout, blocking, allowCore, threadFactory, handoff);
// ---
sizingForm = new Form<WorkmanagerPool>(WorkmanagerPool.class);
sizingForm.setNumColumns(2);
sizingForm.setEnabled(false);
NumberBoxItem maxThreads = new NumberBoxItem("maxThreadsCount", "Max Threads");
NumberBoxItem maxThreadsPerCPU = new NumberBoxItem("maxThreadsPerCPU", "Max Threads/CPU");
NumberBoxItem queueLength = new NumberBoxItem("queueLengthCount", "Queue Length");
NumberBoxItem queueLengthPerCPU = new NumberBoxItem("queueLengthPerCPU", "Queue Length/CPU");
sizingForm.setFields(nameItem, maxThreads, maxThreadsPerCPU, queueLength, queueLengthPerCPU);
attributesForm.bind(table);
sizingForm.bind(table);
FormToolStrip<WorkmanagerPool> sizingTools = new FormToolStrip<WorkmanagerPool>(
sizingForm,
new FormToolStrip.FormCallback<WorkmanagerPool>() {
@Override
public void onSave(Map<String, Object> changeset) {
presenter.onSavePoolConfig(
contextName,
attributesForm.getEditedEntity(),
changeset
);
}
@Override
public void onDelete(WorkmanagerPool entity) {
}
}
);
sizingTools.providesDeleteOp(false);
FormToolStrip<WorkmanagerPool> attributesTools = new FormToolStrip<WorkmanagerPool>(
attributesForm,
new FormToolStrip.FormCallback<WorkmanagerPool>() {
@Override
public void onSave(Map<String, Object> changeset) {
presenter.onSavePoolConfig(
contextName,
attributesForm.getEditedEntity(),
changeset
);
}
@Override
public void onDelete(WorkmanagerPool entity) {
}
}
);
attributesTools.providesDeleteOp(false);
Widget attributesPanel = new FormLayout()
.setForm(attributesForm)
.setSetTools(attributesTools)
.build();
Widget sizingPanel = new FormLayout()
.setForm(sizingForm)
.setSetTools(sizingTools)
.build();
// ---
propertyEditor = new PropertyEditor(presenter);
headline = new Label("HEADLINE");
headline.setStyleName("content-header-label");
// ---
Widget panel = new MultipleToOneLayout()
.setPlain(true)
.setHeadlineWidget(headline)
.setTitle("Thread Pool")
.setDescription("Thread pool configurations used by a JCA workmanager.")
.setMaster("Configured Thread Pools", table)
.setMasterTools(topLevelTools.asWidget())
.addDetail("Attributes", attributesPanel)
.addDetail("Sizing", sizingPanel)
.addDetail("Properties", propertyEditor.asWidget())
.build();
table.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
WorkmanagerPool pool = ((SingleSelectionModel<WorkmanagerPool>) table.getSelectionModel()).getSelectedObject();
String ref = createReferenceToken(pool);
propertyEditor.setProperties(ref, pool.getProperties());
}
});
return panel;
}