예제 #1
0
 /** @param editparts */
 private List flitterEditpart(List editparts) {
   List copy = new ArrayList(editparts);
   int size = editparts.size();
   for (int i = 0; i < size; i++) {
     EditPart part = (EditPart) editparts.get(i);
     if (part.getAdapter(ISelectionFilter.class) != null) {
       copy = ((ISelectionFilter) part.getAdapter(ISelectionFilter.class)).filterEditpart(copy);
     }
   }
   editparts = copy;
   return editparts;
 }
  boolean navigateNextAnchor(int direction) {
    EditPart focus = getCurrentViewer().getFocusEditPart();
    AccessibleAnchorProvider provider;
    provider = (AccessibleAnchorProvider) focus.getAdapter(AccessibleAnchorProvider.class);
    if (provider == null) return false;

    List list;
    if (isInState(STATE_ACCESSIBLE_DRAG_IN_PROGRESS)) list = provider.getTargetAnchorLocations();
    else list = provider.getSourceAnchorLocations();

    Point start = getLocation();
    int distance = Integer.MAX_VALUE;
    Point next = null;
    for (int i = 0; i < list.size(); i++) {
      Point p = (Point) list.get(i);
      if (p.equals(start) || (direction != 0 && (start.getPosition(p) != direction))) continue;
      int d = p.getDistanceOrthogonal(start);
      if (d < distance) {
        distance = d;
        next = p;
      }
    }

    if (next != null) {
      ourPlaceMouseInViewer(next);
      return true;
    }
    return false;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
   */
  @Override
  protected boolean calculateEnabled() {
    node = null;
    List<?> selectedObjects = getSelectedObjects();

    if (selectedObjects.size() != 1) {
      return false;
    }

    Object selectedObject = selectedObjects.get(0);

    if ((selectedObject instanceof EditPart)) {
      EditPart editpart = (EditPart) selectedObject;
      Object selectedModel = editpart.getModel();

      if ((selectedModel instanceof Unit && !(selectedModel instanceof ConditionalUnitPart))) {
        transUnit = (Unit) editpart.getModel();

        return true;
      }

      if (selectedModel instanceof EContainerDescriptor
          && editpart.getAdapter(Parameter.class) != null) {
        transUnit = (Unit) ((EContainerDescriptor) selectedModel).getContainer();

        return true;
      }

      if (editpart.getModel() instanceof Node
          && ((editpart.getParent() instanceof LhsRhsTreeEditPart)
              || (editpart instanceof RuleNodeEditPart
                  && (editpart.getParent() instanceof LhsRhsEditPart)))) {

        node = (Node) editpart.getModel();
        transUnit = (Unit) node.getGraph().eContainer();

        return ParameterUtil.getParameter(node) == null;
      }
    }

    return false;
  }