diff --git a/Kieker.WebGUI/lib/kieker-1.5-SNAPSHOT.jar b/Kieker.WebGUI/lib/kieker-1.5-SNAPSHOT.jar index 43951c2c219d6cd5e08376d746e595be6abb7c15..ac109796b7bdfaa0b6818ef6332b0de816c05d36 100644 Binary files a/Kieker.WebGUI/lib/kieker-1.5-SNAPSHOT.jar and b/Kieker.WebGUI/lib/kieker-1.5-SNAPSHOT.jar differ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java index c1e0a79d4709bf6354a94855c1154034ae2a05da..fab9532f1ac9d1f4576e28fcd3ca322cf052b9ba 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java @@ -32,7 +32,7 @@ import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.beans.session.SelectedProjectBean; /** - * This bean contains the currently choosen dependencies. + * This bean contains the currently choosen dependencies. This has to be request scoped, because the bean fetches the currently selected project when created. * * @author Nils Christian Ehmke * @version 1.0 @@ -41,12 +41,22 @@ import kieker.webgui.beans.session.SelectedProjectBean; @RequestScoped public class SelectedDependenciesBean { + /** + * This list contains the currently selected dependencies. + */ private List<MIDependency> dependencies; + /** + * This field contains the corresponding project, which will be mofified by this bean. + */ private final MIProject project; + /** + * Creates a new instance of this class. + */ public SelectedDependenciesBean() { this.dependencies = new ArrayList<MIDependency>(); + /* Try to get the currently selected project. */ final FacesContext context = FacesContext.getCurrentInstance(); final SelectedProjectBean selProjBean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", @@ -58,89 +68,29 @@ public class SelectedDependenciesBean { } } - // - // /** - // * A dual model containing all available dependencies and the currently choosen one. - // */ - // private DualListModel<MIDependency> dependencies; - // /** - // * The currently selected project. - // */ - // private final MIProject project; - // - // /** - // * Creates a new instance of this class. - // */ - // public SelectedDependenciesBean() { - // final List<MIDependency> source = new ArrayList<MIDependency>(); - // final List<MIDependency> target = new ArrayList<MIDependency>(); - // - // this.dependencies = new DualListModel<MIDependency>(source, target); - // - // final FacesContext context = FacesContext.getCurrentInstance(); - // - // final SelectedProjectBean selProjBean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", - // SelectedProjectBean.class); - // if (selProjBean != null) { - // this.project = selProjBean.getSelectedProject(); - // } else { - // this.project = null; - // } - // - // /* Get all available libs. */ - // - // final AvailableDependenciesBean availDepBean = context.getApplication().evaluateExpressionGet(context, "#{availableDependenciesBean}", - // AvailableDependenciesBean.class); - // this.dependencies.getSource().clear(); - // if (availDepBean != null) { - // this.dependencies.getSource().addAll(availDepBean.getDependencies()); - // } - // this.dependencies.getTarget().clear(); - // - // /* Now move the already selected to the right side. */ - // if (this.project != null) { - // final List<MIDependency> projectLibs = this.project.getDependencies(); - // for (final MIDependency lib : projectLibs) { - // this.dependencies.getSource().remove(lib); - // this.dependencies.getTarget().add(lib); - // } - // } - // } - // - // /** - // * Delivers the stored dependencies within this bean. - // * - // * @return The dependencies dual model. - // */ - // public final DualListModel<MIDependency> getDependencies() { - // return this.dependencies; - // } - // - // /** - // * Sets the dependencies to be stored within this bean to a new value. - // * - // * @param dependencies - // * The new dependencies dual model. - // */ - // public final void setDependencies(final DualListModel<MIDependency> dependencies) { - // this.dependencies = dependencies; - // /* Remember the selected libs. */ - // if (this.project != null) { - // this.project.getDependencies().clear(); - // this.project.getDependencies().addAll(dependencies.getTarget()); - // } - // } - + /** + * Delivers the currently selected dependencies. + * + * @return The selected dependencies. + */ public List<MIDependency> getDependencies() { return this.dependencies; } + /** + * Sets the currently selected dependencies to a new value. + * + * @param dependencies + * The newly selected dependencies. + */ public void setDependencies(final List<MIDependency> dependencies) { this.dependencies = dependencies; } + /** + * This method should be called as an action. It clears the project's dependencies and adds all currently selected dependencies to this project. + */ public void submit() { - // TODO Error while executing this method if (this.project != null) { this.project.getDependencies().clear(); this.project.getDependencies().addAll(this.dependencies); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index f7c4adf335d864bdd6caa1fa49f086bdbd0d0706..8bdc9f3bad232b82728132af7e86798fda3f222e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -26,8 +26,6 @@ import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; -import kieker.webgui.beans.application.ThemeSwitcherBean; - /** * This bean can be used for a single session of a user and stores the * currently used theme (look and feel) for this user. Currently the 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 d80476fe2c78c6f8f14e6d1828beffe50d595ef1..4495e6371e0b30a60bc1697118bfbf5bd195bd05 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java @@ -146,7 +146,7 @@ public final class FileManager { final AnalysisController controller = new AnalysisController(project); return controller.saveToFile(fileProject); } catch (final Exception ex) { - FileManager.LOG.error("Could not save project '" + projectName + "'."); + FileManager.LOG.error("Could not save project '" + projectName + "'.", ex); return false; } } @@ -210,7 +210,7 @@ public final class FileManager { resultList.add(project); } } catch (final Exception ex) { - FileManager.LOG.error("Could not load project '" + directory.getName() + "'."); + FileManager.LOG.error("Could not load project '" + directory.getName() + "'.", ex); } } } @@ -361,12 +361,12 @@ public final class FileManager { public MIProject reloadProject(final MIProject project) { final String projectName = project.getName(); - final File projectFile = new File(FileManager.PROJECT_DIR + File.separator + projectName + File.separator + projectName + EXTENSION); + final File projectFile = new File(FileManager.PROJECT_DIR + File.separator + projectName + File.separator + projectName + FileManager.EXTENSION); if (projectFile.isFile()) { try { return AnalysisController.loadFromFile(projectFile); } catch (Exception ex) { - FileManager.LOG.warn("Error reloaded project '" + projectName + "'"); + FileManager.LOG.warn("Error reloaded project '" + projectName + "'", ex); } } return null; 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 7e543f092f99d269f31909cb90db336b4507bbef..27e445a9033ec8f52d61214ac003dfcee1e1f9dc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java @@ -24,6 +24,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import kieker.analysis.AnalysisController; @@ -45,7 +46,7 @@ public final class PluginClassLoader { /** * This list contains a class loader for each url added to this class loader. */ - private final HashMap<URL, URLClassLoader> classLoaders = new HashMap<URL, URLClassLoader>(); + private final Map<URL, URLClassLoader> classLoaders = new HashMap<URL, URLClassLoader>(); /** * The default constructor of this class. @@ -107,6 +108,7 @@ public final class PluginClassLoader { final Class<?> resultingClass = currClassLoader.loadClass(name); return resultingClass; } catch (final ClassNotFoundException ex) { + // Ignore error } } } 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 7c3bf66ce57bf9c96e71eed49ea9c93076d1099b..c8b003d2fa520a6a0773a5d53ae31b771ec69ade 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -75,7 +75,7 @@ public final class PluginFinder { if (c.isAnnotationPresent(Plugin.class)) { result.add(c); } - } catch (final Throwable ex) { + } catch (final Throwable ex) { // NOCS (IllegalCatchCheck) /* Ignore error. */ } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToSizeConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToSizeConverter.java index f63bbcca19185c381de6dad2c16407c5680248d4..6e05567fde6477c9e2e0be2d424240989aabcfdd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToSizeConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToSizeConverter.java @@ -45,7 +45,7 @@ public class MIDependencyToSizeConverter implements Converter { /** * The factor used to convert the size into MiBytes. */ - private static final double FACTOR = 1.0 / 1024 / 1024; + private static final double FACTOR = 1.0 / 1024 / 1024; // NOCS (MagicNumberCheck) /** * Creates a new instance of this class. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java index 7b8d985cd99bfe4316492b4784f47f835a219b05..e528e2674938dc60be5fa61c007f1df9e440f196 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java @@ -21,7 +21,7 @@ package kieker.webgui.converter; import java.io.File; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; @@ -31,7 +31,8 @@ import javax.faces.convert.FacesConverter; import kieker.analysis.model.analysisMetaModel.MIDependency; /** - * This converter can be used to convert an instance of <i>MIDependency</i> to a human readable string, but <b>not</b> vice versa. + * This converter can be used to convert an instance of <i>MIDependency</i> to a human readable string and also vice versa. This implies that the names of the + * libraries (as those are shown as human readable strings) have to be unique. Otherwise the string cannot be mapped to the corresponding object. * * @author Nils Christian Ehmke * @version 1.0 @@ -43,6 +44,10 @@ public class MIDependencyToStringConverter implements Converter { * This is the name of the converter. */ public static final String NAME = "kieker.webgui.converter.MIDependencyToStringConverter"; + /** + * This map is being used to store the already shown dependencies. + */ + private static final ConcurrentHashMap<String, MIDependency> MAP = new ConcurrentHashMap<String, MIDependency>(); /** * Creates a new instance of this class. @@ -66,7 +71,7 @@ public class MIDependencyToStringConverter implements Converter { */ @Override public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - return null; + return MIDependencyToStringConverter.MAP.get(string); } /** @@ -88,7 +93,9 @@ public class MIDependencyToStringConverter implements Converter { if (!(o instanceof MIDependency)) { return ""; } else { - return new File(((MIDependency) o).getFilePath()).getName(); + final String result = new File(((MIDependency) o).getFilePath()).getName(); + MIDependencyToStringConverter.MAP.put(result, (MIDependency) o); + return result; } } } diff --git a/Kieker.WebGUI/src/main/webapp/projectDependencies.xhtml b/Kieker.WebGUI/src/main/webapp/projectDependencies.xhtml index 550dedbeb3dcf4f5811620da23885d7df1e13328..4761f9b6d37766f34b120b262baad5aef0aa298f 100644 --- a/Kieker.WebGUI/src/main/webapp/projectDependencies.xhtml +++ b/Kieker.WebGUI/src/main/webapp/projectDependencies.xhtml @@ -23,8 +23,9 @@ <p:layoutUnit header="Currently used Dependencies" position="center" > <h:form> <p:selectManyCheckbox value="#{selectedDependenciesBean.dependencies}" - layout="pageDirection"> - <f:selectItems value="#{availableDependenciesBean.dependencies}" /> + layout="pageDirection" + converter="kieker.webgui.converter.MIDependencyToStringConverter"> + <f:selectItems value="#{availableDependenciesBean.dependencies}" var="dependency" itemLabel="#{dependency.filePath}" /> </p:selectManyCheckbox> <p:spacer width="0px" height="20px"/> <div align="center"> diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/common/PluginFinderTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/common/PluginFinderTest.java index 4b3512fa08f2febdc819aa20106136e41ea08f4d..66cae18af028f5125d219f5420fdd550fdecd82b 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/common/PluginFinderTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/common/PluginFinderTest.java @@ -40,6 +40,9 @@ public class PluginFinderTest extends TestCase { */ public PluginFinderTest() {} + /** + * This test makes sure that the plugin finder is able to find plugins within the kieker jar. + */ @Test public void testKiekerJarContainsPlugins() { /* It can be assumed that the kieker jar contains at least one plugin. */