in taverna-workflow-explorer/src/main/java/org/apache/taverna/workbench/ui/workflowexplorer/WorkflowExplorerTreeModel.java [140:399]
public static TreePath getPathForObject(Object userObject,
DefaultMutableTreeNode root) {
if (userObject instanceof Workflow) { // node contains a Dataflow object
if (root.getUserObject().equals(userObject)) // is it the root of the tree?
return new TreePath(root.getPath());
} else if (userObject instanceof InputWorkflowPort) {
// Get the root inputs node
DefaultMutableTreeNode inputs = (DefaultMutableTreeNode) root
.getChildAt(INPUT_IDX);
for (int i = 0; i < inputs.getChildCount(); i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) inputs
.getChildAt(i);
if (node.getUserObject().equals(userObject))
return new TreePath(node.getPath());
}
/*
* The node we are looking for must be under some nested workflow
* then - but we do not want to let the user select a node under a
* nested workflow so return here
*/
return null;
/*DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root.getChildAt(2);
for (int i = 0; i < processors.getChildCount(); i++){
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors.getChildAt(i);
// If this is a nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
}
}*/
} else if (userObject instanceof OutputWorkflowPort) {
// Get the root outputs node
DefaultMutableTreeNode outputs = (DefaultMutableTreeNode) root
.getChildAt(OUTPUT_IDX);
for (int i = 0; i< outputs.getChildCount(); i++) { // loop through the outputs
DefaultMutableTreeNode node = (DefaultMutableTreeNode) outputs
.getChildAt(i);
if (node.getUserObject().equals(userObject))
return new TreePath(node.getPath());
}
/*
* The node we are looking for must be under some nested workflow
* then - but we do not want to let the user select a node under a
* nested workflow so return here
*/
return null;
/*DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root.getChildAt(2);
for (int i = 0; i < processors.getChildCount(); i++){
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors.getChildAt(i);
// If this is a nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
}
}*/
} else if (userObject instanceof Processor) {
// Get the root services (processors) node
DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root
.getChildAt(PROCESSOR_IDX);
for (int i = 0; i < processors.getChildCount(); i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) processors
.getChildAt(i);
if (node.getUserObject().equals(userObject))
return new TreePath(node.getPath());
}
/*
* The node we are looking for must be under some nested workflow
* then - but we do not want to let the user select a node under a
* nested workflow so return here
*/
return null;
/*for (int i = 0; i < processors.getChildCount(); i++){
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors.getChildAt(i);
// If this is a nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
}
}*/
} else if (userObject instanceof InputProcessorPort) {
// This is an input port of a processor
// Get the root processors node
DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root
.getChildAt(PROCESSOR_IDX);
for (int i = processors.getChildCount() - 1; i >= 0; i--) {
// Looping backwards so that nested workflows are checked last
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors
.getChildAt(i);
/*
* We actually do not want to check nested workflows as we do
* not want the user to be able to select a component of a
* nested workflow
*/
/*
// If this is nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Check the associated DataflowActivity's input ports first
// Do not check the last child as it is the nested workflow node
for (int j = 0; j < processor.getChildCount()-1; j++){
DefaultMutableTreeNode port_node = (DefaultMutableTreeNode) processor.getChildAt(j);
if ((port_node.getUserObject() instanceof ActivityInputPort) &&
(((ActivityInputPort) port_node.getUserObject()).equals(userObject)))
return new TreePath(port_node.getPath());
}
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
} else */
/*
* This is not a nested workflow, so loop thought the
* processor's input and output ports, and see if there is a
* matching input port
*/
for (int j = 0; j < processor.getChildCount(); j++) {
DefaultMutableTreeNode port_node = (DefaultMutableTreeNode) processor
.getChildAt(j);
if ((port_node.getUserObject() instanceof InputProcessorPort)
&& (((InputProcessorPort) port_node
.getUserObject()).equals(userObject)))
return new TreePath(port_node.getPath());
}
}
return null; // The node is inside a nested workflow so just return here
} else if (userObject instanceof OutputProcessorPort) {
// This is an output port of a processor (i.e. of its associated activity)
// Get the root processors node
DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root
.getChildAt(PROCESSOR_IDX);
for (int i = processors.getChildCount() - 1; i >= 0 ; i--){
// Looping backwards so that nested workflows are checked last
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors
.getChildAt(i);
/*
* We actually do not want to check nested workflows as we do
* not want the user to be able to select a component of a
* nested workflow
*/
/*
// If this is nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Check the associated DataflowActivity's output ports first
// Do not check the last child as it is the nested workflow node
for (int j = 0; j < processor.getChildCount()-1; j++){
DefaultMutableTreeNode port_node = (DefaultMutableTreeNode) processor.getChildAt(j);
if ((port_node.getUserObject() instanceof ActivityOutputPortImpl) &&
(((ActivityOutputPortImpl) port_node.getUserObject()).equals(userObject)))
return new TreePath(port_node.getPath());
}
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
} else */
{
/*
* This is not a nested workflow, so loop thought the
* processor's input and output ports, and see if there is a
* matching output port
*/
for (int j = 0; j < processor.getChildCount(); j++) {
DefaultMutableTreeNode port_node = (DefaultMutableTreeNode) processor
.getChildAt(j);
if ((port_node.getUserObject() instanceof OutputProcessorPort)
&& (((OutputProcessorPort) port_node
.getUserObject()).equals(userObject)))
return new TreePath(port_node.getPath());
}
}
}
return null; // The node is inside a nested workflow so just return here
} else if (userObject instanceof DataLink) {
// Get the root data links node
DefaultMutableTreeNode datalinks = (DefaultMutableTreeNode) root
.getChildAt(DATA_IDX);
for (int i = 0; i < datalinks.getChildCount(); i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) datalinks
.getChildAt(i);
if (node.getUserObject().equals(userObject))
return new TreePath(node.getPath());
}
/*
* The node we are looking for must be under some nested workflow
* then - but we do not want to let the user select a node under a
* nested workflow so return here
*/
return null;
/*DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root.getChildAt(2);
for (int i = 0; i < processors.getChildCount(); i++){
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors.getChildAt(i);
// If this is a nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
}
}*/
} else if (userObject instanceof ControlLink) {
// Get the root control links node
DefaultMutableTreeNode controllinks = (DefaultMutableTreeNode) root
.getChildAt(CONTROL_IDX);
for (int i = 0; i < controllinks.getChildCount(); i++) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) controllinks
.getChildAt(i);
if (node.getUserObject().equals(userObject))
return new TreePath(node.getPath());
}
/*
* The node we are looking for must be under some nested workflow
* then - but we do not want to let the user select a node under a
* nested workflow so return here
*/
return null;
/*DefaultMutableTreeNode processors = (DefaultMutableTreeNode) root.getChildAt(2);
for (int i = 0; i < processors.getChildCount(); i++){
DefaultMutableTreeNode processor = (DefaultMutableTreeNode) processors.getChildAt(i);
// If this is a nested workflow - descend into it
if (Tools.containsNestedWorkflow((Processor) processor.getUserObject())){
// Get the nested workflow node - it is always the last child of the
// wrapping processor's node
DefaultMutableTreeNode nestedWorkflowNode = (DefaultMutableTreeNode) processor.getLastChild();
TreePath tp = getPathForObject(userObject, nestedWorkflowNode);
if (tp != null)
return tp;
}
}*/
}
return null;
}