Higiene e seguranca:

pedido de confirmacao a cada remocao
gestao de 'normalizacao' alterada
todo o stack das excepccoes e' agora mostrado ao utilizador

git-svn-id: https://svn.coded.pt/svn/SIPRP@950 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
Tiago Simão 17 years ago
parent 395628aa20
commit 5b1d81e433

@ -13,7 +13,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.providers.MedicinaDAO;
@ -104,7 +104,7 @@ public class EmpresaPanel extends JPanel
}
catch( Exception ex )
{
LeafError.error( ex );
LeafDialog.error( ex );
}
}
} );

@ -1,10 +1,13 @@
package siprp.higiene.gestao.email;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsEmail;
@ -49,10 +52,17 @@ public class AdicionarEmailsPanel extends AdicionarPanel
}
catch (Exception e)
{
LeafError.error( e );
LeafDialog.error( e );
}
}
private boolean confirmDelete()
{
return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(
null, "Tem a certeza que deseja remover o email seleccionado?",
"Confirmar remo" + ccedil + atilde + "o",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null );
}
@Override
protected void rem()
@ -63,7 +73,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel
if( path != null )
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
if( node != null )
if( node != null && confirmDelete() )
{
Object obj = node.getUserObject();
if( obj instanceof HsEmailEstabelecimento )
@ -76,7 +86,7 @@ public class AdicionarEmailsPanel extends AdicionarPanel
}
catch (Exception e)
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -1,11 +1,14 @@
package siprp.higiene.gestao.equipamentos;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
@ -17,7 +20,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.TreeInserterDialog;
import leaf.ui.TreeTools;
@ -137,6 +140,7 @@ public class AdicionarEquipamentosPanel extends JPanel
{
if( relatorio != null )
{
DefaultMutableTreeNode allEquipamentos = HigieneSegurancaLogic.getEquipamentosTree();
TreeInserterDialog dialog = new TreeInserterDialog("Adicionar equipamento",allEquipamentos);
DefaultMutableTreeNode result = dialog.getResult();
@ -161,7 +165,7 @@ public class AdicionarEquipamentosPanel extends JPanel
}
catch (Exception e)
{
LeafError.error( e );
LeafDialog.error( e );
}
}
}
@ -178,7 +182,7 @@ public class AdicionarEquipamentosPanel extends JPanel
DefaultMutableTreeNode node = path == null ? null : (DefaultMutableTreeNode)path.getLastPathComponent();
Object obj = node.getUserObject();
HsRelatorioEquipamento rel = obj == null ? null : ((obj instanceof HsRelatorioEquipamento) ? (HsRelatorioEquipamento) obj : null);
if( rel != null )
if( rel != null && confirmDelete() )
{
rel.delete();
refresh();
@ -186,9 +190,17 @@ public class AdicionarEquipamentosPanel extends JPanel
}
catch (Exception e)
{
LeafError.error( e );
LeafDialog.error( e );
}
}
private boolean confirmDelete()
{
return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(
null, "Tem a certeza que deseja remover o equipamento seleccionado?",
"Confirmar remo" + ccedil + atilde + "o",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null );
}
private void setEnabled()
{

@ -1,5 +1,7 @@
package siprp.higiene.gestao.equipamentos;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -25,7 +27,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.LeafUIConstants;
import leaf.ui.TreeTools;
@ -154,7 +156,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -163,7 +165,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea
try
{
HsEquipamento equipamento = getSelected();
if( equipamento != null )
if( equipamento != null && confirmDelete() )
{
equipamento.setDeletedDate( new Date() );
equipamento.save();
@ -172,10 +174,18 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
private boolean confirmDelete()
{
return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(
null, "Tem a certeza que deseja remover o equipamento seleccionado?",
"Confirmar remo" + ccedil + atilde + "o",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null );
}
private void save()
{
try
@ -192,7 +202,7 @@ public class GerirEquipamentosPanel extends JPanel implements CaretListener, Lea
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -6,7 +6,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.TreeInserterDialog;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas;
@ -115,7 +115,7 @@ private static final long serialVersionUID = 1L;
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -154,11 +154,11 @@ private static final long serialVersionUID = 1L;
Object obj = node.getUserObject();
if( obj != null && (obj instanceof HsLegislacao) )
{
if( empresa != null )
if( empresa != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) )
{
removeFromEmpresa( ((HsLegislacao) obj ) );
}
else if( estabelecimento != null )
else if( estabelecimento != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) )
{
removeFromEstabelecimento( ((HsLegislacao) obj ));
}
@ -168,7 +168,7 @@ private static final long serialVersionUID = 1L;
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -28,7 +28,7 @@ import javax.swing.tree.TreeSelectionModel;
import leaf.data.Validator;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.LeafTextAreaEditor;
import leaf.ui.LeafUIConstants;
@ -266,7 +266,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
reload();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
} );
@ -342,7 +342,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -362,7 +362,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -370,7 +370,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
{
try
{
if( selectedCategoria != null )
if( selectedCategoria != null && LeafDialog.confirmDelete( false, false, "categoria" ) )
{
selectedCategoria.setDeletedDate( new Date() );
selectedCategoria.save();
@ -378,7 +378,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -396,7 +396,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -404,7 +404,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
{
try
{
if( selectedLegislacaoEspecifica != null )
if( selectedLegislacaoEspecifica != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) )
{
selectedLegislacaoEspecifica.setDeletedDate( new Date() );
selectedLegislacaoEspecifica.save();
@ -412,7 +412,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -420,7 +420,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
{
try
{
if( selectedLegislacaoGeral != null )
if( selectedLegislacaoGeral != null && LeafDialog.confirmDelete( false, false, "legisla" + ccedil + atilde + "o" ) )
{
selectedLegislacaoGeral.setDeletedDate( new Date() );
selectedLegislacaoGeral.save();
@ -428,7 +428,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -442,7 +442,7 @@ public class GerirLegislacaoPanel extends JPanel implements LeafUIConstants
reload();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -6,7 +6,7 @@ import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.TreeInserterDialog;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas;
@ -118,7 +118,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -170,13 +170,13 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
private void removeFromEmpresa( HsNormalizacao normalizacao ) throws Exception
{
if( normalizacao != null && empresa != null )
if( normalizacao != null && empresa != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) )
{
for( HsNormalizacaoEmpresa rel : empresa.getHsNormalizacaoEmpresaArray() )
{
@ -191,7 +191,7 @@ public class AdicionarNormalizacaoPanel extends AdicionarPanel
private void removeFromEstabelecimento( HsNormalizacao normalizacao ) throws Exception
{
if( normalizacao != null && estabelecimento != null )
if( normalizacao != null && estabelecimento != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) )
{
for( HsNormalizacaoEstabelecimento rel : estabelecimento.getHsNormalizacaoEstabelecimentoArray() )
{

@ -19,10 +19,14 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.AbstractDocument.LeafElement;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
@ -30,7 +34,7 @@ import javax.swing.tree.TreeSelectionModel;
import leaf.data.Validator;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.LeafTextAreaEditor;
import leaf.ui.LeafUIConstants;
@ -38,7 +42,7 @@ import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsNormalizacao;
import siprp.logic.HigieneSegurancaLogic;
public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants, CaretListener
{
private static final long serialVersionUID = 1L;
@ -62,6 +66,10 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
private final LeafButton buttonInternacionalEditar = LeafIconButton.createDefaultEditButton();
private final LeafButton buttonInternacionalRemover = LeafIconButton.createDefaultRemoveButton();
private final LeafButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE );
private final LeafButton buttonRevert = LeafIconButton.createButton( ICON_NAME_REVERT );
private final DefaultMutableTreeNode rootPortuguesa = new DefaultMutableTreeNode();
@ -87,14 +95,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
private final JTextField textCodigo = new JTextField(10);
private final LeafTextAreaEditor textDescricao = new LeafTextAreaEditor( new Validator<String>()
{
@Override
public boolean isValid( String object )
{
return true;
}
} );
private final JTextArea textAreaDescricao = new JTextArea();
public GerirNormalizacaoPanel()
{
@ -118,6 +119,9 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
treePortuguesa.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
textCodigo.setEnabled( false );
buttonSave.setEnabled( false );
buttonRevert.setEnabled( false );
}
private void startupLayout()
@ -155,9 +159,9 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
panelButtonsInternacional.setLayout( layout );
layout = new TableLayout( new double[] {
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL
TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM
}, new double[] {
TableLayout.MINIMUM, TableLayout.FILL
TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL
} );
((TableLayout) layout).setHGap( 5 );
((TableLayout) layout).setVGap( 5 );
@ -180,9 +184,11 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
panelInternacional.add( panelButtonsInternacional, new TableLayoutConstraints( 0, 0 ) );
panelInternacional.add( scrollInternacional, new TableLayoutConstraints( 0, 1, 1, 1 ) );
panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 0 ) );
panelData.add( textCodigo, new TableLayoutConstraints( 1, 0 ) );
panelData.add( textDescricao, new TableLayoutConstraints( 0, 1, 2, 1 ) );
panelData.add( buttonSave, new TableLayoutConstraints( 3, 0 ) );
panelData.add( buttonRevert, new TableLayoutConstraints( 4, 0 ) );
panelData.add( new JLabel("C" + oacute + "digo"), new TableLayoutConstraints( 0, 1 ) );
panelData.add( textCodigo, new TableLayoutConstraints( 1, 1 ) );
panelData.add( textAreaDescricao, new TableLayoutConstraints( 0, 2, 4, 2 ) );
this.add( panelPortuguesa, new TableLayoutConstraints( 0, 0 ) );
this.add( panelInternacional, new TableLayoutConstraints( 0, 1 ) );
@ -247,31 +253,8 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
setEnable();
}
} );
textDescricao.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener()
{
@Override
public void propertyChange( PropertyChangeEvent evt )
{
try
{
String newValue = (String) evt.getNewValue();
if( selectedInternacional != null )
{
selectedInternacional.setDescricao( newValue );
selectedInternacional.save();
}
else if( selectedPortuguesa != null )
{
selectedPortuguesa.setDescricao( newValue );
selectedPortuguesa.save();
}
reload();
} catch( Exception e )
{
LeafError.error( e );
}
}
} );
textCodigo.addCaretListener( this );
textAreaDescricao.addCaretListener( this );
buttonPortuguesaCriar.addActionListener( new ActionListener()
{
@Override
@ -320,6 +303,61 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
removerInternacional();
}
} );
buttonSave.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
try
{
save();
} catch( Exception e1 )
{
LeafDialog.error( e1 );
}
}
} );
buttonRevert.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
if( selectedInternacional != null )
{
textAreaDescricao.setText( selectedInternacional.getDescricao() );
textAreaDescricao.setEnabled( true );
textCodigo.setText( selectedInternacional.getCodigo() );
}
else if( selectedPortuguesa != null )
{
textAreaDescricao.setText( selectedPortuguesa.getDescricao() );
textAreaDescricao.setEnabled( true );
textCodigo.setText( selectedPortuguesa.getCodigo() );
}
else
{
textAreaDescricao.setText( "" );
textCodigo.setText( "" );
}
}
} );
}
private void save() throws Exception
{
if( selectedInternacional != null )
{
selectedInternacional.setCodigo( textCodigo.getText() );
selectedInternacional.setDescricao( textAreaDescricao.getText() );
selectedInternacional.save();
}
else if( selectedPortuguesa != null )
{
selectedPortuguesa.setCodigo( textCodigo.getText() );
selectedPortuguesa.setDescricao( textAreaDescricao.getText() );
selectedPortuguesa.save();
}
reload();
}
private String getCodigoForNormalizacao( boolean criar, boolean portuguesa )
@ -362,7 +400,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -382,7 +420,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -390,7 +428,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
{
try
{
if( selectedPortuguesa != null )
if( selectedPortuguesa != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) )
{
selectedPortuguesa.setDeletedDate( new Date() );
selectedPortuguesa.save();
@ -398,7 +436,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -418,7 +456,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -438,7 +476,7 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -446,15 +484,16 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
{
try
{
if( selectedInternacional != null )
if( selectedInternacional != null && LeafDialog.confirmDelete( false, false, "normaliza" + ccedil + atilde + "o" ) )
{
selectedInternacional.setDeletedDate( new Date() );
selectedInternacional.save();
reload();
}
} catch( Exception e )
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -476,22 +515,26 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
buttonPortuguesaRemover.setEnabled( false );
buttonInternacionalEditar.setEnabled( false );
buttonPortuguesaEditar.setEnabled( false );
textDescricao.setEnabled( false );
textAreaDescricao.setEnabled( false );
buttonSave.setEnabled( false );
buttonRevert.setEnabled( false );
if( selectedInternacional != null )
{
textDescricao.setValue( selectedInternacional.getDescricao() );
textDescricao.setEnabled( true );
textAreaDescricao.setText( selectedInternacional.getDescricao() );
textAreaDescricao.setEnabled( true );
textCodigo.setText( selectedInternacional.getCodigo() );
textCodigo.setEnabled( true );
}
else if( selectedPortuguesa != null )
{
textDescricao.setValue( selectedPortuguesa.getDescricao() );
textDescricao.setEnabled( true );
textAreaDescricao.setText( selectedPortuguesa.getDescricao() );
textAreaDescricao.setEnabled( true );
textCodigo.setText( selectedPortuguesa.getCodigo() );
textCodigo.setEnabled( true );
}
else
{
textDescricao.setValue( null );
textAreaDescricao.setText( "" );
textCodigo.setText( "" );
}
}
@ -504,4 +547,11 @@ public class GerirNormalizacaoPanel extends JPanel implements LeafUIConstants
buttonInternacionalRemover.setEnabled( selectedInternacional != null );
}
@Override
public void caretUpdate( CaretEvent e )
{
buttonSave.setEnabled( true );
buttonRevert.setEnabled( true );
}
}

@ -1,5 +1,6 @@
package siprp.higiene.gestao.postos;
import static com.evolute.utils.strings.UnicodeLatin1Map.aacute;
import info.clearthought.layout.TableLayout;
import info.clearthought.layout.TableLayoutConstraints;
@ -17,7 +18,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.TreeInserterDialog;
import leaf.ui.TreeTools;
@ -161,7 +162,7 @@ public class AdicionarAreasPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -171,12 +172,12 @@ public class AdicionarAreasPanel extends JPanel
if( path != null )
{
Object object = path.getLastPathComponent();
if( object instanceof PostoNode )
if( ( object instanceof PostoNode ) && LeafDialog.confirmDelete( true, false, "posto" ) )
{
HsPosto posto = ((HsPosto) ((PostoNode) object).getUserObject());
remPosto( posto );
}
else if( object instanceof AreaNode )
else if( ( object instanceof AreaNode ) && LeafDialog.confirmDelete( false, false, aacute + "rea" ) )
{
for( int i = 0; i < ((AreaNode) object).getChildCount(); ++i )
{
@ -208,7 +209,7 @@ public class AdicionarAreasPanel extends JPanel
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -28,7 +28,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.LeafUIConstants;
import leaf.ui.TreeTools;
@ -217,7 +217,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -238,7 +238,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -247,14 +247,14 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
try
{
HsArea area = getSelectedArea();
if( area != null )
if( area != null && LeafDialog.confirmDelete( false, false, aacute + "rea") )
{
area.delete();
refresh();
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -278,7 +278,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -299,7 +299,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -308,7 +308,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
try
{
HsPosto posto = getSelectedPosto();
if( posto != null )
if( posto != null && LeafDialog.confirmDelete( true, false, "posto" ) )
{
posto.setDeletedDate( new Date() );
posto.save();
@ -316,7 +316,7 @@ public class GerirAreasPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -19,7 +19,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.TreeInserterDialog;
import leaf.ui.TreeTools;
@ -223,7 +223,7 @@ public class AdicionarRiscosPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -236,7 +236,7 @@ public class AdicionarRiscosPanel extends JPanel
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
Object obj = node.getUserObject();
if( obj != null )
if( obj != null && LeafDialog.confirmDelete( true, false, "risco" ) )
{
((BaseObject) obj).delete();
refresh();
@ -244,7 +244,7 @@ public class AdicionarRiscosPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -15,7 +15,7 @@ import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import siprp.database.cayenne.objects.HsMedida;
import com.evolute.utils.images.ImageException;
@ -164,7 +164,7 @@ public class GerirMedidaPanel extends JPanel
setEnabled();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -26,7 +26,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.LeafUIConstants;
import leaf.ui.TreeTools;
@ -196,7 +196,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -217,7 +217,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -226,14 +226,14 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
try
{
HsRiscoTema tema = getSelectedTema();
if( tema != null )
if( tema != null && LeafDialog.confirmDelete( true, false, "tema" ) )
{
tema.delete();
refresh();
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -272,7 +272,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -293,7 +293,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -302,7 +302,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
try
{
HsRisco risco = getSelectedRisco();
if( risco != null && removerRiscoOK(risco) )
if( risco != null && LeafDialog.confirmDelete( true, false, "risco" ) && removerRiscoOK( risco ) )
{
risco.delete();
refresh();
@ -310,7 +310,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -354,7 +354,7 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -363,14 +363,14 @@ public class GerirRiscosPanel extends JPanel implements LeafUIConstants
try
{
HsRiscoMedida medida = getSelectedMedida();
if( medida != null )
if( medida != null && LeafDialog.confirmDelete( true, false, "requisisto" ) )
{
medida.delete();
refresh();
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -18,7 +18,7 @@ import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
import com.evolute.utils.images.ImageException;
@ -228,7 +228,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -245,7 +245,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
setEnabled();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -262,7 +262,7 @@ public class GerirMedidaRelatorioPanel extends JPanel
setEnabled();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -20,7 +20,7 @@ import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.HsRelatorioMedida;
@ -255,7 +255,7 @@ public class GerirMedidasRelatorioPanel extends JPanel
setEnabled();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
@ -278,7 +278,7 @@ public class GerirMedidasRelatorioPanel extends JPanel
setEnabled();
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -19,7 +19,7 @@ import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
import siprp.database.cayenne.objects.HsRelatorioRiscoValorQualitativo;
@ -306,7 +306,7 @@ public class GerirValoresRiscoPanel extends JPanel implements ActionListener, Ca
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -38,7 +38,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import leaf.ui.LeafButton;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafIconButton;
import siprp.database.cayenne.objects.HsEmailEstabelecimento;
import siprp.database.cayenne.objects.HsRelatorio;
@ -295,7 +295,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
}
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}
@ -340,7 +340,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
}
catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
finally
{
@ -453,7 +453,7 @@ public class PanelRelatorio extends JPanel implements CaretListener, ChangeListe
buttonSave.setEnabled( false );
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}

@ -19,7 +19,7 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
import siprp.database.cayenne.objects.HsRelatorio;
@ -192,7 +192,7 @@ public class RelatorioHigieneSegurancaWindow extends JFrame implements Trackable
}
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}

@ -3,7 +3,7 @@ package siprp.medicina.exames.logic;
import java.util.Collection;
import java.util.List;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafLogic;
import siprp.database.cayenne.objects.Prestadores;
import siprp.database.cayenne.objects.TrabalhadoresEcd;
@ -56,7 +56,7 @@ public class RecepcaoExamesLogic extends LeafLogic
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -37,7 +37,7 @@ import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import siprp.clientes.ClientesDataProvider;
import siprp.clientes.ContactoPanel;
import siprp.data.ContactoData;
@ -427,7 +427,7 @@ public class PrestadoresWindow extends EditorWindow
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}

@ -5,7 +5,7 @@ import java.util.List;
import javax.swing.tree.DefaultMutableTreeNode;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.LeafLogic;
import leaf.ui.LeafWindow.LeafObject;
import siprp.MedicinaConstants;
@ -625,7 +625,7 @@ public class MedicinaProcessoLogic extends LeafLogic
}
} catch( Exception e )
{
LeafError.error( e );
LeafDialog.error( e );
}
}
} );
@ -799,7 +799,7 @@ public class MedicinaProcessoLogic extends LeafLogic
runActionLater( REFRESH );
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}
@ -850,7 +850,7 @@ public class MedicinaProcessoLogic extends LeafLogic
}
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}
@ -893,7 +893,7 @@ public class MedicinaProcessoLogic extends LeafLogic
}
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}

@ -0,0 +1,39 @@
package leaf.ui;
import static com.evolute.utils.strings.UnicodeLatin1Map.atilde;
import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil;
import javax.swing.JOptionPane;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.ui.DialogException;
public class LeafDialog
{
public static void error( Exception e )
{
if( e != null )
{
ErrorLogger.logException( e );
e.printStackTrace( System.out );
DialogException.showException( e );
}
}
public static boolean confirmDelete( boolean masculino, boolean plural, String nome )
{
return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(
null,
"Tem a certeza que deseja remover " +
( masculino ? "o" : "a" ) +
( plural ? "s" : "" ) +
" " + nome + " seleccionad" +
( masculino ? "o" : "a" ) +
( plural ? "s" : "" ) +
"?",
"Confirmar remo" + ccedil + atilde + "o",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null );
}
}

@ -1,20 +0,0 @@
package leaf.ui;
import javax.swing.JOptionPane;
import com.evolute.utils.error.ErrorLogger;
public class LeafError
{
public static void error( Throwable e )
{
if( e != null )
{
ErrorLogger.logException( e );
e.printStackTrace(System.out);
JOptionPane.showMessageDialog( null, "Detalhes: \n"+e.getMessage(), "Erro!", JOptionPane.ERROR_MESSAGE );
}
}
}

@ -9,7 +9,7 @@ import java.util.List;
import javax.swing.tree.DefaultMutableTreeNode;
import leaf.ui.LeafError;
import leaf.ui.LeafDialog;
import leaf.ui.TreeTools;
import siprp.database.cayenne.objects.Empresas;
import siprp.database.cayenne.objects.Estabelecimentos;
@ -198,7 +198,7 @@ public class HigieneSegurancaLogic
}
} catch( Exception e )
{
LeafError.error(e);
LeafDialog.error(e);
}
}
@ -360,8 +360,11 @@ public class HigieneSegurancaLogic
DefaultMutableTreeNode categoriaNode = new DefaultMutableTreeNode( categoria );
for( HsLegislacao legislacao: categoria.getHsLegislacaoArray() )
{
DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao );
categoriaNode.add( legislacaoNode );
if( legislacao.getDeletedDate() == null )
{
DefaultMutableTreeNode legislacaoNode = new DefaultMutableTreeNode( legislacao );
categoriaNode.add( legislacaoNode );
}
}
result.add( categoriaNode );
}

Loading…
Cancel
Save