1 |
26600
|
sandro.lab
|
package eu.dnetlib.functionality.modular.ui.workflows.sarasvati.viewer;
|
2 |
|
|
|
3 |
|
|
import java.util.Set;
|
4 |
|
|
|
5 |
|
|
import javax.swing.Icon;
|
6 |
|
|
|
7 |
|
|
import com.googlecode.sarasvati.Node;
|
8 |
|
|
import com.googlecode.sarasvati.visual.GraphToImageMapAdapter;
|
9 |
|
|
|
10 |
|
|
import eu.dnetlib.functionality.modular.ui.workflows.sarasvati.icons.GraphIcon;
|
11 |
|
|
import eu.dnetlib.msro.workflows.nodes.NodeStatus;
|
12 |
|
|
|
13 |
|
|
public class GraphToImageMapHelper extends GraphToImageMapAdapter {
|
14 |
|
|
|
15 |
|
|
private String workflowId;
|
16 |
|
|
private Set<String> notConfiguredNodes;
|
17 |
|
|
|
18 |
|
|
public GraphToImageMapHelper(final String workflowId, final Set<String> notConfiguredNodes) {
|
19 |
|
|
super();
|
20 |
|
|
this.workflowId = workflowId;
|
21 |
|
|
this.notConfiguredNodes = notConfiguredNodes;
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
@Override
|
25 |
|
|
public String hrefForNode (Node node) {
|
26 |
|
|
if (workflowId == null || workflowId.isEmpty()) {
|
27 |
|
|
return "javascript:alert('TODO')";
|
28 |
|
|
} else if ( node.getName().equals("success") || node.getName().equals("failure")) {
|
29 |
|
|
return "javascript:alert('You can not edit this node !')";
|
30 |
|
|
} else {
|
31 |
|
|
return "javascript:getScope('map').getNode('" + workflowId + "', '" + node.getName() + "')";
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
@Override
|
36 |
|
|
public String hoverForNode (Node node) {
|
37 |
|
|
return "Name: " + node.getName();
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
@Override
|
41 |
|
|
public Icon iconForNode(Node node) {
|
42 |
|
|
if (node.getName().equals("success") || node.getName().equals("failure") ) {
|
43 |
|
|
return new GraphIcon(node, NodeStatus.SYSTEM);
|
44 |
|
|
} else if (notConfiguredNodes != null && notConfiguredNodes.contains(node.getName())) {
|
45 |
|
|
return new GraphIcon(node, NodeStatus.NOT_CONFIGURED);
|
46 |
|
|
} else {
|
47 |
|
|
return new GraphIcon(node, NodeStatus.CONFIGURED);
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
}
|