in taverna-contextual-views/src/main/java/org/apache/taverna/workbench/ui/views/contextualviews/processor/ProcessorPredictedBehaviorContextualViewFactory.java [55:167]
public List<ContextualView> getViews(final Processor selection) {
class ProcessorPredictedBehaviorContextualView extends ContextualView {
protected JPanel mainPanel = new JPanel();
protected Processor processor;
public ProcessorPredictedBehaviorContextualView() {
super();
refreshView();
initView();
}
@Override
public void refreshView() {
initialise();
this.revalidate();
}
private synchronized void initialise() {
mainPanel.removeAll();
mainPanel.setLayout(new BoxLayout(mainPanel, Y_AXIS));
StringBuilder html = new StringBuilder("<html><head>");
addStyle(html);
html.append("</head><body>");
NamedSet<InputProcessorPort> inputs = processor.getInputPorts();
if (!inputs.isEmpty()) {
html.append("<table border=1><tr><th>Input Port Name</th>")
.append("<th>Size of data</th>").append("</tr>");
for (InputProcessorPort ip : inputs) {
html.append("<tr><td>").append(ip.getName())
.append("</td><td>");
List<DataLink> incomingDataLinks = scufl2Tools
.datalinksTo(ip);
if (incomingDataLinks.isEmpty())
html.append("No value");
else {
int depth = getDepth(incomingDataLinks.get(0));
if (depth == -1)
html.append("Invalid");
else if (depth == 0)
html.append("Single value");
else
html.append("List of depth ").append(depth);
}
html.append("</td></tr>");
}
html.append("</table>");
}
NamedSet<OutputProcessorPort> outputs = processor
.getOutputPorts();
if (!outputs.isEmpty()) {
html.append("<table border=1><tr><th>Output Port Name</th>")
.append("<th>Size of data</th>").append("</tr>");
for (OutputProcessorPort op : outputs) {
html.append("<tr><td>").append(op.getName())
.append("</td><td>");
List<DataLink> outgoingDataLinks = scufl2Tools
.datalinksFrom(op);
if (outgoingDataLinks.isEmpty())
html.append("No value");
else {
int depth = getDepth(outgoingDataLinks.get(0));
if (depth == -1)
html.append("Invalid/unpredicted");
else if (depth == 0)
html.append("Single value");
else
html.append("List of depth ").append(depth);
}
html.append("</td></tr>");
}
html.append("</table>");
}
if (inputs.isEmpty() && outputs.isEmpty())
html.append("<p>No port behavior predicted</p>");
html.append("</body></html>");
JEditorPane editorPane = new JEditorPane("text/html",
html.toString());
editorPane.setEditable(false);
mainPanel.add(editorPane);
mainPanel.revalidate();
mainPanel.repaint();
this.revalidate();
this.repaint();
}
protected void addStyle(StringBuilder html) {
html.append("<style type='text/css'>")
.append("table {align:center; border:solid black 1px;")
.append("width:100%; height:100%; overflow:auto;}")
.append("</style>");
}
@Override
public JComponent getMainFrame() {
return mainPanel;
}
@Override
public String getViewTitle() {
return "Predicted behavior";
}
@Override
public int getPreferredPosition() {
return 300;
}
}
return singletonList((ContextualView) new ProcessorPredictedBehaviorContextualView());
}