From ae120c5e74c7a6ee71401cc93e7d80ce8dc3d099 Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Tue, 24 Apr 2012 12:53:41 +0200
Subject: [PATCH] The name is now a property of the plugin; The connections are
 configurable for a project.

---
 .../webgui/beans/request/StringBean.java      |  3 ++
 .../beans/session/SelectedPluginBean.java     | 11 +++++++
 Kieker.WebGUI/src/main/webapp/main.xhtml      | 24 +++++++--------
 .../src/main/webapp/main/pluginDialogs.xhtml  | 29 -------------------
 4 files changed, 26 insertions(+), 41 deletions(-)
 delete mode 100644 Kieker.WebGUI/src/main/webapp/main/pluginDialogs.xhtml

diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java
index 7c262f19..9f2334de 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java
@@ -64,4 +64,7 @@ public class StringBean {
 		this.string = string;
 	}
 
+    public boolean checkString(final Object object) {
+        return object instanceof String;
+    }
 }
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java
index 1f44ddc2..4b4ffa7f 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java
@@ -20,6 +20,8 @@
 
 package kieker.webgui.beans.session;
 
+import java.util.ArrayList;
+import java.util.List;
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.SessionScoped;
 
@@ -65,4 +67,13 @@ public final class SelectedPluginBean {
 	public void setPlugin(final MIPlugin plugin) {
 		this.plugin = plugin;
 	}
+    
+    public List<Object> getAdvancedProperties() {
+        final List<Object> resultList = new ArrayList<Object>();
+        
+        resultList.add(plugin.getName());
+        resultList.addAll(plugin.getProperties());
+        
+        return resultList;
+    }
 }
diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml
index 79eb6ca1..560b45c4 100644
--- a/Kieker.WebGUI/src/main/webapp/main.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/main.xhtml
@@ -48,6 +48,7 @@
                                 <p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" />
                                 <p:separator />
                                 <p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" />
+                                <p:menuitem ajax="true" value="Configure Connections" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
                                 <p:separator />
                                 <p:menuitem value="Analysis" ajax="false" url="/Kieker.WebGUI/handleAnalysis" />
                             </p:submenu>
@@ -98,6 +99,7 @@
                             <p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" />
                             <p:separator />
                             <p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" />
+                            <p:menuitem ajax="true" value="Configure Connections" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
                             <p:separator />
                             <p:menuitem value="Analysis" ajax="false" url="/Kieker.WebGUI/handleAnalysis" />
                         </p:contextMenu>
@@ -122,11 +124,7 @@
                                     <div class="ui-panel-titlebar ui-widget-header ui-corner-all">
                                         <h:outputText style="font-weight: bold" value="#{plugin.getName()}"/>
                                     </div>
-                                    <p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/>
-                                    <br/>
-                                    <p:commandLink ajax="true" value="Connect" update=":connectionDialogForm" onclick="connectionDialog.show();"/>
-                                    <br/>
-                                    <p:commandLink ajax="true" value="Rename" action="#{selectedPluginBean.setPlugin(plugin)}"  update=":propertiesForm" onclick="pluginRenamingDialog.show();"/>
+                                    <p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/>                                    
                                     <br/>
                                     <p:commandLink ajax="true" value="Remove" action="#{selectedMainProjectBean.removePlugin(plugin)}"  update=":propertiesForm"/>
                                 </div>
@@ -149,18 +147,21 @@
                 <p:layoutUnit position="south" size="150" header="Properties" resizable="true" collapsible="true">
                     <h:form id="propertiesForm">
                         <c:if test="#{not empty selectedPluginBean.plugin}">
-                            <p:dataTable value="#{selectedPluginBean.plugin.properties}" var="property" id="propertiesList">
+                            <p:dataTable value="#{selectedPluginBean.advancedProperties}" var="property" id="propertiesList" emptyMessage="No properties available">
                                 <p:column headerText="Key" style="width:125px">
-                                    <h:outputText value="#{property.name}"/>
+                                    <h:outputText value="#{property.name}" rendered="#{not stringBean.checkString(property)}"/>
+                                    <h:outputText value="Name" rendered="#{stringBean.checkString(property)}"/>
                                 </p:column>
 
                                 <p:column headerText="Value" style="width:125px">
                                     <p:cellEditor >
                                         <f:facet name="output">
-                                            <h:outputText value="#{property.value}"/>
+                                            <h:outputText value="#{property.value}" rendered="#{not stringBean.checkString(property)}"/>
+                                            <h:outputText value="#{selectedPluginBean.plugin.name}" rendered="#{stringBean.checkString(property)}"/>
                                         </f:facet>
                                         <f:facet name="input">
-                                            <h:inputText value="#{property.value}"/>
+                                            <h:inputText value="#{property.value}" rendered="#{not stringBean.checkString(property)}"/>
+                                            <h:inputText value="#{selectedPluginBean.plugin.name}" rendered="#{stringBean.checkString(property)}"/>
                                         </f:facet>  
                                     </p:cellEditor>
                                 </p:column>
@@ -168,7 +169,8 @@
                                 <p:column headerText="Options" style="width:50px">  
                                     <p:rowEditor />  
                                 </p:column> 
-
+                                
+                                <p:ajax event="rowEdit" update=":centerForm" />
                             </p:dataTable>
                         </c:if>
                     </h:form>
@@ -215,8 +217,6 @@
 
             <!-- Include the dialog to handle the connections. -->
             <ui:include src="main/connectionDialog.xhtml" />
-
-            <ui:include src="main/pluginDialogs.xhtml" />
         </h:body>
     </f:view>
 </html>
\ No newline at end of file
diff --git a/Kieker.WebGUI/src/main/webapp/main/pluginDialogs.xhtml b/Kieker.WebGUI/src/main/webapp/main/pluginDialogs.xhtml
deleted file mode 100644
index 7c617c9f..00000000
--- a/Kieker.WebGUI/src/main/webapp/main/pluginDialogs.xhtml
+++ /dev/null
@@ -1,29 +0,0 @@
-<ui:composition 
-    xmlns="http://www.w3.org/1999/xhtml"
-    xmlns:h="http://java.sun.com/jsf/html"
-    xmlns:ui="http://java.sun.com/jsf/facelets"
-    xmlns:p="http://primefaces.org/ui"
-    xmlns:c="http://java.sun.com/jsp/jstl/core">     
-
-    <!-- ******************************************************************************** -->
-    <!-- This is the dialog to rename the currently selected plugin. -->
-    <p:dialog id="pluginRenamingDialog" header="Rename Plugin" resizable="false" modal="true" widgetVar="pluginRenamingDialog">
-        <!-- Make sure that closing the dialog also clears the input field. -->
-        <p:ajax event="close" update="pluginRenamingDialogForm:newNameInputText" />
-        
-        <h:form id="pluginRenamingDialogForm">
-            <div style="text-align: center">
-                <h:outputText value="New Name: " /> 
-                <p:inputText id="newNameInputText" value="#{stringBean.string}" />
-            </div>
-
-            <hr/>
-            <div style="text-align: right">
-                <p:commandButton value="Ok" action="#{selectedPluginBean.plugin.setName(stringBean.string)}" update=":centerForm" oncomplete="pluginRenamingDialog.hide()" />
-                <p:spacer width="10px" height="10" />
-                <p:commandButton value="Cancel" onclick="pluginRenamingDialog.hide()" />
-            </div>
-        </h:form>
-    </p:dialog>
-    <!-- ******************************************************************************** -->
-</ui:composition>
\ No newline at end of file
-- 
GitLab