From c0edf313c7bce41c6a935c8dac4c141510445912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=20Lu=C3=ADs=20=3D?= Date: Thu, 23 Oct 2008 10:14:44 +0000 Subject: [PATCH] 11/10/2008 git-svn-id: https://svn.coded.pt/svn/SIPRP@775 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../nbproject/faces-config.NavData | 11 +- .../nbproject/genfiles.properties | 4 +- trunk/PlanosActuacao/nbproject/project.xml | 2 +- trunk/PlanosActuacao/src/java/db/Db.java | 7 + .../src/java/db/entidades/Medida.java | 20 + .../src/java/db/entidades/PlanoActuacao.java | 77 +++ .../src/java/db/entidades/PostoTrabalho.java | 9 + .../src/java/db/entidades/Risco.java | 21 + .../entidades/{User.java => Utilizador.java} | 2 +- .../db/providers/GenericDataProvider.java | 18 +- .../java/db/providers/PlanosDataProvider.java | 6 +- .../providers/UtilizadoresDataProvider.java | 46 ++ .../src/java/global/Global.java | 29 +- .../src/java/mail/SendMail.java | 32 +- .../java/phaselistener/MainPhaseListener.java | 88 +++ .../src/java/planosactuacao/Dummy.java | 170 ++++++ .../src/java/planosactuacao/EditarPlano.java | 540 ++++++++++++++++++ .../src/java/planosactuacao/Footer.java | 139 +++++ .../src/java/planosactuacao/Header.java | 170 ++++++ .../src/java/planosactuacao/ListaPlanos.java | 152 +++++ .../src/java/planosactuacao/SessionBean1.java | 155 +++++ .../src/java/planosactuacao/ViewPlano.java | 139 +++++ .../PlanosActualDataProvider.java | 18 + .../PlanosConcluidosDataProvider.java | 18 + .../PlanosSeguimentoDataProvider.java | 18 + .../src/java/utils/JSFHTTPUtils.java | 23 + .../src/java/utils/JSFUtils.java | 103 ++++ .../java/viewhandler/CustomViewHandler.java | 75 +++ trunk/PlanosActuacao/web/Dummy.jsp | 62 ++ trunk/PlanosActuacao/web/EditarPlano.jsp | 31 +- trunk/PlanosActuacao/web/Footer.jsp | 29 + trunk/PlanosActuacao/web/Header.jspf | 38 ++ trunk/PlanosActuacao/web/ListaPlanos.jsp | 120 +++- trunk/PlanosActuacao/web/ViewPlano.jsp | 25 + .../web/WEB-INF/faces-config.xml | 43 ++ trunk/PlanosActuacao/web/WEB-INF/web.xml | 2 +- .../web/resources/images/SIPRP_logo_small.jpg | Bin 0 -> 1837 bytes .../resources/images/logo_auchan_small.jpg | Bin 0 -> 3819 bytes .../resources/images/logo_evolute_small.png | Bin 0 -> 2399 bytes .../web/resources/stylesheet.css | 37 ++ 40 files changed, 2438 insertions(+), 41 deletions(-) rename trunk/PlanosActuacao/src/java/db/entidades/{User.java => Utilizador.java} (99%) create mode 100644 trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java create mode 100644 trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java create mode 100644 trunk/PlanosActuacao/src/java/planosactuacao/Dummy.java create mode 100644 trunk/PlanosActuacao/src/java/planosactuacao/Footer.java create mode 100644 trunk/PlanosActuacao/src/java/planosactuacao/Header.java create mode 100644 trunk/PlanosActuacao/src/java/planosactuacao/ViewPlano.java create mode 100644 trunk/PlanosActuacao/src/java/tabledataproviders/PlanosActualDataProvider.java create mode 100644 trunk/PlanosActuacao/src/java/tabledataproviders/PlanosConcluidosDataProvider.java create mode 100644 trunk/PlanosActuacao/src/java/tabledataproviders/PlanosSeguimentoDataProvider.java create mode 100644 trunk/PlanosActuacao/src/java/utils/JSFHTTPUtils.java create mode 100644 trunk/PlanosActuacao/src/java/utils/JSFUtils.java create mode 100644 trunk/PlanosActuacao/src/java/viewhandler/CustomViewHandler.java create mode 100644 trunk/PlanosActuacao/web/Dummy.jsp create mode 100644 trunk/PlanosActuacao/web/Footer.jsp create mode 100644 trunk/PlanosActuacao/web/Header.jspf create mode 100644 trunk/PlanosActuacao/web/ViewPlano.jsp create mode 100755 trunk/PlanosActuacao/web/resources/images/SIPRP_logo_small.jpg create mode 100755 trunk/PlanosActuacao/web/resources/images/logo_auchan_small.jpg create mode 100644 trunk/PlanosActuacao/web/resources/images/logo_evolute_small.png diff --git a/trunk/PlanosActuacao/nbproject/faces-config.NavData b/trunk/PlanosActuacao/nbproject/faces-config.NavData index c224e374..3b8457b8 100644 --- a/trunk/PlanosActuacao/nbproject/faces-config.NavData +++ b/trunk/PlanosActuacao/nbproject/faces-config.NavData @@ -2,10 +2,13 @@ - - - - + + + + + + + diff --git a/trunk/PlanosActuacao/nbproject/genfiles.properties b/trunk/PlanosActuacao/nbproject/genfiles.properties index 9676046e..064caa17 100644 --- a/trunk/PlanosActuacao/nbproject/genfiles.properties +++ b/trunk/PlanosActuacao/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=0b61db7f +build.xml.data.CRC32=a8b7045a build.xml.script.CRC32=fa3993b7 build.xml.stylesheet.CRC32=cfd7ba16 # 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=0b61db7f +nbproject/build-impl.xml.data.CRC32=a8b7045a nbproject/build-impl.xml.script.CRC32=64f15e59 nbproject/build-impl.xml.stylesheet.CRC32=8926891b diff --git a/trunk/PlanosActuacao/nbproject/project.xml b/trunk/PlanosActuacao/nbproject/project.xml index c7fc1ede..2551b3fc 100644 --- a/trunk/PlanosActuacao/nbproject/project.xml +++ b/trunk/PlanosActuacao/nbproject/project.xml @@ -2,7 +2,7 @@ org.netbeans.modules.web.project - + PlanosActuacao 1.6 diff --git a/trunk/PlanosActuacao/src/java/db/Db.java b/trunk/PlanosActuacao/src/java/db/Db.java index 44369311..93ba3eb9 100644 --- a/trunk/PlanosActuacao/src/java/db/Db.java +++ b/trunk/PlanosActuacao/src/java/db/Db.java @@ -36,6 +36,13 @@ public class Db { return connection; } + public Connection getConnection() + { + HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); + connection = (Connection) session.getAttribute("connection"); + return connection; + } + public Statement createStatement() { HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(false); diff --git a/trunk/PlanosActuacao/src/java/db/entidades/Medida.java b/trunk/PlanosActuacao/src/java/db/entidades/Medida.java index 9db3f182..7a5a3a90 100644 --- a/trunk/PlanosActuacao/src/java/db/entidades/Medida.java +++ b/trunk/PlanosActuacao/src/java/db/entidades/Medida.java @@ -5,14 +5,18 @@ package db.entidades; +import java.util.Vector; + /** * * @author lluis */ public class Medida { private Integer id; + private Integer risco_id; private String descricao; private String activa; + private Vector postos; public Integer getId() { return id; @@ -37,4 +41,20 @@ public class Medida { public void setActiva(String activa) { this.activa = activa; } + + public Integer getRisco_id() { + return risco_id; + } + + public void setRisco_id(Integer risco_id) { + this.risco_id = risco_id; + } + + public Vector getPostos() { + return postos; + } + + public void setPostos(Vector postos) { + this.postos = postos; + } } diff --git a/trunk/PlanosActuacao/src/java/db/entidades/PlanoActuacao.java b/trunk/PlanosActuacao/src/java/db/entidades/PlanoActuacao.java index d07eb907..ebf1f89d 100644 --- a/trunk/PlanosActuacao/src/java/db/entidades/PlanoActuacao.java +++ b/trunk/PlanosActuacao/src/java/db/entidades/PlanoActuacao.java @@ -5,6 +5,9 @@ package db.entidades; +import java.sql.Date; +import java.util.Vector; + /** * * @author lluis @@ -13,6 +16,16 @@ public class PlanoActuacao { private Integer id; private Integer estabelecimento_id; private Integer estado; + private String descricao; + private Vector riscos; + + // + private Date data_visita; + private Integer tecnico_hs_id; + private Integer fase; + private String fase_nome; + private String tecnico_hs_nome; + private String loja_nome; public Integer getId() { return id; @@ -37,4 +50,68 @@ public class PlanoActuacao { public void setEstado(Integer estado) { this.estado = estado; } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public Vector getRiscos() { + return riscos; + } + + public void setRiscos(Vector riscos) { + this.riscos = riscos; + } + + public Date getData_visita() { + return data_visita; + } + + public void setData_visita(Date data_visita) { + this.data_visita = data_visita; + } + + public Integer getTecnico_hs_id() { + return tecnico_hs_id; + } + + public void setTecnico_hs_id(Integer tecnico_hs_id) { + this.tecnico_hs_id = tecnico_hs_id; + } + + public Integer getFase() { + return fase; + } + + public void setFase(Integer fase) { + this.fase = fase; + } + + public String getFase_nome() { + return fase_nome; + } + + public void setFase_nome(String fase_nome) { + this.fase_nome = fase_nome; + } + + public String getTecnico_hs_nome() { + return tecnico_hs_nome; + } + + public void setTecnico_hs_nome(String tecnico_hs_nome) { + this.tecnico_hs_nome = tecnico_hs_nome; + } + + public String getLoja_nome() { + return loja_nome; + } + + public void setLoja_nome(String loja_nome) { + this.loja_nome = loja_nome; + } } diff --git a/trunk/PlanosActuacao/src/java/db/entidades/PostoTrabalho.java b/trunk/PlanosActuacao/src/java/db/entidades/PostoTrabalho.java index 130e33ff..a6987b24 100644 --- a/trunk/PlanosActuacao/src/java/db/entidades/PostoTrabalho.java +++ b/trunk/PlanosActuacao/src/java/db/entidades/PostoTrabalho.java @@ -12,6 +12,7 @@ package db.entidades; public class PostoTrabalho { private Integer id; private Integer risco_id; + private Integer medida_id; private String descricao; private String activo; @@ -46,4 +47,12 @@ public class PostoTrabalho { public void setRisco_id(Integer risco_id) { this.risco_id = risco_id; } + + public Integer getMedida_id() { + return medida_id; + } + + public void setMedida_id(Integer medida_id) { + this.medida_id = medida_id; + } } diff --git a/trunk/PlanosActuacao/src/java/db/entidades/Risco.java b/trunk/PlanosActuacao/src/java/db/entidades/Risco.java index b252bb8a..c93b9263 100644 --- a/trunk/PlanosActuacao/src/java/db/entidades/Risco.java +++ b/trunk/PlanosActuacao/src/java/db/entidades/Risco.java @@ -5,6 +5,8 @@ package db.entidades; +import java.util.Vector; + /** * * @author lluis @@ -14,6 +16,9 @@ public class Risco { private Integer plano_id; private String descricao; private String activo; + private Integer valor; + + private Vector medidas; public Integer getId() { return id; @@ -46,4 +51,20 @@ public class Risco { public void setPlano_id(Integer plano_id) { this.plano_id = plano_id; } + + public Integer getValor() { + return valor; + } + + public void setValor(Integer valor) { + this.valor = valor; + } + + public Vector getMedidas() { + return medidas; + } + + public void setMedidas(Vector medidas) { + this.medidas = medidas; + } } diff --git a/trunk/PlanosActuacao/src/java/db/entidades/User.java b/trunk/PlanosActuacao/src/java/db/entidades/Utilizador.java similarity index 99% rename from trunk/PlanosActuacao/src/java/db/entidades/User.java rename to trunk/PlanosActuacao/src/java/db/entidades/Utilizador.java index e3ba7be5..9ff62553 100644 --- a/trunk/PlanosActuacao/src/java/db/entidades/User.java +++ b/trunk/PlanosActuacao/src/java/db/entidades/Utilizador.java @@ -11,7 +11,7 @@ import java.util.Date; * * @author lluis */ -public class User { +public class Utilizador { private Integer id; private String login; private String password; diff --git a/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java index 7307b61c..e32962c7 100644 --- a/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java +++ b/trunk/PlanosActuacao/src/java/db/providers/GenericDataProvider.java @@ -15,7 +15,23 @@ import java.sql.Statement; */ public class GenericDataProvider { - public Integer getMaxTableId(String table) + public void checkConnection() + { + Db db = new Db(); + if(db.getConnection() == null) + { + try + { + db.connect(); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + } + } + + protected Integer getMaxTableId(String table) { Statement st = createStatement(); String id = table + ".id"; diff --git a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java index 68f34e58..98577767 100644 --- a/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java +++ b/trunk/PlanosActuacao/src/java/db/providers/PlanosDataProvider.java @@ -9,7 +9,7 @@ import db.entidades.Medida; import db.entidades.PlanoActuacao; import db.entidades.PostoTrabalho; import db.entidades.Risco; -import db.entidades.User; +import db.entidades.Utilizador; import global.Global; import java.sql.ResultSet; import java.sql.Statement; @@ -48,7 +48,7 @@ public class PlanosDataProvider extends GenericDataProvider{ st.execute(sql); } - public ArrayList getPlanosActivos(User u) throws Exception + public ArrayList getPlanosActivos(Utilizador u) throws Exception { int userType = u.getTipo().intValue(); Statement st = createStatement(); @@ -79,7 +79,7 @@ public class PlanosDataProvider extends GenericDataProvider{ return list; } - public ArrayList getPlanosConcluidos(User u) throws Exception + public ArrayList getPlanosConcluidos(Utilizador u) throws Exception { Statement st = createStatement(); String sql = "select * from planos_actuacao where estado = 6"; diff --git a/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java new file mode 100644 index 00000000..17620ee9 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/db/providers/UtilizadoresDataProvider.java @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package db.providers; + +import db.*; +import db.entidades.Utilizador; +import java.sql.ResultSet; +import java.sql.Statement; + +/** + * + * @author lluis + */ +public class UtilizadoresDataProvider extends GenericDataProvider{ + + public Utilizador getUtilizador(Integer id) throws Exception + { + Utilizador u = new Utilizador(); + Statement st = createStatement(); + String sql = "SELECT * FROM utilizadores WHERE id = " + id; + ResultSet rs = st.executeQuery(sql); + rs.first(); + u.setId(new Integer(rs.getInt("id"))); + u.setLogin(rs.getString("login")); + u.setPassword(rs.getString("password")); + u.setData_password(rs.getDate("data_password")); + u.setEmail(rs.getString("email")); + u.setEmpresa_id(new Integer(rs.getInt("empresa_id"))); + u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id"))); + u.setAdministrador(rs.getString("administrador")); + u.setTipo(new Integer(rs.getInt("tipo"))); + u.setNumero_cedula(rs.getString("numero_cedula")); + u.setCap(rs.getString("cap")); + u.setNome(rs.getString("nome")); + u.setMedico_id(new Integer(rs.getInt("medico_id"))); + u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id"))); + u.setActivo(rs.getString("activo")); + u.setResponsavel_loja(rs.getString("responsavel_loja")); + u.setGestor_geral(rs.getString("gestor_geral")); + u.setApagado(rs.getString("apagado")); + return u; + } +} diff --git a/trunk/PlanosActuacao/src/java/global/Global.java b/trunk/PlanosActuacao/src/java/global/Global.java index 70809610..f5f185e8 100644 --- a/trunk/PlanosActuacao/src/java/global/Global.java +++ b/trunk/PlanosActuacao/src/java/global/Global.java @@ -13,16 +13,31 @@ public class Global { //tipos utilizadores public static final int RESPONSAVEL_SEGURANCA = 1; + public static final int RH = 2; public static final int TECNICO_HS = 3; + public static final int GESTOR = 6; + public static final int DIRECTOR_GERAL_RH = 7; + public static final int DIRECTOR_SIPRP = 8; public static final int DIRECTOR_LOJA = 9; public static final int DIRECTOR_NACIONAL_SEGURANCA = 10; - //Estados do plano - public static final int ESTADO_CRIACAO_TSHS = 1; - public static final int ESTADO_EDICAO_SEGURANCA = 2; - public static final int ESTADO_VALIDACAO_DIR_LOJA = 3; - public static final int ESTADO_VALIDACAO_DNS = 4; - public static final int ESTADO_VERIFICACAO_TSHS = 5; - public static final int ESTADO_CONCLUIDO = 6; + //Fases do plano + public static final int FASE_SIPRP_EMISSAO = 1; + public static final int FASE_SEGURANCA_PREENCHIMENTO = 2; + public static final int FASE_DIR_LOJA_VALIDACAO = 3; + public static final int FASE_DNS_PARECER = 4; + public static final int FASE_SIPRP_CONCLUSAO = 5; + public static final int FASE_CONCLUIDO = 6; + + //Fases do plano - texto + public static final String FASE_SIPRP_EMISSAO_TXT = "SIPRP(Emissão)"; + public static final String FASE_SEGURANCA_PREENCHIMENTO_TXT = "Segurança Auchan(Preenchimento)"; + public static final String FASE_DIR_LOJA_VALIDACAO_TXT = "Director de loja(Validação)"; + public static final String FASE_DNS_PARECER_TXT = "DNS(Parecer)"; + public static final String FASE_SIPRP_CONCLUSAO_TXT = "SIPRP(Verificação/Conclusão)"; + + public static final String[] FASES_TEXTO = new String[]{"SIPRP(Emissão)", "Segurança Auchan(Preenchimento)", "Director de loja(Validação)", "DNS(Parecer)", "SIPRP(Verificação/Conclusão)", "Concluído"}; + + public static final String ANALISE_ACIDENTES_URL = "http://localhost:8084/AnaliseAcidentesTrabalho/faces/"; //testes } diff --git a/trunk/PlanosActuacao/src/java/mail/SendMail.java b/trunk/PlanosActuacao/src/java/mail/SendMail.java index 36115906..cb7dcf3c 100644 --- a/trunk/PlanosActuacao/src/java/mail/SendMail.java +++ b/trunk/PlanosActuacao/src/java/mail/SendMail.java @@ -6,7 +6,7 @@ package mail; import db.entidades.PlanoActuacao; -import db.entidades.User; +import db.entidades.Utilizador; import global.Global; /** @@ -15,25 +15,25 @@ import global.Global; */ public class SendMail extends Mail{ - public void sendMail(User u, PlanoActuacao p) + public void sendMail(Utilizador u, PlanoActuacao p) { int estado = p.getEstado().intValue(); switch(estado) { - case Global.ESTADO_CRIACAO_TSHS: - break; - - case Global.ESTADO_EDICAO_SEGURANCA: - break; - - case Global.ESTADO_VALIDACAO_DIR_LOJA: - break; - - case Global.ESTADO_VALIDACAO_DNS: - break; - - case Global.ESTADO_VERIFICACAO_TSHS: - break; +// case Global.ESTADO_CRIACAO_TSHS: +// break; +// +// case Global.ESTADO_EDICAO_SEGURANCA: +// break; +// +// case Global.ESTADO_VALIDACAO_DIR_LOJA: +// break; +// +// case Global.ESTADO_VALIDACAO_DNS: +// break; +// +// case Global.ESTADO_VERIFICACAO_TSHS: +// break; } } } diff --git a/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java b/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java new file mode 100644 index 00000000..5e5de6d7 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/phaselistener/MainPhaseListener.java @@ -0,0 +1,88 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package phaselistener; + +import javax.faces.application.NavigationHandler; +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; +import javax.faces.event.PhaseEvent; +import javax.faces.event.PhaseId; +import javax.faces.event.PhaseListener; +import javax.servlet.http.HttpServletRequest; +import planosactuacao.SessionBean1; +import utils.JSFHTTPUtils; +import utils.JSFUtils; + +/** + * + * @author lluis + */ +public class MainPhaseListener implements PhaseListener{ + private boolean firstEntry = true; + + public void afterPhase(PhaseEvent pe) { + if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE) + { + FacesContext fc = pe.getFacesContext(); + SessionBean1 session = JSFUtils.getSessionBean(fc); + String view = fc.getViewRoot().getViewId(); + if(view.matches("/EditarPlano.jsp")) + { + session.setDisableMenu(true); + } + else + { + session.setDisableMenu(false); + } + System.out.println("VIEW : " + view); + } + } + + public void beforePhase(PhaseEvent pe) { + if(pe.getPhaseId() == PhaseId.RENDER_RESPONSE) + { + FacesContext fc = pe.getFacesContext(); + SessionBean1 session = JSFUtils.getSessionBean(fc); + String referer = JSFHTTPUtils.getReferer(pe.getFacesContext()); + System.out.println("REFERER >>" + referer + "<<"); + + //check if comes from AnalisesAcidentes. If so, set loggedIn to true: + if(referer.indexOf("AnaliseAcidentes") != -1) + { + session.setLoggedIn(true); + String user = JSFUtils.getRequestParameter(fc, "user"); + System.out.println("USER >" + user.toString() + "<"); + } + + + //Determin Session Time out + + HttpServletRequest req = (HttpServletRequest) fc.getExternalContext().getRequest(); + UIViewRoot view = fc.getViewRoot(); + + if(!req.isRequestedSessionIdValid() && view.getViewId().indexOf("Login") == -1 ){ + NavigationHandler nh = fc.getApplication().getNavigationHandler(); + nh.handleNavigation(fc, null, "login"); + } + + //Determin if user is logged in + //HttpSession session = (HttpSession) fc.getExternalContext().getSession(false); + + //SessionBean1 session = JSFUtils.getSessionBean(fc); + boolean loggedIn = session.isLoggedIn(); + System.out.println("LOGGED IN : " + loggedIn); + if(!loggedIn && view.getViewId().indexOf("Login") == -1 ){ + NavigationHandler nh = fc.getApplication().getNavigationHandler(); + nh.handleNavigation(fc, null, "login"); + } + } + } + + public PhaseId getPhaseId() { + return PhaseId.ANY_PHASE; + } + +} diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/Dummy.java b/trunk/PlanosActuacao/src/java/planosactuacao/Dummy.java new file mode 100644 index 00000000..f6aad5e5 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/planosactuacao/Dummy.java @@ -0,0 +1,170 @@ +/* + * Dummy.java + * + * Created on Oct 6, 2008, 10:43:13 AM + */ + +package planosactuacao; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.webui.jsf.component.Calendar; +import com.sun.webui.jsf.component.TextArea; +import com.sun.webui.jsf.component.TextField; +import com.sun.webui.jsf.model.DefaultTableDataProvider; +import javax.faces.component.html.HtmlPanelGrid; +import tabledataproviders.*; +import javax.faces.FacesException; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ * + * @author lluis + */ +public class Dummy extends AbstractPageBean { + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + private HtmlPanelGrid grid = new HtmlPanelGrid(); + + public HtmlPanelGrid getGrid() { + return grid; + } + + public void setGrid(HtmlPanelGrid hpg) { + this.grid = hpg; + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public Dummy() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + @Override + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("Dummy Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + @Override + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + @Override + public void prerender() { + Calendar cal = new Calendar(); + cal.setDateFormatPattern("dd-MM-yyyy"); + + grid.getChildren().add(cal); + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + @Override + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1) getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1) getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1) getBean("SessionBean1"); + } + + public String lnkAnaliseAcidentes_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return null; + } + + public String lnkLogout_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return null; + } + +} + diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java b/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java index 0601b660..5962f6c8 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/EditarPlano.java @@ -7,7 +7,21 @@ package planosactuacao; import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.webui.jsf.component.Button; +import com.sun.webui.jsf.component.Calendar; +import com.sun.webui.jsf.component.PanelGroup; +import com.sun.webui.jsf.component.StaticText; +import com.sun.webui.jsf.component.TextArea; +import com.sun.webui.jsf.component.TextField; +import db.entidades.Medida; +import db.entidades.PlanoActuacao; +import db.entidades.PostoTrabalho; +import db.entidades.Risco; +import java.util.Vector; import javax.faces.FacesException; +import javax.faces.component.html.HtmlPanelGrid; +import javax.faces.context.FacesContext; +import utils.JSFUtils; /** *

Page bean that corresponds to a similarly named JSP page. This @@ -30,7 +44,85 @@ public class EditarPlano extends AbstractPageBean { } // + HtmlPanelGrid grid; + PanelGroup pg; + StaticText st; + private HtmlPanelGrid gridLayout = new HtmlPanelGrid(); + + //Plano actuacao + PlanoActuacao plano; + Vector medidas = new Vector(); + Vector riscos = new Vector(); + Vector postos = new Vector(); + + HtmlPanelGrid gridPlano = new HtmlPanelGrid(); + HtmlPanelGrid gridRisco; + + + + int risco_id = 0; + int medida_id = 0; + int posto_id = 0; + + //page components + TextField txtResponsavelExecucao; + TextArea txtRecursos; + Calendar dtInicio; + Calendar dtFim; + + public HtmlPanelGrid getGridLayout() { + return gridLayout; + } + + public void setGridLayout(HtmlPanelGrid hpg) { + this.gridLayout = hpg; + } + private Button butGravarPlano = new Button(); + + public Button getButGravarPlano() { + return butGravarPlano; + } + + public void setButGravarPlano(Button b) { + this.butGravarPlano = b; + } + private Button butGravarRisco = new Button(); + + public Button getButGravarRisco() { + return butGravarRisco; + } + + public void setButGravarRisco(Button b) { + this.butGravarRisco = b; + } + private Button butEnviar = new Button(); + + public Button getButEnviar() { + return butEnviar; + } + + public void setButEnviar(Button b) { + this.butEnviar = b; + } + private Button butLimparDados = new Button(); + + public Button getButLimparDados() { + return butLimparDados; + } + + public void setButLimparDados(Button b) { + this.butLimparDados = b; + } + private Button butCancelar = new Button(); + + public Button getButCancelar() { + return butCancelar; + } + public void setButCancelar(Button b) { + this.butCancelar = b; + } + /** *

Construct a new Page bean instance.

*/ @@ -71,6 +163,7 @@ public class EditarPlano extends AbstractPageBean { // Perform application initialization that must complete // *after* managed components are initialized // TODO - add your own initialization code here + } /** @@ -94,6 +187,24 @@ public class EditarPlano extends AbstractPageBean { */ @Override public void prerender() { + System.out.println("PRERENDER"); + FacesContext fc = getFacesContext(); + //boolean isPostback = JSFUtils.isPostBack12(fc); + //boolean isPostback = JSFUtils.isPostBack(fc); + boolean isPostback = JSFUtils.isPostback(); + System.out.println("POSTBACK : " + isPostback); + if(!isPostback) + { + initializePlano(); + initialize(); + fillPlano(); + } + else + { + riscos = getSessionBean1().getRiscos(); + medidas = getSessionBean1().getMedidas(); + postos = getSessionBean1().getPostos(); + } } /** @@ -134,6 +245,435 @@ public class EditarPlano extends AbstractPageBean { protected ApplicationBean1 getApplicationBean1() { return (ApplicationBean1) getBean("ApplicationBean1"); } + + public String hyperlink1_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return "lista_planos"; + } + + private void fillPlano() + { + String indent = "      "; + Risco r = getNextRisco(plano.getId()); + fillRisco(r); + } + + private void fillRisco(Risco r) + { + String indent = "      "; + if(gridLayout.getChildren().size() > 0) + { + gridLayout.getChildren().clear(); + } + gridRisco = new HtmlPanelGrid(); + gridRisco.setWidth("100%"); + gridRisco.setStyle("border: solid 1px #000000"); + gridRisco.setColumns(1); + gridRisco.setColumnClasses("gridColLeft"); + + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setStyle("color: #2c4d7a"); + st.setText("RISCO 1" + ": "); + pg.getChildren().add(st); + st = new StaticText(); + st.setEscape(false); + st.setText(r.getDescricao()); + pg.getChildren().add(st); + gridRisco.getChildren().add(pg); + + st = new StaticText(); + st.setEscape(false); + st.setText(" "); + gridRisco.getChildren().add(st); + + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText("Valor:" + " "); + pg.getChildren().add(st); + st = new StaticText(); + st.setEscape(false); + st.setText(r.getValor().toString()); + pg.getChildren().add(st); + gridRisco.getChildren().add(pg); + + st = new StaticText(); + st.setEscape(false); + st.setText(" "); + gridRisco.getChildren().add(st); + + //medidas + Vector meds = getMedidas(r.getId()); + for(int i = 0; i < meds.size(); i++) + { + Medida m = medidas.get(i); + if(m.getRisco_id().intValue() == r.getId().intValue()) + { + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText(indent + "Medida" + ": "); + pg.getChildren().add(st); + st = new StaticText(); + st.setEscape(false); + st.setText(m.getDescricao()); + pg.getChildren().add(st); + gridRisco.getChildren().add(pg); + + //postos trabalho + Vector posts = getPostosTrabalho(m.getId()); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText(indent + indent + "Postos de trabalho afectados" + ": "); + pg.getChildren().add(st); + st = new StaticText(); + st.setEscape(false); + String spostos = ""; + for(int j = 0; j < posts.size(); j++) + { + PostoTrabalho p = posts.get(j); + spostos += p.getDescricao(); // + " "; + if(j < (posts.size() -1) ) + { + spostos += "; "; + } + } + st.setText(spostos); + pg.getChildren().add(st); + gridRisco.getChildren().add(pg); + } + } + + st = new StaticText(); + st.setEscape(false); + st.setText(" "); + gridRisco.getChildren().add(st); + + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText("Responsável de execução:"); + pg.getChildren().add(st); + txtResponsavelExecucao = new TextField(); + txtResponsavelExecucao.setColumns(100); + pg.getChildren().add(txtResponsavelExecucao); + gridRisco.getChildren().add(pg); + pg = new PanelGroup(); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText("Recursos necessários à implementação da medida:"); + pg.getChildren().add(st); + gridRisco.getChildren().add(pg); + txtRecursos = new TextArea(); + txtRecursos.setColumns(200); + gridRisco.getChildren().add(txtRecursos); + + HtmlPanelGrid grd = new HtmlPanelGrid(); + grd.setColumns(2); + grd.setColumnClasses("gridCol15, gridCol85"); + grd.setId("pgDtInicio"); + grd.setStyle("width: 100%"); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText("Data prevista de início:"); + grd.getChildren().add(st); + dtInicio = new Calendar(); + grd.getChildren().add(dtInicio); + gridRisco.getChildren().add(grd); + + grd = new HtmlPanelGrid(); + grd.setColumns(2); + grd.setColumnClasses("gridCol15, gridCol85"); + grd.setId("pgDtFim"); + grd.setStyle("width: 100%"); + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setText("Data prevista de conclusão:"); + grd.getChildren().add(st); + dtFim = new Calendar(); + + grd.getChildren().add(dtFim); + gridRisco.getChildren().add(grd); + + gridLayout.getChildren().add(gridRisco); + + } + + private void initializePlano() + { + getSessionBean1().setRiscosIdx(0); + //plano + plano = new PlanoActuacao(); + plano.setId(new Integer(1)); + plano.setEstabelecimento_id(new Integer(1)); + plano.setEstado(new Integer(1)); + getSessionBean1().setPlanoId(new Integer(1)); + plano.setDescricao("Plano 1"); + + //riscos + Risco r = new Risco(); + r.setId(new Integer(1)); + r.setPlano_id(new Integer(1)); + r.setDescricao("Risco A"); + r.setValor(new Integer(4)); + riscos.add(r); + + r = new Risco(); + r.setId(new Integer(2)); + r.setPlano_id(new Integer(1)); + r.setDescricao("Risco B"); + r.setValor(new Integer(6)); + riscos.add(r); + + r = new Risco(); + r.setId(new Integer(3)); + r.setPlano_id(new Integer(1)); + r.setDescricao("Risco C"); + r.setValor(new Integer(12)); + riscos.add(r); + + //medidas + Medida m = new Medida(); + m.setId(new Integer(1)); + m.setRisco_id(new Integer(1)); + m.setDescricao("Medida a"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(2)); + m.setRisco_id(new Integer(1)); + m.setDescricao("Medida b"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(3)); + m.setRisco_id(new Integer(2)); + m.setDescricao("Medida c"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(4)); + m.setRisco_id(new Integer(2)); + m.setDescricao("Medida d"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(5)); + m.setRisco_id(new Integer(2)); + m.setDescricao("Medida e"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(6)); + m.setRisco_id(new Integer(3)); + m.setDescricao("Medida f"); + medidas.add(m); + + m = new Medida(); + m.setId(new Integer(7)); + m.setRisco_id(new Integer(3)); + m.setDescricao("Medida g"); + medidas.add(m); + + //postos trabalho + PostoTrabalho p = new PostoTrabalho(); + p.setId(new Integer(1)); + p.setMedida_id(new Integer(1)); + p.setDescricao("posto 1"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(2)); + p.setMedida_id(new Integer(1)); + p.setDescricao("posto 2"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(3)); + p.setMedida_id(new Integer(1)); + p.setDescricao("posto 3"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(4)); + p.setMedida_id(new Integer(2)); + p.setDescricao("posto 4"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(5)); + p.setMedida_id(new Integer(2)); + p.setDescricao("posto 5"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(6)); + p.setMedida_id(new Integer(3)); + p.setDescricao("posto 6"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(7)); + p.setMedida_id(new Integer(3)); + p.setDescricao("posto 7"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(8)); + p.setMedida_id(new Integer(4)); + p.setDescricao("posto 8"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(9)); + p.setMedida_id(new Integer(4)); + p.setDescricao("posto 9"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(10)); + p.setMedida_id(new Integer(5)); + p.setDescricao("posto 10"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(11)); + p.setMedida_id(new Integer(5)); + p.setDescricao("posto 11"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(12)); + p.setMedida_id(new Integer(6)); + p.setDescricao("posto 12"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(13)); + p.setMedida_id(new Integer(6)); + p.setDescricao("posto 13"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(14)); + p.setMedida_id(new Integer(7)); + p.setDescricao("posto 14"); + postos.add(p); + + p = new PostoTrabalho(); + p.setId(new Integer(15)); + p.setMedida_id(new Integer(7)); + p.setDescricao("posto 15"); + postos.add(p); + getSessionBean1().setRiscos(riscos); + getSessionBean1().setMedidas(medidas); + getSessionBean1().setPostos(postos); + } + + private Risco getNextRisco(Integer planoId) + { + System.out.println("GET NEXT RISCO"); + System.out.println("RISCOS SIZE : " + riscos.size()); + riscos = getSessionBean1().getRiscos(); + risco_id = getSessionBean1().getRiscosIdx(); + Risco r = riscos.get(risco_id); + if(r != null) + { + if(r.getPlano_id().intValue() != planoId.intValue()) + { + r = null; + risco_id = 0; + } + } + risco_id++; + getSessionBean1().setRiscosIdx(risco_id); + return r; + } + + private Vector getMedidas(Integer riscoId) + { + Vector meds = new Vector(); + medidas = getSessionBean1().getMedidas(); + for(int i = 0; i < medidas.size(); i++) + { + Medida m = medidas.get(i); + if(m.getRisco_id().intValue() == riscoId.intValue()) + { + meds.add(m); + } + } + return meds; + } + + private Vector getPostosTrabalho(Integer medidaId) + { + Vector posts = new Vector(); + postos = getSessionBean1().getPostos(); + for(int i = 0; i < postos.size(); i++) + { + PostoTrabalho p = postos.get(i); + if(p.getMedida_id().intValue() == medidaId.intValue()) + { + posts.add(p); + } + } + return posts; + } + + private void initialize() + { + gridPlano.setWidth("100%"); + gridPlano.setColumns(1); + gridPlano.setColumnClasses("gridColCenter"); + //plano + st = new StaticText(); + st.setEscape(false); + st.setStyleClass("label"); + st.setStyle("font-size: 16px"); + st.setText(plano.getDescricao()); + gridPlano.getChildren().add(st); + + gridLayout.getChildren().add(gridPlano); + } + + public String butGravarPlano_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return null; + } + + public String butGravarRisco_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + System.out.println("BUT NEXT RISCO"); + Risco r = getNextRisco(getSessionBean1().getPlanoId()); + fillRisco(r); + return null; + } + + public String butEnviar_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + processEnviar(); + return null; + } + + private void processEnviar() + { + + } } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/Footer.java b/trunk/PlanosActuacao/src/java/planosactuacao/Footer.java new file mode 100644 index 00000000..9736bfc2 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/planosactuacao/Footer.java @@ -0,0 +1,139 @@ +/* + * Footer.java + * + * Created on Oct 6, 2008, 3:01:32 PM + */ + +package planosactuacao; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import javax.faces.FacesException; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ * + * @author lluis + */ +public class Footer extends AbstractPageBean { + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public Footer() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + @Override + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("Footer Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + @Override + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + @Override + public void prerender() { + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + @Override + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1) getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1) getBean("RequestBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1) getBean("SessionBean1"); + } + +} + diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/Header.java b/trunk/PlanosActuacao/src/java/planosactuacao/Header.java new file mode 100644 index 00000000..e9508a5b --- /dev/null +++ b/trunk/PlanosActuacao/src/java/planosactuacao/Header.java @@ -0,0 +1,170 @@ +/* + * Header.java + * + * Created on Oct 6, 2008, 10:35:36 AM + */ + +package planosactuacao; + +import com.sun.rave.web.ui.appbase.AbstractFragmentBean; +import db.entidades.Utilizador; +import global.Global; +import javax.faces.FacesException; +import javax.faces.context.FacesContext; +import utils.JSFHTTPUtils; +import utils.JSFUtils; + +/** + *

Fragment bean that corresponds to a similarly named JSP page + * fragment. This class contains component definitions (and initialization + * code) for all components that you have defined on this fragment, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ * + * @author lluis + */ +public class Header extends AbstractFragmentBean { + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + //
+ + public Header() { + } + + /** + *

Callback method that is called whenever a page containing + * this page fragment is navigated to, either directly via a URL, + * or indirectly via page navigation. Override this method to acquire + * resources that will be needed for event handlers and lifecycle methods.

+ * + *

The default implementation does nothing.

+ */ + @Override + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + FacesContext fc = getFacesContext(); + String referer = JSFHTTPUtils.getReferer(fc); + System.out.println("HEADER - REFERER : " + referer); + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("Page1 Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called. Override this + * method to release resources acquired in the init() + * resources that will be needed for event handlers and lifecycle methods.

+ * + *

The default implementation does nothing.

+ */ + @Override + public void destroy() { + } + + public String lnkLogout_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + FacesContext fc = getFacesContext(); + try + { + JSFUtils.logout(fc); + //JSFUtils.navigateTo(fc, "login"); + try + { + JSFUtils.redirect(fc, "http://localhost:8084/AnaliseAcidentesTrabalho/faces/Login.jsp"); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + } + catch(Exception ex) + { + + } + return null; + } + + public String lnkAnaliseAcidentes_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + + FacesContext fc = getFacesContext(); + SessionBean1 session = JSFUtils.getSessionBean(fc); + Utilizador u = session.getCurrentUser(); + + String url = Global.ANALISE_ACIDENTES_URL; + int tipo = u.getTipo().intValue(); + switch(tipo) + { + case Global.RESPONSAVEL_SEGURANCA: + url += "FormSeguranca.jsp?user=" + u.getId().intValue(); + break; + + case Global.RH: + url += "FormRH.jsp?user=" + u.getId().intValue(); + break; + + case Global.TECNICO_HS: + url += "FormHS.jsp?user=" + u.getId().intValue(); + break; + + case Global.GESTOR: + url += "FormGestor.jsp?user=" + u.getId().intValue(); + break; + + case Global.DIRECTOR_LOJA: + url += "FormGestor.jsp?user=" + u.getId().intValue(); + break; + case Global.DIRECTOR_GERAL_RH: + url += "FormDirGerRh.jsp?user=" + u.getId().intValue(); + break; + + case Global.DIRECTOR_SIPRP: + url += "FormDirSiprp.jsp?user=" + u.getId().intValue(); + break; + + case Global.DIRECTOR_NACIONAL_SEGURANCA: + url += "FormGestor.jsp?user=" + u.getId().intValue(); + break; + } + + try + { + JSFUtils.redirect(fc.getCurrentInstance(), url); + } + catch(Exception ex) + { + ex.printStackTrace(); + } + return null; + } + +} diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java index dfa9499f..16ffb937 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/ListaPlanos.java @@ -7,7 +7,16 @@ package planosactuacao; import com.sun.rave.web.ui.appbase.AbstractPageBean; +import com.sun.webui.jsf.component.Table; +import com.sun.webui.jsf.component.TableRowGroup; +import db.entidades.PlanoActuacao; +import db.providers.UtilizadoresDataProvider; +import db.entidades.Utilizador; +import java.util.ArrayList; +import java.util.Calendar; import javax.faces.FacesException; +import javax.faces.context.FacesContext; +import utils.JSFUtils; /** *

Page bean that corresponds to a similarly named JSP page. This @@ -28,6 +37,42 @@ public class ListaPlanos extends AbstractPageBean { */ private void _init() throws Exception { } + private Table table1 = new Table(); + + public Table getTable1() { + return table1; + } + + public void setTable1(Table t) { + this.table1 = t; + } + private TableRowGroup tableRowGroup1 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup1() { + return tableRowGroup1; + } + + public void setTableRowGroup1(TableRowGroup trg) { + this.tableRowGroup1 = trg; + } + private TableRowGroup tableRowGroup2 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup2() { + return tableRowGroup2; + } + + public void setTableRowGroup2(TableRowGroup trg) { + this.tableRowGroup2 = trg; + } + private TableRowGroup tableRowGroup3 = new TableRowGroup(); + + public TableRowGroup getTableRowGroup3() { + return tableRowGroup3; + } + + public void setTableRowGroup3(TableRowGroup trg) { + this.tableRowGroup3 = trg; + } // @@ -94,6 +139,37 @@ public class ListaPlanos extends AbstractPageBean { */ @Override public void prerender() { + //UIComponent emptyCol = tableRowGroup1.getEmptyDataText(); + + + tableRowGroup1.setEmptyDataMsg("Sem registos"); + tableRowGroup2.setEmptyDataMsg("Sem registos"); + tableRowGroup3.setEmptyDataMsg("Sem registos"); + + FacesContext fc = getFacesContext(); + String user_id = JSFUtils.getRequestParameter(fc, "user"); + try + { + Integer userId = new Integer(Integer.parseInt(user_id)); + + try + { + UtilizadoresDataProvider udp = new UtilizadoresDataProvider(); + udp.checkConnection(); + Utilizador u = udp.getUtilizador(userId); + getSessionBean1().setCurrentUser(u); + } + catch(Exception ex1) + { + ex1.printStackTrace(); + } + } + catch(Exception ex) + { + ex.printStackTrace(); + } + + initialize(); } /** @@ -134,6 +210,82 @@ public class ListaPlanos extends AbstractPageBean { protected SessionBean1 getSessionBean1() { return (SessionBean1) getBean("SessionBean1"); } + + public String hyperlink1_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return "editar_plano"; + } + + public String goEditarPlano_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return "editar_plano"; + } + + public String goImprimirPlano_action() { + // TODO: Process the action. Return value is a navigation + // case name where null will return to the same page. + return null; + } + + + private void initialize() + { + //Dummy : to remove later + ArrayList listActivos = new ArrayList(); + PlanoActuacao pa = new PlanoActuacao(); + + Calendar cal = Calendar.getInstance(); + + cal.set( cal.YEAR, 2008 ); + cal.set( cal.MONTH, cal.SEPTEMBER ); + cal.set( cal.DATE, 3 ); + + cal.set( cal.HOUR_OF_DAY, 0 ); + cal.set( cal.MINUTE, 0 ); + cal.set( cal.SECOND, 0 ); + cal.set( cal.MILLISECOND, 0 ); + + java.sql.Date dataVisita = + new java.sql.Date( cal.getTime().getTime() ); + + pa.setData_visita(dataVisita); + pa.setEstabelecimento_id(new Integer(12)); + pa.setFase(2); + pa.setFase_nome("SIPRP (Emissão)"); + pa.setLoja_nome("Setubal"); + pa.setTecnico_hs_id(new Integer(7)); + pa.setTecnico_hs_nome("Ana"); + listActivos.add(pa); + + pa = new PlanoActuacao(); + + cal.set( cal.YEAR, 2008 ); + cal.set( cal.MONTH, cal.OCTOBER ); + cal.set( cal.DATE, 12 ); + + cal.set( cal.HOUR_OF_DAY, 0 ); + cal.set( cal.MINUTE, 0 ); + cal.set( cal.SECOND, 0 ); + cal.set( cal.MILLISECOND, 0 ); + + dataVisita = + new java.sql.Date( cal.getTime().getTime() ); + + pa.setData_visita(dataVisita); + pa.setEstabelecimento_id(new Integer(12)); + pa.setFase(2); + pa.setFase_nome("DNS (Parecer)"); + pa.setLoja_nome("Cascais"); + pa.setTecnico_hs_id(new Integer(7)); + pa.setTecnico_hs_nome("Sónia"); + listActivos.add(pa); + + + getSessionBean1().getPlanosActualDataProvider().setList(listActivos); + //End Dummy + } } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java b/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java index 630ce50b..648d17b6 100644 --- a/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java +++ b/trunk/PlanosActuacao/src/java/planosactuacao/SessionBean1.java @@ -7,6 +7,11 @@ package planosactuacao; import com.sun.rave.web.ui.appbase.AbstractSessionBean; +import db.entidades.Medida; +import db.entidades.PostoTrabalho; +import db.entidades.Risco; +import db.entidades.Utilizador; +import java.util.Vector; import javax.faces.FacesException; /** @@ -23,7 +28,19 @@ import javax.faces.FacesException; */ public class SessionBean1 extends AbstractSessionBean { + private boolean loggedIn = false; + private Utilizador currentUser = null; private String msg; + + private Integer planoId; + private Vector riscos = new Vector(); + private Vector medidas = new Vector(); + private Vector postos = new Vector(); + private int riscosIdx = 0; + + private tabledataproviders.PlanosActualDataProvider planosActualDataProvider; + private tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider; + private tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider; // /** @@ -34,12 +51,26 @@ public class SessionBean1 extends AbstractSessionBean { private void _init() throws Exception { } // + + //menu + private boolean disableMenu; + private boolean disableMenuAnalises; + private boolean disableMenuPlanos; + private boolean disableMenuUtilizadores; + private boolean disableMenuDadosUtilizador; + /** *

Construct a new session data bean instance.

*/ public SessionBean1() { msg = ""; + + planosActualDataProvider = new tabledataproviders.PlanosActualDataProvider(); + planosSeguimentoDataProvider = new tabledataproviders.PlanosSeguimentoDataProvider(); + planosConcluidosDataProvider = new tabledataproviders.PlanosConcluidosDataProvider(); + planoId = null; + } /** @@ -133,4 +164,128 @@ public class SessionBean1 extends AbstractSessionBean { this.msg = msg; } + public boolean isLoggedIn() { + return loggedIn; + } + + public void setLoggedIn(boolean loggedIn) { + this.loggedIn = loggedIn; + } + + public tabledataproviders.PlanosActualDataProvider getPlanosActualDataProvider() { + return planosActualDataProvider; + } + + public void setPlanosActualDataProvider(tabledataproviders.PlanosActualDataProvider planosActualDataProvider) { + this.planosActualDataProvider = planosActualDataProvider; + } + + public tabledataproviders.PlanosSeguimentoDataProvider getPlanosSeguimentoDataProvider() { + return planosSeguimentoDataProvider; + } + + public void setPlanosSeguimentoDataProvider(tabledataproviders.PlanosSeguimentoDataProvider planosSeguimentoDataProvider) { + this.planosSeguimentoDataProvider = planosSeguimentoDataProvider; + } + + public tabledataproviders.PlanosConcluidosDataProvider getPlanosConcluidosDataProvider() { + return planosConcluidosDataProvider; + } + + public void setPlanosConcluidosDataProvider(tabledataproviders.PlanosConcluidosDataProvider planosConcluidosDataProvider) { + this.planosConcluidosDataProvider = planosConcluidosDataProvider; + } + + public Integer getPlanoId() { + return planoId; + } + + public void setPlanoId(Integer planoId) { + this.planoId = planoId; + } + + public Vector getRiscos() { + return riscos; + } + + public void setRiscos(Vector riscos) { + this.riscos = riscos; + } + + public Vector getMedidas() { + return medidas; + } + + public void setMedidas(Vector medidas) { + this.medidas = medidas; + } + + public Vector getPostos() { + return postos; + } + + public void setPostos(Vector postos) { + this.postos = postos; + } + + public int getRiscosIdx() { + return riscosIdx; + } + + public void setRiscosIdx(int riscosIdx) { + this.riscosIdx = riscosIdx; + } + + public Utilizador getCurrentUser() { + return currentUser; + } + + public void setCurrentUser(Utilizador currentUser) { + this.currentUser = currentUser; + } + + public boolean isDisableMenu() { + return disableMenu; + } + + public void setDisableMenu(boolean disableMenu) { + setDisableMenuAnalises(disableMenu); + setDisableMenuPlanos(disableMenu); + setDisableMenuUtilizadores(disableMenu); + setDisableMenuDadosUtilizador(disableMenu); + this.disableMenu = disableMenu; + } + + public boolean isDisableMenuAnalises() { + return disableMenuAnalises; + } + + public void setDisableMenuAnalises(boolean disableMenuAnalises) { + this.disableMenuAnalises = disableMenuAnalises; + } + + public boolean isDisableMenuPlanos() { + return disableMenuPlanos; + } + + public void setDisableMenuPlanos(boolean disableMenuPlanos) { + this.disableMenuPlanos = disableMenuPlanos; + } + + public boolean isDisableMenuUtilizadores() { + return disableMenuUtilizadores; + } + + public void setDisableMenuUtilizadores(boolean disableMenuUtilizadores) { + this.disableMenuUtilizadores = disableMenuUtilizadores; + } + + public boolean isDisableMenuDadosUtilizador() { + return disableMenuDadosUtilizador; + } + + public void setDisableMenuDadosUtilizador(boolean disableMenuDadosUtilizador) { + this.disableMenuDadosUtilizador = disableMenuDadosUtilizador; + } + } diff --git a/trunk/PlanosActuacao/src/java/planosactuacao/ViewPlano.java b/trunk/PlanosActuacao/src/java/planosactuacao/ViewPlano.java new file mode 100644 index 00000000..69eb4c8f --- /dev/null +++ b/trunk/PlanosActuacao/src/java/planosactuacao/ViewPlano.java @@ -0,0 +1,139 @@ +/* + * ViewPlano.java + * + * Created on Oct 20, 2008, 10:39:31 AM + */ + +package planosactuacao; + +import com.sun.rave.web.ui.appbase.AbstractPageBean; +import javax.faces.FacesException; + +/** + *

Page bean that corresponds to a similarly named JSP page. This + * class contains component definitions (and initialization code) for + * all components that you have defined on this page, as well as + * lifecycle methods and event handlers where you may add behavior + * to respond to incoming events.

+ * + * @author lluis + */ +public class ViewPlano extends AbstractPageBean { + // + + /** + *

Automatically managed component initialization. WARNING: + * This method is automatically generated, so any user-specified code inserted + * here is subject to being replaced.

+ */ + private void _init() throws Exception { + } + + //
+ + /** + *

Construct a new Page bean instance.

+ */ + public ViewPlano() { + } + + /** + *

Callback method that is called whenever a page is navigated to, + * either directly via a URL, or indirectly via page navigation. + * Customize this method to acquire resources that will be needed + * for event handlers and lifecycle methods, whether or not this + * page is performing post back processing.

+ * + *

Note that, if the current request is a postback, the property + * values of the components do not represent any + * values submitted with this request. Instead, they represent the + * property values that were saved for this view when it was rendered.

+ */ + @Override + public void init() { + // Perform initializations inherited from our superclass + super.init(); + // Perform application initialization that must complete + // *before* managed components are initialized + // TODO - add your own initialiation code here + + // + // Initialize automatically managed components + // *Note* - this logic should NOT be modified + try { + _init(); + } catch (Exception e) { + log("ViewPlano Initialization Failure", e); + throw e instanceof FacesException ? (FacesException) e: new FacesException(e); + } + + // + // Perform application initialization that must complete + // *after* managed components are initialized + // TODO - add your own initialization code here + } + + /** + *

Callback method that is called after the component tree has been + * restored, but before any event processing takes place. This method + * will only be called on a postback request that + * is processing a form submit. Customize this method to allocate + * resources that will be required in your event handlers.

+ */ + @Override + public void preprocess() { + } + + /** + *

Callback method that is called just before rendering takes place. + * This method will only be called for the page that + * will actually be rendered (and not, for example, on a page that + * handled a postback and then navigated to a different page). Customize + * this method to allocate resources that will be required for rendering + * this page.

+ */ + @Override + public void prerender() { + } + + /** + *

Callback method that is called after rendering is completed for + * this request, if init() was called (regardless of whether + * or not this was the page that was actually rendered). Customize this + * method to release resources acquired in the init(), + * preprocess(), or prerender() methods (or + * acquired during execution of an event handler).

+ */ + @Override + public void destroy() { + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected SessionBean1 getSessionBean1() { + return (SessionBean1) getBean("SessionBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected ApplicationBean1 getApplicationBean1() { + return (ApplicationBean1) getBean("ApplicationBean1"); + } + + /** + *

Return a reference to the scoped data bean.

+ * + * @return reference to the scoped data bean + */ + protected RequestBean1 getRequestBean1() { + return (RequestBean1) getBean("RequestBean1"); + } + +} + diff --git a/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosActualDataProvider.java b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosActualDataProvider.java new file mode 100644 index 00000000..da83da58 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosActualDataProvider.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package tabledataproviders; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class PlanosActualDataProvider extends ObjectListDataProvider { + public PlanosActualDataProvider(){ + + } +} diff --git a/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosConcluidosDataProvider.java b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosConcluidosDataProvider.java new file mode 100644 index 00000000..2b6e511e --- /dev/null +++ b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosConcluidosDataProvider.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package tabledataproviders; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class PlanosConcluidosDataProvider extends ObjectListDataProvider { + public PlanosConcluidosDataProvider(){ + + } +} diff --git a/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosSeguimentoDataProvider.java b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosSeguimentoDataProvider.java new file mode 100644 index 00000000..2615d17d --- /dev/null +++ b/trunk/PlanosActuacao/src/java/tabledataproviders/PlanosSeguimentoDataProvider.java @@ -0,0 +1,18 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package tabledataproviders; + +import com.sun.data.provider.impl.ObjectListDataProvider; + +/** + * + * @author lluis + */ +public class PlanosSeguimentoDataProvider extends ObjectListDataProvider { + public PlanosSeguimentoDataProvider(){ + + } +} diff --git a/trunk/PlanosActuacao/src/java/utils/JSFHTTPUtils.java b/trunk/PlanosActuacao/src/java/utils/JSFHTTPUtils.java new file mode 100644 index 00000000..51d05a2b --- /dev/null +++ b/trunk/PlanosActuacao/src/java/utils/JSFHTTPUtils.java @@ -0,0 +1,23 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package utils; + +import java.util.Map; +import javax.faces.context.FacesContext; + +/** + * + * @author lluis + */ +public class JSFHTTPUtils { + + public static String getReferer(FacesContext context) + { + Map headerMap = context.getCurrentInstance().getExternalContext().getRequestHeaderMap(); + String referer = (String) headerMap.get("referer"); + return referer; + } +} diff --git a/trunk/PlanosActuacao/src/java/utils/JSFUtils.java b/trunk/PlanosActuacao/src/java/utils/JSFUtils.java new file mode 100644 index 00000000..7f1bead4 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/utils/JSFUtils.java @@ -0,0 +1,103 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package utils; + +import java.util.Iterator; +import java.util.Map; +import javax.faces.application.Application; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.faces.render.ResponseStateManager; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import planosactuacao.SessionBean1; + +/** + * + * @author lluis + */ +public class JSFUtils { + + + public static SessionBean1 getSessionBean(FacesContext fc) + { + FacesContext context = fc.getCurrentInstance(); + SessionBean1 session = (SessionBean1) context.getApplication().getELResolver().getValue(context.getELContext(), null, "SessionBean1"); + return session; + } + + // + // isPostBack - JSF 1.1 implementation + // + public static boolean isPostBack(FacesContext fc) + { + Map parameterMap = fc.getExternalContext().getRequestParameterMap(); + + if(parameterMap.size() > 0) + { + Iterator iter = parameterMap.keySet().iterator(); + while(iter.hasNext()) + { + String par = (String) iter.next(); + } + return true; + } + return false; + } + + public static boolean isPostback() { + FacesContext facesContext = FacesContext.getCurrentInstance(); + Map requestScope = (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext()); + //Map requestScope = (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext); + boolean ispostback = ((Boolean)requestScope.get("ispostback")).booleanValue(); + System.out.println("POSTBACK A : " + ispostback); + return ispostback; + } + + // + // isPostBack - JSF 1.2 implementation + // + public static boolean isPostBack12(FacesContext fc) + { + ResponseStateManager rsm = fc.getRenderKit().getResponseStateManager(); + if(rsm.isPostback(fc)) + { + return true; + } + return false; + } + + public static void logout(FacesContext fc) throws Exception + { + ExternalContext ectx = fc.getCurrentInstance().getExternalContext(); + HttpSession session = (HttpSession) ectx.getSession(false); + session.invalidate(); + } + + public static void navigateTo(FacesContext fc, String outcome) + { + FacesContext context = fc.getCurrentInstance(); + Application app = context.getApplication(); + app.getNavigationHandler().handleNavigation(context, null, outcome); + } + + public static void redirect(FacesContext context, String url) throws Exception + { + HttpServletResponse response = (HttpServletResponse) context.getCurrentInstance().getExternalContext().getResponse(); + response.sendRedirect(url); + context.responseComplete(); + } + + public static String getRequestParameter(FacesContext fc, String parameter) + { + Map parameters = fc.getCurrentInstance().getExternalContext().getRequestParameterMap(); + return (String) parameters.get(parameter); + } + + + + +} diff --git a/trunk/PlanosActuacao/src/java/viewhandler/CustomViewHandler.java b/trunk/PlanosActuacao/src/java/viewhandler/CustomViewHandler.java new file mode 100644 index 00000000..83199b57 --- /dev/null +++ b/trunk/PlanosActuacao/src/java/viewhandler/CustomViewHandler.java @@ -0,0 +1,75 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package viewhandler; + +import java.io.IOException; +import java.util.Locale; +import java.util.Map; +import javax.el.ValueExpression; +import javax.faces.FacesException; +import javax.faces.application.ViewHandler; +import javax.faces.component.UIViewRoot; +import javax.faces.context.FacesContext; + +/** + * + * @author lluis + */ +public class CustomViewHandler extends ViewHandler{ + protected ViewHandler baseViewHandler; + + public CustomViewHandler(ViewHandler viewHandler) { + super(); + this.baseViewHandler = viewHandler; + } + + public Locale calculateLocale(FacesContext facesContext) { + return baseViewHandler.calculateLocale(facesContext); + } + + public String calculateRenderKitId(FacesContext facesContext) { + return baseViewHandler.calculateRenderKitId(facesContext); + } + + public UIViewRoot createView(FacesContext facesContext, String arg1) { + setPostback(facesContext, false); + return baseViewHandler.createView(facesContext, arg1); + } + + public String getActionURL(FacesContext facesContext, String arg1) { + return baseViewHandler.getActionURL(facesContext, arg1); + } + + public String getResourceURL(FacesContext facesContext, String arg1) { + return baseViewHandler.getResourceURL(facesContext, arg1); + } + + public void renderView(FacesContext facesContext, UIViewRoot arg1) throws IOException, FacesException { + baseViewHandler.renderView(facesContext, arg1); + + } + + public UIViewRoot restoreView(FacesContext facesContext, String arg1) { + setPostback(facesContext, true); + return baseViewHandler.restoreView(facesContext, arg1); + } + + public void writeState(FacesContext facesContext) throws IOException { + baseViewHandler.writeState(facesContext); + } + + public Map getRequestScope(FacesContext facesContext) { + //return (Map)facesContext.getApplication().createValueBinding(?#{requestScope}?).getValue(facesContext); + //return (Map)facesContext.getApplication(). + return (Map) facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{requestScope}", Map.class).getValue(facesContext.getELContext()); + } + + public void setPostback(FacesContext facesContext, boolean value) { + getRequestScope(facesContext).put("ispostback", new Boolean(value)); + } + + +} diff --git a/trunk/PlanosActuacao/web/Dummy.jsp b/trunk/PlanosActuacao/web/Dummy.jsp new file mode 100644 index 00000000..41525ed3 --- /dev/null +++ b/trunk/PlanosActuacao/web/Dummy.jsp @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/PlanosActuacao/web/EditarPlano.jsp b/trunk/PlanosActuacao/web/EditarPlano.jsp index 9795fdf5..33988af5 100644 --- a/trunk/PlanosActuacao/web/EditarPlano.jsp +++ b/trunk/PlanosActuacao/web/EditarPlano.jsp @@ -4,7 +4,6 @@ Created on : Aug 26, 2008, 3:10:59 PM Author : lluis --> - @@ -12,9 +11,37 @@ + - + +
+ +
+ + + + + + + + + + + + + + + + + + + +
diff --git a/trunk/PlanosActuacao/web/Footer.jsp b/trunk/PlanosActuacao/web/Footer.jsp new file mode 100644 index 00000000..9e3306f5 --- /dev/null +++ b/trunk/PlanosActuacao/web/Footer.jsp @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/trunk/PlanosActuacao/web/Header.jspf b/trunk/PlanosActuacao/web/Header.jspf new file mode 100644 index 00000000..cc9577c2 --- /dev/null +++ b/trunk/PlanosActuacao/web/Header.jspf @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/trunk/PlanosActuacao/web/ListaPlanos.jsp b/trunk/PlanosActuacao/web/ListaPlanos.jsp index 3af72684..c78ed8cc 100644 --- a/trunk/PlanosActuacao/web/ListaPlanos.jsp +++ b/trunk/PlanosActuacao/web/ListaPlanos.jsp @@ -4,17 +4,131 @@ Created on : Aug 29, 2008, 2:57:16 PM Author : lluis --> - - + + - + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/trunk/PlanosActuacao/web/ViewPlano.jsp b/trunk/PlanosActuacao/web/ViewPlano.jsp new file mode 100644 index 00000000..30f1edd1 --- /dev/null +++ b/trunk/PlanosActuacao/web/ViewPlano.jsp @@ -0,0 +1,25 @@ + + + + + + + + + + + + +
+ +
+
+
+
+
+
+
diff --git a/trunk/PlanosActuacao/web/WEB-INF/faces-config.xml b/trunk/PlanosActuacao/web/WEB-INF/faces-config.xml index 8c2a53f6..395a6561 100644 --- a/trunk/PlanosActuacao/web/WEB-INF/faces-config.xml +++ b/trunk/PlanosActuacao/web/WEB-INF/faces-config.xml @@ -6,6 +6,15 @@ 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-facesconfig_1_2.xsd"> + + viewhandler.CustomViewHandler + + pt + + + + phaselistener.MainPhaseListener + SessionBean1 planosactuacao.SessionBean1 @@ -48,4 +57,38 @@ /ListaPlanos.jsp + + /ListaPlanos.jsp + + editar_plano + /EditarPlano.jsp + + + + /EditarPlano.jsp + + lista_planos + /ListaPlanos.jsp + + + + Header + planosactuacao.Header + request + + + Dummy + planosactuacao.Dummy + request + + + Footer + planosactuacao.Footer + request + + + ViewPlano + planosactuacao.ViewPlano + request + diff --git a/trunk/PlanosActuacao/web/WEB-INF/web.xml b/trunk/PlanosActuacao/web/WEB-INF/web.xml index 3ca2889e..8fbdd8e4 100644 --- a/trunk/PlanosActuacao/web/WEB-INF/web.xml +++ b/trunk/PlanosActuacao/web/WEB-INF/web.xml @@ -73,7 +73,7 @@ - faces/Login.jsp + faces/Dummy.jsp javax.servlet.ServletException diff --git a/trunk/PlanosActuacao/web/resources/images/SIPRP_logo_small.jpg b/trunk/PlanosActuacao/web/resources/images/SIPRP_logo_small.jpg new file mode 100755 index 0000000000000000000000000000000000000000..240f2358de6f974098233ffdee13327281632692 GIT binary patch literal 1837 zcmb7=cT|&E8i#Kh0jVFI&?LY>V898;8oIy&=0jS9aRXQ&AQDAN2u&f>9TpKJ1P3LI zs0k(rj4}{qEDIJ8lwL%mz!DT`K@nwElx${q&z|{rpL^c-oO_=8d+$A0HYu9{8n7SP z4>ohaH#6Y~0D*zP1^}QaFF7(X@BtVU8jVI_EnkHa0ai)zZUT;7u%yOiWFFAA*oau?ko->pn_^D3HDG5?E&HVwWjQ(T5o#wiFWJz%5O)g8Q+te`j$>k z-%}OCls30|K4CWj4%tTGAUS;SzYQj!5!ZQi(>yhz{JiFzvp9MiY0vgp;i2f2jm9EX z-|=V7%Tp1pk*|HS5MzHjTlWYZtAX6e{MvuOrJ}*^bIZ`UD6H)v+h`hkP>?Y*NBgLf zg%W$hV+`6yYy;wI70LCu^!OfS>38JbF1UkC@*r+L^L5fQwEMzskK(kfCSiUSW=l8X zVmd!)n6)iW=5JhJ_fpOux=JuAAhK=6!WT=SlTN2xEvp45l!#)APcu8OL(HM;32zQR z_US#^t+s2C8i7~~!%p0>Op`<`M)LMEi?_^&Yb0w~-;b6RnPp3#JnPsc`E6%u;i<&8a5%oB{n-L7UhuiKOK2YH#J_B->e*K9c%RKq zxuwC!fKwGtRbzn}jdm^zcU@^QTKu^-TtM?{IAQ<{%(%@8?SFC32`k15TBox1L}=); z>q^nDO@N`2+YD;H$LZoYFNo1}y;kJ%*Ldr0=;fiJj@u)_*fPmmdYV6_$E1X5$)CR% z`{Hv&Q`)Pwo$m2RN}p!DBgbYJFbe9uIcn~Ie|`3;e9!NE^Nz|` ze;VMkVGehW2RKFZ)BTC-c>vYfWV7(-rpwW#f#y5h5l+*YVgihSDR~r5y*A%^oAlmD z8C@J1@~Y;`F8wsOC(R&TfOIwu9ULm#?cG66OM6iKkT@{v?$rz*ALUu*Sqf{m2)oFYz61UwAl z@hf(azkWBFZ{0AIHrq?Z(HR?LHg`<(w8JI+Mp``2xYqm2KheS{#0OkO;gzHiaojm( z*}xN9m|Z@&pwvC3HxO(k1L`~ZPQ=Sr$69{Kja>WDFf^#-Wyd!@%RJ3uqo0Vk#fLww z|2ALliJji;WxQ{aLTx+;KgqhqYOf5iM9zJjiJl;fts2qZ_T5ogH~sB{2;(H<$dig_ W^&p4b4$po9d@bYK>gz1o^M3*E4h0tg literal 0 HcmV?d00001 diff --git a/trunk/PlanosActuacao/web/resources/images/logo_auchan_small.jpg b/trunk/PlanosActuacao/web/resources/images/logo_auchan_small.jpg new file mode 100755 index 0000000000000000000000000000000000000000..376eee0e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0Zvd0pQj{-(31UQU|X@Zzuoy^jF7olcg2 J(eKC{`xp6x;`smo literal 0 HcmV?d00001 diff --git a/trunk/PlanosActuacao/web/resources/images/logo_evolute_small.png b/trunk/PlanosActuacao/web/resources/images/logo_evolute_small.png new file mode 100644 index 0000000000000000000000000000000000000000..0198da2b31afb5a04cc977fea06ebaef5cc3085f GIT binary patch literal 2399 zcmV-l3840gP)G|^D1{IjLWqKT`uI|fy=>X_EYl{eNscjNDb{R4jBWo=ZuDgx!rF z@bH@X^bNL*1M*GD-UDy2`n7u*G{F?0OVA`t(7~rcLS+9Re%?FS#Oe+8ShhJ1$e3^3 zw#k||R$^L;j|{;wzv9*+8%@F;0h^z=6F${vO)9wv#sEr&`);qf`bVTw`QUp_G9TPC)$MR(b{+dH0i56s3Fl zONqtWgk*`wCW6G1Gg~5Isl&!0;B_>l1d(Hslwhk2eM5&%EruNEs%KYIF@3QY#>8Id zz$5Hz3ewhl*VnS6Nhf}9h={H6SWL3h65JKj*kuczGbCFq!3JAmOM#MtpGuocq)my0 zu*@<<3J^k^T7aZ8Ut+5y>CAyKv1gbEP%2H**!{Ka6c<%<*#-AgR#How%I*{KTsAdV zS0sd>UkKht@}`h%(j;3n$wZ-;h(ePfgo|)dRW@WPWiXKVC(+~wWULNQ_J|IpEW+=e zM~QzqQu-N6zC&bi6+!P}%8G6|;edOiYv_x=Oljacihav+i_u13>;;m>PHa0dvRaiM zJdRm}{q?vUrxy-5Dou0G&49(E(kGC@UEtUvL2J)#D3xK-geQ^0L)YLcqRCAFB#k{Z zb+5?IRk%2<_&#*4EH}<3`eHAWG#aq&7)K2hr~WO9eM|AX&u7Nui*V=D+R)qZ>i%1#`$6eIE*z-gNA7T1wTS%rG7)rd&P~shQ z86xaoUa;Lz@?DyHZa^s$uk%cbeaq;N|DC3;71%0Kuw6gUG4LR@<*yL*E*_mRW;4Cf zX8&!mx`vjXo3K^t zxNFlj_y;ONcT+p@KBiQCo0iT7GztD(g}y_`eC8#G{YnX%00o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ources/stylesheet.css index 4b72c958..839c5fdc 100644 --- a/trunk/PlanosActuacao/web/resources/stylesheet.css +++ b/trunk/PlanosActuacao/web/resources/stylesheet.css @@ -5,6 +5,8 @@ /* Style rules to make Java Server faces Standarad data tables look better */ +body {background-color: #f8f8f0;} + .list-header { background-color: #eeeeee; font-size: larger; @@ -56,7 +58,42 @@ text-align: right; } +.gridCol10{ + width: 10%; +} +.gridCol15{ + width: 15%; +} +.gridCol20{ + width: 20%; +} +.gridCol30{ + width: 30%; +} +.gridCol70{ + width: 70%; +} +.gridCol80{ + width: 80%; +} +.gridCol85{ + width: 85%; +} +.gridCol90{ + width: 90%; +} + +.gridPlanosList{ + background-color: #f6f4e8; + border: solid 1px #000000; +} + /* Style rules for message severity levels */ +.labelMsg{ + font-weight : bold; + color: #cc0033; + font-size :14px ; +} .infoMessage { font-size : 13px;