Package org.eclipse.jst.pagedesigner.validation.caret

Examples of org.eclipse.jst.pagedesigner.validation.caret.Target


   * @return the design position
   */
  public static DesignPosition findEditPartPosition(EditPart host, Point p,
      IPositionMediator validator) {
    try {
      host = validator.getEditableContainer(new Target(host));
      FlowBoxLine boxLine = new FlowBoxLine(
          new Rectangle(p.x, p.y, 0, 0), validator, p);
      DesignPosition position = innerFindEditPartPosition(host, host, p,
          boxLine, validator);
      if (position == null) {
View Full Code Here


   */
    //TODO: needs refactoring
  public static DesignPosition innerFindEditPartPosition(EditPart rootHost,
      EditPart host, Point p, FlowBoxLine boxLine,
      IPositionMediator validator) {
    Target target = new Target(host);
    LayoutPart lPart = new LayoutPart(host, p);
    // text
    if (host instanceof TextEditPart) {
      if (lPart.contains(p)) {
        DesignPosition position = null;
        // see if the point is within string.
        position = findTextEditPartPosition((TextEditPart) host, p);
        if (position == null) {
          addToCurrentLine(boxLine, host, p, validator);
        }
        // found?!!
        return position;
      }
            addToCurrentLine(boxLine, host, p, validator);
            return null;
    }
    // widget
    else if (isWidget(host)) {
      if (lPart.contains(p)
          && (validator.isValidPosition(new DOMRefPosition(target
              .getNode(), true)) || //
          validator.isValidPosition((new DOMRefPosition(target
              .getNode(), false))))) {
        if (IHTMLConstants.TAG_BR.equalsIgnoreCase(Target.resolveNode(
            host).getNodeName())) {
          return new DesignRefPosition(host, lPart.isBeforePoint(p));
        }
                return new DesignRefPosition(host, lPart.isBeforePoint(p)
                    || !lPart.atLeftPart(p));
      }
            addToCurrentLine(boxLine, host, p, validator);
    } else {
      // root host. we always support it has editable area.
      if (host == rootHost) {
        if (host.getChildren().size() > 0) {
          List children = host.getChildren();
          for (int i = 0, size = children.size(); i < size; i++) {
            GraphicalEditPart child = (GraphicalEditPart) children
                .get(i);
            DesignPosition position = innerFindEditPartPosition(
                rootHost, child, p, boxLine, validator);
            if (position != null) {
              return position;
            }
          }
        }
        if (boxLine.getPartsList().size() == 0) {
          if (lPart.contains(p)) {
            // found!!!
            return new DesignPosition(host, 0);
          }
          addToCurrentLine(boxLine, host, p, validator);
        }
      }
      // container
      else {
        // can't edit it.
        if (!validator.hasEditableArea(target)) {
          if (lPart.contains(p) && //
              (validator.isValidPosition(new DesignRefPosition(
                  target.getPart(), true)) || //
              validator.isValidPosition(new DesignRefPosition(
                  target.getPart(), false)))) {
            return new DesignRefPosition(host, lPart
                .isBeforePoint(p)
                || !lPart.atLeftPart(p));
          }
                    addToCurrentLine(boxLine, host, p, validator);
        }
        // can edit
        else {
          // contains p
          if (lPart.contains(p) || //
              (!validator.isValidPosition(new DesignRefPosition(
                  target.getPart(), true)) && //
              !validator.isValidPosition(new DesignRefPosition(
                  target.getPart(), false)))) {
            if (host.getChildren().size() > 0) {
              List children = host.getChildren();
              for (int i = 0, size = children.size(); i < size; i++) {
                GraphicalEditPart child = (GraphicalEditPart) children
                    .get(i);
View Full Code Here

   */
    // TODO: needs refactoring
  public static DesignPosition innerFindEditPartPositionConstrained(
      EditPart rootHost, EditPart host, Point p, FlowBoxLine boxLine,
      IMovementMediator validator) {
    Target target = new Target(host);
    LayoutPart lPart = new LayoutPart(host, p);
    // text
    if (host instanceof TextEditPart) {
      if (lPart.contains(p)) {
        DesignPosition position = null;
View Full Code Here

  private EditPart getRootEditablePart(EditPart part,
      IMovementMediator moveMediator) {
    EditPart rootpart = null;
    if ((rootpart = ((InlineEditingNavigationMediator) moveMediator)
        .getRootConstainedEditableContainer(new Target(part))) == null) {
      rootpart = moveMediator.getEditableContainer(new Target(part));
    }
    return rootpart;
  }
View Full Code Here

  public IDOMPosition moveIn(Node node) {
    IDOMPosition result = null;
    if (INNER_DEBUG) {
      _log.info("- Move into: " + node.getLocalName()); //$NON-NLS-1$
    }
    if (_validator.isEditable(new Target(node))) {
      int index;
      // Transparent text is not editable, so this is not transparent.
      if (EditModelQuery.isText(node)) {
        index = (_forward) ? 0 : ((Text) node).getData().length();
        result = new DOMPosition(node, index);
        // move ahead one pos.
        IDOMPosition pos = getNextTextPosition(result);
        if (pos != null) {
          result = pos;
        }
      } else {
        if (node.hasChildNodes()) {
          index = _forward ? 0 : node.getChildNodes().getLength();
          result = new DOMPosition(node, index); // DOMRefPosition(next,
          // !_forward);
        } else {
          result = new DOMPosition(node, 0);
        }
      }
    } else {
      if (node.hasChildNodes()) {
        Node child = _forward ? node.getFirstChild() : node
            .getLastChild();
        result = new DOMRefPosition(child, _forward);
        while (child != null) {
          if (_validator.allowsMoveIn(new Target(child))) {
            result = moveIn(child);
            break;
          }
          child = _forward ? child.getNextSibling() : child
              .getPreviousSibling();
View Full Code Here

        nextNode = EditModelQuery.getInstance().getSibling(nextNode,
            _forward);
      }
      if (nextNode != null) {
        // move in?
        if (validator.allowsMoveIn(new Target(nextNode))) {
          currentPosition = moveIn(nextNode);
          // Stop when it is in table. For others we continue search
          // for text.
          if (!canStopHere(nextNode) && //
              EditModelQuery.getInstance().getSibling(
                  currentPosition, _forward) != null) {
            currentPosition = moveToNextPosition(currentPosition,
                validator);
          }
        }
        // not allowed to move in. e.g. it's empty string.
        else {
          currentPosition = new DOMRefPosition(nextNode, _forward);// skip(position);
        }
      } else {
        if (validator.allowsMoveOut(new Target(
            getNaviContainer(position)))) {
          currentPosition = moveOut(getNaviContainer(position));
        }
      }
    }
View Full Code Here

   * @return
   */
  private boolean shouldStartRangeSelection() {
    IPositionMediator positionMediator = new InlineEditingPositionMediator(
        new ActionData(ActionData.INLINE_EDIT, null));
    if (positionMediator.isEditable(new Target(getSourceEditPart()))) {
      return getSourceEditPart() instanceof TextEditPart
          || !(((NodeEditPart) getSourceEditPart()).isWidget());
    }
        return false;
  }
View Full Code Here

        // we only see if its children can be
        // referenced.
        for (int i = 0, n = children.size(); i < n; i++) {
          LayoutPart nextPart = new LayoutPart((EditPart) children
              .get(i), _point);
          Target target = new Target(nextPart.getPart());
          if (_validator.isValidPosition(new DesignRefPosition(target
              .getPart(), false))) {
            result = getCloserPart(result, nextPart, _point);
          } else if (_validator.hasEditableArea(target)) {
            LayoutPart temp = getClosestChildPart(nextPart);
            if (temp == null) {
View Full Code Here

   * @param closestPart
   * @param target
   * @return
   */
  LayoutPart resolveClosestPartFrom(LayoutPart closestPart) {
    Target target = new Target(closestPart.getPart());
    LayoutPart finalPart = null;
    if (EditModelQuery.isInline(Target.resolveNode(closestPart.getPart()))) {

      if (closestPart.isAfterPoint() || closestPart.isBeforePoint()) {
        finalPart = closestPart;
      } else {
        if (_validator.hasEditableArea(target)
            && (_validator instanceof IMovementMediator
                && ((IMovementMediator) _validator)
                    .allowsMoveIn(target) || !(_validator instanceof IMovementMediator))) {
          finalPart = getClosestChildPartOrPart(closestPart);
        }
      }
    }
    // block
    else {
      if (closestPart.contains(_point)) {
        if (_validator.hasEditableArea(target) && //
            (_validator instanceof IMovementMediator
                && ((IMovementMediator) _validator)
                    .allowsMoveIn(target) || !(_validator instanceof IMovementMediator))) {
          finalPart = getClosestChildPartOrPart(closestPart);
        }
      }
      // outside of bounds
      else {
        if (_validator.hasEditableArea(target)
            && !IHTMLConstants.TAG_TABLE.equalsIgnoreCase(target
                .getNode().getNodeName())
            && (_validator instanceof IMovementMediator
                && ((IMovementMediator) _validator)
                    .allowsMoveIn(target) || !(_validator instanceof IMovementMediator))) {
          if (closestPart.atSameRow(_point)) {
            finalPart = getClosestChildPartOrPart(closestPart);
          } else if (!_validator
              .isValidPosition(new DesignRefPosition(target
                  .getPart(), true))) {
            finalPart = getClosestChildPartOrPart(closestPart);
          }
        }
      }
    }
    if (finalPart == null && //
        (_validator.isValidPosition(new DesignRefPosition(target
            .getPart(), true)) || //
        _validator.isValidPosition(new DesignRefPosition(target
            .getPart(), false)))) {
      finalPart = closestPart;
    }
    return finalPart;
  }
View Full Code Here

      boolean atPointLeft = isBeforePoint(_point);
//      boolean atPointRight = isAfterPoint(_point);
//      if (atPointLeft == atPointRight) {
//          // TODO: and...?
//      }
      Target target = new Target(getPart());
      if (validator.isValidPosition(new DOMRefPosition(target.getNode(),
          atPointLeft))) {
        result = new DesignRefPosition(_part, atPointLeft);
      } else if (validator.isValidPosition(new DOMRefPosition(target
          .getNode(), !atPointLeft))) {
        result = new DesignRefPosition(_part, !atPointLeft);
      } else if (validator.isEditable(target)) {
        if (atPointLeft) {
          result = new DesignPosition(_part, 0);
View Full Code Here

TOP

Related Classes of org.eclipse.jst.pagedesigner.validation.caret.Target

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.