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,24 +16,50 @@ import kieker.analysis.plugin.port.Plugin; ...@@ -16,24 +16,50 @@ import kieker.analysis.plugin.port.Plugin;
*/ */
public class PluginFinder { 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
final JarFile jarFile = new JarFile(new File(url.getPath())); * has the Plugin-Annotation from the Kieker framework.
final List<Class<?>> result = new ArrayList<Class<?>>(); *
Enumeration<JarEntry> jarEntries = jarFile.entries(); * @param url The url for the jar.
while (jarEntries.hasMoreElements()) { * @return A list containing all available plugin-classes or null, if an
JarEntry jarEntry = (JarEntry) jarEntries.nextElement(); * exception occured.
try { */
String name = jarEntry.toString(); public static List<Class<?>> getAllPluginsWithinJar(final URL url) {
name = name.replace('/', '.'); try {
name = name.replace(".class", ""); /*
Class<?> c = classLoader.loadClass(name); * Get a classloader and make sure that it has the system class
if (c.isAnnotationPresent(Plugin.class)) { * loader as parent and that it knows the url.
result.add(c); */
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;
} }
} }
...@@ -42,24 +42,35 @@ ...@@ -42,24 +42,35 @@
<p:submenu label="Help"> <p:submenu label="Help">
<p:menuitem value="About..." onclick="AboutDialog.show();"/> <p:menuitem value="About..." onclick="AboutDialog.show();"/>
</p:submenu> </p:submenu>
</p:menubar> </p:menubar>
</h:form> </h:form>
</p:layoutUnit> </p:layoutUnit>
<!-- The following layout is at the left side of the page and shows the available projects. --> <!-- 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"> <p:layoutUnit style="font-size:15px" header="Projects" collapsible="true" position="west" size="200" resizable="true" minSize="100">
<h:form id="ProjectsList"> <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> <p:treeNode>
<h:outputText value="#{node}"/> <h:outputText value="#{node}"/>
</p:treeNode> </p:treeNode>
</p:tree> </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> </h:form>
</p:layoutUnit> </p:layoutUnit>
<!-- The following layout unit is within the center and used for the graph. --> <!-- 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> </p:layoutUnit>
<!-- The following layout unit is located at the bottom and will be used for properties. --> <!-- The following layout unit is located at the bottom and will be used for properties. -->
...@@ -93,7 +104,7 @@ ...@@ -93,7 +104,7 @@
<p:rowEditor /> <p:rowEditor />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</p:layoutUnit> </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. --> <!-- 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. -->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment