Package org.eclipse.jst.pagedesigner.viewer

Examples of org.eclipse.jst.pagedesigner.viewer.DesignRange


    if (startDomPos != null) {
      DesignPosition startPos = null, endPos = null;
      startPos = DOMPositionHelper.toDesignPosition(startDomPos);
      endPos = DOMPositionHelper.toDesignPosition(endDomPos);
      if (startPos != null) {
        return new DesignRange(startPos, endPos);
      }
    }
    return null;
  }
View Full Code Here


  public boolean isRangeSelected() {
    IHTMLGraphicalViewer viewer = (IHTMLGraphicalViewer) this.getViewer();
    if (viewer == null || !viewer.isInRangeMode()) {
      return false;
    }
    DesignRange range = viewer.getRangeSelection();
    if (range == null || !range.isValid()) {
      return false;
    }
    return RangeUtil.intersect(range, this);
  }
View Full Code Here

  public static Node getCommonParent(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
      Object obj = ((IStructuredSelection) selection).getFirstElement();
      return (Node) obj;
    } else if (selection instanceof DesignRange) {
      DesignRange range = (DesignRange) selection;
      Node node1 = range.getStartPosition().getContainerNode();
      Node node2 = range.getEndPosition().getContainerNode();
      return DOMUtil.findCommonAncester(node1, node2);
    } else {
      // should not happen
      return null;
    }
View Full Code Here

    if (button == 3 && isInState(STATE_INITIAL)) {
      EditPart sourcePart = this.getSourceEditPart();
      IHTMLGraphicalViewer viewer = (IHTMLGraphicalViewer) sourcePart
          .getViewer();
      if (viewer != null && viewer.isInRangeMode()) {
        DesignRange range = viewer.getRangeSelection();
        if (range != null && range.isValid()) {
          if (RangeUtil.intersect(range, sourcePart)) {
            return true;
          }
        }
      }
View Full Code Here

    int position = -1;
    int length = -1;
    ISelection selection = getViewer().getSelection();
    if (selection != null) {
      if (getViewer().isInRangeMode()) {
        DesignRange range = (DesignRange) selection;
        if (range.isValid()) {
          IDOMPosition domPos = DOMPositionHelper.toDOMPosition(range
              .getStartPosition());
          IDOMPosition domEnd = DOMPositionHelper.toDOMPosition(range
              .getEndPosition());
          if (EditValidateUtil.validPosition(domPos)
              && EditValidateUtil.validPosition(domEnd)) {
            position = EditModelQuery
                .getIndexedRegionLocation(domPos);
View Full Code Here

        return null;
      }
      IDOMPosition startPos = range.getStartPosition();
      DesignPosition start = DOMPositionHelper.toDesignPosition(startPos);
      if (range.isEmpty()) {
        return new DesignRange(start, start);
      }
            IDOMPosition endPos = range.getEndPosition();
            return new DesignRange(start, DOMPositionHelper
                .toDesignPosition(endPos));
    } catch (Exception e) {
      // "Selection error"
      _log.error("Error.RangeModeCommand.SetSelection"); //$NON-NLS-1$
      return null;
View Full Code Here

    if (button == 3 && isInState(STATE_INITIAL)) {
      EditPart sourcePart = this.getSourceEditPart();
      IHTMLGraphicalViewer viewer = (IHTMLGraphicalViewer) sourcePart
          .getViewer();
      if (viewer != null && viewer.isInRangeMode()) {
        DesignRange range = viewer.getRangeSelection();
        if (range != null && range.isValid()) {
          if (RangeUtil.intersect(range, sourcePart)) {
            return true;
          }
        }
      }
View Full Code Here

  }

  protected void preExecute() {
    _prevRange = _viewer.getRangeSelection();
    DesignPosition position = findObjectModePosition();
    _prevRange = new DesignRange(position, position);
    super.preExecute();
  }
View Full Code Here

    }
    return result;
  }

  private DesignPosition getCurrentObjectPosition() {
    DesignRange result = null;
    if (_viewer.isInRangeMode()) {
      result = _viewer.getRangeSelection();
    } else {
      List parts = _viewer.getSelectedEditParts();
      if (parts.size() > 0) {
        EditPart selection = (EditPart) parts.get(0);
        if (selection instanceof SubNodeEditPart) {
          DesignPosition position = new DesignRefPosition(selection,
              false);
          position = DOMPositionHelper.toDesignPosition(EditHelper
              .ensureDOMPosition(DOMPositionHelper
                  .toDOMPosition(position)));
          result = new DesignRange(position, position);
        }
      }
    }
    return result != null && result.isValid() ? result.getEndPosition()
        : null;
  }
View Full Code Here

  public int[] getSelectedRange() {
    IHTMLGraphicalViewer viewer = (IHTMLGraphicalViewer) this.getViewer();
    if (viewer == null || !viewer.isInRangeMode()) {
      return null;
    }
    DesignRange range = viewer.getRangeSelection();
    if (range == null || !range.isValid()) {
      return null;
    }
    if (!RangeUtil.intersect(range, this)) {
      return null;
    }
    // ok, we intersect with the range.
    range = RangeUtil.normalize(range);
    EditPart startContainer = range.getStartPosition().getContainerPart();
    EditPart endContainer = range.getEndPosition().getContainerPart();
    int[] ret = new int[2];
    if (startContainer != this) {
      ret[0] = 0;
    } else {
      ret[0] = range.getStartPosition().getOffset();
    }
    if (endContainer != this) {
      ret[1] = this.getTextData().length();
    } else {
      {
        ret[1] = range.getEndPosition().getOffset();
      }
    }
    return ret;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jst.pagedesigner.viewer.DesignRange

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.