public void dispose() {
    getSite()
        .getWorkbenchWindow()
        .getSelectionService()
        .removePostSelectionListener(getSelectionServiceListener());
    if (fDoubleClickProvider != null) {
      getTreeViewer().removeDoubleClickListener(fDoubleClickProvider);
    }

    // dispose menu controls
    if (fContextMenu != null) {
      fContextMenu.dispose();
    }
    if (fContextMenuManager != null) {
      fContextMenuManager.removeMenuListener(fGroupAdder);
      fContextMenuManager.removeAll();
      fContextMenuManager.dispose();
    }

    fDropTarget.dispose();
    fDragSource.dispose();

    IStatusLineManager statusLineManager = getSite().getActionBars().getStatusLineManager();
    if (statusLineManager != null) {
      statusLineManager.setMessage(null);
    }
    unconfigure();
    super.dispose();
  }
  @Override
  public void createControl(Composite parent) {
    super.createControl(parent);
    viewer = getTreeViewer();
    contentProvider = new TreeNodeContentProvider();
    viewer.setContentProvider(contentProvider);
    labelProvider = new TextUMLLabelProvider();
    viewer.setLabelProvider(labelProvider);
    viewer.setComparator(new UIModelObjectViewerComparator());
    viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

    // tracks selections in the outline and reflects them in the editor
    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            TreeSelection selection = (TreeSelection) event.getSelection();
            if (!selection.isEmpty()) {
              TreeNode treeNode = (TreeNode) selection.getFirstElement();
              UIModelObject model = (UIModelObject) treeNode.getValue();
              selectInEditor(model.getToken());
            }
          }
        });

    refresh();
  }
 @Override
 public void dispose() {
   if (labelProvider != null) {
     labelProvider.dispose();
   }
   super.dispose();
 }
Esempio n. 4
0
 public void makeContributions(
     IMenuManager menuManager,
     IToolBarManager toolBarManager,
     IStatusLineManager statusLineManager) {
   super.makeContributions(menuManager, toolBarManager, statusLineManager);
   contentOutlineStatusLineManager = statusLineManager;
 }
Esempio n. 5
0
        @Override
        public void createControl(Composite parent) {
          super.createControl(parent);
          contentOutlineViewer = getTreeViewer();
          contentOutlineViewer.addSelectionChangedListener(this);

          // Set up the tree viewer.
          //
          contentOutlineViewer.setContentProvider(
              new AdapterFactoryContentProvider(adapterFactory));
          contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
          contentOutlineViewer.setInput(editingDomain.getResourceSet());

          // Make sure our popups work.
          //
          createContextMenuFor(contentOutlineViewer);

          if (!editingDomain.getResourceSet().getResources().isEmpty()) {
            // Select the root object in the view.
            //
            contentOutlineViewer.setSelection(
                new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)),
                true);
          }
        }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite
  * )
  */
 public void init(IPageSite pageSite) {
   super.init(pageSite);
   pageSite
       .getWorkbenchWindow()
       .getSelectionService()
       .addPostSelectionListener(getSelectionServiceListener());
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars)
   */
  public void setActionBars(IActionBars actionBars) {
    super.setActionBars(actionBars);
    IToolBarManager toolBarManager = actionBars.getToolBarManager();

    LexicalSortingAction action = new LexicalSortingAction(getTreeViewer());
    toolBarManager.add(action);
  }
  /** @see ContentOutlinePage#createControl */
  public void createControl(Composite parent) {
    super.createControl(parent);
    ColumnViewerToolTipSupport.enableFor(getTreeViewer());

    IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
    if (page != null) {
      fEditor = page.getActiveEditor();
    }

    fDragAdapter = new DelegatingDragAdapter();
    fDragSource = new DragSource(getControl(), DND.DROP_COPY | DND.DROP_MOVE);
    fDropAdapter = new DelegatingDropAdapter();
    fDropTarget = new DropTarget(getControl(), DND.DROP_COPY | DND.DROP_MOVE);

    setConfiguration(getConfiguration());

    /*
     * ContentOutlinePage only implements ISelectionProvider while the
     * tree viewer implements both ISelectionProvider and
     * IPostSelectionProvider. Use an ISelectionProvider that listens to
     * post selection from the tree viewer and forward only post selection
     * to the selection service.
     */
    getTreeViewer()
        .addPostSelectionChangedListener(fSelectionProvider.getPostSelectionChangedListener());
    getTreeViewer().addSelectionChangedListener(fSelectionProvider.getSelectionChangedListener());
    if (fDoubleClickProvider == null) {
      fDoubleClickProvider = new DoubleClickProvider();
    }
    getTreeViewer().addDoubleClickListener(fDoubleClickProvider);
    getSite().setSelectionProvider(fSelectionProvider);
  }
 @Override
 public void dispose() {
   contentProvider.dispose();
   contentProvider = null;
   labelProvider.dispose();
   labelProvider = null;
   editor = null;
   super.dispose();
 }
Esempio n. 10
0
  @Override
  public void dispose() {
    super.dispose();
    Workspace.getInstance().uninstallResourceListener(m_listener);

    if (fMenu != null && !fMenu.isDisposed()) {
      fMenu.dispose();
      fMenu = null;
    }
  }
Esempio n. 11
0
  @Override
  public void createControl(final Composite parent) {
    super.createControl(parent);

    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new OutlineCP());
    viewer.setLabelProvider(new OutlineLabelProvider());
    viewer.addSelectionChangedListener(this);

    IActionBars actionBars = getSite().getActionBars();
    registerToolbarActions(actionBars);

    if (input != null) {
      viewer.setInput(input);
    }
  }
  /* (non-Javadoc)
   * Method declared on ContentOutlinePage
   */
  @Override
  public void createControl(Composite parent) {

    super.createControl(parent);

    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(fContentProvider);
    DelegatingStyledCellLabelProvider delegatingStyledCellLabelProvider =
        new DelegatingStyledCellLabelProvider(new JsonLabelProvider());
    viewer.setLabelProvider(delegatingStyledCellLabelProvider);
    getSite().getPage().addPostSelectionListener(this);

    if (fInput != null) {
      viewer.setInput(fInput);
      fContentProvider.setInput(fInput);
    }
  }
Esempio n. 13
0
  /**
   * Creates the control ie. creates all the stuff that matters and is visible in the outline.
   *
   * <p>Actions must be created before menus and toolbars.
   *
   * @param parent
   */
  @Override
  public void createControl(Composite parent) {
    super.createControl(parent);
    NddlContentProvider provider = editor.getNddlContentProvider();

    // initialize the tree viewers
    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(provider);
    viewer.addFilter(new FileViewerFilter());
    viewer.setLabelProvider(new NddlLabelProvider());

    // set the selection listener
    viewer.addSelectionChangedListener(this);

    // finally set the input
    if (this.input != null) viewer.setInput(this.input);
    else provider.reload(editor.getFile());
  }
Esempio n. 14
0
  @Override
  public void createControl(Composite parent) {
    super.createControl(parent);

    Workspace.getInstance().installResourceListener(m_listener);

    TreeViewer treeViewer = getTreeViewer();
    treeViewer.setContentProvider(new NavigatorTreeContentProvider());
    treeViewer.setLabelProvider(new Z8LabelProvider(false));
    treeViewer.addSelectionChangedListener(this);

    treeViewer.setSorter(
        new ViewerSorter() {
          @Override
          public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 == e2) return 0;

            ISource s1, s2;

            if (e1 instanceof ISource) {
              s1 = (ISource) e1;
            } else {
              return -1;
            }

            if (e2 instanceof ISource) {
              s2 = (ISource) e2;
            } else {
              return 1;
            }

            return s1.getPosition().getOffset() > s2.getPosition().getOffset() ? 1 : -1;
          }
        });

    treeViewer.addFilter(FILTER);

    if (m_compilationUnit != null) {
      treeViewer.setInput(m_compilationUnit);
    }
  }
Esempio n. 15
0
  @Override
  public void createControl(final Composite parent) {
    super.createControl(parent);
    TreeViewer tv = getTreeViewer();
    tv.setLabelProvider(new CabalOutlineLP());
    tv.setContentProvider(new CabalOutlinePageCP());
    tv.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
    tv.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(final SelectionChangedEvent event) {
            if (event.getSelection() instanceof IStructuredSelection) {
              IStructuredSelection ssel = (IStructuredSelection) event.getSelection();
              if (ssel.size() == 1) {
                editor.selectAndReveal(ssel.getFirstElement());
              }
            }
          }
        });

    tv.setInput(packageDescription);
  }
Esempio n. 16
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;
  }
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    super.createControl(parent);
    TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new MakefileContentProvider());
    viewer.setLabelProvider(new MakefileLabelProvider());
    if (fInput != null) {
      viewer.setInput(fInput);
    }

    MenuManager manager = new MenuManager("#MakefileOutlinerContext"); // $NON-NLS-1$
    manager.setRemoveAllWhenShown(true);
    manager.addMenuListener(
        new IMenuListener() {
          public void menuAboutToShow(IMenuManager m) {
            contextMenuAboutToShow(m);
          }
        });
    Control tree = viewer.getControl();
    Menu menu = manager.createContextMenu(tree);
    tree.setMenu(menu);

    viewer.addDoubleClickListener(
        new IDoubleClickListener() {
          /* (non-Javadoc)
           * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
           */
          public void doubleClick(DoubleClickEvent event) {
            if (fOpenIncludeAction != null) {
              fOpenIncludeAction.run();
            }
          }
        });

    IPageSite site = getSite();
    // FIXME: should pluginid below be MakeUIPlugin id?
    site.registerContextMenu(
        AutotoolsUIPlugin.getPluginId() + ".outline", manager, viewer); // $NON-NLS-1$
    site.setSelectionProvider(viewer);
  }
Esempio n. 18
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. 19
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);
      }
    }
  }
  /** Remove the listener associated with the outline. */
  @Override
  public void dispose() {

    getSite().getPage().removeSelectionListener(this);
    super.dispose();
  }
Esempio n. 21
0
 @Override
 public void setActionBars(IActionBars actionBars) {
   super.setActionBars(actionBars);
   getActionBarContributor().shareGlobalActions(this, actionBars);
 }
 /*
  * (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);
 }
 @Override
 public void createControl(Composite parent) {
   super.createControl(parent);
 }