Examples of TextSelection


Examples of org.eclipse.jface.text.TextSelection

    public SPath getPath() {
        return this.path;
    }

    public ITextSelection getSelection() {
        return new TextSelection(this.offset, this.length);
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

   * @see org.eclipse.wst.sse.core.undo.IDocumentSelectionMediator#undoOperationSelectionChanged(org.eclipse.wst.sse.core.undo.UndoDocumentEvent)
   */
  public void undoOperationSelectionChanged(UndoDocumentEvent event) {
    if (event.getRequester() != null && event.getRequester().equals(this) && event.getDocument().equals(getDocument())) {
      // BUG107687: Undo/redo do not scroll editor
      ITextSelection selection = new TextSelection(event.getOffset(), event.getLength());
      setSelection(selection, true);
    }
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        return false;
      }
    }
    if (textEditor != null && textSelection != null) {
      ISelectionProvider sp = textEditor.getSelectionProvider();
      ITextSelection sel = new TextSelection(textSelection.getOffset(), text.length());
      sp.setSelection(sel);
      textEditor.selectAndReveal(sel.getOffset(), sel.getLength());
    }

    return true;
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        //set the selection in the open editor
        IEditorPart editor = activePage.getActiveEditor();
        if (activate)
          editor.getSite().getPage().activate(editor);
        editor.getEditorSite().getSelectionProvider().setSelection(
          new TextSelection(currentOffset, currentLength));
      }
    } catch (PartInitException e) {
      // possible exception trying to open editor
      Logger.logException(e);
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

    ISelection originalSelection = selectionProvider.getSelection();
    if (selectionProvider instanceof StructuredSelectionProvider && originalSelection instanceof ITextSelection) {
      ITextSelection textSelection = (ITextSelection) originalSelection;
      // make sure the old selection is actually still valid
      if (!textSelection.isEmpty() && (document == null || textSelection.getOffset() + textSelection.getLength() <= document.getLength())) {
        SelectionChangedEvent syntheticEvent = new SelectionChangedEvent(selectionProvider, new TextSelection(textSelection.getOffset(), textSelection.getLength()));
        ((StructuredSelectionProvider) selectionProvider).handleSelectionChanged(syntheticEvent);
        ((StructuredSelectionProvider) selectionProvider).handlePostSelectionChanged(syntheticEvent);
      }
      else {
        SelectionChangedEvent syntheticEvent = new SelectionChangedEvent(selectionProvider, new TextSelection(0, 0));
        ((StructuredSelectionProvider) selectionProvider).handleSelectionChanged(syntheticEvent);
        ((StructuredSelectionProvider) selectionProvider).handlePostSelectionChanged(syntheticEvent);
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

   * @see org.eclipse.wst.sse.core.undo.IDocumentSelectionMediator#undoOperationSelectionChanged(org.eclipse.wst.sse.core.undo.UndoDocumentEvent)
   */
  public void undoOperationSelectionChanged(UndoDocumentEvent event) {
    if (event.getRequester() != null && event.getRequester().equals(this) && event.getDocument().equals(getDocument())) {
      // BUG107687: Undo/redo do not scroll editor
      ITextSelection selection = new TextSelection(event.getOffset(), event.getLength());
      setSelection(selection, true);
    }
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        if (descriptor != null) {
          IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
          IEditorPart openedEditor = IDE.openEditor(page, input, descriptor.getId(), true);
          IRegion definitionRegion = findDefinitionRegion(new URLStorage(fURL));
          if (definitionRegion != null) {
            openedEditor.getSite().getSelectionProvider().setSelection(new TextSelection(definitionRegion.getOffset(), definitionRegion.getLength()));
          }
        }
      }
      catch (PartInitException e) {
        Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        ((IPostSelectionProvider) textSelectionProvider)
            .addPostSelectionChangedListener(new ISelectionChangedListener() {
              public void selectionChanged(
                  SelectionChangedEvent event) {
                if (event.getSelection() instanceof TextSelection) {
                  TextSelection textSelection = ((TextSelection) event
                      .getSelection());
                  _designViewer
                      .getSynchronizer()
                      .textSelectionChanged(
                          textSelection.getOffset(),
                          textSelection.getOffset()
                              + textSelection
                                  .getLength());
                }
              }
            });
      } else {
        textSelectionProvider
            .addSelectionChangedListener(new ISelectionChangedListener() {
              public void selectionChanged(
                  SelectionChangedEvent event) {
                TextSelection textSelection = ((TextSelection) event
                    .getSelection());
                _designViewer.getSynchronizer()
                    .textSelectionChanged(
                        textSelection.getOffset(),
                        textSelection.getOffset()
                            + textSelection
                                .getLength());
              }
            });
      }
    }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

    if (_textEditor != null && _designViewer != null) {
      ISelectionProvider provider = _textEditor.getSelectionProvider();
      if (provider != null) {
        ISelection selection = provider.getSelection();
        if (selection instanceof TextSelection) {
          TextSelection textSelection = (TextSelection)selection;
          SelectionSynchronizer synchronizer = _designViewer.getSynchronizer();
          if (synchronizer != null) {
            synchronizer.textSelectionChanged(
                textSelection.getOffset(),
                textSelection.getOffset() + textSelection.getLength());
          }
        }
      }
    }
  }
View Full Code Here

Examples of org.eclipse.jface.text.TextSelection

        if (newNode instanceof IndexedRegion) {
          IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
          newRegion = new Region(newIndexedRegion.getStartOffset(), textSelection.getOffset() + textSelection.getLength() - newIndexedRegion.getStartOffset());
 
          if (newNode.getNodeType() == Node.TEXT_NODE) {
            newRegion = getNewSelectionRegion2(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength()));
          }
        }
      }
    }
    return newRegion;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.