diff --git a/trunk/SIPRPSoft/lib/shst.jar b/trunk/SIPRPSoft/lib/shst.jar index 1cebb250..1d8fe57b 100644 Binary files a/trunk/SIPRPSoft/lib/shst.jar and b/trunk/SIPRPSoft/lib/shst.jar differ diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index 552077e0..312097e1 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -84,7 +84,7 @@ public class Main implements com.evolute.utils.ui.window.Connector SIPRPPropertiesLoader.getInstance().load(); - dbase = (String) Singleton.getInstance( SingletonConstants.LOCAL_DB_NAME ); + dbase = (String) Singleton.getInstance( SHSTPropertiesConstants.LOCAL_DB_NAME ); Insert.setDefaultKeyRetriever( JDBCAutoKeyRetriever.DEFAULT ); @@ -95,8 +95,8 @@ public class Main implements com.evolute.utils.ui.window.Connector loginWindow = new LoginWindow( new Main(), logoFileName, new String[] { (String) Singleton.getInstance( SHSTPropertiesConstants.SOFTWARE_NAME ) }, new String[] { "Vers\u00E3o " + ProjectTools.getInstance().getVersion(), "(EVOLUTE 2004-2010)" }, "", - (String)Singleton.getInstance( SingletonConstants.LOCAL_USER ), - (String)Singleton.getInstance( SingletonConstants.LOCAL_PASSWORD ), avisos, false ); + (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_USER ), + (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_PASSWORD ), avisos, false ); loginWindow.setTitle( (String) Singleton.getInstance( SHSTPropertiesConstants.SOFTWARE_NAME ) ); String iconPath = ( String ) Singleton.getInstance( EvoPropertyKey.APP.ICON_PATH ); @@ -168,9 +168,9 @@ public class Main implements com.evolute.utils.ui.window.Connector String server = null; if( server == null ) { - server = (String)Singleton.getInstance( SingletonConstants.LOCAL_URL ); + server = (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_URL ); } - String prefix = (String)Singleton.getInstance( SingletonConstants.LOCAL_URL_PREFIX ); + String prefix = (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_URL_PREFIX ); url = prefix + server + "/" + dbase; DBManager dbm = new JDBCManager( url, user, passwd , 10, 8, 8, null ); Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, dbm ); diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 207a1798..0985514a 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -20,6 +20,7 @@ import shst.higiene.mapa.MapaHigieneWindow; import shst.higiene.marcacoes.MarcacoesHigieneInterface; import shst.higiene.marcacoes.MarcacoesHigieneWindow; import shst.higiene.relatorio.RelatorioHigieneSegurancaWindow; +import shst.impressaofichas.ImpressaoFichasWindow; import shst.lembretes.LembretesMultiWindow; import shst.medicina.MedicinaWindow; import shst.medicina.MedicinaWindowInterface; @@ -34,7 +35,6 @@ import siprp.companydataloaders.SIPRPPropertiesLoader; import siprp.cursos.SIPRPCursosInit; import siprp.estatistica.EstatisticaWindow; import siprp.ficha.FichaWindow; -import siprp.impressaofichas.ImpressaoFichasWindow; import siprp.pesquisas.RelatorioAnualWindow; import com.evolute.module.cursos.CursosWindow; @@ -73,7 +73,7 @@ public class SIPRPTracker extends WindowTracker implements SHSTTrackerInterface /** Creates a new instance of SIPRPTracker */ public SIPRPTracker( AvisosPanel avisosP ) { - Singleton.setInstance( SingletonConstants.SIPRP_TRACKER, this ); + Singleton.setInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/, this ); Singleton.setInstance( Singleton.TRACKER, this ); this.avisos = avisosP; avisos.setTracker( this ); diff --git a/trunk/SIPRPSoft/src/siprp/SingletonConstants.java b/trunk/SIPRPSoft/src/siprp/SingletonConstants.java deleted file mode 100644 index 3a12712e..00000000 --- a/trunk/SIPRPSoft/src/siprp/SingletonConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SingletonConstants.java - * - * Created on 25 de Maio de 2004, 13:34 - */ - -package siprp; - -/** - * - * @author fpalma - */ -public class SingletonConstants -{ - - public static final String LOCAL_USER = "local_user"; - public static final String LOCAL_PASSWORD = "local_password"; - public static final String LOCAL_URL_PREFIX = "local_url_prefix"; - public static final String LOCAL_URL = "local_url"; - public static final String LOCAL_DB_NAME = "local_db_name"; - public static final String LOCAL_DRIVER_NAME = "local_driver_name"; - - public static final String SIPRP_TRACKER = "SIPRP_TRACKER"; - - /** Creates a new instance of SingletonConstants */ - private SingletonConstants() - { - } - -} diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java index 7b988562..9e00b775 100644 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java +++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/ClinicaAvenidaDataLoader.java @@ -7,7 +7,6 @@ package siprp.companydataloaders; import shst.SHSTPropertiesConstants; -import siprp.SingletonConstants; import com.evolute.utils.Singleton; @@ -83,12 +82,12 @@ public class ClinicaAvenidaDataLoader implements CompanyDataLoader Singleton.setInstance( SHSTPropertiesConstants.WEB_DB_NAME, "" ); Singleton.setInstance( SHSTPropertiesConstants.WEB_DRIVER_NAME, "" ); - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "localhost" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "shst" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_USER, "postgres" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_PASSWORD, "Typein" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL, "localhost" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DB_NAME, "shst" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); } } diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java index fc974a53..f6b67425 100644 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java +++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/IBookDataLoader.java @@ -7,7 +7,6 @@ package siprp.companydataloaders; import shst.SHSTPropertiesConstants; -import siprp.SingletonConstants; import com.evolute.utils.Singleton; @@ -95,12 +94,12 @@ public class IBookDataLoader implements CompanyDataLoader // Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); // Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); - Singleton.setInstance( SingletonConstants.LOCAL_USER, "postgres" ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, "Typein" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, "localhost:5432" ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, "siprp_local" ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_USER, "postgres" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_PASSWORD, "Typein" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL_PREFIX, "jdbc:postgresql://" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL, "localhost:5432" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DB_NAME, "siprp_local" ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DRIVER_NAME, "org.postgresql.Driver" ); } } diff --git a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPPropertiesLoader.java b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPPropertiesLoader.java index 48fc10b9..e516a0c7 100644 --- a/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPPropertiesLoader.java +++ b/trunk/SIPRPSoft/src/siprp/companydataloaders/SIPRPPropertiesLoader.java @@ -1,7 +1,6 @@ package siprp.companydataloaders; import shst.SHSTPropertiesConstants; -import siprp.SingletonConstants; import com.evolute.properties.EvoAbstractPropertiesLoader; import com.evolute.properties.EvoPropertyKey; @@ -105,13 +104,13 @@ public class SIPRPPropertiesLoader extends EvoAbstractPropertiesLoader Singleton.setInstance( SHSTPropertiesConstants.WEB_DB_NAME, "siprp" ); Singleton.setInstance( SHSTPropertiesConstants.WEB_DRIVER_NAME, "org.postgresql.Driver" ); - Singleton.setInstance( SingletonConstants.LOCAL_USER, Singleton.getInstance( EvoPropertyKey.DB.USER ) ); - Singleton.setInstance( SingletonConstants.LOCAL_PASSWORD, Singleton.getInstance( EvoPropertyKey.DB.PASSWORD ) ); - Singleton.setInstance( SingletonConstants.LOCAL_URL_PREFIX, Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.PREFIX ) ); - Singleton.setInstance( SingletonConstants.LOCAL_URL, + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_USER, Singleton.getInstance( EvoPropertyKey.DB.USER ) ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_PASSWORD, Singleton.getInstance( EvoPropertyKey.DB.PASSWORD ) ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL_PREFIX, Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.PREFIX ) ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_URL, Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.HOSTNAME ) + ":" + Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.PORT ) ); - Singleton.setInstance( SingletonConstants.LOCAL_DB_NAME, Singleton.getInstance( EvoPropertyKey.DB.NAME ) ); - Singleton.setInstance( SingletonConstants.LOCAL_DRIVER_NAME, Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.DRIVER_NAME ) ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DB_NAME, Singleton.getInstance( EvoPropertyKey.DB.NAME ) ); + Singleton.setInstance( SHSTPropertiesConstants.LOCAL_DRIVER_NAME, Singleton.getInstance( EvoPropertyKey.DB.CONNECTION.DRIVER_NAME ) ); } } diff --git a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java index ef45c261..b27d036e 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java +++ b/trunk/SIPRPSoft/src/siprp/ficha/FichaWindow.java @@ -35,9 +35,9 @@ import shst.data.outer.EstabelecimentosData; import shst.data.outer.ExamesData; import shst.data.outer.MedicosData; import shst.data.outer.TrabalhadoresData; +import shst.importer.Importer; import shst.medicina.MarcacoesMedicinaHandler; import siprp.FichaDataProvider; -import siprp.importer.Importer; import siprp.lembretes.LembretesDataProvider; import siprp.printer.Printer; import siprp.ui.SIPRPTabbedWindow; diff --git a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java b/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java index 6377fe08..0b260c80 100644 --- a/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java +++ b/trunk/SIPRPSoft/src/siprp/ficha/TrabalhadorPanel.java @@ -17,8 +17,8 @@ import javax.swing.JPanel; import javax.swing.JTextField; import shst.data.outer.TrabalhadoresData; +import shst.importer.Importer; import siprp.FichaDataProvider; -import siprp.importer.Importer; import com.evolute.entity.ProviderInterface; import com.evolute.utils.Singleton; diff --git a/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java b/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java deleted file mode 100644 index 86ec0e73..00000000 --- a/trunk/SIPRPSoft/src/siprp/importer/DataChooserWindow.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * DataChooserWindow.java - * - * Created on 29 de Abril de 2004, 16:53 - */ - -package siprp.importer; - -import java.awt.Container; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Hashtable; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - -import siprp.ui.SIPRPFrame; - -import com.evolute.utils.ui.CustomJDialog; -/** - * - * @author lflores - */ -public class DataChooserWindow extends CustomJDialog -{ - private final String labels[]; - private final Object items[]; - private final Object empty[]; - private final Object allItems[][]; - private final JComboBox combos[]; - private final int preselected[]; - - private boolean canceled = false; - - /** Creates a new instance of DataChooserWindow */ - public DataChooserWindow( SIPRPFrame modalFrame, String names[], Object data[][] ) - { - this( modalFrame, names, data, null ); - } - - public DataChooserWindow( SIPRPFrame modalFrame, String names[], Object data[][], int selected[] ) - { - super( modalFrame, true ); - labels = names; - items = data[ 0 ]; - empty = new String[ items.length ]; - for( int i = 0; i < empty.length; ++i ) - { - empty[ i ] = ""; - } - allItems = data; - combos = new JComboBox[ labels.length ]; - preselected = selected; - setupComponents(); - if( modalFrame == null ) - { - center(); - } - else - { - centerSuper(); - } - setVisible( true ); - } - - private void setupComponents() - { - setTitle( "Escolha os campos correspondentes:" ); - setSize(450, 120 + 25 * labels.length ); - GridBagLayout gbl = new GridBagLayout(); - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets( 2, 2, 2, 2 ); - gbc.fill = GridBagConstraints.HORIZONTAL; - Container cont = getContentPane(); - cont.setLayout( gbl ); - for( int i = 0; i < labels.length; ++i ) - { - gbc.weightx = 0; - gbc.gridwidth = 1; - JLabel label = new JLabel( labels[ i ] ); - gbl.setConstraints( label, gbc ); - cont.add( label ); -/* gbc.weightx = 1; - JPanel pad = new JPanel(); - gbl.setConstraints( pad, gbc ); - cont.add( pad ); -*/ gbc.weightx = 1; - gbc.gridwidth = GridBagConstraints.REMAINDER; - JComboBox combo = new JComboBox( items ); - int index; - if( preselected == null ) - { - index = Math.min( i, items.length - 1 ); - } - else - { - if( i < preselected.length ) - { - index = Math.min( preselected[ i ], items.length - 1 ); - if( index == -1 ) - { - index = items.length - 1; - } - } - else - { - index = items.length - 1; - } - - } - combo.setSelectedIndex( index ); - combos[ i ] = combo; - gbl.setConstraints( combo, gbc ); - cont.add( combo ); - } - gbc.insets = new Insets( 10, 2, 2, 2 ); - gbc.weightx = 1; - gbc.gridwidth = 2; - JPanel pad = new JPanel(); - gbl.setConstraints( pad, gbc ); - cont.add( pad ); - gbc.weightx = 0; - gbc.gridwidth = 1; - JButton butOK = new JButton( "OK" ); - gbl.setConstraints( butOK, gbc ); - cont.add( butOK ); - gbc.weightx = 0; - gbc.gridwidth = GridBagConstraints.REMAINDER; - JButton butCancel = new JButton( "Cancelar" ); - gbl.setConstraints( butCancel, gbc ); - cont.add( butCancel ); - butOK.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent e ) - { - setVisible( false ); - dispose(); - } - }); - butCancel.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent e ) - { - setVisible( false ); - dispose(); - canceled = true; - } - }); - } - - public Hashtable getData() - { - if( canceled ) - { - return null; - } - Hashtable hash = new Hashtable(); - for( int i = 0; i < labels.length; ++i ) - { - hash.put( labels[ i ], combos[ i ].getSelectedItem() ); - } - return hash; - } - - public Hashtable[] getMultipleData() - { - if( canceled ) - { - return null; - } - Hashtable hash[] = new Hashtable[ allItems.length ]; -//System.out.println( "Hash[] size: " + hash.length ); - for( int j = 0; j < hash.length; ++j ) - { - hash[ j ] = new Hashtable(); - } - for( int i = 0; i < labels.length; ++i ) - { - String sel = combos[ i ].getSelectedItem().toString(); - if( sel.length() > 0 ) - { - for( int j = 0; j < allItems.length; ++j ) - { - hash[ j ].put( labels[ i ], allItems[ j ][ combos[ i ].getSelectedIndex() ] ); - } - } - } - return hash; - } - -/* public static void main( String arg[] ) - { - String names[] = new String[] { "Nome:", "Morada:", "Telefone:" }; - String data[] = new String[] { "Joao Catita", "Damaiasdg sdfg sdf gsdfs hgf h", "nao tem", "so a noite", "" }; - DataChooserWindow dcw = new DataChooserWindow( null, names, data, new int[] { 3, 2 ,1 } ); - }*/ -} diff --git a/trunk/SIPRPSoft/src/siprp/importer/Importer.java b/trunk/SIPRPSoft/src/siprp/importer/Importer.java deleted file mode 100644 index 9427fcbb..00000000 --- a/trunk/SIPRPSoft/src/siprp/importer/Importer.java +++ /dev/null @@ -1,369 +0,0 @@ -package siprp.importer; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ListSelectionModel; - -import shst.SHSTPropertiesConstants; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Excel2DArray; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.Virtual2DTableModel; -import com.evolute.utils.ui.CustomJDialog; - -/** - * - * @author psantos - */ -public class Importer extends CustomJDialog -{ - - private static final long serialVersionUID = 1L; - public static final int TYPE_ADMISSAO = 0; - public static final int TYPE_DEMISSAO = 1; - - public static final String DATA_PREFIX = "Data "; - - public static final String NOME = "Nome do Funcion\u00e1rio"; - public static final String SEXO = "Sexo"; - public static final String NACIONALIDADE = "Nacionalidade"; - public static final String DATA_NASCIMENTO = DATA_PREFIX + "Nascimento"; - public static final String NUMERO_MECANOGRAFICO = "N\u00famero Mecanogr\u00e1fico"; - public static final String DATA_ADMISSAO = DATA_PREFIX + "Admiss\u00e3o"; - public static final String CATEGORIA = "Categoria"; - public static final String LOCAL_TRABALHO = "Local Trabalho"; - public static final String FUNCAO = "Fun\u00e7\u00e3o"; - public static final String DATA_ADMISSAO_FUNCAO = DATA_PREFIX + "Admiss\u00e3o na Fun\u00e7\u00e3o"; - public static final String DATA_DEMISSAO = DATA_PREFIX + "Demiss\u00e3o"; - - private JPanel panel; - private BaseTable table; - private Excel2DArray e2da; - private boolean canceled = false; - private DataChooserWindow dcw; - private Object vals[][]; - private int[] DEFAULT_SELECTION = new int[]{ 0, 2, 3, 1, -1, 4, 5, 7, 6, -1 }; - private int[] DEFAULT_SELECTION_DEMISSAO = new int[]{ 0, 1 }; - - public static final String NAMES[] = new String[]{ - NOME, - SEXO, - NACIONALIDADE, - DATA_NASCIMENTO, - NUMERO_MECANOGRAFICO, - DATA_ADMISSAO, - CATEGORIA, - LOCAL_TRABALHO, - FUNCAO, - DATA_ADMISSAO_FUNCAO - }; - - public static final String NAMES_DEMISSAO[] = new String[]{ - NOME, - DATA_DEMISSAO - }; - private final boolean multipleSelection; - protected final int type; - - /** Creates a new instance of Importer */ - public Importer( JFrame modalFrame, String filename, boolean multiple, int type ) - throws Exception - { - super( modalFrame, true ); - multipleSelection = multiple; - this.type = type; - - int []selection = ( int [] ) Singleton.getInstance( SHSTPropertiesConstants.EXCEL_FORMAT ); - if( selection != null ) - { - DEFAULT_SELECTION = selection; - } - int []selectionDemissao = ( int [] ) Singleton.getInstance( SHSTPropertiesConstants.EXCEL_FORMAT_DEMISSAO ); - if( selectionDemissao != null ) - { - DEFAULT_SELECTION_DEMISSAO = selectionDemissao; - } - setupComponents( filename ); - if( modalFrame == null ) - { - center(); - } - else - { - centerSuper(); - } - setVisible( true ); - } - - private void setupComponents( String filename ) - { - setSize( 800, 500 ); - - GridBagLayout gblGridBag = new GridBagLayout(); - GridBagConstraints gbcConstraints = new GridBagConstraints(); - - panel = ( JPanel ) getContentPane(); - - panel.setLayout( gblGridBag ); - - e2da = new Excel2DArray( filename ); - - String colNames[] = new String[ e2da.rowLength() ]; - for( int i = 0; i < colNames.length; i++ ) - { - colNames[ i ] = " "; - } - Virtual2DTableModel tm = new Virtual2DTableModel( colNames, null ); - tm.setValues( e2da ); - table = new BaseTable( tm ); - int col = 0; - switch( type ) - { - case TYPE_ADMISSAO: - col = DEFAULT_SELECTION[ 0 ]; - break; - - case TYPE_DEMISSAO: - col = DEFAULT_SELECTION_DEMISSAO[ 0 ]; - break; - } - table.getColumn( col ).setWidth( 200 ); - if( !multipleSelection ) - { - table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - } - else - { - table.getSelectionModel().setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION ); - } - table.getTableHeader().setResizingAllowed( true ); - table.getTableHeader().setReorderingAllowed( false ); - // table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF ); - - for( int i = 0; i < e2da.rowLength(); i++ ) - { - table.getColumn( i ).setMinWidth( 50 ); - //table.getColumn( i ).setResizable( true ); - } - - JScrollPane sp = new JScrollPane( table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - - gbcConstraints.anchor = GridBagConstraints.CENTER; - gbcConstraints.fill = GridBagConstraints.BOTH; - gbcConstraints.insets = new Insets(5, 5, 5, 5); - gbcConstraints.gridwidth = 3; - gbcConstraints.gridheight = 3; - gbcConstraints.weighty = 3; - gbcConstraints.gridx = 0; - gbcConstraints.gridy = 3; - gblGridBag.setConstraints( sp, gbcConstraints ); - - panel.add( sp ); - - JPanel jpButtons = new JPanel(); - final JButton jbOK = new JButton( "Escolher" ); - jbOK.setEnabled( false ); - jpButtons.add( jbOK ); - JButton jbCancel = new JButton( "Cancelar" ); - jpButtons.add( jbCancel ); - - gbcConstraints.gridheight = 1; - gbcConstraints.weightx = 1; - gbcConstraints.weighty = 0; - gbcConstraints.anchor = GridBagConstraints.SOUTH; - gbcConstraints.fill = GridBagConstraints.BOTH; - gbcConstraints.insets = new Insets( 2, 2, 2, 2 ); - gbcConstraints.gridwidth = 3; - gbcConstraints.gridx = 0; - gbcConstraints.gridy = 6; - gblGridBag.setConstraints( jpButtons, gbcConstraints ); - panel.add( jpButtons ); - - table.addMouseListener( new MouseAdapter() { - public void mouseClicked( MouseEvent e ) { - jbOK.setEnabled( true ); - if( e.getButton() == MouseEvent.BUTTON1 - && e.getClickCount() == 2 - && table.columnAtPoint( e.getPoint() ) != -1 - && table.rowAtPoint( e.getPoint() ) != -1 ) - { - acceptResult(); - } - } - public void mousePressed( MouseEvent e ) { - jbOK.setEnabled( true ); - } - }); - - jbOK.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent a ) { - acceptResult(); - } - }); - - jbCancel.addActionListener( new ActionListener() { - public void actionPerformed( ActionEvent a ) { - setVisible( false ); - dispose(); - canceled = true; - } - }); - - } - - private void acceptResult() - { - if( multipleSelection ) - { - int rows[] = table.getSelectedRows(); - vals = new Object[ rows.length ][]; - for( int i = 0; i < rows.length; ++i ) - { - Vector v = new Vector( Arrays.asList( e2da.getRow( rows[ i ] ) ) ); - v.add( "" ); - vals[ i ] = (Object[]) v.toArray( new Object[ v.size() ] ); - } - } - else - { - Vector v = new Vector( Arrays.asList( e2da.getRow( table.getSelectedRow() ) ) ); - v.add( "" ); - vals = new Object[][] { ( Object[] )v.toArray( new Object[ v.size() ] ) }; - } - -/* - System.out.println( "row: " + table.getSelectedRow() ); - System.out.print( "vals: " ); - for( int i = 0; i < vals.length; i++ ) - { - System.out.print( "[" + vals[ i ] + "]" ); - } - System.out.println(); -*/ - setVisible( false ); - dispose(); - - } - - public Hashtable getData() - { - if( NAMES == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION ); - - if( canceled || ( dcw == null ) ) - { - return null; - } - - return dcw.getData(); - } - - public Hashtable[] getMultipleData() - { - switch( type ) - { - case TYPE_ADMISSAO: - if( NAMES == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES, vals, DEFAULT_SELECTION ); - break; - - case TYPE_DEMISSAO: - if( NAMES_DEMISSAO == null || vals == null ) - { - return null; - } - dcw = new DataChooserWindow( null, NAMES_DEMISSAO, vals, DEFAULT_SELECTION_DEMISSAO ); - break; - } - - if( canceled || ( dcw == null ) ) - { - return null; - } - - return dcw.getMultipleData(); - } - - - public static void main( String args[] ) - { -// FileDialog fd = new FileDialog( null, "Escolha um ficheiro Excel:", FileDialog.LOAD ); -// fd.setDirectory( System.getProperty( "user.home" ) ); -// fd.setFilenameFilter( new FilenameFilter() { -// public boolean accept( File dir, String name ) -// { -// return (name!=null) && (name.indexOf( ".xls" ) != -1); -// } -// } ); -// fd.show(); - String filename = "c:\\teste_com_dados.xls"; - //String filename = fd.getFile(); - if( filename != null ) - { - //filename = fd.getDirectory() + File.separator + filename; - try - { - Importer importer = new Importer( null, filename, true, TYPE_ADMISSAO ); - Hashtable hash = importer.getData(); - if( hash != null ) - { - System.out.println( "Data: " + hash ); - } - } - catch( Exception ex ) - { - ex.printStackTrace(); - JOptionPane.showMessageDialog( null, "Erro a importar", "Erro...", JOptionPane.ERROR_MESSAGE ); - } - } -// Importer im = null; -// try -// { -// im = new Importer( null, -// "E:\\test.xls" -// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\teste.xls" -// "C:\\Documents and Settings\\psantos\\My Documents\\Devel\\Docs\\jexcelapi\\jxlrwtest.xls" -// ); -// -//System.out.println( "Escolhido: " + im.getData() ); -// -// } -// catch( Exception e ) -// { -// e.printStackTrace(); -// } - -// String[][] all = (String[][]) e.getObjects(); -// -// for( int j = 0; j < e.rowLength(); j++ ) -// { -// String[] r = e.getRow( j ); -// for( int i = 0; i < r.length; i++ ) -// { -// System.out.print( "[" + r[ i ] + "]" ); -// } -// System.out.println(); -// } - } -} \ No newline at end of file diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java deleted file mode 100644 index 2be8c6cd..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/FichasPrinter.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * FichasPrinter.java - * - * Created on 20 de Fevereiro de 2006, 0:43 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.impressaofichas; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Hashtable; -import java.util.Locale; - -import javax.xml.transform.TransformerFactory; - -import shst.util.fop.FOPCreator; -import shst.util.fop.FOPPrinter; -import shst.util.fop.PDFCreator; -import siprp.printer.Printer; - -import com.evolute.utils.Singleton; -import com.evolute.utils.date.DateUtils; -import com.evolute.utils.strings.StringPlainer; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.xml.SimpleXMLElement; - -/** - * - * @author Frederico - */ -public class FichasPrinter extends Thread -{ - protected static final DateFormat D_F = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) ); - protected static final DateFormat D_F_L = DateFormat.getDateInstance( DateFormat.LONG, new Locale( "pt", "PT" ) ); - - private ImpressaoFichasDataProvider provider; - - protected Integer ids[]; - protected String printerName; - protected String listPath; - protected String nomeEmpresa; - protected String nomeEstabelecimento; - - /** Creates a new instance of FichasPrinter */ - public FichasPrinter( Integer ids[], String printerName, String listPath, - String nomeEmpresa, String nomeEstabelecimento ) - { - this.ids = ids; - this.printerName = printerName; - this.listPath = listPath; - this.nomeEmpresa = nomeEmpresa; - this.nomeEstabelecimento = nomeEstabelecimento; - } - - public void run() - { - try - { - SimpleXMLElement root = new SimpleXMLElement( "LISTA_FICHAS" ); - for( int n = 0; n < ids.length; n++ ) - { - print( ids[ n ] ); - Object dados[] = provider.getDadosForExameID( ids[ n ] ); - SimpleXMLElement linha = new SimpleXMLElement( "FICHA" ); - linha.addElement( new SimpleXMLElement( "NOME", ( String ) dados[ 0 ] ) ); - linha.addElement( new SimpleXMLElement( "DATA_EXAME", D_F.format( ( Date ) dados[ 1 ] ) ) ); - linha.addElement( new SimpleXMLElement( "DATA_PROXIMO_EXAME", dados[ 2 ] != null ? D_F.format( ( Date ) dados[ 2 ] ) : "n/d" ) ); - root.addElement( linha ); - - try - { - sleep( (n % 5 == 0 && n > 0) ? 3000 : 2000 ); - } - catch( InterruptedException iex ) - { - } - } - Date today = ( Date ) Singleton.getInstance( Singleton.TODAY ); - Calendar cal = Calendar.getInstance(); - cal.setTime( today ); - SimpleXMLElement data = new SimpleXMLElement( "DATA_EXTENSO", DateUtils.WEEKDAYS_FULL_PT[ cal.get( Calendar.DAY_OF_WEEK ) - Calendar.MONDAY ] - + ", " + D_F_L.format( today ) ); - root.addElement( data ); - TransformerFactory tFactory = TransformerFactory.newInstance(); - String xml = root.toString(); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - FOPCreator creator = FOPCreator.getFOPCreator(); - InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() ); - creator.createFOfromXML( xmlIn, - FichasPrinter.class.getClassLoader().getResourceAsStream( - "siprp/impressaofichas/lista_fichas.xsl" ), - out ); - byte toPrint[] = out.toByteArray(); - ByteArrayInputStream in = new ByteArrayInputStream( toPrint ); - Hashtable printOptions = new Hashtable(); -//System.out.println( "OUT: " + out.toString() ); -// printOptions.put( FOPPrinterConstants.FOP_MANDATORY_PRINTER_NAME, printerName ); - FOPPrinter.getFOPPrinter().printFO( in, false, true, printOptions ); - byte []pdfData = PDFCreator.getPDFCreator().createPdfFromFo( toPrint ); - File dir = new File( new File( listPath ), StringPlainer.convertString( nomeEmpresa ).replace( ' ', '_' ) ); - if( !dir.exists() ) - { - dir.mkdir(); - } - String fileName = StringPlainer.convertString( nomeEstabelecimento ).replace( ' ', '_' ) - + "_" + DateUtils.plainFormatDate( today ) + ".pdf"; - FileOutputStream fos = new FileOutputStream( new File( dir, fileName ) ); - fos.write( pdfData ); - fos.close(); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a imprimir", true ); - } - ids = null; - } - - private void print( Integer exameID ) - throws Exception - { - if( provider == null ) - { - provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider(); - } -// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) ); -// ExameData exame = (ExameData) JDO.load( ExamesData.class, exameID ); -// byte pdf[] = (byte []) exame.get( ExamesData.PDF ); - - if( /* !printFO( exameID ) && */!printPDF( exameID ) ) - { - throw new Exception( "N\u00e3o existe exame" ); - } - } - - private boolean printFO(int exameID) throws Exception - { - boolean result = false; - byte[] fo = provider.getFO( exameID ); - if(fo != null) - { - Printer.printFO( fo ); - result = true; - } - return result; - } - - private boolean printPDF(int exameID) throws Exception - { - boolean result = false; - byte pdf[] = provider.getPDF( exameID ); - if( pdf != null ) - { - String nomeFicheiro = StringPlainer.convertString( provider.getNomeTrabalhadorForExameID( exameID ) ); - String split[] = nomeFicheiro.split( " " ); - nomeFicheiro = ""; - for( int n = 0; n < split.length; n++ ) - { - nomeFicheiro += split[n] + "_"; - } - Printer.printPDF( pdf, nomeFicheiro, printerName ); - result = true; - } - return result; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java deleted file mode 100644 index 8f186b67..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasDataProvider.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * HigieneDataProvider.java - * - * Created on February 1, 2006, 10:49 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.impressaofichas; - -import java.text.DateFormat; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; -import java.util.Locale; -import java.util.Vector; - -import com.evolute.utils.Singleton; -import com.evolute.utils.arrays.Virtual2DArray; -import com.evolute.utils.data.MappableObject; -import com.evolute.utils.db.DBManager; -import com.evolute.utils.db.Executer; -import com.evolute.utils.metadb.MetaProvider; -import com.evolute.utils.sql.Field; -import com.evolute.utils.sql.Select; -import com.evolute.utils.tables.ColumnizedMappable; - -/** - * - * @author fpalma - */ -public class ImpressaoFichasDataProvider extends MetaProvider -{ - private static final DateFormat DATE_FORMAT = - DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "PT", "pt" ) ); - - private static final Object LOCK = new Object(); - private static ImpressaoFichasDataProvider instance = null; - private final Executer executer; - - /** Creates a new instance of HigieneDataProvider */ - public ImpressaoFichasDataProvider() - throws Exception - { - DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER /*SingletonConstants.DBMANAGER*/ ); - executer = dbm.getSharedExecuter( this ); - } - - public static MetaProvider getProvider() - throws Exception - { - synchronized( LOCK ) - { - if( instance == null ) - { - instance = new ImpressaoFichasDataProvider(); - } - } - return instance; - } - - public ColumnizedMappable[] getAllEmpresas() - throws Exception - { - Select select = - new Select( new String[]{ "empresas" }, - new String[]{ "id", "designacao_social", "designacao_social_plain" }, - new Field( "inactivo" ).isDifferent( "y" ), - new String[]{ "designacao_social_plain" }, - null ); - Virtual2DArray array = executer.executeQuery( select ); - ColumnizedMappable empresas[] = new ColumnizedMappable[ array.columnLength() ]; - for( int n = 0; n < empresas.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String designacao = ( String ) array.get( n, 1 ); - empresas[ n ] = new ColumnizedMappable( id, designacao ); - } - return empresas; - } - - public ColumnizedMappable[] getAllEstabelecimentosForEmpresa( Integer empresaID ) - throws Exception - { - Select select = - new Select( new String[]{ "estabelecimentos" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "empresa_id" ).isEqual( empresaID ).and( - new Field( "inactivo" ).isDifferent( "y" ) ), - new String[]{ "nome_plain" }, - null ); - Virtual2DArray array = executer.executeQuery( select ); - ColumnizedMappable estabelecimentos[] = new ColumnizedMappable[ array.columnLength() ]; - for( int n = 0; n < estabelecimentos.length; n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - estabelecimentos[ n ] = new ColumnizedMappable( id, nome ); - } - return estabelecimentos; - } - - public Object [][]getAllFichasForEstabelecimentoAndDatas( Integer estabelecimentoID, Date dataInicio, Date dataFim ) - throws Exception - { - Vector fichas = new Vector(); - Select select = - new Select( new String[]{ "trabalhadores" }, - new String[]{ "id", "nome", "nome_plain" }, - new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ), - new String[]{ "nome_plain" }, - null ); - Virtual2DArray array = executer.executeQuery( select ); - for( int n = 0; n < array.columnLength(); n++ ) - { - Integer id = ( Integer ) array.get( n, 0 ); - String nome = ( String ) array.get( n, 1 ); - String nomePlain = ( String ) array.get( n, 2 ); - MappableObject fichasTrabalhador[] = getAllFichasForTrabalhadorAndDatas( id, dataInicio, dataFim ); - for( int f = 0; f < fichasTrabalhador.length; f++ ) - { - fichas.add( new Object[]{ fichasTrabalhador[ f ].getID(), nome, fichasTrabalhador[ f ].getValue(), nomePlain } ); - } - } - Object fichasArray[][] = ( Object[][] )fichas.toArray( new Object[ fichas.size() ][] ); - Arrays.sort( fichasArray, new Comparator< Object >(){ - public int compare( Object o1, Object o2 ) - { - Object arr1[] = ( Object[] )o1; - Object arr2[] = ( Object[] )o2; - int res = 0; - if( arr1[ 2 ] == null && arr2[ 2 ] == null ) - { - res = 0; - } - else if( arr1[ 2 ] == null ) - { - res = -1; - } - else if( arr2[ 2 ] == null ) - { - res = 1; - } - else - { - res = ( (Date)arr1[ 2 ]).compareTo( (Date)arr2[ 2 ] ); - } - - if( res == 0 ) - { - res = ( (String)arr1[ 3 ]).compareTo( (String)arr2[ 3 ] ); - } - return res; - } - } ); - for( int n = 0; n < fichasArray.length; n++ ) - { - fichasArray[ n ][ 2 ] = fichasArray[ n ][ 2 ] != null? DATE_FORMAT.format( (Date)fichasArray[ n ][ 2 ] ): ""; - } - return fichasArray; - } - - public MappableObject []getAllFichasForTrabalhadorAndDatas( Integer trabalhadorID, Date dataInicio, Date dataFim ) - throws Exception - { - Select select = - new Select( new String[]{ "exames" }, new String[]{ "MAX(id)", "data" }, - new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "inactivo" ).isEqual( "n" ) ).and( - new Field( "data" ).between( new Object[]{ dataInicio, dataFim } ) ), - new String[]{ "data DESC" }, new String[]{ "data" } ); - Virtual2DArray array = executer.executeQuery( select ); - MappableObject exames[] = new MappableObject[ array.columnLength() ]; - for( int n = 0; n < exames.length; n++ ) - { - Date date = (Date)array.get( n, 1 ); - Integer id = new Integer( ((Number)array.get( n, 0 )).intValue() ); - exames[ n ] = new MappableObject( id, date ); - } - return exames; - } - - public byte[] getPDF( Integer exameID ) - throws Exception - { - Select select = - new Select( new String[]{ "exames" }, - new String[]{ "pdf" }, - new Field( "id" ).isEqual( exameID ) ); - Virtual2DArray array = executer.executeQuery( select ); - byte pdf[] = ( byte[] ) array.get( 0, 0 ); - return pdf; - } - - public byte[] getFO( Integer exameID ) - throws Exception - { - Select select = - new Select( new String[]{ "exames" }, - new String[]{ "fo" }, - new Field( "id" ).isEqual( exameID ) ); - Virtual2DArray array = executer.executeQuery( select ); - byte fo[] = ( byte[] ) array.get( 0, 0 ); - return fo; - } - - public String getNomeTrabalhadorForExameID( Integer exameID ) - throws Exception - { - Select select = - new Select( new String[]{ "exames", "trabalhadores" }, - new String[]{ "trabalhadores.nome_plain" }, - new Field( "exames.id" ).isEqual( exameID ).and( - new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - return ( String ) array.get( 0, 0 ); - } - - public Object[] getDadosForExameID( Integer exameID ) - throws Exception - { - Select select = - new Select( new String[]{ "exames", "trabalhadores" }, - new String[]{ "trabalhadores.nome", "exames.data", "exames.proximo_exame" }, - new Field( "exames.id" ).isEqual( exameID ).and( - new Field( "exames.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) ) ); - Virtual2DArray array = executer.executeQuery( select ); - return array.getObjects()[ 0 ]; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java b/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java deleted file mode 100644 index 1c9949b2..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/ImpressaoFichasWindow.java +++ /dev/null @@ -1,445 +0,0 @@ -/* - * ImpressaoFichasUpperPanel.java - * - * Created on 19 de Fevereiro de 2006, 19:00 - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package siprp.impressaofichas; - -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Date; -import java.util.Properties; -import java.util.Vector; - -import javax.print.PrintService; -import javax.print.PrintServiceLookup; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import siprp.ui.SIPRPEditorWindow; - -import com.evolute.utils.properties.PropertyHandler; -import com.evolute.utils.tables.BaseTable; -import com.evolute.utils.tables.ColumnizedMappable; -import com.evolute.utils.tables.ColumnizedObjectArray; -import com.evolute.utils.tables.VectorTableModel; -import com.evolute.utils.ui.DialogException; -import com.evolute.utils.ui.calendar.JCalendarPanel; - -/** - * - * @author Frederico - */ -public class ImpressaoFichasWindow extends SIPRPEditorWindow - implements ListSelectionListener, ActionListener -{ - public final static String TITLE = "Impress\u00e3o de Fichas de Aptid\u00e3o"; - - protected final static String PATH_PROPERTY_SUFFIX = ".path"; - - private final static int iPermissionArray[][] = - new int[][]{ {} }; - - protected JCalendarPanel dataInicioPanel; - protected JCalendarPanel dataFimPanel; - protected VectorTableModel empresasModel; - protected BaseTable empresasTable; - protected VectorTableModel estabelecimentosModel; - protected BaseTable estabelecimentosTable; - protected VectorTableModel fichasModel; - protected BaseTable fichasTable; - protected JButton procurarButton; - protected JTextField pathText; - protected JButton pathButton; - protected JComboBox impressorasCombo; - protected JButton imprimirButton; - protected JButton imprimirTodasButton; - - protected ImpressaoFichasDataProvider provider; - protected PropertyHandler propertyHandler; - - /** Creates a new instance of ImpressaoFichasUpperPanel */ - public ImpressaoFichasWindow() - throws Exception - { - super( iPermissionArray ); - provider = ( ImpressaoFichasDataProvider ) ImpressaoFichasDataProvider.getProvider(); - propertyHandler = new PropertyHandler(); - setupComponents(); - } - - private void setupComponents() - throws Exception - { - setTitle( TITLE ); - empresasModel = new VectorTableModel( new String[]{ "empresas" } ); - empresasTable = new BaseTable( empresasModel ); - empresasTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - empresasTable.setNonResizableNorReordable(); - JScrollPane empresasScroll = - new JScrollPane( empresasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - empresasTable.getSelectionModel().addListSelectionListener( this ); - estabelecimentosModel = new VectorTableModel( new String[]{ "estabelecimentos" } ); - estabelecimentosTable = new BaseTable( estabelecimentosModel ); - estabelecimentosTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - estabelecimentosTable.setNonResizableNorReordable(); - JScrollPane estabelecimentosScroll = - new JScrollPane( estabelecimentosTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - estabelecimentosTable.getSelectionModel().addListSelectionListener( this ); - fichasModel = new VectorTableModel( new String[]{ "trabalhador", "data" } ); - fichasTable = new BaseTable( fichasModel ); - fichasTable.fixColumnWidth( 1, 120 ); - fichasTable.setNonResizableNorReordable(); - fichasTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); - fichasTable.getSelectionModel().addListSelectionListener( this ); - JScrollPane fichasScroll = new JScrollPane( fichasTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, - JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); - JLabel inicioLabel = new JLabel( "In\u00edcio" ); - dataInicioPanel = new JCalendarPanel( null ); - JLabel fimLabel = new JLabel( "Fim" ); - dataFimPanel = new JCalendarPanel( null ); - procurarButton = new JButton( "Carregar" ); - procurarButton.addActionListener( this ); - procurarButton.setEnabled( false ); - pathText = new JTextField(); - pathText.setEditable( false ); - pathButton = new JButton( "Escolher Direct\u00f3rio" ); - pathButton.addActionListener( this ); - impressorasCombo = new JComboBox(); - PrintService printers[] = PrintServiceLookup.lookupPrintServices( null, null ); - for( int n = 0; n < printers.length; n++ ) - { - impressorasCombo.addItem( printers[ n ].getName() ); - } - imprimirButton = new JButton( "Imprimir escolhidas" ); - imprimirButton.addActionListener( this ); - imprimirButton.setEnabled( false ); - imprimirTodasButton = new JButton( "Imprimir Todas" ); - imprimirTodasButton.addActionListener( this ); - imprimirTodasButton.setEnabled( false ); - JPanel upperPad = new JPanel(); - JPanel lowerPad = new JPanel(); - JPanel upperPanel = new JPanel(); - - GridBagLayout gridbag = new GridBagLayout(); - setLayout( gridbag ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.gridheight = 1; - constraints.weighty = 0.35; - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( upperPanel, constraints ); - - constraints.gridwidth = 2; - constraints.weightx = 1; - constraints.weighty = 0.65; - constraints.gridheight = GridBagConstraints.REMAINDER; - gridbag.setConstraints( fichasScroll, constraints ); - - constraints.weighty = 0; - constraints.gridheight = 1; - constraints.weightx = 0; - constraints.gridwidth = GridBagConstraints.REMAINDER; - gridbag.setConstraints( inicioLabel, constraints ); - gridbag.setConstraints( dataInicioPanel, constraints ); - gridbag.setConstraints( fimLabel, constraints ); - gridbag.setConstraints( dataFimPanel, constraints ); - gridbag.setConstraints( procurarButton, constraints ); - gridbag.setConstraints( pathText, constraints ); - gridbag.setConstraints( pathButton, constraints ); - gridbag.setConstraints( impressorasCombo, constraints ); - gridbag.setConstraints( imprimirButton, constraints ); - gridbag.setConstraints( imprimirTodasButton, constraints ); - - constraints.weighty = 0.32; - gridbag.setConstraints( upperPad, constraints ); - gridbag.setConstraints( lowerPad, constraints ); - - add( upperPanel ); - add( fichasScroll ); - add( upperPad ); - add( inicioLabel ); - add( dataInicioPanel ); - add( fimLabel ); - add( dataFimPanel ); - add( procurarButton ); - add( lowerPad ); - add( pathButton ); - add( pathText ); - add( impressorasCombo ); - add( imprimirButton ); - add( imprimirTodasButton ); - - upperPanel.setLayout( new GridLayout( 1, 2 ) ); - upperPanel.add( empresasScroll ); - upperPanel.add( estabelecimentosScroll ); - ColumnizedMappable empresas[] = provider.getAllEmpresas(); - Vector values = empresasModel.getValues(); - values.addAll( Arrays.asList( empresas ) ); - empresasModel.setValues( values ); - - Properties properties = propertyHandler.load(); -System.out.println( properties ); - String path = (String) properties.get( getClass().getName() + PATH_PROPERTY_SUFFIX ); - if( path == null ) - { - setDirectorio( System.getProperty( "user.home" ) ); - } - else - { - pathText.setText( path ); - } - } - - public void valueChanged( ListSelectionEvent e ) - { - Object source = e.getSource(); - if( e.getValueIsAdjusting() ) - { - return; - } - if( source.equals( empresasTable.getSelectionModel() ) ) - { - carregarEstabelecimentos(); - } - else if( source.equals( estabelecimentosTable.getSelectionModel() ) ) - { - procurarButton.setEnabled( estabelecimentosTable.getSelectedRow() != -1 ); - } - else if( source.equals( fichasTable.getSelectionModel() ) ) - { - imprimirButton.setEnabled( fichasTable.getSelectedRow() != -1 ); - } - } - - protected void carregarEstabelecimentos() - { - estabelecimentosTable.clearSelection(); - int selected = empresasTable.getSelectedRow(); - estabelecimentosModel.clearAll(); - if( selected > -1 ) - { - try - { - Integer empresaID = ( ( ColumnizedMappable ) empresasModel.getRowAt( selected ) ).getID(); - ColumnizedMappable estabelecimentos[] = provider.getAllEstabelecimentosForEmpresa( empresaID); - Vector values = estabelecimentosModel.getValues(); - values.addAll( Arrays.asList( estabelecimentos ) ); - estabelecimentosModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar os estabelecimentos.", true ); - estabelecimentosModel.clearAll(); - } - } - } - - public void clear() - { - empresasTable.clearSelection(); - } - - public void fill( Object value ) - { - if( value == null ) - { - clear(); - } - Integer ids[] = ( Integer [] ) value; - for( int n = 0; n < empresasTable.getRowCount(); n++ ) - { - if( ( ( ColumnizedMappable ) empresasModel.getRowAt( n ) ).getID().equals( ids[ 0 ] ) ) - { - empresasTable.setRowSelectionInterval( n, n ); - break; - } - } - - for( int n = 0; n < estabelecimentosTable.getRowCount(); n++ ) - { - if( ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( n ) ).getID().equals( ids[ 1 ] ) ) - { - estabelecimentosTable.setRowSelectionInterval( n, n ); - break; - } - } - } - - public Object save() - { - int empresaSelected = empresasTable.getSelectedRow(); - int estabelecimentoSelected = estabelecimentosTable.getSelectedRow(); - return new Integer[]{ - empresaSelected == -1 ? null : ( ( ColumnizedMappable ) empresasModel.getRowAt( empresaSelected ) ).getID(), - estabelecimentoSelected == -1 ? null : ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( estabelecimentoSelected ) ).getID() - }; - } - - public void setEnabled( boolean enable ) - { - empresasTable.setEnabled( enable ); - estabelecimentosTable.setEnabled( enable ); - } - - public void actionPerformed( ActionEvent e ) - { - Object source = e.getSource(); - if( source.equals( procurarButton ) ) - { - procurar(); - } - else if( source.equals( imprimirButton ) ) - { - imprimir(); - } - else if( source.equals( imprimirTodasButton ) ) - { - imprimirTodas(); - } - else if( source.equals( pathButton ) ) - { - escolherDirectorio(); - } - } - - public void procurar() - { - int selected = estabelecimentosTable.getSelectedRow(); - Date dataInicio = dataInicioPanel.getDate(); - Date dataFim = dataFimPanel.getDate(); - if( selected == -1 || ( dataInicio == null && dataFim == null ) ) - { - JOptionPane.showMessageDialog( this, "Tem de escolher pelo menos uma data e um estabelecimento.", "Erro", - JOptionPane.ERROR_MESSAGE ); - return; - } - if( dataInicio == null ) - { - dataInicio = dataFim; - } - else if( dataFim == null ) - { - dataFim = dataInicio; - } - fichasModel.clearAll(); - try - { - Integer estabelecimentoID = ( ( ColumnizedMappable ) estabelecimentosModel.getRowAt( selected ) ).getID(); - Object fichas[][] = provider.getAllFichasForEstabelecimentoAndDatas( estabelecimentoID, dataInicio, dataFim ); - Vector values = fichasModel.getValues(); - for( int n = 0; n < fichas.length; n++ ) - { - values.add( new ColumnizedObjectArray( fichas[ n ], true ) ); - } - fichasModel.setValues( values ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a carregar a lista.", true ); - estabelecimentosModel.clearAll(); - } - imprimirTodasButton.setEnabled( fichasTable.getRowCount() > 0 ); - } - - public void imprimir() - { - imprimirLinhas( fichasTable.getSelectedRows() ); - } - - public void imprimirTodas() - { - int linhas[] = new int[ fichasTable.getRowCount() ]; - for( int n = 0; n < linhas.length; n++ ) - { - linhas[ n ] = n; - } - imprimirLinhas( linhas ); - } - - protected void imprimirLinhas( int linhas[] ) - { - try - { - File file = new File( pathText.getText().trim() ); - if( !file.exists() || !file.isDirectory() ) - { - throw new IOException( "Direct\u00f3rio inexistente ou indispon\u00edvel: " + pathText.getText().trim() ); - } - } - catch( IOException ioex ) - { - JOptionPane.showMessageDialog( this, ioex.getMessage(), "Erro...", - JOptionPane.ERROR_MESSAGE ); - return; - } - String impressora = ( String ) impressorasCombo.getSelectedItem(); - Integer ids[] = new Integer[ linhas.length ]; - for( int n = 0; n < ids.length; n++ ) - { - ids[ n ] = ( ( ColumnizedObjectArray )fichasModel.getRowAt( linhas[ n ] ) ).getID(); - } - int option = JOptionPane.showConfirmDialog( this, "Imprimir as " + ids.length + " fichas para a impressora " + impressora + "?", - "Imprimir", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE ); - if( option == 0 ) - { - System.out.println( "imprimir" ); - new FichasPrinter( ids, impressora, pathText.getText().trim(), - empresasModel.getRowAt( empresasTable.getSelectedRow() ).toString(), - estabelecimentosModel.getRowAt( estabelecimentosTable.getSelectedRow() ).toString() ).start(); - } - } - - protected void escolherDirectorio() - { - JFileChooser chooser = new JFileChooser(); - chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ); - int returnVal = chooser.showOpenDialog( this ); - if(returnVal == JFileChooser.APPROVE_OPTION) - { - setDirectorio( chooser.getSelectedFile().getAbsolutePath() ); - } - } - - protected void setDirectorio( String path ) - { - if( path != null ) - { - pathText.setText( path ); - Properties properties = propertyHandler.load(); - properties.setProperty( getClass().getName() + PATH_PROPERTY_SUFFIX, path ); - try - { - propertyHandler.save( properties ); - } - catch( IOException ioex ) - { - ioex.printStackTrace(); - } - } - } -} diff --git a/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl b/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl deleted file mode 100644 index 98b21d4b..00000000 --- a/trunk/SIPRPSoft/src/siprp/impressaofichas/lista_fichas.xsl +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - RELAÇÃO DE FICHAS DE APTIDÃO ENVIADAS - - - - - - - - - - NOME - - - DATA EXAME - - - PRÓXIMO EXAME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/externos/actions/TratarExternoAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/externos/actions/TratarExternoAction.java index ea2c2d45..b5b50fa2 100755 --- a/trunk/SIPRPSoft/src/siprp/lembretes/externos/actions/TratarExternoAction.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/externos/actions/TratarExternoAction.java @@ -17,13 +17,13 @@ import java.util.List; import javax.swing.AbstractAction; import javax.swing.JOptionPane; +import shst.SHSTPropertiesConstants; import shst.data.outer.EmpresasData; import shst.data.outer.EstabelecimentosData; import shst.data.outer.TrabalhadoresData; import shst.data.provider.MedicinaDataProvider; import shst.medicina.multi.MultiMarcacoesWindow; import siprp.SIPRPTracker; -import siprp.SingletonConstants; import siprp.lembretes.Lembrete; import siprp.lembretes.LembretesDataProvider; @@ -67,7 +67,7 @@ public class TratarExternoAction extends AbstractAction { try { - tracker = (SIPRPTracker) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER ); + tracker = (SIPRPTracker) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ ); Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID ); if( lembrete == null ) { diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/marcacoes/actions/TratarCriacaoProcessoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/marcacoes/actions/TratarCriacaoProcessoTrabalhadorAction.java index 11913280..df985db3 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/marcacoes/actions/TratarCriacaoProcessoTrabalhadorAction.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/marcacoes/actions/TratarCriacaoProcessoTrabalhadorAction.java @@ -17,13 +17,13 @@ import java.util.List; import javax.swing.AbstractAction; import javax.swing.JOptionPane; +import shst.SHSTPropertiesConstants; import shst.data.outer.EmpresasData; import shst.data.outer.EstabelecimentosData; import shst.data.outer.TrabalhadoresData; import shst.data.provider.MedicinaDataProvider; import shst.medicina.multi.MultiMarcacoesWindow; import siprp.SIPRPTracker; -import siprp.SingletonConstants; import siprp.lembretes.Lembrete; import siprp.lembretes.LembretesDataProvider; @@ -71,7 +71,7 @@ public class TratarCriacaoProcessoTrabalhadorAction extends AbstractAction { try { - tracker = ( SIPRPTracker ) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER ); + tracker = ( SIPRPTracker ) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ ); Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID ); if( lembrete == null ) { diff --git a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java index 01eb949d..2e779c8f 100644 --- a/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java +++ b/trunk/SIPRPSoft/src/siprp/lembretes/remarcacoes/actions/TratarMarcacaoTrabalhadorAction.java @@ -17,6 +17,7 @@ import java.util.List; import javax.swing.AbstractAction; import javax.swing.JOptionPane; +import shst.SHSTPropertiesConstants; import shst.data.outer.EmpresasData; import shst.data.outer.EstabelecimentosData; import shst.data.outer.MarcacoesTrabalhadorData; @@ -30,7 +31,6 @@ import shst.data.provider.BaseProvider; import shst.data.provider.MedicinaDataProvider; import shst.medicina.multi.MultiMarcacoesWindow; import siprp.SIPRPTracker; -import siprp.SingletonConstants; import siprp.lembretes.Lembrete; import siprp.lembretes.LembretesDataProvider; @@ -79,7 +79,7 @@ public class TratarMarcacaoTrabalhadorAction extends AbstractAction { try { - tracker = ( SIPRPTracker ) Singleton.getInstance( SingletonConstants.SIPRP_TRACKER ); + tracker = ( SIPRPTracker ) Singleton.getInstance( SHSTPropertiesConstants.SHST_TRACKER /*SingletonConstants.SIPRP_TRACKER*/ ); Lembrete lembrete = lembretesProvider.getLembreteByID( lembreteID ); if( lembrete == null ) { diff --git a/trunk/SIPRPSoft/src/siprp/ui/SIPRPIcon.java b/trunk/SIPRPSoft/src/siprp/ui/SIPRPIcon.java deleted file mode 100644 index 8f82f794..00000000 --- a/trunk/SIPRPSoft/src/siprp/ui/SIPRPIcon.java +++ /dev/null @@ -1,9 +0,0 @@ -package siprp.ui; - - - - -public class SIPRPIcon -{ - -}