From 5c3ac9e196238f6919b74aff6c450f969822ff88 Mon Sep 17 00:00:00 2001 From: nie <nie@informatik.uni-kiel.de> Date: Sat, 31 Dec 2011 01:07:18 +0100 Subject: [PATCH] Added comments & context menu. --- .../kieker/webgui/common/PluginFinder.java | 58 ++++++++++++++----- Kieker.WebGUI/src/main/webapp/main.xhtml | 21 +++++-- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 2c96f898..b5ac3306 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -16,24 +16,50 @@ import kieker.analysis.plugin.port.Plugin; */ public class PluginFinder { - public static List<Class<?>> getAllPluginsWithinJar(final URL url) throws IOException { - final ClassLoader classLoader = new URLClassLoader(new URL[]{url}); - final JarFile jarFile = new JarFile(new File(url.getPath())); - final List<Class<?>> result = new ArrayList<Class<?>>(); - Enumeration<JarEntry> jarEntries = jarFile.entries(); - while (jarEntries.hasMoreElements()) { - JarEntry jarEntry = (JarEntry) jarEntries.nextElement(); - try { - String name = jarEntry.toString(); - name = name.replace('/', '.'); - name = name.replace(".class", ""); - Class<?> c = classLoader.loadClass(name); - if (c.isAnnotationPresent(Plugin.class)) { - result.add(c); + /** + * This method delivers all classes which are available in the given jar and + * has the Plugin-Annotation from the Kieker framework. + * + * @param url The url for the jar. + * @return A list containing all available plugin-classes or null, if an + * exception occured. + */ + public static List<Class<?>> getAllPluginsWithinJar(final URL url) { + try { + /* + * Get a classloader and make sure that it has the system class + * loader as parent and that it knows the url. + */ + final ClassLoader classLoader = new URLClassLoader(new URL[]{url}, ClassLoader.getSystemClassLoader()); + /* + * Open the jar file and run through all entries within this file. + */ + final JarFile jarFile = new JarFile(new File(url.getPath())); + final List<Class<?>> result = new ArrayList<Class<?>>(); + Enumeration<JarEntry> jarEntries = jarFile.entries(); + while (jarEntries.hasMoreElements()) { + JarEntry jarEntry = (JarEntry) jarEntries.nextElement(); + try { + String name = jarEntry.toString(); + name = name.replace('/', '.'); + name = name.replace(".class", ""); + /* + * Try to find a class with the same name. + */ + Class<?> c = classLoader.loadClass(name); + /* + * If it is a class and has the annotation - put it into our + * list. + */ + if (c.isAnnotationPresent(Plugin.class)) { + result.add(c); + } + } catch (Throwable ex) { } - } catch (Throwable ex) { } + return result; + } catch (IOException ex) { + return null; } - return result; } } diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 1e1bfa88..0daec44e 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -42,24 +42,35 @@ <p:submenu label="Help"> <p:menuitem value="About..." onclick="AboutDialog.show();"/> </p:submenu> + </p:menubar> + </h:form> </p:layoutUnit> <!-- The following layout is at the left side of the page and shows the available projects. --> <p:layoutUnit style="font-size:15px" header="Projects" collapsible="true" position="west" size="200" resizable="true" minSize="100"> <h:form id="ProjectsList"> - <p:tree selectionMode="single" style="width: auto" value="#{projectsBean.projectsRoot}" var="node" > + <p:tree id="ProjectsListTree" selectionMode="single" style="width: auto" value="#{projectsBean.projectsRoot}" var="node" > <p:treeNode> - <h:outputText value="#{node}"/> + <h:outputText value="#{node}"/> </p:treeNode> </p:tree> + + <p:contextMenu style="font-size:15px" for="ProjectsListTree"> + <p:menuitem value="Set as Main Project" update="ProjectsList"/> + <p:menuitem value="Save Project" update="ProjectsList"/> + <p:separator/> + <p:menuitem value="Delete Project" /> + </p:contextMenu> + </h:form> + </p:layoutUnit> <!-- The following layout unit is within the center and used for the graph. --> - <p:layoutUnit position="center"> - + <p:layoutUnit style="font-size:15px" position="center"> + </p:layoutUnit> <!-- The following layout unit is located at the bottom and will be used for properties. --> @@ -93,7 +104,7 @@ <p:rowEditor /> </p:column> - </p:dataTable> + </p:dataTable> </p:layoutUnit> <!-- 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. --> -- GitLab