diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBeanV2.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBeanV2.java index 38f6afeb7ee9953080c092ed53f878eea6e83ad9..f0a92869ede8d54388bf3d990703465468426d81 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBeanV2.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBeanV2.java @@ -106,18 +106,10 @@ public final class CurrentAnalysisEditorBeanV2 { * This is the javascript command for a port object. */ private static final String JS_CMD_PORT = "{\"name\":\"%s\",\"id\":\"%s\", \"tooltip\":\"%s\"}"; - /** - * This is the javascript type name for a repository port. - */ - private static final String JS_CMD_PORT_TYPE_REPOSITORY = "repoPort"; /** * This is the javascript type name for an input port. */ private static final String JS_CMD_PORT_TYPE_INPUT = "inputPort"; - /** - * This is the javascript type name for an output port. - */ - private static final String JS_CMD_PORT_TYPE_OUTPUT = "outputPort"; /** * This is the javascript command to add a filter to the graph. */ @@ -646,7 +638,6 @@ public final class CurrentAnalysisEditorBeanV2 { } // TODO Now the connections between filters and repositories - } /** @@ -674,75 +665,100 @@ public final class CurrentAnalysisEditorBeanV2 { for (final MIPlugin plugin : this.project.getPlugins()) { final int pos = posCounter * 100; if (plugin instanceof MIReader) { - context.execute(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_ADD_READER, pos, pos, this.assembleGraphString(plugin), "", "")); + context.execute(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_ADD_READER, pos, pos, this.assembleGraphString(plugin), + this.assembleGraphRepositoryPortString(plugin), this.assembleGraphOuputPortString(plugin))); } else { - context.execute(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_ADD_FILTER, pos, pos, this.assembleGraphString(plugin), "", "", "")); + context.execute(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_ADD_FILTER, pos, pos, this.assembleGraphString(plugin), + this.assembleGraphRepositoryPortString(plugin), this.assembleGraphInputPortString((MIFilter) plugin), + this.assembleGraphOuputPortString(plugin))); } posCounter++; } } /** - * This method assembles the ID of the port for the graph based on the given parameters. + * This method assembles the string containing the given ports. * - * @param plugin - * The parent plugin of the port. - * @param port - * The port itself. - * @return The ID for the port within the graph + * @param ports + * The ports to be used within the string command. + * @return A string containing the JS commands to create the ports. */ - private String assembleGraphPortID(final MIPlugin plugin, final MIPort port) { - return this.pluginMap.get(plugin) + "_" + this.portMap.get(port); - } - - /** - * This method assembles the (simple) IDs for the ports of the given plugin and delivers them as a list as requested by the javascript commands. - * - * @param plugin - * The plugin whose list of input ports should be delivered. - * @return A list with the input port IDs. - */ - private String assembleInputPortsGraphString(final MIPlugin plugin) { + private String assembleGraphPortString(final EList<? extends MIPort> ports) { final StringBuilder builder = new StringBuilder(); + final int len = ports.size(); - boolean first = true; - if (plugin instanceof MIFilter) { - for (final MIInputPort port : ((MIFilter) plugin).getInputPorts()) { - if (first) { - first = false; - } else { - builder.append(','); - } - builder.append('\"').append(this.portMap.get(port)).append('\"'); + for (int i = 0; i < len; i++) { + final MIPort port = ports.get(i); + + if (i != 0) { + builder.append(','); } + + builder.append(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_PORT, port.getName(), this.portMap.get(port), port.getName())); } return builder.toString(); } /** - * This method assembles the (simple) IDs for the ports of the given plugin and delivers them as a list as requested by the javascript commands. + * This method assembles the string containing the available repository ports of the given plugin. * * @param plugin - * The plugin whose list of output ports should be delivered. - * @return A list with the output port IDs. + * The plugin whose repository ports will be used. + * @return A string containing the JS commands to create the repository ports. */ - private String assembleOutputPortsGraphString(final MIPlugin plugin) { + private String assembleGraphRepositoryPortString(final MIPlugin plugin) { final StringBuilder builder = new StringBuilder(); + final int len = plugin.getRepositories().size(); - boolean first = true; - for (final MIOutputPort port : plugin.getOutputPorts()) { - if (first) { - first = false; - } else { + for (int i = 0; i < len; i++) { + final MIRepositoryConnector port = plugin.getRepositories().get(i); + + if (i != 0) { builder.append(','); } - builder.append('\"').append(this.portMap.get(port)).append('\"'); + + builder.append(String.format(CurrentAnalysisEditorBeanV2.JS_CMD_PORT, port.getName(), port.getName(), port.getName())); } return builder.toString(); } + /** + * This method assembles the string containing the available input ports of the given filter. + * + * @param filter + * The filter whose input ports will be used. + * @return A string containing the JS commands to create the input ports. + */ + private String assembleGraphInputPortString(final MIFilter filter) { + return this.assembleGraphPortString(filter.getInputPorts()); + } + + /** + * This method assembles the string containing the available output ports of the given plugin. + * + * @param plugin + * The plugin whose output ports will be used. + * @return A string containing the JS commands to create the output ports. + */ + private String assembleGraphOuputPortString(final MIPlugin plugin) { + return this.assembleGraphPortString(plugin.getOutputPorts()); + } + + /** + * This method assembles the ID of the port for the graph based on the given parameters. + * + * @param plugin + * The parent plugin of the port. + * @param port + * The port itself. + * @return The ID for the port within the graph + */ + private String assembleGraphPortID(final MIPlugin plugin, final MIPort port) { + return this.pluginMap.get(plugin) + "_" + this.portMap.get(port); + } + /** * Assembles a human-readable string of the given repository, which can also be used as a graph ID. * @@ -751,7 +767,9 @@ public final class CurrentAnalysisEditorBeanV2 { * @return A human readable ID. */ private String assembleGraphString(final MIRepository repository) { - return String.format(CurrentAnalysisEditorBeanV2.JS_CMD_NODE, this.repositoryMap.get(repository), repository.getName(), repository.getClassname(), "N/A"); + final String className = repository.getClassname(); + final String shortName = className.substring(className.lastIndexOf('.') + 1); + return String.format(CurrentAnalysisEditorBeanV2.JS_CMD_NODE, this.repositoryMap.get(repository), repository.getName(), shortName, className); } /** @@ -762,7 +780,9 @@ public final class CurrentAnalysisEditorBeanV2 { * @return A human readable ID. */ private String assembleGraphString(final MIPlugin plugin) { - return String.format(CurrentAnalysisEditorBeanV2.JS_CMD_NODE, this.pluginMap.get(plugin), plugin.getName(), plugin.getClassname(), "N/A"); + final String className = plugin.getClassname(); + final String shortName = className.substring(className.lastIndexOf('.') + 1); + return String.format(CurrentAnalysisEditorBeanV2.JS_CMD_NODE, this.pluginMap.get(plugin), plugin.getName(), shortName, className); } /**