From 61dadc84a612896c374ce6ef5aa8935942c35eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Thu, 8 Jan 2009 12:09:38 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@892 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../higiene/gestao/GestaoRelatorioWindow.java | 2 +- .../src/siprp/higiene/gestao/GlobalPanel.java | 4 + .../legislacao/GerirLegislacaoPanel.java | 12 +- .../normalizacao/GerirNormalizacaoPanel.java | 504 ++++++++++++++++++ .../gestao/postos/AdicionarAreasPanel.java | 2 +- .../gestao/postos/GerirAreasPanel.java | 198 ++++--- .../gestao/riscos/AdicionarRiscosPanel.java | 2 +- .../gestao/riscos/GerirMedidaPanel.java | 3 + .../gestao/riscos/GerirRiscosPanel.java | 2 +- .../higiene/relatorio/PanelRelatorio.java | 43 +- .../higiene/relatorio/PlanoActuacaoPanel.java | 4 +- .../src/siprp/update/UpdateList.java | 55 +- .../siprp/update/updates/V10_0_To_V10_1.java | 59 ++ trunk/common/src/SIPRPMap.map.xml | 40 ++ .../src/leaf/ui/LeafTextAreaEditor.java | 3 + .../src/leaf/ui/TreeInserterDialog.java | 48 +- .../cayenne/objects/HsNormalizacao.java | 24 + .../objects/HsNormalizacaoEmpresa.java | 7 + .../HsNormalizacaoEstabelecimento.java | 7 + .../cayenne/objects/HsRiscoMedida.java | 2 +- .../objects/auto/_HsNormalizacaoEmpresa.java | 39 ++ .../auto/_HsNormalizacaoEstabelecimento.java | 39 ++ .../cayenne/providers/PlanoActuacaoDAO.java | 10 + .../siprp/logic/HigieneSegurancaLogic.java | 12 + 24 files changed, 985 insertions(+), 136 deletions(-) create mode 100644 trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java create mode 100644 trunk/SIPRPSoft/src/siprp/update/updates/V10_0_To_V10_1.java create mode 100644 trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEmpresa.java create mode 100644 trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEstabelecimento.java create mode 100644 trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEmpresa.java create mode 100644 trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEstabelecimento.java diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GestaoRelatorioWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GestaoRelatorioWindow.java index 0f1b3463..795cf802 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GestaoRelatorioWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GestaoRelatorioWindow.java @@ -15,7 +15,7 @@ public class GestaoRelatorioWindow extends JFrame implements TrackableWindow public static final String TITLE = "Gest" + atilde + "o de Relat" + oacute + "rio de Higiene e Seguran" + ccedil + "a"; - private static final Dimension SIZE = new Dimension( 800, 600 ); + private static final Dimension SIZE = new Dimension( 1024, 700 ); private static final long serialVersionUID = 1L; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java index 077fc8aa..1d76959a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java @@ -3,6 +3,7 @@ package siprp.higiene.gestao; import javax.swing.JTabbedPane; import siprp.higiene.gestao.legislacao.GerirLegislacaoPanel; +import siprp.higiene.gestao.normalizacao.GerirNormalizacaoPanel; import siprp.higiene.gestao.riscos.GerirRiscosPanel; import static com.evolute.utils.strings.UnicodeLatin1Map.*; @@ -15,6 +16,8 @@ public class GlobalPanel extends JTabbedPane private final GerirRiscosPanel panelRiscos = new GerirRiscosPanel(); private final GerirLegislacaoPanel panelLegislacao = new GerirLegislacaoPanel(); + + private final GerirNormalizacaoPanel panelNormalizacao= new GerirNormalizacaoPanel(); public GlobalPanel() { @@ -28,6 +31,7 @@ public class GlobalPanel extends JTabbedPane { addTab( "Riscos", panelRiscos ); addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); + addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao ); } private void setupLayout() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java index 450da532..02057160 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java @@ -363,9 +363,17 @@ public class GerirLegislacaoPanel extends JPanel private void removerCategoria() { - if( selectedCategoria != null ) + try { - selectedCategoria.setDeletedDate( new Date() ); + if( selectedCategoria != null ) + { + selectedCategoria.setDeletedDate( new Date() ); + selectedCategoria.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java new file mode 100644 index 00000000..cee3d565 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java @@ -0,0 +1,504 @@ +package siprp.higiene.gestao.normalizacao; + +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; +import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; +import info.clearthought.layout.TableLayout; +import info.clearthought.layout.TableLayoutConstraints; + +import java.awt.GridLayout; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + +import leaf.data.Validator; +import leaf.ui.LeafButton; +import leaf.ui.LeafError; +import leaf.ui.LeafTextAreaEditor; +import leaf.ui.TreeTools; +import siprp.database.cayenne.objects.HsNormalizacao; +import siprp.logic.HigieneSegurancaLogic; + +public class GerirNormalizacaoPanel extends JPanel +{ + + private static final long serialVersionUID = 1L; + + private final JPanel panelPortuguesa = new JPanel(); + + private final JPanel panelInternacional = new JPanel(); + + private final JPanel panelButtonsPortuguesa = new JPanel(); + + private final LeafButton buttonPortuguesaCriar = new LeafButton( "Criar" ); + + private final LeafButton buttonPortuguesaEditar = new LeafButton( "Editar" ); + + private final LeafButton buttonPortuguesaRemover = new LeafButton( "Remover" ); + + private final JPanel panelButtonsInternacional = new JPanel(); + + private final LeafButton buttonInternacionalCriar = new LeafButton( "Criar" ); + + private final LeafButton buttonInternacionalEditar = new LeafButton( "Editar" ); + + private final LeafButton buttonInternacionalRemover = new LeafButton( "Remover" ); + + private final DefaultMutableTreeNode rootPortuguesa = new DefaultMutableTreeNode(); + + private final DefaultTreeModel modelPortuguesa = new DefaultTreeModel( rootPortuguesa ); + + private final JTree treePortuguesa = new JTree( modelPortuguesa ); + + private final JScrollPane scrollPortuguesa = new JScrollPane( treePortuguesa ); + + private final DefaultMutableTreeNode rootInternacional = new DefaultMutableTreeNode(); + + private final DefaultTreeModel modelInternacional = new DefaultTreeModel( rootInternacional ); + + private final JTree treeInternacional = new JTree( modelInternacional ); + + private final JScrollPane scrollInternacional = new JScrollPane( treeInternacional ); + + private HsNormalizacao selectedPortuguesa = null; + + private HsNormalizacao selectedInternacional = null; + + private final JPanel panelData = new JPanel(); + + private final JTextField textCodigo = new JTextField(10); + + private final LeafTextAreaEditor textDescricao = new LeafTextAreaEditor( new Validator() + { + @Override + public boolean isValid( String object ) + { + return true; + } + } ); + + public GerirNormalizacaoPanel() + { + startupComponents(); + startupLayout(); + placeComponents(); + setupListeners(); + reload(); + } + + private void startupComponents() + { + panelPortuguesa.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Portuguesa" ) ); + + panelInternacional.setBorder( BorderFactory.createTitledBorder( "Normaliza" + ccedil + atilde + "o Internacional" ) ); + + treeInternacional.setRootVisible( false ); + treePortuguesa.setRootVisible( false ); + treeInternacional.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); + treePortuguesa.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); + + textCodigo.setEnabled( false ); + } + + private void startupLayout() + { + LayoutManager layout = new TableLayout( new double[] { + TableLayout.FILL, TableLayout.FILL + }, new double[] { + TableLayout.FILL, TableLayout.FILL + } ); + this.setLayout( layout ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM, TableLayout.FILL + } ); + panelPortuguesa.setLayout( layout ); + ((TableLayout) layout).setHGap( 5 ); + ((TableLayout) layout).setVGap( 5 ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM, TableLayout.FILL + } ); + ((TableLayout) layout).setHGap( 5 ); + ((TableLayout) layout).setVGap( 5 ); + + panelInternacional.setLayout( layout ); + + layout = new GridLayout( 3, 1, 5, 5 ); + panelButtonsPortuguesa.setLayout( layout ); + + layout = new GridLayout( 3, 1, 5, 5 ); + panelButtonsInternacional.setLayout( layout ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM, TableLayout.FILL + } ); + ((TableLayout) layout).setHGap( 5 ); + ((TableLayout) layout).setVGap( 5 ); + panelData.setLayout( layout ); + } + + private void placeComponents() + { + panelButtonsPortuguesa.add( buttonPortuguesaCriar ); + panelButtonsPortuguesa.add( buttonPortuguesaEditar ); + panelButtonsPortuguesa.add( buttonPortuguesaRemover ); + + panelButtonsInternacional.add( buttonInternacionalCriar ); + panelButtonsInternacional.add( buttonInternacionalEditar ); + panelButtonsInternacional.add( buttonInternacionalRemover ); + + panelPortuguesa.add( panelButtonsPortuguesa, new TableLayoutConstraints( 0, 0 ) ); + panelPortuguesa.add( scrollPortuguesa, new TableLayoutConstraints( 1, 0, 1, 1 ) ); + + panelInternacional.add( panelButtonsInternacional, new TableLayoutConstraints( 0, 0 ) ); + panelInternacional.add( scrollInternacional, new TableLayoutConstraints( 1, 0, 1, 1 ) ); + + panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 0 ) ); + panelData.add( textCodigo, new TableLayoutConstraints( 1, 0 ) ); + panelData.add( textDescricao, new TableLayoutConstraints( 0, 1, 2, 1 ) ); + + this.add( panelPortuguesa, new TableLayoutConstraints( 0, 0 ) ); + this.add( panelInternacional, new TableLayoutConstraints( 0, 1 ) ); + this.add( panelData, new TableLayoutConstraints( 1, 0, 1, 1 ) ); + } + + private void setupListeners() + { + treeInternacional.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { + @Override + public void valueChanged( TreeSelectionEvent e ) + { + TreePath selectionPath = e.getNewLeadSelectionPath(); + if( selectionPath != null ) + { + Object last = selectionPath.getLastPathComponent(); + if( last instanceof DefaultMutableTreeNode ) + { + Object userObject = ((DefaultMutableTreeNode) last).getUserObject(); + if( userObject instanceof HsNormalizacao ) + { + selectedInternacional = (HsNormalizacao) userObject; + } + } + treePortuguesa.clearSelection(); + selectedPortuguesa = null; + } + else + { + selectedInternacional = null; + } + refreshData(); + setEnable(); + } + } ); + treePortuguesa.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { + @Override + public void valueChanged( TreeSelectionEvent e ) + { + TreePath selectionPath = e.getNewLeadSelectionPath(); + if( selectionPath != null ) + { + Object last = selectionPath.getLastPathComponent(); + if( last instanceof DefaultMutableTreeNode ) + { + Object userObject = ((DefaultMutableTreeNode) last).getUserObject(); + if( userObject instanceof HsNormalizacao ) + { + selectedPortuguesa = (HsNormalizacao) userObject; + } + } + treeInternacional.clearSelection(); + selectedInternacional = null; + } + else + { + selectedPortuguesa = null; + } + refreshData(); + setEnable(); + } + } ); + textDescricao.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() + { + @Override + public void propertyChange( PropertyChangeEvent evt ) + { + try + { + String newValue = (String) evt.getNewValue(); + if( selectedInternacional != null ) + { + selectedInternacional.setDescricao( newValue ); + selectedInternacional.save(); + } + else if( selectedPortuguesa != null ) + { + selectedPortuguesa.setDescricao( newValue ); + selectedPortuguesa.save(); + } + reload(); + } catch( Exception e ) + { + LeafError.error( e ); + } + } + } ); + buttonPortuguesaCriar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + criarPortuguesa(); + } + } ); + buttonPortuguesaEditar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + editarPortuguesa(); + } + } ); + buttonPortuguesaRemover.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + removerPortuguesa(); + } + } ); + buttonInternacionalCriar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + criarInternacional(); + } + } ); + buttonInternacionalEditar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + editarInternacional(); + } + } ); + buttonInternacionalRemover.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + removerInternacional(); + } + } ); + } + + private String getCodigoForNormalizacao( boolean criar, boolean portuguesa ) + { + String result = null; + if( criar ) + { + result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", "Criar normaliza" + ccedil + atilde + "o" + (portuguesa ? " Portuguesa": " internacional"), JOptionPane.QUESTION_MESSAGE ); + } + else + { + result = JOptionPane.showInputDialog( this, "C" + oacute + "digo", portuguesa ? selectedPortuguesa.getCodigo() : selectedInternacional.getCodigo() ); + } + return result; + } + + private boolean isValidCodigo( String codigo ) + { + boolean result = false; + if( codigo != null ) + { + result = true; + } + return result; + } + + private void criarPortuguesa() + { + try + { + String codigo = getCodigoForNormalizacao(true,true); + if( isValidCodigo(codigo) ) + { + HsNormalizacao normalizacao = new HsNormalizacao(); + normalizacao.setDescricao( "" ); + normalizacao.setCodigo( codigo ); + normalizacao.setPortuguesa( true ); + normalizacao.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + private void editarPortuguesa() + { + try + { + if( selectedPortuguesa != null ) + { + String codigo = getCodigoForNormalizacao(false, true); + if( isValidCodigo(codigo) ) + { + selectedPortuguesa.setCodigo( codigo ); + selectedPortuguesa.save(); + reload(); + } + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + private void removerPortuguesa() + { + try + { + if( selectedPortuguesa != null ) + { + selectedPortuguesa.setDeletedDate( new Date() ); + selectedPortuguesa.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + private void criarInternacional() + { + try + { + String codigo = getCodigoForNormalizacao(true, false); + if( isValidCodigo(codigo) ) + { + HsNormalizacao normalizacao = new HsNormalizacao(); + normalizacao.setDescricao( "" ); + normalizacao.setCodigo( codigo ); + normalizacao.setPortuguesa( false ); + normalizacao.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + private void editarInternacional() + { + try + { + if( selectedInternacional != null ) + { + String codigo = getCodigoForNormalizacao(false, false); + if( isValidCodigo(codigo) ) + { + selectedInternacional.setCodigo( codigo ); + selectedInternacional.save(); + reload(); + } + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + private void removerInternacional() + { + try + { + if( selectedInternacional != null ) + { + selectedInternacional.setDeletedDate( new Date() ); + selectedInternacional.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + + + private void reload() + { + rootPortuguesa.removeAllChildren(); + rootInternacional.removeAllChildren(); + textCodigo.setText( "" ); + TreeTools.merge( rootPortuguesa, HigieneSegurancaLogic.getNormalizacao( true ) ); + TreeTools.merge( rootInternacional, HigieneSegurancaLogic.getNormalizacao( false ) ); + TreeTools.refreshTree( treePortuguesa, rootPortuguesa ); + TreeTools.refreshTree( treeInternacional, rootInternacional ); + } + + private void refreshData() + { + buttonInternacionalRemover.setEnabled( false ); + buttonPortuguesaRemover.setEnabled( false ); + buttonInternacionalEditar.setEnabled( false ); + buttonPortuguesaEditar.setEnabled( false ); + textDescricao.setEnabled( false ); + if( selectedInternacional != null ) + { + textDescricao.setValue( selectedInternacional.getDescricao() ); + textDescricao.setEnabled( true ); + textCodigo.setText( selectedInternacional.getCodigo() ); + } + else if( selectedPortuguesa != null ) + { + textDescricao.setValue( selectedPortuguesa.getDescricao() ); + textDescricao.setEnabled( true ); + textCodigo.setText( selectedPortuguesa.getCodigo() ); + } + else + { + textDescricao.setValue( null ); + textCodigo.setText( "" ); + } + } + + private void setEnable() + { + buttonPortuguesaEditar.setEnabled( selectedPortuguesa != null ); + buttonPortuguesaRemover.setEnabled( selectedPortuguesa != null ); + buttonInternacionalEditar.setEnabled( selectedInternacional != null ); + buttonInternacionalRemover.setEnabled( selectedInternacional != null ); + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java index b99dd356..609c0602 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java @@ -130,7 +130,7 @@ public class AdicionarAreasPanel extends JPanel { DefaultMutableTreeNode allPostos = HigieneSegurancaLogic.getAreasTree( estabelecimento.getToEmpresas() ); TreeTools.removeAll( allPostos, HigieneSegurancaLogic.getPostosTree( estabelecimento ) ); - TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Postos de Trabalho", allPostos ); + TreeInserterDialog dialog = new TreeInserterDialog( this, "Adicionar Postos de Trabalho", allPostos ); save( dialog.getResult() ); refresh(); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java index 2e7c8b2a..e67d7671 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java @@ -36,31 +36,35 @@ import siprp.logic.node.PostoNode; public class GerirAreasPanel extends JPanel { - + private static final long serialVersionUID = 1L; - + private final JPanel panelButtons = new JPanel(); - + private final JPanel panelTree = new JPanel(); - + public final LeafButton buttonAreaCriar = new LeafButton( "Criar" ); - + + public final LeafButton buttonAreaEditar = new LeafButton( "Editar" ); + public final LeafButton buttonAreaRemover = new LeafButton( "Remover" ); - + public final LeafButton buttonPostoCriar = new LeafButton( "Criar" ); - + + public final LeafButton buttonPostoEditar = new LeafButton( "Editar" ); + public final LeafButton buttonPostoRemover = new LeafButton( "Remover" ); - + private final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); - + private final DefaultTreeModel model = new DefaultTreeModel( root ); - + public final JTree tree = new JTree( model ); - + private final JScrollPane scroll = new JScrollPane( tree ); - + private Empresas empresa = null; - + public GerirAreasPanel() { startupComponents(); @@ -69,7 +73,6 @@ public class GerirAreasPanel extends JPanel setupListeners(); } - private void startupComponents() { panelButtons.setPreferredSize( new Dimension( 150, 0 ) ); @@ -77,59 +80,65 @@ public class GerirAreasPanel extends JPanel tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } - + private void startupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM, TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM, TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM } - ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panelButtons.setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.FILL }, - new double[]{ TableLayout.FILL } - ); + + layout = new TableLayout( new double[] { + TableLayout.FILL + }, new double[] { + TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panelTree.setLayout( layout ); } - + private void placeComponents() { JPanel panel = new JPanel(); panel.setBorder( BorderFactory.createTitledBorder( "Area" ) ); - panel.setLayout( new GridLayout( 2, 1 ) ); + panel.setLayout( new GridLayout( 3, 1 ) ); panel.add( buttonAreaCriar ); + panel.add( buttonAreaEditar ); panel.add( buttonAreaRemover ); panelButtons.add( panel, new TableLayoutConstraints( 0, 0 ) ); - + panel = new JPanel(); panel.setBorder( BorderFactory.createTitledBorder( "Posto" ) ); - panel.setLayout( new GridLayout( 2, 1 ) ); + panel.setLayout( new GridLayout( 3, 1 ) ); panel.add( buttonPostoCriar ); + panel.add( buttonPostoEditar ); panel.add( buttonPostoRemover ); - panelButtons.add( panel, new TableLayoutConstraints( 2, 0 ) ); - - panelTree.add( scroll, new TableLayoutConstraints( 0,0 ) ); - + panelButtons.add( panel, new TableLayoutConstraints( 1, 0 ) ); + + panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) ); + add( panelButtons, new TableLayoutConstraints( 0, 0 ) ); add( panelTree, new TableLayoutConstraints( 0, 1 ) ); } - + private void setupListeners() { - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { @@ -144,6 +153,14 @@ public class GerirAreasPanel extends JPanel criarArea(); } } ); + buttonAreaEditar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + editarArea(); + } + } ); buttonAreaRemover.addActionListener( new ActionListener() { @Override @@ -160,6 +177,14 @@ public class GerirAreasPanel extends JPanel criarPosto(); } } ); + buttonPostoEditar.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + editarPosto(); + } + } ); buttonPostoRemover.addActionListener( new ActionListener() { @Override @@ -169,7 +194,7 @@ public class GerirAreasPanel extends JPanel } } ); } - + private void criarArea() { try @@ -188,10 +213,31 @@ public class GerirAreasPanel extends JPanel } } catch( Exception e ) { - LeafError.error(e); + LeafError.error( e ); } } - + + private void editarArea() + { + try + { + HsArea area = getSelectedArea(); + if( area != null ) + { + String areaString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", area.getDescription() ); + if( areaString != null ) + { + area.setDescription( areaString ); + area.save(); + refresh(); + } + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + private void removerArea() { try @@ -204,10 +250,10 @@ public class GerirAreasPanel extends JPanel } } catch( Exception e ) { - LeafError.error(e); + LeafError.error( e ); } } - + private void criarPosto() { try @@ -228,10 +274,31 @@ public class GerirAreasPanel extends JPanel } } catch( Exception e ) { - LeafError.error(e); + LeafError.error( e ); } } + private void editarPosto() + { + try + { + HsPosto posto = getSelectedPosto(); + if( posto != null ) + { + String postoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", posto.getDescription() ); + if( postoString != null ) + { + posto.setDescription( postoString ); + posto.save(); + refresh(); + } + } + } catch( Exception e ) + { + LeafError.error( e ); + } + } + private void removerPosto() { try @@ -245,10 +312,10 @@ public class GerirAreasPanel extends JPanel } } catch( Exception e ) { - LeafError.error(e); + LeafError.error( e ); } } - + private HsArea getSelectedArea() { HsArea result = null; @@ -258,19 +325,19 @@ public class GerirAreasPanel extends JPanel Object leaf = path.getLastPathComponent(); if( leaf != null ) { - if(leaf instanceof AreaNode) + if( leaf instanceof AreaNode ) { - result = (HsArea) ((AreaNode)leaf).getUserObject(); + result = (HsArea) ((AreaNode) leaf).getUserObject(); } - else if(leaf instanceof PostoNode) + else if( leaf instanceof PostoNode ) { - result = (HsArea) ((HsPosto)((PostoNode)leaf).getUserObject()).getToHsArea(); + result = (HsArea) ((HsPosto) ((PostoNode) leaf).getUserObject()).getToHsArea(); } } } return result; } - + private HsPosto getSelectedPosto() { HsPosto result = null; @@ -278,54 +345,55 @@ public class GerirAreasPanel extends JPanel if( path != null ) { Object leaf = path.getLastPathComponent(); - if( leaf != null && ( leaf instanceof PostoNode ) ) + if( leaf != null && (leaf instanceof PostoNode) ) { - result = (HsPosto) ((PostoNode)leaf).getUserObject(); + result = (HsPosto) ((PostoNode) leaf).getUserObject(); } } return result; } - - + private void setEnabled() { TreePath path = tree.getSelectionPath(); TreeNode node = path == null ? null : (TreeNode) path.getLastPathComponent(); - boolean areaSelected = node != null && ( node instanceof AreaNode ); - boolean postoSelected = node != null && ( node instanceof PostoNode ); + boolean areaSelected = node != null && (node instanceof AreaNode); + boolean postoSelected = node != null && (node instanceof PostoNode); buttonPostoCriar.setEnabled( areaSelected || postoSelected ); + buttonPostoEditar.setEnabled( postoSelected ); buttonPostoRemover.setEnabled( postoSelected ); buttonAreaRemover.setEnabled( areaSelected ); buttonAreaCriar.setEnabled( empresa != null ); + buttonAreaEditar.setEnabled( areaSelected ); } - + public void refresh() { root.removeAllChildren(); if( empresa != null ) { - for( HsArea area : empresa.getHsAreaArray()) + for( HsArea area : empresa.getHsAreaArray() ) { addArea( area ); } } setEnabled(); - TreeTools.refreshTree(tree, root); + TreeTools.refreshTree( tree, root ); } - + private void addArea( HsArea area ) { if( area != null ) { AreaNode areaNode = new AreaNode( area ); - for ( HsPosto posto : area.getHsPostoArray() ) + for( HsPosto posto : area.getHsPostoArray() ) { addPosto( posto, areaNode ); } root.add( areaNode ); } } - + private void addPosto( HsPosto posto, AreaNode areaNode ) { if( posto != null && posto.getDeletedDate() == null ) @@ -340,5 +408,5 @@ public class GerirAreasPanel extends JPanel this.empresa = empresa; refresh(); } - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java index 7b274cdd..d95803f6 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java @@ -136,7 +136,7 @@ public class AdicionarRiscosPanel extends JPanel { DefaultMutableTreeNode allRiscos = getAllRiscos(); TreeTools.removeAll( allRiscos, getRiscosTree() ); - TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Riscos", allRiscos ); + TreeInserterDialog dialog = new TreeInserterDialog( this, "Adicionar Riscos", allRiscos ); DefaultMutableTreeNode result = dialog.getResult(); if( result != null ) { diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index d4e939e4..c4a758a7 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -20,6 +20,7 @@ import siprp.database.cayenne.objects.HsMedida; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; +import com.evolute.utils.ui.text.CopyPasteHandler; public class GerirMedidaPanel extends JPanel { @@ -66,8 +67,10 @@ public class GerirMedidaPanel extends JPanel { fieldTextMedida.setWrapStyleWord( true ); fieldTextMedida.setLineWrap( true ); + new CopyPasteHandler(fieldTextMedida); fieldTextRequisitosLegais.setWrapStyleWord( true ); fieldTextRequisitosLegais.setLineWrap( true ); + new CopyPasteHandler(fieldTextRequisitosLegais); scrollMedida.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index 5df78db1..33c598a0 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -405,7 +405,7 @@ public class GerirRiscosPanel extends JPanel private void startupComponents() { panelButtons.setPreferredSize( new Dimension( 150, 0 ) ); - panelTree.setPreferredSize( new Dimension( 300, 0 ) ); + panelTree.setPreferredSize( new Dimension( 400, 0 ) ); tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 7b9a6652..e0746c28 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -6,7 +6,6 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; import static com.evolute.utils.strings.UnicodeLatin1Map.iacute; import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; -import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -59,11 +58,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private final JTextField fieldNome1 = new JTextField(); private final JTextField fieldNome2 = new JTextField(); - private final JTextField fieldNome3 = new JTextField(); +// private final JTextField fieldNome3 = new JTextField(); private final JTextField fieldFuncao1 = new JTextField(); private final JTextField fieldFuncao2 = new JTextField(); - private final JTextField fieldFuncao3 = new JTextField(); +// private final JTextField fieldFuncao3 = new JTextField(); private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); private final LeafIconButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); @@ -92,20 +91,20 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private void startupComponents() { dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) ); - panelEquipamentos.setPreferredSize( new Dimension( 200, 0 ) ); + panelEquipamentos.setPreferredSize( new Dimension( 400, 0 ) ); fieldFuncao1.setPreferredSize( new Dimension( 100, 0 ) ); 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 + otilde + "es", panelLegislacao ); + tabs.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); } private void startupLayout() { TableLayout layout = new TableLayout( new double[] { - TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED }, new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } ); @@ -116,7 +115,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe layout = new TableLayout( new double[] { TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.PREFERRED }, new double[] { - TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM + TableLayout.MINIMUM, TableLayout.MINIMUM/*, TableLayout.MINIMUM*/ } ); layout.setVGap( 5 ); layout.setHGap( 5 ); @@ -133,10 +132,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe panelAcompanhantes.add( fieldNome2, new TableLayoutConstraints( 1, 1 ) ); panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 1 ) ); panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) ); - panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) ); - panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) ); - panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) ); - panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) ); +// panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 2 ) ); +// panelAcompanhantes.add( fieldNome3, new TableLayoutConstraints( 1, 2 ) ); +// panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 2 ) ); +// panelAcompanhantes.add( fieldFuncao3, new TableLayoutConstraints( 3, 2 ) ); TableLayout layout = new TableLayout( new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM @@ -155,10 +154,12 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) ); add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) ); add( dataRelatorio, new TableLayoutConstraints( 3, 1 ) ); - add( new JLabel( "Avalia" + ccedil + atilde + "o" ), new TableLayoutConstraints( 4, 1 ) ); + JLabel labelAvaliacao = new JLabel( "Avalia" + ccedil + atilde + "o" ); + labelAvaliacao.setHorizontalAlignment( JLabel.RIGHT ); + add( labelAvaliacao , new TableLayoutConstraints( 4, 1 ) ); add( radioInicial, new TableLayoutConstraints( 5, 1 ) ); add( radioPeriodica, new TableLayoutConstraints( 6, 1 ) ); - add( new JLabel( "T" + eacute + "cnico de H.S." ), new TableLayoutConstraints( 0, 2, 2, 2 ) ); + 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( panelAcompanhantes, new TableLayoutConstraints( 0, 3, 6, 3 ) ); @@ -169,10 +170,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe { fieldFuncao1.addCaretListener( this ); fieldFuncao2.addCaretListener( this ); - fieldFuncao3.addCaretListener( this ); +// fieldFuncao3.addCaretListener( this ); fieldNome1.addCaretListener( this ); fieldNome2.addCaretListener( this ); - fieldNome3.addCaretListener( this ); +// fieldNome3.addCaretListener( this ); dataRelatorio.addChangeListener( this ); radioInicial.addActionListener( this ); radioPeriodica.addActionListener( this ); @@ -258,11 +259,11 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe } relatorio.setAcompanhante1( fieldNome1.getText() ); relatorio.setAcompanhante2( fieldNome2.getText() ); - relatorio.setAcompanhante3( fieldNome3.getText() ); +// relatorio.setAcompanhante3( fieldNome3.getText() ); relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText()); relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); - relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText()); +// relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText()); relatorio.save(); refresh(); buttonRevert.setEnabled( false ); @@ -308,10 +309,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe fieldTecnico.setText( tecnicoName ); fieldNome1.setText( relatorio == null ? null : relatorio.getAcompanhante1() ); fieldNome2.setText( relatorio == null ? null : relatorio.getAcompanhante2() ); - fieldNome3.setText( relatorio == null ? null : relatorio.getAcompanhante3() ); +// fieldNome3.setText( relatorio == null ? null : relatorio.getAcompanhante3() ); fieldFuncao1.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante1() ); fieldFuncao2.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante2() ); - fieldFuncao3.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante3() ); +// fieldFuncao3.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante3() ); } private void setEnabled() @@ -323,10 +324,10 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe fieldTecnico.setEnabled( false ); fieldNome1.setEnabled( enabled ); fieldNome2.setEnabled( enabled ); - fieldNome3.setEnabled( enabled ); +// fieldNome3.setEnabled( enabled ); fieldFuncao1.setEnabled( enabled ); fieldFuncao2.setEnabled( enabled ); - fieldFuncao3.setEnabled( enabled ); +// fieldFuncao3.setEnabled( enabled ); buttonSubmit.setEnabled( enabled ); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java index 30382b8a..17876dfd 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PlanoActuacaoPanel.java @@ -7,6 +7,7 @@ import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.CardLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -149,13 +150,14 @@ public class PlanoActuacaoPanel extends JPanel { riscos.setBorder( BorderFactory.createTitledBorder( "Medidas" ) ); areas.setBorder( BorderFactory.createTitledBorder( "Postos de trabalho" ) ); + areas.setPreferredSize( new Dimension(250,0) ); buttonRevert.setToolTipText( "Carregar dados do estabelecimento" ); } private void startupLayout() { TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL }, + new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.FILL }, new double[]{ TableLayout.MINIMUM, TableLayout.FILL } ); layout.setHGap( 5 ); diff --git a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java index 0c8c7fcf..749aa1ca 100644 --- a/trunk/SIPRPSoft/src/siprp/update/UpdateList.java +++ b/trunk/SIPRPSoft/src/siprp/update/UpdateList.java @@ -9,12 +9,27 @@ package siprp.update; -import java.util.*; +import java.util.Vector; -import com.evolute.utils.*; -import com.evolute.utils.arrays.*; -import com.evolute.utils.db.*; -import com.evolute.utils.sql.*; +import siprp.update.updates.V10_0_To_V10_1; +import siprp.update.updates.V9_1_To_V9_2; +import siprp.update.updates.V9_2_To_V9_3; +import siprp.update.updates.V9_3_To_V9_4; +import siprp.update.updates.V9_4_To_V9_5; +import siprp.update.updates.V9_5_To_V9_6; +import siprp.update.updates.V9_6_To_V9_7; +import siprp.update.updates.V9_7_To_V9_8; +import siprp.update.updates.V9_8_To_V9_9; +import siprp.update.updates.V9_9_To_V10_0; + +import com.evolute.utils.Singleton; +import com.evolute.utils.arrays.Virtual2DArray; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; +import com.evolute.utils.sql.Assignment; +import com.evolute.utils.sql.Field; +import com.evolute.utils.sql.Insert; +import com.evolute.utils.sql.Select; /** @@ -25,21 +40,21 @@ public class UpdateList { protected static final Update UPDATE_LIST[] = new Update[]{ -// new siprp.update.updates.V6_1_To_V7_0(), new siprp.update.updates.V7_0_To_V7_2(), -// new siprp.update.updates.V7_2_To_V7_4(), new siprp.update.updates.V7_4_To_V7_5(), -// new siprp.update.updates.V7_5_To_V7_6(), new siprp.update.updates.V7_6_To_V7_7(), -// new siprp.update.updates.V7_7_To_V7_8(), new siprp.update.updates.V7_8_To_V7_9(), -// new siprp.update.updates.V7_9_To_V8_0(), new siprp.update.updates.V8_0_To_V8_1(), -// new siprp.update.updates.V8_1_To_V8_2(), new siprp.update.updates.V8_2_To_V8_3(), -// new siprp.update.updates.V8_3_To_V8_4(), new siprp.update.updates.V8_4_To_V8_5(), -// new siprp.update.updates.V8_5_To_V8_6(), new siprp.update.updates.V8_6_To_V8_7(), -// new siprp.update.updates.V8_7_To_V8_8(), new siprp.update.updates.V8_8_To_V8_9(), -// new siprp.update.updates.V8_9_To_V9_0(), new siprp.update.updates.V9_0_To_V9_1(), - new siprp.update.updates.V9_1_To_V9_2(), new siprp.update.updates.V9_2_To_V9_3(), - new siprp.update.updates.V9_3_To_V9_4(), new siprp.update.updates.V9_4_To_V9_5(), - new siprp.update.updates.V9_5_To_V9_6(), new siprp.update.updates.V9_6_To_V9_7(), - new siprp.update.updates.V9_7_To_V9_8(), new siprp.update.updates.V9_8_To_V9_9(), - new siprp.update.updates.V9_9_To_V10_0() }; +// new V6_1_To_V7_0(), new V7_0_To_V7_2(), +// new V7_2_To_V7_4(), new V7_4_To_V7_5(), +// new V7_5_To_V7_6(), new V7_6_To_V7_7(), +// new V7_7_To_V7_8(), new V7_8_To_V7_9(), +// new V7_9_To_V8_0(), new V8_0_To_V8_1(), +// new V8_1_To_V8_2(), new V8_2_To_V8_3(), +// new V8_3_To_V8_4(), new V8_4_To_V8_5(), +// new V8_5_To_V8_6(), new V8_6_To_V8_7(), +// new V8_7_To_V8_8(), new V8_8_To_V8_9(), +// new V8_9_To_V9_0(), new V9_0_To_V9_1(), + new V9_1_To_V9_2(), new V9_2_To_V9_3(), + new V9_3_To_V9_4(), new V9_4_To_V9_5(), + new V9_5_To_V9_6(), new V9_6_To_V9_7(), + new V9_7_To_V9_8(), new V9_8_To_V9_9(), + new V9_9_To_V10_0(), new V10_0_To_V10_1() }; protected static Executer EXECUTER; protected static double version = -1; diff --git a/trunk/SIPRPSoft/src/siprp/update/updates/V10_0_To_V10_1.java b/trunk/SIPRPSoft/src/siprp/update/updates/V10_0_To_V10_1.java new file mode 100644 index 00000000..8cf9b7ea --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/update/updates/V10_0_To_V10_1.java @@ -0,0 +1,59 @@ +package siprp.update.updates; + +import com.evolute.utils.Singleton; +import com.evolute.utils.db.DBManager; +import com.evolute.utils.db.Executer; + +public class V10_0_To_V10_1 + implements siprp.update.Update +{ + + public V10_0_To_V10_1() + { + } + + public String []listChanges() + { + return new String[]{ + "adicionadas normalizacoes para estabelecimentos e empresas" + }; + } + + public double getStartVersion() + { + return 10.0; + } + + public double getEndVersion() + { + return 10.1; + } + + 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( + "CREATE TABLE hs_normalizacao_empresa " + + "( " + + " normalizacao_id int4 REFERENCES hs_normalizacao(id), " + + " empresa_id int4 REFERENCES empresas(id), " + + " CONSTRAINT hs_normalizacao_empresa_pkey PRIMARY KEY(normalizacao_id,empresa_id) " + + "); " + + "CREATE TABLE hs_normalizacao_estabelecimento " + + "( " + + " normalizacao_id int4 REFERENCES hs_normalizacao(id), " + + " estabelecimento_id int4 REFERENCES estabelecimentos(id), " + + " CONSTRAINT hs_normalizacao_estabelecimento_pkey PRIMARY KEY(normalizacao_id,estabelecimento_id) " + + ");" + ); + executer.executeQuery( update ); + } + + public String toString() + { + return "v" + getStartVersion() + " para v" + getEndVersion(); + } +} diff --git a/trunk/common/src/SIPRPMap.map.xml b/trunk/common/src/SIPRPMap.map.xml index bdcf4f96..98f43a11 100644 --- a/trunk/common/src/SIPRPMap.map.xml +++ b/trunk/common/src/SIPRPMap.map.xml @@ -269,6 +269,14 @@ 1 + + + + + + + + @@ -933,6 +941,10 @@ + + + + @@ -1235,6 +1247,9 @@ + + + @@ -1268,6 +1283,9 @@ + + + @@ -1358,6 +1376,24 @@ + + + + + + + + + + + + + + + + + + @@ -1825,6 +1861,10 @@ + + + + diff --git a/trunk/common/src/leaf/ui/LeafTextAreaEditor.java b/trunk/common/src/leaf/ui/LeafTextAreaEditor.java index 9803227b..b1edc9c4 100644 --- a/trunk/common/src/leaf/ui/LeafTextAreaEditor.java +++ b/trunk/common/src/leaf/ui/LeafTextAreaEditor.java @@ -13,6 +13,8 @@ import javax.swing.JTextArea; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; +import com.evolute.utils.ui.text.CopyPasteHandler; + import leaf.data.Validator; public class LeafTextAreaEditor extends JPanel @@ -61,6 +63,7 @@ public class LeafTextAreaEditor extends JPanel { fieldText.setWrapStyleWord( true ); fieldText.setLineWrap( true ); + new CopyPasteHandler(fieldText); scroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); buttonSave.setMargin( new Insets(0,0,0,0) ); diff --git a/trunk/common/src/leaf/ui/TreeInserterDialog.java b/trunk/common/src/leaf/ui/TreeInserterDialog.java index 64e8d6b3..5ec1982e 100644 --- a/trunk/common/src/leaf/ui/TreeInserterDialog.java +++ b/trunk/common/src/leaf/ui/TreeInserterDialog.java @@ -3,6 +3,7 @@ package leaf.ui; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Component; import java.awt.Dimension; import java.awt.Insets; import java.awt.event.ActionEvent; @@ -61,7 +62,7 @@ public class TreeInserterDialog extends JDialog private final LeafButton buttonCancel = new LeafButton( "Cancelar" ); - public TreeInserterDialog( String title, DefaultMutableTreeNode root ) + public TreeInserterDialog( Component relativeTo, String title, DefaultMutableTreeNode root ) { this.allRoot = root; this.allModel = new DefaultTreeModel( allRoot ); @@ -82,7 +83,7 @@ public class TreeInserterDialog extends JDialog startupListeners(); TreeTools.refreshTree(allTree, allRoot); setEnabled(); - this.setLocationRelativeTo( null ); + this.setLocationRelativeTo( relativeTo ); this.setSize( 680, 400 ); this.setModal( true ); this.setVisible( true ); @@ -91,9 +92,9 @@ public class TreeInserterDialog extends JDialog private void startupComponents() { newTree.setRootVisible( false ); - newTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); + newTree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION ); allTree.setRootVisible( false ); - allTree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); + allTree.getSelectionModel().setSelectionMode( TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); allScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); allScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); newScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); @@ -181,32 +182,35 @@ public class TreeInserterDialog extends JDialog private void move( JTree from, JTree to ) { - TreePath path = from.getSelectionPath(); - DefaultMutableTreeNode fromRoot = (DefaultMutableTreeNode) from.getModel().getRoot(); - DefaultMutableTreeNode toRoot = (DefaultMutableTreeNode) to.getModel().getRoot(); - if( path != null ) + TreePath [] paths = from.getSelectionPaths(); + if( paths != null ) { - for( int i = 1; i < path.getPathCount(); ++i ) + DefaultMutableTreeNode fromRoot = (DefaultMutableTreeNode) from.getModel().getRoot(); + DefaultMutableTreeNode toRoot = (DefaultMutableTreeNode) to.getModel().getRoot(); + for( TreePath path : paths ) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent( i ); - DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getPathComponent( i-1 ); - if( node != null && parent != null ) + for( int i = 1; i < path.getPathCount(); ++i ) { - DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( node.getUserObject(), toRoot ); - if( exists == null ) + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getPathComponent( i ); + DefaultMutableTreeNode parent = (DefaultMutableTreeNode) path.getPathComponent( i-1 ); + if( node != null && parent != null ) { - add(node, parent.getUserObject(), toRoot, path.getPathCount() == i + 1 ); - } - else - { - TreeTools.merge( exists, node ); + DefaultMutableTreeNode exists = TreeTools.findNodeWithUserObject( node.getUserObject(), toRoot ); + if( exists == null ) + { + add(node, parent.getUserObject(), toRoot, path.getPathCount() == i + 1 ); + } + else if( i + 1 == path.getPathCount() ) + { + TreeTools.merge( exists, node ); + } } } + removeNode( (DefaultMutableTreeNode) path.getLastPathComponent(), fromRoot ); } - removeNode( (DefaultMutableTreeNode) path.getLastPathComponent(), fromRoot ); + TreeTools.refreshTree( from, fromRoot ); + TreeTools.refreshTree( to, toRoot ); } - TreeTools.refreshTree( from, fromRoot ); - TreeTools.refreshTree( to, toRoot ); } private void removeNode( DefaultMutableTreeNode node, DefaultMutableTreeNode root ) diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacao.java b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacao.java index a7d873bf..d81579b8 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacao.java +++ b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacao.java @@ -3,5 +3,29 @@ package siprp.database.cayenne.objects; import siprp.database.cayenne.objects.auto._HsNormalizacao; public class HsNormalizacao extends _HsNormalizacao { + + private static final long serialVersionUID = 1L; + + private static final int TO_STRING_LENGTH = 58; + @Override + public String getDescricao() + { + return parseFromUnicode( super.getDescricao() ); + } + + @Override + public void setDescricao( String nome ) + { + super.setDescricao( parseToUnicode( nome ) ); + } + + @Override + public String toString() + { + String codigo = getCodigo(); + String descricao = getDescricao() == null ? "" : getDescricao().replaceAll( "\n", " " ); + return (codigo == null ? "" : codigo ) + ": " + ( descricao.substring( 0, Math.min( TO_STRING_LENGTH, descricao.length() ) ) + ( TO_STRING_LENGTH < descricao.length() ? "..." : "" ) ); + } + } diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEmpresa.java b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEmpresa.java new file mode 100644 index 00000000..ad8e7131 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEmpresa.java @@ -0,0 +1,7 @@ +package siprp.database.cayenne.objects; + +import siprp.database.cayenne.objects.auto._HsNormalizacaoEmpresa; + +public class HsNormalizacaoEmpresa extends _HsNormalizacaoEmpresa { + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEstabelecimento.java b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEstabelecimento.java new file mode 100644 index 00000000..68e72ee2 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/HsNormalizacaoEstabelecimento.java @@ -0,0 +1,7 @@ +package siprp.database.cayenne.objects; + +import siprp.database.cayenne.objects.auto._HsNormalizacaoEstabelecimento; + +public class HsNormalizacaoEstabelecimento extends _HsNormalizacaoEstabelecimento { + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java b/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java index af4535e1..3255dbdf 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java +++ b/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java @@ -9,6 +9,6 @@ public class HsRiscoMedida extends _HsRiscoMedida { public String toString() { String d = getToHsMedida() == null ? null : getToHsMedida().getRequesitosLegais(); - return d == null ? " " : d.substring( 0, Math.min( 20, d.length() ) ) + "..."; + return d == null ? " " : d.substring( 0, Math.min( 40, d.length() ) ) + "..."; } } diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEmpresa.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEmpresa.java new file mode 100644 index 00000000..cd517508 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEmpresa.java @@ -0,0 +1,39 @@ +package siprp.database.cayenne.objects.auto; + +import siprp.database.cayenne.objects.BaseObject; +import siprp.database.cayenne.objects.Empresas; +import siprp.database.cayenne.objects.HsNormalizacao; + +/** + * Class _HsNormalizacaoEmpresa was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _HsNormalizacaoEmpresa extends BaseObject { + + public static final String TO_EMPRESA_PROPERTY = "toEmpresa"; + public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao"; + + public static final String EMPRESA_ID_PK_COLUMN = "empresa_id"; + public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id"; + + public void setToEmpresa(Empresas toEmpresa) { + setToOneTarget("toEmpresa", toEmpresa, true); + } + + public Empresas getToEmpresa() { + return (Empresas)readProperty("toEmpresa"); + } + + + public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) { + setToOneTarget("toHsNormalizacao", toHsNormalizacao, true); + } + + public HsNormalizacao getToHsNormalizacao() { + return (HsNormalizacao)readProperty("toHsNormalizacao"); + } + + +} diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEstabelecimento.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEstabelecimento.java new file mode 100644 index 00000000..39647746 --- /dev/null +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsNormalizacaoEstabelecimento.java @@ -0,0 +1,39 @@ +package siprp.database.cayenne.objects.auto; + +import siprp.database.cayenne.objects.BaseObject; +import siprp.database.cayenne.objects.Estabelecimentos; +import siprp.database.cayenne.objects.HsNormalizacao; + +/** + * Class _HsNormalizacaoEstabelecimento was generated by Cayenne. + * It is probably a good idea to avoid changing this class manually, + * since it may be overwritten next time code is regenerated. + * If you need to make any customizations, please use subclass. + */ +public abstract class _HsNormalizacaoEstabelecimento extends BaseObject { + + public static final String TO_ESTABELECIMENTO_PROPERTY = "toEstabelecimento"; + public static final String TO_HS_NORMALIZACAO_PROPERTY = "toHsNormalizacao"; + + public static final String ESTABELECIMENTO_ID_PK_COLUMN = "estabelecimento_id"; + public static final String NORMALIZACAO_ID_PK_COLUMN = "normalizacao_id"; + + public void setToEstabelecimento(Estabelecimentos toEstabelecimento) { + setToOneTarget("toEstabelecimento", toEstabelecimento, true); + } + + public Estabelecimentos getToEstabelecimento() { + return (Estabelecimentos)readProperty("toEstabelecimento"); + } + + + public void setToHsNormalizacao(HsNormalizacao toHsNormalizacao) { + setToOneTarget("toHsNormalizacao", toHsNormalizacao, true); + } + + public HsNormalizacao getToHsNormalizacao() { + return (HsNormalizacao)readProperty("toHsNormalizacao"); + } + + +} diff --git a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java index 4f95c427..7afca4f9 100644 --- a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java +++ b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java @@ -12,6 +12,7 @@ import siprp.database.cayenne.objects.EmailPlanoDeActuacao; import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsLegislacao; import siprp.database.cayenne.objects.HsLegislacaoCategoria; +import siprp.database.cayenne.objects.HsNormalizacao; import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPostoRisco; import siprp.database.cayenne.objects.HsRelatorio; @@ -324,4 +325,13 @@ public class PlanoActuacaoDAO extends MainDAO return context.performQuery( query ); } + public List getNormalizacao( boolean portuguesa ) + { + SelectQuery query = new SelectQuery( HsNormalizacao.class ); + query.andQualifier( ExpressionFactory.matchExp( HsNormalizacao.DELETED_DATE_PROPERTY, null ) ); + query.andQualifier( ExpressionFactory.matchExp( HsNormalizacao.PORTUGUESA_PROPERTY, portuguesa ) ); + query.addOrdering( HsNormalizacao.CODIGO_PROPERTY, true ); + return context.performQuery( query ); + } + } diff --git a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java index d63f3eb6..88f043dd 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -12,6 +12,7 @@ import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsArea; import siprp.database.cayenne.objects.HsLegislacao; import siprp.database.cayenne.objects.HsLegislacaoCategoria; +import siprp.database.cayenne.objects.HsNormalizacao; import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPostoEstabelecimento; import siprp.database.cayenne.objects.HsPostoRisco; @@ -289,5 +290,16 @@ public class HigieneSegurancaLogic } return result; } + + public static DefaultMutableTreeNode getNormalizacao( boolean portuguesa ) + { + DefaultMutableTreeNode result = new DefaultMutableTreeNode(); + for( HsNormalizacao normalizacao : planoProvider.getNormalizacao( portuguesa ) ) + { + DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao ); + result.add( normalizacaoNode ); + } + return result; + } }