Search in sources :

Example 6 with Component

use of org.apache.airavata.workflow.model.component.Component in project airavata by apache.

the class ComponentSelector method expandTreeLeaf.

private void expandTreeLeaf(ComponentTreeNode selectedNode, List<? extends Component> components) {
    ComponentReference componentReference = selectedNode.getComponentReference();
    ComponentTreeNode newNode = new ComponentTreeNode(componentReference.getName());
    ComponentTreeNode parent = (ComponentTreeNode) selectedNode.getParent();
    int index = this.treeModel.getIndexOfChild(parent, selectedNode);
    this.treeModel.removeNodeFromParent(selectedNode);
    this.treeModel.insertNodeInto(newNode, parent, index);
    for (Component component : components) {
        WSComponent wsComponent = (WSComponent) component;
        String operationName = wsComponent.getOperationName();
        ComponentOperationReference reference = new ComponentOperationReference(operationName, wsComponent);
        ComponentTreeNode child = new ComponentTreeNode(reference);
        this.treeModel.addNodeInto(child, newNode);
    }
    // expand
    TreeNode[] path = newNode.getPath();
    this.tree.expandPath(new TreePath(path));
}
Also used : ComponentOperationReference(org.apache.airavata.workflow.model.component.ComponentOperationReference) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component) XBayaComponent(org.apache.airavata.xbaya.ui.widgets.XBayaComponent) Point(java.awt.Point)

Example 7 with Component

use of org.apache.airavata.workflow.model.component.Component in project airavata by apache.

the class ComponentSelector method select.

/**
 * This method is called when a component is selected. It reads the component information from the server and set
 * the selectedComponent.
 *
 * @param treePath
 *            The path of the selected selectedComponent.
 */
private void select(TreePath treePath) {
    final ComponentTreeNode selectedNode = (ComponentTreeNode) treePath.getLastPathComponent();
    final ComponentReference componentReference = selectedNode.getComponentReference();
    selectComponent(null);
    this.selectedComponentReference = null;
    if (componentReference != null) {
        this.selectedComponentReference = componentReference;
        new Thread() {

            @Override
            public void run() {
                try {
                    // get all components and check the number of
                    // components. If there are multiple, expand the tree.
                    final List<? extends Component> components = componentReference.getComponents();
                    if (components.size() == 1) {
                        selectComponent(components.get(0));
                    } else {
                        SwingUtilities.invokeLater(new Runnable() {

                            public void run() {
                                expandTreeLeaf(selectedNode, components);
                            }
                        });
                    }
                } catch (ComponentException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_ERROR, e);
                } catch (ComponentRegistryException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                } catch (RuntimeException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                } catch (Exception e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                }
            }
        }.start();
    }
}
Also used : WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component) XBayaComponent(org.apache.airavata.xbaya.ui.widgets.XBayaComponent) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 8 with Component

use of org.apache.airavata.workflow.model.component.Component in project airavata by apache.

the class InstanceNode method getComponent.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#getComponent()
 */
@Override
public Component getComponent() {
    Component component = super.getComponent();
    if (component == null) {
        // The component is null when read from the graph XML.
        component = new InstanceComponent();
        setComponent(component);
    }
    return component;
}
Also used : InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent) Component(org.apache.airavata.workflow.model.component.Component) InstanceComponent(org.apache.airavata.workflow.model.component.amazon.InstanceComponent)

Example 9 with Component

use of org.apache.airavata.workflow.model.component.Component in project airavata by apache.

the class GraphCanvas method drop.

private void drop(final DropTargetDropEvent event) {
    logger.debug("Event:" + event);
    Transferable transferable = event.getTransferable();
    try {
        // Cannot cast transferable.
        final ComponentReference componentReference = (ComponentReference) transferable.getTransferData(ComponentSourceTransferable.FLAVOR);
        final Point location = event.getLocation();
        // The component might not have loaded if the network is slow.
        new Thread() {

            @Override
            public void run() {
                try {
                    Component component = componentReference.getComponent();
                    addNode(component, location);
                    // To be able to delete the added node by the keyboard.
                    GraphCanvas.this.panel.requestFocusInWindow();
                    // XXX this sometimes throws exception.
                    event.dropComplete(true);
                } catch (ComponentException e) {
                    // If there is any error, the component tree viewer
                    // shows the error dialog.
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                } catch (ComponentRegistryException e) {
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                }
            }
        }.start();
    } catch (UnsupportedFlavorException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    }
}
Also used : ComponentSourceTransferable(org.apache.airavata.xbaya.ui.widgets.component.ComponentSourceTransferable) Transferable(java.awt.datatransfer.Transferable) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Point(java.awt.Point) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) IOException(java.io.IOException) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Component(org.apache.airavata.workflow.model.component.Component) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) JComponent(javax.swing.JComponent) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Example 10 with Component

use of org.apache.airavata.workflow.model.component.Component in project airavata by apache.

the class ComponentViewer method componentSelectorChanged.

/**
 * @see org.apache.airavata.xbaya.ui.widgets.component.ComponentSelectorListener#componentSelectorChanged(org.apache.airavata.xbaya.ui.widgets.component.ComponentSelectorEvent)
 */
public void componentSelectorChanged(ComponentSelectorEvent event) {
    ComponentSelectorEventType type = event.getType();
    switch(type) {
        case COMPONENT_SELECTED:
            Component component = event.getComponent();
            setComponent(component);
            break;
    }
}
Also used : ComponentSelectorEventType(org.apache.airavata.xbaya.ui.widgets.component.ComponentSelectorEvent.ComponentSelectorEventType) XBayaComponent(org.apache.airavata.xbaya.ui.widgets.XBayaComponent) Component(org.apache.airavata.workflow.model.component.Component)

Aggregations

Component (org.apache.airavata.workflow.model.component.Component)17 ComponentReference (org.apache.airavata.workflow.model.component.ComponentReference)5 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)5 ArrayList (java.util.ArrayList)4 InstanceComponent (org.apache.airavata.workflow.model.component.amazon.InstanceComponent)3 TerminateInstanceComponent (org.apache.airavata.workflow.model.component.amazon.TerminateInstanceComponent)3 DynamicComponent (org.apache.airavata.workflow.model.component.dynamic.DynamicComponent)3 InputComponent (org.apache.airavata.workflow.model.component.system.InputComponent)3 Node (org.apache.airavata.workflow.model.graph.Node)3 XBayaComponent (org.apache.airavata.xbaya.ui.widgets.XBayaComponent)3 Point (java.awt.Point)2 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)2 ComponentRegistryException (org.apache.airavata.workflow.model.component.ComponentRegistryException)2 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)2 DataPort (org.apache.airavata.workflow.model.graph.DataPort)2 EdgeImpl (org.apache.airavata.workflow.model.graph.impl.EdgeImpl)2 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1