Visualizacao de rede e de nodos adicionada.
authorMichele Silva <michele.silva@gmail.com>
Sat, 4 Feb 2012 23:27:20 +0000 (21:27 -0200)
committerMichele Silva <michele.silva@gmail.com>
Sat, 4 Feb 2012 23:27:20 +0000 (21:27 -0200)
20 files changed:
lib/casablanca-1.0.3.jar [new file with mode: 0644]
lib/primefaces-3.0.1.jar [new file with mode: 0644]
lib/primefaces-3.1-SNAPSHOT.jar [new file with mode: 0644]
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/ufcspa/simdecs/entities/Rede.java
src/java/org/ufcspa/simdecs/mb/bn/FileUploadController.java [moved from src/java/org/ufcspa/simdecs/bn/ui/FileUploadController.java with 75% similarity]
src/java/org/ufcspa/simdecs/mb/bn/RedeController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/mb/bn/RedeDataModel.java [new file with mode: 0644]
web/WEB-INF/lib/primefaces-3.0.1.jar [new file with mode: 0644]
web/WEB-INF/web.xml
web/editarcasos/selecioneCaso.xhtml
web/img/bn/browse.png [new file with mode: 0644]
web/img/bn/remove.png [new file with mode: 0644]
web/login.xhtml
web/rede/editarRede.xhtml [new file with mode: 0644]
web/rede/header.xhtml [new file with mode: 0644]
web/rede/index.xhtml

diff --git a/lib/casablanca-1.0.3.jar b/lib/casablanca-1.0.3.jar
new file mode 100644 (file)
index 0000000..8a866e8
Binary files /dev/null and b/lib/casablanca-1.0.3.jar differ
diff --git a/lib/primefaces-3.0.1.jar b/lib/primefaces-3.0.1.jar
new file mode 100644 (file)
index 0000000..c811102
Binary files /dev/null and b/lib/primefaces-3.0.1.jar differ
diff --git a/lib/primefaces-3.1-SNAPSHOT.jar b/lib/primefaces-3.1-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..9c4701c
Binary files /dev/null and b/lib/primefaces-3.1-SNAPSHOT.jar differ
index c62acee..df2c7ee 100644 (file)
@@ -673,8 +673,8 @@ exists or setup the property manually. For example like this:
     </target>
     <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
     <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
-        <copyfiles files="${libs.primefaces.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${libs.hibernate-support.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.primefaces-3.1-SNAPSHOT.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.avalon-framework-4.1.3.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.commons-fileupload-1.2.2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.commons-io-2.1.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
@@ -695,12 +695,13 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.unbbayes-4.10.4-1s.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.xalan-2.7.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.xml-apis-1.0.b2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.casablanca-1.0.3.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
     <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
-        <copyfiles files="${libs.primefaces.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${libs.hibernate-support.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.primefaces-3.1-SNAPSHOT.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.avalon-framework-4.1.3.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.commons-fileupload-1.2.2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.commons-io-2.1.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
@@ -721,6 +722,7 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.unbbayes-4.10.4-1s.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.xalan-2.7.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.xml-apis-1.0.b2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.casablanca-1.0.3.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
     </target>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>
index 1fe4b67..75bab72 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=8ce0c982
+build.xml.data.CRC32=04b72030
 build.xml.script.CRC32=9f680c47
 build.xml.stylesheet.CRC32=651128d4@1.36.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=8ce0c982
-nbproject/build-impl.xml.script.CRC32=6bf12d49
+nbproject/build-impl.xml.data.CRC32=04b72030
+nbproject/build-impl.xml.script.CRC32=ee0ab292
 nbproject/build-impl.xml.stylesheet.CRC32=b7883b1f@1.36.1.1
index e315115..6b7069b 100644 (file)
@@ -29,6 +29,7 @@ endorsed.classpath=\
     ${libs.javaee-endorsed-api-6.0.classpath}
 excludes=
 file.reference.avalon-framework-4.1.3.jar=lib/avalon-framework-4.1.3.jar
+file.reference.casablanca-1.0.3.jar=lib/casablanca-1.0.3.jar
 file.reference.commons-fileupload-1.2.2.jar=lib/commons-fileupload-1.2.2.jar
 file.reference.commons-io-2.1.jar=lib/commons-io-2.1.jar
 file.reference.commons-lang3-3.1.jar=lib/commons-lang3-3.1.jar
@@ -44,6 +45,7 @@ file.reference.jpf-1.5.jar=lib/jpf-1.5.jar
 file.reference.junit-4.1.jar=lib/junit-4.1.jar
 file.reference.log4j-1.2.12.jar=lib/log4j-1.2.12.jar
 file.reference.logkit-1.0.1.jar=lib/logkit-1.0.1.jar
+file.reference.primefaces-3.1-SNAPSHOT.jar=lib/primefaces-3.1-SNAPSHOT.jar
 file.reference.servlet-api-2.3.jar=lib/servlet-api-2.3.jar
 file.reference.unbbayes-4.10.4-1s.jar=lib/unbbayes-4.10.4-1s.jar
 file.reference.xalan-2.7.0.jar=lib/xalan-2.7.0.jar
@@ -61,8 +63,8 @@ j2ee.platform.wsit.classpath=
 j2ee.server.type=gfv3ee6
 jar.compress=false
 javac.classpath=\
-    ${libs.primefaces.classpath}:\
     ${libs.hibernate-support.classpath}:\
+    ${file.reference.primefaces-3.1-SNAPSHOT.jar}:\
     ${file.reference.avalon-framework-4.1.3.jar}:\
     ${file.reference.commons-fileupload-1.2.2.jar}:\
     ${file.reference.commons-io-2.1.jar}:\
@@ -82,7 +84,8 @@ javac.classpath=\
     ${file.reference.servlet-api-2.3.jar}:\
     ${file.reference.unbbayes-4.10.4-1s.jar}:\
     ${file.reference.xalan-2.7.0.jar}:\
-    ${file.reference.xml-apis-1.0.b2.jar}
+    ${file.reference.xml-apis-1.0.b2.jar}:\
+    ${file.reference.casablanca-1.0.3.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=
 javac.debug=true
index d7258b2..e78675e 100644 (file)
@@ -7,11 +7,11 @@
             <minimum-ant-version>1.6.5</minimum-ant-version>
             <web-module-libraries>
                 <library dirs="200">
-                    <file>${libs.primefaces.classpath}</file>
+                    <file>${libs.hibernate-support.classpath}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
                 <library dirs="200">
-                    <file>${libs.hibernate-support.classpath}</file>
+                    <file>${file.reference.primefaces-3.1-SNAPSHOT.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
                 <library dirs="200">
                     <file>${file.reference.xml-apis-1.0.b2.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.casablanca-1.0.3.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>
index 52a3457..56d2c22 100644 (file)
@@ -33,12 +33,16 @@ public class Rede implements Serializable {
 
     @Column(length=100, nullable=false)
     private String arquivo;
+    
+    @Column(length=100, nullable=true)
+    private String descricao;
         
     @OneToMany(cascade = javax.persistence.CascadeType.ALL, mappedBy="rede")
     private List<Nodo> nodos;
         
     public Long getId() {
         return id;
+        
     }
 
     public void setId(Long id) {
@@ -77,6 +81,11 @@ public class Rede implements Serializable {
     public void setArquivo(String arquivo) {
         this.arquivo = arquivo;
     }
+    
+    public String getNomeArquivo() {
+        String nomeArquivo = arquivo.substring(arquivo.lastIndexOf('/') + 1);
+        return nomeArquivo.substring(nomeArquivo.indexOf("_") + 1);
+    }
 
     public String getNome() {
         return nome;
@@ -86,7 +95,6 @@ public class Rede implements Serializable {
         this.nome = nome;
     }
 
-
     public List<Nodo> getNodos() {
         return nodos;
     }
@@ -94,5 +102,13 @@ public class Rede implements Serializable {
     public void setNodos(List<Nodo> nodos) {
         this.nodos = nodos;
     }
+    
+    public String getDescricao() {
+        return descricao;
+    }
+
+    public void setDescricao(String descricao) {
+        this.descricao = descricao;
+    }
 
 }
@@ -2,45 +2,35 @@
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
-package org.ufcspa.simdecs.bn.ui;
+package org.ufcspa.simdecs.mb.bn;
 
 import java.io.*;
 import java.util.ArrayList;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import javax.faces.application.FacesMessage;
 import javax.faces.bean.ManagedBean;
-import javax.faces.context.FacesContext;
-import javax.persistence.EntityManager;
+import javax.faces.bean.RequestScoped;
 import javax.xml.bind.JAXBException;
 import org.primefaces.event.FileUploadEvent;
 import org.primefaces.model.UploadedFile;
 import org.ufcspa.simdecs.entities.Nodo;
 import org.ufcspa.simdecs.entities.Rede;
-import org.ufcspa.simdecs.util.DbUtil;
+import org.ufcspa.simdecs.mb.DefaultManagedBean;
 import unbbayes.io.exception.LoadException;
 import unbbayes.io.xmlbif.version6.XMLBIFIO;
 import unbbayes.prs.bn.ProbabilisticNetwork;
 
-/**
- *
- * @author mchelem
- */
-@ManagedBean(name = "fileUploadController")
-public class FileUploadController implements Serializable {    
-    
-    private static final Logger logger = Logger.getLogger("" + FileUploadController.class);
-    EntityManager em = null;
+@ManagedBean
+@RequestScoped
+public class FileUploadController extends DefaultManagedBean {    
     
-    public FileUploadController() {
-        em = DbUtil.getInstance().getEntityManager();
-    }
+    private static final Logger logger = Logger.getLogger("" + FileUploadController.class);    
        
     private File saveUploadedFile(UploadedFile uploadedFile) throws IOException{
         long unixTime = System.currentTimeMillis() / 1000L;
         
         InputStream in = new BufferedInputStream(uploadedFile.getInputstream()); 
-        File file = new File("bn_"+ unixTime + "_" + uploadedFile.getFileName());           
+        File file = new File("bn"+ unixTime + "_" + uploadedFile.getFileName());           
         FileOutputStream fout = new FileOutputStream(file);
         while(in.available() != 0){ 
             fout.write(in.read());
@@ -50,9 +40,15 @@ public class FileUploadController implements Serializable {
     }
     
     private void persist(Rede redeBayesiana){        
-        em.getTransaction().begin();
-        em.persist(redeBayesiana);  
-        em.getTransaction().commit();
+        try
+        {   
+            em.getTransaction().begin();        
+        } 
+        finally {
+             em.persist(redeBayesiana);  
+             em.getTransaction().commit();
+        }
+       
         logger.log(Level.INFO, "Bayesian Network {0} persisted.", redeBayesiana.getNome());
     }
     
@@ -80,8 +76,7 @@ public class FileUploadController implements Serializable {
             rede.setNodos(nodes);             
             persist(rede);
             
-            FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
-            FacesContext.getCurrentInstance().addMessage(null, msg);
+           addInfoMessage("Rede Adicionada!", "Rede Bayesiana adicionada com sucesso!");
         } catch (LoadException ex) {
             Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
         } catch (IOException ex) {
diff --git a/src/java/org/ufcspa/simdecs/mb/bn/RedeController.java b/src/java/org/ufcspa/simdecs/mb/bn/RedeController.java
new file mode 100644 (file)
index 0000000..613ee2f
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.mb.bn;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.persistence.Query;
+import javax.persistence.criteria.CriteriaQuery;
+import org.primefaces.component.commandbutton.CommandButton;
+import org.primefaces.event.SelectEvent;
+import org.primefaces.event.UnselectEvent;
+import org.ufcspa.simdecs.entities.Nodo;
+import org.ufcspa.simdecs.entities.Rede;
+import org.ufcspa.simdecs.mb.DefaultManagedBean;
+
+@ManagedBean
+@SessionScoped
+public class RedeController extends DefaultManagedBean {
+
+    private Rede[] selectedItems;
+    private static final Logger logger = Logger.getLogger("" + RedeDataModel.class);
+
+    public List<Rede> getItems() {
+        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+        cq.select(cq.from(Rede.class));
+        Query q = em.createQuery(cq);
+        return q.getResultList();
+    }
+    
+    
+    public Rede getSelectedItem() {
+        assert selectedItems.length == 1;
+        return selectedItems[0];
+    }
+
+    public Rede[] getSelectedItems() {
+        return selectedItems;
+    }
+
+    public void setSelectedItems(Rede[] selectedItems) {
+        this.selectedItems = selectedItems;
+        logger.log(Level.INFO, "Set selected items.");
+    }
+
+    public RedeDataModel getSelectableItems() {
+        return new RedeDataModel(this.getItems());
+    }
+
+    public void destroy() {
+        try {
+            em.getTransaction().begin();
+        } finally {
+            for (Rede item : selectedItems) {
+                em.remove(item);
+            }
+            addInfoMessage("Rede removida!", "Rede Bayesiana removida com sucesso!");
+            em.getTransaction().commit();
+        }
+    }    
+    
+    public String close(){
+        return "/rede/index";
+    }
+    
+    public String edit() {
+        return "/rede/editarRede";
+    }
+
+    public List<Nodo> getNodos(){
+        Rede rede = getSelectedItem();
+        return rede.getNodos();               
+    }
+    
+    public boolean getViewButtonDisabled(){        
+        return selectedItems == null || selectedItems.length != 1;
+    }
+    
+    private void setViewButton(){
+        CommandButton verButton = (CommandButton) getComponentById(
+                "formRedeTable:redeTable:verButton");
+        assert verButton != null;
+        assert selectedItems != null;
+        verButton.setDisabled(getViewButtonDisabled());
+    }
+    
+    public void onRowSelect(SelectEvent event) throws Exception {
+        setViewButton();
+    }
+
+    public void onRowUnselect(UnselectEvent event) throws Exception {
+        setViewButton();
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/mb/bn/RedeDataModel.java b/src/java/org/ufcspa/simdecs/mb/bn/RedeDataModel.java
new file mode 100644 (file)
index 0000000..883aab5
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.mb.bn;
+
+/**
+ *
+ * @author mchelem
+ */  
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.faces.model.ListDataModel;
+import org.primefaces.model.SelectableDataModel;
+import org.ufcspa.simdecs.entities.Rede;
+  
+public class RedeDataModel extends ListDataModel<Rede> implements SelectableDataModel<Rede> {    
+  
+    private static final Logger logger = Logger.getLogger("" + RedeDataModel.class);
+
+    public RedeDataModel() {  
+    }  
+  
+    public RedeDataModel(List<Rede> data) {  
+        super(data);  
+    }  
+      
+    @Override
+    public Rede getRowData(String rowKey) {          
+        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data            
+        List<Rede> redes = (List<Rede>) getWrappedData();            
+        for(Rede rede : redes) {  
+            if(rowKey.equals(rede.getId().toString())){  
+                logger.log(Level.INFO, "Selected network {0}", rede.getId());
+                return rede;                  
+            }
+        }    
+        logger.log(Level.INFO, "Did not select network");
+        return null;  
+    }  
+  
+    @Override
+    public Object getRowKey(Rede rede) {  
+        return rede.getId().toString();  
+    }  
+}  
diff --git a/web/WEB-INF/lib/primefaces-3.0.1.jar b/web/WEB-INF/lib/primefaces-3.0.1.jar
new file mode 100644 (file)
index 0000000..c811102
Binary files /dev/null and b/web/WEB-INF/lib/primefaces-3.0.1.jar differ
index 8806522..f21a71e 100644 (file)
@@ -2,8 +2,12 @@
 <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
     <context-param>
         <param-name>javax.faces.PROJECT_STAGE</param-name>
-        <param-value>Development</param-value>
+        <param-value>Release</param-value>
     </context-param>
+    <context-param>  
+        <param-name>primefaces.THEME</param-name>  
+        <param-value>casablanca</param-value>  
+    </context-param>  
     <servlet>
         <servlet-name>Faces Servlet</servlet-name>
         <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
index ec35611..8a694cd 100644 (file)
@@ -1,7 +1,7 @@
 <?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:p="http://primefaces.prime.com.tr/ui"
+      xmlns:p="http://primefaces.org/ui"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:ui="http://java.sun.com/jsf/facelets">
                 <ul>
                     <ui:repeat id="listaCasos" var="caso" value="#{selecioneCasoBean.listaCasos}">
                         <li>
-                            <p:commandLink update="fEditarCaso" oncomplete="dialogEditarCaso.show()" actionListener="#{selecioneCasoBean.prepararEditarCasoClinico()}" value="#{caso.nome}" title="Editar Caso Clínico">
+                            <p:commandLink update=":fEditarCaso" oncomplete="dialogEditarCaso.show()" actionListener="#{selecioneCasoBean.prepararEditarCasoClinico()}" value="#{caso.nome}" title="Editar Caso Clínico">
                                 <f:param name="pIDCaso" value="#{caso.id}" />
                             </p:commandLink>
                         </li>
                     </ui:repeat>
                     <li>
-                        <p:commandLink oncomplete="dialogEditarCaso.show();" actionListener="#{selecioneCasoBean.preparaNovoCaso()}" update="fEditarCaso" >
+                        <p:commandLink oncomplete="dialogEditarCaso.show();" actionListener="#{selecioneCasoBean.preparaNovoCaso()}" update=":fEditarCaso" >
                             Criar um novo caso clínico
                         </p:commandLink>
                     </li>
@@ -70,7 +70,7 @@
                     &nbsp;&nbsp;&nbsp;
                     <p:commandButton onclick="dialogEditarCaso.hide();" value="Cancelar" type="button" />
                     &nbsp;&nbsp;&nbsp;
-                    <p:commandButton id="excluir" update="listaCasos" actionListener="#{selecioneCasoBean.excluirCasoClinico()}" value="Excluir" title="Excluir Caso Clínico" ajax="false">  
+                    <p:commandButton id="excluir" update=":fSelecionaCaso:listaCasos" actionListener="#{selecioneCasoBean.excluirCasoClinico()}" value="Excluir" title="Excluir Caso Clínico" ajax="false">  
                         <f:param name="pIDCaso" value="#{selecioneCasoBean.idCaso}" />
                     </p:commandButton>
                 </center>
diff --git a/web/img/bn/browse.png b/web/img/bn/browse.png
new file mode 100644 (file)
index 0000000..62fd424
Binary files /dev/null and b/web/img/bn/browse.png differ
diff --git a/web/img/bn/remove.png b/web/img/bn/remove.png
new file mode 100644 (file)
index 0000000..b18352b
Binary files /dev/null and b/web/img/bn/remove.png differ
index 3c24551..e7e8cc8 100644 (file)
@@ -1,7 +1,7 @@
 <?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:p="http://primefaces.prime.com.tr/ui"
+      xmlns:p="http://primefaces.org/ui"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core">
     <h:head>
diff --git a/web/rede/editarRede.xhtml b/web/rede/editarRede.xhtml
new file mode 100644 (file)
index 0000000..a246d57
--- /dev/null
@@ -0,0 +1,90 @@
+<?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:p="http://primefaces.org/ui"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:c="http://java.sun.com/jsp/jstl/core"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <h:head>
+        <title>SimDeCS: Redes Bayesianas</title>
+    </h:head>
+    <h:body>
+        <h:form>      
+            <h2>Rede Bayesiana: #{redeController.selectedItem.nome}</h2> 
+            <p:dataTable var="nodo" value="#{redeController.nodos}" id="nodoTable" 
+                         paginator="true" rows="10"
+                         style="width:70%"
+                         paginatorPosition="top"
+                         paginatorAlwaysVisible="false"
+                         emptyMessage="Não existem nodos cadastrados.">  
+
+                <f:facet name="header">
+                    <h:outputText value="Nodos"/>
+                    <p:separator/>
+                    <p:commandButton icon="ui-icon-close" action="#{redeController.close}" ajax="false"/>
+            <p:commandButton icon="ui-icon-plus" action="#{redeController.close}" ajax="false"/>
+                </f:facet>
+
+                <p:column headerText="Nome">  
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{nodo.nome}" />  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{nodo.nome}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+                </p:column>  
+                <p:column headerText="Nome Alternativo">  
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{nodo.nomeAmigavel}" />  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{nodo.nomeAmigavel}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+                </p:column>  
+                <p:column headerText="Custo">  
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{nodo.custo}" />  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{nodo.custo}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+                </p:column>  
+                <p:column headerText="Tipo">
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{nodo.tipo}" />  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{nodo.tipo}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+                </p:column>  
+                <p:column headerText="Bogus">
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{nodo.bogus}" />  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{nodo.bogus}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+                </p:column>              
+
+                <p:column headerText="">  
+                    <p:rowEditor />  
+
+                </p:column>  
+            </p:dataTable>  
+        </h:form>   
+
+    </h:body>
+</html>
+
diff --git a/web/rede/header.xhtml b/web/rede/header.xhtml
new file mode 100644 (file)
index 0000000..d184bad
--- /dev/null
@@ -0,0 +1,19 @@
+<?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">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:p="http://primefaces.org/ui"
+                xmlns:h="http://java.sun.com/jsf/html"
+                xmlns:ui="http://java.sun.com/jsf/facelets">
+
+    <h:form>
+        <p:menubar style="width:70%">
+            <p:menuitem value="Project" url="#"/>
+            <p:menuitem value="Other" url="#"/>
+            <p:menuitem value="Undo" url="#"/>
+            <p:menuitem value="Redo" url="#"/>
+            <p:menuitem value="Quit" url="http://www.primefaces.org"/>
+        </p:menubar>
+
+    </h:form>
+</ui:composition>
+
index b97f284..72dc886 100644 (file)
@@ -1,19 +1,90 @@
 <?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:p="http://primefaces.prime.com.tr/ui"
-      xmlns:h="http://java.sun.com/jsf/html">
+      xmlns:p="http://primefaces.org/ui"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:ui="http://java.sun.com/jsf/facelets"
+      xmlns:c="http://java.sun.com/jsp/jstl/core"
+      xmlns:f="http://java.sun.com/jsf/core">
     <h:head>
-        <title>Facelet Title</title>
+        <title>SimDeCS: Redes Bayesianas</title>
     </h:head>
     <h:body>
-        Hello from Facelets
-        <h:form enctype="multipart/form-data">
-            <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
-                          update="messages"/>
-
+<!--        <ui:include src="header.xhtml"/>-->
+        <h:form id="formUpload" enctype="multipart/form-data"> 
+            <h2>Upload de Redes Bayesianas</h2>
+            <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"  
+                          mode="advanced"  
+                          update=":formRedeTable,:formUpload:messages"  
+                          style="width:70%; height: 50px"
+                          multiple="true"
+                          allowTypes="/(\.|\/)(xml)$/"
+                          uploadLabel="Enviar"
+                          cancelLabel="Cancelar"
+                          label="Selecionar"/>  
             <p:growl id="messages" showDetail="true"/>
+        </h:form>
+
+        <br></br><br></br>     
+        <h:form id="formRedeTable">
+            <p:dataTable id="redeTable" var="rede" value="#{redeController.selectableItems}" paginator="true" rows="30"
+                         selection="#{redeController.selectedItems}" style="width:70%"
+                         paginatorPosition="top"
+                         paginatorAlwaysVisible="false"
+                         emptyMessage="Não existem redes cadastradas.">
+                
+                <p:ajax event="rowSelect" listener="#{redeController.onRowSelect}"   
+                        update=":formRedeTable,:formUpload:messages"/>  
+                <p:ajax event="rowUnselect" listener="#{redeController.onRowUnselect}"   
+                        update=":formRedeTable,:formUpload:messages"/> 
+                
+                <f:facet name="header">
+                    <h:outputText value="Redes Bayesianas"/>
+                    
+                    <p:separator />                    
+                    <p:commandButton id="verButton" icon="ui-icon-folder-open"
+                                     action="#{redeController.edit}"
+                                     disabled="#{redeController.viewButtonDisabled}" ajax="false"/>
+                    <p:commandButton icon="ui-icon-trash" actionListener="#{redeController.destroy}"
+                                     update=":formRedeTable,:formUpload:messages"/>
+                </f:facet>
+
+                <p:column selectionMode="multiple" />
+
+                <p:column headerText="Nome">
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <p:commandLink value="#{rede.nome}"/>
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{rede.nome}"/>  
+                        </f:facet>  
+                    </p:cellEditor> 
+                </p:column>
+
+                <p:column headerText="Arquivo">                    
+                    #{rede.nomeArquivo}
+                </p:column>        
+
+                <p:column headerText="Descrição">                    
+                    <p:cellEditor>  
+                        <f:facet name="output">  
+                            <h:outputText value="#{rede.descricao}"/>  
+                        </f:facet>  
+                        <f:facet name="input">  
+                            <p:inputText value="#{rede.descricao}"/>  
+                        </f:facet>  
+                    </p:cellEditor>  
+
+                </p:column>     
+
+                <p:column headerText="">  
+                    <p:rowEditor />                     
+                </p:column>  
+
+            </p:dataTable>
 
+            
         </h:form>
     </h:body>
 </html>