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

Corrected some details; Started with the possibility to choose dependencies for the projects.

parent 340a5e1c
No related branches found
No related tags found
No related merge requests found
Showing
with 176 additions and 42 deletions
......@@ -25,6 +25,7 @@ import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIPlugin;
import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.webgui.beans.session.SelectedProjectBean;
......@@ -98,20 +99,23 @@ public class AvailableProjectsBean {
final TreeNode projectNode = new DefaultTreeNode("project", project, root);
final TreeNode dependenciesNode = new DefaultTreeNode("dependencies", "Dependencies", projectNode);
final TreeNode usedPluginsNode = new DefaultTreeNode("usedPlugins", "Used Plugins", projectNode);
for (final MIPlugin plugin : project.getPlugins()) {
final TreeNode usedPluginNode = new DefaultTreeNode("usedPlugin", plugin.getClassname(), usedPluginsNode);
}
}
return root;
}
public synchronized void saveProject(final MIProject project) {
}
public synchronized void deleteProject(final MIProject project) {
}
public synchronized void resetProject(final MIProject project) {
}
public synchronized void saveProject(final MIProject project) {
}
public synchronized void deleteProject(final MIProject project) {
}
public synchronized void resetProject(final MIProject project) {
}
}
......@@ -25,6 +25,12 @@ import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.webgui.beans.application.AvailableDependenciesBean;
import kieker.webgui.beans.session.SelectedProjectBean;
import org.primefaces.model.DualListModel;
......@@ -32,19 +38,47 @@ import org.primefaces.model.DualListModel;
@RequestScoped
public class SelectedDependenciesBean {
private DualListModel<String> dependencies;
private DualListModel<MIDependency> dependencies;
private final MIProject project;
private final FacesContext context;
/**
* Creates a new instance of this class.
*/
public SelectedDependenciesBean() {
final List<String> source = new ArrayList<String>();
final List<String> target = new ArrayList<String>();
final List<MIDependency> source = new ArrayList<MIDependency>();
final List<MIDependency> target = new ArrayList<MIDependency>();
this.dependencies = new DualListModel<MIDependency>(source, target);
this.context = FacesContext.getCurrentInstance();
source.add("Lib 1");
source.add("Lib 2");
final SelectedProjectBean selProjBean = this.context.getApplication().evaluateExpressionGet(this.context, "#{selectedProjectBean}",
SelectedProjectBean.class);
if (selProjBean != null) {
this.project = selProjBean.getSelectedProject();
} else {
this.project = null;
}
this.dependencies = new DualListModel<String>(source, target);
/* Get all available libs. */
final AvailableDependenciesBean availDepBean = this.context.getApplication().evaluateExpressionGet(this.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);
}
}
}
/**
......@@ -52,7 +86,7 @@ public class SelectedDependenciesBean {
*
* @return The dependencies dual model.
*/
public DualListModel<String> getDependencies() {
public DualListModel<MIDependency> getDependencies() {
return this.dependencies;
}
......@@ -62,8 +96,15 @@ public class SelectedDependenciesBean {
* @param dependencies
* The new dependencies dual model.
*/
public void setDependencies(final DualListModel<String> dependencies) {
public void setDependencies(final DualListModel<MIDependency> dependencies) {
System.out.println(dependencies);
this.dependencies = dependencies;
/* Remember the selected libs. */
if (this.project != null) {
this.project.getDependencies().clear();
this.project.getDependencies().addAll(dependencies.getTarget());
}
}
}
......@@ -59,5 +59,5 @@ public class StringBean {
public void setString(final String string) {
this.string = string;
}
}
......@@ -202,7 +202,7 @@ public final class FileManager {
* @return The new dependency iff the uploading was sucesfull, null
* otherwise.
*/
public MIDependency uploadDependency(final UploadedFile file) {
public synchronized MIDependency uploadDependency(final UploadedFile file) {
final File depFile = new File(FileManager.LIB_DIR, file.getFileName());
InputStream in = null;
......@@ -251,7 +251,7 @@ public final class FileManager {
*
* @return The singleton instance of this class.
*/
public static FileManager getInstance() {
public synchronized static FileManager getInstance() {
return FileManager.INSTANCE;
}
......@@ -260,7 +260,7 @@ public final class FileManager {
*
* @return A list containing all available dependencies. If there are no files, an empty list will be returned.
*/
public List<MIDependency> loadAllDependencies() {
public synchronized List<MIDependency> loadAllDependencies() {
final List<MIDependency> resultList = new ArrayList<MIDependency>();
/*
* Try to get all files within the library directory.
......@@ -288,7 +288,7 @@ public final class FileManager {
* The dependency to be removed.
* @return true iff the dependency exists and the removal was succesful.
*/
public boolean deleteDependency(final MIDependency dependency) {
public synchronized boolean deleteDependency(final MIDependency dependency) {
final File file = new File(dependency.getFilePath());
if (file.isFile()) {
return file.delete();
......
......@@ -77,6 +77,7 @@ public final class PluginFinder {
* If it is a class and has the annotation - put it into our
* list.
*/
// TODO It seems like the classloader knows two annotations with the same name...
if (c.isAnnotationPresent(Plugin.class)) {
result.add(c);
}
......@@ -85,6 +86,7 @@ public final class PluginFinder {
}
return result;
} catch (final IOException ex) {
ex.printStackTrace();
return null;
}
}
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package kieker.webgui.converter;
import java.io.File;
import java.net.MalformedURLException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.webgui.common.PluginFinder;
/**
* This converter can be used to convert an instance of <i>MIDependency</i> to
* the size (in MiBByte) of the dependency, but of course <b>not</b> vice versa.
*
* @author Nils Christian Ehmke
*/
@FacesConverter(value = MIDependencyToCountPluginsConverter.NAME)
public class MIDependencyToCountPluginsConverter implements Converter {
public static final String NAME = "kieker.webgui.converter.MIDependencyToCountPluginsConverter";
/**
* Creates a new instance of this class.
*/
public MIDependencyToCountPluginsConverter() {}
/**
* Delivers always null
*/
@Override
public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) {
return null;
}
@Override
public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) {
if (o == null || !(o instanceof MIDependency)) {
return "";
} else {
try {
// TODO check why toURI().toURL() does not work instead of toURL()
return Integer.toString(PluginFinder.getAllPluginsWithinJar(new File(((MIDependency) o).getFilePath()).toURL()).size());
} catch (final MalformedURLException ex) {
return "";
} catch (final NullPointerException ex) {
return "";
}
}
}
}
......@@ -35,16 +35,16 @@ import kieker.analysis.model.analysisMetaModel.MIDependency;
*
* @author Nils Christian Ehmke
*/
@FacesConverter(value = MIDependencyToIntConverter.NAME)
public class MIDependencyToIntConverter implements Converter {
@FacesConverter(value = MIDependencyToSizeConverter.NAME)
public class MIDependencyToSizeConverter implements Converter {
public static final String NAME = "kieker.webgui.converter.MIDependencyToIntConverter";
public static final String NAME = "kieker.webgui.converter.MIDependencyToSizeConverter";
private static final double FACTOR = 1.0 / 1024 / 1024;
/**
* Creates a new instance of this class.
*/
public MIDependencyToIntConverter() {}
public MIDependencyToSizeConverter() {}
/**
* Delivers always null
......@@ -57,10 +57,10 @@ public class MIDependencyToIntConverter implements Converter {
@Override
public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) {
if (o == null || !(o instanceof MIDependency)) {
return null;
return "";
} else {
final long size = new File(((MIDependency) o).getFilePath()).length();
return new DecimalFormat("#.##").format(size * MIDependencyToIntConverter.FACTOR).concat(" [MiByte]");
return new DecimalFormat("#.##").format(size * MIDependencyToSizeConverter.FACTOR).concat(" [MiByte]");
}
}
}
......@@ -84,7 +84,7 @@ public class MIDependencyToStringConverter implements Converter {
* Make sure that the given object is well-defined.
*/
if (o == null || !(o instanceof MIDependency)) {
return null;
return "";
} else {
return new File(((MIDependency) o).getFilePath()).getName();
}
......
......@@ -82,7 +82,7 @@ public class MIProjectToStringConverter implements Converter {
* Make sure that the given object is well-defined.
*/
if (o == null || !(o instanceof MIProject)) {
return null;
return "";
} else {
return ((MIProject) o).getName();
}
......
......@@ -72,14 +72,17 @@
<h:outputText value="#{node}" />
</p:treeNode>
<p:treeNode type="usedPlugin">
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
<p:contextMenu for="projectsTree" nodeType="project">
<p:menuitem value="Save Project" ajax="true" action="#{availableProjectsBean.saveProject(selectedProjectBean.getSelectedProject)}" update=":projectsForm" />
<p:menuitem value="Save Project" ajax="true" action="#{availableProjectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:separator />
<p:menuitem value="Delete Project" ajax="true" action="#{availableProjectsBean.deleteProject(selectedProjectBean.getSelectedProject)}" update=":projectsForm" />
<p:menuitem value="Reset Project" ajax="true" action="#{availableProjectsBean.resetProject(selectedProjectBean.getSelectedProject)}" update=":projectsForm" />
<p:menuitem value="Delete Project" ajax="true" action="#{availableProjectsBean.deleteProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Reset Project" ajax="true" action="#{availableProjectsBean.resetProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:separator />
<p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" />
</p:contextMenu>
......
......@@ -45,17 +45,28 @@
</f:facet>
<div align="center">
<h:outputText value="#{dependency}" >
<f:converter converterId="kieker.webgui.converter.MIDependencyToIntConverter" />
<f:converter converterId="kieker.webgui.converter.MIDependencyToSizeConverter" />
</h:outputText>
</div>
</p:column>
<p:column style="width:40px">
<f:facet name="header">
<p:column>
<f:facet name="header">
# Plugins
</f:facet>
<div align="center">
<h:outputText value="#{dependency}" >
<f:converter converterId="kieker.webgui.converter.MIDependencyToCountPluginsConverter" />
</h:outputText>
</div>
</p:column>
<p:column style="width:40px">
<f:facet name="header">
</f:facet>
<div align="center">
<p:commandButton ajax="true" update="currentDependenciesForm" icon="ui-icon-trash" title="Delete"
action="#{availableDependenciesBean.deleteDependency(dependency)}"/>
action="#{availableDependenciesBean.deleteDependency(dependency)}"/>
</div>
</p:column>
</p:dataTable>
......
......@@ -27,9 +27,10 @@
<p:layoutUnit header="Currently used Dependencies" position="center" >
<div align="center">
<p:pickList id="pickList" value="#{selectedDependenciesBean.dependencies}" var="dependency"
itemLabel="#{dependency}" itemValue="#{dependency}" >
itemLabel="#{dependency.getFilePath()}" itemValue="#{dependency}"
converter="kieker.webgui.converter.MIDependencyToStringConverter" >
<f:facet name="sourceCaption">Available</f:facet>
<f:facet name="targetCaption">Project</f:facet>
<f:facet name="targetCaption">Project</f:facet>
</p:pickList>
</div>
</p:layoutUnit>
......
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