blob: 06b70de0ba34eb7042514286baa0ba7f8422b374 [file] [log] [blame]
/**
*
* 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 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* 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;
private VerticalLayout inner;
public BpmnWindow(IBPMEngine bpmEngine, IBlipBPMFunctionProvider blip, IEclipseContext context) {
super();
setClosable(true);
setModal(false);
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);
inner.setHeight(height, Unit.PIXELS);
inner.setWidth(width, Unit.PIXELS);
if ( !bpmnRenderer.drawBpmn(processId) ) {
closeBpmn();
}
}
});
}
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);
}
}