From 052892b27aeb6f26301ef898640ce455cf8d20ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Mon, 16 Mar 2009 17:47:41 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@966 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../src/siprp/higiene/mapa/DiaLine.java | 9 ++- .../src/siprp/higiene/mapa/DiaPanel.java | 36 +++++------ .../src/siprp/higiene/mapa/DiaRenderer.java | 26 ++++---- .../siprp/higiene/mapa/MapaHigienePanel.java | 30 ++++----- .../siprp/higiene/mapa/MapaHigieneWindow.java | 41 ++++++------ .../src/siprp/higiene/mapa/TecnicosPanel.java | 13 +++- .../higiene/relatorio/PanelRelatorio.java | 63 ++++++++++++++++--- .../src/siprp/update/UpdateList.java | 4 +- .../siprp/update/updates/V10_9_To_V11_0.java | 48 ++++++++++++++ 9 files changed, 181 insertions(+), 89 deletions(-) create mode 100644 trunk/SIPRPSoft/src/siprp/update/updates/V10_9_To_V11_0.java diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java index 7eb4a647..4513f150 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaLine.java @@ -9,9 +9,9 @@ package siprp.higiene.mapa; -import java.util.*; +import java.util.Vector; -import com.evolute.utils.tables.*; +import com.evolute.utils.tables.ColumnizedObjectForUpdate; /** * @@ -20,10 +20,9 @@ import com.evolute.utils.tables.*; public class DiaLine implements ColumnizedObjectForUpdate { protected Integer day; - protected Vector data[]; + protected Vector data[]; - /** Creates a new instance of DiaLine */ - public DiaLine( int day, Vector data[] ) + public DiaLine( int day, Vector data[] ) { this.day = new Integer( day ); this.data = data; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java index 05c508b4..dafe4fe4 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaPanel.java @@ -1,38 +1,34 @@ -/* - * DiaPanel.java - * - * Created on February 1, 2006, 6:42 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - package siprp.higiene.mapa; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; -import com.evolute.utils.dataui.*; +import com.evolute.utils.dataui.ControllableComponent; /** * * @author fpalma */ -public class DiaPanel extends JPanel - implements ControllableComponent, ActionListener +public class DiaPanel extends JPanel implements ControllableComponent, ActionListener { + + private static final long serialVersionUID = 1L; + protected Object data[][]; protected JButton buttons[]; - /** Creates a new instance of DiaPanel */ public DiaPanel() { } - private void setupComponents() - { - } - public void setEnabled( boolean enable ) { } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java index 40dc967e..8ba625ed 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/DiaRenderer.java @@ -1,25 +1,21 @@ -/* - * DiaRenderer.java - * - * Created on 8 de Fevereiro de 2006, 21:45 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - package siprp.higiene.mapa; -import java.awt.*; -import javax.swing.*; -import javax.swing.table.*; -import java.util.*; +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; /** * * @author Frederico */ -public class DiaRenderer extends DefaultCellEditor - implements TableCellRenderer +public class DiaRenderer extends DefaultCellEditor implements TableCellRenderer { + + private static final long serialVersionUID = 1L; + protected JLabel diaLabel; protected DiaPanel diaPanel; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java index 05c6d67e..76b490f1 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigienePanel.java @@ -1,28 +1,24 @@ -/* - * MapaHigienePanel.java - * - * Created on 9 de Fevereiro de 2006, 0:11 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - package siprp.higiene.mapa; -import java.awt.*; -import javax.swing.*; -import java.util.*; +import java.awt.GridLayout; +import java.util.Vector; -import com.evolute.utils.dataui.*; -import com.evolute.utils.date.*; -import com.evolute.utils.tables.*; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import com.evolute.utils.dataui.ControllableComponent; +import com.evolute.utils.date.DateUtils; +import com.evolute.utils.tables.BaseTable; +import com.evolute.utils.tables.VectorTableModel; /** * * @author Frederico */ -public class MapaHigienePanel extends JPanel - implements ControllableComponent +public class MapaHigienePanel extends JPanel implements ControllableComponent { + + private static final long serialVersionUID = 1L; + protected BaseTable yearTable; protected VectorTableModel yearModel; protected JScrollPane yearScroll; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java index 26612fc7..ec8812dd 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/MapaHigieneWindow.java @@ -1,34 +1,33 @@ -/* - * MarcacoesHigieneWindow.java - * - * Created on January 31, 2006, 11:32 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - package siprp.higiene.mapa; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import java.util.*; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Calendar; -import com.evolute.utils.documents.*; -import com.evolute.utils.tables.*; -import com.evolute.utils.ui.*; -import com.evolute.utils.ui.window.*; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; -import siprp.higiene.*; +import siprp.higiene.HigieneDataProvider; + +import com.evolute.utils.documents.YearDocument; +import com.evolute.utils.ui.DialogException; +import com.evolute.utils.ui.window.EditorWindow; /** * * @author fpalma */ -public class MapaHigieneWindow extends EditorWindow - implements ActionListener +public class MapaHigieneWindow extends EditorWindow implements ActionListener { + + private static final long serialVersionUID = 1L; + public final static String TITLE = "Mapa de Higiene e Seguran\u00e7a"; private final static int iPermissionArray[][] = diff --git a/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java index 2cf77ab2..c098e430 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/mapa/TecnicosPanel.java @@ -9,10 +9,14 @@ package siprp.higiene.mapa; -import java.awt.*; -import javax.swing.*; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; -import siprp.higiene.*; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import siprp.higiene.HigieneDataProvider; /** * @@ -20,6 +24,9 @@ import siprp.higiene.*; */ public class TecnicosPanel extends JPanel { + + private static final long serialVersionUID = 1L; + protected HigieneDataProvider provider; /** Creates a new instance of TecnicosPanel */ diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 06833a82..b398775f 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -15,6 +15,8 @@ import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileOutputStream; import java.text.SimpleDateFormat; @@ -36,10 +38,13 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.text.AbstractDocument.LeafElement; +import leaf.data.Validator; import leaf.ui.LeafButton; import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; +import leaf.ui.LeafTextAreaEditor; import siprp.database.cayenne.objects.HsEmailEstabelecimento; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; @@ -55,6 +60,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe { private static final long serialVersionUID = 1L; + + private static final String DEFAULT_FUNCIONARIOS_TEXT = "A empresa supracitada possui ? funcionários, sendo que ? destes exercem actividades na zona de produtos frescos."; private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png"; private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; @@ -84,9 +91,20 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private final LeafIconButton buttonPdfRelatorio = LeafIconButton.createButton( "Relat" + oacute + "rio", ICON_NAME_PDF ); private final LeafButton buttonRevertPlano = LeafIconButton.createButton( "Recarregar", ICON_NAME_UNDO ); + private final JTabbedPane tabsRelatorio = new JTabbedPane(); + private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel(); + + private final LeafTextAreaEditor panelFuncionarios = new LeafTextAreaEditor( new Validator() + { + @Override + public boolean isValid( String text ) + { + return !DEFAULT_FUNCIONARIOS_TEXT.equals( text ); + } + }); - private final JTabbedPane tabs = new JTabbedPane(); + private final JTabbedPane tabsPlanoActuacao = new JTabbedPane(); private final PlanoActuacaoPanel panelPlano = new PlanoActuacaoPanel(); @@ -114,10 +132,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe bg.add( radioInicial ); bg.add( radioPeriodica ); panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) ); - panelEquipamentos.setBorder( BorderFactory.createTitledBorder( "Equipamentos de medi"+ccedil+atilde+"o" ) ); - tabs.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); - tabs.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); - tabs.addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao ); + tabsRelatorio.addTab( "Funcion" + aacute + "rios", panelFuncionarios ); + tabsRelatorio.addTab( "Equipamentos de medi"+ccedil+atilde+"o", panelEquipamentos ); + tabsPlanoActuacao.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); + tabsPlanoActuacao.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); + tabsPlanoActuacao.addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao ); buttonSave.setToolTipText( "Guardar" ); buttonRevertText.setToolTipText( "Reverter" ); buttonRevertPlano.setToolTipText( "Carregar dados do estabelecimento" ); @@ -182,9 +201,9 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe add( radioPeriodica, new TableLayoutConstraints( 6, 1 ) ); add( new JLabel( "T" + eacute + "cnico Superior de H.S." ), new TableLayoutConstraints( 0, 2, 2, 2 ) ); add( fieldTecnico, new TableLayoutConstraints( 3, 2, 6, 2 ) ); - add( panelEquipamentos, new TableLayoutConstraints( 7, 1, 7, 3 ) ); + add( tabsRelatorio, new TableLayoutConstraints( 7, 1, 7, 3 ) ); add( panelAcompanhantes, new TableLayoutConstraints( 0, 3, 6, 3 ) ); - add( tabs, new TableLayoutConstraints( 0, 4, 7, 4 ) ); + add( tabsPlanoActuacao, new TableLayoutConstraints( 0, 4, 7, 4 ) ); } private void setupListeners() @@ -242,6 +261,35 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe revert(true); } } ); + panelFuncionarios.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() + { + @Override + public void propertyChange( PropertyChangeEvent evt ) + { + try + { + String text = (String) evt.getNewValue(); + if( text != null && relatorio != null ) + { + text = text.trim(); + if( text.length() == 0 ) + { + text = null; + } + else if( text.equals( DEFAULT_FUNCIONARIOS_TEXT ) ) + { + text = null; + } + } + relatorio.setFuncionarios( text ); + relatorio.save(); + } + catch( Exception e ) + { + LeafDialog.error( e ); + } + } + } ); } protected void revert( boolean ask ) @@ -521,6 +569,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe panelPlano.setRelatorio( relatorio ); panelLegislacao.setRelatorio( relatorio ); panelNormalizacao.setRelatorio( relatorio ); + panelFuncionarios.setValue( relatorio == null ? null : ( relatorio.getFuncionarios() == null ? DEFAULT_FUNCIONARIOS_TEXT : relatorio.getFuncionarios() ) ); if( create ) { this.revert(false); diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index 2ca183f1..0f5679d7 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -20,6 +20,7 @@ import siprp.update.updates.V10_5_To_V10_6; import siprp.update.updates.V10_6_To_V10_7; import siprp.update.updates.V10_7_To_V10_8; import siprp.update.updates.V10_8_To_V10_9; +import siprp.update.updates.V10_9_To_V11_0; import siprp.update.updates.V6_1_To_V7_0; import siprp.update.updates.V7_0_To_V7_2; import siprp.update.updates.V7_2_To_V7_4; @@ -86,7 +87,8 @@ public class UpdateList new V10_1_To_V10_2(), new V10_2_To_V10_3(), new V10_3_To_V10_4(), new V10_4_To_V10_5(), new V10_5_To_V10_6(), new V10_6_To_V10_7(), - new V10_7_To_V10_8(), new V10_8_To_V10_9() + new V10_7_To_V10_8(), new V10_8_To_V10_9(), + new V10_9_To_V11_0() }; protected static Executer EXECUTER; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V10_9_To_V11_0.java b/trunk/SIPRPSoft/src/siprp/update/updates/V10_9_To_V11_0.java new file mode 100644 index 00000000..caa9fa9b --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V10_9_To_V11_0.java @@ -0,0 +1,48 @@ +package siprp.update.updates; + +import com.evolute.utils.Singleton; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; + +public class V10_9_To_V11_0 implements siprp.update.Update +{ + + public V10_9_To_V11_0() + { + } + + public String []listChanges() + { + return new String[]{ + "relatorio de higiene e seguranca: adicionado campo 'funcionarios'" + }; + } + + public double getStartVersion() + { + return 10.9; + } + + public double getEndVersion() + { + return 11.0; + } + + public void doUpdate() + throws Exception + { + DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ); + Executer executer = dbm.getSharedExecuter(); + com.evolute.utils.sql.Update update = + new com.evolute.utils.sql.Update( + "alter table hs_relatorio add column funcionarios varchar(8192); " + ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } + +}