Skip to content
Snippets Groups Projects
Commit 96832e39 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Improved the connection handling.

parent 82752158
No related branches found
No related tags found
No related merge requests found
......@@ -123,21 +123,6 @@ public class SelectedMainProjectBean {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName()));
}
/**
* Delivers the "font weight" (whether the font is bold or normal) for a given project. This can be especially be used to mark a selected main project.
*
* @param project
* The project to be checked.
* @return "bold" if the given project is the current main project, "normal" otherwise.
*/
public final String getFontWeight(final MIProject project) {
if (project == this.mainProject) {
return "bold";
} else {
return "normal";
}
}
/**
* This method delivers the available reader-plugins for the current main project. The delivered plugins are never abstract.
*
......@@ -388,11 +373,29 @@ public class SelectedMainProjectBean {
return this.connections;
}
/**
* Delivers the valid connections (between the filters) within the current main project.
*
* @return A list containing all available and valid connections.
*/
public List<Connection> getValidConnections() {
final List<Connection> validConnections = new ArrayList<Connection>();
final List<Connection> availableConnections = this.getConnections();
for (final Connection connection : availableConnections) {
if (connection.isValid()) {
validConnections.add(connection);
}
}
return validConnections;
}
/**
* This method adds an empty connection to the current main project.
*/
public void addConnection() {
System.out.println("new conn.");
System.out.println("new conn.");
this.connections.add(new Connection(null, null, null, null));
}
......@@ -406,4 +409,23 @@ public class SelectedMainProjectBean {
}
}
}
/**
* This method returns all available filters of the current main project. In other words: It returns the same as mainProject.getPlugin() but only those which are
* really instances of {@link MIFilter}.
*
* @return A list with all filters of the main project.
*/
public List<MIFilter> getFilters() {
final List<MIFilter> result = new ArrayList<MIFilter>();
final List<MIPlugin> plugins = this.mainProject.getPlugins();
for (final MIPlugin plugin : plugins) {
if (plugin instanceof MIFilter) {
result.add((MIFilter) plugin);
}
}
return result;
}
}
......@@ -85,6 +85,10 @@ public class Connection {
*/
public void setDestination(final MIPlugin destination) {
this.destination = destination;
// Make sure that the output port is always valid - if necessary even null.
if (this.destination == null) {
this.outputPort = null;
}
}
/**
......@@ -142,6 +146,10 @@ public class Connection {
*/
public void setSource(final MIPlugin source) {
this.source = source;
// Make sure that the input port is always valid - if necessary even null.
if (this.source == null) {
this.inputPort = null;
}
}
/**
......
......@@ -63,17 +63,13 @@
<!-- ******************************************************************************** -->
<!-- The following layout is at the left side of the page and shows the available projects. -->
<p:layoutUnit header="Projects" collapsible="true" position="west"
size="200" resizable="true" minSize="100">
<p:layoutUnit header="Projects" collapsible="true" position="west" size="200" resizable="true" minSize="100">
<h:form id="projectsForm">
<p:tree selection="#{selectedProjectBean.selectedNode}" id="projectsTree" selectionMode="single" value="#{projectsBean.projectsRoot}" var="node">
<p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/>
<p:treeNode type="project">
<h:outputText style="font-weight: #{selectedMainProjectBean.getFontWeight(node)}" value="#{node}">
<f:converter
converterId="kieker.webgui.converter.MIProjectToStringConverter" />
</h:outputText>
<h:outputText style="font-weight: #{selectedMainProjectBean.mainProject == node ? 'bold' : 'normal' }" value="#{node.name}"/>
</p:treeNode>
<p:treeNode type="dependencies">
......@@ -124,12 +120,12 @@
</div>
<p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/>
<br/>
<p:commandLink ajax="true" value="Configure Connections" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
<p:commandLink ajax="true" value="Connections" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
<br/>
<p:commandLink ajax="true" value="Remove" action="#{selectedMainProjectBean.removePlugin(plugin)}" update=":propertiesForm"/>
</div>
</c:forEach>
<c:forEach items="#{selectedMainProjectBean.connections}" var="connection">
<c:forEach items="#{selectedMainProjectBean.validConnections}" var="connection">
<div class="connector #{stringToIDBean.stringToID(connection.source)} #{stringToIDBean.stringToID(connection.destination)}">
<label class="source-label"><h:outputText value="#{connection.outputPort.getName()}"/></label>
<label class="destination-label"><h:outputText value="#{connection.inputPort.getName()}"/></label>
......
......@@ -53,7 +53,7 @@
<f:facet name="input">
<p:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.destination}" effectDuration="100">
<f:selectItem value="#{null}" itemLabel="N/A" itemValue="#{null}"/>
<f:selectItems value="#{selectedMainProjectBean.mainProject.plugins}" var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}"/>
<f:selectItems value="#{selectedMainProjectBean.filters}" var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}"/>
<p:ajax event="change" update="validColumn inputPortsList"/>
</p:selectOneMenu>
</f:facet>
......@@ -78,7 +78,7 @@
</p:column>
<p:column id="validColumn" headerText="Valid" style="width:50px">
<h:outputText rendered="#{connection.valid}" value="#{connection.valid ? 'True' : 'False'}"/>
<h:outputText value="#{connection.valid ? 'True' : 'False'}"/>
</p:column>
<p:column headerText="Options" style="width:50px">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment