diff --git a/trunk/SIPRPSoft/lib.tools/evo-ant.jar b/trunk/SIPRPSoft/lib.tools/evo-ant.jar index f49f3f89..3617ed4d 100644 Binary files a/trunk/SIPRPSoft/lib.tools/evo-ant.jar and b/trunk/SIPRPSoft/lib.tools/evo-ant.jar differ diff --git a/trunk/SIPRPSoft/lib/evolute.jar b/trunk/SIPRPSoft/lib/evolute.jar index ab5af455..bd5466f7 100644 Binary files a/trunk/SIPRPSoft/lib/evolute.jar and b/trunk/SIPRPSoft/lib/evolute.jar differ diff --git a/trunk/SIPRPSoft/lib/shst.jar b/trunk/SIPRPSoft/lib/shst.jar index 9737f87b..d5f0ca65 100644 Binary files a/trunk/SIPRPSoft/lib/shst.jar and b/trunk/SIPRPSoft/lib/shst.jar differ diff --git a/trunk/SIPRPSoft/properties/2-testing/app.properties b/trunk/SIPRPSoft/properties/2-testing/app.properties index 5a6a7c29..9c921a81 100644 --- a/trunk/SIPRPSoft/properties/2-testing/app.properties +++ b/trunk/SIPRPSoft/properties/2-testing/app.properties @@ -13,6 +13,15 @@ db.connection.driver = org.postgresql.Driver jnlp.resources.property.server.address = www.evolute.pt jnlp.resources.property.server.port = 5436 +module_spellchecker=true +module_cursos=true +module_utilizadores=false +module_ficha=true +module_clientes=true +module_relatorio=true +module_listagens=true +module_medicina_controlo_fluxo_ecd=true +module_hs_trabalho_plano_actuacao=true #app.max.mem=512M #app.run.args=test 1 2 3 @@ -31,8 +40,6 @@ shst.prestador.omissao.id=35 shst.prestador.omissao.nome = SIPRP shst.prestador.analisador.tab = true -module_spellchecker=true - app.icon.path=logo/icon.png #usado em UserDataProvider (shst.jar) diff --git a/trunk/SIPRPSoft/properties/3-production/app.properties b/trunk/SIPRPSoft/properties/3-production/app.properties index d27a2132..bf600c9f 100644 --- a/trunk/SIPRPSoft/properties/3-production/app.properties +++ b/trunk/SIPRPSoft/properties/3-production/app.properties @@ -31,6 +31,15 @@ shst.prestador.omissao.nome = SIPRP shst.prestador.analisador.tab = true module_spellchecker=true +module_cursos=true +module_utilizadores=false +module_ficha=true +module_clientes=true +module_relatorio=true +module_listagens=true +module_medicina_controlo_fluxo_ecd=true +module_hs_trabalho_plano_actuacao=true + app.icon.path=logo/icon.png diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index 91c13a28..a9c5d3f1 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -23,10 +23,10 @@ import javax.swing.tree.MutableTreeNode; import shst.SHSTPropertiesConstants; import shst.SHSTShutdownHook; +import shst.SHSTTracker; import shst.companydataloaders.SIPRPPropertiesLoader; import shst.initializer.SHSTORMInitializer; import shst.lembretes.LembretesDaemon; -import siprp.clientes.AvisosPanel; import siprp.initializer.SIPRPLoggerInit; import siprp.initializer.SIPRPUIInitializer; import siprp.update.UpdateList; @@ -53,10 +53,9 @@ public class Main implements com.evolute.utils.ui.window.Connector { private static String dbase; - private static SIPRPTracker siprpTracker; + private static SHSTTracker shstTracker; private static LoginWindow loginWindow; - private static AvisosPanel avisos = null; public static File fopConfigFile; static @@ -92,7 +91,6 @@ public class Main implements com.evolute.utils.ui.window.Connector UnicodeChecker.setUseDoubleSlash( true ); - avisos = new AvisosPanel(); final String logoFileName = ( String ) Singleton.getInstance( SHSTPropertiesConstants.COMPANY_LOGO ); String url = null; @@ -130,7 +128,7 @@ public class Main implements com.evolute.utils.ui.window.Connector new String[] { (String) Singleton.getInstance( SHSTPropertiesConstants.SOFTWARE_NAME ) }, new String[] { "Vers\u00E3o " + ProjectTools.getInstance().getVersion(), "(EVOLUTE 2004-2010)" }, "", (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_USER ), - (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_PASSWORD ), avisos, false ); + (String)Singleton.getInstance( SHSTPropertiesConstants.LOCAL_PASSWORD ), null, false ); loginWindow.setTitle( (String) Singleton.getInstance( SHSTPropertiesConstants.SOFTWARE_NAME ) ); String iconPath = ( String ) Singleton.getInstance( EvoPropertyKey.APP.ICON_PATH ); @@ -143,7 +141,7 @@ public class Main implements com.evolute.utils.ui.window.Connector JPanel left = loginWindow.getLeftPanel(); left.setBackground( Color.white ); - loginWindow.setSize( 1024, 510 ); + loginWindow.setSize( 700, 510 ); loginWindow.setExtendedState(loginWindow.getExtendedState() | LoginWindow.MAXIMIZED_BOTH); loginWindow.setVisible( true ); SwingUtilities.invokeLater( new Runnable() @@ -153,7 +151,6 @@ public class Main implements com.evolute.utils.ui.window.Connector { try { - siprpTracker.setLoginWindow( loginWindow ); loginWindow.expandAll(); } catch ( Exception e ) @@ -211,9 +208,8 @@ public class Main implements com.evolute.utils.ui.window.Connector { Singleton.setInstance( Singleton.USERNAME, user ); SIPRPLoggerInit.init(); - siprpTracker = new SIPRPTracker( avisos ); + shstTracker = SHSTTracker.getInstance();//new SIPRPTracker( avisos ); - avisos.refresh(); LembretesDaemon.go(); return true; @@ -222,9 +218,9 @@ public class Main implements com.evolute.utils.ui.window.Connector @Override public boolean disconnect() { - if( siprpTracker.quit() ) + if( shstTracker.quit() ) { - siprpTracker = null; + shstTracker = null; try { ( ( DBManager )Singleton.getInstance( Singleton.DEFAULT_DBMANAGER ) ).close(); @@ -244,7 +240,7 @@ public class Main implements com.evolute.utils.ui.window.Connector { try { - siprpTracker.openWindow( ( String )node.getUserObject() ); + shstTracker.openWindow( ( String )node.getUserObject() ); } catch( Exception ex ) { @@ -256,31 +252,18 @@ public class Main implements com.evolute.utils.ui.window.Connector @Override public void exit() { - if( siprpTracker == null || siprpTracker.quit() ) + if( shstTracker == null || shstTracker.quit() ) { -// Thread exit = new Thread( new Runnable() -// { -// @Override -// public void run() -// { - if ( siprpTracker != null && siprpTracker.getLoginWindow() != null ) - { - siprpTracker.getLoginWindow().setVisible( false ); - siprpTracker.getLoginWindow().dispose(); - } - System.exit( 0 ); -// } -// }); -// exit.setName( "Exit Thread" ); -// exit.setDaemon( false ); -// exit.start(); + loginWindow.setVisible( false ); + loginWindow.dispose(); + System.exit( 0 ); } } @Override public MutableTreeNode getTree() { - return siprpTracker.getRoot(); + return shstTracker.getRoot(); } } diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java deleted file mode 100644 index 257c243e..00000000 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * SIPRPTracker.java - * - * Created on 18 de Maio de 2004, 19:46 - */ - -package siprp; - - -import java.util.HashMap; -import java.util.Map; - -import javax.swing.tree.DefaultMutableTreeNode; - -import shst.SHSTPropertiesConstants; -import shst.SHSTTrackerInterface; -import shst.companydataloaders.SIPRPPropertiesLoader; -import shst.cursos.CursosWindowAdapter; -import shst.higiene.gestao.GestaoRelatorioWindow; -import shst.higiene.relatorio.RelatorioHigieneSegurancaWindow; -import shst.higiene.trabalho.mapa.HSTrabalhoMapaWindow; -import shst.higiene.trabalho.marcacoes.MarcacoesHigieneInterface; -import shst.higiene.trabalho.marcacoes.MarcacoesHigieneWindow; -import shst.impressaofichas.ImpressaoFichasWindow; -import shst.lembretes.LembretesMultiWindow; -import shst.medicina.MedicinaWindow; -import shst.medicina.MedicinaWindowInterface; -import shst.medicina.exames.ui.RecepcaoExamesWindow; -import shst.medicina.locais_analise.EnviarAnalisesWindow; -import shst.medicina.locais_realizacao.LocaisRealizacaoWindow; -import shst.medicina.multi.MultiMarcacoesWindow; -import shst.medicina.presencas.RegistarPresencasWindow; -import shst.medicina.prestadores.PrestadoresWindow; -import siprp.clientes.AvisosPanel; -import siprp.cursos.SIPRPCursosInit; -import siprp.estatistica.EstatisticaWindow; -import siprp.ficha.FichaWindow; -import siprp.pesquisas.RelatorioAnualWindow; - -import com.evolute.module.cursos.CursosWindow; -import com.evolute.utils.Singleton; -import com.evolute.utils.error.ErrorLogger; -import com.evolute.utils.tracker.TrackableWindow; -import com.evolute.utils.tracker.WindowCreator; -import com.evolute.utils.tracker.WindowTracker; -import com.evolute.utils.ui.window.LoginWindow; -/** - * - * @author fpalma - */ -public class SIPRPTracker extends WindowTracker implements SHSTTrackerInterface -{ - public static final String FICHA_APTIDAO = "Ficha de Aptid\u00e3o"; - public static final String CRIACAO_FICHA_APTIDAO = "Cria\u00e7\u00e3o de Fichas de Aptid\u00e3o"; - public static final String GESTAO_CLIENTES = "Gest\u00e3o de Clientes"; - public static final String MEDICINA = "Medicina"; - public static final String MEDICINA_MARCACOES = "Marca\u00e7\u00f5es"; - public static final String MEDICINA_MULTI_MARCACOES = MultiMarcacoesWindow.TITLE; - public static final String MEDICINA_LOCAIS = "Locais de Realiza\u00e7\u00e3o"; - public static final String MEDICINA_ENVIO_ANALISES = EnviarAnalisesWindow.TITLE; - public static final String MEDICINA_PRESENCAS = "Presen\u00e7as"; - public static final String HIGIENE_SEGURANCA = "Higiene e Seguran\u00e7a"; - public static final String RELATORIO_ANUAL = "Relat\u00f3rio Anual"; - public static final String LISTAGENS = "Listagens"; - - private final AvisosPanel avisos; - private shst.clientes.ClientesWindow clientesWindow; - private MedicinaWindowInterface medicinaWindow; - private MultiMarcacoesWindow multiMarcacoesWindow; - private MarcacoesHigieneInterface higieneWindow; - - private LoginWindow loginWindow = null; - - /** Creates a new instance of SIPRPTracker */ - public SIPRPTracker( AvisosPanel avisosP ) - { - Singleton.setInstance( SHSTPropertiesConstants.SHST_TRACKER, this ); - Singleton.setInstance( Singleton.TRACKER, this ); - this.avisos = avisosP; - avisos.setTracker( this ); - Map creators = new HashMap(); - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( - Singleton.getInstance( SHSTPropertiesConstants.COMPANY_ACRONYM ) ); - - boolean hasFicha = ( (Boolean) Singleton.getInstance( SHSTPropertiesConstants.MODULE_FICHA ) ).booleanValue(); - boolean hasGestao = ( (Boolean) Singleton.getInstance( SHSTPropertiesConstants.MODULE_CLIENTES ) ).booleanValue(); - boolean hasRelatorio = ( (Boolean) Singleton.getInstance( SHSTPropertiesConstants.MODULE_RELATORIO ) ).booleanValue(); - boolean hasListagens = ( (Boolean) Singleton.getInstance( SHSTPropertiesConstants.MODULE_LISTAGENS ) ).booleanValue(); - boolean hasCursos = SIPRPPropertiesLoader.getInstance().findProperty( SHSTPropertiesConstants.MODULE_CURSOS, true ); - - if( hasGestao ) - { - try - { - clientesWindow = new shst.clientes.ClientesWindow( avisos ); - clientesWindow.setTracker( this ); - medicinaWindow = new MedicinaWindow(); - medicinaWindow.setTracker( this ); - higieneWindow = new MarcacoesHigieneWindow(); - higieneWindow.setTracker( this ); - } - catch( Exception ex ) - { - clientesWindow = null; - medicinaWindow = null; - higieneWindow = null; - ErrorLogger.logException(ex); - } - } - else - { - clientesWindow = null; - medicinaWindow = null; - } - - if( hasFicha ) - { - DefaultMutableTreeNode fichaNode = new DefaultMutableTreeNode( FICHA_APTIDAO ); - - fichaNode.add( new DefaultMutableTreeNode( CRIACAO_FICHA_APTIDAO ) ); - creators.put( CRIACAO_FICHA_APTIDAO, new WindowCreator(){ - public TrackableWindow create() - throws Exception - { - return FichaWindow.getWindow(); - } - } ); - - fichaNode.add( new DefaultMutableTreeNode( ImpressaoFichasWindow.TITLE ) ); - creators.put( ImpressaoFichasWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new ImpressaoFichasWindow(); - } - } ); - - rootNode.add( fichaNode ); - } - - if( hasGestao ) - { - rootNode.add( new DefaultMutableTreeNode( GESTAO_CLIENTES ) ); - creators.put( GESTAO_CLIENTES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return getClientesWindow(); - } - } ); - - rootNode.add( new DefaultMutableTreeNode( LembretesMultiWindow.TITLE ) ); - creators.put( LembretesMultiWindow.TITLE, new WindowCreator() { - @Override - public TrackableWindow create() throws Exception - { - return new LembretesMultiWindow(); - } - }); - - DefaultMutableTreeNode medicinaNode = new DefaultMutableTreeNode( MEDICINA ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_MARCACOES ) ); - creators.put( MEDICINA_MARCACOES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return getMedicinaWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_MULTI_MARCACOES ) ); - creators.put( MEDICINA_MULTI_MARCACOES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return getMultiMarcacoesWindow(); - } - }); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_LOCAIS ) ); - creators.put( MEDICINA_LOCAIS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new LocaisRealizacaoWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_ENVIO_ANALISES ) ); - creators.put( MEDICINA_ENVIO_ANALISES, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new EnviarAnalisesWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( RecepcaoExamesWindow.TITLE ) ); - creators.put( RecepcaoExamesWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new RecepcaoExamesWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( MEDICINA_PRESENCAS ) ); - creators.put( MEDICINA_PRESENCAS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new RegistarPresencasWindow(); - } - } ); - - medicinaNode.add( new DefaultMutableTreeNode( PrestadoresWindow.TITLE ) ); - creators.put( PrestadoresWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new PrestadoresWindow(); - } - } ); - - rootNode.add( medicinaNode ); - - DefaultMutableTreeNode higieneNode = new DefaultMutableTreeNode( HIGIENE_SEGURANCA ); - - higieneNode.add( new DefaultMutableTreeNode( MarcacoesHigieneWindow.TITLE ) ); - creators.put( MarcacoesHigieneWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return getHigieneWindow(); - } - } ); - - higieneNode.add( new DefaultMutableTreeNode( HSTrabalhoMapaWindow.TITLE ) ); - creators.put( HSTrabalhoMapaWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new HSTrabalhoMapaWindow(); - } - } ); - higieneNode.add( new DefaultMutableTreeNode( GestaoRelatorioWindow.TITLE ) ); - creators.put( GestaoRelatorioWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new GestaoRelatorioWindow(); - } - } ); - higieneNode.add( new DefaultMutableTreeNode( RelatorioHigieneSegurancaWindow.TITLE ) ); - creators.put( RelatorioHigieneSegurancaWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new RelatorioHigieneSegurancaWindow(); - } - } ); - rootNode.add( higieneNode ); - } - - if( hasRelatorio ) - { - rootNode.add( new DefaultMutableTreeNode( RELATORIO_ANUAL ) ); - creators.put( RELATORIO_ANUAL, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new RelatorioAnualWindow(); - } - } ); - } - - if( hasListagens ) - { - rootNode.add( new DefaultMutableTreeNode( LISTAGENS ) ); - creators.put( LISTAGENS, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new EstatisticaWindow(); - } - } ); - } - - - try - { - SIPRPCursosInit.initFactory(); - } - catch ( Exception e ) - { - ErrorLogger.logException( e ); - } - if( hasCursos ) - { - rootNode.add( new DefaultMutableTreeNode( CursosWindow.TITLE ) ); - creators.put( CursosWindow.TITLE, new WindowCreator() { - public TrackableWindow create() - throws Exception - { - return new CursosWindowAdapter(); - } - } ); - } - setRoot( rootNode ); - setCreators( creators ); - } - - @Override - public shst.clientes.ClientesWindow getClientesWindow() - { - try - { - if( clientesWindow == null ) - { - clientesWindow = new shst.clientes.ClientesWindow( avisos ); - clientesWindow.setTracker( SIPRPTracker.this ); - } - } - catch( Exception e ) - { - ErrorLogger.logException( e ); - } - return clientesWindow; - } - - @Override - public MedicinaWindowInterface getMedicinaWindow() throws Exception - { - if( medicinaWindow == null ) - { - medicinaWindow = new MedicinaWindow(); - medicinaWindow.setTracker( SIPRPTracker.this ); - } - return medicinaWindow; - } - - @Override - public MultiMarcacoesWindow getMultiMarcacoesWindow() - { - try - { - if( multiMarcacoesWindow == null ) - { - multiMarcacoesWindow = new MultiMarcacoesWindow(); - multiMarcacoesWindow.setTracker( SIPRPTracker.this ); - } - } - catch( Exception e ) - { - ErrorLogger.logException( e ); - } - return multiMarcacoesWindow; - } - - @Override - public MarcacoesHigieneInterface getHigieneWindow() throws Exception - { - if( higieneWindow == null ) - { - higieneWindow = new MarcacoesHigieneWindow(); - higieneWindow.setTracker( SIPRPTracker.this ); - } - return higieneWindow; - } - - @Override - public AvisosPanel getAvisosPanel() - { - return avisos; - } - - public void setLoginWindow( LoginWindow loginWindow ) - { - this.loginWindow = loginWindow; - } - - public LoginWindow getLoginWindow() - { - return loginWindow; - } -} diff --git a/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java deleted file mode 100644 index 399e5e35..00000000 --- a/trunk/SIPRPSoft/src/siprp/clientes/AvisosPanel.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * AvisosPanel.java - * - * Created on 21 de Maio de 2004, 13:06 - */ - -package siprp.clientes; - -import java.awt.Color; -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.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Hashtable; -import java.util.Map; -import java.util.Set; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; - -import shst.clientes.AvisosPanelInterface; -import shst.data.AvisoConstants; -import shst.data.outer.AvisosData; -import shst.data.outer.EmpresasData; -import shst.data.outer.EstabelecimentosData; -import shst.data.outer.TrabalhadoresData; -import siprp.FichaDataProvider; -import siprp.SIPRPTracker; - -import com.evolute.entity.ProviderInterface; -import com.evolute.utils.Singleton; -import com.evolute.utils.dataui.ControllableComponent; -import com.evolute.utils.ui.DialogException; - -/** - * - * @author fpalma - */ -public class AvisosPanel extends JPanel implements ActionListener, ControllableComponent< Object >, AvisosPanelInterface -{ - private static final long serialVersionUID = 1L; - private static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT ); - private ProviderInterface JDO; - private FichaDataProvider provider; - private SIPRPTracker tracker; - - private JPanel empresaPanel; - private JPanel estabelecimentosPanel; - private JPanel trabalhadoresPanel; - - private Object avisosEmpresa[][]; - private Object avisosEstabelecimento[][]; - private Object avisosTrabalhador[][]; - - private boolean refreshed = false; - - private Hashtable buttonHash; - private Hashtable buttonTypeHash; - - /** Creates a new instance of AvisosPanel */ - public AvisosPanel() throws Exception - { - buttonHash = new Hashtable(); - buttonTypeHash = new Hashtable(); - JDO = (ProviderInterface) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER ); - } - - private void setupComponents() - { - empresaPanel = new JPanel(); - empresaPanel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Empresas" ) ); - empresaPanel.setLayout( new GridLayout( avisosEmpresa.length, 1 ) ); - GridBagConstraints constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.HORIZONTAL; - constraints.weighty = 0; - for( int n = 0; n < avisosEmpresa.length; n++ ) - { - JPanel pan = new JPanel(); - GridBagLayout gridbag = new GridBagLayout(); - pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); - pan.setLayout( gridbag ); - constraints.gridheight = GridBagConstraints.REMAINDER; - constraints.gridx = 0; - constraints.weightx = 0; - constraints.gridwidth = 1; - JButton tratarButton = new JButton( "Tratar" ); - gridbag.setConstraints( tratarButton, constraints ); - pan.add( tratarButton ); - buttonHash.put( tratarButton, avisosEmpresa[ n ][ 0 ] ); - buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_EMPRESA ) ); - tratarButton.addActionListener( this ); - - constraints.gridx = 1; - constraints.weightx = 1; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel empresaLabel = new JLabel( "" + avisosEmpresa[ n ][ 3 ] ); - gridbag.setConstraints( empresaLabel, constraints ); - pan.add( empresaLabel ); - - - constraints.weightx = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel descricaoLabel = criarDescricao( avisosEmpresa[ n ] ); - gridbag.setConstraints( descricaoLabel, constraints ); - pan.add( descricaoLabel ); - - empresaPanel.add( pan ); - } - - estabelecimentosPanel = new JPanel(); - estabelecimentosPanel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Estabelecimentos" ) ); - estabelecimentosPanel.setLayout( new GridLayout( avisosEstabelecimento.length, 1 ) ); - - for( int n = 0; n < avisosEstabelecimento.length; n++ ) - { - Date dataAviso = ( Date ) avisosEstabelecimento[ n ][ 5 ]; - Date dataEvento = ( Date ) avisosEstabelecimento[ n ][ 1 ]; - Calendar calAviso = Calendar.getInstance(); - calAviso.setTime( dataAviso ); - Calendar calEvento = Calendar.getInstance(); - calEvento.setTime( dataEvento ); - boolean mesmoDia = - ( calAviso.get( Calendar.YEAR ) == calEvento.get( Calendar.YEAR ) ) && - ( calAviso.get( Calendar.MONTH ) == calEvento.get( Calendar.MONTH ) ) && - ( calAviso.get( Calendar.DAY_OF_MONTH ) == calEvento.get( Calendar.DAY_OF_MONTH ) ); - JPanel pan = new JPanel(); - GridBagLayout gridbag = new GridBagLayout(); - pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); - pan.setLayout( gridbag ); - constraints.gridheight = GridBagConstraints.REMAINDER; - constraints.gridx = 0; - constraints.weightx = 0; - constraints.gridwidth = 1; - JButton tratarButton = new JButton( mesmoDia ? "Confirmar" : "Marcar" ); - gridbag.setConstraints( tratarButton, constraints ); - pan.add( tratarButton ); - buttonHash.put( tratarButton, avisosEstabelecimento[ n ][ 0 ] ); - buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_ESTABELECIMENTO ) ); - tratarButton.addActionListener( this ); - - constraints.gridx = 1; - constraints.weightx = 1; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel empresaLabel = new JLabel( "" + avisosEstabelecimento[ n ][ 3 ] ); - gridbag.setConstraints( empresaLabel, constraints ); - pan.add( empresaLabel ); - - JLabel estabelecimentoLabel = new JLabel( "" + avisosEstabelecimento[ n ][ 4 ] ); - gridbag.setConstraints( estabelecimentoLabel, constraints ); - pan.add( estabelecimentoLabel ); - - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel descricaoLabel = criarDescricao( avisosEstabelecimento[ n ] ); - gridbag.setConstraints( descricaoLabel, constraints ); - pan.add( descricaoLabel ); - - estabelecimentosPanel.add( pan ); - } - - trabalhadoresPanel = new JPanel(); - trabalhadoresPanel.setBorder( - BorderFactory.createTitledBorder( - BorderFactory.createLineBorder( new Color( 0.0f, 0.0f, 0.0f, 0.0f ), 1 ), "Trabalhadores" ) ); - trabalhadoresPanel.setLayout( new GridLayout( avisosTrabalhador.length, 1 ) ); - - for( int n = 0; n < avisosTrabalhador.length; n++ ) - { - Date dataAviso = ( Date ) avisosTrabalhador[ n ][ 6 ]; - Date dataEvento = ( Date ) avisosTrabalhador[ n ][ 1 ]; - Calendar calAviso = Calendar.getInstance(); - calAviso.setTime( dataAviso ); - Calendar calEvento = Calendar.getInstance(); - calEvento.setTime( dataEvento ); - boolean mesmoDia = - ( calAviso.get( Calendar.YEAR ) == calEvento.get( Calendar.YEAR ) ) && - ( calAviso.get( Calendar.MONTH ) == calEvento.get( Calendar.MONTH ) ) && - ( calAviso.get( Calendar.DAY_OF_MONTH ) == calEvento.get( Calendar.DAY_OF_MONTH ) ); - JPanel pan = new JPanel(); - GridBagLayout gridbag = new GridBagLayout(); - pan.setBorder( BorderFactory.createLineBorder( Color.black, 1 ) ); - pan.setLayout( gridbag ); - constraints.gridheight = GridBagConstraints.REMAINDER; - constraints.gridx = 0; - constraints.weightx = 0; - constraints.gridwidth = 1; - JButton tratarButton = new JButton( mesmoDia ? "Confirmar" : "Marcar" ); - gridbag.setConstraints( tratarButton, constraints ); - pan.add( tratarButton ); - buttonHash.put( tratarButton, avisosTrabalhador[ n ][ 0 ] ); - buttonTypeHash.put( tratarButton, new Integer( AvisoConstants.TIPO_TRABALHADOR ) ); - tratarButton.addActionListener( this ); - - constraints.gridx = 1; - constraints.weightx = 1; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel empresaLabel = new JLabel( "" + avisosTrabalhador[ n ][ 3 ] ); - gridbag.setConstraints( empresaLabel, constraints ); - pan.add( empresaLabel ); - - JLabel estabelecimentoLabel = new JLabel( "" + avisosTrabalhador[ n ][ 4 ] ); - gridbag.setConstraints( estabelecimentoLabel, constraints ); - pan.add( estabelecimentoLabel ); - - JLabel trabalhadorLabel = new JLabel( "" + avisosTrabalhador[ n ][ 5 ] ); - gridbag.setConstraints( trabalhadorLabel, constraints ); - pan.add( trabalhadorLabel ); - constraints.gridwidth = GridBagConstraints.REMAINDER; - JLabel descricaoLabel = criarDescricao( avisosTrabalhador[ n ] ); - gridbag.setConstraints( descricaoLabel, constraints ); - pan.add( descricaoLabel ); - - trabalhadoresPanel.add( pan ); - } - - JScrollPane scp = new JScrollPane(); - setLayout( new GridLayout( 1, 1 ) ); - add( scp ); - JPanel contentPanel = new JPanel(); - scp.setViewportView( contentPanel ); - GridBagLayout gridbag = new GridBagLayout(); - contentPanel.setLayout( gridbag ); - constraints = new GridBagConstraints(); - constraints.insets = new Insets( 1, 1, 1, 1 ); - constraints.fill = GridBagConstraints.BOTH; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - constraints.gridheight = 1; - constraints.weighty = 0; - if( avisosEmpresa.length > 0 ) - { - gridbag.setConstraints( empresaPanel, constraints ); - contentPanel.add( empresaPanel ); - } - if( avisosTrabalhador.length > 0 ) - { - gridbag.setConstraints( trabalhadoresPanel, constraints ); - contentPanel.add( trabalhadoresPanel ); - } - if( avisosEstabelecimento.length > 0 ) - { - gridbag.setConstraints( estabelecimentosPanel, constraints ); - contentPanel.add( estabelecimentosPanel ); - } - } - - public void refresh() - { - if( refreshed ) - { - return; - } - refreshed = true; - try - { - provider = ( FichaDataProvider ) FichaDataProvider.getProvider(); - avisosEmpresa = provider.getAvisosEmpresaByDate( new Date() ); - avisosEstabelecimento = provider.getAvisosEstabelecimentoByDate( new Date() ); - avisosTrabalhador = provider.getAvisosTrabalhadorByDate( new Date() ); - } - catch( Exception ex ) - { - ex.printStackTrace(); - } - setupComponents(); - setVisible( true ); - repaint(); - } - - private JLabel criarDescricao( Object aviso[] ) - { - Date dataEvento = ( Date )aviso[ 1 ]; - - String descricao = (String)aviso[ 2 ]; - Calendar cal = Calendar.getInstance(); - cal.setTime( dataEvento ); - cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 ); - cal.set( Calendar.MILLISECOND, 0 ); - dataEvento = cal.getTime(); - - cal = Calendar.getInstance(); - cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 ); - cal.set( Calendar.MILLISECOND, 0 ); - Date hoje = cal.getTime(); - - if( !hoje.after( dataEvento ) && !hoje.before( dataEvento ) ) - { - descricao += " hoje"; - } - else - { - descricao += " no dia " + DATE_FORMAT.format( dataEvento ); - } - JLabel descricaoLabel = new JLabel( descricao ); - if( hoje.after( dataEvento ) ) - { - descricaoLabel.setForeground( Color.red ); - } - else if( hoje.equals( dataEvento ) ) - { - descricaoLabel.setForeground( Color.green.darker() ); - } - return descricaoLabel; - } - - public void actionPerformed( ActionEvent e ) - { - if( JDO == null ) - { - JDO = ( ProviderInterface ) Singleton.getInstance( Singleton.DEFAULT_EVO_DATA_PROVIDER ); - } - Object source = e.getSource(); - if( source instanceof JButton ) - { - try - { - ( (JButton) source ).setEnabled( false ); - Integer id = (Integer)buttonHash.get( source ); - if( id == null ) - { - return; - } - buttonHash.remove( source ); - AvisosData aviso = (AvisosData) JDO.load( AvisosData.class, id ); - if( aviso == null ) - { - JOptionPane.showMessageDialog( null, "Este aviso j\u00e1 foi tratado.", "J\u00e1 tratado", - JOptionPane.WARNING_MESSAGE ); - return; - } - Map dataHash = aviso.getHashData(); - Date dataEvento = (Date)dataHash.get( AvisosData.DATA_EVENTO ); - Calendar cal = Calendar.getInstance(); - cal.setTime( dataEvento ); - cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 0, 0, 0 ); - cal.set( Calendar.MILLISECOND, 0 ); - dataEvento = cal.getTime(); - - cal = Calendar.getInstance(); - cal.set( cal.get( Calendar.YEAR ), cal.get( Calendar.MONTH ), cal.get( Calendar.DAY_OF_MONTH ), 10, 0, 0 ); - cal.set( Calendar.MILLISECOND, 0 ); - Date hoje = cal.getTime(); - if( hoje.before( dataEvento ) ) - { - AvisosData novoAviso = new AvisosData(); - novoAviso.setHashData( dataHash ); - novoAviso.set( AvisosData.DATA_AVISO, dataEvento ); - novoAviso.save(); - } - - Integer tipo = (Integer) aviso.get( AvisosData.TIPO ); - TrabalhadoresData trabalhador; - EstabelecimentosData estabelecimento; - EmpresasData empresa; - - switch( tipo.intValue() ) - { - case AvisoConstants.TIPO_TRABALHADOR: - trabalhador = aviso.toTrabalhador_id(); - estabelecimento = trabalhador.toEstabelecimento_id(); - empresa = estabelecimento.toEmpresa_id(); - aviso.delete(); - tracker.getMedicinaWindow().setVisible( true ); - tracker.getMedicinaWindow().setEmpresaAndEstabelecimentoAndTrabalhador( (Integer) empresa.get( EmpresasData.ID ), - ( Integer ) estabelecimento.get( EstabelecimentosData.ID ), - ( Integer ) trabalhador.get( TrabalhadoresData.ID ) ); - break; - - case AvisoConstants.TIPO_ESTABELECIMENTO: - estabelecimento = aviso.toEstabelecimento_id(); - empresa = estabelecimento.toEmpresa_id(); - aviso.delete(); - tracker.getHigieneWindow().setVisible( true ); - tracker.getHigieneWindow().setEmpresaAndEstabelecimento( (Integer) empresa.get( EmpresasData.ID ), - ( Integer ) estabelecimento.get( EstabelecimentosData.ID ) ); - break; - - case AvisoConstants.TIPO_EMPRESA: - empresa = aviso.toEmpresa_id(); - aviso.delete(); - shst.clientes.ClientesWindow clientesWindow = tracker.getClientesWindow(); - clientesWindow.setVisible( true ); - clientesWindow.setDataObject( empresa ); - break; - } -System.out.println( "delete aviso" ); - } - catch( Exception ex ) - { - DialogException.showExceptionMessage( ex, "Erro a limpar o aviso", true ); - } - } - } - - public void clear() - { - } - - public void fill(Object value) - { - } - - public Object save() - { - return null; - } - - public void setEnabled( boolean enable ) - { - Set buttonSet = buttonHash.keySet(); - JButton buttons[] = (JButton[]) buttonSet.toArray( new JButton[0] ); - for( int n = 0;n < buttons.length; n++ ) - { - buttons[ n ].setEnabled( enable ); - } - } - - public void setEnabled( boolean enable, int type ) - { - Set buttonSet = buttonHash.keySet(); - JButton buttons[] = (JButton[]) buttonSet.toArray( new JButton[0] ); - for( int n = 0;n < buttons.length; n++ ) - { - Integer buttonType = ( Integer ) buttonTypeHash.get( buttons[ n ] ); - if( buttonType.intValue() == type ) - { - buttons[ n ].setEnabled( enable ); - } - } - } - - public void setTracker( SIPRPTracker tracker ) - { - this.tracker = tracker; - } -}