use of org.apache.airavata.workflow.model.component.ComponentReference in project airavata by apache.
the class AmazonComponentRegistry method getComponentReferenceList.
/**
* @see org.apache.airavata.workflow.model.component.registry.ComponentRegistry#getComponentReferenceList()
*/
@Override
public List<ComponentReference> getComponentReferenceList() {
List<ComponentReference> tree = new ArrayList<ComponentReference>();
for (String name : this.componentMap.keySet()) {
Component component = this.componentMap.get(name);
SystemComponentReference componentReference = new SystemComponentReference(name, component);
tree.add(componentReference);
}
return tree;
}
use of org.apache.airavata.workflow.model.component.ComponentReference 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));
}
use of org.apache.airavata.workflow.model.component.ComponentReference 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();
}
}
use of org.apache.airavata.workflow.model.component.ComponentReference 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);
}
}
use of org.apache.airavata.workflow.model.component.ComponentReference in project airavata by apache.
the class LocalComponentRegistry method getComponentTree.
private List<ComponentReference> getComponentTree(File dir) {
if (!dir.isDirectory()) {
throw new WorkflowRuntimeException(dir + "is not a directory.");
}
boolean found = false;
List<ComponentReference> tree = new ArrayList<ComponentReference>();
for (File file : dir.listFiles()) {
String fileName = file.getName();
if (file.isDirectory()) {
List<ComponentReference> subTree = getComponentTree(file);
if (subTree != null) {
found = true;
LocalComponentReference componentRef = new LocalComponentReference(file.getName(), file, this);
componentRef.getChildComponentReferences().addAll(subTree);
tree.add(componentRef);
}
} else if (fileName.endsWith(FileConstants.XML_SUFFIX) || fileName.endsWith(FileConstants.WSDL_SUFFIX) || fileName.endsWith(FileConstants.WSDL_SUFFIX2)) {
found = true;
LocalComponentReference componentReference = new LocalComponentReference(file.getName(), file, this);
tree.add(componentReference);
}
}
if (!found) {
// Doesn't show a directory that doesn't have any components.
tree = null;
}
return tree;
}
Aggregations