this.session = session;
this.i18NSource = i18NSource;
BeanItemContainer<ProcessDefinitionConfig> bic = new BeanItemContainer<ProcessDefinitionConfig>(ProcessDefinitionConfig.class);
final ComboBox l = new ComboBox(getMessage("tasks.processType"), bic);
ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
for (ProcessDefinitionConfig cfg : session.getAvailableConfigurations(ctx)) {
bic.addItem(cfg);
l.setItemCaption(cfg, getMessage(cfg.getDescription()));
}
if (bic.size() != 0) {
l.setValue(bic.firstItemId());
}
l.setNullSelectionAllowed(false);
l.setNewItemsAllowed(false);
l.setFilteringMode(ComboBox.FILTERINGMODE_OFF);
l.setCaption(null);//getMessage("newProcess.caption"));
Button b = new Button(getMessage("newProcess.start"));
b.addStyleName("small default");
b.addListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
if (l.getValue() == null) {
return;
}
withErrorHandling(getApplication(), new Runnable() {
public void run() {
ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
ProcessDefinitionConfig cfg = (ProcessDefinitionConfig) l.getValue();
cfg = ctx.getProcessDefinitionDAO().getActiveConfigurationByKey(cfg.getBpmDefinitionKey());
ProcessInstance instance = session.createProcessInstance(cfg, null, ctx, null, null, "portlet", null);
getWindow().showNotification(getMessage("newProcess.started"), 2000);
getWindow().executeJavaScript("Liferay.trigger('processtool.bpm.newProcess', '" + instance.getInternalId() + "');");
getWindow().executeJavaScript("vaadin.forceSync();");