diff --git a/trunk/SIPRPSoft/lib/evolute.jar b/trunk/SIPRPSoft/lib/evolute.jar index 83289660..484aab41 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 5694ba7e..1951750b 100644 Binary files a/trunk/SIPRPSoft/lib/shst.jar and b/trunk/SIPRPSoft/lib/shst.jar differ diff --git a/trunk/SIPRPSoft/src/leaf/ui/LeafIconButton.java b/trunk/SIPRPSoft/src/leaf/ui/LeafIconButton.java index 6203c131..baa9a75f 100644 --- a/trunk/SIPRPSoft/src/leaf/ui/LeafIconButton.java +++ b/trunk/SIPRPSoft/src/leaf/ui/LeafIconButton.java @@ -1,5 +1,8 @@ package leaf.ui; +import java.io.IOException; + +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; @@ -7,9 +10,9 @@ public class LeafIconButton extends LeafButton implements LeafUIConstants { private static final long serialVersionUID = 1L; - private LeafIconButton( String imagePath ) throws ImageException + private LeafIconButton( String imagePath ) throws ImageException, IOException { - super(ImageIconLoader.loadImageIcon( imagePath )); + super( ImageIconLoader.loadImageIcon( imagePath ) ); } public static LeafIconButton createDefaultNewButton() @@ -40,11 +43,16 @@ public class LeafIconButton extends LeafButton implements LeafUIConstants { try { - result = new LeafIconButton(imagePath); + result = new LeafIconButton( imagePath ); // result.setMargin( new Insets(0,0,0,0) ); - } catch( ImageException e ) + } + catch( ImageException e ) + { + ErrorLogger.logException( e ); + } + catch ( IOException e ) { - e.printStackTrace(); + ErrorLogger.logException( e ); } } return result; diff --git a/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java b/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java index 621626ab..76bab9b2 100644 --- a/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java +++ b/trunk/SIPRPSoft/src/leaf/ui/TreeInserterDialog.java @@ -9,6 +9,7 @@ import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import java.util.Enumeration; import java.util.LinkedList; import java.util.List; @@ -80,7 +81,12 @@ public class TreeInserterDialog extends EvoDialog { buttonAdd = new JButton( ImageIconLoader.loadImageIcon( ICON_NAME_ADD ) ); buttonRemove = new JButton( ImageIconLoader.loadImageIcon( ICON_NAME_REM ) ); - } catch( ImageException e ) + } + catch( ImageException e ) + { + ErrorLogger.logException( e ); + } + catch ( IOException e ) { ErrorLogger.logException( e ); } diff --git a/trunk/SIPRPSoft/src/siprp/Main.java b/trunk/SIPRPSoft/src/siprp/Main.java index 40439c33..b36bc9e8 100644 --- a/trunk/SIPRPSoft/src/siprp/Main.java +++ b/trunk/SIPRPSoft/src/siprp/Main.java @@ -75,6 +75,8 @@ public class Main implements com.evolute.utils.ui.window.Connector UIManager.put( "FormattedTextField.inactiveForeground", ColorUIResource.BLACK ); UIManager.put( "FormattedTextField.foreground", ColorUIResource.RED.darker() ); + new SIPRPShutdownHook().init(); + new SIPRPUIInitializer().doInit(); SIPRPPropertiesLoader.getInstance().load(); @@ -232,7 +234,22 @@ public class Main implements com.evolute.utils.ui.window.Connector { if( siprpTracker == null || siprpTracker.quit() ) { - System.exit( 0 ); +// 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(); } } diff --git a/trunk/SIPRPSoft/src/siprp/SIPRPShutdownHook.java b/trunk/SIPRPSoft/src/siprp/SIPRPShutdownHook.java new file mode 100644 index 00000000..ef10365c --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/SIPRPShutdownHook.java @@ -0,0 +1,39 @@ +package siprp; + +import siprp.higiene.relatorio.MedidasRiscosDeleterController; + +import com.evolute.threads.EvoShutdownHook; +import com.evolute.utils.error.ErrorLogger; + +public class SIPRPShutdownHook extends EvoShutdownHook +{ + + public SIPRPShutdownHook() + { + + } + + + public void execute() + { + MedidasRiscosDeleterController controller = MedidasRiscosDeleterController.getInstance(); + System.out.println( "\nChecking " + controller.getThreads().size() + " threads ..." ); + for ( Thread deleter : controller.getThreads() ) + { + System.out.println( "\nChecking " + deleter.getName() + " ... Running ? " + deleter.isAlive() ); + if ( deleter.isAlive() ) + { + try + { + System.out.println( "\nWaiting for <" + deleter + "> ... " ); + deleter.join(); + } + catch ( InterruptedException e ) + { + ErrorLogger.logException( e ); + } + } + } + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java index bfa40739..923cce8a 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/gestao/riscos/GerirMedidaPanel.java @@ -3,12 +3,11 @@ package siprp.higiene.gestao.riscos; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import javax.swing.JLabel; -import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.event.CaretEvent; @@ -20,6 +19,7 @@ import siprp.SIPRPSpellChecker; import siprp.data.outer.HsMedidaData; import siprp.higiene.gestao.SIPRPLazyLoadedPanel; +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; @@ -54,9 +54,14 @@ public class GerirMedidaPanel extends SIPRPLazyLoadedPanel { buttonSaveRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); buttonRevertRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); - } catch( ImageException e ) + } + catch( ImageException e ) { - e.printStackTrace(); + ErrorLogger.logException( e ); + } + catch ( IOException e ) + { + ErrorLogger.logException( e ); } startupComponents(); startupLayout(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java index 22b006b7..f7f65240 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidaRelatorioPanel.java @@ -5,9 +5,9 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; -import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import javax.swing.JCheckBox; import javax.swing.JLabel; @@ -22,6 +22,7 @@ import leaf.ui.LeafDialog; import siprp.SIPRPSpellChecker; import siprp.data.outer.HsRelatorioPostoMedidaData; +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.images.ImageException; import com.evolute.utils.images.ImageIconLoader; @@ -64,9 +65,14 @@ public class GerirMedidaRelatorioPanel extends JPanel buttonRevertMedida = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); buttonSaveRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_SAVE ) ); buttonRevertRequesito = new LeafButton( ImageIconLoader.loadImageIcon( ICON_NAME_REVERT ) ); - } catch( ImageException e ) + } + catch( ImageException e ) { - e.printStackTrace(); + ErrorLogger.logException( e ); + } + catch ( IOException e ) + { + ErrorLogger.logException( e ); } startupComponents(); startupLayout(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java index 73a117fb..3bd56dc2 100644 --- a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/GerirMedidasRelatorioPanel.java @@ -9,7 +9,6 @@ import java.awt.Color; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -349,11 +348,17 @@ public class GerirMedidasRelatorioPanel extends SIPRPLazyLoadedPanel return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( this, message, "Confirma"+ccedil+atilde+"o", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null ); } + private String shortenString( String string ) + { + return string == null ? null : (string.length() <= 40 ? string : (string.substring(0,40) + "...")); + } + + private void rem() { for( TreePath path : tree.getSelectionPaths() ) { - if( !rem(path) ) + if ( ! rem( path ) ) { break; } @@ -361,15 +366,8 @@ public class GerirMedidasRelatorioPanel extends SIPRPLazyLoadedPanel doRefresh(); setEnabled(); } - - - private String shortenString( String string ) - { - return string == null ? null : (string.length() <= 40 ? string : (string.substring(0,40) + "...")); - } - - - private boolean rem(TreePath path) + + private boolean rem( TreePath path ) { boolean outcome = false; try @@ -395,14 +393,9 @@ public class GerirMedidasRelatorioPanel extends SIPRPLazyLoadedPanel if( confirm("Tem a certeza que deseja remover o risco '" + shortenString( rel.toRisco_id().toString() ) + "'?") ) { HsRelatorioRiscoData riscoData = rel.toRisco_id(); - for( HsRelatorioMedidaData medida : riscoData.fromHsRelatorioMedida_risco_id() ) - { - for ( HsRelatorioPostoMedidaData relMedida : medida.fromHsRelatorioPostoMedida_medida_id() ) - { - relMedida.delete(); - } - medida.delete(); - } + + MedidasRiscosDeleterController.getInstance().delete( new MedidasRiscosDeleter( riscoData ) ); + riscoData.delete(); rel.delete(); diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleter.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleter.java new file mode 100644 index 00000000..0d26b14f --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleter.java @@ -0,0 +1,51 @@ +package siprp.higiene.relatorio; + +import com.evolute.utils.error.ErrorLogger; + +import siprp.data.outer.HsRelatorioMedidaData; +import siprp.data.outer.HsRelatorioPostoMedidaData; +import siprp.data.outer.HsRelatorioRiscoData; + + +public class MedidasRiscosDeleter implements Runnable +{ + private HsRelatorioRiscoData riscoData; + + private String name; + + public MedidasRiscosDeleter( HsRelatorioRiscoData riscoData ) + { + this.riscoData = riscoData; + + setName( "Delete Medidas from Risco - " + riscoData ); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public void run() + { + try + { + for( HsRelatorioMedidaData medida : riscoData.fromHsRelatorioMedida_risco_id() ) + { + for ( HsRelatorioPostoMedidaData relMedida : medida.fromHsRelatorioPostoMedida_medida_id() ) + { + relMedida.delete(); + } + medida.delete(); + } + } + catch ( Exception e ) + { + ErrorLogger.logException( e ); + } + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleterController.java b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleterController.java new file mode 100644 index 00000000..4386d621 --- /dev/null +++ b/trunk/SIPRPSoft/src/siprp/higiene/relatorio/MedidasRiscosDeleterController.java @@ -0,0 +1,51 @@ +package siprp.higiene.relatorio; + +import java.util.LinkedList; +import java.util.List; + +public class MedidasRiscosDeleterController +{ + private static MedidasRiscosDeleterController INSTANCE = null; + + private List< Thread > threads = null; + + private MedidasRiscosDeleterController() + { + threads = new LinkedList< Thread >(); + } + + public static synchronized MedidasRiscosDeleterController getInstance() + { + if ( INSTANCE == null ) + { + INSTANCE = new MedidasRiscosDeleterController(); + } + return INSTANCE; + } + + + public List< Thread > getThreads() + { + return threads; + } + + private void setThreads( List< Thread > threads ) + { + this.threads = threads; + } + + public void delete( MedidasRiscosDeleter thread ) + { + if ( getThreads() == null ) + { + setThreads( new LinkedList< Thread >() ); + } + + Thread t = new Thread( thread ); + t.setName( thread.getName() ); + t.setDaemon( false ); + t.start(); + getThreads().add( t ); + } + +} diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java index 72f950a3..7acce6ae 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/estrutura/EstruturaProcessoMutableTreeNode.java @@ -14,6 +14,7 @@ import java.awt.Color; import javax.swing.Icon; import javax.swing.tree.DefaultMutableTreeNode; +import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.images.ImageIconLoader; /** @@ -51,11 +52,11 @@ abstract public class EstruturaProcessoMutableTreeNode extends DefaultMutableTre { try { - icon = ImageIconLoader.loadImageIcon( getClass(), getIconPath() ); + icon = ImageIconLoader.loadImageIcon( getIconPath() ); } catch( Exception ex ) { - ex.printStackTrace(); + ErrorLogger.logException( ex ); } } } diff --git a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java index 882fd991..0e865fec 100644 --- a/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java +++ b/trunk/SIPRPSoft/src/siprp/medicina/processo/mail/MailDialog.java @@ -483,8 +483,7 @@ public class MailDialog extends CustomJDialog private JButton createButton( Action action, String iconPath ) throws Exception { - action.putValue( Action.SMALL_ICON, - ImageIconLoader.loadImageIcon( getClass(), iconPath ) ); + action.putValue( Action.SMALL_ICON, ImageIconLoader.loadImageIcon( iconPath ) ); JButton button = new JButton( action ); button.setText( null );