Changed controllers to handle table row edit.
[simdecs.git] / web / bn.xhtml
index c677556..147a7d5 100644 (file)
@@ -9,34 +9,31 @@
         <h:outputStylesheet name="css/jsfcrud.css"/>
     </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:outputLabel> <h1>SimDeCS - Cadastro de Redes Bayesianas</h1> </h:outputLabel>           
         <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}">
+        <p:tabView id="tabView"> 
+            <p:tab id="tab1" title="Redes Bayesianas">
+                <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="tabView"/> 
+                    <h:outputLink value="#" title="Upload" onclick="uploader.upload();" 
+                                  style="font-weight:bold;color:#616D7E">Enviar Redes Bayesianas
+                    </h:outputLink>
+                </h:form>            
                 <h:form>    
                     <br></br>
-                    <h:commandLink action="#{bayesianNetworkController.prepareList}" value="Atualizar tabela"/>
+                    <h:commandLink action="#{bayesianNetworkController.recreateModel}" 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="Opções">  
                                     <p:rowEditor />  
                                     <h:commandLink action="#{bayesianNetworkController.destroy}" >
-                                        <h:graphicImage value="/img/bayesianNetwork/remove.png" />
+                                        <h:graphicImage value="/img/bn/remove.png" />
                                     </h:commandLink>
                                 </p:column>  
                             </p:dataTable>  
                         </h:form>         
-
                     </h:panelGroup>
                 </h:panelGrid>
-            </p:panel>     
-            <p:panel header="Nodos" toggleable="true">
+            </p:tab>     
+
+            <p:tab id="tab2" title="Nodos">
                 <h:form>
                     <br></br>
-                    <h:commandLink action="#{nodeController.prepareList}" value="Atualizar tabela"/>
+                    <h:commandLink action="#{nodeController.recreateModel}" value="Atualizar tabela"/>
                 </h:form>                            
                 <h:outputText escape="false" value="#{bundle.ListNodeEmpty}" rendered="#{nodeController.items.rowCount == 0}"/>
                 <h:panelGroup rendered="#{nodeController.items.rowCount > 0}">  
@@ -81,7 +78,6 @@
                             <p:column headerText="id">                                 
                                 <h:outputText value="#{node.id}" />                                
                             </p:column>  
-
                             <p:column headerText="Nome">  
                                 <p:cellEditor>  
                                     <f:facet name="output">  
                                     </f:facet>  
                                 </p:cellEditor>  
                             </p:column>  
-                            <p:column headerText="Tipo">
+                            <p:column headerText="Classificação">
                                 <p:cellEditor>  
                                     <f:facet name="output">  
                                         <h:outputText value="#{node.nodeType}" />  
                                     </f:facet>  
                                 </p:cellEditor>  
                             </p:column>  
+                            <p:column headerText="Tipo">
+                                <p:cellEditor>  
+                                    <f:facet name="output">  
+                                        <h:outputText value="#{node.nodeRole}" />  
+                                    </f:facet>  
+                                    <f:facet name="input">  
+                                        <h:selectOneMenu value="#{node.nodeRole}" >  
+                                            <f:selectItems value="#{nodeRoleController.nodeRoles}"  
+                                                           var="nodeRole"   
+                                                           itemLabel="#{nodeRole}"  
+                                                           itemValue="#{nodeRole}" />  
+                                        </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="#{nodeController.destroy}" >
+                                    <h:graphicImage value="/img/bn/remove.png" />
+                                </h:commandLink>
                             </p:column>  
-
                         </p:dataTable>  
                     </h:form>   
                 </h:panelGroup>
+                <h:form>
+                    <br></br>
+                    <h:commandLink action="/bn/node/Create.xhtml" value="Criar novo nodo"/>
+                </h:form>
+            </p:tab>
 
-            </p:panel>
-            <p:panel header="Perguntas" toggleable="true">
+            <p:tab id="tab3" title="Perguntas">
                 <h:form>
                     <br></br>
-                    <h:commandLink action="#{questionController.prepareList}" value="Atualizar tabela"/>
+                    <h:commandLink action="#{questionController.recreateModel}" value="Atualizar tabela"/>
                 </h:form>       
                 <h:form>
                     <h:outputText escape="false" value="#{bundle.ListQuestionEmpty}" rendered="#{questionController.items.rowCount == 0}"/>
                             <p:column headerText="Rede Bayesiana"> 
                                 <h:outputText value="#{question.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 action="#{questionController.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:commandLink action="/bn/question/Create.xhtml" value="Criar nova pergunta"/>
                 </h:form>
-            </p:panel>
-            <p:panel header="Respostas" toggleable="true">
+            </p:tab>
+
+            <p:tab id="tab4" title="Respostas">
                 <h:form>
                     <br></br>
-                    <h:commandLink action="#{answerController.prepareList}" value="Atualizar tabela"/>
+                    <h:commandLink action="#{answerController.recreateModel}" value="Atualizar tabela"/>
                 </h:form>       
                 <h:form>
                     <h:outputText escape="false" value="#{bundle.ListAnswerEmpty}" rendered="#{answerController.items.rowCount == 0}"/>
                             </p:column> 
                             <p:column headerText="Rede Bayesiana"> 
                                 <h:outputText value="#{answer.question.node.bayesianNetwork.name}"/>
-                            </p:column>  
-
-
+                            </p:column> 
                             <p:column headerText="Opções">  
-                                <p:rowEditor />  
+                                <p:rowEditor /> 
+                                <h:commandLink action="#{answerController.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/answer/Create.xhtml" value="Criar nova resposta"/>
+                    <h:commandLink action="/bn/answer/Create.xhtml" value="Criar nova resposta"/>
                 </h:form>
-            </p:panel>
+            </p:tab>
+        </p:tabView>
     </h:body>