From 5586bd1f243819e152ca9626f7560098a5b66fcc Mon Sep 17 00:00:00 2001 From: nie <nie@informatik.uni-kiel.de> Date: Tue, 28 Feb 2012 17:22:35 +0100 Subject: [PATCH] Added the files for JointJS; Made sure that the available plugins will be shown; Made sure that messages can be shown --- .../beans/session/SelectedProjectBean.java | 45 +++++++++++++++-- .../kieker/webgui/common/FileManager.java | 5 +- .../webgui/common/PluginClassLoader.java | 3 +- .../kieker/webgui/converter/package-info.java | 2 +- Kieker.WebGUI/src/main/webapp/main.css | 24 ++++----- Kieker.WebGUI/src/main/webapp/main.xhtml | 50 ++++++++++++++----- .../src/main/webapp/main/joint.dia.uml.min.js | 5 ++ .../src/main/webapp/main/raphael-min.js | 7 +++ 8 files changed, 108 insertions(+), 33 deletions(-) create mode 100644 Kieker.WebGUI/src/main/webapp/main/joint.dia.uml.min.js create mode 100644 Kieker.WebGUI/src/main/webapp/main/raphael-min.js 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 59e649e1..3440e25c 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 @@ -19,10 +19,22 @@ ***************************************************************************/ package kieker.webgui.beans.session; +import java.lang.reflect.Modifier; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; + +import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; +import javax.faces.context.FacesContext; +import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; +import kieker.analysis.plugin.AbstractAnalysisPlugin; +import kieker.analysis.plugin.AbstractReaderPlugin; +import kieker.webgui.common.PluginClassLoader; +import kieker.webgui.common.PluginFinder; import org.primefaces.event.NodeSelectEvent; import org.primefaces.model.DefaultTreeNode; @@ -76,6 +88,7 @@ public class SelectedProjectBean { */ public final void setMainProject(final MIProject mainProject) { this.mainProject = mainProject; + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName())); } /** @@ -159,9 +172,35 @@ public class SelectedProjectBean { public final TreeNode getAvailablePluginsRoot() { final TreeNode root = new DefaultTreeNode("Root", null); - new DefaultTreeNode("default", "Reader", root); - new DefaultTreeNode("default", "AnalysisPlugins", root); - + final TreeNode readerNode = new DefaultTreeNode("default", "Reader", root); + final TreeNode filterNode = new DefaultTreeNode("default", "AnalysisPlugins", root); + + 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)) { + new DefaultTreeNode("reader", plugin, readerNode); + } else { + if (AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) { + new DefaultTreeNode("filter", plugin, filterNode); + } + } + } + } + } catch (final MalformedURLException ex) { + ex.printStackTrace(); + // TODO Log exception + } + } + } return root; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java index 4495e637..c7de9563 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java @@ -143,6 +143,7 @@ public final class FileManager { */ final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); try { + // TODO Copy before saving as the controller destroys at least the dependencies. final AnalysisController controller = new AnalysisController(project); return controller.saveToFile(fileProject); } catch (final Exception ex) { @@ -341,7 +342,7 @@ public final class FileManager { final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); if (dirProject.isDirectory()) { final File[] files = dirProject.listFiles(); - for (File file : files) { + for (final File file : files) { if (!file.delete()) { return false; } @@ -365,7 +366,7 @@ public final class FileManager { if (projectFile.isFile()) { try { return AnalysisController.loadFromFile(projectFile); - } catch (Exception ex) { + } catch (final Exception ex) { FileManager.LOG.warn("Error reloaded project '" + projectName + "'", ex); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java index 27e445a9..cd624f35 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java @@ -105,8 +105,7 @@ public final class PluginClassLoader { final URLClassLoader currClassLoader = classLoaderIter.next(); /* If no exception is thrown, we found the correct class and return it. Otherwise we continue the search. */ try { - final Class<?> resultingClass = currClassLoader.loadClass(name); - return resultingClass; + return currClassLoader.loadClass(name); } catch (final ClassNotFoundException ex) { // Ignore error } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java index 14eab31e..cde21594 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java @@ -18,7 +18,7 @@ * limitations under the License. ***************************************************************************/ -/** +/** * This package contains all converters used within the project. */ package kieker.webgui.converter; diff --git a/Kieker.WebGUI/src/main/webapp/main.css b/Kieker.WebGUI/src/main/webapp/main.css index 08ff2943..650ca587 100644 --- a/Kieker.WebGUI/src/main/webapp/main.css +++ b/Kieker.WebGUI/src/main/webapp/main.css @@ -4,41 +4,41 @@ * The following style modifications make sure that the menu bar is visible. */ .ui-layout-north { - z-index: 20 !important; - overflow: visible !important;; + z-index: 20 !important; + overflow: visible !important;; } - + .ui-layout-north .ui-layout-unit-content { - overflow: visible !important; + overflow: visible !important; } .ui-layout-center { - font-size: 15px; + font-size: 15px; } .ui-layout-east { - font-size: 15px; + font-size: 15px; } .ui-layout-south { - font-size: 15px; + font-size: 15px; } .ui-layout-west { - font-size: 15px; + font-size: 15px; } .ui-menubar .ui-menuitem { - font-size: 15px; + font-size: 15px; } .ui-contextmenu { - font-size: 15px; + font-size: 15px; } .ui-dialog { - font-size: 15px; - width: auto; + font-size: 15px; + width: auto; } .projectInputText { diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 18109510..a828cae4 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -10,6 +10,8 @@ <h:head> <title>Kieker.WebGUI</title> <link rel="stylesheet" type="text/css" href="../main.css" /> + <script src="../main/raphael-min.js" type="text/javascript"></script> + <script src="../main/joint.dia.uml.min.js" type="text/javascript"></script> </h:head> <h:body> @@ -56,40 +58,40 @@ <h:form id="projectsForm"> <p:tree selection="#{selectedProjectBean.selectedNode}" id="projectsTree" selectionMode="single" value="#{availableProjectsBean.projectsRoot}" var="node"> <p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/> - + <p:treeNode type="project"> <h:outputText style="font-weight: #{selectedProjectBean.getFontWeight(node)}" value="#{node}"> <f:converter converterId="kieker.webgui.converter.MIProjectToStringConverter" /> </h:outputText> </p:treeNode> - + <p:treeNode type="dependencies"> <h:outputText value="#{node}" /> </p:treeNode> - + <p:treeNode type="usedPlugins"> <h:outputText value="#{node}" /> </p:treeNode> - - <p:treeNode type="usedPlugin"> + + <p:treeNode type="usedPlugin"> <h:outputText value="#{node}" /> </p:treeNode> </p:tree> <p:contextMenu for="projectsTree" nodeType="project"> <p:menuitem value="Save Project" ajax="true" action="#{availableProjectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> - <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> + <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette" /> <p:separator /> <p:menuitem value="Delete Project" ajax="true" action="#{availableProjectsBean.deleteProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:menuitem value="Reset Project" ajax="true" action="#{availableProjectsBean.resetProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:separator /> <p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" /> </p:contextMenu> - + <p:contextMenu for="projectsTree" nodeType="dependencies"> </p:contextMenu> - + <p:contextMenu for="projectsTree" nodeType="usedPlugins"> </p:contextMenu> </h:form> @@ -100,6 +102,8 @@ <!-- ******************************************************************************** --> <!-- The following layout unit is within the center and used for the graph. --> <p:layoutUnit position="center"> + <div id="workspace" style="width: fill-available; height: 100%" > + </div> </p:layoutUnit> <!-- ******************************************************************************** --> @@ -143,11 +147,29 @@ <!-- 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" resizable="true" collapsible="true"> - <h:form> - <p:tree style="width: auto" - value="#{selectedProjectBean.availablePluginsRoot}" var="node"> - <p:treeNode> - <h:outputText value="#{node}" /> + <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> + <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> </h:form> @@ -155,6 +177,8 @@ <!-- ******************************************************************************** --> </p:layout> + <p:growl id="messages" showDetail="true" autoUpdate="true" sticky="false"/> + <!-- Include the dialogs for creating/deleting projects etc. --> <ui:include src="main\projectDialogs.xhtml" /> diff --git a/Kieker.WebGUI/src/main/webapp/main/joint.dia.uml.min.js b/Kieker.WebGUI/src/main/webapp/main/joint.dia.uml.min.js new file mode 100644 index 00000000..d008f145 --- /dev/null +++ b/Kieker.WebGUI/src/main/webapp/main/joint.dia.uml.min.js @@ -0,0 +1,5 @@ +/** + * Joint 0.4 - JavaScript diagramming library. + * Copyright (c) David Durman 2009 - 2011 + * Licensed under the MIT license: (http://www.opensource.org/licenses/mit-license.php) + */(function(g){var e=g.Joint;g=e.dia.Element;var h=e.point,f=e.dia.uml={};e.arrows.aggregation=function(){return{path:["M","7","0","L","0","5","L","-7","0","L","0","-5","z"],dx:9,dy:9,attrs:{stroke:"black","stroke-width":2,fill:"black"}}};f.aggregationArrow={endArrow:{type:"aggregation"},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.dependencyArrow={endArrow:{type:"basic",size:5},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.generalizationArrow={endArrow:{type:"basic", size:10,attrs:{fill:"white"}},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.arrow={startArrow:{type:"none"},endArrow:{type:"basic",size:5},attrs:{"stroke-dasharray":"none"}};f.State=g.extend({object:"State",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{radius:15,attrs:{fill:"white"},label:"",labelOffsetX:20,labelOffsetY:5,swimlaneOffsetY:18,actions:{entry:null,exit:null,inner:[]},actionsOffsetX:5,actionsOffsetY:5});this.setWrapper(this.paper.rect(a.rect.x,a.rect.y, a.rect.width,a.rect.height,a.radius).attr(a.attrs));this.addInner(this.getLabelElement());this.addInner(this.getSwimlaneElement());this.addInner(this.getActionsElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x,b.y,a.label).attr(a.labelAttrs||{}),d=c.getBBox();c.translate(b.x-d.x+a.labelOffsetX,b.y-d.y+a.labelOffsetY);return c},getSwimlaneElement:function(){var a=this.wrapper.getBBox(),b=this.properties;return this.paper.path(["M",a.x,a.y+b.labelOffsetY+ b.swimlaneOffsetY,"L",a.x+a.width,a.y+b.labelOffsetY+b.swimlaneOffsetY].join(" "))},getActionsElement:function(){var a=this.properties,b=a.actions.entry?"entry/ "+a.actions.entry+"\n":"";b+=a.actions.exit?"exit/ "+a.actions.exit+"\n":"";for(var c=a.actions.inner.length,d=0;d<c;d+=2)b+=a.actions.inner[d]+"/ "+a.actions.inner[d+1]+"\n";b=b.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();a=this.paper.text(c.x+a.actionsOffsetX,c.y+a.labelOffsetY+a.swimlaneOffsetY+a.actionsOffsetY,b); b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},zoom:function(){this.wrapper.attr("r",this.properties.radius);this.shadow&&this.shadow.attr("r",this.properties.radius);this.inner[0].remove();this.inner[1].remove();this.inner[2].remove();this.inner[0]=this.getLabelElement();this.inner[1]=this.getSwimlaneElement();this.inner[2]=this.getActionsElement()}});f.StartState=g.extend({object:"StartState",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{position:h(0, 0),radius:10,attrs:{fill:"black"}});this.setWrapper(this.paper.circle(a.position.x,a.position.y,a.radius).attr(a.attrs))}});f.EndState=g.extend({object:"EndState",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{position:h(0,0),radius:10,innerRadius:a.radius&&a.radius/2||5,attrs:{fill:"white"},innerAttrs:{fill:"black"}});this.setWrapper(this.paper.circle(a.position.x,a.position.y,a.radius).attr(a.attrs));this.addInner(this.paper.circle(a.position.x,a.position.y,a.innerRadius).attr(a.innerAttrs))}, zoom:function(){this.inner[0].scale.apply(this.inner[0],arguments)}});f.Class=g.extend({object:"Class",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{attrs:{fill:"white"},label:"",labelOffsetX:20,labelOffsetY:5,swimlane1OffsetY:18,swimlane2OffsetY:18,attributes:[],attributesOffsetX:5,attributesOffsetY:5,methods:[],methodsOffsetX:5,methodsOffsetY:5});this.setWrapper(this.paper.rect(a.rect.x,a.rect.y,a.rect.width,a.rect.height).attr(a.attrs));this.addInner(this.getLabelElement()); this.addInner(this.getSwimlane1Element());this.addInner(this.getAttributesElement());this.addInner(this.getSwimlane2Element());this.addInner(this.getMethodsElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x,b.y,a.label).attr(a.labelAttrs||{}),d=c.getBBox();c.translate(b.x-d.x+a.labelOffsetX,b.y-d.y+a.labelOffsetY);return c},getSwimlane1Element:function(){var a=this.wrapper.getBBox(),b=this.properties;return this.paper.path(["M",a.x,a.y+b.labelOffsetY+ b.swimlane1OffsetY,"L",a.x+a.width,a.y+b.labelOffsetY+b.swimlane1OffsetY].join(" "))},getSwimlane2Element:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.inner[2].getBBox();return this.paper.path(["M",b.x,b.y+a.labelOffsetY+a.swimlane1OffsetY+c.height+a.swimlane2OffsetY,"L",b.x+b.width,b.y+a.labelOffsetY+a.swimlane1OffsetY+c.height+a.swimlane2OffsetY].join(" "))},getAttributesElement:function(){for(var a=" ",b=this.properties,c=0,d=b.attributes.length;c<d;c++)a+=b.attributes[c]+"\n"; a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();a=this.paper.text(c.x+b.attributesOffsetX,c.y+b.labelOffsetY+b.swimlane1OffsetY+b.attributesOffsetY,a);b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},getMethodsElement:function(){for(var a=" ",b=this.properties,c=0,d=b.methods.length;c<d;c++)a+=b.methods[c]+"\n";a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();d=this.inner[2].getBBox();a=this.paper.text(c.x+b.methodsOffsetX, c.y+b.labelOffsetY+b.swimlane1OffsetY+b.attributesOffsetY+d.height+b.swimlane2OffsetY+b.methodsOffsetY,a);b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},zoom:function(){this.inner[0].remove();this.inner[1].remove();this.inner[2].remove();this.inner[3].remove();this.inner[4].remove();this.inner[0]=this.getLabelElement();this.inner[1]=this.getSwimlane1Element();this.inner[2]=this.getAttributesElement();this.inner[3]=this.getSwimlane2Element();this.inner[4]=this.getMethodsElement()}})})(this); diff --git a/Kieker.WebGUI/src/main/webapp/main/raphael-min.js b/Kieker.WebGUI/src/main/webapp/main/raphael-min.js new file mode 100644 index 00000000..cf95128b --- /dev/null +++ b/Kieker.WebGUI/src/main/webapp/main/raphael-min.js @@ -0,0 +1,7 @@ +<html> +<head><title>301 Moved Permanently</title></head> +<body bgcolor="white"> +<center><h1>301 Moved Permanently</h1></center> +<hr><center>nginx/1.0.12</center> +</body> +</html> -- GitLab