From 672ab008b827113821aacaba7d7d737df0647af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Mon, 5 Jan 2009 21:29:22 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@885 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../AdicionarEquipamentosPanel.java | 115 +++--- .../legislacao/GerirLegislacaoPanel.java | 164 +++++--- .../gestao/postos/AdicionarAreasPanel.java | 126 ++++--- .../gestao/postos/GerirAreasPanel.java | 77 ++-- .../gestao/riscos/AdicionarRiscosPanel.java | 135 ++++--- .../gestao/riscos/GerirMedidaPanel.java | 139 +++---- .../gestao/riscos/GerirRiscosPanel.java | 354 +++++++++++------- .../relatorio/GerirMedidaRelatorioPanel.java | 154 ++++---- .../relatorio/GerirMedidasRelatorioPanel.java | 166 ++++---- .../relatorio/GerirValoresRiscoPanel.java | 86 +++-- .../higiene/relatorio/PanelRelatorio.java | 69 ++-- .../RelatorioHigieneSegurancaWindow.java | 47 ++- .../exames/logic/RecepcaoExamesLogic.java | 57 +-- .../prestadores/PrestadoresWindow.java | 73 ++-- .../processo/logic/MedicinaProcessoLogic.java | 133 ++++--- trunk/common/src/SIPRPMap.map.xml | 1 + trunk/common/src/leaf/ui/LeafError.java | 20 + .../src/leaf/ui/TreeInserterDialog.java | 12 +- .../database/cayenne/objects/BaseObject.java | 29 +- .../cayenne/objects/HsRiscoMedida.java | 2 +- .../database/cayenne/objects/Prestadores.java | 5 +- .../cayenne/objects/auto/_HsRisco.java | 14 + .../database/cayenne/providers/MainDAO.java | 30 +- .../cayenne/providers/PlanoActuacaoDAO.java | 1 + .../siprp/logic/HigieneSegurancaLogic.java | 35 +- 25 files changed, 1158 insertions(+), 886 deletions(-) create mode 100644 trunk/common/src/leaf/ui/LeafError.java diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java index cc1041a7..009715de 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java @@ -2,7 +2,6 @@ package siprp.higiene.gestao.equipamentos; import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; -import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -21,6 +20,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.LeafIconButton; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsEquipamentoMedico; @@ -32,23 +32,23 @@ public class AdicionarEquipamentosPanel extends JPanel { private static final long serialVersionUID = 1L; - + public static final String SELECTION_CHANGED = "SELECTION_CHANGED"; - + private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/equipamentos/add.png"; - + private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/equipamentos/delete.png"; - + private final LeafButton buttonAdicionar = LeafIconButton.createButton( ICON_NAME_SAVE ); - + private final LeafButton buttonRemover = LeafIconButton.createButton( ICON_NAME_REVERT ); - + 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 HsRelatorio relatorio = null; @@ -60,7 +60,7 @@ public class AdicionarEquipamentosPanel extends JPanel placeComponents(); startupListeners(); } - + private void startupComponents() { buttonAdicionar.setEnabled( false ); @@ -70,46 +70,49 @@ public class AdicionarEquipamentosPanel extends JPanel tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } - + private void setupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL }, - new double[]{ TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL + }, new double[] { + TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); setLayout( layout ); } - + private void placeComponents() { JPanel panel = new JPanel(); - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); panel.add( buttonRemover, new TableLayoutConstraints( 0, 1 ) ); - + add( panel, new TableLayoutConstraints( 0, 0 ) ); add( scroll, new TableLayoutConstraints( 1, 0 ) ); } - + private void startupListeners() { - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { setEnabled(); TreePath path = tree.getSelectionPath(); Object object = path == null ? null : path.getLastPathComponent(); - HsRelatorioEquipamentoMedico rel = object == null ? null : ( (object instanceof HsRelatorioEquipamentoMedico) ? (HsRelatorioEquipamentoMedico) ((EquipamentoNode) object).getUserObject() : null); - firePropertyChange( SELECTION_CHANGED, null, rel == null ? null : rel.getToHsRelatorio() ); + HsRelatorioEquipamentoMedico rel = object == null ? null : ((object instanceof HsRelatorioEquipamentoMedico) ? (HsRelatorioEquipamentoMedico) ((EquipamentoNode) object).getUserObject() : null); + firePropertyChange( SELECTION_CHANGED, null, rel == null ? null : rel.getToHsRelatorio() ); } } ); buttonAdicionar.addActionListener( new ActionListener() @@ -129,47 +132,59 @@ public class AdicionarEquipamentosPanel extends JPanel } } ); } - + private void add() { - if( relatorio != null ) + try { - String equipamentoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo equipamento de medi" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); - if( equipamentoString != null ) + if( relatorio != null ) { - HsEquipamentoMedico equipamento = new HsEquipamentoMedico(); - equipamento.setNome( equipamentoString ); - equipamento.save(); - HsRelatorioEquipamentoMedico rel = new HsRelatorioEquipamentoMedico(); - rel.setToHsRelatorio( relatorio ); - rel.setToHsEquipamentoMedico( equipamento ); - rel.save(); - refresh(); + String equipamentoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo equipamento de medi" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); + if( equipamentoString != null ) + { + HsEquipamentoMedico equipamento = new HsEquipamentoMedico(); + equipamento.setNome( equipamentoString ); + equipamento.save(); + HsRelatorioEquipamentoMedico rel = new HsRelatorioEquipamentoMedico(); + rel.setToHsRelatorio( relatorio ); + rel.setToHsEquipamentoMedico( equipamento ); + rel.save(); + refresh(); + } } + } catch( Exception e ) + { + e.printStackTrace(); } } private void rem() { - TreePath path = tree.getSelectionPath(); - if( path != null ) + try { - Object object = path.getLastPathComponent(); - if( object instanceof EquipamentoNode ) + TreePath path = tree.getSelectionPath(); + if( path != null ) { - HsRelatorioEquipamentoMedico rel = ((HsRelatorioEquipamentoMedico)((EquipamentoNode) object).getUserObject()); - rel.delete(); + Object object = path.getLastPathComponent(); + if( object instanceof EquipamentoNode ) + { + HsRelatorioEquipamentoMedico rel = ((HsRelatorioEquipamentoMedico) ((EquipamentoNode) object).getUserObject()); + rel.delete(); + } } + refresh(); + } catch( Exception e ) + { + LeafError.error(e); } - refresh(); } - + private void setEnabled() { buttonAdicionar.setEnabled( relatorio != null && relatorio.getIsSubmetido() == null ); buttonRemover.setEnabled( tree.getSelectionCount() > 0 ); } - + public void refresh() { root.removeAllChildren(); @@ -177,19 +192,17 @@ public class AdicionarEquipamentosPanel extends JPanel { for( HsRelatorioEquipamentoMedico rel : relatorio.getHsRelatorioEquipamentoMedicoArray() ) { - root.add( new EquipamentoNode(rel) ); + root.add( new EquipamentoNode( rel ) ); } } setEnabled(); TreeTools.refreshTree( tree, root ); } - public void setRelatorio( HsRelatorio relatorio ) { - this.relatorio = relatorio; + this.relatorio = relatorio; refresh(); } - } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java index 69375652..450da532 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java @@ -28,6 +28,7 @@ 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.HsLegislacao; @@ -64,25 +65,25 @@ public class GerirLegislacaoPanel extends JPanel private final LeafButton buttonCategoriasLegislacaoRemover = new LeafButton( "Remover" ); private final DefaultMutableTreeNode rootGeral = new DefaultMutableTreeNode(); - + private final DefaultTreeModel modelGeral = new DefaultTreeModel( rootGeral ); - + private final JTree treeGeral = new JTree( modelGeral ); private final JScrollPane scrollGeral = new JScrollPane( treeGeral ); private final DefaultMutableTreeNode rootCategorias = new DefaultMutableTreeNode(); - + private final DefaultTreeModel modelCategorias = new DefaultTreeModel( rootCategorias ); - - private final JTree treeCategorias = new JTree(modelCategorias); + + private final JTree treeCategorias = new JTree( modelCategorias ); private final JScrollPane scrollCategorias = new JScrollPane( treeCategorias ); - + private HsLegislacao selectedLegislacaoGeral = null; - + private HsLegislacao selectedLegislacaoEspecifica = null; - + private HsLegislacaoCategoria selectedCategoria = null; private final LeafTextAreaEditor panelData = new LeafTextAreaEditor( new Validator() @@ -111,7 +112,7 @@ public class GerirLegislacaoPanel extends JPanel panelCategorias.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + atilde + "o espec" + iacute + "fica" ) ); panelButtonsCategoriasCategoria.setBorder( BorderFactory.createTitledBorder( "Categoria" ) ); panelButtonsCategoriasLegislacao.setBorder( BorderFactory.createTitledBorder( "Legisla" + ccedil + atilde + "o" ) ); - + treeCategorias.setRootVisible( false ); treeGeral.setRootVisible( false ); treeCategorias.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); @@ -153,7 +154,6 @@ public class GerirLegislacaoPanel extends JPanel private void placeComponents() { - panelButtonsGeral.add( buttonGeralCriar ); panelButtonsGeral.add( buttonGeralRemover ); @@ -189,7 +189,7 @@ public class GerirLegislacaoPanel extends JPanel Object last = selectionPath.getLastPathComponent(); if( last instanceof DefaultMutableTreeNode ) { - Object userObject = ((DefaultMutableTreeNode)last).getUserObject(); + Object userObject = ((DefaultMutableTreeNode) last).getUserObject(); if( userObject instanceof HsLegislacao ) { selectedLegislacaoEspecifica = (HsLegislacao) userObject; @@ -222,7 +222,7 @@ public class GerirLegislacaoPanel extends JPanel Object last = selectionPath.getLastPathComponent(); if( last instanceof DefaultMutableTreeNode ) { - Object userObject = ((DefaultMutableTreeNode)last).getUserObject(); + Object userObject = ((DefaultMutableTreeNode) last).getUserObject(); if( userObject instanceof HsLegislacao ) { selectedLegislacaoGeral = (HsLegislacao) userObject; @@ -240,23 +240,29 @@ public class GerirLegislacaoPanel extends JPanel setEnable(); } } ); - panelData.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() + panelData.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() { @Override public void propertyChange( PropertyChangeEvent evt ) { - String newValue = (String) evt.getNewValue(); - if( selectedLegislacaoEspecifica != null ) + try { - selectedLegislacaoEspecifica.setDescription( newValue ); - selectedLegislacaoEspecifica.save(); - } - else if( selectedLegislacaoGeral != null ) + String newValue = (String) evt.getNewValue(); + if( selectedLegislacaoEspecifica != null ) + { + selectedLegislacaoEspecifica.setDescription( newValue ); + selectedLegislacaoEspecifica.save(); + } + else if( selectedLegislacaoGeral != null ) + { + selectedLegislacaoGeral.setDescription( newValue ); + selectedLegislacaoGeral.save(); + } + reload(); + } catch( Exception e ) { - selectedLegislacaoGeral.setDescription( newValue ); - selectedLegislacaoGeral.save(); + LeafError.error( e ); } - reload(); } } ); buttonCategoriaCriar.addActionListener( new ActionListener() @@ -316,30 +322,42 @@ public class GerirLegislacaoPanel extends JPanel } } ); } - + private void criarCategoria() { - String categoriaString = JOptionPane.showInputDialog( this, "Nova categoria", "" ); - if( categoriaString != null ) + try { - HsLegislacaoCategoria novaCategoria = new HsLegislacaoCategoria(); - novaCategoria.setDescription( categoriaString ); - novaCategoria.save(); - reload(); + String categoriaString = JOptionPane.showInputDialog( this, "Nova categoria", "" ); + if( categoriaString != null ) + { + HsLegislacaoCategoria novaCategoria = new HsLegislacaoCategoria(); + novaCategoria.setDescription( categoriaString ); + novaCategoria.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void editarCategoria() { - if( selectedCategoria != null ) + try { - String categoriaString = JOptionPane.showInputDialog( this, "Nova categoria", selectedCategoria.getDescription() ); - if( categoriaString != null ) + if( selectedCategoria != null ) { - selectedCategoria.setDescription( categoriaString ); - selectedCategoria.save(); - reload(); + String categoriaString = JOptionPane.showInputDialog( this, "Nova categoria", selectedCategoria.getDescription() ); + if( categoriaString != null ) + { + selectedCategoria.setDescription( categoriaString ); + selectedCategoria.save(); + reload(); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } @@ -350,47 +368,71 @@ public class GerirLegislacaoPanel extends JPanel selectedCategoria.setDeletedDate( new Date() ); } } - + private void criarCategoriaLegislacao() { - if( selectedCategoria != null ) + try { - HsLegislacao novaLegislacao = new HsLegislacao(); - novaLegislacao.setDescription( "" ); - novaLegislacao.setToHsLegislacaoCategoria( selectedCategoria ); - novaLegislacao.save(); - reload(); + if( selectedCategoria != null ) + { + HsLegislacao novaLegislacao = new HsLegislacao(); + novaLegislacao.setDescription( "" ); + novaLegislacao.setToHsLegislacaoCategoria( selectedCategoria ); + novaLegislacao.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void removerCategoriaLegislacao() { - if( selectedLegislacaoEspecifica != null ) + try { - selectedLegislacaoEspecifica.setDeletedDate( new Date() ); - selectedLegislacaoEspecifica.save(); - reload(); + if( selectedLegislacaoEspecifica != null ) + { + selectedLegislacaoEspecifica.setDeletedDate( new Date() ); + selectedLegislacaoEspecifica.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void removerGeral() { - if( selectedLegislacaoGeral != null ) + try { - selectedLegislacaoGeral.setDeletedDate( new Date() ); - selectedLegislacaoGeral.save(); - reload(); + if( selectedLegislacaoGeral != null ) + { + selectedLegislacaoGeral.setDeletedDate( new Date() ); + selectedLegislacaoGeral.save(); + reload(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void criarGeral() { - HsLegislacao legislacao = new HsLegislacao(); - legislacao.setDescription( "" ); - legislacao.save(); - reload(); + try + { + HsLegislacao legislacao = new HsLegislacao(); + legislacao.setDescription( "" ); + legislacao.save(); + reload(); + } catch( Exception e ) + { + LeafError.error( e ); + } } - + private void reload() { rootGeral.removeAllChildren(); @@ -400,7 +442,7 @@ public class GerirLegislacaoPanel extends JPanel TreeTools.refreshTree( treeGeral, rootGeral ); TreeTools.refreshTree( treeCategorias, rootCategorias ); } - + private void refreshData() { buttonCategoriaEditar.setEnabled( false ); @@ -429,7 +471,7 @@ public class GerirLegislacaoPanel extends JPanel buttonCategoriaRemover.setEnabled( true ); } } - + private void setEnable() { buttonCategoriaEditar.setEnabled( selectedCategoria != null ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java index 6619d500..b99dd356 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java @@ -17,6 +17,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Estabelecimentos; @@ -32,17 +33,17 @@ public class AdicionarAreasPanel extends JPanel private static final long serialVersionUID = 1L; public static final String SELECTION_CHANGED = "SELECTION_CHANGED"; - - private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); - - private final LeafButton buttonRemover = new LeafButton("Remover"); - + + private final LeafButton buttonAdicionar = new LeafButton( "Adicionar" ); + + private final LeafButton buttonRemover = 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 Estabelecimentos estabelecimento = null; @@ -54,7 +55,7 @@ public class AdicionarAreasPanel extends JPanel placeComponents(); startupListeners(); } - + private void startupComponents() { buttonAdicionar.setEnabled( false ); @@ -62,46 +63,49 @@ public class AdicionarAreasPanel extends JPanel tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } - + private void setupLayout() { - 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 ); } - + private void placeComponents() { JPanel panel = new JPanel(); - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); - + add( panel, new TableLayoutConstraints( 0, 0 ) ); add( scroll, new TableLayoutConstraints( 0, 1 ) ); } - + private void startupListeners() { - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { setEnabled(); TreePath path = tree.getSelectionPath(); Object object = path == null ? null : path.getLastPathComponent(); - HsPosto posto = object == null ? null : ( (object instanceof PostoNode) ? (HsPosto) ((PostoNode) object).getUserObject() : null); - firePropertyChange( SELECTION_CHANGED, null, posto ); + HsPosto posto = object == null ? null : ((object instanceof PostoNode) ? (HsPosto) ((PostoNode) object).getUserObject() : null); + firePropertyChange( SELECTION_CHANGED, null, posto ); } } ); buttonAdicionar.addActionListener( new ActionListener() @@ -121,35 +125,41 @@ public class AdicionarAreasPanel extends JPanel } } ); } - + private void add() { 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( "Adicionar Postos de Trabalho", allPostos ); save( dialog.getResult() ); refresh(); } - + private void save( DefaultMutableTreeNode toadd ) { - Object obj = toadd.getUserObject(); - if( obj instanceof HsPosto ) + try { - HsPostoEstabelecimento rel = new HsPostoEstabelecimento(); - rel.setToEstabelecimentos( estabelecimento ); - rel.setToHsPosto( (HsPosto) obj ); - rel.save(); - } - else - { - for( int i = 0; i < toadd.getChildCount(); ++i ) + Object obj = toadd.getUserObject(); + if( obj instanceof HsPosto ) + { + HsPostoEstabelecimento rel = new HsPostoEstabelecimento(); + rel.setToEstabelecimentos( estabelecimento ); + rel.setToHsPosto( (HsPosto) obj ); + rel.save(); + } + else { - save( (DefaultMutableTreeNode) toadd.getChildAt( i ) ); + for( int i = 0; i < toadd.getChildCount(); ++i ) + { + save( (DefaultMutableTreeNode) toadd.getChildAt( i ) ); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void rem() { TreePath path = tree.getSelectionPath(); @@ -158,44 +168,51 @@ public class AdicionarAreasPanel extends JPanel Object object = path.getLastPathComponent(); if( object instanceof PostoNode ) { - HsPosto posto = ((HsPosto)((PostoNode) object).getUserObject()); + HsPosto posto = ((HsPosto) ((PostoNode) object).getUserObject()); remPosto( posto ); } else if( object instanceof AreaNode ) { - for( int i = 0; i < ((AreaNode)object).getChildCount(); ++i ) + for( int i = 0; i < ((AreaNode) object).getChildCount(); ++i ) { - PostoNode postoNode = (PostoNode) ((AreaNode)object).getChildAt( i ); + PostoNode postoNode = (PostoNode) ((AreaNode) object).getChildAt( i ); remPosto( (HsPosto) postoNode.getUserObject() ); } } } refresh(); } - + private void remPosto( HsPosto posto ) { - HsPostoEstabelecimento toDelete = null; - for( HsPostoEstabelecimento rel : posto.getHsPostoEstabelecimentoArray() ) + try { - if( rel.getToEstabelecimentos().equals( estabelecimento ) ) + HsPostoEstabelecimento toDelete = null; + for( HsPostoEstabelecimento rel : posto.getHsPostoEstabelecimentoArray() ) { - toDelete = rel; - break; + if( rel.getToEstabelecimentos().equals( estabelecimento ) ) + { + toDelete = rel; + break; + } + } + if( toDelete != null ) + { + toDelete.delete(); } } - if( toDelete != null ) + catch( Exception e ) { - toDelete.delete(); + LeafError.error( e ); } } - + private void setEnabled() { buttonAdicionar.setEnabled( estabelecimento != null ); buttonRemover.setEnabled( tree.getSelectionCount() > 0 ); } - + public void refresh() { root.removeAllChildren(); @@ -207,11 +224,10 @@ public class AdicionarAreasPanel extends JPanel TreeTools.refreshTree( tree, root ); } - public void setEstabelecimento( Estabelecimentos estabelecimento ) { - this.estabelecimento = estabelecimento; + this.estabelecimento = estabelecimento; refresh(); } - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java index 4b983649..2e7c8b2a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java @@ -26,6 +26,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.HsArea; @@ -171,56 +172,80 @@ public class GerirAreasPanel extends JPanel private void criarArea() { - if( empresa != null ) + try { - String areaString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar nova " + aacute + "rea", JOptionPane.QUESTION_MESSAGE ); - if( areaString != null ) + if( empresa != null ) { - HsArea area = new HsArea(); - area.setToEmpresas( empresa ); - area.setDescription( areaString ); - area.save(); - refresh(); + String areaString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar nova " + aacute + "rea", JOptionPane.QUESTION_MESSAGE ); + if( areaString != null ) + { + HsArea area = new HsArea(); + area.setToEmpresas( empresa ); + area.setDescription( areaString ); + area.save(); + refresh(); + } } + } catch( Exception e ) + { + LeafError.error(e); } } private void removerArea() { - HsArea area = getSelectedArea(); - if( area != null ) + try + { + HsArea area = getSelectedArea(); + if( area != null ) + { + area.delete(); + refresh(); + } + } catch( Exception e ) { - area.delete(); - refresh(); + LeafError.error(e); } } private void criarPosto() { - HsArea area = getSelectedArea(); - if( area != null ) + try { - String postoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo posto de trabalho", JOptionPane.QUESTION_MESSAGE ); - if( postoString != null ) + HsArea area = getSelectedArea(); + if( area != null ) { - HsPosto posto = new HsPosto(); - posto.setToHsArea( area ); - posto.setDescription( postoString ); - posto.save(); + String postoString = JOptionPane.showInputDialog( this, "Descri" + ccedil + atilde + "o", "Criar novo posto de trabalho", JOptionPane.QUESTION_MESSAGE ); + if( postoString != null ) + { + HsPosto posto = new HsPosto(); + posto.setToHsArea( area ); + posto.setDescription( postoString ); + posto.save(); + refresh(); + } refresh(); } - refresh(); + } catch( Exception e ) + { + LeafError.error(e); } } private void removerPosto() { - HsPosto posto = getSelectedPosto(); - if( posto != null ) + try + { + HsPosto posto = getSelectedPosto(); + if( posto != null ) + { + posto.setDeletedDate( new Date() ); + posto.save(); + refresh(); + } + } catch( Exception e ) { - posto.setDeletedDate( new Date() ); - posto.save(); - refresh(); + LeafError.error(e); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java index f603959f..7b274cdd 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java @@ -17,13 +17,13 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.BaseObject; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.HsPosto; import siprp.database.cayenne.objects.HsPostoRisco; -import siprp.database.cayenne.objects.HsRelatorioPosto; import siprp.database.cayenne.objects.HsRisco; import siprp.database.cayenne.objects.HsRiscoEmpresa; import siprp.logic.HigieneSegurancaLogic; @@ -35,21 +35,21 @@ public class AdicionarRiscosPanel extends JPanel private static final long serialVersionUID = 1L; public static final String SELECTION_CHANGED = "RISCOS_SELECTION_CHANGED"; - - private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); - - private final LeafButton buttonRemover = new LeafButton("Remover"); - + + private final LeafButton buttonAdicionar = new LeafButton( "Adicionar" ); + + private final LeafButton buttonRemover = 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; - + private HsPosto posto = null; public AdicionarRiscosPanel() @@ -59,7 +59,7 @@ public class AdicionarRiscosPanel extends JPanel placeComponents(); startupListeners(); } - + private void startupComponents() { buttonAdicionar.setEnabled( false ); @@ -67,35 +67,37 @@ public class AdicionarRiscosPanel extends JPanel tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } - + private void setupLayout() { - 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 ); } - + private void placeComponents() { JPanel panel = new JPanel(); - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); - + add( panel, new TableLayoutConstraints( 0, 0 ) ); add( scroll, new TableLayoutConstraints( 0, 1 ) ); } - + private void startupListeners() { buttonAdicionar.addActionListener( new ActionListener() @@ -114,7 +116,8 @@ public class AdicionarRiscosPanel extends JPanel rem(); } } ); - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { @@ -128,21 +131,21 @@ public class AdicionarRiscosPanel extends JPanel } } ); } - + private void add() { DefaultMutableTreeNode allRiscos = getAllRiscos(); - TreeTools.removeAll( allRiscos, getRiscosTree( ) ); + TreeTools.removeAll( allRiscos, getRiscosTree() ); TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Riscos", allRiscos ); DefaultMutableTreeNode result = dialog.getResult(); if( result != null ) { - addResult(result); + addResult( result ); refresh(); } setEnabled(); } - + private DefaultMutableTreeNode getAllRiscos() { DefaultMutableTreeNode result = new DefaultMutableTreeNode(); @@ -156,6 +159,7 @@ public class AdicionarRiscosPanel extends JPanel } return result; } + private DefaultMutableTreeNode getRiscosTree() { DefaultMutableTreeNode result = new DefaultMutableTreeNode(); @@ -179,53 +183,64 @@ public class AdicionarRiscosPanel extends JPanel } return result; } - + private void addResult( DefaultMutableTreeNode root ) { - if( root != null ) + try { - if( root instanceof NodeRisco ) + if( root != null ) { - HsRisco risco = (HsRisco) root.getUserObject(); - if( empresa != null ) + if( root instanceof NodeRisco ) { - HsRiscoEmpresa rel = new HsRiscoEmpresa(); - rel.setToEmpresa( empresa ); - rel.setToHsRisco( risco ); - rel.save(); + HsRisco risco = (HsRisco) root.getUserObject(); + if( empresa != null ) + { + HsRiscoEmpresa rel = new HsRiscoEmpresa(); + rel.setToEmpresa( empresa ); + rel.setToHsRisco( risco ); + rel.save(); + } + else if( posto != null ) + { + HsPostoRisco rel = new HsPostoRisco(); + rel.setToHsPosto( posto ); + rel.setToHsRisco( risco ); + rel.save(); + } } - else if( posto != null ) + for( int i = 0; i < root.getChildCount(); ++i ) { - HsPostoRisco rel = new HsPostoRisco(); - rel.setToHsPosto( posto); - rel.setToHsRisco( risco ); - rel.save(); + DefaultMutableTreeNode child = (DefaultMutableTreeNode) root.getChildAt( i ); + addResult( child ); } } - for( int i = 0; i < root.getChildCount(); ++i ) - { - DefaultMutableTreeNode child = (DefaultMutableTreeNode) root.getChildAt( i ); - addResult( child ); - } + } catch( Exception e ) + { + LeafError.error( e ); } } - - + private void rem() { - TreePath path = tree.getSelectionPath(); - if (path != null) + try { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - Object obj = node.getUserObject(); - if( obj != null ) + TreePath path = tree.getSelectionPath(); + if( path != null ) { - ((BaseObject) obj).delete(); - refresh(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); + Object obj = node.getUserObject(); + if( obj != null ) + { + ((BaseObject) obj).delete(); + refresh(); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void setEnabled() { if( empresa != null ) @@ -270,12 +285,12 @@ public class AdicionarRiscosPanel extends JPanel this.posto = null; refresh(); } - + public void setPosto( HsPosto posto ) { this.posto = posto; this.empresa = null; refresh(); } - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index 67671722..d4e939e4 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -15,6 +15,7 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import siprp.database.cayenne.objects.HsMedida; import com.evolute.utils.images.ImageException; @@ -26,35 +27,29 @@ public class GerirMedidaPanel extends JPanel public static final String MEDIDA_CHANGED = "MEDIDA_CHANGED"; private static final long serialVersionUID = 1L; - + 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"; - private LeafButton buttonSaveMedida; - - private LeafButton buttonRevertMedida; - private LeafButton buttonSaveRequesito; - + private LeafButton buttonRevertRequesito; - + private final JTextArea fieldTextMedida = new JTextArea(); - - private final JScrollPane scrollMedida = new JScrollPane(fieldTextMedida); - + + private final JScrollPane scrollMedida = new JScrollPane( fieldTextMedida ); + private final JTextArea fieldTextRequisitosLegais = new JTextArea(); - - private final JScrollPane scrollRequesitos = new JScrollPane(fieldTextRequisitosLegais); - + + private final JScrollPane scrollRequesitos = new JScrollPane( fieldTextRequisitosLegais ); + private HsMedida medida = null; - + public GerirMedidaPanel() { try { - buttonSaveMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); - buttonRevertMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); buttonSaveRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); buttonRevertRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); } catch( ImageException e ) @@ -66,7 +61,7 @@ public class GerirMedidaPanel extends JPanel placeComponents(); setupListeners(); } - + private void startupComponents() { fieldTextMedida.setWrapStyleWord( true ); @@ -77,12 +72,10 @@ public class GerirMedidaPanel extends JPanel scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - buttonSaveMedida.setMargin( new Insets(0,0,0,0) ); - buttonSaveRequesito.setMargin( new Insets(0,0,0,0) ); - buttonRevertMedida.setMargin( new Insets(0,0,0,0) ); - buttonRevertRequesito.setMargin( new Insets(0,0,0,0) ); + buttonSaveRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); + buttonRevertRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); } - + private void setupListeners() { fieldTextRequisitosLegais.addCaretListener( new CaretListener() @@ -101,14 +94,6 @@ public class GerirMedidaPanel extends JPanel setEnabled(); } } ); - buttonSaveMedida.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - saveMedida(); - } - } ); buttonSaveRequesito.addActionListener( new ActionListener() { @Override @@ -117,14 +102,6 @@ public class GerirMedidaPanel extends JPanel saveRequesito(); } } ); - buttonRevertMedida.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - revertMedida(); - } - } ); buttonRevertRequesito.addActionListener( new ActionListener() { @Override @@ -134,30 +111,29 @@ public class GerirMedidaPanel extends JPanel } } ); } - + private void startupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); setLayout( layout ); } - + private void placeComponents() { - add( new JLabel("Requisitos legais"), new TableLayoutConstraints(0,0) ); - add( buttonSaveRequesito, new TableLayoutConstraints(1,0) ); - add( buttonRevertRequesito, new TableLayoutConstraints(2,0) ); - add( scrollRequesitos, new TableLayoutConstraints(0,1,2,1) ); - add( new JLabel("Medida"), new TableLayoutConstraints(0,2) ); - add( buttonSaveMedida, new TableLayoutConstraints(1,2) ); - add( buttonRevertMedida, new TableLayoutConstraints(2,2) ); - add( scrollMedida, new TableLayoutConstraints(0,3,2,3) ); + add( new JLabel( "Requisitos legais" ), new TableLayoutConstraints( 0, 0 ) ); + add( buttonSaveRequesito, new TableLayoutConstraints( 1, 0 ) ); + add( buttonRevertRequesito, new TableLayoutConstraints( 2, 0 ) ); + add( scrollRequesitos, new TableLayoutConstraints( 0, 1, 2, 1 ) ); + add( new JLabel( "Medida" ), new TableLayoutConstraints( 0, 2 ) ); + add( scrollMedida, new TableLayoutConstraints( 0, 3, 2, 3 ) ); } - + private void setEnabled() { boolean medidaChanged = false; @@ -167,57 +143,43 @@ public class GerirMedidaPanel extends JPanel medidaChanged = !fieldTextMedida.getText().equals( medida.getDescription() ); requesitoChanged = !fieldTextRequisitosLegais.getText().equals( medida.getRequesitosLegais() ); } - buttonSaveMedida.setEnabled( medidaChanged ); - buttonSaveRequesito.setEnabled( requesitoChanged ); - buttonRevertMedida.setEnabled( medidaChanged ); - buttonRevertRequesito.setEnabled( requesitoChanged ); - } - - private void saveMedida() - { - if( medida != null ) - { - medida.setDescription( fieldTextMedida.getText() ); - medida.save(); - refresh(); - } - setEnabled(); + buttonSaveRequesito.setEnabled( requesitoChanged || medidaChanged ); + buttonRevertRequesito.setEnabled( requesitoChanged || medidaChanged ); } - + private void saveRequesito() { - if( medida != null ) + try { - medida.setRequesitosLegais(fieldTextRequisitosLegais.getText() ); - medida.save(); - refresh(); - } - setEnabled(); - } - - private void revertMedida() - { - if( medida != null ) + if( medida != null ) + { + medida.setRequesitosLegais( fieldTextRequisitosLegais.getText() ); + medida.setDescription( fieldTextMedida.getText() ); + medida.save(); + refresh(); + } + setEnabled(); + } catch( Exception e ) { - fieldTextMedida.setText( medida.getDescription() ); + LeafError.error( e ); } - setEnabled(); } - + private void revertRequesito() { if( medida != null ) { fieldTextRequisitosLegais.setText( medida.getRequesitosLegais() ); + fieldTextMedida.setText( medida.getDescription() ); } setEnabled(); } - + private void refresh() { firePropertyChange( MEDIDA_CHANGED, null, medida ); } - + public void setMedida( HsMedida medida ) { this.medida = medida; @@ -225,11 +187,10 @@ public class GerirMedidaPanel extends JPanel fieldTextRequisitosLegais.setText( medida == null ? null : medida.getRequesitosLegais() ); setEnabled(); } - + public HsMedida getMedida() { return this.medida; } - - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index 444b5123..5df78db1 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -1,6 +1,6 @@ package siprp.higiene.gestao.riscos; -import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.*; import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -26,6 +26,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsMedida; import siprp.database.cayenne.objects.HsRisco; @@ -37,49 +38,49 @@ public class GerirRiscosPanel extends JPanel { private static final long serialVersionUID = 1L; - + private static final String PANEL_TEMA = "PANEL_TEMA"; - + private static final String PANEL_RISCO = "PANEL_RISCO"; - + private static final String PANEL_MEDIDA = "PANEL_MEDIDA"; - + private final JPanel panelButtons = new JPanel(); - + private final JPanel panelTree = new JPanel(); - + private final JPanel panelData = new JPanel(); - + private final JPanel panelDataTema = new JPanel(); - + private final JPanel panelDataRisco = new JPanel(); - + private final GerirMedidaPanel panelDataMedida = new GerirMedidaPanel(); - + private final LeafButton buttonTemaCriar = new LeafButton( "Criar" ); - + private final LeafButton buttonTemaEditar = new LeafButton( "Editar" ); - + private final LeafButton buttonTemaRemover = new LeafButton( "Remover" ); - + private final LeafButton buttonRiscoCriar = new LeafButton( "Criar" ); - + private final LeafButton buttonRiscoEditar = new LeafButton( "Editar" ); - + private final LeafButton buttonRiscoRemover = new LeafButton( "Remover" ); - + private final LeafButton buttonMedidaCriar = new LeafButton( "Criar" ); - + private final LeafButton buttonMedidaRemover = new LeafButton( "Remover" ); - + private final DefaultMutableTreeNode root = new DefaultMutableTreeNode(); - + private final DefaultTreeModel model = new DefaultTreeModel( root ); - + private final JTree tree = new JTree( model ); - + private final JScrollPane scroll = new JScrollPane( tree ); - + private final CardLayout cardLayout = new CardLayout(); public GerirRiscosPanel() @@ -90,7 +91,7 @@ public class GerirRiscosPanel extends JPanel setupListeners(); refresh(); } - + private void setupListeners() { buttonTemaCriar.addActionListener( new ActionListener() @@ -157,14 +158,15 @@ public class GerirRiscosPanel extends JPanel removerMedida(); } } ); - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { setEnabled(); selectCard(); } - }); + } ); panelDataMedida.addPropertyChangeListener( GerirMedidaPanel.MEDIDA_CHANGED, new PropertyChangeListener() { @Override @@ -175,163 +177,225 @@ public class GerirRiscosPanel extends JPanel refresh(); } } - }); + } ); } - + private void criarTema() { - String temaString = JOptionPane.showInputDialog( this, "Criar tema", "Descri" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); - if( temaString != null ) + try + { + String temaString = JOptionPane.showInputDialog( this, "Criar tema", "Descri" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); + if( temaString != null ) + { + HsRiscoTema tema = new HsRiscoTema(); + tema.setDescription( temaString ); + tema.save(); + refresh(); + } + } catch( Exception e ) { - HsRiscoTema tema = new HsRiscoTema(); - tema.setDescription( temaString ); - tema.save(); - refresh(); + LeafError.error( e ); } } - + private void editarTema() { - HsRiscoTema tema = getSelectedTema(); - if( tema != null ) + try { - String temaString = JOptionPane.showInputDialog( this, "Editar tema", tema.getDescription() ); - if( temaString != null ) + HsRiscoTema tema = getSelectedTema(); + if( tema != null ) { - tema.setDescription( temaString ); - tema.save(); - refresh(); + String temaString = JOptionPane.showInputDialog( this, "Editar tema", tema.getDescription() ); + if( temaString != null ) + { + tema.setDescription( temaString ); + tema.save(); + refresh(); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private void removerTema() { - HsRiscoTema tema = getSelectedTema(); - if( tema != null ) + try + { + HsRiscoTema tema = getSelectedTema(); + if( tema != null ) + { + tema.delete(); + refresh(); + } + } catch( Exception e ) { - tema.delete(); - refresh(); + LeafError.error( e ); } } - + private void criarRisco() { - HsRiscoTema tema = getSelectedTema(); - if( tema == null ) + try { - HsRisco risco = getSelectedRisco(); - if( risco != null ) + HsRiscoTema tema = getSelectedTema(); + if( tema == null ) { - tema = risco.getToHsRiscoTema(); + HsRisco risco = getSelectedRisco(); + if( risco != null ) + { + tema = risco.getToHsRiscoTema(); + } + else + { + HsRiscoMedida medida = getSelectedMedida(); + if( medida != null ) + { + tema = medida.getToHsRisco().getToHsRiscoTema(); + } + } } - else + if( tema != null ) { - HsRiscoMedida medida = getSelectedMedida(); - if( medida != null ) + String riscoString = JOptionPane.showInputDialog( this, "Criar risco", "Descri" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); + if( riscoString != null ) { - tema = medida.getToHsRisco().getToHsRiscoTema(); + HsRisco risco = new HsRisco(); + risco.setDescription( riscoString ); + risco.setToHsRiscoTema( tema ); + tema.save(); + refresh(); } } + } catch( Exception e ) + { + LeafError.error( e ); } - if( tema != null ) + } + + private void editarRisco() + { + try { - String riscoString = JOptionPane.showInputDialog( this, "Criar risco", "Descri" + ccedil + atilde + "o", JOptionPane.QUESTION_MESSAGE ); - if( riscoString != null ) + HsRisco risco = getSelectedRisco(); + if( risco != null ) { - HsRisco risco = new HsRisco(); - risco.setDescription( riscoString ); - risco.setToHsRiscoTema( tema ); - tema.save(); - refresh(); + String riscoString = JOptionPane.showInputDialog( this, "Editar risco", risco.getDescription() ); + if( riscoString != null ) + { + risco.setDescription( riscoString ); + risco.save(); + refresh(); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } - - private void editarRisco() + + private void removerRisco() { - HsRisco risco = getSelectedRisco(); - if( risco != null ) + try { - String riscoString = JOptionPane.showInputDialog( this, "Editar risco", risco.getDescription() ); - if( riscoString != null ) + HsRisco risco = getSelectedRisco(); + if( risco != null && removerRiscoOK(risco) ) { - risco.setDescription( riscoString ); - risco.save(); + risco.delete(); refresh(); } } + catch( Exception e ) + { + LeafError.error( e ); + } } - private void removerRisco() + private boolean removerRiscoOK( HsRisco risco ) { - HsRisco risco = getSelectedRisco(); - if( risco != null ) + boolean result = true; + if( risco.getHsRiscoEmpresaArray().size() > 0 ) { - risco.delete(); - refresh(); + if( JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog( this, "Este risco est" + aacute + " associado a uma ou mais empresas, \n tem a certeza que o deseja remover?", "Aviso", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE ) ) + { + result = false; + } } + return result; } - + private void criarMedida() { - HsRisco risco = getSelectedRisco(); - if( risco == null ) + try { - HsRiscoMedida medida = getSelectedMedida(); - if( medida != null ) + HsRisco risco = getSelectedRisco(); + if( risco == null ) { - risco = medida.getToHsRisco(); + HsRiscoMedida medida = getSelectedMedida(); + if( medida != null ) + { + risco = medida.getToHsRisco(); + } } - } - if( risco != null ) + if( risco != null ) + { + HsMedida medida = new HsMedida(); + medida.setDescription( "" ); + medida.setRequesitosLegais( "" ); + medida.save(); + HsRiscoMedida rel = new HsRiscoMedida(); + rel.setToHsRisco( risco ); + rel.setToHsMedida( medida ); + rel.save(); + refresh(); + } + } catch( Exception e ) { - HsMedida medida = new HsMedida(); - medida.setDescription( "" ); - medida.setRequesitosLegais( "" ); - medida.save(); - HsRiscoMedida rel = new HsRiscoMedida(); - rel.setToHsRisco( risco ); - rel.setToHsMedida( medida ); - rel.save(); - refresh(); + LeafError.error( e ); } } - + private void removerMedida() { - HsRiscoMedida medida = getSelectedMedida(); - if( medida != null ) + try { - medida.delete(); - refresh(); + HsRiscoMedida medida = getSelectedMedida(); + if( medida != null ) + { + medida.delete(); + refresh(); + } + } catch( Exception e ) + { + LeafError.error( e ); } } - + private HsRiscoTema getSelectedTema() { Object object = getSelectedObject(); return object == null ? null : ((object instanceof HsRiscoTema) ? (HsRiscoTema) object : null); } - + private HsRisco getSelectedRisco() { Object object = getSelectedObject(); return object == null ? null : ((object instanceof HsRisco) ? (HsRisco) object : null); } - + private HsRiscoMedida getSelectedMedida() { Object object = getSelectedObject(); return object == null ? null : ((object instanceof HsRiscoMedida) ? (HsRiscoMedida) object : null); } - + private Object getSelectedObject() { DefaultMutableTreeNode node = getSelectedNode(); return node == null ? null : node.getUserObject(); } - + private DefaultMutableTreeNode getSelectedNode() { TreePath path = tree.getSelectionPath(); @@ -345,7 +409,7 @@ public class GerirRiscosPanel extends JPanel tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); } - + private void setEnabled() { HsRiscoTema tema = getSelectedTema(); @@ -353,60 +417,65 @@ public class GerirRiscosPanel extends JPanel HsRiscoMedida medida = getSelectedMedida(); buttonMedidaCriar.setEnabled( risco != null || medida != null ); buttonRiscoCriar.setEnabled( tema != null || risco != null || medida != null ); - + buttonTemaEditar.setEnabled( tema != null ); buttonRiscoEditar.setEnabled( risco != null ); - + buttonMedidaRemover.setEnabled( medida != null ); buttonRiscoRemover.setEnabled( risco != null ); buttonTemaRemover.setEnabled( tema != null ); } - + private void startupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL }, - new double[]{ TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL + }, new double[] { + TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); setLayout( layout ); - - layout = new TableLayout( - new double[]{ TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } - ); + + layout = new TableLayout( new double[] { + TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL + } ); 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 ); - - 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 ); panelDataTema.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 ); panelDataRisco.setLayout( layout ); - + panelData.setLayout( cardLayout ); } - + private void placeComponents() { JPanel panel = new JPanel(); @@ -429,19 +498,18 @@ public class GerirRiscosPanel extends JPanel panel.add( buttonMedidaCriar ); panel.add( buttonMedidaRemover ); panelButtons.add( panel, new TableLayoutConstraints( 0, 2 ) ); - + panelTree.add( scroll, new TableLayoutConstraints( 0, 0 ) ); - + panelData.add( panelDataTema, PANEL_TEMA ); panelData.add( panelDataRisco, PANEL_RISCO ); panelData.add( panelDataMedida, PANEL_MEDIDA ); - + add( panelButtons, new TableLayoutConstraints( 0, 0 ) ); add( panelTree, new TableLayoutConstraints( 1, 0 ) ); add( panelData, new TableLayoutConstraints( 2, 0 ) ); } - - + private void selectCard() { HsRiscoTema tema = getSelectedTema(); @@ -453,15 +521,15 @@ public class GerirRiscosPanel extends JPanel } else if( risco != null ) { - cardLayout.show( panelData, PANEL_RISCO ); + cardLayout.show( panelData, PANEL_RISCO ); } else if( medida != null ) { cardLayout.show( panelData, PANEL_MEDIDA ); panelDataMedida.setMedida( medida.getToHsMedida() ); - } + } } - + private void refresh() { root.removeAllChildren(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index 51edc9cd..d909a5df 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -18,6 +18,7 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import siprp.database.cayenne.objects.HsRelatorioPostoMedida; import com.evolute.utils.images.ImageException; @@ -29,31 +30,31 @@ public class GerirMedidaRelatorioPanel extends JPanel public static final String MEDIDA_CHANGED = "MEDIDA_CHANGED"; private static final long serialVersionUID = 1L; - + 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"; private LeafButton buttonSaveMedida; - + private LeafButton buttonRevertMedida; - + private LeafButton buttonSaveRequesito; - + private LeafButton buttonRevertRequesito; - - private final JCheckBox checkPlanoActuacao = new JCheckBox("Plano de actua" + ccedil + atilde + "o"); - + + private final JCheckBox checkPlanoActuacao = new JCheckBox( "Plano de actua" + ccedil + atilde + "o" ); + private final JTextArea fieldTextMedida = new JTextArea(); - - private final JScrollPane scrollMedida = new JScrollPane(fieldTextMedida); - + + private final JScrollPane scrollMedida = new JScrollPane( fieldTextMedida ); + private final JTextArea fieldTextRequisitosLegais = new JTextArea(); - - private final JScrollPane scrollRequesitos = new JScrollPane(fieldTextRequisitosLegais); - + + private final JScrollPane scrollRequesitos = new JScrollPane( fieldTextRequisitosLegais ); + private HsRelatorioPostoMedida relacao = null; - + public GerirMedidaRelatorioPanel() { try @@ -71,7 +72,7 @@ public class GerirMedidaRelatorioPanel extends JPanel placeComponents(); setupListeners(); } - + private void startupComponents() { fieldTextMedida.setWrapStyleWord( true ); @@ -82,12 +83,12 @@ public class GerirMedidaRelatorioPanel extends JPanel scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - buttonSaveMedida.setMargin( new Insets(0,0,0,0) ); - buttonSaveRequesito.setMargin( new Insets(0,0,0,0) ); - buttonRevertMedida.setMargin( new Insets(0,0,0,0) ); - buttonRevertRequesito.setMargin( new Insets(0,0,0,0) ); + buttonSaveMedida.setMargin( new Insets( 0, 0, 0, 0 ) ); + buttonSaveRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); + buttonRevertMedida.setMargin( new Insets( 0, 0, 0, 0 ) ); + buttonRevertRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); } - + private void setupListeners() { checkPlanoActuacao.addActionListener( new ActionListener() @@ -147,40 +148,42 @@ public class GerirMedidaRelatorioPanel extends JPanel } } ); } - + private void startupLayout() { - TableLayout layout = new TableLayout( - new double[]{ TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); setLayout( layout ); } - + private void placeComponents() { JPanel panel = new JPanel(); - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL }, - new double[]{ TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL + }, new double[] { + TableLayout.MINIMUM + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); - panel.add( checkPlanoActuacao, new TableLayoutConstraints(0,0) ); - add( panel, new TableLayoutConstraints(0,0,2,0) ); - add( new JLabel("Requisitos legais"), new TableLayoutConstraints(0,1) ); - add( buttonSaveRequesito, new TableLayoutConstraints(1,1) ); - add( buttonRevertRequesito, new TableLayoutConstraints(2,1) ); - add( scrollRequesitos, new TableLayoutConstraints(0,2,2,2) ); - add( new JLabel("Medida"), new TableLayoutConstraints(0,3) ); - add( buttonSaveMedida, new TableLayoutConstraints(1,3) ); - add( buttonRevertMedida, new TableLayoutConstraints(2,3) ); - add( scrollMedida, new TableLayoutConstraints(0,4,2,4) ); + panel.add( checkPlanoActuacao, new TableLayoutConstraints( 0, 0 ) ); + add( panel, new TableLayoutConstraints( 0, 0, 2, 0 ) ); + add( new JLabel( "Requisitos legais" ), new TableLayoutConstraints( 0, 1 ) ); + add( buttonSaveRequesito, new TableLayoutConstraints( 1, 1 ) ); + add( buttonRevertRequesito, new TableLayoutConstraints( 2, 1 ) ); + add( scrollRequesitos, new TableLayoutConstraints( 0, 2, 2, 2 ) ); + add( new JLabel( "Medida" ), new TableLayoutConstraints( 0, 3 ) ); + add( buttonSaveMedida, new TableLayoutConstraints( 1, 3 ) ); + add( buttonRevertMedida, new TableLayoutConstraints( 2, 3 ) ); + add( scrollMedida, new TableLayoutConstraints( 0, 4, 2, 4 ) ); } - + private void setEnabled() { if( isEnabled() ) @@ -210,41 +213,59 @@ public class GerirMedidaRelatorioPanel extends JPanel fieldTextMedida.setEnabled( false ); checkPlanoActuacao.setEnabled( false ); } - + } - + private void savePlano() { - if( relacao != null ) + try + { + if( relacao != null ) + { + relacao.setIsPlanoActuacao( checkPlanoActuacao.isSelected() ); + relacao.save(); + firePropertyChange( MEDIDA_CHANGED, null, relacao ); + } + } catch( Exception e ) { - relacao.setIsPlanoActuacao( checkPlanoActuacao.isSelected() ); - relacao.save(); - firePropertyChange( MEDIDA_CHANGED, null, relacao ); + LeafError.error( e ); } } - + private void saveMedida() { - if( relacao != null ) + try { - relacao.getToHsRelatorioMedida().setDescription( fieldTextMedida.getText() ); - relacao.save(); - refresh(); + if( relacao != null ) + { + relacao.getToHsRelatorioMedida().setDescription( fieldTextMedida.getText() ); + relacao.save(); + refresh(); + } + setEnabled(); + } catch( Exception e ) + { + LeafError.error( e ); } - setEnabled(); } - + private void saveRequesito() { - if( relacao != null ) + try + { + if( relacao != null ) + { + relacao.getToHsRelatorioMedida().setRequesitosLegais( fieldTextRequisitosLegais.getText() ); + relacao.save(); + refresh(); + } + setEnabled(); + } catch( Exception e ) { - relacao.getToHsRelatorioMedida().setRequesitosLegais(fieldTextRequisitosLegais.getText() ); - relacao.save(); - refresh(); + LeafError.error( e ); } - setEnabled(); } - + private void revertMedida() { if( relacao != null ) @@ -253,7 +274,7 @@ public class GerirMedidaRelatorioPanel extends JPanel } setEnabled(); } - + private void revertRequesito() { if( relacao != null ) @@ -262,20 +283,19 @@ public class GerirMedidaRelatorioPanel extends JPanel } setEnabled(); } - + private void refresh() { firePropertyChange( MEDIDA_CHANGED, null, relacao ); } - + public void setMedida( HsRelatorioPostoMedida medida ) { this.relacao = medida; fieldTextMedida.setText( medida == null ? null : medida.getToHsRelatorioMedida().getDescription() ); fieldTextRequisitosLegais.setText( medida == null ? null : medida.getToHsRelatorioMedida().getRequesitosLegais() ); - checkPlanoActuacao.setSelected( medida == null ? false : ( medida.getIsPlanoActuacao() == null ? false : medida.getIsPlanoActuacao() ) ); + checkPlanoActuacao.setSelected( medida == null ? false : (medida.getIsPlanoActuacao() == null ? false : medida.getIsPlanoActuacao()) ); setEnabled(); } - - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java index 5e07b596..a6ebb2b1 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java @@ -20,6 +20,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsRelatorioMedida; import siprp.database.cayenne.objects.HsRelatorioPosto; @@ -36,21 +37,21 @@ public class GerirMedidasRelatorioPanel extends JPanel private static final long serialVersionUID = 1L; public static final String SELECTION_CHANGED = "RISCOS_SELECTION_CHANGED"; - + public static final String VALUE_CHANGED = "VALUE_CHANGED"; - - private final LeafButton buttonAdicionar = new LeafButton("Adicionar"); - - private final LeafButton buttonRemover = new LeafButton("Remover"); - + + private final LeafButton buttonAdicionar = new LeafButton( "Adicionar" ); + + private final LeafButton buttonRemover = 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 HsRelatorioPosto posto = null; public GerirMedidasRelatorioPanel() @@ -60,27 +61,27 @@ public class GerirMedidasRelatorioPanel extends JPanel placeComponents(); startupListeners(); } - + private void startupComponents() { buttonAdicionar.setEnabled( false ); buttonRemover.setEnabled( false ); tree.setRootVisible( false ); tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); - tree.setCellRenderer(new DefaultTreeCellRenderer() - { + tree.setCellRenderer( new DefaultTreeCellRenderer() + { private static final long serialVersionUID = 1L; - public Component getTreeCellRendererComponent(JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus) - { - super.getTreeCellRendererComponent(pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus); - boolean highlight= false; + public Component getTreeCellRendererComponent( JTree pTree, Object pValue, boolean pIsSelected, boolean pIsExpanded, boolean pIsLeaf, int pRow, boolean pHasFocus ) + { + super.getTreeCellRendererComponent( pTree, pValue, pIsSelected, pIsExpanded, pIsLeaf, pRow, pHasFocus ); + boolean highlight = false; Color highColor = null; Color lowColor = null; if( pValue instanceof RiscoRelatorioNode ) { - Object userObject = ((RiscoRelatorioNode)pValue).getUserObject(); + Object userObject = ((RiscoRelatorioNode) pValue).getUserObject(); if( userObject instanceof HsRelatorioPostoRisco ) { highlight = HigieneSegurancaLogic.isRelatorioRiscoPreenchido( (HsRelatorioPostoRisco) userObject ); @@ -90,7 +91,7 @@ public class GerirMedidasRelatorioPanel extends JPanel } else if( pValue instanceof MedidaRelatorioNode ) { - Object userObject = ((MedidaRelatorioNode)pValue).getUserObject(); + Object userObject = ((MedidaRelatorioNode) pValue).getUserObject(); if( userObject instanceof HsRelatorioPostoMedida ) { HsRelatorioPostoMedida medida = (HsRelatorioPostoMedida) userObject; @@ -111,42 +112,45 @@ public class GerirMedidasRelatorioPanel extends JPanel { setOpaque( false ); } - return(this); - } - }); + return (this); + } + } ); } - + private void setupLayout() { - 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 ); } - + private void placeComponents() { JPanel panel = new JPanel(); - TableLayout layout = new TableLayout( - new double[]{ TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM }, - new double[]{ TableLayout.MINIMUM } - ); + TableLayout layout = new TableLayout( new double[] { + TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM + }, new double[] { + TableLayout.MINIMUM + } ); layout.setHGap( 5 ); layout.setVGap( 5 ); panel.setLayout( layout ); panel.add( buttonAdicionar, new TableLayoutConstraints( 0, 0 ) ); panel.add( buttonRemover, new TableLayoutConstraints( 2, 0 ) ); - + add( panel, new TableLayoutConstraints( 0, 0 ) ); add( scroll, new TableLayoutConstraints( 0, 1 ) ); } - + private void startupListeners() { - tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener(){ + tree.getSelectionModel().addTreeSelectionListener( new TreeSelectionListener() + { @Override public void valueChanged( TreeSelectionEvent e ) { @@ -157,12 +161,12 @@ public class GerirMedidasRelatorioPanel extends JPanel Object selection = path.getLastPathComponent(); if( selection instanceof RiscoRelatorioNode ) { - object = selection == null ? null : ((RiscoRelatorioNode)selection).getUserObject(); + object = selection == null ? null : ((RiscoRelatorioNode) selection).getUserObject(); } else if( selection instanceof MedidaRelatorioNode ) { - object = selection == null ? null : ((MedidaRelatorioNode)selection).getUserObject(); + object = selection == null ? null : ((MedidaRelatorioNode) selection).getUserObject(); } } setEnabled(); @@ -171,28 +175,28 @@ public class GerirMedidasRelatorioPanel extends JPanel } ); buttonAdicionar.addActionListener( new ActionListener() { - + @Override public void actionPerformed( ActionEvent e ) { add(); - + } - + } ); buttonRemover.addActionListener( new ActionListener() { - + @Override public void actionPerformed( ActionEvent e ) { rem(); - + } - + } ); } - + private HsRelatorioPostoRisco getSelectedRisco() { HsRelatorioPostoRisco result = null; @@ -202,12 +206,12 @@ public class GerirMedidasRelatorioPanel extends JPanel Object selection = path.getLastPathComponent(); if( selection instanceof RiscoRelatorioNode ) { - result = selection == null ? null : (HsRelatorioPostoRisco) ((RiscoRelatorioNode)selection).getUserObject(); + result = selection == null ? null : (HsRelatorioPostoRisco) ((RiscoRelatorioNode) selection).getUserObject(); } } return result; } - + private HsRelatorioPostoMedida getSelectedMedida() { HsRelatorioPostoMedida result = null; @@ -217,52 +221,64 @@ public class GerirMedidasRelatorioPanel extends JPanel Object selection = path.getLastPathComponent(); if( selection instanceof MedidaRelatorioNode ) { - result = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode)selection).getUserObject(); + result = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject(); } } return result; } - + private void add() { - HsRelatorioPostoRisco postoRisco = getSelectedRisco(); - if( posto != null ) + try { - HsRelatorioMedida medida = new HsRelatorioMedida(); - medida.setDescription( "" ); - medida.setRequesitosLegais( "" ); - medida.setToHsRelatorioRisco( postoRisco.getToHsRelatorioRisco() ); - HsRelatorioPostoMedida rel = new HsRelatorioPostoMedida(); - rel.setToHsRelatorioMedida( medida ); - rel.setToHsRelatorioPosto( posto ); - rel.save(); + HsRelatorioPostoRisco postoRisco = getSelectedRisco(); + if( posto != null ) + { + HsRelatorioMedida medida = new HsRelatorioMedida(); + medida.setDescription( "" ); + medida.setRequesitosLegais( "" ); + medida.setToHsRelatorioRisco( postoRisco.getToHsRelatorioRisco() ); + HsRelatorioPostoMedida rel = new HsRelatorioPostoMedida(); + rel.setToHsRelatorioMedida( medida ); + rel.setToHsRelatorioPosto( posto ); + rel.save(); + } + refresh(); + setEnabled(); + } catch( Exception e ) + { + LeafError.error( e ); } - refresh(); - setEnabled(); } private void rem() { - TreePath path = tree.getSelectionPath(); - if( path != null ) + try { - Object selection = path.getLastPathComponent(); - if( selection instanceof MedidaRelatorioNode ) + TreePath path = tree.getSelectionPath(); + if( path != null ) { - HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode)selection).getUserObject(); - rel.getToHsRelatorioMedida().delete(); - rel.delete(); + Object selection = path.getLastPathComponent(); + if( selection instanceof MedidaRelatorioNode ) + { + HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject(); + rel.getToHsRelatorioMedida().delete(); + rel.delete(); + } } + refresh(); + setEnabled(); + } catch( Exception e ) + { + LeafError.error( e ); } - refresh(); - setEnabled(); } - + private void setEnabled() { boolean add = false; boolean rem = false; - if( posto!= null ) + if( posto != null ) { if( posto.getToHsRelatorioArea() != null && posto.getToHsRelatorioArea().getToHsRelatorio() != null && posto.getToHsRelatorioArea().getToHsRelatorio().getIsSubmetido() == null ) { @@ -276,7 +292,7 @@ public class GerirMedidasRelatorioPanel extends JPanel public void refresh() { - root.removeAllChildren(); + root.removeAllChildren(); if( posto != null ) { for( HsRelatorioPostoRisco rel : posto.getHsRelatorioPostoRiscoArray() ) @@ -287,7 +303,7 @@ public class GerirMedidasRelatorioPanel extends JPanel { for( HsRelatorioPostoMedida medidaRel : medida.getHsRelatorioPostoMedidaArray() ) { - node.add( new MedidaRelatorioNode(medidaRel) ); + node.add( new MedidaRelatorioNode( medidaRel ) ); } } root.add( node ); @@ -296,12 +312,12 @@ public class GerirMedidasRelatorioPanel extends JPanel setEnabled(); TreeTools.refreshTree( tree, root ); } - + public void setPosto( HsRelatorioPosto posto ) { this.posto = posto; refresh(); setEnabled(); } - + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java index f3cb5a71..37484913 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java @@ -1,5 +1,6 @@ package siprp.higiene.relatorio; +import static com.evolute.utils.strings.UnicodeLatin1Map.aacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -18,13 +19,12 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; +import leaf.ui.LeafError; import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsRelatorioPostoRisco; import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; import siprp.logic.HigieneSegurancaLogic; -import static com.evolute.utils.strings.UnicodeLatin1Map.*; - public class GerirValoresRiscoPanel extends JPanel implements ActionListener, CaretListener { @@ -240,7 +240,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca refresh(); setEnabled(); } - + private void error( boolean probabilidade ) { JOptionPane.showMessageDialog( this, "Valor inv" + aacute + "lido para " + (probabilidade ? "'Probabilidade'" : "'Severidade'") + ".", "Erro", JOptionPane.ERROR_MESSAGE, null ); @@ -248,59 +248,65 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca private void save() { - if( valoresRisco != null ) + try { - if( radioValorQualitativo.isSelected() ) - { - valoresRisco.setToHsRelatorioRiscoValorQualitativo( (HsRelatorioRiscoValorQualitativo) comboValorQualitativo.getSelectedItem() ); - } - else + if( valoresRisco != null ) { - valoresRisco.setToHsRelatorioRiscoValorQualitativo( null ); - Integer probabilidade = null; - Integer severidade = null; - boolean ok = true; - if( textProbabilidade.getText() != null && !textProbabilidade.getText().trim().equals( "" ) ) + if( radioValorQualitativo.isSelected() ) { - try - { - probabilidade = new Integer( textProbabilidade.getText() ); - } catch( NumberFormatException e1 ) - { - ok = false; - } - if(!ok || !HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ) ) - { - error(true); - } + valoresRisco.setToHsRelatorioRiscoValorQualitativo( (HsRelatorioRiscoValorQualitativo) comboValorQualitativo.getSelectedItem() ); } - if( textSeveridade.getText() != null && !textSeveridade.getText().trim().equals( "" ) ) + else { - if( ok ) + valoresRisco.setToHsRelatorioRiscoValorQualitativo( null ); + Integer probabilidade = null; + Integer severidade = null; + boolean ok = true; + if( textProbabilidade.getText() != null && !textProbabilidade.getText().trim().equals( "" ) ) { try { - severidade = new Integer( textSeveridade.getText() ); - } catch( NumberFormatException e2 ) + probabilidade = new Integer( textProbabilidade.getText() ); + } catch( NumberFormatException e1 ) { ok = false; } - if(!ok || !HigieneSegurancaLogic.isSeveridadeValida( severidade ) ) + if( !ok || !HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ) ) { - error(false); + error( true ); } } + if( textSeveridade.getText() != null && !textSeveridade.getText().trim().equals( "" ) ) + { + if( ok ) + { + try + { + severidade = new Integer( textSeveridade.getText() ); + } catch( NumberFormatException e2 ) + { + ok = false; + } + if( !ok || !HigieneSegurancaLogic.isSeveridadeValida( severidade ) ) + { + error( false ); + } + } + } + boolean pvalid = HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ); + boolean svalid = HigieneSegurancaLogic.isSeveridadeValida( severidade ); + + valoresRisco.setProbabilidade( pvalid && svalid ? probabilidade : null ); + valoresRisco.setSeveridade( pvalid && svalid ? severidade : null ); } - boolean pvalid = HigieneSegurancaLogic.isProbabilidadeValida( probabilidade ); - boolean svalid = HigieneSegurancaLogic.isSeveridadeValida( severidade ); - - valoresRisco.setProbabilidade( pvalid && svalid ? probabilidade : null ); - valoresRisco.setSeveridade( pvalid && svalid ? severidade : null ); + valoresRisco.save(); + firePropertyChange( VALUE_CHANGED, null, valoresRisco ); + refresh(); + setEnabled(); } - valoresRisco.save(); - firePropertyChange( VALUE_CHANGED, null, valoresRisco ); - refresh(); - setEnabled(); + } catch( Exception e ) + { + LeafError.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 2d45c949..7b9a6652 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -30,6 +30,7 @@ import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import leaf.ui.LeafError; import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; @@ -222,42 +223,54 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe private void submit() { - if( relatorio != null ) + try { - relatorio.setIsSubmetido( new Date() ); - relatorio.save(); - refresh(); - setRelatorio( relatorio, false ); + if( relatorio != null ) + { + relatorio.setIsSubmetido( new Date() ); + relatorio.save(); + refresh(); + setRelatorio( relatorio, false ); + } + } catch( Exception e ) + { + LeafError.error(e); } } private void save() { - if( relatorio != null ) + try + { + if( relatorio != null ) + { + relatorio.setData( dataRelatorio.getDate() ); + relatorio.setAvaliacaoInicial( radioInicial.isSelected() ); + // MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); + // if( marcacao != null ) + // { + // MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst(); + // if( tecnico != null ) + // { + // tecnico.setNome( fieldTecnico.getText() ); + // } + // } + } + relatorio.setAcompanhante1( fieldNome1.getText() ); + relatorio.setAcompanhante2( fieldNome2.getText() ); + relatorio.setAcompanhante3( fieldNome3.getText() ); + + relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText()); + relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); + relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText()); + relatorio.save(); + refresh(); + buttonRevert.setEnabled( false ); + buttonSave.setEnabled( false ); + } catch( Exception e ) { - relatorio.setData( dataRelatorio.getDate() ); - relatorio.setAvaliacaoInicial( radioInicial.isSelected() ); -// MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); -// if( marcacao != null ) -// { -// MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst(); -// if( tecnico != null ) -// { -// tecnico.setNome( fieldTecnico.getText() ); -// } -// } + LeafError.error(e); } - relatorio.setAcompanhante1( fieldNome1.getText() ); - relatorio.setAcompanhante2( fieldNome2.getText() ); - relatorio.setAcompanhante3( fieldNome3.getText() ); - - relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText()); - relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); - relatorio.setFuncaoAcompanhante3(fieldFuncao3.getText()); - relatorio.save(); - refresh(); - buttonRevert.setEnabled( false ); - buttonSave.setEnabled( false ); } private void revert() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java index ddb946a1..56cb3583 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java @@ -19,6 +19,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; +import leaf.ui.LeafError; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsRelatorio; @@ -160,31 +161,37 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable private void fillRelatorio( MarcacoesEstabelecimento visita ) { - boolean carregarDadosEstabelecimento = false; - panelRelatorio.setRelatorio( null, carregarDadosEstabelecimento ); - if( visita != null ) + try { - HsRelatorio relatorio = null; - List relatorios = visita.getHsRelatorioArray(); - Date data = null; - for( HsRelatorio current : relatorios ) + boolean carregarDadosEstabelecimento = false; + panelRelatorio.setRelatorio( null, carregarDadosEstabelecimento ); + if( visita != null ) { - boolean newest = data == null ? true : (data.before( current.getData() ) ); - if( newest ) + HsRelatorio relatorio = null; + List relatorios = visita.getHsRelatorioArray(); + Date data = null; + for( HsRelatorio current : relatorios ) { - data = current.getData(); - relatorio = current; + boolean newest = data == null ? true : (data.before( current.getData() ) ); + if( newest ) + { + data = current.getData(); + relatorio = current; + } } + if( relatorio == null ) + { + relatorio = new HsRelatorio(); + relatorio.setData( new Date() ); + relatorio.setToHsMarcacoesEstabelecimento( visita ); + relatorio.save(); + carregarDadosEstabelecimento = true; + } + panelRelatorio.setRelatorio( relatorio, carregarDadosEstabelecimento );; } - if( relatorio == null ) - { - relatorio = new HsRelatorio(); - relatorio.setData( new Date() ); - relatorio.setToHsMarcacoesEstabelecimento( visita ); - relatorio.save(); - carregarDadosEstabelecimento = true; - } - panelRelatorio.setRelatorio( relatorio, carregarDadosEstabelecimento );; + } catch( Exception e ) + { + LeafError.error(e); } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java b/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java index 1746ac9c..b80fff23 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java @@ -1,58 +1,63 @@ package siprp.medicina.exames.logic; -import java.util.ArrayList; import java.util.Collection; import java.util.List; +import leaf.ui.LeafError; import leaf.ui.LeafLogic; import siprp.database.cayenne.objects.Prestadores; import siprp.database.cayenne.objects.TrabalhadoresEcd; import siprp.database.cayenne.providers.MedicinaDAO; -import siprp.medicina.processo.data.TrabalhadoresEcdData; public class RecepcaoExamesLogic extends LeafLogic { - - @Action(isSave=true) + + @Action(isSave = true) public final static String ACTION_SELECT_ANALISADOR = "ACTION_SELECT_ANALISADOR"; - - @Action(isSave=false) + + @Action(isSave = false) public final static String ACTION_SELECT_EXAME = "ACTION_SELECT_EXAME"; - - @Action(isSave=false) + + @Action(isSave = false) public final static String ACTION_FILL_EXAMES = "ACTION_FILL_EXAMES"; - - @Action(isSave=true) + + @Action(isSave = true) public final static String ACTION_RECEBER_EXAMES = "ACTION_RECEBER_EXAMES"; - - @Action(isSave=false) + + @Action(isSave = false) public final static String ACTION_SORT = "ACTION_SORT"; - + public Prestadores currentAnalisador = null; - + private MedicinaDAO dao = new MedicinaDAO(); - - @LeafLogicActionBinding(actions=ACTION_SELECT_ANALISADOR) - public void getExamesForAnalisador(Prestadores analisador) + + @LeafLogicActionBinding(actions = ACTION_SELECT_ANALISADOR) + public void getExamesForAnalisador( Prestadores analisador ) { currentAnalisador = analisador; - if(analisador != null) + if( analisador != null ) { - Collection result = dao.getPendingExamesForAnalisador(currentAnalisador); + Collection result = dao.getPendingExamesForAnalisador( currentAnalisador ); runAction( ACTION_FILL_EXAMES, result ); } } - - @LeafLogicActionBinding(actions=ACTION_RECEBER_EXAMES) - public void receberExames(List ecds) + + @LeafLogicActionBinding(actions = ACTION_RECEBER_EXAMES) + public void receberExames( List ecds ) { - if(ecds != null) + try { - for( TrabalhadoresEcd ecd : ecds ) + if( ecds != null ) { - dao.saveObject( ecd ); + for( TrabalhadoresEcd ecd : ecds ) + { + ecd.save(); + } } + } catch( Exception e ) + { + LeafError.error( e ); } } - + } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java index ab4a5dac..23b02801 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java @@ -9,18 +9,8 @@ package siprp.medicina.prestadores; -import com.evolute.utils.Singleton; -import static com.evolute.utils.strings.UnicodeLatin1Map.*; -import com.evolute.utils.data.IDObject; -import com.evolute.utils.dataui.ComponentController; -import com.evolute.utils.dataui.ComponentsHashtable; -import com.evolute.utils.dataui.JDOControllable; -import com.evolute.utils.dataui.JTextComponentPlainFillerSaver; -import com.evolute.utils.jdo.JDOProvider; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.panel.CheckBoxPanel; -import com.evolute.utils.ui.search.SearchDialog; -import com.evolute.utils.ui.window.EditorWindow; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; +import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -35,6 +25,7 @@ import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Vector; + import javax.swing.BorderFactory; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -45,6 +36,8 @@ import javax.swing.JSeparator; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; + +import leaf.ui.LeafError; import siprp.clientes.ClientesDataProvider; import siprp.clientes.ContactoPanel; import siprp.data.ContactoData; @@ -53,6 +46,18 @@ import siprp.database.cayenne.objects.PrtGruposProtocolo; import siprp.database.cayenne.providers.MedicinaDAO; import siprp.medicina.prestadores.data.PrestadoresData; +import com.evolute.utils.Singleton; +import com.evolute.utils.data.IDObject; +import com.evolute.utils.dataui.ComponentController; +import com.evolute.utils.dataui.ComponentsHashtable; +import com.evolute.utils.dataui.JDOControllable; +import com.evolute.utils.dataui.JTextComponentPlainFillerSaver; +import com.evolute.utils.jdo.JDOProvider; +import com.evolute.utils.ui.DialogException; +import com.evolute.utils.ui.panel.CheckBoxPanel; +import com.evolute.utils.ui.search.SearchDialog; +import com.evolute.utils.ui.window.EditorWindow; + /** * * @author fpalma @@ -74,8 +79,8 @@ public class PrestadoresWindow extends EditorWindow protected JTextField localidadeText; protected ContactoPanel contactoPanel; protected JTextField contribuinteText; - - private final JLabel labelObservacoes = new JLabel("Observa"+ccedil+otilde+"es"); + + private final JLabel labelObservacoes = new JLabel( "Observa" + ccedil + otilde + "es" ); private final JTextArea textObservacoes = new JTextArea(); protected PrestadoresDataProvider provider; @@ -119,13 +124,13 @@ public class PrestadoresWindow extends EditorWindow private void setupComponents() { setTitle( TITLE ); - setSize( 800, 600); + setSize( 800, 600 ); tabbedPane.addTab( "Prestadores", prestadoresPanel ); tabbedPane.addTab( "Analisadores", analisadoresPanel ); setupAnalisadoresTab(); setupPrestadoresTab(); -// pack(); + // pack(); } private void setupPrestadoresTab() @@ -175,17 +180,7 @@ public class PrestadoresWindow extends EditorWindow TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL }; double rows[] = new double[] { - TableLayout.MINIMUM, - TableLayout.MINIMUM, - TableLayout.MINIMUM, - TableLayout.FILL, - TableLayout.PREFERRED, - TableLayout.PREFERRED, - TableLayout.MINIMUM, - TableLayout.MINIMUM, - TableLayout.MINIMUM, - TableLayout.MINIMUM, - TableLayout.FILL + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL }; TableLayout tableLayout = new TableLayout( cols, rows ); prestadoresPanel.setLayout( tableLayout ); @@ -216,7 +211,7 @@ public class PrestadoresWindow extends EditorWindow prestadoresPanel.add( contribuinteLabel, new TableLayoutConstraints( 0, 8 ) ); prestadoresPanel.add( contribuinteText, new TableLayoutConstraints( 1, 8 ) ); prestadoresPanel.add( labelObservacoes, new TableLayoutConstraints( 0, 9 ) ); - prestadoresPanel.add( textObservacoes, new TableLayoutConstraints( 0, 10,3,10 ) ); + prestadoresPanel.add( textObservacoes, new TableLayoutConstraints( 0, 10, 3, 10 ) ); } catch( Exception e ) { e.printStackTrace(); @@ -414,19 +409,25 @@ public class PrestadoresWindow extends EditorWindow @Override public void itemStateChanged( ItemEvent itemEvent ) { - if( ItemEvent.SELECTED == itemEvent.getStateChange() ) + try { - JComboBox combo = (JComboBox) itemEvent.getSource(); - for( PrtGruposProtocolo grupo : mapComboBox.keySet() ) + if( ItemEvent.SELECTED == itemEvent.getStateChange() ) { - if( mapComboBox.get( grupo ).equals( combo ) ) + JComboBox combo = (JComboBox) itemEvent.getSource(); + for( PrtGruposProtocolo grupo : mapComboBox.keySet() ) { - Prestadores analisador = (Prestadores) combo.getSelectedItem(); - grupo.setToAnalisador( Prestadores.prestadorNulo.equals( analisador ) ? null : analisador ); - medicinaCayenneDAO.saveObject( grupo ); - shout( "Tipo de ECD: " + grupo.getDescricao() + " -> Analisador: " + analisador.getNome() + " [guardado]" ); + if( mapComboBox.get( grupo ).equals( combo ) ) + { + Prestadores analisador = (Prestadores) combo.getSelectedItem(); + grupo.setToAnalisador( Prestadores.prestadorNulo.equals( analisador ) ? null : analisador ); + grupo.save(); + shout( "Tipo de ECD: " + grupo.getDescricao() + " -> Analisador: " + analisador.getNome() + " [guardado]" ); + } } } + } catch( Exception e ) + { + LeafError.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java index cd8d42ad..f485a678 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java @@ -5,6 +5,7 @@ import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; +import leaf.ui.LeafError; import leaf.ui.LeafLogic; import leaf.ui.LeafWindow.LeafObject; import siprp.MedicinaConstants; @@ -158,13 +159,13 @@ public class MedicinaProcessoLogic extends LeafLogic @Action(isSave = false) public static final String APAGAR_CONSULTA = "APAGAR_CONSULTA"; - + @Action(isSave = false) public static final String APAGAR_CONSULTA_MARCACAO = "APAGAR_CONSULTA_MARCACAO"; @Action(isSave = false) public static final String APAGAR_EXAME = "APAGAR_EXAME"; - + @Action(isSave = false) public static final String APAGAR_EXAME_MARCACAO = "APAGAR_EXAME_MARCACAO"; @@ -225,7 +226,9 @@ public class MedicinaProcessoLogic extends LeafLogic }) public TrabalhadoresConsultas currentConsulta = null; - @LeafObject(useWith = { SAVE_CONSULTA_MARCACAO, APAGAR_CONSULTA_MARCACAO } ) + @LeafObject(useWith = { + SAVE_CONSULTA_MARCACAO, APAGAR_CONSULTA_MARCACAO + }) public TrabalhadoresConsultasDatas currentConsultaMarcacao = null; @LeafObject(useWith = SAVE_CONSULTA_MARCACAO_EMAIL) @@ -604,19 +607,25 @@ public class MedicinaProcessoLogic extends LeafLogic @Override public void exameSaved( Integer trabalhadorID, Integer exameID ) { - if( trabalhadorID != null && exameID != null ) + try { - if( trabalhadorID.equals( currentTrabalhador.getId() ) ) + if( trabalhadorID != null && exameID != null ) { - currentFichaExameID = exameID; - Exames exame = provider.getExameForExameID( currentFichaExameID ); - if( exame != null ) + if( trabalhadorID.equals( currentTrabalhador.getId() ) ) { - currentFicha.setToExames( exame ); - provider.saveObject( currentFicha ); - runAction( REFRESH ); + currentFichaExameID = exameID; + Exames exame = provider.getExameForExameID( currentFichaExameID ); + if( exame != null ) + { + currentFicha.setToExames( exame ); + currentFicha.save(); + runAction( REFRESH ); + } } } + } catch( Exception e ) + { + LeafError.error( e ); } } } ); @@ -626,7 +635,7 @@ public class MedicinaProcessoLogic extends LeafLogic e.printStackTrace(); } } - + private Date getUltimaConsultaMarcacaoDateForProcesso() { Date result = null; @@ -635,15 +644,15 @@ public class MedicinaProcessoLogic extends LeafLogic List consultas = currentProcesso.getTrabalhadoresConsultasArray(); for( TrabalhadoresConsultas consulta : consultas ) { - if( new Integer(MedicinaConstants.ESTADO_REALIZADO).equals( consulta.getEstado() )) + if( new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( consulta.getEstado() ) ) { List marcacoes = consulta.getTrabalhadoresConsultasDatasArray(); for( TrabalhadoresConsultasDatas marcacao : marcacoes ) { - if( new Integer(MedicinaConstants.ESTADO_REALIZADO).equals( marcacao.getEstado() )) + if( new Integer( MedicinaConstants.ESTADO_REALIZADO ).equals( marcacao.getEstado() ) ) { Date marcacaoDate = marcacao.getData(); - if( marcacaoDate != null && (result == null || result.before( marcacaoDate ) ) ) + if( marcacaoDate != null && (result == null || result.before( marcacaoDate )) ) { result = marcacaoDate; } @@ -784,8 +793,14 @@ public class MedicinaProcessoLogic extends LeafLogic }) public void saveObject( BaseObject object ) { - provider.saveObject( object ); - runActionLater( REFRESH ); + try + { + object.save(); + runActionLater( REFRESH ); + } catch( Exception e ) + { + LeafError.error(e); + } } @LeafLogicActionBinding(actions = { @@ -806,67 +821,79 @@ public class MedicinaProcessoLogic extends LeafLogic private void apagarConsulta( TrabalhadoresConsultas consulta ) { - List marcacoes = consulta.getTrabalhadoresConsultasDatasArray(); - if( marcacoes != null ) + try { - for( TrabalhadoresConsultasDatas marcacao : marcacoes ) + List marcacoes = consulta.getTrabalhadoresConsultasDatasArray(); + if( marcacoes != null ) { - List emails = marcacao.getTrabalhadoresConsultasDatasEmailsArray(); - if( emails != null ) + for( TrabalhadoresConsultasDatas marcacao : marcacoes ) { - for( TrabalhadoresConsultasDatasEmails email : emails ) + List emails = marcacao.getTrabalhadoresConsultasDatasEmailsArray(); + if( emails != null ) { - provider.deleteObject( email ); + for( TrabalhadoresConsultasDatasEmails email : emails ) + { + email.delete(); + } } - } - List observacoes = marcacao.getTrabalhadoresConsultasDatasObservacoesArray(); - if( observacoes != null ) - { - for( TrabalhadoresConsultasDatasObservacoes observacao : observacoes ) + List observacoes = marcacao.getTrabalhadoresConsultasDatasObservacoesArray(); + if( observacoes != null ) { - provider.deleteObject( observacao ); + for( TrabalhadoresConsultasDatasObservacoes observacao : observacoes ) + { + observacao.delete(); + } } + marcacao.delete(); } - provider.deleteObject( marcacao ); + consulta.delete(); } - provider.deleteObject( consulta ); + } catch( Exception e ) + { + LeafError.error(e); } } private void apagarExame( TrabalhadoresEcds exame ) { - List marcacoes = exame.getTrabalhadoresEcdsDatasArray(); - if( marcacoes != null ) + try { - for( TrabalhadoresEcdsDatas marcacao : marcacoes ) + List marcacoes = exame.getTrabalhadoresEcdsDatasArray(); + if( marcacoes != null ) { - List ecds = marcacao.getTrabalhadoresEcdArray(); - if( ecds != null ) + for( TrabalhadoresEcdsDatas marcacao : marcacoes ) { - for( TrabalhadoresEcd ecd : ecds ) + List ecds = marcacao.getTrabalhadoresEcdArray(); + if( ecds != null ) { - provider.deleteObject( ecd ); + for( TrabalhadoresEcd ecd : ecds ) + { + ecd.delete(); + } } - } - List emails = marcacao.getTrabalhadoresEcdsDatasEmailsArray(); - if( emails != null ) - { - for( TrabalhadoresEcdsDatasEmails email : emails ) + List emails = marcacao.getTrabalhadoresEcdsDatasEmailsArray(); + if( emails != null ) { - provider.deleteObject( email ); + for( TrabalhadoresEcdsDatasEmails email : emails ) + { + email.delete(); + } } - } - List observacoes = marcacao.getTrabalhadoresEcdsDatasObservacoesArray(); - if( observacoes != null ) - { - for( TrabalhadoresEcdsDatasObservacoes observacao : observacoes ) + List observacoes = marcacao.getTrabalhadoresEcdsDatasObservacoesArray(); + if( observacoes != null ) { - provider.deleteObject( observacao ); + for( TrabalhadoresEcdsDatasObservacoes observacao : observacoes ) + { + observacao.delete(); + } } + marcacao.delete(); } - provider.deleteObject( marcacao ); + exame.delete(); } - provider.deleteObject( exame ); + } catch( Exception e ) + { + LeafError.error(e); } } diff --git a/trunk/common/src/SIPRPMap.map.xml b/trunk/common/src/SIPRPMap.map.xml index 7494a342..bdcf4f96 100644 --- a/trunk/common/src/SIPRPMap.map.xml +++ b/trunk/common/src/SIPRPMap.map.xml @@ -1864,6 +1864,7 @@ + diff --git a/trunk/common/src/leaf/ui/LeafError.java b/trunk/common/src/leaf/ui/LeafError.java new file mode 100644 index 00000000..947c47a9 --- /dev/null +++ b/trunk/common/src/leaf/ui/LeafError.java @@ -0,0 +1,20 @@ +package leaf.ui; + +import javax.swing.JOptionPane; + +import com.evolute.utils.error.ErrorLogger; + +public class LeafError +{ + + public static void error( Throwable e ) + { + if( e != null ) + { + ErrorLogger.logException( e ); + e.printStackTrace(System.out); + JOptionPane.showMessageDialog( null, "Detalhes: \n"+e.getMessage(), "Erro!", JOptionPane.ERROR_MESSAGE ); + } + } + +} diff --git a/trunk/common/src/leaf/ui/TreeInserterDialog.java b/trunk/common/src/leaf/ui/TreeInserterDialog.java index e713dfa0..64e8d6b3 100644 --- a/trunk/common/src/leaf/ui/TreeInserterDialog.java +++ b/trunk/common/src/leaf/ui/TreeInserterDialog.java @@ -29,9 +29,9 @@ public class TreeInserterDialog extends JDialog private static final long serialVersionUID = 1L; - private static final Dimension allDimension = new Dimension(300,500); + private static final Dimension ALL_DIMENSION = new Dimension(300,500); - private static final Dimension newDimension = new Dimension(300,400); + private static final Dimension NEW_DIMENSION = new Dimension(300,400); private static final String ICON_NAME_ADD = "leaf/ui/icons/add.png"; @@ -98,12 +98,12 @@ public class TreeInserterDialog extends JDialog allScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); newScroll.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); newScroll.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - allScroll.setPreferredSize( allDimension ); - newScroll.setPreferredSize( newDimension ); + allScroll.setPreferredSize( ALL_DIMENSION ); + newScroll.setPreferredSize( NEW_DIMENSION ); buttonAdd.setToolTipText( "Adicionar" ); buttonRemove.setToolTipText( "Remover" ); - buttonAdd.setMargin( new Insets(4,4,4,4) ); - buttonRemove.setMargin( new Insets(4,4,4,4) ); + buttonAdd.setMargin( new Insets(0,0,0,0) ); + buttonRemove.setMargin( new Insets(0,0,0,0) ); } private void setupLayout() diff --git a/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java b/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java index d0f3afe8..f8ea4cbf 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java +++ b/trunk/common/src/siprp/database/cayenne/objects/BaseObject.java @@ -6,7 +6,7 @@ import java.util.Locale; import org.apache.cayenne.CayenneDataObject; import org.apache.cayenne.PersistenceState; -import siprp.database.cayenne.providers.MedicinaDAO; +import siprp.database.cayenne.providers.MainDAO; import com.evolute.utils.strings.UnicodeChecker; @@ -19,7 +19,7 @@ public class BaseObject extends CayenneDataObject private static final long serialVersionUID = 1L; - protected static MedicinaDAO medicinaProvider = new MedicinaDAO(); + protected static MainDAO dao = new MainDAO(); protected static final DateFormat sdf = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); @@ -45,16 +45,29 @@ public class BaseObject extends CayenneDataObject return getPersistenceState() == PersistenceState.MODIFIED; } - public void save() + public void commit() { - medicinaProvider.saveObject( this ); - medicinaProvider.commit(); + dao.commit(); } - public void delete() + public void rollback() { - medicinaProvider.deleteObject( this ); - medicinaProvider.commit(); + dao.rollback(); + } + + public void save() throws Exception + { + if( isTransient() ) + { + dao.getContext().registerNewObject( this ); + } + commit(); + } + + public void delete() throws Exception + { + dao.getContext().deleteObject( this ); + commit(); } protected String parseToUnicode( String string ) diff --git a/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java b/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java index 4ff1a772..af4535e1 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java +++ b/trunk/common/src/siprp/database/cayenne/objects/HsRiscoMedida.java @@ -8,7 +8,7 @@ public class HsRiscoMedida extends _HsRiscoMedida { @Override public String toString() { - String d = getToHsMedida().getRequesitosLegais(); + String d = getToHsMedida() == null ? null : getToHsMedida().getRequesitosLegais(); return d == null ? " " : d.substring( 0, Math.min( 20, d.length() ) ) + "..."; } } diff --git a/trunk/common/src/siprp/database/cayenne/objects/Prestadores.java b/trunk/common/src/siprp/database/cayenne/objects/Prestadores.java index 4ec279ab..991e85fe 100755 --- a/trunk/common/src/siprp/database/cayenne/objects/Prestadores.java +++ b/trunk/common/src/siprp/database/cayenne/objects/Prestadores.java @@ -3,8 +3,7 @@ package siprp.database.cayenne.objects; import java.util.List; import siprp.database.cayenne.objects.auto._Prestadores; - -import com.evolute.utils.strings.UnicodeChecker; +import siprp.database.cayenne.providers.MedicinaDAO; public class Prestadores extends _Prestadores { @@ -59,7 +58,7 @@ public class Prestadores extends _Prestadores { public static List getAllPrestadores() { - List result = medicinaProvider.getAllPrestadores(); + List result = new MedicinaDAO().getAllPrestadores(); result.add( 0, prestadorNulo); return result; } diff --git a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRisco.java b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRisco.java index 91e02770..1d6cab04 100644 --- a/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRisco.java +++ b/trunk/common/src/siprp/database/cayenne/objects/auto/_HsRisco.java @@ -5,6 +5,7 @@ import java.util.List; import siprp.database.cayenne.objects.BaseObject; import siprp.database.cayenne.objects.HsPostoRisco; +import siprp.database.cayenne.objects.HsRiscoEmpresa; import siprp.database.cayenne.objects.HsRiscoMedida; import siprp.database.cayenne.objects.HsRiscoTema; @@ -19,6 +20,7 @@ public abstract class _HsRisco extends BaseObject { public static final String DELETED_DATE_PROPERTY = "deletedDate"; public static final String DESCRIPTION_PROPERTY = "description"; public static final String HS_POSTO_RISCO_ARRAY_PROPERTY = "hsPostoRiscoArray"; + public static final String HS_RISCO_EMPRESA_ARRAY_PROPERTY = "hsRiscoEmpresaArray"; public static final String HS_RISCO_MEDIDA_ARRAY_PROPERTY = "hsRiscoMedidaArray"; public static final String TO_HS_RISCO_TEMA_PROPERTY = "toHsRiscoTema"; @@ -50,6 +52,18 @@ public abstract class _HsRisco extends BaseObject { } + public void addToHsRiscoEmpresaArray(HsRiscoEmpresa obj) { + addToManyTarget("hsRiscoEmpresaArray", obj, true); + } + public void removeFromHsRiscoEmpresaArray(HsRiscoEmpresa obj) { + removeToManyTarget("hsRiscoEmpresaArray", obj, true); + } + @SuppressWarnings("unchecked") + public List getHsRiscoEmpresaArray() { + return (List)readProperty("hsRiscoEmpresaArray"); + } + + public void addToHsRiscoMedidaArray(HsRiscoMedida obj) { addToManyTarget("hsRiscoMedidaArray", obj, true); } diff --git a/trunk/common/src/siprp/database/cayenne/providers/MainDAO.java b/trunk/common/src/siprp/database/cayenne/providers/MainDAO.java index 89593c21..adb5dcc7 100755 --- a/trunk/common/src/siprp/database/cayenne/providers/MainDAO.java +++ b/trunk/common/src/siprp/database/cayenne/providers/MainDAO.java @@ -2,8 +2,6 @@ package siprp.database.cayenne.providers; import org.apache.cayenne.access.DataContext; -import siprp.database.cayenne.objects.BaseObject; - public class MainDAO { protected static DataContext context = null; @@ -21,31 +19,15 @@ public class MainDAO context.commitChanges(); } - public BaseObject saveObject( BaseObject object ) - { - if( object != null ) - { - if( object.isTransient() ) - { - context.registerNewObject( object ); - } - context.commitChanges(); - } - return object; - } - - public void deleteObject( BaseObject object ) - { - if( object != null ) - { - context.deleteObject( object ); - context.commitChanges(); - } - } - public void rollback() { context.rollbackChanges(); context.unregisterObjects( context.uncommittedObjects() ); } + + public DataContext getContext() + { + return context; + } + } diff --git a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java index 882eaea4..4f95c427 100644 --- a/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java +++ b/trunk/common/src/siprp/database/cayenne/providers/PlanoActuacaoDAO.java @@ -40,6 +40,7 @@ public class PlanoActuacaoDAO extends MainDAO { SelectQuery query = new SelectQuery( HsRiscoTema.class ); query.andQualifier( ExpressionFactory.matchExp( HsRiscoTema.DELETED_DATE_PROPERTY, null ) ); + query.addOrdering( HsRiscoTema.DESCRIPTION_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 2fd66eee..d63f3eb6 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -5,6 +5,7 @@ import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; +import leaf.ui.LeafError; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Estabelecimentos; @@ -169,22 +170,28 @@ public class HigieneSegurancaLogic public static void reverterRelatorio( HsRelatorio relatorio ) { - if(relatorio != null) + try { - List areas = relatorio.getHsRelatorioArea(); - int areasSize = areas == null ? 0 : areas.size(); - for( int i = 0; i < areasSize; ++i ) - { - areas.get( 0 ).delete(); - } - relatorio.save(); - Estabelecimentos estabelecimento = relatorio.getToHsMarcacoesEstabelecimento() == null ? null : relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos(); - if( estabelecimento != null ) - { - List postos = estabelecimento.getHsPostoEstabelecimentoArray(); - reverterPostos(relatorio,postos); + if(relatorio != null) + { + List areas = relatorio.getHsRelatorioArea(); + int areasSize = areas == null ? 0 : areas.size(); + for( int i = 0; i < areasSize; ++i ) + { + areas.get( 0 ).delete(); + } relatorio.save(); - } + Estabelecimentos estabelecimento = relatorio.getToHsMarcacoesEstabelecimento() == null ? null : relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos(); + if( estabelecimento != null ) + { + List postos = estabelecimento.getHsPostoEstabelecimentoArray(); + reverterPostos(relatorio,postos); + relatorio.save(); + } + } + } catch( Exception e ) + { + LeafError.error(e); } }