コード例 #1
0
 /**
  * Sets the dirty state of the right side of this viewer. If the new value differs from the old
  * all registered listener are notified with a <code>PropertyChangeEvent</code> with the property
  * name <code>CompareEditorInput.DIRTY_STATE</code>.
  *
  * @param dirty the state of the right side dirty flag
  */
 protected void setRightDirty(boolean dirty) {
   if (isRightDirty() != dirty) {
     fRightSaveAction.setEnabled(dirty);
     // Only fire the event if the combined dirty state has changed
     if ((!isRightDirty() && !isLeftDirty()) || (isRightDirty() && !isLeftDirty()))
       fireDirtyState(dirty);
   }
 }
コード例 #2
0
  /**
   * Creates a new content merge viewer and initializes with a resource bundle and a configuration.
   *
   * @param style SWT style bits
   * @param bundle the resource bundle
   * @param cc the configuration object
   */
  protected ContentMergeViewer(int style, ResourceBundle bundle, CompareConfiguration cc) {

    fStyles = style & ~(SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); // remove
    // BIDI
    // direction
    // bits
    fBundle = bundle;

    fAncestorVisible =
        Utilities.getBoolean(cc, ICompareUIConstants.PROP_ANCESTOR_VISIBLE, fAncestorVisible);
    fConfirmSave = Utilities.getBoolean(cc, CompareEditor.CONFIRM_SAVE_PROPERTY, fConfirmSave);

    setContentProvider(new MergeViewerContentProvider(cc));

    fCompareInputChangeListener =
        new ICompareInputChangeListener() {
          public void compareInputChanged(ICompareInput input) {
            if (input == getInput()) {
              handleCompareInputChange();
            }
          }
        };

    // Make sure the compare configuration is not null
    if (cc == null) fCompareConfiguration = new CompareConfiguration();
    else fCompareConfiguration = cc;
    fPropertyChangeListener =
        new IPropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent event) {
            ContentMergeViewer.this.handlePropertyChangeEvent(event);
          }
        };
    fCompareConfiguration.addPropertyChangeListener(fPropertyChangeListener);

    fLeftSaveAction = new SaveAction(true);
    fLeftSaveAction.setEnabled(false);
    fRightSaveAction = new SaveAction(false);
    fRightSaveAction.setEnabled(false);

    // this is used to update the dirty status,if we use
    // org.eclipse.php.internal.ui.compare.ContentMergeViewer,we will get a
    // ClassCastException
    cmv =
        new org.eclipse.compare.contentmergeviewer.ContentMergeViewer(
            fStyles, fBundle, fCompareConfiguration) {

          @Override
          protected void createControls(Composite composite) {}

          @Override
          protected void handleResizeAncestor(int x, int y, int width, int height) {}

          @Override
          protected void handleResizeLeftRight(
              int x, int y, int leftWidth, int centerWidth, int rightWidth, int height) {}

          @Override
          protected void updateContent(Object ancestor, Object left, Object right) {}

          @Override
          protected void copy(boolean leftToRight) {}

          @Override
          protected byte[] getContents(boolean left) {
            return null;
          }

          @Override
          public boolean internalIsLeftDirty() {
            return ContentMergeViewer.this.isLeftDirty();
          }

          @Override
          public boolean internalIsRightDirty() {
            return ContentMergeViewer.this.isRightDirty();
          }
        };
  }