Пример #1
0
 @Override
 public boolean select(Viewer viewer, Object parentElement, Object element) {
   if (element instanceof ILanguageElement) {
     CompilationUnit compilationUnit = ((ILanguageElement) element).getCompilationUnit();
     return compilationUnit == m_compilationUnit;
   }
   if (element instanceof ISource) {
     ISource src = (ISource) element;
     if (src.getCompilationUnit() != m_compilationUnit) return false;
   }
   return true;
 }
Пример #2
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;
  }
Пример #3
0
 protected void handleOpen(OpenEvent event) {
   if (event.getSelection() instanceof IStructuredSelection) {
     IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
     Object element = structuredSelection.getFirstElement();
     if (element instanceof MemberNestedType || element instanceof DeclaratorNestedType) {
       (new OpenSourceAction((ISource) element)).run();
     } else if (element instanceof IType) {
       IType type = (IType) element;
       (new OpenCompilationUnitAction(type.getCompilationUnit())).run();
     }
   }
 }