### Eclipse Workspace Patch 1.0 #P org.eclipse.compare Index: compare/org/eclipse/compare/internal/CompareEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java,v retrieving revision 1.31 diff -u -r1.31 CompareEditor.java --- compare/org/eclipse/compare/internal/CompareEditor.java 28 Mar 2006 14:50:59 -0000 1.31 +++ compare/org/eclipse/compare/internal/CompareEditor.java 29 Mar 2006 22:53:44 -0000 @@ -36,7 +36,7 @@ * A CompareEditor takes a ICompareEditorInput as input. * Most functionality is delegated to the ICompareEditorInput. */ -public class CompareEditor extends EditorPart implements IReusableEditor, ISaveableModelSource, ISaveableModel { +public class CompareEditor extends EditorPart implements IReusableEditor, ISaveablesSource { /** * Internal property change listener for handling changes in the editor's input. @@ -59,6 +59,8 @@ private Control fControl; /** the outline page */ private CompareOutlinePage fOutlinePage; + + private CompareSaveable fSaveable; /** enable outline */ @@ -258,11 +260,11 @@ */ public boolean isDirty() { IEditorInput input= getEditorInput(); - if (input instanceof ISaveableModelSource) { - ISaveableModelSource sms = (ISaveableModelSource) input; - ISaveableModel[] models = sms.getModels(); + if (input instanceof ISaveablesSource) { + ISaveablesSource sms = (ISaveablesSource) input; + Saveable[] models = sms.getSaveables(); for (int i = 0; i < models.length; i++) { - ISaveableModel model = models[i]; + Saveable model = models[i]; if (model.isDirty()) return true; } @@ -280,48 +282,65 @@ } /* (non-Javadoc) - * @see org.eclipse.ui.ISaveableModelSource#getModels() + * @see org.eclipse.ui.ISaveablesSource#getModels() */ - public ISaveableModel[] getModels() { + public Saveable[] getSaveables() { IEditorInput input= getEditorInput(); - if (input instanceof ISaveableModelSource) { - ISaveableModelSource source = (ISaveableModelSource) input; - return source.getModels(); + if (input instanceof ISaveablesSource) { + ISaveablesSource source = (ISaveablesSource) input; + return source.getSaveables(); } - return new ISaveableModel[] { this }; + return new Saveable[] { getSaveable() }; } - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveableModelSource#getActiveModels() - */ - public ISaveableModel[] getActiveModels() { - IEditorInput input= getEditorInput(); - if (input instanceof ISaveableModelSource) { - ISaveableModelSource source = (ISaveableModelSource) input; - return source.getActiveModels(); + private Saveable getSaveable() { + if (fSaveable == null) { + fSaveable = new CompareSaveable(); } - return new ISaveableModel[] { this }; + return fSaveable; } /* (non-Javadoc) - * @see org.eclipse.ui.ISaveableModel#getName() + * @see org.eclipse.ui.ISaveablesSource#getActiveModels() */ - public String getName() { - return getPartName(); + public Saveable[] getActiveSaveables() { + IEditorInput input= getEditorInput(); + if (input instanceof ISaveablesSource) { + ISaveablesSource source = (ISaveablesSource) input; + return source.getActiveSaveables(); + } + return new Saveable[] { getSaveable() }; } + + private class CompareSaveable extends Saveable { - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveableModel#getToolTipText() - */ - public String getToolTipText() { - return getTitleToolTip(); - } + public String getName() { + return CompareEditor.this.getPartName(); + } - /* (non-Javadoc) - * @see org.eclipse.ui.ISaveableModel#getImageDescriptor() - */ - public ImageDescriptor getImageDescriptor() { - return ImageDescriptor.createFromImage(getTitleImage()); + public String getToolTipText() { + return CompareEditor.this.getTitleToolTip(); + } + + public ImageDescriptor getImageDescriptor() { + return ImageDescriptor.createFromImage(CompareEditor.this.getTitleImage()); + } + + public void doSave(IProgressMonitor monitor) throws CoreException { + CompareEditor.this.doSave(monitor); + } + + public boolean isDirty() { + return CompareEditor.this.isDirty(); + } + + public boolean equals(Object object) { + return object == this; + } + + public int hashCode() { + return CompareEditor.this.hashCode(); + } } } Index: compare/org/eclipse/compare/CompareEditorInput.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java,v retrieving revision 1.58 diff -u -r1.58 CompareEditorInput.java --- compare/org/eclipse/compare/CompareEditorInput.java 28 Mar 2006 14:50:59 -0000 1.58 +++ compare/org/eclipse/compare/CompareEditorInput.java 29 Mar 2006 22:53:44 -0000 @@ -88,7 +88,7 @@ * If a subclass cannot use the DiffTreeViewer which is installed by default in the * top left pane, method createDiffViewer can be overridden. *

- * If subclasses of this class implement {@link ISaveableModelSource}, the compare editor will + * If subclasses of this class implement {@link ISaveablesSource}, the compare editor will * pass these models through to the workbench. The editor will still show the dirty indicator * if one of these underlying models is dirty. It is the reponsibility of subclasses that * implement this interface to call {@link #setDirty(boolean)} when the dirty state of