Beispiel #1
0
 private void setupFonts(
     Composite parent, final TreeTableComposite tree, final MergeTotalComposite total) {
   final IPropertyChangeListener preferenceListener =
       new IPropertyChangeListener() {
         @Override
         public void propertyChange(PropertyChangeEvent event) {
           if (event.getProperty().equals(MergeEditorPreferencePage.P_MERGE_EDITOR_FONT_SIZE)) {
             Font font = getMergeTreeFont();
             tree.getTree().setFont(font);
             total.getTable().setFont(font);
             editorComposite.layout(true);
             IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
             if (labelProvider instanceof MergeTreeLabelProvider) {
               ((MergeTreeLabelProvider) labelProvider).updateFonts();
             }
             treeViewer.refresh(true);
           }
         }
       };
   parent.addDisposeListener(
       new DisposeListener() {
         @Override
         public void widgetDisposed(DisposeEvent e) {
           MergePlugin.getDefault()
               .getPreferenceStore()
               .removePropertyChangeListener(preferenceListener);
         }
       });
   MergePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(preferenceListener);
   Font font = getMergeTreeFont();
   tree.getTree().setFont(font);
   total.getTable().setFont(font);
   total.layout(true);
 }
Beispiel #2
0
  /** This only works on linux */
  private void syncTreeTableScrollBars() {
    final ScrollBar treeBar = treeComposite.getTree().getHorizontalBar();
    final ScrollBar totalBar = totalComposite.getTable().getHorizontalBar();
    treeBar.setVisible(false);
    treeBar.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            scrollTable();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            scrollTable();
          }

          private void scrollTable() {
            int selection = treeBar.getSelection();
            totalBar.setSelection(selection);
          }
        });
    totalBar.addSelectionListener(
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            scrollTree();
          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            scrollTree();
          }

          private void scrollTree() {
            int selection = totalBar.getSelection();
            treeBar.setSelection(selection);
          }
        });
  }