コード例 #1
0
  /**
   * This accesses a cached version of the content outliner.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IContentOutlinePage getContentOutlinePage() {
    if (contentOutlinePage == null) {
      // The content outline is just a tree.
      //
      class MyContentOutlinePage extends ContentOutlinePage {
        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.
            //
            ArrayList selection = new ArrayList();
            selection.add(editingDomain.getResourceSet().getResources().get(0));
            contentOutlineViewer.setSelection(new StructuredSelection(selection), true);
          }
        }

        public void makeContributions(
            IMenuManager menuManager,
            IToolBarManager toolBarManager,
            IStatusLineManager statusLineManager) {
          super.makeContributions(menuManager, toolBarManager, statusLineManager);
          contentOutlineStatusLineManager = statusLineManager;
        }

        public void setActionBars(IActionBars actionBars) {
          super.setActionBars(actionBars);
          getActionBarContributor().shareGlobalActions(this, actionBars);
        }
      }

      contentOutlinePage = new MyContentOutlinePage();

      // Listen to selection so that we can handle it is a special way.
      //
      contentOutlinePage.addSelectionChangedListener(
          new ISelectionChangedListener() {
            // This ensures that we handle selections correctly.
            //
            public void selectionChanged(SelectionChangedEvent event) {
              handleContentOutlineSelection(event.getSelection());
            }
          });
    }

    return contentOutlinePage;
  }
コード例 #2
0
  /** @param page */
  public void setPageActive(IContentOutlinePage page) {

    synchronized (fEditor) // don't want to call this while a reconciling
    // action
    // is occuring!
    {
      Control control = fCurrentPage.getControl();
      if ((control != null && !control.isDisposed()) && page == fCurrentPage) return;

      if (page == fMessagePage && fCurrentPage != fTapestryOutlinePage) page = fCurrentPage;

      if (page == fTapestryOutlinePage && fReconciledObject == null) page = fMessagePage;

      if (fCurrentPage != null) {
        fCurrentPage.removeSelectionChangedListener(this);
      }
      page.addSelectionChangedListener(this);
      this.fCurrentPage = page;
      if (fPageBook == null) {
        // still not being made
        return;
      }
      control = page.getControl();
      if (control == null || control.isDisposed()) {
        // first time
        page.createControl(fPageBook);
        control = page.getControl();
      }
      fPageBook.showPage(control);
      this.fCurrentPage = page;
    }
    updateToolbar();
  }