From d08754d783baa759640ae5a0cdeb7b119ce13c3b Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Sun, 7 Oct 2012 09:28:11 +0200
Subject: [PATCH] #619

---
 .../beans/view/CurrentAnalysisEditorBean.java | 29 ++++++++++++++-----
 .../common/ClassAndMethodContainer.java       | 12 ++++++++
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java
index decd02f1..5f211f53 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/CurrentAnalysisEditorBean.java
@@ -326,21 +326,34 @@ public final class CurrentAnalysisEditorBean {
 	@SuppressWarnings("unchecked")
 	private void addContentsToToolPalette(final List<Class<AbstractPlugin>> plugins, final List<Class<AbstractRepository>> repositories) {
 		synchronized (this) {
-			// Now run through the available classes and add all non-abstract classes to our lists
+			// Now run through the available classes and add all non-abstract classes to our lists.
 			for (final Class<AbstractRepository> repository : repositories) {
 				if (!Modifier.isAbstract(repository.getModifiers())) {
-					this.availableRepositories.add(repository);
+					// Make also sure that the current repository is not "programmaticOnly"
+					final Annotation annotationRepository = repository.getAnnotation(this.classAndMethodContainer.getRepositoryAnnotationClass());
+					final boolean programmaticOnly = (Boolean) ClassAndMethodContainer.invokeMethod(
+							this.classAndMethodContainer.getRepositoryProgrammaticOnlyMethod(),
+							annotationRepository, false);
+					if (!programmaticOnly) {
+						this.availableRepositories.add(repository);
+					}
 				}
 			}
 
 			for (final Class<?> plugin : plugins) {
 				if (!Modifier.isAbstract(plugin.getModifiers())) {
-					// The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct.
-					if (this.classAndMethodContainer.getAbstractFilterPluginClass().isAssignableFrom(plugin)) {
-						this.availableFilters.add((Class<AbstractFilterPlugin>) plugin);
-					} else {
-						if (this.classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(plugin)) {
-							this.availableReaders.add((Class<AbstractReaderPlugin>) plugin);
+					// Make also sure that the current plugin is not "programmaticOnly"
+					final Annotation annotationPlugin = plugin.getAnnotation(this.classAndMethodContainer.getPluginAnnotationClass());
+					final boolean programmaticOnly = (Boolean) ClassAndMethodContainer.invokeMethod(this.classAndMethodContainer.getPluginProgrammaticOnlyMethod(),
+							annotationPlugin, false);
+					if (!programmaticOnly) {
+						// The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct.
+						if (this.classAndMethodContainer.getAbstractFilterPluginClass().isAssignableFrom(plugin)) {
+							this.availableFilters.add((Class<AbstractFilterPlugin>) plugin);
+						} else {
+							if (this.classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(plugin)) {
+								this.availableReaders.add((Class<AbstractReaderPlugin>) plugin);
+							}
 						}
 					}
 				}
diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java
index cf785bfc..2097e237 100644
--- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java
+++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java
@@ -222,6 +222,8 @@ public final class ClassAndMethodContainer {
 	private final Method displayDescriptionMethod;
 	private final Method pluginDependenciesMethod;
 	private final Method repositoryDependenciesMethod;
+	private final Method pluginProgrammaticOnlyMethod;
+	private final Method repositoryProgrammaticOnlyMethod;
 	/**
 	 * This is the constructor for {@link AnalysisControllerThread}, which gets an instance of {@link AnalysisController}.
 	 */
@@ -280,6 +282,8 @@ public final class ClassAndMethodContainer {
 			this.displayDescriptionMethod = this.displayAnnotationClass.getMethod("description", new Class<?>[0]);
 			this.pluginDependenciesMethod = this.pluginAnnotationClass.getMethod("dependencies", new Class<?>[0]);
 			this.repositoryDependenciesMethod = this.repositoryAnnotationClass.getMethod("dependencies", new Class<?>[0]);
+			this.pluginProgrammaticOnlyMethod = this.pluginAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]);
+			this.repositoryProgrammaticOnlyMethod = this.repositoryAnnotationClass.getMethod("programmaticOnly", new Class<?>[0]);
 			// This is a special case as we need to load some additional classes to search for the correct method
 			final Class<?> miProjectClass = classLoader.loadClass(MIProject.class.getName());
 			this.analysisControllerLoadFromFile = this.analysisControllerClass.getMethod("loadFromFile", File.class);
@@ -699,6 +703,14 @@ public final class ClassAndMethodContainer {
 		return this.repositoryDependenciesMethod;
 	}
 
+	public Method getPluginProgrammaticOnlyMethod() {
+		return this.pluginProgrammaticOnlyMethod;
+	}
+
+	public Method getRepositoryProgrammaticOnlyMethod() {
+		return this.repositoryProgrammaticOnlyMethod;
+	}
+
 	/**
 	 * This method can be used to invoke a given method with given parameters, without having to mind about the exceptions. If an exception occurs, the given default
 	 * value will be returned.
-- 
GitLab