/** * isFirtLifelineNodeFromFragment * * @param fragmentNode * @return boolean */ private boolean isFirtLifelineNodeFromFragment(NotationNode fragmentNode) { List<LifeLineNode> list = new ArrayList<LifeLineNode>(); List<AbstractNode> nodeList = diagram.getNodeList(); CombinedFragment combindFragment = (CombinedFragment) fragmentNode.getUmlModel(); EList<Lifeline> coveredsLifeline = combindFragment.getCovereds(); for (Lifeline lifeline : coveredsLifeline) { for (AbstractNode abstractNode : nodeList) { if (abstractNode instanceof LifeLineNode && lifeline.equals(abstractNode.getUmlModel())) { if (list.size() == 0) { list.add((LifeLineNode) abstractNode); } else { if (list.get(0).getX() > abstractNode.getX()) { list.add(0, (LifeLineNode) abstractNode); } else { list.add((LifeLineNode) abstractNode); } } } } } if (node.equals(list.get(0))) { return true; } return false; }
/** * ShiftLifeLineNodeCommand * * @param editPart * @param constraint * @param lifeLineNodeList * @param diagram */ public ShiftLifeLineNodeCommand( EditPart editPart, Rectangle constraint, List<LifeLineNode> lifeLineNodeList, Diagram diagram) { this.node = (AbstractNode) editPart.getModel(); this.lifeLineNodeList = lifeLineNodeList; this.oldX = node.getX(); this.newX = constraint.x; this.diagram = diagram; }
/** * isMoveFragment * * @param fragmentNode * @return boolean */ private boolean isMoveFragment(NotationNode fragmentNode) { CombinedFragment combindFragment = (CombinedFragment) fragmentNode.getUmlModel(); if (combindFragment.getCovereds().contains(node.getUmlModel())) { if (isFirtLifelineNodeFromFragment(fragmentNode)) { return true; } } else { if (fragmentNode.getX() > node.getX()) { return true; } } return false; }