Package org.eclipse.jface.text.link

Examples of org.eclipse.jface.text.link.LinkedPositionGroup


  public void run() {
    ISourceViewer viewer = editor.getViewer();
    IDocument document = viewer.getDocument();
    int offset = ((ITextSelection) editor.getSelectionProvider().getSelection()).getOffset();
    LinkedPositionGroup group = new LinkedPositionGroup();
    IDocument doc =  editor.getDocumentProvider().getDocument(editor.getEditorInput());
    ITextSelection sel = (ITextSelection)editor.getSelectionProvider().getSelection();
    Point curRange = viewer.getSelectedRange();
    this.enclose(doc, sel, "<>", "</>");
    List positions = new ArrayList();
    // the offset / content of groups much match ("<[>]" and "</[>]")
    offset++;
    Position tagOpen = new Position(offset,1);
    Position tagClose = new Position(offset+ sel.getLength() + 3,1);
    positions.add(tagOpen);
    positions.add(tagClose);
    addPositionsToGroup(offset, positions, document, group);
    if (group.isEmpty()) {
      return;
    }
    try {
      LinkedModeModel model = new LinkedModeModel();
      model.addGroup(group);
View Full Code Here


  }

  @Override
  public void applyQuickFix(final IDocument document) {
    final LinkedPosition position = new LinkedPosition(document, getOffset(), getLength());
    LinkedPositionGroup group = new LinkedPositionGroup();

    LinkedModeModel model = new LinkedModeModel();
    try {
      group.addPosition(position);
      model.addGroup(group);
      model.forceInstall();

      ITextViewer viewer = getViewer(document);
      if (viewer == null) {
View Full Code Here

        formatter.formatNode(element);
        if (element instanceof ElementImpl) {
          ElementImpl elementImpl = (ElementImpl) element;
          int nodeOffset = elementImpl.getStartEndOffset() - 1;

          LinkedPositionGroup group = new LinkedPositionGroup();

          try {
            group.addPosition(new LinkedPosition(document, nodeOffset, 0));
            linkModel.addGroup(group);
            hasPositions = true;
          }
          catch (BadLocationException e) {
            StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
View Full Code Here

      LinkedModeModel model = new LinkedModeModel();
      StringBuilder methodStr = new StringBuilder();

      int startPos, length;
      List<LinkedPositionGroup> groups = new ArrayList<LinkedPositionGroup>();
      LinkedPositionGroup group;

      group = new LinkedPositionGroup();
      startPos = startOffset + importOffset + methodStr.length();
      methodStr.append("List<");
      methodStr.append(domainClass.getSimpleName());
      methodStr.append(">");
      length = methodStr.length();
      group.addPosition(new LinkedPosition(document, startPos, length));
      groups.add(group);

      methodStr.append(" ");

      group = new LinkedPositionGroup();
      startPos = startOffset + importOffset + methodStr.length();
      String methodName = getMethodName(propertyName);
      methodStr.append(methodName);
      length = methodName.length();
      group.addPosition(new LinkedPosition(document, startPos, length));
      groups.add(group);

      methodStr.append("(");

      group = new LinkedPositionGroup();
      startPos = startOffset + importOffset + methodStr.length();
      String paramTypeName = propertyClass.getSimpleName();
      length = paramTypeName.length();
      methodStr.append(paramTypeName);
      group.addPosition(new LinkedPosition(document, startPos, length));
      groups.add(group);

      methodStr.append(" ");

      group = new LinkedPositionGroup();
      startPos = startOffset + importOffset + methodStr.length();
      String paramName = propertyName.toLowerCase();
      length = paramName.length();
      methodStr.append(paramName);
      group.addPosition(new LinkedPosition(document, startPos, length));
      groups.add(group);

      methodStr.append(");");

      document.replace(startOffset + importOffset, endOffset - startOffset, methodStr.toString());
View Full Code Here

        formatter.formatNode(element);
        if (element instanceof ElementImpl) {
          ElementImpl elementImpl = (ElementImpl) element;
          int nodeOffset = elementImpl.getStartEndOffset() - 1;

          LinkedPositionGroup group = new LinkedPositionGroup();

          try {
            group.addPosition(new LinkedPosition(document, nodeOffset, 0));
            linkModel.addGroup(group);
            hasPositions = true;
          }
          catch (BadLocationException e) {
            StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
View Full Code Here

  }

  @Override
  public void applyQuickFix(final IDocument document) {
    final LinkedPosition position = new LinkedPosition(document, getOffset(), getLength());
    LinkedPositionGroup group = new LinkedPositionGroup();

    LinkedModeModel model = new LinkedModeModel();
    try {
      group.addPosition(position);
      model.addGroup(group);
      model.forceInstall();

      ITextViewer viewer = getViewer(document);
      if (viewer == null) {
View Full Code Here

      if (model != null) {
        model.endRecording(this);
      }

      LinkedModeModel linkModel = new LinkedModeModel();
      LinkedPositionGroup group = new LinkedPositionGroup();
      attrNode = ((AttrImpl) beanNode.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_FACTORY_METHOD));

      try {
        group.addPosition(new LinkedPosition(document, attrNode.getValueRegionStartOffset() + 1, 0));
        linkModel.addGroup(group);

      }
      catch (BadLocationException e) {
        StatusHandler.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
View Full Code Here

        TemplateVariable variable= variables[i];

        if (variable.isUnambiguous())
          continue;

        LinkedPositionGroup group= new LinkedPositionGroup();

        int[] offsets= variable.getOffsets();
        int length= variable.getLength();

        LinkedPosition first;
        {
          String[] values= variable.getValues();
          ICompletionProposal[] proposals= new ICompletionProposal[values.length];
          for (int j= 0; j < values.length; j++) {
            ensurePositionCategoryInstalled(document, model);
            Position pos= new Position(offsets[0] + start, length);
            document.addPosition(getCategory(), pos);
            proposals[j]= new PositionBasedCompletionProposal(values[j], pos, length);
          }

          if (proposals.length > 1)
            first= new ProposalPosition(document, offsets[0] + start, length, proposals);
          else
            first= new LinkedPosition(document, offsets[0] + start, length);
        }

        for (int j= 0; j != offsets.length; j++)
          if (j == 0)
            group.addPosition(first);
          else
            group.addPosition(new LinkedPosition(document, offsets[j] + start, length));

        model.addGroup(group);
        hasPositions= true;
      }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.link.LinkedPositionGroup

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.