Added new UI to upload bayesian network.
[simdecs.git] / web / bn.xhtml
index c677556..d42bc8c 100644 (file)
     </h:head>
     <h:body>
         <h:outputLabel> <h1>SimDeCS - Cadastro de Redes Bayesianas</h1> </h:outputLabel>
-        <h:panelGrid>
-           <h:form enctype="multipart/form-data">
-
-    <p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}"
-            mode="advanced"
-            update="messages" 
-            multiple="true"
-            allowTypes="/(\.|\/)(xml)$/"/>
-
-    <p:growl id="messages" showDetail="true"/>
-
-</h:form>        
-        </h:panelGrid>
+            <h:panelGrid>
+                <h:form>
+                    <p:fileUpload widgetVar="uploader" height="48" width="48"  
+                                  fileUploadListener="#{fileUploadController.handleFileUpload}"   
+                                  image="/img/bn/browse.png" customUI="true"
+                                  multiple="true" label="Selecione..." allowTypes="*.xml;" description="Images"
+                                  update="bayesianNetworkList, nodeList"/> 
+                    <h:outputLink value="#" title="Upload" onclick="uploader.upload();" 
+                                  style="font-weight:bold;color:#616D7E">Enviar Redes Bayesianas
+                    </h:outputLink>
+                </h:form>            
+            </h:panelGrid>    
         <h:panelGroup id="messagePanel" layout="block">
             <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
         </h:panelGroup>   
-            <p:panel header="Redes Bayesianas" toggleable="true" toggleListener="#{bayesianNetworkController.prepareList}">
-                <h:form>    
-                    <br></br>
-                    <h:commandLink action="#{bayesianNetworkController.prepareList}" value="Atualizar tabela"/>
-                </h:form>
-                <h:panelGrid columns="2" cellpadding="10">                                        
-                    <h:outputText escape="false" value="#{bundle.ListBayesianNetworkEmpty}" rendered="#{bayesianNetworkController.items.rowCount == 0}"/>
-                    <h:panelGroup rendered="#{bayesianNetworkController.items.rowCount > 0}">   
-
-                        <h:form id="fBayesianNetworkList">
-
-                            <p:dataTable var="bayesianNetwork" value="#{bayesianNetworkController.items}" id="bayesianNetworkList" 
-                                         paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
-                                         rowEditListener="#{bayesianNetworkController.rowEditListener}">  
-                                <p:column headerText="id">  
-                                    <h:outputText value="#{bayesianNetwork.id}"/>  
-                                </p:column>  
+        <p:panel header="Redes Bayesianas" toggleable="true" toggleListener="#{bayesianNetworkController.prepareList}">
+            <h:form>    
+                <br></br>
+                <h:commandLink action="#{bayesianNetworkController.prepareList}" value="Atualizar tabela"/>
+            </h:form>
+            <h:panelGrid columns="2" cellpadding="10">                                        
+                <h:outputText escape="false" value="#{bundle.ListBayesianNetworkEmpty}" rendered="#{bayesianNetworkController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{bayesianNetworkController.items.rowCount > 0}">   
 
-                                <p:column headerText="Nome">  
-                                    <p:cellEditor>  
-                                        <f:facet name="output">  
-                                            <h:outputText value="#{bayesianNetwork.name}"/>  
-                                        </f:facet>  
-                                        <f:facet name="input">  
-                                            <p:inputText value="#{bayesianNetwork.name}"/>  
-                                        </f:facet>  
-                                    </p:cellEditor>  
-                                </p:column>   
-                                <p:column headerText="Opções">  
-                                    <p:rowEditor />  
-                                    <h:commandLink action="#{bayesianNetworkController.destroy}" >
-                                        <h:graphicImage value="/img/bayesianNetwork/remove.png" />
-                                    </h:commandLink>
-                                </p:column>  
-                            </p:dataTable>  
-                        </h:form>         
+                    <h:form id="fBayesianNetworkList">
 
-                    </h:panelGroup>
-                </h:panelGrid>
-            </p:panel>     
-            <p:panel header="Nodos" toggleable="true">
-                <h:form>
-                    <br></br>
-                    <h:commandLink action="#{nodeController.prepareList}" value="Atualizar tabela"/>
-                </h:form>                            
-                <h:outputText escape="false" value="#{bundle.ListNodeEmpty}" rendered="#{nodeController.items.rowCount == 0}"/>
-                <h:panelGroup rendered="#{nodeController.items.rowCount > 0}">  
-                    <h:form>      
-                        <p:dataTable var="node" value="#{nodeController.items}" id="nodeList" 
+                        <p:dataTable var="bayesianNetwork" value="#{bayesianNetworkController.items}" id="bayesianNetworkList" 
                                      paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
-                                     rowEditListener="#{nodeController.rowEditListener}">  
-
-                            <p:column headerText="id">                                 
-                                <h:outputText value="#{node.id}" />                                
+                                     rowEditListener="#{bayesianNetworkController.rowEditListener}">  
+                            <p:column headerText="id">  
+                                <h:outputText value="#{bayesianNetwork.id}"/>  
                             </p:column>  
 
                             <p:column headerText="Nome">  
                                 <p:cellEditor>  
                                     <f:facet name="output">  
-                                        <h:outputText value="#{node.name}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <p:inputText value="#{node.name}" style="width:100%"/>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>  
-                            <p:column headerText="Tempo">  
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{node.time}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <p:inputText value="#{node.time}" style="width:100%"/>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>  
-                            <p:column headerText="Custo">  
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{node.cost}" />  
+                                        <h:outputText value="#{bayesianNetwork.name}"/>  
                                     </f:facet>  
                                     <f:facet name="input">  
-                                        <p:inputText value="#{node.cost}" style="width:100%"/>  
+                                        <p:inputText value="#{bayesianNetwork.name}"/>  
                                     </f:facet>  
                                 </p:cellEditor>  
-                            </p:column>  
-                            <p:column headerText="Tipo">
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{node.nodeType}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <h:selectOneMenu value="#{node.nodeType}" >  
-                                            <f:selectItems value="#{nodeTypeController.nodeTypes}"  
-                                                           var="nodeType"   
-                                                           itemLabel="#{nodeType}"  
-                                                           itemValue="#{nodeType}" />  
-                                        </h:selectOneMenu>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>  
-                            <p:column headerText="Rede Bayesiana"> 
-                                <h:outputText value="#{node.bayesianNetwork.name}"/>
-                            </p:column>  
-
-
+                            </p:column>   
                             <p:column headerText="Opções">  
                                 <p:rowEditor />  
+                                <h:commandLink action="#{bayesianNetworkController.destroy}" >
+                                    <h:graphicImage value="/img/bn/remove.png" />
+                                </h:commandLink>
                             </p:column>  
-
                         </p:dataTable>  
-                    </h:form>   
-                </h:panelGroup>
+                    </h:form>         
 
-            </p:panel>
-            <p:panel header="Perguntas" toggleable="true">
-                <h:form>
-                    <br></br>
-                    <h:commandLink action="#{questionController.prepareList}" value="Atualizar tabela"/>
-                </h:form>       
-                <h:form>
-                    <h:outputText escape="false" value="#{bundle.ListQuestionEmpty}" rendered="#{questionController.items.rowCount == 0}"/>
-                    <h:panelGroup rendered="#{questionController.items.rowCount > 0}">                       
-                        <p:dataTable var="question" value="#{questionController.items}" id="questionList" 
-                                     paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
-                                     rowEditListener="#{questionController.rowEditListener}">  
+                </h:panelGroup>
+            </h:panelGrid>
+        </p:panel>     
+        <p:panel header="Nodos" toggleable="true">
+            <h:form>
+                <br></br>
+                <h:commandLink action="#{nodeController.prepareList}" value="Atualizar tabela"/>
+            </h:form>                            
+            <h:outputText escape="false" value="#{bundle.ListNodeEmpty}" rendered="#{nodeController.items.rowCount == 0}"/>
+            <h:panelGroup rendered="#{nodeController.items.rowCount > 0}">  
+                <h:form>      
+                    <p:dataTable var="node" value="#{nodeController.items}" id="nodeList" 
+                                 paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
+                                 rowEditListener="#{nodeController.rowEditListener}">  
 
-                            <p:column headerText="id">                                 
-                                <h:outputText value="#{question.id}" />                                
-                            </p:column>  
+                        <p:column headerText="id">                                 
+                            <h:outputText value="#{node.id}" />                                
+                        </p:column>  
 
-                            <p:column headerText="Texto">  
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{question.text}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <p:inputText value="#{question.text}" style="width:100%"/>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>                     
-                            <p:column headerText="Nodo"> 
-                                <h:outputText value="#{question.node.name}"/>
-                            </p:column> 
-                            <p:column headerText="Rede Bayesiana"> 
-                                <h:outputText value="#{question.node.bayesianNetwork.name}"/>
-                            </p:column>  
+                        <p:column headerText="Nome">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{node.name}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{node.name}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>  
+                        <p:column headerText="Tempo">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{node.time}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{node.time}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>  
+                        <p:column headerText="Custo">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{node.cost}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{node.cost}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>  
+                        <p:column headerText="Tipo">
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{node.nodeType}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <h:selectOneMenu value="#{node.nodeType}" >  
+                                        <f:selectItems value="#{nodeTypeController.nodeTypes}"  
+                                                       var="nodeType"   
+                                                       itemLabel="#{nodeType}"  
+                                                       itemValue="#{nodeType}" />  
+                                    </h:selectOneMenu>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>  
+                        <p:column headerText="Rede Bayesiana"> 
+                            <h:outputText value="#{node.bayesianNetwork.name}"/>
+                        </p:column>  
 
 
-                            <p:column headerText="Opções">  
-                                <p:rowEditor />  
-                                <h:commandLink action="#{bayesianNetworkController.destroy}" >
-                                    <h:graphicImage value="/img/bayesianNetwork/remove.png" />
-                                </h:commandLink>
-                            </p:column>  
+                        <p:column headerText="Opções">  
+                            <p:rowEditor />  
+                        </p:column>  
 
-                        </p:dataTable>                                                 
-                    </h:panelGroup>                    
+                    </p:dataTable>  
                 </h:form>   
+            </h:panelGroup>
 
-                <h:form>
-                    <br></br>
-                    <h:commandLink action="/net/question/Create.xhtml" value="Criar nova pergunta"/>
-                </h:form>
-            </p:panel>
-            <p:panel header="Respostas" toggleable="true">
-                <h:form>
-                    <br></br>
-                    <h:commandLink action="#{answerController.prepareList}" value="Atualizar tabela"/>
-                </h:form>       
-                <h:form>
-                    <h:outputText escape="false" value="#{bundle.ListAnswerEmpty}" rendered="#{answerController.items.rowCount == 0}"/>
-                    <h:panelGroup rendered="#{answerController.items.rowCount > 0}">                       
-                        <p:dataTable var="answer" value="#{answerController.items}" id="answerList" 
-                                     paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
-                                     rowEditListener="#{answerController.rowEditListener}">  
+        </p:panel>
+        <p:panel header="Perguntas" toggleable="true">
+            <h:form>
+                <br></br>
+                <h:commandLink action="#{questionController.prepareList}" value="Atualizar tabela"/>
+            </h:form>       
+            <h:form>
+                <h:outputText escape="false" value="#{bundle.ListQuestionEmpty}" rendered="#{questionController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{questionController.items.rowCount > 0}">                       
+                    <p:dataTable var="question" value="#{questionController.items}" id="questionList" 
+                                 paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
+                                 rowEditListener="#{questionController.rowEditListener}">  
 
-                            <p:column headerText="id">                                 
-                                <h:outputText value="#{answer.id}" />                                
-                            </p:column>  
+                        <p:column headerText="id">                                 
+                            <h:outputText value="#{question.id}" />                                
+                        </p:column>  
 
-                            <p:column headerText="Texto">  
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{answer.text}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <p:inputText value="#{answer.text}" style="width:100%"/>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>      
-                            <p:column headerText="Probabilidade">  
-                                <p:cellEditor>  
-                                    <f:facet name="output">  
-                                        <h:outputText value="#{answer.likelihood}" />  
-                                    </f:facet>  
-                                    <f:facet name="input">  
-                                        <p:inputText value="#{answer.likelihood}" style="width:100%"/>  
-                                    </f:facet>  
-                                </p:cellEditor>  
-                            </p:column>   
-                            <p:column headerText="Pergunta"> 
-                                <h:outputText value="#{answer.question.text}"/>
-                            </p:column>
-                            <p:column headerText="Nodo"> 
-                                <h:outputText value="#{answer.question.node.name}"/>
-                            </p:column> 
-                            <p:column headerText="Rede Bayesiana"> 
-                                <h:outputText value="#{answer.question.node.bayesianNetwork.name}"/>
-                            </p:column>  
+                        <p:column headerText="Texto">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{question.text}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{question.text}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>                     
+                        <p:column headerText="Nodo"> 
+                            <h:outputText value="#{question.node.name}"/>
+                        </p:column> 
+                        <p:column headerText="Rede Bayesiana"> 
+                            <h:outputText value="#{question.node.bayesianNetwork.name}"/>
+                        </p:column>  
 
 
-                            <p:column headerText="Opções">  
-                                <p:rowEditor />  
-                            </p:column>  
-                        </p:dataTable>  
-                    </h:panelGroup>   
-                </h:form>   
-                <h:form>
-                    <br></br>
-                    <h:commandLink action="/net/answer/Create.xhtml" value="Criar nova resposta"/>
-                </h:form>
-            </p:panel>
+                        <p:column headerText="Opções">  
+                            <p:rowEditor />  
+                            <h:commandLink action="#{bayesianNetworkController.destroy}" >
+                                <h:graphicImage value="/img/bn/remove.png" />
+                            </h:commandLink>
+                        </p:column>  
+
+                    </p:dataTable>                                                 
+                </h:panelGroup>                    
+            </h:form>   
+
+            <h:form>
+                <br></br>
+                <h:commandLink action="/net/question/Create.xhtml" value="Criar nova pergunta"/>
+            </h:form>
+        </p:panel>
+        <p:panel header="Respostas" toggleable="true">
+            <h:form>
+                <br></br>
+                <h:commandLink action="#{answerController.prepareList}" value="Atualizar tabela"/>
+            </h:form>       
+            <h:form>
+                <h:outputText escape="false" value="#{bundle.ListAnswerEmpty}" rendered="#{answerController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{answerController.items.rowCount > 0}">                       
+                    <p:dataTable var="answer" value="#{answerController.items}" id="answerList" 
+                                 paginator="true" rows="10" style="width:100%" paginatorPosition="bottom"
+                                 rowEditListener="#{answerController.rowEditListener}">  
+
+                        <p:column headerText="id">                                 
+                            <h:outputText value="#{answer.id}" />                                
+                        </p:column>  
+
+                        <p:column headerText="Texto">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{answer.text}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{answer.text}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>      
+                        <p:column headerText="Probabilidade">  
+                            <p:cellEditor>  
+                                <f:facet name="output">  
+                                    <h:outputText value="#{answer.likelihood}" />  
+                                </f:facet>  
+                                <f:facet name="input">  
+                                    <p:inputText value="#{answer.likelihood}" style="width:100%"/>  
+                                </f:facet>  
+                            </p:cellEditor>  
+                        </p:column>   
+                        <p:column headerText="Pergunta"> 
+                            <h:outputText value="#{answer.question.text}"/>
+                        </p:column>
+                        <p:column headerText="Nodo"> 
+                            <h:outputText value="#{answer.question.node.name}"/>
+                        </p:column> 
+                        <p:column headerText="Rede Bayesiana"> 
+                            <h:outputText value="#{answer.question.node.bayesianNetwork.name}"/>
+                        </p:column>  
+
+
+                        <p:column headerText="Opções">  
+                            <p:rowEditor />  
+                        </p:column>  
+                    </p:dataTable>  
+                </h:panelGroup>   
+            </h:form>   
+            <h:form>
+                <br></br>
+                <h:commandLink action="/net/answer/Create.xhtml" value="Criar nova resposta"/>
+            </h:form>
+        </p:panel>
     </h:body>