diff --git a/trunk/SIPRPSoft/lib/evolute.jar b/trunk/SIPRPSoft/lib/evolute.jar index 336d23be..bbcf5b2c 100644 Binary files a/trunk/SIPRPSoft/lib/evolute.jar and b/trunk/SIPRPSoft/lib/evolute.jar differ diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index e68f4aaa..40439c33 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -48,7 +48,7 @@ public class Main implements com.evolute.utils.ui.window.Connector { private static String dbase; - private SIPRPTracker siprpTracker; + private static SIPRPTracker siprpTracker; private static LoginWindow loginWindow; private static AvisosPanel avisos = null; @@ -114,6 +114,7 @@ public class Main implements com.evolute.utils.ui.window.Connector @Override public void run() { + siprpTracker.setLoginWindow( loginWindow ); loginWindow.expandAll(); } } ); diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java index 65bf2d9f..49ee014d 100644 --- a/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java +++ b/trunk/SIPRPSoft/src/siprp/SIPRPTracker.java @@ -35,6 +35,7 @@ import com.evolute.utils.Singleton; 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 @@ -65,6 +66,7 @@ public class SIPRPTracker extends WindowTracker implements SHSTTrackerInterface public SIPRPTracker( AvisosPanel avisosP ) { Singleton.setInstance( SingletonConstants.SIPRP_TRACKER, this ); + Singleton.setInstance( Singleton.TRACKER, this ); this.avisos = avisosP; avisos.setTracker( this ); Hashtable creators = new Hashtable(); @@ -302,6 +304,9 @@ public class SIPRPTracker extends WindowTracker implements SHSTTrackerInterface } private shst.clientes.ClientesWindow clientesWindow2 = null; + + private LoginWindow loginWindow = null; + public shst.clientes.ClientesWindow getClientesWindow2() throws Exception { if( clientesWindow2 == null ) @@ -361,4 +366,14 @@ public class SIPRPTracker extends WindowTracker implements SHSTTrackerInterface { return avisos; } + + public void setLoginWindow( LoginWindow loginWindow ) + { + this.loginWindow = loginWindow; + } + + public LoginWindow getLoginWindow() + { + return loginWindow; + } } diff --git a/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java index 8073dbc8..38a5f457 100644 --- a/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/clientes/HistoricoEstabelecimentoPanel.java @@ -219,7 +219,6 @@ public class HistoricoEstabelecimentoPanel extends JPanel saveButton.setText( null ); saveButton.setBorderPainted( false ); saveButton.setRequestFocusEnabled( false ); - saveButton.setMargin( new Insets( 0, 0, 0, 0 ) ); saveButton.setToolTipText( "Gravar" ); normal = new ImageIcon( cl.getResource( "buttons/shiftl_normal.gif" ) ); @@ -233,7 +232,6 @@ public class HistoricoEstabelecimentoPanel extends JPanel cancelButton.setText( null ); cancelButton.setBorderPainted( false ); cancelButton.setRequestFocusEnabled( false ); - cancelButton.setMargin( new Insets( 0, 0, 0, 0 ) ); cancelButton.setToolTipText( "Voltar \u00e0 lista" ); } diff --git a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java index 51dfe716..9be47857 100644 --- a/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/clientes/MarcacaoEmpresaPanel.java @@ -226,7 +226,6 @@ public class MarcacaoEmpresaPanel extends JPanel saveButton.setText( null ); saveButton.setBorderPainted( false ); saveButton.setRequestFocusEnabled( false ); - saveButton.setMargin( new Insets( 0, 0, 0, 0 ) ); saveButton.setToolTipText( "Gravar" ); normal = new ImageIcon( cl.getResource( "buttons/shiftl_normal.gif" ) ); @@ -240,7 +239,6 @@ public class MarcacaoEmpresaPanel extends JPanel cancelButton.setText( null ); cancelButton.setBorderPainted( false ); cancelButton.setRequestFocusEnabled( false ); - cancelButton.setMargin( new Insets( 0, 0, 0, 0 ) ); cancelButton.setToolTipText( "Voltar \u00e0 lista" ); } diff --git a/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java b/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java index dff36709..d659458b 100644 --- a/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java @@ -6,11 +6,13 @@ import java.util.LinkedList; import java.util.List; import siprp.data.outer.EmailPlanoDeActuacaoData; +import siprp.data.outer.EmpresasData; import siprp.data.outer.EstabelecimentosData; import siprp.data.outer.HsEmailEstabelecimentoData; import siprp.data.outer.HsEquipamentoData; import siprp.data.outer.HsLegislacaoCategoriaData; import siprp.data.outer.HsLegislacaoData; +import siprp.data.outer.HsLegislacaoEmpresaData; import siprp.data.outer.HsNormalizacaoData; import siprp.data.outer.HsPostoData; import siprp.data.outer.HsPostoRiscoData; @@ -21,6 +23,7 @@ import siprp.data.outer.HsRiscoData; import siprp.data.outer.HsRiscoTemaData; import siprp.data.outer.MarcacoesEstabelecimentoData; +import com.evolute.entity.ForeignKey; import com.evolute.entity.ProviderInterface; import com.evolute.utils.Singleton; import com.evolute.utils.arrays.Virtual2DArray; @@ -258,7 +261,7 @@ public class PlanoActuacaoDataProvider try { result = ENTITY_PROVIDER.listLoad( HsLegislacaoCategoriaData.class, - new Object[] { null }, new String[] { HsLegislacaoCategoriaData.DELETED_DATE }, + new Object[] { null }, new String[] { HsLegislacaoCategoriaData.DELETED_DATE }, new String[] { HsLegislacaoCategoriaData.DESCRIPTION } ); } catch ( Exception e ) @@ -267,6 +270,24 @@ public class PlanoActuacaoDataProvider } return result; } + + public List< HsLegislacaoData > getAllLegislacaoForEmpresa( EmpresasData empresa ) + { + List< HsLegislacaoData > result = null; + try + { + Expression where = new Field( HsLegislacaoData.DELETED_DATE_FULL ).isEqual( null ); + where = where.and( new Field( HsLegislacaoEmpresaData.EMPRESA_ID_FULL ).isEqual( empresa.getId() ) ); + List fks = new LinkedList(); + fks.add( new ForeignKey( HsLegislacaoData.class, HsLegislacaoData.ID_FULL, HsLegislacaoEmpresaData.class, HsLegislacaoEmpresaData.LEGISLACAO_ID_FULL ) ); + result = ENTITY_PROVIDER.listLoad( HsLegislacaoData.class, fks, where, new String[] { HsLegislacaoData.DESCRIPTION_FULL } ); + } + catch ( Exception e ) + { + ErrorLogger.logException( e ); + } + return result == null ? new LinkedList() : result; + } public List< HsNormalizacaoData > getNormalizacao( boolean portuguesa ) { @@ -305,9 +326,12 @@ public class PlanoActuacaoDataProvider List< HsEmailEstabelecimentoData > result = null; try { - result = ENTITY_PROVIDER.listLoad( HsEmailEstabelecimentoData.class, - new Object[] { estabelecimento.getId() }, new String[] { HsEmailEstabelecimentoData.ESTABELECIMENTO_ID }, - null ); + if( estabelecimento != null ) + { + result = ENTITY_PROVIDER.listLoad( HsEmailEstabelecimentoData.class, + new Object[] { estabelecimento.getId() }, new String[] { HsEmailEstabelecimentoData.ESTABELECIMENTO_ID }, + null ); + } } catch ( Exception e ) { diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarPanel.java index d82dce3e..172774a8 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/AdicionarPanel.java @@ -19,7 +19,7 @@ import leaf.ui.LeafButton; import leaf.ui.LeafIconButton; import leaf.ui.LeafTree; -public abstract class AdicionarPanel extends JPanel +public abstract class AdicionarPanel extends SIPRPLazyLoadedPanel { private static final long serialVersionUID = 1L; @@ -127,7 +127,5 @@ public abstract class AdicionarPanel extends JPanel protected abstract void add(); protected abstract void setEnabled(); - - public abstract void refresh(); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java index 6b5dbf67..0b1f6d8f 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/EmpresaPanel.java @@ -3,6 +3,7 @@ package siprp.higiene.gestao; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; +import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; @@ -10,7 +11,6 @@ import java.util.List; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JTabbedPane; import leaf.ui.LeafDialog; @@ -19,11 +19,13 @@ import siprp.data.provider.MedicinaDataProvider; import com.evolute.utils.error.ErrorLogger; -public class EmpresaPanel extends JPanel +public class EmpresaPanel extends SIPRPLazyLoadedPanel { private static final long serialVersionUID = 1L; + private static final String NULL_EMPRESA = "Nenhuma"; + private final JComboBox comboEmpresa = new JComboBox(); private final JCheckBox checkImpressao = new JCheckBox("Imprimir tabela alargada"); @@ -42,7 +44,6 @@ public class EmpresaPanel extends JPanel startupComponents(); setupLayout(); placeComponents(); - } private void startupComponents() @@ -60,6 +61,7 @@ public class EmpresaPanel extends JPanel if( empresas != null ) { + comboEmpresa.addItem( NULL_EMPRESA ); for( EmpresasData empresa : empresas ) { comboEmpresa.addItem( empresa ); @@ -94,11 +96,7 @@ public class EmpresaPanel extends JPanel private void setEmpresa( EmpresasData empresa ) { this.empresa = empresa; - checkImpressao.setSelected( false ); - if( empresa != null ) - { - checkImpressao.setSelected( empresa.getImprimir_tabela_alargada() == null ? false : empresa.getImprimir_tabela_alargada() ); - } + checkImpressao.setSelected( empresa != null && empresa.getImprimir_tabela_alargada() != null && empresa.getImprimir_tabela_alargada() ); } private void startupListeners() @@ -110,8 +108,11 @@ public class EmpresaPanel extends JPanel { try { - empresa.setImprimir_tabela_alargada( checkImpressao.isSelected() ); - empresa.save(); + if( empresa != null ) + { + empresa.setImprimir_tabela_alargada( checkImpressao.isSelected() ); + empresa.save(); + } } catch( Exception ex ) { @@ -133,9 +134,25 @@ public class EmpresaPanel extends JPanel panelEstabelecimentos.setEmpresa( (EmpresasData) item ); EmpresaPanel.this.setEmpresa( (EmpresasData) item ); } + else + { + panelEmpresa.setEmpresa( null ); + panelEstabelecimentos.setEmpresa( null ); + EmpresaPanel.this.setEmpresa( null ); + } } } - }); + } ); + } + + @Override + protected void refresh() + { + Component c = tabs.getSelectedComponent(); + if( c instanceof SIPRPLazyLoadedPanel ) + { + ((SIPRPLazyLoadedPanel)c).init(); + } } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java index b3541018..abb56a1c 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEmpresaPanel.java @@ -9,7 +9,6 @@ import info.clearthought.layout.TableLayoutConstraints; import java.awt.Dimension; import javax.swing.BorderFactory; -import javax.swing.JPanel; import siprp.data.outer.EmpresasData; import siprp.higiene.gestao.email.AdicionarEmailsPanel; @@ -18,7 +17,7 @@ import siprp.higiene.gestao.normalizacao.AdicionarNormalizacaoPanel; import siprp.higiene.gestao.postos.GerirAreasPanel; import siprp.higiene.gestao.riscos.AdicionarRiscosPanel; -public class GerirEmpresaPanel extends JPanel +public class GerirEmpresaPanel extends SIPRPLazyLoadedPanel { private static final long serialVersionUID = 1L; @@ -67,7 +66,6 @@ public class GerirEmpresaPanel extends JPanel private void startupListeners() { - } public void setEmpresa( EmpresasData empresa ) @@ -77,5 +75,10 @@ public class GerirEmpresaPanel extends JPanel panelRiscos.setEmpresa( empresa ); panelNormalizacao.setEmpresa( empresa ); } + + @Override + protected void refresh() + { + } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java index 439fef2c..5786919b 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GerirEstabelecimentosPanel.java @@ -30,6 +30,8 @@ public class GerirEstabelecimentosPanel extends JPanel private static final long serialVersionUID = 1L; + private static final String NULL_ESTABELECIMENTO = "Nenhum"; + private final JComboBox comboEstabelecimentos = new JComboBox(); private final JPanel panelAreasRiscos = new JPanel(); private final AdicionarAreasPanel panelAreas = new AdicionarAreasPanel(); @@ -96,6 +98,14 @@ public class GerirEstabelecimentosPanel extends JPanel panelLegislacao.setEstabelecimento( estabelecimento ); panelNormalizacao.setEstabelecimento( estabelecimento ); } + else + { + EstabelecimentosData estabelecimento = null; + panelAreas.setEstabelecimento( estabelecimento ); + panelEmails.setEstabelecimento( estabelecimento ); + panelLegislacao.setEstabelecimento( estabelecimento ); + panelNormalizacao.setEstabelecimento( estabelecimento ); + } } } } ); @@ -120,8 +130,10 @@ public class GerirEstabelecimentosPanel extends JPanel public void setEmpresa( EmpresasData empresa ) { comboEstabelecimentos.removeAllItems(); + System.out.println("setEmpresa!"); if( empresa != null ) { + comboEstabelecimentos.addItem( NULL_ESTABELECIMENTO ); for( EstabelecimentosData estabelecimento : empresa.fromEstabelecimentos_empresa_id() ) { comboEstabelecimentos.addItem( estabelecimento ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java index cc77c4d8..a9d94e00 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/GlobalPanel.java @@ -3,7 +3,11 @@ package siprp.higiene.gestao; import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; +import java.awt.Component; + import javax.swing.JTabbedPane; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import siprp.higiene.gestao.equipamentos.GerirEquipamentosPanel; import siprp.higiene.gestao.legislacao.GerirLegislacaoPanel; @@ -29,6 +33,7 @@ public class GlobalPanel extends JTabbedPane setupLayout(); placeComponents(); startupListeners(); + panelRiscos.init(); } private void startupComponents() @@ -49,6 +54,18 @@ public class GlobalPanel extends JTabbedPane private void startupListeners() { + addChangeListener( new ChangeListener() + { + @Override + public void stateChanged( ChangeEvent e ) + { + Component c = getSelectedComponent(); + if( c instanceof SIPRPLazyLoadedPanel ) + { + ((SIPRPLazyLoadedPanel)c).init(); + } + } + } ); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java new file mode 100644 index 00000000..900047af --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java @@ -0,0 +1,77 @@ +package siprp.higiene.gestao; + +import java.awt.Cursor; + +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import siprp.SIPRPTracker; + +import com.evolute.utils.Singleton; +import com.evolute.utils.error.ErrorLogger; + + +public abstract class SIPRPLazyLoadedPanel extends JPanel +{ + + private static final long serialVersionUID = 1L; + + private boolean inited = false; + + public synchronized final void doRefresh( ) + { + Runnable run = new Runnable() + { + @Override + public void run() + { + try + { + inited = true; + SIPRPTracker tracker = (SIPRPTracker) Singleton.getInstance( Singleton.TRACKER ); + if( tracker != null ) + { + GestaoRelatorioWindow window = (GestaoRelatorioWindow)tracker.getWindow( GestaoRelatorioWindow.TITLE ); + window.runAsynchronously( new Runnable() + { + + @Override + public void run() + { + refresh(); + } + } ); + } + else + { + try + { + setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); + refresh(); + } + finally + { + setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) ); + } + } + } + catch( Exception e ) + { + ErrorLogger.logException( e ); + } + } + }; + SwingUtilities.invokeLater( run ); + } + + public final void init() + { + if( !inited ) + { + doRefresh(); + } + } + + protected abstract void refresh(); + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java index b763be42..4f6bc29a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/email/AdicionarEmailsPanel.java @@ -26,7 +26,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel public void setEstabelecimento( EstabelecimentosData estabelecimento ) { this.estabelecimento = estabelecimento; - refresh(); + doRefresh(); setEnabled(); } @@ -47,7 +47,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel rel.setToEmail_id( email ); rel.setToEstabelecimento_id( estabelecimento ); rel.save(); - refresh(); + doRefresh(); } } } @@ -80,7 +80,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel if( obj instanceof HsEmailEstabelecimentoData ) { ((HsEmailEstabelecimentoData) obj).delete(); - refresh(); + doRefresh(); } } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java index 9fc68465..6de61a86 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/equipamentos/GerirEquipamentosPanel.java @@ -31,11 +31,12 @@ import leaf.ui.LeafIconButton; import leaf.ui.LeafTree; import leaf.ui.LeafUIConstants; import siprp.data.outer.HsEquipamentoData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import siprp.logic.HigieneSegurancaLogic; import com.evolute.utils.ui.trees.TreeTools; -public class GerirEquipamentosPanel extends JPanel implements CaretListener, LeafUIConstants +public class GerirEquipamentosPanel extends SIPRPLazyLoadedPanel implements CaretListener, LeafUIConstants { private static final long serialVersionUID = 1L; @@ -74,7 +75,6 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea startupLayout(); placeComponents(); setupListeners(); - refresh(); } private void setupListeners() @@ -152,7 +152,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea HsEquipamentoData equipamento = new HsEquipamentoData(); equipamento.setTipo( tipo ); equipamento.save(); - refresh(); + doRefresh(); } } catch( Exception e ) @@ -170,7 +170,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea { equipamento.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); equipamento.save(); - refresh(); + doRefresh(); } } catch( Exception e ) @@ -198,7 +198,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea equipamento.setMarca( textMarca.getText() ); equipamento.setModelo( textModelo.getText() ); equipamento.save(); - refresh(); + doRefresh(); } } catch( Exception e ) @@ -315,7 +315,8 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea add( panelData, new TableLayoutConstraints( 2, 1 ) ); } - private void refresh() + @Override + public void refresh() { root.removeAllChildren(); TreeTools.merge( root, HigieneSegurancaLogic.getEquipamentosTree() ); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java index 0ac61fc1..85bd8a68 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/AdicionarLegislacaoPanel.java @@ -31,14 +31,14 @@ private static final long serialVersionUID = 1L; { this.empresa = empresa; this.estabelecimento = null; - refresh(); + doRefresh(); } public void setEstabelecimento( EstabelecimentosData estabelecimento ) { this.empresa = null; this.estabelecimento = estabelecimento; - refresh(); + doRefresh(); } @Override @@ -51,7 +51,7 @@ private static final long serialVersionUID = 1L; if( result != null ) { addResult( result ); - refresh(); + doRefresh(); } setEnabled(); } @@ -163,7 +163,7 @@ private static final long serialVersionUID = 1L; { removeFromEstabelecimento( ((HsLegislacaoData) obj )); } - refresh(); + doRefresh(); } } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java index 56e6e395..8687a22b 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/legislacao/GerirLegislacaoPanel.java @@ -33,12 +33,13 @@ import leaf.ui.LeafTree; import leaf.ui.LeafUIConstants; import siprp.data.outer.HsLegislacaoCategoriaData; import siprp.data.outer.HsLegislacaoData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import siprp.logic.HigieneSegurancaLogic; import com.evolute.adt.Validator; import com.evolute.utils.ui.trees.TreeTools; -public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants +public class GerirLegislacaoPanel extends SIPRPLazyLoadedPanel implements LeafUIConstants { private static final long serialVersionUID = 1L; @@ -104,8 +105,6 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants startupLayout(); placeComponents(); setupListeners(); - reload(); - setEnable(); } private void startupComponents() @@ -264,7 +263,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants selectedLegislacaoGeral.setDescription( newValue ); selectedLegislacaoGeral.save(); } - reload(); + doRefresh(); } catch( Exception e ) { LeafDialog.error( e ); @@ -339,7 +338,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants HsLegislacaoCategoriaData novaCategoria = new HsLegislacaoCategoriaData(); novaCategoria.setDescription( categoriaString ); novaCategoria.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -358,7 +357,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { selectedCategoria.setDescription( categoriaString ); selectedCategoria.save(); - reload(); + doRefresh(); } } } catch( Exception e ) @@ -375,7 +374,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { selectedCategoria.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); selectedCategoria.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -393,7 +392,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants novaLegislacao.setDescription( "" ); novaLegislacao.setToCategoria_id( selectedCategoria ); novaLegislacao.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -409,7 +408,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { selectedLegislacaoEspecifica.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); selectedLegislacaoEspecifica.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -425,7 +424,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants { selectedLegislacaoGeral.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); selectedLegislacaoGeral.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -440,14 +439,15 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants HsLegislacaoData legislacao = new HsLegislacaoData(); legislacao.setDescription( "" ); legislacao.save(); - reload(); + doRefresh(); } catch( Exception e ) { LeafDialog.error( e ); } } - private void reload() + @Override + public void refresh() { rootGeral.removeAllChildren(); rootCategorias.removeAllChildren(); @@ -455,6 +455,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants TreeTools.merge( rootCategorias, HigieneSegurancaLogic.getLegislacaoEspecifica() ); TreeTools.refreshTree( treeGeral, rootGeral, false ); TreeTools.refreshTree( treeCategorias, rootCategorias, false ); + setEnable(); } private void refreshData() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java index 52196e8a..72030b82 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/AdicionarNormalizacaoPanel.java @@ -31,7 +31,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel { this.empresa = empresa; this.estabelecimento = null; - refresh(); + doRefresh(); setEnabled(); } @@ -39,7 +39,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel { this.empresa = null; this.estabelecimento = estabelecimento; - refresh(); + doRefresh(); setEnabled(); } @@ -53,7 +53,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel if( result != null ) { addResult( result ); - refresh(); + doRefresh(); } setEnabled(); } @@ -165,7 +165,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel { removeFromEstabelecimento( ((HsNormalizacaoData) obj )); } - refresh(); + doRefresh(); } } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java index 8ae08566..9d0b9935 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/normalizacao/GerirNormalizacaoPanel.java @@ -35,11 +35,12 @@ import leaf.ui.LeafTree; import leaf.ui.LeafUIConstants; import siprp.SIPRPSpellChecker; import siprp.data.outer.HsNormalizacaoData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import siprp.logic.HigieneSegurancaLogic; import com.evolute.utils.ui.trees.TreeTools; -public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, CaretListener +public class GerirNormalizacaoPanel extends SIPRPLazyLoadedPanel implements LeafUIConstants, CaretListener { private static final long serialVersionUID = 1L; @@ -100,8 +101,6 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C startupLayout(); placeComponents(); setupListeners(); - reload(); - setEnable(); } private void startupComponents() @@ -355,7 +354,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C selectedPortuguesa.setDescricao( textAreaDescricao.getText() ); selectedPortuguesa.save(); } - reload(); + doRefresh(); } private String getCodigoForNormalizacao( boolean criar, boolean portuguesa ) @@ -394,7 +393,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C normalizacao.setCodigo( codigo ); normalizacao.setPortuguesa( true ); normalizacao.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -413,7 +412,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C { selectedPortuguesa.setCodigo( codigo ); selectedPortuguesa.save(); - reload(); + doRefresh(); } } } catch( Exception e ) @@ -430,7 +429,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C { selectedPortuguesa.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); selectedPortuguesa.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -450,7 +449,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C normalizacao.setCodigo( codigo ); normalizacao.setPortuguesa( false ); normalizacao.save(); - reload(); + doRefresh(); } } catch( Exception e ) { @@ -469,7 +468,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C { selectedInternacional.setCodigo( codigo ); selectedInternacional.save(); - reload(); + doRefresh(); } } } catch( Exception e ) @@ -486,7 +485,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C { selectedInternacional.setDeleted_date( new java.sql.Timestamp( new Date().getTime() ) ); selectedInternacional.save(); - reload(); + doRefresh(); } } catch( Exception e ) @@ -495,8 +494,8 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C } } - - private void reload() + @Override + public void refresh() { rootPortuguesa.removeAllChildren(); rootInternacional.removeAllChildren(); @@ -505,6 +504,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, C TreeTools.merge( rootInternacional, HigieneSegurancaLogic.getNormalizacaoTree( false ) ); TreeTools.refreshTree( treePortuguesa, rootPortuguesa, false ); TreeTools.refreshTree( treeInternacional, rootInternacional, false ); + setEnable(); } private void refreshData() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java index 2286f4bb..b0512c42 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/AdicionarRiscosPanel.java @@ -28,12 +28,13 @@ import siprp.data.outer.HsPostoData; import siprp.data.outer.HsPostoRiscoData; import siprp.data.outer.HsRiscoData; import siprp.data.outer.HsRiscoEmpresaData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import siprp.logic.HigieneSegurancaLogic; import siprp.logic.node.NodeRisco; import com.evolute.utils.ui.trees.TreeTools; -public class AdicionarRiscosPanel extends JPanel +public class AdicionarRiscosPanel extends SIPRPLazyLoadedPanel { private static final long serialVersionUID = 1L; @@ -149,7 +150,7 @@ public class AdicionarRiscosPanel extends JPanel if( result != null ) { addResult( result ); - refresh(); + doRefresh(); } setEnabled(); } @@ -240,7 +241,7 @@ public class AdicionarRiscosPanel extends JPanel if( obj != null && LeafDialog.confirmDelete( true, false, "risco" ) ) { ((BaseObject) obj).delete(); - refresh(); + doRefresh(); } } } catch( Exception e ) @@ -266,6 +267,7 @@ public class AdicionarRiscosPanel extends JPanel buttonRemover.setEnabled( tree.getSelectionCount() > 0 ); } + @Override public void refresh() { root.removeAllChildren(); @@ -295,14 +297,14 @@ public class AdicionarRiscosPanel extends JPanel { this.empresa = empresa; this.posto = null; - refresh(); + doRefresh(); } public void setPosto( HsPostoData posto ) { this.posto = posto; this.empresa = null; - refresh(); + doRefresh(); } } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index 5b97ef3b..bfa40739 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -18,11 +18,12 @@ import leaf.ui.LeafButton; import leaf.ui.LeafDialog; import siprp.SIPRPSpellChecker; import siprp.data.outer.HsMedidaData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; -public class GerirMedidaPanel extends JPanel +public class GerirMedidaPanel extends SIPRPLazyLoadedPanel { public static final String MEDIDA_CHANGED = "MEDIDA_CHANGED"; @@ -75,8 +76,6 @@ public class GerirMedidaPanel extends JPanel scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - buttonSaveRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); - buttonRevertRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); } private void setupListeners() @@ -159,7 +158,7 @@ public class GerirMedidaPanel extends JPanel medida.setRequesitos_legais( fieldTextRequisitosLegais.getText() ); medida.setDescription( fieldTextMedida.getText() ); medida.save(); - refresh(); + doRefresh(); } setEnabled(); } catch( Exception e ) @@ -178,7 +177,8 @@ public class GerirMedidaPanel extends JPanel setEnabled(); } - private void refresh() + @Override + public void refresh() { firePropertyChange( MEDIDA_CHANGED, null, medida ); } diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java index 120aeea6..f219d714 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirRiscosPanel.java @@ -34,11 +34,12 @@ import siprp.data.outer.HsMedidaData; import siprp.data.outer.HsRiscoData; import siprp.data.outer.HsRiscoMedidaData; import siprp.data.outer.HsRiscoTemaData; +import siprp.higiene.gestao.SIPRPLazyLoadedPanel; import siprp.logic.HigieneSegurancaLogic; import com.evolute.utils.ui.trees.TreeTools; -public class GerirRiscosPanel extends JPanel implements LeafUIConstants +public class GerirRiscosPanel extends SIPRPLazyLoadedPanel implements LeafUIConstants { private static final long serialVersionUID = 1L; @@ -93,7 +94,6 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants startupLayout(); placeComponents(); setupListeners(); - refresh(); } private void setupListeners() @@ -178,7 +178,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants { if( evt.getNewValue() != null ) { - refresh(); + doRefresh(); } } } ); @@ -194,7 +194,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants HsRiscoTemaData tema = new HsRiscoTemaData(); tema.setDescription( temaString ); tema.save(); - refresh(); + doRefresh(); } } catch( Exception e ) @@ -215,7 +215,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants { tema.setDescription( temaString ); tema.save(); - refresh(); + doRefresh(); } } } catch( Exception e ) @@ -232,7 +232,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants if( tema != null && LeafDialog.confirmDelete( true, false, "tema" ) ) { tema.delete(); - refresh(); + doRefresh(); } } catch( Exception e ) { @@ -270,7 +270,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants risco.setDescription( riscoString ); risco.setToTema_id( tema ); risco.save(); - refresh(); + doRefresh(); } } } catch( Exception e ) @@ -291,7 +291,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants { risco.setDescription( riscoString ); risco.save(); - refresh(); + doRefresh(); } } } catch( Exception e ) @@ -308,7 +308,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants if( risco != null && LeafDialog.confirmDelete( true, false, "risco" ) && removerRiscoOK( risco ) ) { risco.delete(); - refresh(); + doRefresh(); } } catch( Exception e ) @@ -353,7 +353,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants rel.setToRisco_id( risco ); rel.setToMedida_id( medida ); rel.save(); - refresh(); + doRefresh(); } } catch( Exception e ) { @@ -369,7 +369,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants if( medida != null && LeafDialog.confirmDelete( true, false, "requisisto" ) ) { medida.delete(); - refresh(); + doRefresh(); } } catch( Exception e ) { @@ -536,7 +536,8 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants } } - private void refresh() + @Override + public void refresh() { TreePath selPath = tree.getSelectionPath(); Object selObject = null; diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index 660b5d6c..22b006b7 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -86,10 +86,6 @@ public class GerirMedidaRelatorioPanel extends JPanel scrollMedida.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); scrollRequesitos.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ); scrollRequesitos.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); - buttonSaveMedida.setMargin( new Insets( 0, 0, 0, 0 ) ); - buttonSaveRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); - buttonRevertMedida.setMargin( new Insets( 0, 0, 0, 0 ) ); - buttonRevertRequesito.setMargin( new Insets( 0, 0, 0, 0 ) ); } private void setupListeners() diff --git a/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java index 1167d164..340afbca 100644 --- a/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java @@ -7,6 +7,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.iacute; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import javax.swing.tree.DefaultMutableTreeNode; @@ -17,7 +18,6 @@ import siprp.data.outer.HsEmailEstabelecimentoData; import siprp.data.outer.HsEquipamentoData; import siprp.data.outer.HsLegislacaoCategoriaData; import siprp.data.outer.HsLegislacaoData; -import siprp.data.outer.HsLegislacaoEmpresaData; import siprp.data.outer.HsLegislacaoEstabelecimentoData; import siprp.data.outer.HsNormalizacaoData; import siprp.data.outer.HsNormalizacaoEmpresaData; @@ -57,6 +57,7 @@ public class HigieneSegurancaLogic private static PlanoActuacaoDataProvider planoProvider = null; private static MedicinaDataProvider medicinaProvider = null; + static { try @@ -553,54 +554,29 @@ public class HigieneSegurancaLogic DefaultMutableTreeNode result = new DefaultMutableTreeNode(); DefaultMutableTreeNode geral = new DefaultMutableTreeNode( "Legisla" + ccedil + atilde + "o de aplica" + ccedil + atilde + "o geral" ); DefaultMutableTreeNode especifica = new DefaultMutableTreeNode( "Legisla" + ccedil + atilde + "o espec" + iacute + "fica" ); - for( HsLegislacaoData legislacao : planoProvider.getAllLegislacaoGeral() ) + Map categorias = new HashMap(); + for( HsLegislacaoData legislacao : planoProvider.getAllLegislacaoForEmpresa( empresa ) ) { - if( empresa == null || hasEmpresa( legislacao, empresa ) ) + DefaultMutableTreeNode categoriaNode = legislacao.getCategoria_id() == null ? null : categorias.get( legislacao.getCategoria_id() ); + if( categoriaNode == null && legislacao.getCategoria_id() != null ) { - DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao ); - geral.add( legislacaoNode ); + categoriaNode = new DefaultMutableTreeNode( legislacao.toCategoria_id() ); + categorias.put( legislacao.getCategoria_id(), categoriaNode ); + especifica.add( categoriaNode ); } - } - for( HsLegislacaoCategoriaData categoria : planoProvider.getAllLegislacaoCategorias( ) ) - { - boolean addCategory = false; - DefaultMutableTreeNode categoriaNode = new DefaultMutableTreeNode( categoria ); - for( HsLegislacaoData legislacao : categoria.fromHsLegislacao_categoria_id() ) + if( categoriaNode == null ) { - if( empresa == null || hasEmpresa( legislacao, empresa ) ) - { - DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao ); - categoriaNode.add( legislacaoNode ); - addCategory = true; - } - + geral.add( new DefaultMutableTreeNode( legislacao ) ); } - if( addCategory) + else { - especifica.add( categoriaNode ); + categoriaNode.add( new DefaultMutableTreeNode( legislacao ) ); } } result.add( geral ); result.add( especifica ); return result; } - - private static boolean hasEmpresa( HsLegislacaoData legislacao, EmpresasData empresa ) - { - boolean result = false; - if( legislacao != null && empresa != null ) - { - for( HsLegislacaoEmpresaData rel : legislacao.fromHsLegislacaoEmpresa_legislacao_id() ) - { - result = empresa.equals( rel.toEmpresa_id() ); - if( result ) - { - break; - } - } - } - return result; - } public static DefaultMutableTreeNode getLegislacaoTreeForEstabelecimento( EstabelecimentosData estabelecimento ) {