From 68bdc5ba593f04cfe67cbfe87334a1e20082a1dc Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Wed, 14 Mar 2012 22:14:40 +0100
Subject: [PATCH] Modified the tool palette.

---
 .../application/AvailableProjectsBean.java    |  2 +-
 .../request/SelectedDependenciesBean.java     |  6 +-
 .../beans/session/SelectedProjectBean.java    | 78 ++++++++++++++++---
 Kieker.WebGUI/src/main/webapp/main.xhtml      | 43 ++++------
 .../src/main/webapp/main/aboutDialog.xhtml    |  2 +-
 .../src/main/webapp/manageDependencies.xhtml  |  2 +-
 6 files changed, 88 insertions(+), 45 deletions(-)

diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java
index d5bba715..295b777c 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java
@@ -175,5 +175,5 @@ public class AvailableProjectsBean {
 			}
 		}
 	}
-   
+
 }
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java
index cf00728b..14f57c5d 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java
@@ -95,10 +95,10 @@ public class SelectedDependenciesBean {
 		if (this.project != null) {
 			this.project.getDependencies().clear();
 			this.project.getDependencies().addAll(this.dependencies);
-            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Dependencies saved."));
+			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Dependencies saved."));
 		} else {
-            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "No project selected."));
-        }
+			FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "No project selected."));
+		}
 	}
 
 }
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 3440e25c..ea6db00c 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
@@ -22,6 +22,7 @@ package kieker.webgui.beans.session;
 import java.lang.reflect.Modifier;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.faces.application.FacesMessage;
@@ -41,8 +42,7 @@ import org.primefaces.model.DefaultTreeNode;
 import org.primefaces.model.TreeNode;
 
 /**
- * This bean can be used to store the currently selected project and the current
- * main project for the user within a session.
+ * This bean can be used to store the currently selected project and the current main project for the user within a session.
  * 
  * @author Nils Christian Ehmke
  * @version 1.0
@@ -68,7 +68,9 @@ public class SelectedProjectBean {
 	 * Creates a new instance of this class.
 	 */
 	public SelectedProjectBean() {
-		/* No code necessary. */
+		/*
+		 * No code necessary.
+		 */
 	}
 
 	/**
@@ -120,13 +122,10 @@ public class SelectedProjectBean {
 	}
 
 	/**
-	 * This event should be triggered once a new node is selected
-	 * to make sure that the newly selected node is stored within
-	 * this bean.
+	 * This event should be triggered once a new node is selected to make sure that the newly selected node is stored within this bean.
 	 * 
 	 * @param event
-	 *            The event that a node has been selected by the
-	 *            user.
+	 *            The event that a node has been selected by the user.
 	 */
 	public final void onNodeSelect(final NodeSelectEvent event) {
 		this.setSelectedNode(event.getTreeNode());
@@ -148,9 +147,7 @@ public class SelectedProjectBean {
 	}
 
 	/**
-	 * 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.
+	 * 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.
@@ -164,6 +161,65 @@ public class SelectedProjectBean {
 		}
 	}
 
+	public final List<Class<?>> getAvailableReaders() {
+		final List<Class<?>> list = new ArrayList<Class<?>>();
+
+		if (this.mainProject != null) {
+			for (final MIDependency lib : this.mainProject.getDependencies()) {
+				try {
+					PluginClassLoader.getInstance().addURL(new URL("file", "localhost", lib.getFilePath()));
+				} catch (final MalformedURLException ex) {
+					// TODO Log exception
+				}
+				try {
+					final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL("file", "localhost", lib.getFilePath()));
+					for (final Class<?> plugin : plugins) {
+						if (!Modifier.isAbstract(plugin.getModifiers())) {
+							if (AbstractReaderPlugin.class.isAssignableFrom(plugin)) {
+								list.add(plugin);
+							}
+						}
+					}
+				} catch (final MalformedURLException ex) {
+					ex.printStackTrace();
+					// TODO Log exception
+				}
+			}
+		}
+
+		return list;
+	}
+
+	public final List getAvailableFilters() {
+		final List<Class<?>> list = new ArrayList<Class<?>>();
+
+		if (this.mainProject != null) {
+			for (final MIDependency lib : this.mainProject.getDependencies()) {
+				try {
+					PluginClassLoader.getInstance().addURL(new URL("file", "localhost", lib.getFilePath()));
+				} catch (final MalformedURLException ex) {
+					// TODO Log exception
+				}
+				try {
+					final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL("file", "localhost", lib.getFilePath()));
+					for (final Class<?> plugin : plugins) {
+						if (!Modifier.isAbstract(plugin.getModifiers())) {
+							if (AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) {
+								list.add(plugin);
+							}
+						}
+					}
+				} catch (final MalformedURLException ex) {
+					ex.printStackTrace();
+					// TODO Log exception
+				}
+			}
+		}
+
+		return list;
+
+	}
+
 	/**
 	 * Delivers the available plugins.
 	 * 
diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml
index deef92c3..b48b150b 100644
--- a/Kieker.WebGUI/src/main/webapp/main.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/main.xhtml
@@ -12,7 +12,7 @@
             <link rel="stylesheet" type="text/css" href="../main.css" />
         </h:head>
 
-        <h:body onload="initPageObjects();">
+        <h:body>
             <!-- This is the layout for the whole page. -->
             <p:layout id="layout" fullPage="true">
 
@@ -40,7 +40,7 @@
                             </p:submenu>
 
                             <p:submenu label="Help">
-                                <p:menuitem value="About..." ajax="true" onclick="AboutDialog.show();" />
+                                <p:menuitem value="About..." ajax="true" onclick="aboutDialog.show()" />
                             </p:submenu>
 
                         </p:menubar>
@@ -100,7 +100,7 @@
 
                 <!-- ******************************************************************************** -->
                 <!-- The following layout unit is within the center and used for the graph. -->
-                <p:layoutUnit position="center">
+                <p:layoutUnit position="center" id="centerLayout">
                 </p:layoutUnit>
                 <!-- ******************************************************************************** -->
 
@@ -145,31 +145,18 @@
                 <p:layoutUnit position="east" size="200" header="Tool Palette"
                               resizable="true" collapsible="true">
                     <h:form id="toolpalette">
-                        <p:tree style="width: auto" value="#{selectedProjectBean.availablePluginsRoot}" dynamic="true" var="node">
-
-                            <p:treeNode type="default">
-                                <h:outputText value="#{node}"/>
-                            </p:treeNode>
-                            <p:treeNode type="reader" icon="ui-icon-folder-open">
-                                <h:form>
-                                    <p:commandLink ajax="true">
-                                        <h:outputText value="#{node}">
-                                            <f:converter converterId="kieker.webgui.converter.ClassToStringConverter"/>
-                                        </h:outputText>
-                                    </p:commandLink>
-                                </h:form>
-                            </p:treeNode>
-
-                            <p:treeNode type="filter" icon="ui-icon-disk">
-                                <h:form>
-                                    <p:commandLink>
-                                        <h:outputText value="#{node}" >
-                                            <f:converter converterId="kieker.webgui.converter.ClassToStringConverter"/>
-                                        </h:outputText>
-                                    </p:commandLink>
-                                </h:form>
-                            </p:treeNode>
-                        </p:tree>
+                        <p:accordionPanel multiple="true" activeIndex="">
+                            <p:tab title="Reader">
+                                <ui:repeat value="#{selectedProjectBean.availableReaders}" var="reader">
+                                    <p:commandLink value="#{reader.simpleName}"/><br/>
+                                </ui:repeat>
+                            </p:tab>
+                            <p:tab title="Filter">
+                                <ui:repeat value="#{selectedProjectBean.availableFilters}" var="filter">
+                                    <p:commandLink value="#{filter.simpleName}"/><br/>
+                                </ui:repeat>
+                            </p:tab>
+                        </p:accordionPanel>
                     </h:form>
                 </p:layoutUnit>
                 <!-- ******************************************************************************** -->
diff --git a/Kieker.WebGUI/src/main/webapp/main/aboutDialog.xhtml b/Kieker.WebGUI/src/main/webapp/main/aboutDialog.xhtml
index 38dc4a65..a109c34d 100644
--- a/Kieker.WebGUI/src/main/webapp/main/aboutDialog.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/main/aboutDialog.xhtml
@@ -8,7 +8,7 @@
     <!-- ******************************************************************************** -->
     <!-- This is the about-dialog. -->
     <p:dialog header="About..." resizable="false" modal="true"
-              widgetVar="AboutDialog">
+              widgetVar="aboutDialog" id="aboutDialog">
         <h:form>
             <h:outputText value="Kieker.WebGUI" />
             <br />
diff --git a/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml b/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml
index d37c663d..29b158d4 100644
--- a/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml
+++ b/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml
@@ -63,7 +63,7 @@
                                 <f:facet name="header">  
                                 </f:facet>  
                                 <div align="center">
-                                    <p:commandButton ajax="true" update="currentDependenciesForm" icon="ui-icon-trash" title="Delete" 
+                                    <p:commandButton ajax="true" update=":currentDependenciesForm" icon="ui-icon-trash" title="Delete" 
                                                      action="#{availableDependenciesBean.deleteDependency(dependency)}"/>  
                                 </div>
                             </p:column> 
-- 
GitLab