* @param focus
*
* @return The graph canvas created
*/
public GraphCanvas newGraphCanvas(boolean focus) {
GraphCanvas newGraphCanvas = new GraphCanvas(this.engine);
this.graphCanvases.add(newGraphCanvas);
this.graphTabbedPane.addTab("Workflow",
newGraphCanvas.getSwingComponent());
if (focus) {
setFocus(newGraphCanvas);
}
newGraphCanvas.addGraphCanvasListener(this.componentViewer);
newGraphCanvas.addGraphCanvasListener(this.portViewer);
newGraphCanvas.addGraphCanvasListener(new GraphCanvasListener() {
public void graphCanvasChanged(GraphCanvasEvent event) {
GraphCanvasEventType type = event.getType();
final GraphCanvas graphCanvas = event.getGraphCanvas();
final Workflow workflow = event.getWorkflow();
switch (type) {
case GRAPH_LOADED:
case NAME_CHANGED:
SwingUtilities.invokeLater(new Runnable() {
public void run() {
String name = workflow.getName();
// Change the name of the tab.
int index = XBayaGUI.this.graphTabbedPane
.indexOfComponent(graphCanvas
.getSwingComponent());
XBayaGUI.this.graphTabbedPane.setTitleAt(index,
workflow.getName());
// Change the name of the frame.