|
|
|
|
@ -29,14 +29,20 @@ import javax.swing.tree.TreeSelectionModel;
|
|
|
|
|
import leaf.ui.LeafButton;
|
|
|
|
|
import leaf.ui.LeafDialog;
|
|
|
|
|
import leaf.ui.LeafIconButton;
|
|
|
|
|
import leaf.ui.TreeInserterDialog;
|
|
|
|
|
import leaf.ui.TreeTools;
|
|
|
|
|
import siprp.database.cayenne.objects.BaseObject;
|
|
|
|
|
import siprp.database.cayenne.objects.HsPostoRisco;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRelatorioMedida;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRelatorioPosto;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRelatorioPostoMedida;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRelatorioPostoRisco;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRelatorioRisco;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRisco;
|
|
|
|
|
import siprp.database.cayenne.objects.HsRiscoEmpresa;
|
|
|
|
|
import siprp.logic.HigieneSegurancaLogic;
|
|
|
|
|
import siprp.logic.node.MedidaRelatorioNode;
|
|
|
|
|
import siprp.logic.node.NodeRisco;
|
|
|
|
|
import siprp.logic.node.RiscoRelatorioNode;
|
|
|
|
|
|
|
|
|
|
public class GerirMedidasRelatorioPanel extends JPanel
|
|
|
|
|
@ -245,27 +251,68 @@ public class GerirMedidasRelatorioPanel extends JPanel
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
HsRelatorioPostoRisco postoRisco = getSelectedRisco();
|
|
|
|
|
if( posto != null )
|
|
|
|
|
DefaultMutableTreeNode allRiscos = getAllRiscos();
|
|
|
|
|
TreeTools.removeAll( allRiscos, getRiscosTree() );
|
|
|
|
|
TreeInserterDialog dialog = new TreeInserterDialog( "Adicionar Riscos", allRiscos );
|
|
|
|
|
DefaultMutableTreeNode result = dialog.getResult();
|
|
|
|
|
if( result != null )
|
|
|
|
|
{
|
|
|
|
|
HsRelatorioMedida medida = new HsRelatorioMedida();
|
|
|
|
|
medida.setDescription( "" );
|
|
|
|
|
medida.setRequesitosLegais( "" );
|
|
|
|
|
medida.setToHsRelatorioRisco( postoRisco.getToHsRelatorioRisco() );
|
|
|
|
|
HsRelatorioPostoMedida rel = new HsRelatorioPostoMedida();
|
|
|
|
|
rel.setToHsRelatorioMedida( medida );
|
|
|
|
|
rel.setToHsRelatorioPosto( posto );
|
|
|
|
|
rel.save();
|
|
|
|
|
selectedMedida = rel;
|
|
|
|
|
}
|
|
|
|
|
addResult( result );
|
|
|
|
|
refresh();
|
|
|
|
|
}
|
|
|
|
|
setEnabled();
|
|
|
|
|
} catch( Exception e )
|
|
|
|
|
}
|
|
|
|
|
catch( Exception e )
|
|
|
|
|
{
|
|
|
|
|
LeafDialog.error( e );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DefaultMutableTreeNode getAllRiscos()
|
|
|
|
|
{
|
|
|
|
|
DefaultMutableTreeNode result = new DefaultMutableTreeNode();
|
|
|
|
|
if( posto != null )
|
|
|
|
|
{
|
|
|
|
|
result = HigieneSegurancaLogic.getRiscosTree( posto.getToHsRelatorioArea().getToHsRelatorio().getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getToEmpresas() );
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DefaultMutableTreeNode getRiscosTree()
|
|
|
|
|
{
|
|
|
|
|
DefaultMutableTreeNode result = new DefaultMutableTreeNode();
|
|
|
|
|
for( int i = 0; i < root.getChildCount(); ++i )
|
|
|
|
|
{
|
|
|
|
|
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) root.getChildAt( i );
|
|
|
|
|
HsRelatorioPostoRisco relPostoRisco = null;
|
|
|
|
|
if( childNode instanceof RiscoRelatorioNode )
|
|
|
|
|
{
|
|
|
|
|
relPostoRisco = (HsRelatorioPostoRisco) ((RiscoRelatorioNode) childNode).getUserObject();
|
|
|
|
|
}
|
|
|
|
|
HsRelatorioRisco relRisco = relPostoRisco == null ? null : relPostoRisco.getToHsRelatorioRisco();
|
|
|
|
|
if( relRisco != null )
|
|
|
|
|
{
|
|
|
|
|
HsRisco risco = HigieneSegurancaLogic.findHsRiscoFor( relRisco );
|
|
|
|
|
if( risco != null )
|
|
|
|
|
{
|
|
|
|
|
result.add( new NodeRisco( risco ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addResult( DefaultMutableTreeNode root )
|
|
|
|
|
{
|
|
|
|
|
if( root != null )
|
|
|
|
|
{
|
|
|
|
|
if( root instanceof NodeRisco )
|
|
|
|
|
{
|
|
|
|
|
//TODO
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean confirm( String message )
|
|
|
|
|
{
|
|
|
|
|
return JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( this, message, "Confirma"+ccedil+atilde+"o", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null );
|
|
|
|
|
@ -316,7 +363,8 @@ public class GerirMedidasRelatorioPanel extends JPanel
|
|
|
|
|
}
|
|
|
|
|
refresh();
|
|
|
|
|
setEnabled();
|
|
|
|
|
} catch( Exception e )
|
|
|
|
|
}
|
|
|
|
|
catch( Exception e )
|
|
|
|
|
{
|
|
|
|
|
LeafDialog.error( e );
|
|
|
|
|
}
|
|
|
|
|
|