Skip to content
Snippets Groups Projects
Commit 5c3ac9e1 authored by nie's avatar nie
Browse files

Added comments & context menu.

parent b6aefb09
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,24 @@ 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});
/**
* 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();
......@@ -27,7 +43,14 @@ public class PluginFinder {
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);
}
......@@ -35,5 +58,8 @@ public class PluginFinder {
}
}
return result;
} catch (IOException ex) {
return null;
}
}
}
......@@ -42,23 +42,34 @@
<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}"/>
</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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment