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

Moved some code; Properties can now be manipulated; Added details.

parent f129818e
No related branches found
No related tags found
No related merge requests found
Showing
with 181 additions and 79 deletions
......@@ -36,17 +36,20 @@ import kieker.webgui.common.PluginClassLoader;
import org.primefaces.model.UploadedFile;
/**
* This bean manages all dependencies (libraries) within the application. The bean can be used to add and remove dependencies as well as to get all available
* dependencies. This bean doesn't modify other beans directly.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
@ManagedBean
@ApplicationScoped
public class AvailableDependenciesBean {
public class DependenciesBean {
/**
* The logger within this class.
*/
private static final Log LOG = LogFactory.getLog(AvailableDependenciesBean.class);
private static final Log LOG = LogFactory.getLog(DependenciesBean.class);
/**
* The list containing the depenencies.
*/
......@@ -55,12 +58,12 @@ public class AvailableDependenciesBean {
/**
* Creates a new instance of this class.
*/
public AvailableDependenciesBean() {
public DependenciesBean() {
this.dependencies = FileManager.getInstance().loadAllDependencies();
}
/**
* Delivers the currently available dependencies as a list.
* Delivers the currently available dependencies as a list. The list must <b>not</b> be modified.
*
* @return All available dependencies.
*/
......@@ -69,7 +72,8 @@ public class AvailableDependenciesBean {
}
/**
* Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten.
* Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten. If the dependencies has been uploaded
* sucesfully, the plugin class loader will get the lib as well.
*
* @param file
* The file to be uploaded.
......@@ -91,14 +95,14 @@ public class AvailableDependenciesBean {
PluginClassLoader.getInstance().addURL(new URL("file", "localhost", FileManager.getInstance().getFullPath(dependency)));
this.dependencies.add(dependency);
} catch (final MalformedURLException ex) {
AvailableDependenciesBean.LOG.error("Could not add the dependency to the ClassLoader.", ex);
DependenciesBean.LOG.error("Could not add the dependency to the ClassLoader.", ex);
}
}
}
}
/**
* Tries to delete a given dependency.
* Tries to delete a given dependency. Once this has been done, the class loader cannot use the dependency any longer.
*
* @param dependency
* The dependency to be removed.
......@@ -112,7 +116,7 @@ public class AvailableDependenciesBean {
PluginClassLoader.getInstance().removeURL(new URL("file", "localhost", dependency.getFilePath()));
this.dependencies.remove(dependency);
} catch (final MalformedURLException ex) {
AvailableDependenciesBean.LOG.error("Could not remove the dependency from the ClassLoader.", ex);
DependenciesBean.LOG.error("Could not remove the dependency from the ClassLoader.", ex);
}
}
}
......
......@@ -19,7 +19,6 @@
***************************************************************************/
package kieker.webgui.beans.application;
import java.io.File;
import java.util.List;
import javax.faces.application.FacesMessage;
......@@ -31,9 +30,7 @@ import kieker.analysis.model.analysisMetaModel.MIDependency;
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;
import kieker.webgui.common.FileManager;
import org.primefaces.event.ToggleEvent;
import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;
......@@ -41,14 +38,15 @@ import org.primefaces.model.TreeNode;
/**
* This bean can be used to handle all available projects within the program. It is like a blackboard for all other components when it comes to the actual projects
* <b>stored</b> on the file system. The properties of the projects, like the adding of dependencies the an actual existing project, can be done otherwise, but the
* storage is done via this bean.
* storage is done via this bean. Other beans (like for the currently selected main project) are not modified directly by this bean. If the user removes the main
* project, the bean for the main project has to handle this.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
@ManagedBean
@ApplicationScoped
public class AvailableProjectsBean {
public class ProjectsBean {
/**
* A list containing all available projects.
......@@ -62,7 +60,7 @@ public class AvailableProjectsBean {
/**
* Creates a new instance of this class.
*/
public AvailableProjectsBean() {
public ProjectsBean() {
/* Load all projects from the file system. */
this.projects = FileManager.getInstance().loadAllProjects();
this.factory = new MAnalysisMetaModelFactory();
......@@ -88,16 +86,7 @@ public class AvailableProjectsBean {
* Try to save the project. If this fails, the project exists already.
*/
if (FileManager.getInstance().saveNewProject(project)) {
/*
* Set the new project as the main project, if the current user doesn't have one.
*/
final FacesContext context = FacesContext.getCurrentInstance();
final SelectedProjectBean bean = context.getApplication().evaluateExpressionGet(context, "#{selectedProjectBean}",
SelectedProjectBean.class);
if (bean != null && bean.getMainProject() == null) {
bean.setMainProject(project);
}
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New Project: " + projectName));
this.projects.add(project);
} else {
/* Inform the user about the fail. */
......@@ -120,11 +109,13 @@ public class AvailableProjectsBean {
final TreeNode dependenciesNode = new DefaultTreeNode("dependencies", "Dependencies", projectNode);
final TreeNode usedPluginsNode = new DefaultTreeNode("usedPlugins", "Used Plugins", projectNode);
/* Append the used plugins and dependencies. */
for (final MIPlugin plugin : project.getPlugins()) {
new DefaultTreeNode("usedPlugin", plugin.getClassname(), usedPluginsNode);
new DefaultTreeNode("usedPlugin", plugin.getName(), usedPluginsNode);
}
for (final MIDependency dependency : project.getDependencies()) {
new DefaultTreeNode("dependencies", new File(dependency.getFilePath()).getName(), dependenciesNode);
new DefaultTreeNode("dependencies", dependency.getFilePath(), dependenciesNode);
}
}
......
......@@ -28,9 +28,8 @@ import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
/**
* This bean is an application-wide bean, responsible for storing the possible
* themes (look and feels) available within the program. It is not possible to
* import new themes during runtime.
* This bean is an application-wide bean, responsible for storing the possible themes (look and feels) available within the program. It is not possible to import new
* themes during runtime.
*
* @author Nils Christian Ehmke
* @version 1.0
......@@ -54,16 +53,14 @@ public class ThemeSwitcherBean {
/**
* Returns the available themes.
*
* @return A map containing the user readable names of the themes as a key
* and the actual theme-names as the corresponding value.
* @return A map containing the user readable names of the themes as a key and the actual theme-names as the corresponding value.
*/
public final Map<String, String> getThemes() {
return this.themes;
}
/**
* Initializes the bean. If one wants to add new themes to the program,
* this is the right place.
* Initializes the bean. If one wants to add new themes to the program, this is the right place.
*/
@PostConstruct
public final void init() {
......
......@@ -24,7 +24,7 @@ import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.webgui.beans.application.AvailableDependenciesBean;
import kieker.webgui.beans.application.DependenciesBean;
import org.primefaces.model.UploadedFile;
......@@ -35,7 +35,7 @@ import org.primefaces.model.UploadedFile;
*/
@ManagedBean
@SessionScoped
public class DependencyUploadController {
public class DependencyUploadBean {
/**
* The file stored within this bean.
......@@ -45,7 +45,7 @@ public class DependencyUploadController {
/**
* Creates a new instance of this class.
*/
public DependencyUploadController() {
public DependencyUploadBean() {
/* No code necessary. */
}
......@@ -74,8 +74,8 @@ public class DependencyUploadController {
public void upload() {
if (this.file != null) {
final FacesContext context = FacesContext.getCurrentInstance();
final AvailableDependenciesBean bean = context.getApplication().evaluateExpressionGet(context, "#{availableDependenciesBean}",
AvailableDependenciesBean.class);
final DependenciesBean bean = context.getApplication().evaluateExpressionGet(context, "#{availableDependenciesBean}",
DependenciesBean.class);
if (bean != null) {
bean.uploadDependency(this.file);
}
......
/***************************************************************************
* 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.beans.session;
/**
*
* @author Nils Christian Ehmke
*/
public class SelectedMainProjectBean {
}
......@@ -20,31 +20,47 @@
package kieker.webgui.beans.session;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIPlugin;
import kieker.analysis.model.analysisMetaModel.MIProperty;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
/**
* This bean can be used to save the currently selected plugin of the user.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
@ManagedBean
@SessionScoped
public class CurrentPlugin {
public final class SelectedPluginBean {
/**
* The plugin which is stored by this container.
*/
private MIPlugin plugin;
public CurrentPlugin() {}
/**
* Creates a new instance of this class.
*/
public SelectedPluginBean() {}
/**
* Delivers the stored plugin.
*
* @return The plugin within this container.
*/
public MIPlugin getPlugin() {
return plugin;
return this.plugin;
}
public void setPlugin(MIPlugin plugin) {
/**
* Sets the plugin stored by this bean.
*
* @param plugin
* The new bean to be stored within this bean.
*/
public void setPlugin(final MIPlugin plugin) {
this.plugin = plugin;
}
}
......@@ -23,21 +23,20 @@ import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin;
import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.MIReader;
import kieker.analysis.model.analysisMetaModel.*;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.analysis.plugin.AbstractAnalysisPlugin;
import kieker.analysis.plugin.AbstractPlugin;
import kieker.analysis.plugin.AbstractReaderPlugin;
import kieker.common.configuration.Configuration;
import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginClassLoader;
import kieker.webgui.common.PluginFinder;
......@@ -285,22 +284,51 @@ public class SelectedProjectBean {
return root;
}
private static void addConfiguration(final AbstractPlugin plugin, final MIPlugin mPlugin) {
/* Get the current configuration and use it to initialize the model plugin. */
final Configuration configuration = plugin.getCurrentConfiguration();
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
/* Run through all entries. */
Iterator<Map.Entry<Object, Object>> iterator = configuration.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<Object, Object> entry = iterator.next();
/* Create a property object for the current entry. */
MIProperty property = factory.createProperty();
property.setName(entry.getKey().toString());
property.setValue(entry.getValue().toString());
mPlugin.getProperties().add(property);
}
}
public final void addPlugin(final Class<AbstractPlugin> pluginClass) {
// TODO It seems like it is necessary to completly load all properties, including the available ports in order to work
// TODO It seems like it is necessary to completly load all properties, including the available ports in order to work
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
try {
AbstractPlugin plugin = pluginClass.getConstructor(Configuration.class).newInstance(new Configuration());
if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) {
final MIReader reader = factory.createReader();
reader.setClassname(pluginClass.getCanonicalName());
reader.setName(pluginClass.getSimpleName());
if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) {
final MIReader reader = factory.createReader();
reader.setClassname(pluginClass.getCanonicalName());
reader.setName(pluginClass.getSimpleName());
addConfiguration(plugin, reader);
this.mainProject.getPlugins().add(reader);
} else {
final MIAnalysisPlugin filter = factory.createAnalysisPlugin();
filter.setClassname(pluginClass.getCanonicalName());
filter.setName(pluginClass.getSimpleName());
this.mainProject.getPlugins().add(reader);
} else {
final MIAnalysisPlugin filter = factory.createAnalysisPlugin();
filter.setClassname(pluginClass.getCanonicalName());
filter.setName(pluginClass.getSimpleName());
addConfiguration(plugin, filter);
this.mainProject.getPlugins().add(filter);
this.mainProject.getPlugins().add(filter);
}
} catch (Exception ex) {
// TODO Log exception
}
}
public final void removePlugin(final MIPlugin plugin) {
this.mainProject.getPlugins().remove(plugin);
}
}
......@@ -31,11 +31,11 @@
<!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. -->
<p:submenu label="Current Project">
<p:menuitem value="Save Project" ajax="true" action="#{availableProjectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Save Project" ajax="true" action="#{projectsBean.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" onclick="deleteProjectDialog.show()" />
<p:menuitem value="Reset Project" ajax="true" action="#{availableProjectsBean.resetProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" />
<p:separator />
<p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" />
</p:submenu>
......@@ -44,6 +44,7 @@
<p:menuitem value="About..." ajax="true" onclick="aboutDialog.show()" />
</p:submenu>
<p:menuitem value="Start/Stop Analysis"></p:menuitem>
</p:menubar>
</h:form>
......@@ -55,7 +56,7 @@
<p:layoutUnit header="Projects" collapsible="true" position="west"
size="200" resizable="true" minSize="100">
<h:form id="projectsForm">
<p:tree selection="#{selectedProjectBean.selectedNode}" id="projectsTree" selectionMode="single" value="#{availableProjectsBean.projectsRoot}" var="node">
<p:tree selection="#{selectedProjectBean.selectedNode}" id="projectsTree" selectionMode="single" value="#{projectsBean.projectsRoot}" var="node">
<p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/>
<p:treeNode type="project">
......@@ -79,12 +80,12 @@
</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="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette :centerForm" />
<p:separator />
<p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" />
<p:menuitem value="Reset Project" ajax="true" action="#{availableProjectsBean.resetProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" />
<p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" />
<p:separator />
<p:menuitem value="Configure Dependencies" ajax="false" url="/Kieker.WebGUI/projectDependencies" />
</p:contextMenu>
......@@ -105,7 +106,8 @@
<h:form id="centerForm">
<ui:repeat id="centerRepeat" value="#{selectedProjectBean.mainProject.plugins}" var="plugin">
<p:panel header="#{plugin.name}" closable="true" closeSpeed="200" toggleSpeed="200" toggleable="true" id="plugin" style="width: 30%">
<p:commandLink ajax="true" value="Configure" action="#{currentPlugin.setPlugin(plugin)}" update=":propertiesForm"/>
<p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/>
<p:ajax event="close" listener="#{selectedProjectBean.removePlugin(plugin)}" update=":centerForm"/>
</p:panel>
<p:draggable for="plugin">
</p:draggable>
......@@ -118,16 +120,27 @@
<!-- The following layout unit is located at the bottom and will be used for properties. -->
<p:layoutUnit position="south" size="150" header="Properties" resizable="true" collapsible="true">
<h:form id="propertiesForm">
<c:if test="#{not empty currentPlugin.plugin}">
<p:dataTable value="#{currentPlugin.plugin.properties}" var="property" id="propertiesList">
<c:if test="#{not empty selectedPluginBean.plugin}">
<p:dataTable value="#{selectedPluginBean.plugin.properties}" var="property" id="propertiesList">
<p:column headerText="Key" style="width:125px">
<h:outputText value="#{property.name}"/>
</p:column>
<p:column headerText="Value" style="width:125px">
<h:outputText value="#{property.value}"/>
<p:cellEditor >
<f:facet name="output">
<h:outputText value="#{property.value}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{property.value}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options" style="width:50px">
<p:rowEditor />
</p:column>
</p:dataTable>
</c:if>
</h:form>
......@@ -150,6 +163,9 @@
<p:commandLink value="#{filter.simpleName}" action="#{selectedProjectBean.addPlugin(filter)}" update=":projectsForm :centerForm"/><br/>
</ui:repeat>
</p:tab>
<p:tab title="Repositories">
</p:tab>
</p:accordionPanel>
</h:form>
</p:layoutUnit>
......
......@@ -3,7 +3,8 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<!-- ******************************************************************************** -->
<!-- This is the dialog to create a new project. -->
......@@ -21,7 +22,7 @@
value="#{stringBean.string}" />
<br /> <br />
<p:commandButton value="Ok"
action="#{availableProjectsBean.addProject(stringBean.string)}"
action="#{projectsBean.addProject(stringBean.string)}"
update=":projectsForm"
oncomplete="newProjectDialog.hide()" />
<p:spacer width="100" height="10" />
......@@ -41,7 +42,7 @@
<br />
<center>
<p:commandButton value="Yes"
action="#{availableProjectsBean.deleteProject(selectedProjectBean.getSelectedProject())}"
action="#{projectsBean.deleteProject(selectedProjectBean.getSelectedProject())}"
update=":projectsForm"
oncomplete="deleteProjectDialog.hide()" />
<p:spacer width="100" height="10" />
......@@ -50,4 +51,24 @@
</h:form>
</p:dialog>
<!-- ******************************************************************************** -->
<!-- ******************************************************************************** -->
<!-- This is the dialog to reset the selected project. -->
<p:dialog id="resetProjectDialog" header="Reset Project" resizable="false"
modal="true" widgetVar="resetProjectDialog">
<h:form>
<h:outputText value="Do you really want to reset the selected project?" />
<br />
<br />
<center>
<p:commandButton value="Yes"
action="#{projectsBean.resetProject(selectedProjectBean.getSelectedProject())}"
update=":projectsForm"
oncomplete="resetProjectDialog.hide()" />
<p:spacer width="100" height="10" />
<p:commandButton value="Cancel" onclick="resetProjectDialog.hide()" />
</center>
</h:form>
</p:dialog>
<!-- ******************************************************************************** -->
</ui:composition>
\ No newline at end of file
......@@ -26,7 +26,7 @@
<p:layoutUnit header="Currently available Dependencies" position="center" >
<!-- This form shows the currently available dependencies. -->
<h:form id="currentDependenciesForm">
<p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
<p:dataTable id="currentDependencies" value="#{dependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
<p:column>
<f:facet name="header">
......@@ -64,7 +64,7 @@
</f:facet>
<div align="center">
<p:commandButton ajax="true" update=":currentDependenciesForm" icon="ui-icon-trash" title="Delete"
action="#{availableDependenciesBean.deleteDependency(dependency)}"/>
action="#{dependenciesBean.deleteDependency(dependency)}"/>
</div>
</p:column>
</p:dataTable>
......@@ -77,13 +77,13 @@
<br />
<br />
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{dependencyUploadController.file}"
<p:fileUpload value="#{dependencyUploadBean.file}"
allowTypes="/(\.|\/)(jar)$/"
sizeLimit="104857600"
mode="simple" />
<p:spacer width ="50px" height="0px"/>
<p:commandLink ajax="false" actionListener="#{dependencyUploadController.upload}">
<p:commandLink ajax="false" actionListener="#{dependencyUploadBean.upload}">
<h:outputText value="Upload File" />
</p:commandLink>
</h:form>
......
......@@ -30,7 +30,7 @@
<p:selectManyMenu value="#{selectedDependenciesBean.dependencies}" style="width: 100%"
converter="kieker.webgui.converter.MIDependencyToStringConverter">
<f:selectItems value="#{availableDependenciesBean.dependencies}"
<f:selectItems value="#{dependenciesBean.dependencies}"
var="dependency" itemLabel="#{dependency.filePath}"
itemValue="#{player}" />
</p:selectManyMenu>
......
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