|
|
|
|
@ -19,6 +19,7 @@ import java.beans.PropertyChangeEvent;
|
|
|
|
|
import java.beans.PropertyChangeListener;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.EventObject;
|
|
|
|
|
@ -49,6 +50,7 @@ import siprp.database.cayenne.objects.HsRelatorio;
|
|
|
|
|
import siprp.database.cayenne.objects.MarcacoesEstabelecimento;
|
|
|
|
|
import siprp.database.cayenne.objects.MarcacoesTecnicosHst;
|
|
|
|
|
import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel;
|
|
|
|
|
import siprp.higiene.relatorio.print.RelatorioPDFCreator;
|
|
|
|
|
import siprp.logic.HigieneSegurancaLogic;
|
|
|
|
|
import siprp.medicina.processo.mail.MailDialog;
|
|
|
|
|
import siprp.planoactuacao.print.PlanoActuacaoPDFCreator;
|
|
|
|
|
@ -125,7 +127,6 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
|
|
|
|
|
private void startupComponents()
|
|
|
|
|
{
|
|
|
|
|
buttonPdfRelatorio.setEnabled( false );
|
|
|
|
|
dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) );
|
|
|
|
|
panelEquipamentos.setPreferredSize( new Dimension( 400, 0 ) );
|
|
|
|
|
bg.add( radioInicial );
|
|
|
|
|
@ -249,7 +250,15 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
|
|
|
{
|
|
|
|
|
pdf();
|
|
|
|
|
pdf(true);
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
buttonPdfRelatorio.addActionListener( new ActionListener()
|
|
|
|
|
{
|
|
|
|
|
@Override
|
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
|
|
|
{
|
|
|
|
|
pdf(false);
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
buttonRevertPlano.addActionListener( new ActionListener()
|
|
|
|
|
@ -361,37 +370,23 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pdf()
|
|
|
|
|
private void pdf(boolean plano)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
setCursor( new Cursor(Cursor.WAIT_CURSOR) );
|
|
|
|
|
PlanoActuacaoPDFCreator creator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
byte [] pdf = creator.createPDF( relatorio.getId(), false );
|
|
|
|
|
if( pdf != null )
|
|
|
|
|
byte [] pdf = null;
|
|
|
|
|
if( plano )
|
|
|
|
|
{
|
|
|
|
|
JFileChooser fileChooser = new JFileChooser( );
|
|
|
|
|
if( fileChooser.showSaveDialog( this ) == JFileChooser.APPROVE_OPTION )
|
|
|
|
|
{
|
|
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
|
|
String path = file.getAbsolutePath();
|
|
|
|
|
if( !path.toUpperCase().endsWith( ".PDF" ) )
|
|
|
|
|
{
|
|
|
|
|
path += ".pdf";
|
|
|
|
|
file = new File( path );
|
|
|
|
|
}
|
|
|
|
|
if( file != null )
|
|
|
|
|
{
|
|
|
|
|
if( file.exists() && confirmDelete( file ) )
|
|
|
|
|
{
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream a = new FileOutputStream(file);
|
|
|
|
|
a.write( pdf );
|
|
|
|
|
a.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PlanoActuacaoPDFCreator creator = new PlanoActuacaoPDFCreator();
|
|
|
|
|
pdf = creator.createPDF( relatorio.getId(), false );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RelatorioPDFCreator creator = new RelatorioPDFCreator();
|
|
|
|
|
pdf = creator.createPDF( relatorio.getId() );
|
|
|
|
|
}
|
|
|
|
|
printToFile( pdf );
|
|
|
|
|
}
|
|
|
|
|
catch( Exception e )
|
|
|
|
|
{
|
|
|
|
|
@ -403,6 +398,35 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printToFile( byte [] pdf ) throws IOException
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if( pdf != null )
|
|
|
|
|
{
|
|
|
|
|
JFileChooser fileChooser = new JFileChooser( );
|
|
|
|
|
if( fileChooser.showSaveDialog( this ) == JFileChooser.APPROVE_OPTION )
|
|
|
|
|
{
|
|
|
|
|
File file = fileChooser.getSelectedFile();
|
|
|
|
|
String path = file.getAbsolutePath();
|
|
|
|
|
if( !path.toUpperCase().endsWith( ".PDF" ) )
|
|
|
|
|
{
|
|
|
|
|
path += ".pdf";
|
|
|
|
|
file = new File( path );
|
|
|
|
|
}
|
|
|
|
|
if( file != null )
|
|
|
|
|
{
|
|
|
|
|
if( file.exists() && confirmDelete( file ) )
|
|
|
|
|
{
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
FileOutputStream a = new FileOutputStream(file);
|
|
|
|
|
a.write( pdf );
|
|
|
|
|
a.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JFrame getFrame( )
|
|
|
|
|
{
|
|
|
|
|
Component comp = this;
|
|
|
|
|
|