Esempio n. 1
0
  @Override
  public void selectionChanged(SelectionChangedEvent event) {

    super.selectionChanged(event);
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    Object element = selection.getFirstElement();
    if (element == null) return;
    if (element instanceof ISourceProvider) {
      ISourceProvider prov = (ISourceProvider) element;
      element = prov.getSource();
    }
    if (element instanceof ISource) {
      ISource source = (ISource) element;
      m_editor
          .getSelectionProvider()
          .setSelection(
              new TextSelection(
                  source.getPosition().getOffset(), source.getPosition().getLength()));
    }
    return;
  }
Esempio n. 2
0
  /**
   * Focuses the editor to the text of the selected item.
   *
   * @param event the selection event
   */
  @Override
  public void selectionChanged(SelectionChangedEvent event) {
    super.selectionChanged(event);
    ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
      editor.resetHighlightRange();
    } else {
      OutlineNode node = (OutlineNode) ((IStructuredSelection) selection).getFirstElement();
      IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());

      Position position = computePosition(node.getAst(), doc);
      if (position != null) {
        try {
          editor.setHighlightRange(position.getOffset(), position.getLength(), true);
          editor.getViewer().revealRange(position.getOffset(), position.getLength());
        } catch (IllegalArgumentException x) {
          editor.resetHighlightRange();
        }
      } else {
        editor.resetHighlightRange();
      }
    }
  }
Esempio n. 3
0
  @Override
  public void selectionChanged(final SelectionChangedEvent event) {
    super.selectionChanged(event);

    ISelection selection = event.getSelection();
    if (selection.isEmpty()) {
      editor.resetHighlightRange();
    } else {
      IStructuredSelection sel = (IStructuredSelection) selection;
      Object firstElement = sel.getFirstElement();
      /*if( firstElement instanceof IHaskellLanguageElement ) {
        IHaskellLanguageElement elem = ( IHaskellLanguageElement )firstElement;
        IEditorInput fei = editor.getEditorInput();
        IDocument doc = editor.getDocumentProvider().getDocument( fei );
        ISourceLocation srcLoc = elem.getSourceLocation();
        if( srcLoc != null ) {
          int offset = -1;
          try {
            offset = doc.getLineOffset( srcLoc.getLine() ) + srcLoc.getColumn();
          } catch( final BadLocationException badlox ) {
            // ignore
          }
          int length = elem.getName().length();
          try {
            editor.setHighlightRange( offset, length, true );
          } catch( IllegalArgumentException iaex ) {
            editor.resetHighlightRange();
          }
        }
      }*/
      if (firstElement instanceof OutlineDef) {
        OutlineDef od = (OutlineDef) firstElement;
        reveal(editor, od);
      }
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.views.contentoutline.ContentOutlinePage#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
  */
 public void selectionChanged(SelectionChangedEvent event) {
   if (!fIsReceivingSelection) super.selectionChanged(event);
 }