From 5b1d81e4338a467879324cb5b297cfe59dc30660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Tue, 3 Mar 2009 13:27:20 +0000 Subject: [PATCH] Higiene e seguranca: pedido de confirmacao a cada remocao gestao de 'normalizacao' alterada todo o stack das excepccoes e' agora mostrado ao utilizador git-svn-id: https://svn.coded.pt/svn/SIPRP@950 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../siprp/higiene/gestao/EmpresaPanel.java | 4 +- .../gestao/email/AdicionarEmailsPanel.java | 18 +- .../AdicionarEquipamentosPanel.java | 20 ++- .../equipamentos/GerirEquipamentosPanel.java | 20 ++- .../legislacao/AdicionarLegislacaoPanel.java | 10 +- .../legislacao/GerirLegislacaoPanel.java | 24 +-- .../AdicionarNormalizacaoPanel.java | 10 +- .../normalizacao/GerirNormalizacaoPanel.java | 160 ++++++++++++------ .../gestao/postos/AdicionarAreasPanel.java | 11 +- .../gestao/postos/GerirAreasPanel.java | 18 +- .../gestao/riscos/AdicionarRiscosPanel.java | 8 +- .../gestao/riscos/GerirMedidaPanel.java | 4 +- .../gestao/riscos/GerirRiscosPanel.java | 24 +-- .../relatorio/GerirMedidaRelatorioPanel.java | 8 +- .../relatorio/GerirMedidasRelatorioPanel.java | 6 +- .../relatorio/GerirValoresRiscoPanel.java | 4 +- .../higiene/relatorio/PanelRelatorio.java | 8 +- .../RelatorioHigieneSegurancaWindow.java | 4 +- .../exames/logic/RecepcaoExamesLogic.java | 4 +- .../prestadores/PrestadoresWindow.java | 4 +- .../processo/logic/MedicinaProcessoLogic.java | 10 +- trunk/common/src/leaf/ui/LeafDialog.java | 39 +++++ trunk/common/src/leaf/ui/LeafError.java | 20 --- .../siprp/logic/HigieneSegurancaLogic.java | 11 +- 24 files changed, 277 insertions(+), 172 deletions(-) create mode 100644 trunk/common/src/leaf/ui/LeafDialog.java delete mode 100644 trunk/common/src/leaf/ui/LeafError.java diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java index 15a148b3..55e0b0fc 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java @@ -13,7 +13,7 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTabbedPane; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.providers.MedicinaDAO; @@ -104,7 +104,7 @@ public class EmpresaPanel extends JPanel } catch( Exception ex ) { - LeafError.error( ex ); + LeafDialog.error( ex ); } } } ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java index 73365d95..23cdf30c 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java @@ -1,10 +1,13 @@ package siprp.higiene.gestao.email; +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; + import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsEmail; @@ -49,10 +52,17 @@ public class AdicionarEmailsPanel extends AdicionarPanel } catch (Exception e) { - LeafError.error( e ); + LeafDialog.error( e ); } } + private boolean confirmDelete() + { + return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( + null, "Tem a certeza que deseja remover o email seleccionado?", + "Confirmar remo" + ccedil + atilde + "o", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null ); + } @Override protected void rem() @@ -63,7 +73,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel if( path != null ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); - if( node != null ) + if( node != null && confirmDelete() ) { Object obj = node.getUserObject(); if( obj instanceof HsEmailEstabelecimento ) @@ -76,7 +86,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel } catch (Exception e) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java index 37304f42..eaa52011 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/AdicionarEquipamentosPanel.java @@ -1,11 +1,14 @@ package siprp.higiene.gestao.equipamentos; +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTree; @@ -17,7 +20,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; @@ -137,6 +140,7 @@ public class AdicionarEquipamentosPanel extends JPanel { if( relatorio != null ) { + DefaultMutableTreeNode allEquipamentos = HigieneSegurancaLogic.getEquipamentosTree(); TreeInserterDialog dialog = new TreeInserterDialog("Adicionar equipamento",allEquipamentos); DefaultMutableTreeNode result = dialog.getResult(); @@ -161,7 +165,7 @@ public class AdicionarEquipamentosPanel extends JPanel } catch (Exception e) { - LeafError.error( e ); + LeafDialog.error( e ); } } } @@ -178,7 +182,7 @@ public class AdicionarEquipamentosPanel extends JPanel DefaultMutableTreeNode node = path == null ? null : (DefaultMutableTreeNode)path.getLastPathComponent(); Object obj = node.getUserObject(); HsRelatorioEquipamento rel = obj == null ? null : ((obj instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) obj : null); - if( rel != null ) + if( rel != null && confirmDelete() ) { rel.delete(); refresh(); @@ -186,9 +190,17 @@ public class AdicionarEquipamentosPanel extends JPanel } catch (Exception e) { - LeafError.error( e ); + LeafDialog.error( e ); } } + + private boolean confirmDelete() + { + return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( + null, "Tem a certeza que deseja remover o equipamento seleccionado?", + "Confirmar remo" + ccedil + atilde + "o", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null ); + } private void setEnabled() { diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java index 848665ce..12857d2c 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java @@ -1,5 +1,7 @@ package siprp.higiene.gestao.equipamentos; +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -25,7 +27,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafUIConstants; import leaf.ui.TreeTools; @@ -154,7 +156,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -163,7 +165,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea try { HsEquipamento equipamento = getSelected(); - if( equipamento != null ) + if( equipamento != null && confirmDelete() ) { equipamento.setDeletedDate( new Date() ); equipamento.save(); @@ -172,10 +174,18 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } + private boolean confirmDelete() + { + return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( + null, "Tem a certeza que deseja remover o equipamento seleccionado?", + "Confirmar remo" + ccedil + atilde + "o", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null ); + } + private void save() { try @@ -192,7 +202,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java index e6fd61e3..c6ad2ec9 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java @@ -6,7 +6,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Empresas; @@ -115,7 +115,7 @@ private static final long serialVersionUID = 1L; } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -154,11 +154,11 @@ private static final long serialVersionUID = 1L; Object obj = node.getUserObject(); if( obj != null && (obj instanceof HsLegislacao) ) { - if( empresa != null ) + if( empresa != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) ) { removeFromEmpresa( ((HsLegislacao) obj ) ); } - else if( estabelecimento != null ) + else if( estabelecimento != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) ) { removeFromEstabelecimento( ((HsLegislacao) obj )); } @@ -168,7 +168,7 @@ private static final long serialVersionUID = 1L; } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java index 2000b3b4..06622d69 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java @@ -28,7 +28,7 @@ import javax.swing.tree.TreeSelectionModel; import leaf.data.Validator; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafTextAreaEditor; import leaf.ui.LeafUIConstants; @@ -266,7 +266,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants reload(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } } ); @@ -342,7 +342,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -362,7 +362,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -370,7 +370,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { try { - if( selectedCategoria != null ) + if( selectedCategoria != null && LeafDialog.confirmDelete( false, false, "categoria" ) ) { selectedCategoria.setDeletedDate( new Date() ); selectedCategoria.save(); @@ -378,7 +378,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -396,7 +396,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -404,7 +404,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { try { - if( selectedLegislacaoEspecifica != null ) + if( selectedLegislacaoEspecifica != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) ) { selectedLegislacaoEspecifica.setDeletedDate( new Date() ); selectedLegislacaoEspecifica.save(); @@ -412,7 +412,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -420,7 +420,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { try { - if( selectedLegislacaoGeral != null ) + if( selectedLegislacaoGeral != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) ) { selectedLegislacaoGeral.setDeletedDate( new Date() ); selectedLegislacaoGeral.save(); @@ -428,7 +428,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -442,7 +442,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants reload(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java index 2b126a30..84ac94df 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java @@ -6,7 +6,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Empresas; @@ -118,7 +118,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -170,13 +170,13 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } private void removeFromEmpresa( HsNormalizacao normalizacao ) throws Exception { - if( normalizacao != null && empresa != null ) + if( normalizacao != null && empresa != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) ) { for( HsNormalizacaoEmpresa rel : empresa.getHsNormalizacaoEmpresaArray() ) { @@ -191,7 +191,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel private void removeFromEstabelecimento( HsNormalizacao normalizacao ) throws Exception { - if( normalizacao != null && estabelecimento != null ) + if( normalizacao != null && estabelecimento != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) ) { for( HsNormalizacaoEstabelecimento rel : estabelecimento.getHsNormalizacaoEstabelecimentoArray() ) { diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java index 0989c0c3..e4882833 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java @@ -19,10 +19,14 @@ import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JTree; +import javax.swing.event.CaretEvent; +import javax.swing.event.CaretListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; +import javax.swing.text.AbstractDocument.LeafElement; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; @@ -30,7 +34,7 @@ import javax.swing.tree.TreeSelectionModel; import leaf.data.Validator; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafTextAreaEditor; import leaf.ui.LeafUIConstants; @@ -38,7 +42,7 @@ import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsNormalizacao; import siprp.logic.HigieneSegurancaLogic; -public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants +public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, CaretListener { private static final long serialVersionUID = 1L; @@ -62,6 +66,10 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants private final LeafButton buttonInternacionalEditar = LeafIconButton.createDefaultEditButton(); private final LeafButton buttonInternacionalRemover = LeafIconButton.createDefaultRemoveButton(); + + private final LeafButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); + + private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT ); private final DefaultMutableTreeNode rootPortuguesa = new DefaultMutableTreeNode(); @@ -87,14 +95,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants private final JTextField textCodigo = new JTextField(10); - private final LeafTextAreaEditor textDescricao = new LeafTextAreaEditor( new Validator() - { - @Override - public boolean isValid( String object ) - { - return true; - } - } ); + private final JTextArea textAreaDescricao = new JTextArea(); public GerirNormalizacaoPanel() { @@ -118,6 +119,9 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants treePortuguesa.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION ); textCodigo.setEnabled( false ); + + buttonSave.setEnabled( false ); + buttonRevert.setEnabled( false ); } private void startupLayout() @@ -155,9 +159,9 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants panelButtonsInternacional.setLayout( layout ); layout = new TableLayout( new double[] { - TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL + TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM }, new double[] { - TableLayout.MINIMUM, TableLayout.FILL + TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } ); ((TableLayout) layout).setHGap( 5 ); ((TableLayout) layout).setVGap( 5 ); @@ -180,9 +184,11 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants panelInternacional.add( panelButtonsInternacional, new TableLayoutConstraints( 0, 0 ) ); panelInternacional.add( scrollInternacional, new TableLayoutConstraints( 0, 1, 1, 1 ) ); - panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 0 ) ); - panelData.add( textCodigo, new TableLayoutConstraints( 1, 0 ) ); - panelData.add( textDescricao, new TableLayoutConstraints( 0, 1, 2, 1 ) ); + panelData.add( buttonSave, new TableLayoutConstraints( 3, 0 ) ); + panelData.add( buttonRevert, new TableLayoutConstraints( 4, 0 ) ); + panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 1 ) ); + panelData.add( textCodigo, new TableLayoutConstraints( 1, 1 ) ); + panelData.add( textAreaDescricao, new TableLayoutConstraints( 0, 2, 4, 2 ) ); this.add( panelPortuguesa, new TableLayoutConstraints( 0, 0 ) ); this.add( panelInternacional, new TableLayoutConstraints( 0, 1 ) ); @@ -247,31 +253,8 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants setEnable(); } } ); - textDescricao.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() - { - @Override - public void propertyChange( PropertyChangeEvent evt ) - { - try - { - String newValue = (String) evt.getNewValue(); - if( selectedInternacional != null ) - { - selectedInternacional.setDescricao( newValue ); - selectedInternacional.save(); - } - else if( selectedPortuguesa != null ) - { - selectedPortuguesa.setDescricao( newValue ); - selectedPortuguesa.save(); - } - reload(); - } catch( Exception e ) - { - LeafError.error( e ); - } - } - } ); + textCodigo.addCaretListener( this ); + textAreaDescricao.addCaretListener( this ); buttonPortuguesaCriar.addActionListener( new ActionListener() { @Override @@ -320,6 +303,61 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants removerInternacional(); } } ); + buttonSave.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + try + { + save(); + } catch( Exception e1 ) + { + LeafDialog.error( e1 ); + } + } + } ); + buttonRevert.addActionListener( new ActionListener() + { + @Override + public void actionPerformed( ActionEvent e ) + { + if( selectedInternacional != null ) + { + textAreaDescricao.setText( selectedInternacional.getDescricao() ); + textAreaDescricao.setEnabled( true ); + textCodigo.setText( selectedInternacional.getCodigo() ); + } + else if( selectedPortuguesa != null ) + { + textAreaDescricao.setText( selectedPortuguesa.getDescricao() ); + textAreaDescricao.setEnabled( true ); + textCodigo.setText( selectedPortuguesa.getCodigo() ); + } + else + { + textAreaDescricao.setText( "" ); + textCodigo.setText( "" ); + } + } + } ); + } + + private void save() throws Exception + { + if( selectedInternacional != null ) + { + selectedInternacional.setCodigo( textCodigo.getText() ); + selectedInternacional.setDescricao( textAreaDescricao.getText() ); + selectedInternacional.save(); + } + else if( selectedPortuguesa != null ) + { + selectedPortuguesa.setCodigo( textCodigo.getText() ); + selectedPortuguesa.setDescricao( textAreaDescricao.getText() ); + selectedPortuguesa.save(); + } + reload(); } private String getCodigoForNormalizacao( boolean criar, boolean portuguesa ) @@ -362,7 +400,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -382,7 +420,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -390,7 +428,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants { try { - if( selectedPortuguesa != null ) + if( selectedPortuguesa != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) ) { selectedPortuguesa.setDeletedDate( new Date() ); selectedPortuguesa.save(); @@ -398,7 +436,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -418,7 +456,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -438,7 +476,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -446,15 +484,16 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants { try { - if( selectedInternacional != null ) + if( selectedInternacional != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) ) { selectedInternacional.setDeletedDate( new Date() ); selectedInternacional.save(); reload(); } - } catch( Exception e ) + } + catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -476,22 +515,26 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants buttonPortuguesaRemover.setEnabled( false ); buttonInternacionalEditar.setEnabled( false ); buttonPortuguesaEditar.setEnabled( false ); - textDescricao.setEnabled( false ); + textAreaDescricao.setEnabled( false ); + buttonSave.setEnabled( false ); + buttonRevert.setEnabled( false ); if( selectedInternacional != null ) { - textDescricao.setValue( selectedInternacional.getDescricao() ); - textDescricao.setEnabled( true ); + textAreaDescricao.setText( selectedInternacional.getDescricao() ); + textAreaDescricao.setEnabled( true ); textCodigo.setText( selectedInternacional.getCodigo() ); + textCodigo.setEnabled( true ); } else if( selectedPortuguesa != null ) { - textDescricao.setValue( selectedPortuguesa.getDescricao() ); - textDescricao.setEnabled( true ); + textAreaDescricao.setText( selectedPortuguesa.getDescricao() ); + textAreaDescricao.setEnabled( true ); textCodigo.setText( selectedPortuguesa.getCodigo() ); + textCodigo.setEnabled( true ); } else { - textDescricao.setValue( null ); + textAreaDescricao.setText( "" ); textCodigo.setText( "" ); } } @@ -504,4 +547,11 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants buttonInternacionalRemover.setEnabled( selectedInternacional != null ); } + @Override + public void caretUpdate( CaretEvent e ) + { + buttonSave.setEnabled( true ); + buttonRevert.setEnabled( true ); + } + } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java index b7879935..b3e5619b 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/AdicionarAreasPanel.java @@ -1,5 +1,6 @@ package siprp.higiene.gestao.postos; +import static com.evolute.utils.strings.UnicodeLatin1Map.aacute; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; @@ -17,7 +18,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; @@ -161,7 +162,7 @@ public class AdicionarAreasPanel extends JPanel } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -171,12 +172,12 @@ public class AdicionarAreasPanel extends JPanel if( path != null ) { Object object = path.getLastPathComponent(); - if( object instanceof PostoNode ) + if( ( object instanceof PostoNode ) && LeafDialog.confirmDelete( true, false, "posto" ) ) { HsPosto posto = ((HsPosto) ((PostoNode) object).getUserObject()); remPosto( posto ); } - else if( object instanceof AreaNode ) + else if( ( object instanceof AreaNode ) && LeafDialog.confirmDelete( false, false, aacute + "rea" ) ) { for( int i = 0; i < ((AreaNode) object).getChildCount(); ++i ) { @@ -208,7 +209,7 @@ public class AdicionarAreasPanel extends JPanel } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java index 4e2e5e14..27943dd6 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/postos/GerirAreasPanel.java @@ -28,7 +28,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafUIConstants; import leaf.ui.TreeTools; @@ -217,7 +217,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -238,7 +238,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -247,14 +247,14 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants try { HsArea area = getSelectedArea(); - if( area != null ) + if( area != null && LeafDialog.confirmDelete( false, false, aacute + "rea") ) { area.delete(); refresh(); } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -278,7 +278,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -299,7 +299,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -308,7 +308,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants try { HsPosto posto = getSelectedPosto(); - if( posto != null ) + if( posto != null && LeafDialog.confirmDelete( true, false, "posto" ) ) { posto.setDeletedDate( new Date() ); posto.save(); @@ -316,7 +316,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.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 1a092642..c80aba18 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java @@ -19,7 +19,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.TreeInserterDialog; import leaf.ui.TreeTools; @@ -223,7 +223,7 @@ public class AdicionarRiscosPanel extends JPanel } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -236,7 +236,7 @@ public class AdicionarRiscosPanel extends JPanel { DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); Object obj = node.getUserObject(); - if( obj != null ) + if( obj != null && LeafDialog.confirmDelete( true, false, "risco" ) ) { ((BaseObject) obj).delete(); refresh(); @@ -244,7 +244,7 @@ public class AdicionarRiscosPanel extends JPanel } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index 80775c91..e0254229 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -15,7 +15,7 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import siprp.database.cayenne.objects.HsMedida; import com.evolute.utils.images.ImageException; @@ -164,7 +164,7 @@ public class GerirMedidaPanel extends JPanel setEnabled(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index f7b2a532..baba2658 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -26,7 +26,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafUIConstants; import leaf.ui.TreeTools; @@ -196,7 +196,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -217,7 +217,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -226,14 +226,14 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants try { HsRiscoTema tema = getSelectedTema(); - if( tema != null ) + if( tema != null && LeafDialog.confirmDelete( true, false, "tema" ) ) { tema.delete(); refresh(); } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -272,7 +272,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -293,7 +293,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -302,7 +302,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants try { HsRisco risco = getSelectedRisco(); - if( risco != null && removerRiscoOK(risco) ) + if( risco != null && LeafDialog.confirmDelete( true, false, "risco" ) && removerRiscoOK( risco ) ) { risco.delete(); refresh(); @@ -310,7 +310,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -354,7 +354,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -363,14 +363,14 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants try { HsRiscoMedida medida = getSelectedMedida(); - if( medida != null ) + if( medida != null && LeafDialog.confirmDelete( true, false, "requisisto" ) ) { medida.delete(); refresh(); } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index d909a5df..68d84716 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -18,7 +18,7 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import siprp.database.cayenne.objects.HsRelatorioPostoMedida; import com.evolute.utils.images.ImageException; @@ -228,7 +228,7 @@ public class GerirMedidaRelatorioPanel extends JPanel } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -245,7 +245,7 @@ public class GerirMedidaRelatorioPanel extends JPanel setEnabled(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -262,7 +262,7 @@ public class GerirMedidaRelatorioPanel extends JPanel setEnabled(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java index e81c714a..553e3df5 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java @@ -20,7 +20,7 @@ import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.HsRelatorioMedida; @@ -255,7 +255,7 @@ public class GerirMedidasRelatorioPanel extends JPanel setEnabled(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } @@ -278,7 +278,7 @@ public class GerirMedidasRelatorioPanel extends JPanel setEnabled(); } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java index 37484913..a721ca96 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirValoresRiscoPanel.java @@ -19,7 +19,7 @@ import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsRelatorioPostoRisco; import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo; @@ -306,7 +306,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 1b70aa17..d082bdf2 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -38,7 +38,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import leaf.ui.LeafButton; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import siprp.database.cayenne.objects.HsEmailEstabelecimento; import siprp.database.cayenne.objects.HsRelatorio; @@ -295,7 +295,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe } } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } @@ -340,7 +340,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } finally { @@ -453,7 +453,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe buttonSave.setEnabled( false ); } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java index 6c7ed60d..2fe2d365 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/RelatorioHigieneSegurancaWindow.java @@ -19,7 +19,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsRelatorio; @@ -192,7 +192,7 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable } } catch( Exception e ) { - LeafError.error(e); + LeafDialog.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 b80fff23..6f2a3160 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/exames/logic/RecepcaoExamesLogic.java @@ -3,7 +3,7 @@ package siprp.medicina.exames.logic; import java.util.Collection; import java.util.List; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafLogic; import siprp.database.cayenne.objects.Prestadores; import siprp.database.cayenne.objects.TrabalhadoresEcd; @@ -56,7 +56,7 @@ public class RecepcaoExamesLogic extends LeafLogic } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java index 23b02801..7559c96f 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/prestadores/PrestadoresWindow.java @@ -37,7 +37,7 @@ import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import siprp.clientes.ClientesDataProvider; import siprp.clientes.ContactoPanel; import siprp.data.ContactoData; @@ -427,7 +427,7 @@ public class PrestadoresWindow extends EditorWindow } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.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 f485a678..dbcafc19 100755 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/logic/MedicinaProcessoLogic.java @@ -5,7 +5,7 @@ import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.LeafLogic; import leaf.ui.LeafWindow.LeafObject; import siprp.MedicinaConstants; @@ -625,7 +625,7 @@ public class MedicinaProcessoLogic extends LeafLogic } } catch( Exception e ) { - LeafError.error( e ); + LeafDialog.error( e ); } } } ); @@ -799,7 +799,7 @@ public class MedicinaProcessoLogic extends LeafLogic runActionLater( REFRESH ); } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } @@ -850,7 +850,7 @@ public class MedicinaProcessoLogic extends LeafLogic } } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } @@ -893,7 +893,7 @@ public class MedicinaProcessoLogic extends LeafLogic } } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } diff --git a/trunk/common/src/leaf/ui/LeafDialog.java b/trunk/common/src/leaf/ui/LeafDialog.java new file mode 100644 index 00000000..a48f0dbf --- /dev/null +++ b/trunk/common/src/leaf/ui/LeafDialog.java @@ -0,0 +1,39 @@ +package leaf.ui; + +import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; +import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; + +import javax.swing.JOptionPane; + +import com.evolute.utils.error.ErrorLogger; +import com.evolute.utils.ui.DialogException; + +public class LeafDialog +{ + + public static void error( Exception e ) + { + if( e != null ) + { + ErrorLogger.logException( e ); + e.printStackTrace( System.out ); + DialogException.showException( e ); + } + } + + public static boolean confirmDelete( boolean masculino, boolean plural, String nome ) + { + return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( + null, + "Tem a certeza que deseja remover " + + ( masculino ? "o" : "a" ) + + ( plural ? "s" : "" ) + + " " + nome + " seleccionad" + + ( masculino ? "o" : "a" ) + + ( plural ? "s" : "" ) + + "?", + "Confirmar remo" + ccedil + atilde + "o", + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null ); + } + +} diff --git a/trunk/common/src/leaf/ui/LeafError.java b/trunk/common/src/leaf/ui/LeafError.java deleted file mode 100644 index 947c47a9..00000000 --- a/trunk/common/src/leaf/ui/LeafError.java +++ /dev/null @@ -1,20 +0,0 @@ -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/siprp/logic/HigieneSegurancaLogic.java b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java index 0f076ad1..e33dd039 100644 --- a/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/common/src/siprp/logic/HigieneSegurancaLogic.java @@ -9,7 +9,7 @@ import java.util.List; import javax.swing.tree.DefaultMutableTreeNode; -import leaf.ui.LeafError; +import leaf.ui.LeafDialog; import leaf.ui.TreeTools; import siprp.database.cayenne.objects.Empresas; import siprp.database.cayenne.objects.Estabelecimentos; @@ -198,7 +198,7 @@ public class HigieneSegurancaLogic } } catch( Exception e ) { - LeafError.error(e); + LeafDialog.error(e); } } @@ -360,8 +360,11 @@ public class HigieneSegurancaLogic DefaultMutableTreeNode categoriaNode = new DefaultMutableTreeNode( categoria ); for( HsLegislacao legislacao: categoria.getHsLegislacaoArray() ) { - DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao ); - categoriaNode.add( legislacaoNode ); + if( legislacao.getDeletedDate() == null ) + { + DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao ); + categoriaNode.add( legislacaoNode ); + } } result.add( categoriaNode ); }