From 1a262727694ea4a8fb0a4f693f6e99bc91d90ad3 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Sun, 29 Jan 2012 17:01:14 +0100 Subject: [PATCH] Continued with the uploading-functionality. --- .../AvailableDependenciesBean.java | 20 +- .../kieker/webgui/common/FileManager.java | 398 ++++++++------ .../converter/MIDependencyToIntConverter.java | 39 ++ .../MIDependencyToStringConverter.java | 33 ++ Kieker.WebGUI/src/main/webapp/main.css | 2 +- Kieker.WebGUI/src/main/webapp/main.xhtml | 496 +++++++++--------- .../src/main/webapp/manageDependencies.css | 14 +- .../src/main/webapp/manageDependencies.xhtml | 104 ++-- 8 files changed, 643 insertions(+), 463 deletions(-) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java index 474d638e..9dc7602e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableDependenciesBean.java @@ -7,20 +7,22 @@ import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; import kieker.analysis.model.analysisMetaModel.MIDependency; +import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; +import kieker.webgui.common.FileManager; @ManagedBean @ApplicationScoped public class AvailableDependenciesBean { - - private final List<MIDependency> dependencies; - public AvailableDependenciesBean() { - this.dependencies = new ArrayList<MIDependency>(); + private final List<MIDependency> dependencies; + private final MAnalysisMetaModelFactory factory; - } - - public List<MIDependency> getDependencies() { - return dependencies; - } + public AvailableDependenciesBean() { + this.dependencies = FileManager.getInstance().loadAllDependencies(); + factory = new MAnalysisMetaModelFactory(); + } + public List<MIDependency> getDependencies() { + return dependencies; + } } 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 4176a282..7d1d7194 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java @@ -11,186 +11,238 @@ import java.util.List; import org.primefaces.model.UploadedFile; import kieker.analysis.AnalysisController; +import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; +import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; /** - * This is a singleton class for the access to the file system. It makes sure that the necessary directories for the execution of the application exist. <b>Do - * not</b> remove directories created from this manager during runtime! Directories are created during first access to the class.<br> - * Currently nearly all methods are synchronized. A fine grained synchronization should be implemented in the future. - * + * This is a singleton class for the access to the file system. It makes sure + * that the necessary directories for the execution of the application exist. + * <b>Do not</b> remove directories created from this manager during runtime! + * Directories are created during first access to the class.<br> Currently + * nearly all methods are synchronized. A fine grained synchronization should be + * implemented in the future. + * * @author Nils Christian Ehmke */ public final class FileManager { - private static final Log LOG = LogFactory.getLog(FileManager.class); - - private static final String ROOT_DIR = "data"; - private static final String PROJECT_DIR = ROOT_DIR + File.separator + "projects"; - private static final String LIB_DIR = ROOT_DIR + File.separator + "libraries"; - private static final String EXTENSION = ".xml"; - private static final int BUF_SIZE = 1024; - private static final FileManager instance = new FileManager(); - - private FileManager() { - checkAndCreateDirectories(); - } - - private synchronized void checkAndCreateDirectories() { - /* - * Make sure that the directories exist and create them if necessary. - */ - final File dirProj = new File(PROJECT_DIR); - final File dirLib = new File(LIB_DIR); - boolean couldCreated = true; - - if (!dirProj.exists()) { - couldCreated &= dirProj.mkdirs(); - } - if (!dirLib.exists()) { - couldCreated &= dirLib.mkdirs(); - } - - if (!couldCreated) { - FileManager.LOG.error("Could not create the necessary directories for the application"); - } - } - - /** - * This method saves a given project using the name of the project as the project-directory. The project-directory must already exist. - * - * @param project - * The project to be stored. - * @return true iff the project-directory does already exist and the storage was successful. - */ - public synchronized boolean saveProject(final MIProject project) { - final String projectName = project.getName(); - - final File dirProject = new File(PROJECT_DIR + File.separator + projectName); - - /* Make sure that the directory for the project exists. */ - if (!dirProject.exists()) { - return false; - } else { - /* Try to save the project. */ - final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); - try { - final AnalysisController controller = new AnalysisController(project); - return controller.saveToFile(fileProject, projectName); - } catch (final Exception ex) { - FileManager.LOG.error("Could not save project '" + projectName + "'."); - return false; - } - } - } - - /** - * This method saves a given project using the name of the project as the project-directory. THe project-directory must not already exist. - * - * @param project - * The project to be stored. - * @return true iff the project-directory does not already exist and the storage was successful. - */ - public synchronized boolean saveNewProject(final MIProject project) { - final String projectName = project.getName(); - - final File dirProject = new File(PROJECT_DIR + File.separator + projectName); - - /* Make sure that the project does not already exist and create the project directory. */ - if (dirProject.exists() || !dirProject.mkdir()) { - return false; - } else { - /* The directory should exist now. Store the project. */ - return saveProject(project); - } - } - - /** - * This method can be used to load all currently saved projects. - * - * @return A list containing the loaded projects. If something went wrong, an empty list will be returned, never null. - */ - public synchronized List<MIProject> loadAllProjects() { - List<MIProject> resultList = new ArrayList<MIProject>(); - - /* Try to get all directories within the project directory. */ - final File directories[] = new File(PROJECT_DIR).listFiles(); - if (directories != null) { - for (File directory : directories) { - if (directory.isDirectory()) { - /* If there is a project file within the directory, we know the name of it. */ - final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION); - if (projectFile.exists()) { - try { - /* Try to load the project. */ - MIProject project = AnalysisController.loadFromFile(projectFile); - if (project != null) { - resultList.add(project); - } - } catch (Exception ex) { - FileManager.LOG.error("Could not load project '" + directory.getName() + "'."); - } - } - } - } - } - - return resultList; - } - - /** - * This method uploads a given file as a new dependency. The file is stored within the lib-directory of this application. If a file with the same name does - * already exist, it will be replaces. - * - * @param file - * The file to be uploaded. - * @return true iff the file has been uploaded successfully. - */ - public boolean uploadDependency(final UploadedFile file) { - System.out.println(file); - final File depFile = new File(LIB_DIR, file.getFileName()); - - InputStream in = null; - OutputStream out = null; - try { - /* Get the streams. */ - in = file.getInputstream(); - out = new FileOutputStream(depFile); - final byte buf[] = new byte[BUF_SIZE]; - int count; - - /* Transfer the file. */ - while ((count = in.read(buf)) != -1) { - out.write(buf, 0, count); - } - - } catch (final IOException ex) { - FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'"); - return false; - } finally { - /* Try to make sure that the streams will be closed. */ - try { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } catch (IOException ex) { - // Ignore - } - } - - return true; - } - - /** - * Delivers the only instance of this class. - * - * @return The singleton instance of this class. - */ - public static FileManager getInstance() { - return instance; - } + private static final Log LOG = LogFactory.getLog(FileManager.class); + private static final String ROOT_DIR = "data"; + private static final String PROJECT_DIR = ROOT_DIR + File.separator + "projects"; + private static final String LIB_DIR = ROOT_DIR + File.separator + "libraries"; + private static final String EXTENSION = ".kax"; + private static final String JAR_EXTENSION = ".jar"; + private static final int BUF_SIZE = 1024; + private static final FileManager instance = new FileManager(); + + private FileManager() { + checkAndCreateDirectories(); + } + + private synchronized void checkAndCreateDirectories() { + /* + * Make sure that the directories exist and create them if necessary. + */ + final File dirProj = new File(PROJECT_DIR); + final File dirLib = new File(LIB_DIR); + boolean couldCreated = true; + + if (!dirProj.exists()) { + couldCreated &= dirProj.mkdirs(); + } + if (!dirLib.exists()) { + couldCreated &= dirLib.mkdirs(); + } + + if (!couldCreated) { + FileManager.LOG.error("Could not create the necessary directories for the application"); + } + } + + /** + * This method saves a given project using the name of the project as the + * project-directory. The project-directory must already exist. + * + * @param project The project to be stored. + * @return true iff the project-directory does already exist and the storage + * was successful. + */ + public synchronized boolean saveProject(final MIProject project) { + final String projectName = project.getName(); + + final File dirProject = new File(PROJECT_DIR + File.separator + projectName); + + /* + * Make sure that the directory for the project exists. + */ + if (!dirProject.exists()) { + return false; + } else { + /* + * Try to save the project. + */ + final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); + try { + final AnalysisController controller = new AnalysisController(project); + return controller.saveToFile(fileProject, projectName); + } catch (final Exception ex) { + FileManager.LOG.error("Could not save project '" + projectName + "'."); + return false; + } + } + } + + /** + * This method saves a given project using the name of the project as the + * project-directory. THe project-directory must not already exist. + * + * @param project The project to be stored. + * @return true iff the project-directory does not already exist and the + * storage was successful. + */ + public synchronized boolean saveNewProject(final MIProject project) { + final String projectName = project.getName(); + + final File dirProject = new File(PROJECT_DIR + File.separator + projectName); + + /* + * Make sure that the project does not already exist and create the + * project directory. + */ + if (dirProject.exists() || !dirProject.mkdir()) { + return false; + } else { + /* + * The directory should exist now. Store the project. + */ + return saveProject(project); + } + } + + /** + * This method can be used to load all currently saved projects. + * + * @return A list containing the loaded projects. If something went wrong, + * an empty list will be returned, never null. + */ + public synchronized List<MIProject> loadAllProjects() { + List<MIProject> resultList = new ArrayList<MIProject>(); + + /* + * Try to get all directories within the project directory. + */ + final File directories[] = new File(PROJECT_DIR).listFiles(); + if (directories != null) { + for (File directory : directories) { + if (directory.isDirectory()) { + /* + * If there is a project file within the directory, we know + * the name of it. + */ + final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION); + if (projectFile.exists()) { + try { + /* + * Try to load the project. + */ + MIProject project = AnalysisController.loadFromFile(projectFile); + if (project != null) { + resultList.add(project); + } + } catch (Exception ex) { + FileManager.LOG.error("Could not load project '" + directory.getName() + "'."); + } + } + } + } + } + + return resultList; + } + + /** + * This method uploads a given file as a new dependency. The file is stored + * within the lib-directory of this application. If a file with the same + * name does already exist, it will be replaces. + * + * @param file The file to be uploaded. + * @return true iff the file has been uploaded successfully. + */ + public boolean uploadDependency(final UploadedFile file) { + System.out.println(file); + final File depFile = new File(LIB_DIR, file.getFileName()); + + InputStream in = null; + OutputStream out = null; + try { + /* + * Get the streams. + */ + in = file.getInputstream(); + out = new FileOutputStream(depFile); + final byte buf[] = new byte[BUF_SIZE]; + int count; + + /* + * Transfer the file. + */ + while ((count = in.read(buf)) != -1) { + out.write(buf, 0, count); + } + + } catch (final IOException ex) { + FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'"); + return false; + } finally { + /* + * Try to make sure that the streams will be closed. + */ + try { + if (in != null) { + in.close(); + } + if (out != null) { + out.close(); + } + } catch (IOException ex) { + // Ignore + } + } + + return true; + } + + /** + * Delivers the only instance of this class. + * + * @return The singleton instance of this class. + */ + public static FileManager getInstance() { + return instance; + } + + public List<MIDependency> loadAllDependencies() { + final List<MIDependency> resultList = new ArrayList<MIDependency>(); + final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); + /* + * Try to get all files within the library directory. + */ + final File files[] = new File(LIB_DIR).listFiles(); + if (files != null) { + for (File file : files) { + if (file.isFile()) { + if (file.getName().endsWith(JAR_EXTENSION)) { + MIDependency dependency = factory.createDependency(); + dependency.setFilePath(file.getAbsolutePath()); + resultList.add(dependency); + } + } + } + } + + return resultList; + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java new file mode 100644 index 00000000..c4b3d1f0 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToIntConverter.java @@ -0,0 +1,39 @@ +package kieker.webgui.converter; + +import java.io.File; +import java.text.DecimalFormat; +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; + +/** + * 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 = MIDependencyToIntConverter.NAME) +public class MIDependencyToIntConverter implements Converter { + + public static final String NAME = "kieker.webgui.converter.MIDependencyToIntConverter"; + + /** + * Delivers always null + */ + @Override + public Object getAsObject(FacesContext fc, UIComponent uic, String string) { + return null; + } + + @Override + public String getAsString(FacesContext fc, UIComponent uic, Object o) { + if (o == null || !(o instanceof MIDependency)) { + return null; + } else { + long size = new File(((MIDependency) o).getFilePath()).length(); + return new DecimalFormat("#.##").format(size / 1024f / 1024).concat(" [MiByte]"); + } + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java new file mode 100644 index 00000000..f84d6af5 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToStringConverter.java @@ -0,0 +1,33 @@ +package kieker.webgui.converter; + +import java.io.File; +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; + +/** + * This converter can be used to convert an instance of <i>MIDependency</i> to a + * human readable string, but <b>not</b> vice versa. + * + * @author Nils Christian Ehmke + */ +@FacesConverter(value = MIDependencyToStringConverter.NAME) +public class MIDependencyToStringConverter implements Converter { + + public static final String NAME = "kieker.webgui.converter.MIDependencyToStringConverter"; + + /** + * Delivers always null + */ + @Override + public Object getAsObject(FacesContext fc, UIComponent uic, String string) { + return null; + } + + @Override + public String getAsString(FacesContext fc, UIComponent uic, Object o) { + return (o == null || !(o instanceof MIDependency)) ? null : (new File(((MIDependency) o).getFilePath()).getName()); + } +} diff --git a/Kieker.WebGUI/src/main/webapp/main.css b/Kieker.WebGUI/src/main/webapp/main.css index 35e24a8d..208b019b 100644 --- a/Kieker.WebGUI/src/main/webapp/main.css +++ b/Kieker.WebGUI/src/main/webapp/main.css @@ -7,7 +7,7 @@ z-index: 20 !important; overflow: visible !important;; } - + .ui-layout-north .ui-layout-unit-content { overflow: visible !important; } diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 54cde655..fab1ec87 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -1,254 +1,252 @@ <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui"> - -<f:view contentType="text/html"> - <h:head> - <title>Kieker.WebGUI</title> - <link rel="stylesheet" title="Standard-Stylesheet" type="text/css" - href="main.css" /> - </h:head> - - <h:body> - - <!-- This is the layout for the whole page. --> - <p:layout fullPage="true"> - - <!-- ******************************************************************************** --> - <!-- This is the top unit within the layout and is used for the menu bar. --> - <p:layoutUnit position="north" size="60" collapsible="false"> - <h:form> - <p:menubar> - <p:submenu label="File"> - <p:menuitem value="New Project" onclick="newProjectDialog.show()" - ajax="true" /> - <p:menuitem value="Manage Dependencies" ajax="false" - url="/Kieker.WebGUI/manageDependencies" /> - <p:separator /> - - <p:menuitem value="Settings" onclick="settingsDialog.show()" - ajax="true" /> - </p:submenu> - - <!-- 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" /> - <p:menuitem value="Set as Main Project" ajax="true" /> - <p:separator /> - - <p:menuitem value="Delete Project" ajax="true" /> - <p:menuitem value="Reset Project" ajax="true" /> - <p:separator /> - - <p:menuitem value="Configure Dependencies" ajax="false" - url="/Kieker.WebGUI/projectDependencies" /> - </p:submenu> - - <p:submenu label="Help"> - <p:menuitem value="About..." onclick="AboutDialog.show();" /> - </p:submenu> - - </p:menubar> - - </h:form> - </p:layoutUnit> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- The following layout is at the left side of the page and shows the available projects. --> - <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" style="width: auto" - value="#{availableProjectsBean.projectsRoot}" var="node"> - <p:treeNode type="project"> - <h:outputText - style="font-weight: #{selectedProjectBean.getFontWeight(node)}" - value="#{node}"> - <f:converter - converterId="kieker.webgui.converter.MIProjectToStringConverter" /> - </h:outputText> - </p:treeNode> - <p:treeNode type="dependencies"> - <h:outputText value="#{node}" /> - </p:treeNode> - <p:treeNode type="usedPlugins"> - <h:outputText value="#{node}" /> - </p:treeNode> - </p:tree> - - <p:contextMenu for="projectsTree" nodeType="project"> - <p:menuitem value="Save Project" ajax="true" /> - <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" /> - <p:menuitem value="Reset Project" ajax="true" /> - <p:separator /> - <p:menuitem value="Configure Dependencies" ajax="true" /> - </p:contextMenu> - <p:contextMenu for="projectsTree" nodeType="dependencies"> - </p:contextMenu> - <p:contextMenu for="projectsTree" nodeType="usedPlugins"> - </p:contextMenu> - </h:form> - - </p:layoutUnit> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- The following layout unit is within the center and used for the graph. --> - <p:layoutUnit position="center"> - </p:layoutUnit> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- 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> - <p:dataTable id="carList"> - - - <p:column headerText="Key" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText value="" /> - </f:facet> - <f:facet name="input"> - <p:inputText value="" style="width:100%" /> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column headerText="Value" style="width:125px"> - <p:cellEditor> - <f:facet name="output"> - <h:outputText value="" /> - </f:facet> - <f:facet name="input"> - <p:inputText value="" style="width:100%" label="Year" /> - </f:facet> - </p:cellEditor> - </p:column> - - <p:column headerText="Options" style="width:50px"> - <p:rowEditor /> - </p:column> - - </p:dataTable> - </h:form> - </p:layoutUnit> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- The following layout unit is located at the right side of the page and is used as a tool palette. It shows the available plugins etc. --> - <p:layoutUnit position="east" size="200" header="Tool Palette" - resizable="true" collapsible="true"> - <h:form> - <p:tree style="width: auto" - value="#{availablePluginsBean.availablePluginsRoot}" var="node"> - <p:treeNode> - <h:outputText value="#{node}" /> - </p:treeNode> - </p:tree> - </h:form> - </p:layoutUnit> - <!-- ******************************************************************************** --> - </p:layout> - - - <!-- ******************************************************************************** --> - <!-- This is the about-dialog. --> - <p:dialog header="About..." resizable="false" modal="true" - widgetVar="AboutDialog"> - <h:form> - <h:outputText value="Kieker.WebGUI" /> - <br /> - <br /> - <h:outputText value="Version: 1.0-SNAPSHOT" /> - <br /> - <h:outputText value="Copyright (c) 2012 Kieker Project" /> - <br /> - <br /> - <a href="http://www.kieker-monitoring.net/">http://www.kieker-monitoring.net/</a> - </h:form> - </p:dialog> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- This is the dialog to create a new project. --> - <p:dialog id="newProjectDialog" header="New Project" resizable="false" - modal="true" widgetVar="newProjectDialog"> - <!-- Make sure that closing of the dialog also clears the input field. --> - <p:ajax event="close" update="newProjectDialog" - listener="#{stringBean.clear()}" /> - - <h:form> - <h:outputText value="Please enter the name of the new project: " /> - <br /> - <br /> - <center> - <p:inputText id="NewProjectInput" style="width: 90%" - value="#{stringBean.string}" /> - <br /> <br /> - <p:commandButton value="Ok" - action="#{availableProjectsBean.addProject(stringBean.string)}" - oncomplete="newProjectDialog.hide()" /> - <p:spacer width="100" height="10" /> - <p:commandButton value="Cancel" onclick="newProjectDialog.hide()" /> - </center> - </h:form> - </p:dialog> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- This is the dialog for settings and properties. --> - <p:dialog id="settingsDialog" header="Settings" resizable="false" - modal="true" widgetVar="settingsDialog"> - <h:form> - <h:panelGrid columns="2" cellpadding="10"> - <h:outputText value="Look and Feel:" /> - <p:themeSwitcher value="#{currentThemeBean.theme}" - style="width:150px" effect="fade"> - <f:selectItem itemLabel="Choose Theme" itemValue="" /> - <f:selectItems value="#{themeSwitcherBean.themes}" /> - </p:themeSwitcher> - </h:panelGrid> - <center> - <p:commandButton value="Ok" oncomplete="settingsDialog.hide();" /> - </center> - </h:form> - </p:dialog> - <!-- ******************************************************************************** --> - - <!-- ******************************************************************************** --> - <!-- This is the dialog for uploading dependencies. --> - <p:dialog id="dependenciesUploadDialog" header="Add Dependency" - resizable="false" modal="true" widgetVar="dependenciesUploadDialog"> - - <h:form enctype="multipart/form-data"> - - <p:messages showDetail="true" /> - - <p:fileUpload value="#{dependencyUploadController.file}" - mode="simple" /> - - <p:commandButton value="Submit" ajax="false" - actionListener="#{dependencyUploadController.upload}" /> - - </h:form> - - </p:dialog> - <!-- ******************************************************************************** --> - - </h:body> -</f:view> + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:p="http://primefaces.org/ui"> + + <f:view contentType="text/html"> + <h:head> + <title>Kieker.WebGUI</title> + <link rel="stylesheet" type="text/css" href="main.css" /> + </h:head> + + <h:body> + <!-- This is the layout for the whole page. --> + <p:layout fullPage="true"> + + <!-- ******************************************************************************** --> + <!-- This is the top unit within the layout and is used for the menu bar. --> + <p:layoutUnit position="north" size="60" collapsible="false"> + <h:form> + <p:menubar> + <p:submenu label="File"> + <p:menuitem value="New Project" onclick="newProjectDialog.show()" + ajax="true" /> + <p:menuitem value="Manage Dependencies" ajax="false" + url="/Kieker.WebGUI/manageDependencies" /> + <p:separator /> + + <p:menuitem value="Settings" onclick="settingsDialog.show()" + ajax="true" /> + </p:submenu> + + <!-- 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" /> + <p:menuitem value="Set as Main Project" ajax="true" /> + <p:separator /> + + <p:menuitem value="Delete Project" ajax="true" /> + <p:menuitem value="Reset Project" ajax="true" /> + <p:separator /> + + <p:menuitem value="Configure Dependencies" ajax="false" + url="/Kieker.WebGUI/projectDependencies" /> + </p:submenu> + + <p:submenu label="Help"> + <p:menuitem value="About..." onclick="AboutDialog.show();" /> + </p:submenu> + + </p:menubar> + + </h:form> + </p:layoutUnit> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- The following layout is at the left side of the page and shows the available projects. --> + <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" style="width: auto" + value="#{availableProjectsBean.projectsRoot}" var="node"> + <p:treeNode type="project"> + <h:outputText + style="font-weight: #{selectedProjectBean.getFontWeight(node)}" + value="#{node}"> + <f:converter + converterId="kieker.webgui.converter.MIProjectToStringConverter" /> + </h:outputText> + </p:treeNode> + <p:treeNode type="dependencies"> + <h:outputText value="#{node}" /> + </p:treeNode> + <p:treeNode type="usedPlugins"> + <h:outputText value="#{node}" /> + </p:treeNode> + </p:tree> + + <p:contextMenu for="projectsTree" nodeType="project"> + <p:menuitem value="Save Project" ajax="true" /> + <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" /> + <p:menuitem value="Reset Project" ajax="true" /> + <p:separator /> + <p:menuitem value="Configure Dependencies" ajax="true" /> + </p:contextMenu> + <p:contextMenu for="projectsTree" nodeType="dependencies"> + </p:contextMenu> + <p:contextMenu for="projectsTree" nodeType="usedPlugins"> + </p:contextMenu> + </h:form> + + </p:layoutUnit> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- The following layout unit is within the center and used for the graph. --> + <p:layoutUnit position="center"> + </p:layoutUnit> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- 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> + <p:dataTable id="carList"> + + + <p:column headerText="Key" style="width:125px"> + <p:cellEditor> + <f:facet name="output"> + <h:outputText value="" /> + </f:facet> + <f:facet name="input"> + <p:inputText value="" style="width:100%" /> + </f:facet> + </p:cellEditor> + </p:column> + + <p:column headerText="Value" style="width:125px"> + <p:cellEditor> + <f:facet name="output"> + <h:outputText value="" /> + </f:facet> + <f:facet name="input"> + <p:inputText value="" style="width:100%" label="Year" /> + </f:facet> + </p:cellEditor> + </p:column> + + <p:column headerText="Options" style="width:50px"> + <p:rowEditor /> + </p:column> + + </p:dataTable> + </h:form> + </p:layoutUnit> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- The following layout unit is located at the right side of the page and is used as a tool palette. It shows the available plugins etc. --> + <p:layoutUnit position="east" size="200" header="Tool Palette" + resizable="true" collapsible="true"> + <h:form> + <p:tree style="width: auto" + value="#{availablePluginsBean.availablePluginsRoot}" var="node"> + <p:treeNode> + <h:outputText value="#{node}" /> + </p:treeNode> + </p:tree> + </h:form> + </p:layoutUnit> + <!-- ******************************************************************************** --> + </p:layout> + + + <!-- ******************************************************************************** --> + <!-- This is the about-dialog. --> + <p:dialog header="About..." resizable="false" modal="true" + widgetVar="AboutDialog"> + <h:form> + <h:outputText value="Kieker.WebGUI" /> + <br /> + <br /> + <h:outputText value="Version: 1.0-SNAPSHOT" /> + <br /> + <h:outputText value="Copyright (c) 2012 Kieker Project" /> + <br /> + <br /> + <a href="http://www.kieker-monitoring.net/">http://www.kieker-monitoring.net/</a> + </h:form> + </p:dialog> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- This is the dialog to create a new project. --> + <p:dialog id="newProjectDialog" header="New Project" resizable="false" + modal="true" widgetVar="newProjectDialog"> + <!-- Make sure that closing of the dialog also clears the input field. --> + <p:ajax event="close" update="newProjectDialog" + listener="#{stringBean.clear()}" /> + + <h:form> + <h:outputText value="Please enter the name of the new project: " /> + <br /> + <br /> + <center> + <p:inputText id="NewProjectInput" style="width: 90%" + value="#{stringBean.string}" /> + <br /> <br /> + <p:commandButton value="Ok" + action="#{availableProjectsBean.addProject(stringBean.string)}" + oncomplete="newProjectDialog.hide()" /> + <p:spacer width="100" height="10" /> + <p:commandButton value="Cancel" onclick="newProjectDialog.hide()" /> + </center> + </h:form> + </p:dialog> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- This is the dialog for settings and properties. --> + <p:dialog id="settingsDialog" header="Settings" resizable="false" + modal="true" widgetVar="settingsDialog"> + <h:form> + <h:panelGrid columns="2" cellpadding="10"> + <h:outputText value="Look and Feel:" /> + <p:themeSwitcher value="#{currentThemeBean.theme}" + style="width:150px" effect="fade"> + <f:selectItem itemLabel="Choose Theme" itemValue="" /> + <f:selectItems value="#{themeSwitcherBean.themes}" /> + </p:themeSwitcher> + </h:panelGrid> + <center> + <p:commandButton value="Ok" oncomplete="settingsDialog.hide();" /> + </center> + </h:form> + </p:dialog> + <!-- ******************************************************************************** --> + + <!-- ******************************************************************************** --> + <!-- This is the dialog for uploading dependencies. --> + <p:dialog id="dependenciesUploadDialog" header="Add Dependency" + resizable="false" modal="true" widgetVar="dependenciesUploadDialog"> + + <h:form enctype="multipart/form-data"> + + <p:messages showDetail="true" /> + + <p:fileUpload value="#{dependencyUploadController.file}" + mode="simple" /> + + <p:commandButton value="Submit" ajax="false" + actionListener="#{dependencyUploadController.upload}" /> + + </h:form> + + </p:dialog> + <!-- ******************************************************************************** --> + + </h:body> + </f:view> </html> diff --git a/Kieker.WebGUI/src/main/webapp/manageDependencies.css b/Kieker.WebGUI/src/main/webapp/manageDependencies.css index 133b19ab..f6fc4c8a 100644 --- a/Kieker.WebGUI/src/main/webapp/manageDependencies.css +++ b/Kieker.WebGUI/src/main/webapp/manageDependencies.css @@ -1,5 +1,17 @@ @charset "UTF-8"; .ui-button { - font-size: 15px; + font-size: 15px; +} + +.fileinput-button { + font-size: 5px; +} + +.ui-datatable { + font-size: 15px; +} + +.ui-panel { + font-size: 15px; } \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml b/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml index d92351a3..23481b11 100644 --- a/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml +++ b/Kieker.WebGUI/src/main/webapp/manageDependencies.xhtml @@ -1,35 +1,79 @@ <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" - xmlns:h="http://java.sun.com/jsf/html" - xmlns:f="http://java.sun.com/jsf/core" - xmlns:p="http://primefaces.org/ui"> - -<f:view contentType="text/html"> - <h:head> - <title>Kieker.WebGUI - Dependencies</title> - <link rel="stylesheet" title="Standard-Stylesheet" type="text/css" - href="manageDependencies.css" /> - </h:head> - <body> - <h:form> - <h3>Currently Available Dependencies</h3> - <p:dataList id="currentDependencies" - value="#{availableDependenciesBean.dependencies}" var="dependency" - itemType="square"> - #{dependency.getFilePath()} - </p:dataList> - </h:form> - - <h:form enctype="multipart/form-data"> - <p:fileUpload value="#{dependencyUploadController.file}" - mode="simple" /> - <br /> - <p:commandButton value="Upload" ajax="false" - actionListener="#{dependencyUploadController.upload}" /> - - </h:form> - </body> -</f:view> + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:p="http://primefaces.org/ui"> + + <f:view contentType="text/html"> + <h:head> + <title>Kieker.WebGUI - Dependencies</title> + <link rel="stylesheet" type="text/css" href="../manageDependencies.css" /> + </h:head> + <h:body> + <!-- The control panel to get back. --> + <p:panel> + <h:form> + <p:commandButton icon="ui-icon-circle-arrow-w" value="Mainmenu"/> + </h:form> + </p:panel> + + <p:spacer height="20px"/> + + <!-- This is the form for the uploading. --> + <p:panel header="Upload Dependencies"> + <h:outputText value="Currently only *.jar-Dependencies can be uploaded. The maximal file size is limited to 100 [MiByte]." /> + <br /> + <br /> + <h:form enctype="multipart/form-data"> + <p:fileUpload value="#{dependencyUploadController.file}" + allowTypes="/(\.|\/)(jar)$/" + sizeLimit="104857600" + mode="simple" /> + <br /> + <br /> + <p:commandButton value="Upload" ajax="true" + actionListener="#{dependencyUploadController.upload}" /> + + </h:form> + </p:panel> + + <p:spacer height="20px"/> + + <!-- This form shows the currently available dependencies. --> + <h:form> + <p:dataTable id="currentDependencies" value="#{availableDependenciesBean.dependencies}" var="dependency" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15"> + <f:facet name="header"> + Currently available Dependencies + </f:facet> + <p:column> + <f:facet name="header"> + Filename + </f:facet> + <h:outputText value="#{dependency}" > + <f:converter converterId="kieker.webgui.converter.MIDependencyToStringConverter" /> + </h:outputText> + </p:column> + + <p:column> + <f:facet name="header"> + Size + </f:facet> + <center> + <h:outputText value="#{dependency}" > + <f:converter converterId="kieker.webgui.converter.MIDependencyToIntConverter" /> + </h:outputText> + </center> + </p:column> + + <p:column style="width:40px"> + <center> + <p:commandButton icon="ui-icon-trash" title="Delete"/> + </center> + </p:column> + </p:dataTable> + </h:form> + </h:body> + </f:view> </html> \ No newline at end of file -- GitLab