Skip to content
Snippets Groups Projects
Commit 170a6b3f authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Solved minor problems and made sure that the user can select libraries for...

Solved minor problems and made sure that the user can select libraries for projects; Updated the Kieker-Jar
parent 6e45b562
No related branches found
No related tags found
No related merge requests found
Showing
with 51 additions and 90 deletions
No preview for this file type
...@@ -32,7 +32,7 @@ import kieker.analysis.model.analysisMetaModel.MIProject; ...@@ -32,7 +32,7 @@ import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.webgui.beans.session.SelectedProjectBean; 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 * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
...@@ -41,12 +41,22 @@ import kieker.webgui.beans.session.SelectedProjectBean; ...@@ -41,12 +41,22 @@ import kieker.webgui.beans.session.SelectedProjectBean;
@RequestScoped @RequestScoped
public class SelectedDependenciesBean { public class SelectedDependenciesBean {
/**
* This list contains the currently selected dependencies.
*/
private List<MIDependency> dependencies; private List<MIDependency> dependencies;
/**
* This field contains the corresponding project, which will be mofified by this bean.
*/
private final MIProject project; private final MIProject project;
/**
* Creates a new instance of this class.
*/
public SelectedDependenciesBean() { public SelectedDependenciesBean() {
this.dependencies = new ArrayList<MIDependency>(); this.dependencies = new ArrayList<MIDependency>();
/* Try to get the currently selected project. */
final FacesContext context = FacesContext.getCurrentInstance(); final FacesContext context = FacesContext.getCurrentInstance();
final SelectedProjectBean selProjBean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}", final SelectedProjectBean selProjBean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}",
...@@ -58,89 +68,29 @@ public class SelectedDependenciesBean { ...@@ -58,89 +68,29 @@ public class SelectedDependenciesBean {
} }
} }
// /**
// /** * Delivers the currently selected dependencies.
// * A dual model containing all available dependencies and the currently choosen one. *
// */ * @return The selected dependencies.
// 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());
// }
// }
public List<MIDependency> getDependencies() { public List<MIDependency> getDependencies() {
return this.dependencies; 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) { public void setDependencies(final List<MIDependency> dependencies) {
this.dependencies = 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() { public void submit() {
// TODO Error while executing this method
if (this.project != null) { if (this.project != null) {
this.project.getDependencies().clear(); this.project.getDependencies().clear();
this.project.getDependencies().addAll(this.dependencies); this.project.getDependencies().addAll(this.dependencies);
......
...@@ -26,8 +26,6 @@ import javax.faces.bean.ManagedBean; ...@@ -26,8 +26,6 @@ import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext; 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 * 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 * currently used theme (look and feel) for this user. Currently the
......
...@@ -146,7 +146,7 @@ public final class FileManager { ...@@ -146,7 +146,7 @@ public final class FileManager {
final AnalysisController controller = new AnalysisController(project); final AnalysisController controller = new AnalysisController(project);
return controller.saveToFile(fileProject); return controller.saveToFile(fileProject);
} catch (final Exception ex) { } catch (final Exception ex) {
FileManager.LOG.error("Could not save project '" + projectName + "'."); FileManager.LOG.error("Could not save project '" + projectName + "'.", ex);
return false; return false;
} }
} }
...@@ -210,7 +210,7 @@ public final class FileManager { ...@@ -210,7 +210,7 @@ public final class FileManager {
resultList.add(project); resultList.add(project);
} }
} catch (final Exception ex) { } 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 { ...@@ -361,12 +361,12 @@ public final class FileManager {
public MIProject reloadProject(final MIProject project) { public MIProject reloadProject(final MIProject project) {
final String projectName = project.getName(); 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()) { if (projectFile.isFile()) {
try { try {
return AnalysisController.loadFromFile(projectFile); return AnalysisController.loadFromFile(projectFile);
} catch (Exception ex) { } catch (Exception ex) {
FileManager.LOG.warn("Error reloaded project '" + projectName + "'"); FileManager.LOG.warn("Error reloaded project '" + projectName + "'", ex);
} }
} }
return null; return null;
......
...@@ -24,6 +24,7 @@ import java.net.URL; ...@@ -24,6 +24,7 @@ import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map;
import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController;
...@@ -45,7 +46,7 @@ public final class PluginClassLoader { ...@@ -45,7 +46,7 @@ public final class PluginClassLoader {
/** /**
* This list contains a class loader for each url added to this class loader. * 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. * The default constructor of this class.
...@@ -107,6 +108,7 @@ public final class PluginClassLoader { ...@@ -107,6 +108,7 @@ public final class PluginClassLoader {
final Class<?> resultingClass = currClassLoader.loadClass(name); final Class<?> resultingClass = currClassLoader.loadClass(name);
return resultingClass; return resultingClass;
} catch (final ClassNotFoundException ex) { } catch (final ClassNotFoundException ex) {
// Ignore error
} }
} }
} }
......
...@@ -75,7 +75,7 @@ public final class PluginFinder { ...@@ -75,7 +75,7 @@ public final class PluginFinder {
if (c.isAnnotationPresent(Plugin.class)) { if (c.isAnnotationPresent(Plugin.class)) {
result.add(c); result.add(c);
} }
} catch (final Throwable ex) { } catch (final Throwable ex) { // NOCS (IllegalCatchCheck)
/* Ignore error. */ /* Ignore error. */
} }
} }
......
...@@ -45,7 +45,7 @@ public class MIDependencyToSizeConverter implements Converter { ...@@ -45,7 +45,7 @@ public class MIDependencyToSizeConverter implements Converter {
/** /**
* The factor used to convert the size into MiBytes. * 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. * Creates a new instance of this class.
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
package kieker.webgui.converter; package kieker.webgui.converter;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
...@@ -31,7 +31,8 @@ import javax.faces.convert.FacesConverter; ...@@ -31,7 +31,8 @@ import javax.faces.convert.FacesConverter;
import kieker.analysis.model.analysisMetaModel.MIDependency; 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 * @author Nils Christian Ehmke
* @version 1.0 * @version 1.0
...@@ -43,6 +44,10 @@ public class MIDependencyToStringConverter implements Converter { ...@@ -43,6 +44,10 @@ public class MIDependencyToStringConverter implements Converter {
* This is the name of the converter. * This is the name of the converter.
*/ */
public static final String NAME = "kieker.webgui.converter.MIDependencyToStringConverter"; 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. * Creates a new instance of this class.
...@@ -66,7 +71,7 @@ public class MIDependencyToStringConverter implements Converter { ...@@ -66,7 +71,7 @@ public class MIDependencyToStringConverter implements Converter {
*/ */
@Override @Override
public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { 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 { ...@@ -88,7 +93,9 @@ public class MIDependencyToStringConverter implements Converter {
if (!(o instanceof MIDependency)) { if (!(o instanceof MIDependency)) {
return ""; return "";
} else { } 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;
} }
} }
} }
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
<p:layoutUnit header="Currently used Dependencies" position="center" > <p:layoutUnit header="Currently used Dependencies" position="center" >
<h:form> <h:form>
<p:selectManyCheckbox value="#{selectedDependenciesBean.dependencies}" <p:selectManyCheckbox value="#{selectedDependenciesBean.dependencies}"
layout="pageDirection"> layout="pageDirection"
<f:selectItems value="#{availableDependenciesBean.dependencies}" /> converter="kieker.webgui.converter.MIDependencyToStringConverter">
<f:selectItems value="#{availableDependenciesBean.dependencies}" var="dependency" itemLabel="#{dependency.filePath}" />
</p:selectManyCheckbox> </p:selectManyCheckbox>
<p:spacer width="0px" height="20px"/> <p:spacer width="0px" height="20px"/>
<div align="center"> <div align="center">
......
...@@ -40,6 +40,9 @@ public class PluginFinderTest extends TestCase { ...@@ -40,6 +40,9 @@ public class PluginFinderTest extends TestCase {
*/ */
public PluginFinderTest() {} public PluginFinderTest() {}
/**
* This test makes sure that the plugin finder is able to find plugins within the kieker jar.
*/
@Test @Test
public void testKiekerJarContainsPlugins() { public void testKiekerJarContainsPlugins() {
/* It can be assumed that the kieker jar contains at least one plugin. */ /* It can be assumed that the kieker jar contains at least one plugin. */
......
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