diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java index 6dafef6aebee1eb5fc9ed26e06241d927c1d5dd5..0baa18db7d8405d386afc1d9ab9ab8e72956ad98 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java @@ -34,6 +34,8 @@ import javax.faces.context.FacesContext; import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin; import kieker.analysis.model.analysisMetaModel.MIDependency; +import kieker.analysis.model.analysisMetaModel.MIInputPort; +import kieker.analysis.model.analysisMetaModel.MIOutputPort; import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProperty; @@ -44,10 +46,12 @@ import kieker.analysis.plugin.AbstractPlugin; import kieker.analysis.plugin.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.common.configuration.Configuration; +import kieker.webgui.common.Connection; import kieker.webgui.common.FileManager; import kieker.webgui.common.PluginClassLoader; import kieker.webgui.common.PluginFinder; +import org.eclipse.emf.common.util.EList; import org.primefaces.event.NodeSelectEvent; import org.primefaces.model.TreeNode; @@ -83,6 +87,8 @@ public class SelectedProjectBean { */ private MIProject mainProject; + private List<Connection> connections; + /** * Creates a new instance of this class. */ @@ -90,6 +96,7 @@ public class SelectedProjectBean { /* * No code necessary. */ + this.connections = new ArrayList<Connection>(); } /** @@ -109,6 +116,7 @@ public class SelectedProjectBean { */ public final void setMainProject(final MIProject mainProject) { this.mainProject = mainProject; + this.connections = this.getConnectionsFromMainProject(); FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName())); } @@ -270,7 +278,7 @@ public class SelectedProjectBean { SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); for (final Class<AbstractRepository> repository : repositories) { if (!Modifier.isAbstract(repository.getModifiers())) { - list.add((Class<AbstractRepository>) repository); + list.add(repository); } } } catch (final MalformedURLException ex) { @@ -331,4 +339,35 @@ public class SelectedProjectBean { public final void removePlugin(final MIPlugin plugin) { this.mainProject.getPlugins().remove(plugin); } + + private List<Connection> getConnectionsFromMainProject() { + final List<Connection> result = new ArrayList<Connection>(); + + if (this.mainProject != null) { + final EList<MIPlugin> mPlugins = this.mainProject.getPlugins(); + for (final MIPlugin mPlugin : mPlugins) { + final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts(); + for (final MIOutputPort mOutputPort : mOutputPorts) { + final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers(); + for (final MIInputPort mInputPort : mInputPorts) { + result.add(new Connection(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort)); + } + } + } + } + + return result; + } + + public List<Connection> getConnections() { + return this.connections; + } + + public void addConnection() { + this.connections.add(new Connection(null, null, null, null)); + } + + public void submitConnections() { + // TODO + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java new file mode 100644 index 0000000000000000000000000000000000000000..6f63e84974a6d068dd6bd8329d8c5d7255f6a898 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + +package kieker.webgui.common; + +import kieker.analysis.AnalysisController; +import kieker.analysis.model.analysisMetaModel.MIInputPort; +import kieker.analysis.model.analysisMetaModel.MIOutputPort; +import kieker.analysis.model.analysisMetaModel.MIPlugin; +import kieker.analysis.plugin.AbstractPlugin; + +/** + * + * @author Nils Christian Ehmke + */ +public class Connection { + + private MIPlugin source; + private MIPlugin destination; + private MIInputPort inputPort; + private MIOutputPort outputPort; + + public Connection(MIPlugin source, MIPlugin destination, MIInputPort inputPort, MIOutputPort outputPort) { + this.source = source; + this.destination = destination; + this.inputPort = inputPort; + this.outputPort = outputPort; + } + + public MIPlugin getDestination() { + return destination; + } + + public void setDestination(MIPlugin destination) { + this.destination = destination; + } + + public MIInputPort getInputPort() { + return inputPort; + } + + public void setInputPort(MIInputPort inputPort) { + this.inputPort = inputPort; + } + + public MIOutputPort getOutputPort() { + return outputPort; + } + + public void setOutputPort(MIOutputPort outputPort) { + this.outputPort = outputPort; + } + + public MIPlugin getSource() { + return source; + } + + public void setSource(MIPlugin source) { + this.source = source; + } + + public boolean isValid() { + if (source == null || destination == null || inputPort == null || outputPort == null) { + return false; + } + // TODO: This is not necessarily valid currently + return true; + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..c38030c0addcfc74c9e1866488b36251080cb05a --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java @@ -0,0 +1,42 @@ +package kieker.webgui.converter; + +import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.convert.Converter; +import javax.faces.convert.FacesConverter; +import kieker.analysis.model.analysisMetaModel.MIPlugin; + +/** + * + * @author Nils Christian Ehmke + */ +@FacesConverter(value = MIPluginToStringConverter.NAME) +public class MIPluginToStringConverter implements Converter { + /** + * This is the name of this converter. + */ + public static final String NAME = "kieker.webgui.converter.MIPluginToStringConverter"; + + private static ConcurrentHashMap<String, MIPlugin> map = new ConcurrentHashMap<String, MIPlugin>(); + + /** + * Creates a new instance of this class. + */ + public MIPluginToStringConverter() { + + } + + @Override + public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { + return map.get(string); + } + + @Override + public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { + String result = o.toString(); + map.put(result, (MIPlugin) o); + return result; + } +} diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 8bb8ed453a0570259dd4fba733ede2987df4b9c6..c5617ca6eeef29ae28cef13e5f2bb23d7d65366e 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -108,7 +108,7 @@ <p:panel header="#{plugin.name}" closable="true" closeSpeed="200" toggleSpeed="200" toggleable="true" id="plugin" style="width: 30%"> <p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/> <br/> - <p:commandLink ajax="true" value="Connect" onclick="connectionDialog.show();"/> + <p:commandLink ajax="true" value="Connect" update=":connectionDialogForm" onclick="connectionDialog.show();"/> <p:ajax event="close" listener="#{selectedProjectBean.removePlugin(plugin)}" update=":centerForm"/> </p:panel> <p:draggable for="plugin"> @@ -151,7 +151,7 @@ <!-- ******************************************************************************** --> <!-- The following layout unit is located at the right side of the page and is used as a tool palette. It shows the available plugins etc. --> - <p:layoutUnit position="east" size="200" header="Tool Palette" + <p:layoutUnit position="east" size="300" header="Tool Palette" resizable="true" collapsible="true"> <h:form id="toolpalette"> <p:accordionPanel multiple="true" activeIndex=""> @@ -186,8 +186,8 @@ <!-- Include the about-dialog. --> <ui:include src="main\aboutDialog.xhtml" /> - - <!-- Include the dialog to handle the connections. --> + + <!-- Include the dialog to handle the connections. --> <ui:include src="main\connectionDialog.xhtml" /> </h:body> diff --git a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml index fe4f777d9c0a0c9ee70ce918a4cfb59f758ead85..b556bff0d8753e781834cd013106a20d5a99ffc7 100644 --- a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml @@ -3,31 +3,68 @@ xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui"> + xmlns:p="http://primefaces.org/ui" + xmlns:c="http://java.sun.com/jsp/jstl/core"> <!-- ******************************************************************************** --> <!-- This is the dialog for settings and properties. --> <p:dialog id="connectionDialog" header="Manage Connections" resizable="false" modal="true" widgetVar="connectionDialog"> - <h:form> - <h:panelGrid columns="4"> - <h:outputText value="Source"/> - <h:outputText value="Output-Port"/> - <h:outputText value="Destination"/> - <h:outputText value="Input-Ports"/> + <h:form id="connectionDialogForm"> + <c:if test="#{not empty selectedProjectBean.mainProject}"> + <p:commandButton value="Add Connection" ajax="true" action="#{selectedProjectBean.addConnection()}" update=":connectionDialogForm"/> + <br/><br/> + <p:dataTable value="#{selectedProjectBean.connections}" var="connection"> + <p:column headerText="Source" style="width:125px"> + <p:cellEditor> + <f:facet name="output"> + <h:outputText value="#{connection.source.name}"/> + </f:facet> + <f:facet name="input"> + <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.source}"> + <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" + var="plugin" + itemLabel="#{plugin.name}" + itemValue="#{plugin}"/> + </h:selectOneMenu> + </f:facet> + </p:cellEditor> + </p:column> - <p:selectOneListbox> - <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" var="plugin" itemLabel="#{plugin.name}"/> - </p:selectOneListbox> - <p:selectOneListbox/> - <p:selectOneListbox> - <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" var="plugin" itemLabel="#{plugin.name}"/> - </p:selectOneListbox> - <p:selectManyMenu/> - </h:panelGrid> - <center> - <p:commandButton value="Ok" oncomplete="connectionDialog.hide();" /> - </center> + <p:column headerText="Destination" style="width:125px"> + <p:cellEditor> + <f:facet name="output"> + <h:outputText value="#{connection.destination.name}"/> + </f:facet> + <f:facet name="input"> + <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.destination}"> + <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" + var="plugin" + itemLabel="#{plugin.name}" + itemValue="#{plugin}"/> + </h:selectOneMenu> + </f:facet> + </p:cellEditor> + </p:column> + + <p:column headerText="Valid" style="width:50px"> + <c:if test="#{connection.valid}"> + <h:outputText value="True"/> + </c:if> + <c:otherwise> + <h:outputText value="False"/> + </c:otherwise> + </p:column> + + <p:column headerText="Options" style="width:50px"> + <p:rowEditor /> + </p:column> + </p:dataTable> + <br/> + <center> + <p:commandButton value="Ok" action="#{selectedProjectBean.submitConnections()}" oncomplete="connectionDialog.hide();" /> + </center> + </c:if> </h:form> </p:dialog> <!-- ******************************************************************************** -->