panel.getElement().setId("process-history-search-view");
panel.setPadding(0);
panel.setWidgetSpacing(5);
final ToolBar toolbar = new ToolBar();
panel.add(toolbar, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
toolbar.add(new Button("Search", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (definitionList.getItemCount() < 1) {
return;
}
String proDef = definitionList.getValue(definitionList.getSelectedIndex());
String definitionId = null;
for (ProcessDefinitionRef ref : processDefinitions) {
if (proDef.equals(ref.getName())) {
definitionId = ref.getId();
}
}
String theStatus = processStatusList.getValue(processStatusList.getSelectedIndex());
Date theDate = startTime.getValue();
if (theDate == null) {
theDate = new Date(103,1,1);
}
Date edate = endTime.getValue();
if (edate == null) {
edate = new Date();
}
String ckey = correlationKey.getValue();
ProcessSearchEvent event = new ProcessSearchEvent();
event.setDefinitionKey(definitionId);
event.setStatus(theStatus);
event.setStartTime(theDate.getTime());
event.setEndTime(edate.getTime());
event.setPage(page);
event.setKey(ckey);
controller.handleEvent(new Event(LoadProcessHistoryAction.ID, event));
}
}) );
final MosaicPanel formPanel = new MosaicPanel(new BoxLayout(BoxLayout.Orientation.VERTICAL));
panel.add(formPanel, new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL));
BoxLayoutData bld1 = new BoxLayoutData(BoxLayoutData.FillStyle.HORIZONTAL);
bld1.setPreferredWidth("130px");
final MosaicPanel processDefBox = new MosaicPanel(new BoxLayout());
processDefBox.add(new Label("Process Definition: "), bld1);
definitionList = new ListBox();
for (ProcessDefinitionRef ref : processDefinitions) {
definitionList.addItem(ref.getName());
}
processDefBox.add(definitionList);
formPanel.add(processDefBox);
formPanel.add(createProcessStatusListBox(bld1));
formPanel.add(createCorrelationKeyTextBox(bld1));
formPanel.add(createStartTimeDateBox(bld1));
formPanel.add(createEndTimeDateBox(bld1));
prevButton=new Button("<< Previous", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (definitionList.getItemCount() < 1) {
return;
}
String proDef = definitionList.getValue(definitionList.getSelectedIndex());
String definitionId = null;
for (ProcessDefinitionRef ref : processDefinitions) {
if (proDef.equals(ref.getName())) {
definitionId = ref.getId();
}
}
String theStatus = processStatusList.getValue(processStatusList.getSelectedIndex());
Date theDate = startTime.getValue();
if (theDate == null) {
theDate = new Date(103,1,1);
}
Date edate = endTime.getValue();
if (edate == null) {
edate = new Date();
}
String ckey = correlationKey.getValue();
ProcessSearchEvent event = new ProcessSearchEvent();
event.setDefinitionKey(definitionId);
event.setStatus(theStatus);
event.setStartTime(theDate.getTime());
event.setEndTime(edate.getTime());
page--;
if (page == 0) {
prevButton.setEnabled(false);
}
pageLabel.setText(""+(page+1));
event.setPage(page);
event.setKey(ckey);
controller.handleEvent(new Event(LoadProcessHistoryAction.ID, event));
}
});
prevButton.setEnabled(false);
nextButton=new Button("Next >>", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
if (definitionList.getItemCount() < 1) {
return;
}
String proDef = definitionList.getValue(definitionList.getSelectedIndex());
String definitionId = null;
for (ProcessDefinitionRef ref : processDefinitions) {
if (proDef.equals(ref.getName())) {
definitionId = ref.getId();
}
}
String theStatus = processStatusList.getValue(processStatusList.getSelectedIndex());
Date theDate = startTime.getValue();
if (theDate == null) {
theDate = new Date(103,1,1);
}
Date edate = endTime.getValue();
if (edate == null) {
edate = new Date();
}
String ckey = correlationKey.getValue();
ProcessSearchEvent event = new ProcessSearchEvent();
event.setDefinitionKey(definitionId);
event.setStatus(theStatus);
event.setStartTime(theDate.getTime());
event.setEndTime(edate.getTime());
page++;
pageLabel.setText(""+(page+1));
event.setPage(page);
event.setKey(ckey);
controller.handleEvent(new Event(LoadProcessHistoryAction.ID, event));
}
});
nextButton.setEnabled(false);
MosaicPanel buttonBox = new MosaicPanel(new BoxLayout());
buttonBox.add(prevButton);
buttonBox.add(nextButton);
pageLabel = new Label("1");
buttonBox.add(pageLabel);
buttonBox.setWidgetSpacing(10);
panel.add(buttonBox, new BoxLayoutData());
ProcessHistoryInstanceListView listview = new ProcessHistoryInstanceListView();
final DecoratedTabLayoutPanel tabPanel = new DecoratedTabLayoutPanel(false);
listview.provideWidget(new ProvisioningCallback(){
@Override
public void onSuccess(Widget instance) {
tabPanel.add(instance, "History Instances");
}
@Override
public void onUnavailable() {
}
});
panel.add(tabPanel, new BoxLayoutData(BoxLayoutData.FillStyle.BOTH));
callback.onSuccess(panel);
}