Search in sources :

Example 1 with GraphCanvasEventType

use of org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType in project airavata by apache.

the class ComponentViewer method graphCanvasChanged.

/**
 * @see org.apache.airavata.xbaya.ui.graph.GraphCanvasListener#graphCanvasChanged(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent)
 */
public void graphCanvasChanged(GraphCanvasEvent event) {
    GraphCanvasEventType type = event.getType();
    GraphCanvas graphCanvas = event.getGraphCanvas();
    switch(type) {
        case NODE_SELECTED:
            Node node = graphCanvas.getSelectedNode();
            if (node == null) {
                setComponent(null);
            } else {
                setComponent(node.getComponent());
            }
            break;
        case GRAPH_LOADED:
        case NAME_CHANGED:
        case INPUT_PORT_SELECTED:
        case OUTPUT_PORT_SELECTED:
    }
}
Also used : GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) Node(org.apache.airavata.workflow.model.graph.Node) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 2 with GraphCanvasEventType

use of org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType in project airavata by apache.

the class PortViewer method graphCanvasChanged.

/**
 * @see org.apache.airavata.xbaya.ui.graph.GraphCanvasListener#graphCanvasChanged(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent)
 */
public void graphCanvasChanged(GraphCanvasEvent event) {
    GraphCanvasEventType type = event.getType();
    GraphCanvas graphCanvas = event.getGraphCanvas();
    switch(type) {
        case INPUT_PORT_SELECTED:
            Port inputPort = graphCanvas.getSelectedInputPort();
            setInputPort(inputPort);
            break;
        case OUTPUT_PORT_SELECTED:
            Port outputPort = graphCanvas.getSelectedOutputPort();
            setOutputPort(outputPort);
            break;
        case GRAPH_LOADED:
        case NAME_CHANGED:
        case NODE_SELECTED:
    }
}
Also used : GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 3 with GraphCanvasEventType

use of org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType in project airavata by apache.

the class XBayaGUI method getNewGraphCanvas.

public GraphCanvas getNewGraphCanvas(String wfName, String wfDescription) {
    GraphCanvas newGraphCanvas = new GraphCanvas(this.engine, wfName);
    newGraphCanvas.setDescription(wfDescription);
    this.graphCanvases.add(newGraphCanvas);
    this.graphTabbedPane.addTab(newGraphCanvas.getWorkflow().getName(), newGraphCanvas.getSwingComponent());
    final int index = graphTabbedPane.getTabCount() - 1;
    TabLabelButton tabLabelButton = new TabLabelButton(graphTabbedPane, "Close this workflow");
    graphTabbedPane.setTabComponentAt(index, tabLabelButton);
    tabLabelButton.setCloseButtonListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeGraphCanvasFromIndex(index);
        }
    });
    graphTabbedPane.addContainerListener(new ContainerListener() {

        @Override
        public void componentAdded(ContainerEvent event) {
        }

        @Override
        public void componentRemoved(ContainerEvent event) {
            List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
            for (GraphCanvas graphCanvas : graphCanvases) {
                if (graphCanvas.getSwingComponent() == event.getComponent()) {
                    if (graphCanvas.isWorkflowChanged()) {
                        setFocus(graphCanvas);
                        if (JOptionPane.showConfirmDialog(null, "The workflow '" + graphCanvas.getWorkflow().getName() + "' has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                            graphFiler.saveWorkflow(graphCanvas);
                        }
                    }
                    break;
                }
            }
        }
    });
    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.
                            updateTabTitle(graphCanvas, workflow);
                            // Change the name of the frame.
                            setFrameName(name);
                        }
                    });
                    break;
                case NODE_SELECTED:
                case INPUT_PORT_SELECTED:
                case OUTPUT_PORT_SELECTED:
                // Do nothing
                case WORKFLOW_CHANGED:
                    updateTabTitle(graphCanvas, graphCanvas.getWorkflow());
                    setFrameName(workflow.getName());
                    for (ChangeListener listener : tabChangeListeners) {
                        try {
                            listener.stateChanged(null);
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
            }
        }

        private void updateTabTitle(final GraphCanvas graphCanvas, final Workflow workflow) {
            int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
            String newTitle = workflow.getName();
            if (graphCanvas.isWorkflowChanged()) {
                newTitle = "*" + newTitle;
            }
            XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
        }
    });
    return newGraphCanvas;
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) TabLabelButton(org.apache.airavata.xbaya.ui.widgets.TabLabelButton) ActionEvent(java.awt.event.ActionEvent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) ActionListener(java.awt.event.ActionListener) GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) GraphCanvasListener(org.apache.airavata.xbaya.ui.graph.GraphCanvasListener) ContainerListener(java.awt.event.ContainerListener) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ChangeListener(javax.swing.event.ChangeListener) GraphCanvasEvent(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Aggregations

GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)3 GraphCanvasEventType (org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType)3 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ContainerEvent (java.awt.event.ContainerEvent)1 ContainerListener (java.awt.event.ContainerListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ChangeListener (javax.swing.event.ChangeListener)1 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)1 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 DataPort (org.apache.airavata.workflow.model.graph.DataPort)1 Node (org.apache.airavata.workflow.model.graph.Node)1 Port (org.apache.airavata.workflow.model.graph.Port)1 Workflow (org.apache.airavata.workflow.model.wf.Workflow)1 MonitorException (org.apache.airavata.xbaya.messaging.MonitorException)1 GraphCanvasEvent (org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent)1 GraphCanvasListener (org.apache.airavata.xbaya.ui.graph.GraphCanvasListener)1