final MosaicPanel toolBox = new MosaicPanel();
toolBox.setPadding(0);
toolBox.setWidgetSpacing(5);
final ToolBar toolBar = new ToolBar();
refreshBtn = new Button("Refresh", new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
controller.handleEvent(
new Event(
UpdateInstancesAction.ID,
getCurrentDefinition()
)
);
}
}
);
toolBar.add(refreshBtn);
refreshBtn.setEnabled(false);
toolBar.addSeparator();
startBtn = new Button("Start", new ClickHandler()
{
public void onClick(ClickEvent clickEvent)
{
MessageBox.confirm("Start new execution",
"Do you want to start a new execution of this process?",
new MessageBox.ConfirmationCallback()
{
public void onResult(boolean doIt)
{
if (doIt)
{
String url = getCurrentDefinition().getFormUrl();
boolean hasForm = (url != null && !url.equals(""));
if (hasForm)
{
ProcessDefinitionRef definition = getCurrentDefinition();
iframeWindow = new IFrameWindowPanel(
definition.getFormUrl(), "New Process Instance: " + definition.getId()
);
iframeWindow.setCallback(
new IFrameWindowCallback()
{
public void onWindowClosed()
{
controller.handleEvent(
new Event(UpdateInstancesAction.ID, getCurrentDefinition())
);
}
}
);
iframeWindow.show();
}
else
{
controller.handleEvent(
new Event(
StartNewInstanceAction.ID,
getCurrentDefinition()
)
);
}
}
}
});
}
}
);
terminateBtn = new Button("Terminate", new ClickHandler()
{
public void onClick(ClickEvent clickEvent)
{
if (getSelection() != null)
{
MessageBox.confirm("Terminate instance",
"Terminating this instance will stop further execution.",
new MessageBox.ConfirmationCallback()
{
public void onResult(boolean doIt)
{
if (doIt)
{
ProcessInstanceRef selection = getSelection();
if (selection.getState().equals(ProcessInstanceRef.STATE.ENDED)) {
MessageBox.alert("Info", "Process is already completed");
} else {
selection.setState(ProcessInstanceRef.STATE.ENDED);
selection.setEndResult(ProcessInstanceRef.RESULT.OBSOLETE);
controller.handleEvent(
new Event(
StateChangeAction.ID,
selection
)
);
}
}
}
});
}
else
{
MessageBox.alert("Missing selection", "Please select an instance");
}
}
}
);
deleteBtn = new Button("Delete", new ClickHandler()
{
public void onClick(ClickEvent clickEvent)
{
if (getSelection() != null)
{
MessageBox.confirm("Delete instance",
"Deleting this instance will remove any history information and associated tasks as well.",
new MessageBox.ConfirmationCallback()
{
public void onResult(boolean doIt)
{
if (doIt)
{
try {
ProcessInstanceRef selection = getSelection();
if (selection.getState().equals(ProcessInstanceRef.STATE.ENDED)) {
MessageBox.alert("Info", "Process is already completed");
} else {
selection.setState(ProcessInstanceRef.STATE.ENDED);
controller.handleEvent(
new Event(
DeleteInstanceAction.ID,
selection
)
);
}
} catch (Exception e) {
MessageBox.alert("Warning", e.getMessage());
}
}
}
});
}
else
{
MessageBox.alert("Missing selection", "Please select an instance");
}
}
}
);
signalBtn = new Button("Signal", new ClickHandler()
{
public void onClick(ClickEvent clickEvent)
{
if (getSelection() != null)
{
createSignalWindow();
}
else
{
MessageBox.alert("Missing selection", "Please select an instance");
}
}
}
);
if(!isRiftsawInstance) // riftsaw doesn't support instance operations
{
toolBar.add(startBtn);
toolBar.add(signalBtn);
toolBar.add(deleteBtn);
startBtn.setEnabled(false);
deleteBtn.setEnabled(false);
signalBtn.setEnabled(false);
}
// terminate works on any BPM Engine
toolBar.add(terminateBtn);
terminateBtn.setEnabled(false);
toolBox.add(toolBar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));