Skip to content
Snippets Groups Projects
Commit a99f427c authored by Stephane Dallongeville's avatar Stephane Dallongeville
Browse files

fixed possible NPE

parent e0bc89c0
No related branches found
No related tags found
No related merge requests found
......@@ -90,13 +90,18 @@ public class BlockPanel extends JPanel implements ActionListener, BlockListener
if (dragging)
{
WorkFlow wf = workFlowPane.getWorkFlow();
if (wf.isBlockSelected(blockDesc))
{
for (BlockDescriptor bd : wf.getBlockSelection())
{
BlockPanel bp = workFlowPane.getBlockPanel(bd);
bp.setBounds(Math.max(0, dx - pressedX + bp.getX()), Math.max(0, dy - pressedY + bp.getY()),
bp.getWidth(), bp.getHeight());
if (bp != null)
bp.setBounds(Math.max(0, dx - pressedX + bp.getX()), Math.max(0, dy - pressedY + bp.getY()),
bp.getWidth(), bp.getHeight());
}
}
else
setBounds(Math.max(0, dx - pressedX + x), Math.max(0, dy - pressedY + y), w, h);
}
......
......@@ -315,21 +315,29 @@ public class WorkFlowContainer extends JLayeredPane implements WorkFlowListener,
BlockPanel srcBlockPanel = getBlockPanel(link.srcBlock);
BlockPanel dstBlockPanel = getBlockPanel(link.dstBlock);
linkLines.put(link, new RoundedSquareLine(srcBlockPanel, dstBlockPanel, link));
// refresh the target block
if (dstBlockPanel instanceof WorkFlowPanel)
if ((srcBlockPanel == null) || (dstBlockPanel == null))
{
WorkFlowContainer innerFlow = ((WorkFlowPanel) dstBlockPanel).innerFlowPane;
BlockDescriptor targetInnerlBlock = innerFlow.workFlow.getInputOwner(link.dstVar);
innerFlow.getBlockPanel(targetInnerlBlock).refreshNow();
System.err.println("Warning: cannot recover link between " + link.srcBlock.getDefinedName()
+ " and " + link.dstBlock.getDefinedName() + " !");
}
else
dstBlockPanel.refreshNow();
{
linkLines.put(link, new RoundedSquareLine(srcBlockPanel, dstBlockPanel, link));
repaint();
// refresh the target block
if (dstBlockPanel instanceof WorkFlowPanel)
{
WorkFlowContainer innerFlow = ((WorkFlowPanel) dstBlockPanel).innerFlowPane;
BlockDescriptor targetInnerlBlock = innerFlow.workFlow.getInputOwner(link.dstVar);
innerFlow.getBlockPanel(targetInnerlBlock).refreshNow();
}
else
dstBlockPanel.refreshNow();
repaint();
}
}
}, true);
}
......@@ -638,15 +646,12 @@ public class WorkFlowContainer extends JLayeredPane implements WorkFlowListener,
Line line = linkLines.remove(link);
if (line == null)
{
System.err.println("Warning: missing link, cannot be removed properly");
}
else
{
line.dispose();
}
BlockPanel dstBlockPanel = getBlockPanel(link.dstBlock);
if (dstBlockPanel != null)
{
// refresh the target block
......
......@@ -297,6 +297,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener
public void run()
{
final BlockPanel ownerPanel = innerFlowPane.getBlockPanel(innerBlock);
exposingLinks.put(variable, new RoundedSquareLine(WorkFlowPanel.this, ownerPanel, variable)
{
@Override
......@@ -360,6 +361,7 @@ public class WorkFlowPanel extends BlockPanel implements VarVisibilityListener
{
final BlockPanel ownerPanel = innerFlowPane.getBlockPanel(innerBlock);
exposingLinks.put(variable, new RoundedSquareLine(ownerPanel, WorkFlowPanel.this, variable)
{
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment