From 96832e39bb8cb22cc3103c2fff635ca813f04934 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Thu, 26 Apr 2012 12:35:06 +0200 Subject: [PATCH] Improved the connection handling. --- .../session/SelectedMainProjectBean.java | 54 +++++++++++++------ .../java/kieker/webgui/common/Connection.java | 8 +++ Kieker.WebGUI/src/main/webapp/main.xhtml | 12 ++--- .../main/webapp/main/connectionDialog.xhtml | 4 +- 4 files changed, 52 insertions(+), 26 deletions(-) diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java index e1c94c1b..5368438f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java @@ -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; + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java index ae30efca..70a9ce18 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java @@ -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; + } } /** diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 9eb54835..eaea4f31 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -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> diff --git a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml index 2c0f7f2b..cf19e145 100644 --- a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml @@ -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"> -- GitLab