示例#1
0
  private void initializeToolbars(Composite parent) {
    ToolBarManager tbm = CompareViewerPane.getToolBarManager(parent);
    if (tbm != null) {
      tbm.removeAll();

      // define groups
      tbm.add(new Separator("modes")); // $NON-NLS-1$
      tbm.add(new Separator("merge")); // $NON-NLS-1$
      tbm.add(new Separator("navigation")); // $NON-NLS-1$

      CompareConfiguration cc = getCompareConfiguration();

      if (cc.isRightEditable()) {
        fCopyLeftToRightAction =
            new Action() {
              public void run() {
                copy(true);
              }
            };
        Utilities.initAction(
            fCopyLeftToRightAction, getResourceBundle(), "action.CopyLeftToRight."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyLeftToRightAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyLeftToRightAction, "org.eclipse.compare.copyAllLeftToRight"); // $NON-NLS-1$
      }

      if (cc.isLeftEditable()) {
        fCopyRightToLeftAction =
            new Action() {
              public void run() {
                copy(false);
              }
            };
        Utilities.initAction(
            fCopyRightToLeftAction, getResourceBundle(), "action.CopyRightToLeft."); // $NON-NLS-1$
        tbm.appendToGroup("merge", fCopyRightToLeftAction); // $NON-NLS-1$
        fHandlerService.registerAction(
            fCopyRightToLeftAction, "org.eclipse.compare.copyAllRightToLeft"); // $NON-NLS-1$
      }

      final ChangePropertyAction a =
          new ChangePropertyAction(
              fBundle,
              getCompareConfiguration(),
              "action.EnableAncestor.",
              ICompareUIConstants.PROP_ANCESTOR_VISIBLE); // $NON-NLS-1$
      a.setChecked(fAncestorVisible);
      fAncestorItem = new ActionContributionItem(a);
      fAncestorItem.setVisible(false);
      tbm.appendToGroup("modes", fAncestorItem); // $NON-NLS-1$
      tbm.getControl().addDisposeListener(a);

      createToolItems(tbm);
      updateToolItems();

      tbm.update(true);
    }
  }
示例#2
0
  /**
   * Called on the viewer disposal. Unregisters from the compare configuration. Clients may extend
   * if they have to do additional cleanup.
   *
   * @see org.eclipse.jface.viewers.ContentViewer#handleDispose(org.eclipse.swt.events.DisposeEvent)
   */
  protected void handleDispose(DisposeEvent event) {

    if (fHandlerService != null) fHandlerService.dispose();

    Object input = getInput();
    if (input instanceof ICompareInput) {
      ICompareContainer container = getCompareConfiguration().getContainer();
      container.removeCompareInputChangeListener(
          (ICompareInput) input, fCompareInputChangeListener);
    }
    if (input != null) {
      ICompareInputLabelProvider lp = getCompareConfiguration().getLabelProvider();
      if (lp != null) lp.removeListener(labelChangeListener);
    }

    if (fPropertyChangeListener != null) {
      fCompareConfiguration.removePropertyChangeListener(fPropertyChangeListener);
      fPropertyChangeListener = null;
    }

    fAncestorLabel = null;
    fLeftLabel = null;
    fDirectionLabel = null;
    fRightLabel = null;
    fCenter = null;

    if (fRightArrow != null) {
      fRightArrow.dispose();
      fRightArrow = null;
    }
    if (fLeftArrow != null) {
      fLeftArrow.dispose();
      fLeftArrow = null;
    }
    if (fBothArrow != null) {
      fBothArrow.dispose();
      fBothArrow = null;
    }

    if (fNormalCursor != null) {
      fNormalCursor.dispose();
      fNormalCursor = null;
    }
    if (fHSashCursor != null) {
      fHSashCursor.dispose();
      fHSashCursor = null;
    }
    if (fVSashCursor != null) {
      fVSashCursor.dispose();
      fVSashCursor = null;
    }
    if (fHVSashCursor != null) {
      fHVSashCursor.dispose();
      fHVSashCursor = null;
    }

    super.handleDispose(event);
  }
示例#3
0
  /**
   * Builds the SWT controls for the three areas of a compare/merge viewer.
   *
   * <p>Calls the hooks <code>createControls</code> and <code>createToolItems</code> to let
   * subclasses build the specific content areas and to add items to an enclosing toolbar.
   *
   * <p>This method must only be called in the constructor of subclasses.
   *
   * @param parent the parent control
   * @return the new control
   */
  protected final Control buildControl(Composite parent) {

    fComposite =
        new Composite(parent, fStyles | SWT.LEFT_TO_RIGHT) { // we
          // force
          // a
          // specific
          // direction
          public boolean setFocus() {
            return ContentMergeViewer.this.handleSetFocus();
          }
        };
    fComposite.setData(CompareUI.COMPARE_VIEWER_TITLE, getTitle());

    hookControl(fComposite); // hook help & dispose listener

    fComposite.setLayout(new ContentMergeViewerLayout());

    int style = SWT.SHADOW_OUT;
    fAncestorLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());

    fLeftLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fLeftLabel, VERTICAL);

    fDirectionLabel = new CLabel(fComposite, style);
    fDirectionLabel.setAlignment(SWT.CENTER);
    new Resizer(fDirectionLabel, HORIZONTAL | VERTICAL);

    fRightLabel = new CLabel(fComposite, style | Window.getDefaultOrientation());
    new Resizer(fRightLabel, VERTICAL);

    if (fCenter == null || fCenter.isDisposed()) fCenter = createCenterControl(fComposite);

    createControls(fComposite);

    fHandlerService =
        CompareHandlerService.createFor(
            getCompareConfiguration().getContainer(), fComposite.getShell());

    initializeToolbars(parent);

    return fComposite;
  }