From dad45b5f330990f0dc04b40928d60947460542c2 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Sun, 11 Mar 2012 18:11:39 +0100 Subject: [PATCH] Minor corrections and experiments with JointJS. --- .../application/AvailableProjectsBean.java | 30 ++++++++++++------- Kieker.WebGUI/src/main/webapp/main.xhtml | 13 ++------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java index 69308739..d5bba715 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/AvailableProjectsBean.java @@ -22,6 +22,7 @@ package kieker.webgui.beans.application; import java.io.File; import java.util.List; +import javax.faces.application.FacesMessage; import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; import javax.faces.context.FacesContext; @@ -37,7 +38,9 @@ import org.primefaces.model.DefaultTreeNode; import org.primefaces.model.TreeNode; /** - * This bean can be used to handle all available projects within the program. + * 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. * * @author Nils Christian Ehmke * @version 1.0 @@ -59,32 +62,33 @@ public class AvailableProjectsBean { * Creates a new instance of this class. */ public AvailableProjectsBean() { + /* Load all projects from the file system. */ this.projects = FileManager.getInstance().loadAllProjects(); this.factory = new MAnalysisMetaModelFactory(); } /** * Uses the given name to create a new project. If a project with the - * same name does already exist, nothing happens. + * same name does already exist, nothing happens, but a message will inform the user. * * @param projectName * The name of the new project. */ public final void addProject(final String projectName) { - synchronized (this) { - /* - * Create a new project. - */ - final MIProject project = this.factory.createProject(); - project.setName(projectName); + /* + * Create a new project. + */ + final MIProject project = this.factory.createProject(); + project.setName(projectName); + /* The check for an existing project and the potential storage within our list has to be done atomically. */ + synchronized (this) { /* - * Try to save the project. + * 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. + * 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}", @@ -94,6 +98,9 @@ public class AvailableProjectsBean { } this.projects.add(project); + } else { + /* Inform the user about the fail. */ + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "A project with this name exists already.")); } } } @@ -168,4 +175,5 @@ public class AvailableProjectsBean { } } } + } diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index 599bdf32..deef92c3 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -10,10 +10,9 @@ <h:head> <title>Kieker.WebGUI</title> <link rel="stylesheet" type="text/css" href="../main.css" /> - <script src="../main/joint.all.min.js" type="text/javascript"></script> </h:head> - <h:body> + <h:body onload="initPageObjects();"> <!-- This is the layout for the whole page. --> <p:layout id="layout" fullPage="true"> @@ -102,12 +101,6 @@ <!-- ******************************************************************************** --> <!-- The following layout unit is within the center and used for the graph. --> <p:layoutUnit position="center"> - <div style="width: fill-available; height: 100%" id="myfsa" > - - </div> - <script type="text/javascript"> - - </script> </p:layoutUnit> <!-- ******************************************************************************** --> @@ -159,7 +152,7 @@ </p:treeNode> <p:treeNode type="reader" icon="ui-icon-folder-open"> <h:form> - <p:commandLink> + <p:commandLink ajax="true"> <h:outputText value="#{node}"> <f:converter converterId="kieker.webgui.converter.ClassToStringConverter"/> </h:outputText> @@ -182,7 +175,7 @@ <!-- ******************************************************************************** --> </p:layout> - <p:growl id="messages" showDetail="true" autoUpdate="true" sticky="false"/> + <p:growl id="messages" showDetail="true" autoUpdate="true" sticky="false"/> <!-- Include the dialogs for creating/deleting projects etc. --> <ui:include src="main\projectDialogs.xhtml" /> -- GitLab