diff --git a/trunk/SIPRPSoft/lib/evolute.jar b/trunk/SIPRPSoft/lib/evolute.jar index bbcf5b2c..ae5757a9 100644 Binary files a/trunk/SIPRPSoft/lib/evolute.jar and b/trunk/SIPRPSoft/lib/evolute.jar differ diff --git a/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java b/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java index 38a59dfd..d95c1e78 100644 --- a/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java +++ b/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java @@ -12,7 +12,7 @@ import java.util.Enumeration; import java.util.LinkedList; import java.util.List; -import javax.swing.JDialog; +import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTree; @@ -23,6 +23,7 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; +import com.evolute.swing.dialog.EvoDialog; import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; @@ -30,7 +31,7 @@ import com.evolute.utils.ui.trees.TreeTools; -public class TreeInserterDialog extends JDialog +public class TreeInserterDialog extends EvoDialog { private static final long serialVersionUID = 1L; @@ -57,13 +58,13 @@ public class TreeInserterDialog extends JDialog private final JScrollPane allScroll; - private LeafButton buttonAdd = null; + private JButton buttonAdd = null; - private LeafButton buttonRemove = null; + private JButton buttonRemove = null; - private final LeafButton buttonOK = new LeafButton( "OK" ); + private final JButton buttonOK = new JButton( "OK" ); - private final LeafButton buttonCancel = new LeafButton( "Cancelar" ); + private final JButton buttonCancel = new JButton( "Cancelar" ); private static List expandedNodes = new LinkedList(); @@ -71,13 +72,13 @@ public class TreeInserterDialog extends JDialog { this.allRoot = root; this.allModel = new DefaultTreeModel( allRoot ); - this.allTree = new JTree(allModel); + this.allTree = new JTree( allModel ); this.allScroll = new JScrollPane( allTree ); this.setTitle( title ); try { - buttonAdd = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_ADD ) ); - buttonRemove = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REM ) ); + buttonAdd = new JButton( ImageIconLoader.loadImageIcon( ICON_NAME_ADD ) ); + buttonRemove = new JButton( ImageIconLoader.loadImageIcon( ICON_NAME_REM ) ); } catch( ImageException e ) { ErrorLogger.logException( e ); @@ -91,13 +92,13 @@ public class TreeInserterDialog extends JDialog Toolkit tk = Toolkit.getDefaultToolkit(); if( tk != null ) { - this.setSize( tk.getScreenSize().width, DIALOG_DEFAULT_DIMENSIONS.height ); + this.setSize( tk.getScreenSize().width, tk.getScreenSize().height ); } else { this.setSize( DIALOG_DEFAULT_DIMENSIONS ); } - this.setLocationRelativeTo( null ); + this.setModal( true ); this.setVisible( true ); } diff --git a/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java b/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java index d659458b..0c614f69 100644 --- a/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/data/provider/PlanoActuacaoDataProvider.java @@ -14,6 +14,8 @@ import siprp.data.outer.HsLegislacaoCategoriaData; import siprp.data.outer.HsLegislacaoData; import siprp.data.outer.HsLegislacaoEmpresaData; import siprp.data.outer.HsNormalizacaoData; +import siprp.data.outer.HsNormalizacaoEmpresaData; +import siprp.data.outer.HsNormalizacaoEstabelecimentoData; import siprp.data.outer.HsPostoData; import siprp.data.outer.HsPostoRiscoData; import siprp.data.outer.HsRelatorioData; @@ -288,21 +290,62 @@ public class PlanoActuacaoDataProvider } return result == null ? new LinkedList() : result; } - - public List< HsNormalizacaoData > getNormalizacao( boolean portuguesa ) + + public List getNormalizacaoForEstabelecimento( boolean portuguesa, EstabelecimentosData estabelecimento ) { - List< HsNormalizacaoData > result = null; + List result = null; try { - result = ENTITY_PROVIDER.listLoad( HsNormalizacaoData.class, - new Object[] { null, portuguesa }, new String[] { HsNormalizacaoData.DELETED_DATE, HsNormalizacaoData.PORTUGUESA }, - new String[] {} ); + if( estabelecimento != null ) + { + Expression where = new Field( HsNormalizacaoData.DELETED_DATE_FULL ).isEqual( null ); + where = where.and( new Field( HsNormalizacaoEstabelecimentoData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento.getId() ) ); + where = where.and( new Field( HsNormalizacaoData.PORTUGUESA_FULL ).isEqual( portuguesa ) ); + List fks = new LinkedList(); + fks.add( new ForeignKey( HsNormalizacaoData.class, HsNormalizacaoData.ID_FULL, HsNormalizacaoEstabelecimentoData.class, HsNormalizacaoEstabelecimentoData.NORMALIZACAO_ID_FULL ) ); + result = ENTITY_PROVIDER.listLoad( HsNormalizacaoData.class, fks, where, new String[] { HsNormalizacaoData.DESCRICAO_FULL } ); + } + else + { + result = ENTITY_PROVIDER.listLoad( HsNormalizacaoData.class, new Object[]{ null, portuguesa }, new String[]{ HsNormalizacaoData.DELETED_DATE_FULL, HsNormalizacaoData.PORTUGUESA_FULL }, new String[] { HsNormalizacaoData.DESCRICAO_FULL } ); + } } catch ( Exception e ) { ErrorLogger.logException( e ); } - return result; + return result == null ? new LinkedList() : result; + } + + public List getNormalizacaoForEmpresa( boolean portuguesa, EmpresasData empresa ) + { + List result = null; + try + { + if( empresa != null ) + { + Expression where = new Field( HsNormalizacaoData.DELETED_DATE_FULL ).isEqual( null ); + where = where.and( new Field( HsNormalizacaoEmpresaData.EMPRESA_ID_FULL ).isEqual( empresa.getId() ) ); + where = where.and( new Field( HsNormalizacaoData.PORTUGUESA_FULL ).isEqual( portuguesa ) ); + List fks = new LinkedList(); + fks.add( new ForeignKey( HsNormalizacaoData.class, HsNormalizacaoData.ID_FULL, HsNormalizacaoEmpresaData.class, HsNormalizacaoEmpresaData.NORMALIZACAO_ID_FULL ) ); + result = ENTITY_PROVIDER.listLoad( HsNormalizacaoData.class, fks, where, new String[] { HsNormalizacaoData.DESCRICAO_FULL } ); + } + else + { + result = ENTITY_PROVIDER.listLoad( HsNormalizacaoData.class, new Object[]{ null, portuguesa }, new String[]{ HsNormalizacaoData.DELETED_DATE_FULL, HsNormalizacaoData.PORTUGUESA_FULL }, new String[] { HsNormalizacaoData.DESCRICAO_FULL } ); + } + } + catch ( Exception e ) + { + ErrorLogger.logException( e ); + } + return result == null ? new LinkedList() : result; + } + + public List getNormalizacao( boolean portuguesa ) + { + return getNormalizacaoForEmpresa( portuguesa, (EmpresasData) null ); } public List< HsEquipamentoData > getAllEquipamentos() diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java index 900047af..bef89651 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/SIPRPLazyLoadedPanel.java @@ -1,6 +1,7 @@ package siprp.higiene.gestao; import java.awt.Cursor; +import java.util.Date; import javax.swing.JPanel; import javax.swing.SwingUtilities; @@ -38,7 +39,9 @@ public abstract class SIPRPLazyLoadedPanel extends JPanel @Override public void run() { + long start = System.currentTimeMillis(); refresh(); + System.out.println("\n\t" + SIPRPLazyLoadedPanel.this.getClass() + ": took " + ( System.currentTimeMillis() - start ) ); } } ); } diff --git a/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java b/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java index 340afbca..f0473e17 100644 --- a/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java +++ b/trunk/SIPRPSoft/src/siprp/logic/HigieneSegurancaLogic.java @@ -468,64 +468,64 @@ public class HigieneSegurancaLogic DefaultMutableTreeNode result = new DefaultMutableTreeNode(); DefaultMutableTreeNode portuguesa = new DefaultMutableTreeNode("Normaliza" + ccedil + atilde + "o Portuguesa" ); DefaultMutableTreeNode internacional = new DefaultMutableTreeNode("Normaliza" + ccedil + atilde + "o Internacional" ); - for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacao( true ) ) + for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacaoForEmpresa( true, empresa ) ) { - if( empresa == null || hasEmpresa( normalizacao, empresa ) ) - { +// if( empresa == null || hasEmpresa( normalizacao, empresa ) ) +// { DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao ); portuguesa.add( normalizacaoNode ); - } +// } } - for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacao( false ) ) + for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacaoForEmpresa( false, empresa ) ) { - if( empresa == null || hasEmpresa( normalizacao, empresa ) ) - { +// if( empresa == null || hasEmpresa( normalizacao, empresa ) ) +// { DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao ); internacional.add( normalizacaoNode ); - } +// } } result.add( portuguesa ); result.add( internacional ); return result; } - private static boolean hasEmpresa( HsNormalizacaoData normalizacao, EmpresasData empresa ) - { - boolean result = false; - if( normalizacao != null && empresa != null ) - { - for( HsNormalizacaoEmpresaData rel : normalizacao.fromHsNormalizacaoEmpresa_normalizacao_id() ) - { - result = empresa.equals( rel.toEmpresa_id() ); - if( result ) - { - break; - } - } - } - return result; - } +// private static boolean hasEmpresa( HsNormalizacaoData normalizacao, EmpresasData empresa ) +// { +// boolean result = false; +// if( normalizacao != null && empresa != null ) +// { +// for( HsNormalizacaoEmpresaData rel : normalizacao.fromHsNormalizacaoEmpresa_normalizacao_id() ) +// { +// result = empresa.equals( rel.toEmpresa_id() ); +// if( result ) +// { +// break; +// } +// } +// } +// return result; +// } public static DefaultMutableTreeNode getNormalizacaoTreeForEstabelecimento( EstabelecimentosData estabelecimento ) { DefaultMutableTreeNode result = new DefaultMutableTreeNode(); DefaultMutableTreeNode portuguesa = new DefaultMutableTreeNode("Normaliza" + ccedil + atilde + "o Portuguesa" ); DefaultMutableTreeNode internacional = new DefaultMutableTreeNode("Normaliza" + ccedil + atilde + "o Internacional" ); - for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacao( true ) ) + for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacaoForEstabelecimento( true, estabelecimento ) ) { - if( estabelecimento == null || hasEstabelecimento( normalizacao, estabelecimento ) ) - { +// if( estabelecimento == null || hasEstabelecimento( normalizacao, estabelecimento ) ) +// { DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao ); portuguesa.add( normalizacaoNode ); - } +// } } - for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacao( false ) ) + for( HsNormalizacaoData normalizacao : planoProvider.getNormalizacaoForEstabelecimento( false, estabelecimento ) ) { - if( estabelecimento == null || hasEstabelecimento( normalizacao, estabelecimento ) ) - { +// if( estabelecimento == null || hasEstabelecimento( normalizacao, estabelecimento ) ) +// { DefaultMutableTreeNode normalizacaoNode = new DefaultMutableTreeNode( normalizacao ); internacional.add( normalizacaoNode ); - } +// } } result.add( portuguesa ); result.add( internacional );