From 0b03933a8b215eb2a895df54e44c007de3196238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Sim=C3=A3o?= Date: Thu, 2 Jul 2009 12:16:18 +0000 Subject: [PATCH] git-svn-id: https://svn.coded.pt/svn/SIPRP@1058 bb69d46d-e84e-40c8-a05a-06db0d633741 --- .../relatorio/GerirMedidasRelatorioPanel.java | 57 ++++++++++++++++--- .../higiene/relatorio/PanelRelatorio.java | 40 +++++++------ .../medicina/processo/mail/MailDialog.java | 15 +++-- .../medicina/processo/mail/MailSender.java | 2 +- 4 files changed, 85 insertions(+), 29 deletions(-) diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java index 826f64d3..52800382 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java @@ -1,5 +1,7 @@ package siprp.higiene.relatorio; +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; @@ -7,7 +9,10 @@ import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.Date; +import java.util.List; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTree; @@ -259,6 +264,11 @@ public class GerirMedidasRelatorioPanel extends JPanel } } + private boolean confirm( String message ) + { + return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( this, message, "Confirma"+ccedil+atilde+"o", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null ); + } + private void rem() { try @@ -269,9 +279,37 @@ public class GerirMedidasRelatorioPanel extends JPanel Object selection = path.getLastPathComponent(); if( selection instanceof MedidaRelatorioNode ) { - HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject(); - rel.getToHsRelatorioMedida().delete(); - rel.delete(); + if( confirm("Tem a certeza que deseja remover o requisito?") ) + { + HsRelatorioPostoMedida rel = selection == null ? null : (HsRelatorioPostoMedida) ((MedidaRelatorioNode) selection).getUserObject(); + rel.getToHsRelatorioMedida().setDeletedDate( new Date() ); + rel.delete(); + } + } + else if( selection instanceof RiscoRelatorioNode ) + { + if( confirm("Tem a certeza que deseja remover o risco?") ) + { + HsRelatorioPostoRisco rel = (HsRelatorioPostoRisco) ((RiscoRelatorioNode)selection).getUserObject(); + for( HsRelatorioMedida medida : rel.getToHsRelatorioRisco().getHsRelatorioMedidaArray() ) + { + while( true ) + { + List list = medida.getHsRelatorioPostoMedidaArray(); + HsRelatorioPostoMedida relMedida = list.isEmpty() ? null : list.get(0); + if( relMedida != null ) + { + relMedida.delete(); + } + else + { + break; + } + } + medida.setDeletedDate( new Date() ); + } + rel.getToHsRelatorioRisco().setDeletedDate( new Date() ); + } } } refresh(); @@ -295,7 +333,7 @@ public class GerirMedidasRelatorioPanel extends JPanel } } buttonAdicionar.setEnabled( add && getSelectedRisco() != null ); - buttonRemover.setEnabled( rem && getSelectedMedida() != null ); + buttonRemover.setEnabled( rem && ( getSelectedMedida() != null || getSelectedRisco() != null ) ); } public void refresh() @@ -307,14 +345,17 @@ public class GerirMedidasRelatorioPanel extends JPanel { RiscoRelatorioNode node = new RiscoRelatorioNode( rel ); HsRelatorioRisco risco = rel.getToHsRelatorioRisco(); - for( HsRelatorioMedida medida : risco.getHsRelatorioMedidaArray() ) + if( risco.getDeletedDate() == null ) { - for( HsRelatorioPostoMedida medidaRel : medida.getHsRelatorioPostoMedidaArray() ) + for( HsRelatorioMedida medida : risco.getHsRelatorioMedidaArray() ) { - node.add( new MedidaRelatorioNode( medidaRel ) ); + for( HsRelatorioPostoMedida medidaRel : medida.getHsRelatorioPostoMedidaArray() ) + { + node.add( new MedidaRelatorioNode( medidaRel ) ); + } } + root.add( node ); } - root.add( node ); } } setEnabled(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java index 3ea40de9..083ee31d 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/PanelRelatorio.java @@ -240,13 +240,13 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe @Override public void actionPerformed( ActionEvent e ) { -// if( isValidEmail() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, "Emails n" + atilde + "o preenchidos para este estabelecimento!\nContinuar?", "Aviso", JOptionPane.YES_NO_OPTION ) ) -// { + if( isValidEmail() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, "Emails n" + atilde + "o preenchidos para este estabelecimento!\nContinuar?", "Aviso", JOptionPane.YES_NO_OPTION ) ) + { if( isValidPlano() && confirmSubmit() ) { submit(); } -// } + } } } ); buttonPdfPlano.addActionListener( new ActionListener() @@ -356,13 +356,13 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe setCursor(new Cursor(Cursor.WAIT_CURSOR)); if( relatorio != null ) { -// if( sendMail( relatorio ) ) -// { - refresh(); - relatorio.setIsSubmetido( new Date() ); - relatorio.save(); - setRelatorio( relatorio, false ); -// } + if( sendMail( relatorio ) ) + { + refresh(); + relatorio.setIsSubmetido( new Date() ); + relatorio.save(); + setRelatorio( relatorio, false ); + } } } catch( Exception e ) @@ -461,13 +461,21 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe boolean result = false; List rels = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento(); String to = ""; + String bcc = ""; for( HsEmailEstabelecimento rel : rels ) { - to += rel.getToHsEmail().getEmail() + ","; + if( to.isEmpty() ) + { + to += rel.getToHsEmail().getEmail(); + } + else + { + bcc += rel.getToHsEmail().getEmail() + ", "; + } } - if(to.endsWith( "," )) + if(bcc.endsWith( ", " )) { - to = to.substring( 0, to.length() - 1 ); + bcc = bcc.substring( 0, bcc.length() - 2 ); } if( to.length() > 0 ) { @@ -477,7 +485,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe Date dataVisita = relatorio.getToHsMarcacoesEstabelecimento().getData(); String dataVisitaString = new SimpleDateFormat("dd/MM/yyyy").format( dataVisita ); String subject = "Relatório da Avaliação de Riscos Laborais e Plano de Actuação de " + nomeEstabelecimento + " - auditoria de " + dataVisitaString; - String body = "Exmos. Senhores" + + String body = "

Exmos. Senhores" + "
" + "
" + "
" + @@ -517,8 +525,8 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe "
" + "
" + "
" + - "Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda."; - MailDialog md = new MailDialog( getFrame(), to, "", subject, body, getRelatoriosTemp(relatorio) ); + "Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda.

"; + MailDialog md = new MailDialog( getFrame(), to, bcc, subject, body, getRelatoriosTemp(relatorio) ); result = md.wasSent(); } return result; diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java index c678bf8f..ab79ee9f 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java @@ -5,6 +5,7 @@ import info.clearthought.layout.TableLayoutConstraints; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Cursor; import java.awt.FileDialog; import java.awt.FlowLayout; import java.awt.GridLayout; @@ -121,7 +122,7 @@ public class MailDialog extends CustomJDialog setMessage( message ); attach( files ); setModal( true ); - setSize( 1024, 768 ); + setSize( 800, 600 ); setLocationRelativeTo( null ); setVisible( true ); } @@ -174,7 +175,15 @@ public class MailDialog extends CustomJDialog public void actionPerformed( ActionEvent e ) { - send(); + try + { + setCursor( new Cursor(Cursor.WAIT_CURSOR) ); + send(); + } + finally + { + setCursor( new Cursor(Cursor.DEFAULT_CURSOR ) ); + } close(); } }; @@ -235,10 +244,8 @@ public class MailDialog extends CustomJDialog JLabel toLabel = new JLabel( "Para:" ); toText = new JTextField(); - toText.setEditable( false ); JLabel bccLabel = new JLabel( "C\u00f3pia:" ); bccText = new JTextField(); - bccText.setEditable( false ); JLabel assuntoLabel = new JLabel( "Assunto:" ); subjectText = new JTextField(); attachmentsModel = new VectorTableModel( new String[]{ "" } ); diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailSender.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailSender.java index fb5ec3aa..e30f41c3 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailSender.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailSender.java @@ -46,7 +46,7 @@ public class MailSender msg.setFrom( new InternetAddress( from ) ); msg.setReplyTo( new Address[]{ new InternetAddress(from)} ); msg.setRecipients( Message.RecipientType.TO, InternetAddress.parse( to, true ) ); - msg.setRecipients( Message.RecipientType.BCC, InternetAddress.parse( bcc, true ) ); + msg.setRecipients( Message.RecipientType.CC, InternetAddress.parse( bcc, true ) ); msg.setSubject( subject ); MimeBodyPart bodyPart = new MimeBodyPart();