|
|
|
|
@ -9,6 +9,12 @@ import info.clearthought.layout.TableLayoutConstraints;
|
|
|
|
|
import java.awt.CardLayout;
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
import java.awt.GridLayout;
|
|
|
|
|
import java.awt.Point;
|
|
|
|
|
import java.awt.dnd.DropTarget;
|
|
|
|
|
import java.awt.dnd.DropTargetDragEvent;
|
|
|
|
|
import java.awt.dnd.DropTargetDropEvent;
|
|
|
|
|
import java.awt.dnd.DropTargetEvent;
|
|
|
|
|
import java.awt.dnd.DropTargetListener;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.beans.PropertyChangeEvent;
|
|
|
|
|
@ -23,6 +29,7 @@ import javax.swing.event.TreeSelectionEvent;
|
|
|
|
|
import javax.swing.event.TreeSelectionListener;
|
|
|
|
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
|
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
|
|
|
import javax.swing.tree.TreeNode;
|
|
|
|
|
import javax.swing.tree.TreePath;
|
|
|
|
|
import javax.swing.tree.TreeSelectionModel;
|
|
|
|
|
|
|
|
|
|
@ -38,6 +45,8 @@ import siprp.data.outer.HsRiscoTemaData;
|
|
|
|
|
import siprp.higiene.gestao.SIPRPLazyLoadedPanel;
|
|
|
|
|
import siprp.logic.HigieneSegurancaLogic;
|
|
|
|
|
|
|
|
|
|
import com.evolute.entity.evo.EvoDataException;
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
import com.evolute.utils.ui.trees.TreeTools;
|
|
|
|
|
|
|
|
|
|
public class GerirRiscosPanel extends SIPRPLazyLoadedPanel implements LeafUIConstants
|
|
|
|
|
@ -183,6 +192,124 @@ public class GerirRiscosPanel extends SIPRPLazyLoadedPanel implements LeafUICons
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
DropTargetListener dropTargetListener = new DropTargetListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dragEnter(DropTargetDragEvent dtde)
|
|
|
|
|
{
|
|
|
|
|
// System.out.println( "DragEnter" );
|
|
|
|
|
// System.out.println( tree.getSelectionPath() );
|
|
|
|
|
// getSelectedObject();
|
|
|
|
|
// dtde.acceptDrag( dtde.getDropAction() );
|
|
|
|
|
|
|
|
|
|
//TODO: isDesendent != null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dragExit(DropTargetEvent dte)
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "DragExit" );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dragOver(DropTargetDragEvent dtde)
|
|
|
|
|
{
|
|
|
|
|
// Point pt = dtde.getLocation();
|
|
|
|
|
// TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
|
|
|
|
|
// if( !tree.getSelectionPath().equals( parentpath ) )
|
|
|
|
|
// {
|
|
|
|
|
// tree.expandPath( parentpath );
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void drop(DropTargetDropEvent dtde)
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "Drop" );
|
|
|
|
|
|
|
|
|
|
Point pt = dtde.getLocation();
|
|
|
|
|
TreePath destinyPath = tree.getClosestPathForLocation(pt.x, pt.y);
|
|
|
|
|
|
|
|
|
|
Object destinyComponent = destinyPath.getLastPathComponent();
|
|
|
|
|
System.out.println( destinyPath );
|
|
|
|
|
System.out.println( );
|
|
|
|
|
|
|
|
|
|
if( destinyComponent instanceof DefaultMutableTreeNode )
|
|
|
|
|
{
|
|
|
|
|
System.out.println("moving node ...");
|
|
|
|
|
DefaultMutableTreeNode destinyNode = ( DefaultMutableTreeNode ) destinyComponent;
|
|
|
|
|
Object destinyObject = destinyNode.getUserObject();
|
|
|
|
|
|
|
|
|
|
TreePath parentPath = tree.getSelectionPath();
|
|
|
|
|
Object parentComponent = parentPath.getLastPathComponent();
|
|
|
|
|
|
|
|
|
|
if( parentComponent instanceof DefaultMutableTreeNode )
|
|
|
|
|
{
|
|
|
|
|
DefaultMutableTreeNode parentNode = ( DefaultMutableTreeNode ) parentComponent;
|
|
|
|
|
Object parentObject = parentNode.getUserObject();
|
|
|
|
|
|
|
|
|
|
if( destinyObject instanceof HsRiscoTemaData )
|
|
|
|
|
{
|
|
|
|
|
System.out.println("\tmove risco -> tema");
|
|
|
|
|
HsRiscoTemaData destTema = ( HsRiscoTemaData ) destinyObject;
|
|
|
|
|
|
|
|
|
|
if ( parentObject instanceof HsRiscoData )
|
|
|
|
|
{
|
|
|
|
|
HsRiscoData parent = ( HsRiscoData ) parentObject;
|
|
|
|
|
parent.setToTema_id( destTema );
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
parent.save();
|
|
|
|
|
destinyNode.add( parentNode );
|
|
|
|
|
tree.updateUI();
|
|
|
|
|
}
|
|
|
|
|
catch ( EvoDataException e )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( e );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if( destinyObject instanceof HsRiscoData )
|
|
|
|
|
{
|
|
|
|
|
System.out.println("\tmove medida -> risco");
|
|
|
|
|
HsRiscoData destRisco = ( HsRiscoData ) destinyObject;
|
|
|
|
|
|
|
|
|
|
if ( parentObject instanceof HsRiscoMedidaData )
|
|
|
|
|
{
|
|
|
|
|
HsRiscoMedidaData parent = ( HsRiscoMedidaData ) parentObject;
|
|
|
|
|
parent.setToRisco_id( destRisco );
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
parent.save();
|
|
|
|
|
destinyNode.add( parentNode );
|
|
|
|
|
tree.updateUI();
|
|
|
|
|
}
|
|
|
|
|
catch ( EvoDataException e )
|
|
|
|
|
{
|
|
|
|
|
ErrorLogger.logException( e );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dropActionChanged(DropTargetDragEvent dtde)
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "DropActionChange" );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
tree.setDragEnabled( true );
|
|
|
|
|
tree.setDropTarget( new DropTarget( tree , dropTargetListener ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void criarTema()
|
|
|
|
|
@ -587,4 +714,13 @@ public class GerirRiscosPanel extends SIPRPLazyLoadedPanel implements LeafUICons
|
|
|
|
|
setEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void moverRisco( HsRiscoData from, DefaultMutableTreeNode to )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void moverRequisito( )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|