Created
November 7, 2019 23:54
-
-
Save romartin/919e3f07da726fbce717d8ffdbe20577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.kie.workbench.common.stunner.client.lienzo.components.views; | |
import javax.enterprise.context.Dependent; | |
import com.ait.lienzo.client.core.shape.Group; | |
import com.ait.lienzo.client.core.shape.Layer; | |
import org.kie.workbench.common.stunner.client.lienzo.canvas.wires.WiresCanvas; | |
import org.kie.workbench.common.stunner.core.client.canvas.Canvas; | |
import org.kie.workbench.common.stunner.core.client.components.views.EmptyScreen; | |
@Dependent | |
public class LienzoEmptyScreen implements EmptyScreen { | |
// This class contains the pure lienzo "empty screen" implementation object as a field | |
// so it can be showed against some Canvas or hidden. | |
private WiresCanvas canvas; | |
private Group theLienzoEmptyScreenGroupInstance; | |
@Override | |
public void configure(Canvas canvas, String text) { | |
// It allows to configure the lienzo "empty screen" to show different texts, on any Stunner's editor (Canvas) | |
// This way, either BPMN, CM and DMN can reuse this component and just use different text literals | |
this.canvas = (WiresCanvas) canvas; | |
this.theLienzoEmptyScreenGroupInstance = /*create a new lienzo instance here*/; | |
// etc | |
} | |
@Override | |
public void show() { | |
// It shows the "empty screen" into the right "Canvas" | |
// The lienzo object for the "empty screen" will be attached to the "top" canvas layer, instead of the main one, for performance reasons | |
getTargetLayer().add(theLienzoEmptyScreenGroupInstance); | |
batch(); | |
} | |
@Override | |
public void hide() { | |
theLienzoEmptyScreenGroupInstance.removeFromParent(); | |
batch(); | |
} | |
@Override | |
public void destroy() { | |
theLienzoEmptyScreenGroupInstance.removeFromParent(); | |
theLienzoEmptyScreenGroupInstance = null; | |
canvas = null; | |
// etc | |
} | |
private void batch() { | |
getTargetLayer().batch(); | |
} | |
private Layer getTargetLayer() { | |
return canvas.getView().getLayer().getTopLayer(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment