| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.utils.vaadin.bpmn; |
| |
| import org.eclipse.e4.core.contexts.IEclipseContext; |
| import org.eclipse.osbp.bpm.api.IBPMEngine; |
| import org.eclipse.osbp.bpm.api.IBlipBPMFunctionProvider; |
| import org.slf4j.Logger; |
| |
| import com.vaadin.server.ClientConnector; |
| import com.vaadin.server.Page; |
| import com.vaadin.ui.UI; |
| import com.vaadin.ui.VerticalLayout; |
| import com.vaadin.ui.Window; |
| |
| @SuppressWarnings("all") |
| public class BpmnWindow extends Window implements ClientConnector.DetachListener { |
| private static Logger log = org.slf4j.LoggerFactory |
| .getLogger(BpmnWindow.class); |
| |
| private boolean isAttached = false; |
| private BpmnRenderer bpmnRenderer; |
| private float width = 820; |
| private float height = 650; |
| |
| public BpmnWindow(IBPMEngine bpmEngine, IBlipBPMFunctionProvider blip, IEclipseContext context) { |
| super(); |
| setClosable(true); |
| setModal(false); |
| VerticalLayout inner = new VerticalLayout(); |
| inner.setMargin(false); |
| inner.setSizeFull(); |
| setContent(inner); |
| inner.setPrimaryStyleName("osbp"); |
| addDetachListener(this); |
| bpmnRenderer = new BpmnRenderer(bpmEngine, blip, context); |
| inner.addComponent(bpmnRenderer); |
| } |
| |
| public void showBpmn(String processId) { |
| if(!isAttached) { |
| UI.getCurrent().addWindow(this); |
| isAttached = true; |
| } |
| UI.getCurrent().access(new Runnable() { |
| @Override |
| public void run() { |
| setPosition(Page.getCurrent().getBrowserWindowWidth()-(int)width, Page.getCurrent().getBrowserWindowHeight()-(int)height); |
| setHeight(height, Unit.PIXELS); |
| setWidth(width, Unit.PIXELS); |
| bpmnRenderer.drawBpmn(processId); |
| bpmnRenderer.setSelectedCell("ScriptTask_1"); |
| } |
| }); |
| } |
| |
| public void closeBpmn() { |
| if(isAttached) { |
| bpmnRenderer.dispose(); |
| UI.getCurrent().removeWindow(this); |
| } |
| } |
| |
| @Override |
| public void detach(DetachEvent event) { |
| bpmnRenderer.dispose(); |
| isAttached = false; |
| } |
| |
| public void selectTask(String taskName) { |
| bpmnRenderer.setSelectedCell(taskName); |
| } |
| |
| } |