Пример #1
0
 @Override
 public void dispose() {
   if (treeViewer != null) {
     EnsembleSelectionProvider selectionProvider =
         (EnsembleSelectionProvider) getSelectionProvider();
     if (selectionProvider != null) {
       selectionProvider.detachSelectionProvider(treeViewer);
     }
     treeViewer = null;
   }
   /*
   if (mergeTreeFont != null) {
   	mergeTreeFont.dispose();
   }*/
   if (treeComposite != null) {
     treeComposite.dispose();
   }
   if (editorComposite != null) {
     editorComposite.dispose();
   }
   totalViewer = null;
   super.dispose();
 }
Пример #2
0
  @Override
  public void createPartControl(Composite parent) {
    IEditorInput input = getEditorInput();
    final TreeTableColumnConfiguration configuration =
        TableEditorUtils.getTableConfiguration(getId(), input);
    final PlanEditorModel model = PlanEditorModelRegistry.getPlanEditorModel(input);
    final EPlan plan = model.getEPlan();
    EnsembleSelectionProvider selectionProvider =
        (EnsembleSelectionProvider) getSelectionProvider();

    editorComposite = new EnsembleComposite(parent, SWT.NONE);
    // layout for the editor (arrangement and spacing between tree and table)
    GridLayout layout = new GridLayout(1, true);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    editorComposite.setLayout(layout);

    // setup tree
    treeComposite = buildTree(editorComposite, configuration);
    treeComposite.setData("name", "MergeEditor.treeComposite");
    treeComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    treeViewer = new MergeTreeViewer(treeComposite, configuration, getSite());
    treeViewer.setContentProvider(new MergeTreeContentProvider());
    MergeTreeLabelProvider labelProvider = new MergeTreeLabelProvider();
    labelProvider.setRowHighlightDecorator(rowHighlightDecorator);
    treeViewer.setLabelProvider(labelProvider);
    treeViewer.setInput(plan);
    treeViewer.setEditorModel(model);
    treeViewer.expandToLevel(1);
    treeViewer.setAutoExpandLevel(1);
    selectionProvider.attachSelectionProvider(new TreeTableViewerSelectionListener(treeViewer));

    // setup table
    totalComposite = new MergeTotalComposite(editorComposite, configuration);
    totalComposite.setData("name", "MergeEditor.totalComposite");
    totalComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

    totalViewer = new MergeTotalViewer(totalComposite);
    totalViewer.setInput(treeViewer);

    if (Platform.getOS().equals(Platform.OS_LINUX)) {
      syncTreeTableScrollBars();
    }

    IWorkbenchPage page = getSite().getPage();
    IEditorPart activeEditor = page.getActiveEditor();
    if ((activeEditor != null) && (activeEditor.getEditorInput() == input)) {
      treeViewer.setSelection(page.getSelection());
    }

    // make sure all the row/column sizes are correct given the current font
    setupFonts(editorComposite, treeComposite, totalComposite);

    MenuManager menuManager =
        WidgetUtils.createContextMenu(
            treeComposite.getTree(),
            new IMenuListener() {
              @Override
              public void menuAboutToShow(IMenuManager mgr) {
                fillContextMenu(mgr);
              }
            });
    // allow extensions to the context menu but not those based on the editor input
    getEditorSite().registerContextMenu(menuManager, getSelectionProvider(), false);
  }