View | Details | Raw Unified | Return to bug 126230
Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/CompareEditor.java (-1 / +56 lines)
Lines 17-22 Link Here
17
17
18
import org.eclipse.jface.dialogs.ErrorDialog;
18
import org.eclipse.jface.dialogs.ErrorDialog;
19
import org.eclipse.jface.dialogs.MessageDialog;
19
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.util.*;
21
import org.eclipse.jface.util.*;
21
import org.eclipse.jface.util.Assert;
22
import org.eclipse.jface.util.Assert;
22
23
Lines 35-41 Link Here
35
 * A CompareEditor takes a ICompareEditorInput as input.
36
 * A CompareEditor takes a ICompareEditorInput as input.
36
 * Most functionality is delegated to the ICompareEditorInput.
37
 * Most functionality is delegated to the ICompareEditorInput.
37
 */
38
 */
38
public class CompareEditor extends EditorPart implements IReusableEditor {
39
public class CompareEditor extends EditorPart implements IReusableEditor, ISaveableModelSource, ISaveableModel {
39
	
40
	
40
	/**
41
	/**
41
	 * Internal property change listener for handling changes in the editor's input.
42
	 * Internal property change listener for handling changes in the editor's input.
Lines 257-262 Link Here
257
	 */
258
	 */
258
	public boolean isDirty() {
259
	public boolean isDirty() {
259
		IEditorInput input= getEditorInput();
260
		IEditorInput input= getEditorInput();
261
		if (input instanceof ISaveableModelSource) {
262
			ISaveableModelSource sms = (ISaveableModelSource) input;
263
			ISaveableModel[] models = sms.getModels();
264
			for (int i = 0; i < models.length; i++) {
265
				ISaveableModel model = models[i];
266
				if (model.isDirty())
267
					return true;
268
			}
269
		}
260
		if (input instanceof CompareEditorInput)
270
		if (input instanceof CompareEditorInput)
261
			return ((CompareEditorInput)input).isSaveNeeded();
271
			return ((CompareEditorInput)input).isSaveNeeded();
262
		return false;
272
		return false;
Lines 268-272 Link Here
268
		if (old_value == null || new_value == null || !old_value.equals(new_value))
278
		if (old_value == null || new_value == null || !old_value.equals(new_value))
269
			firePropertyChange(PROP_DIRTY);
279
			firePropertyChange(PROP_DIRTY);
270
	}
280
	}
281
282
	/* (non-Javadoc)
283
	 * @see org.eclipse.ui.ISaveableModelSource#getModels()
284
	 */
285
	public ISaveableModel[] getModels() {
286
		IEditorInput input= getEditorInput();
287
		if (input instanceof ISaveableModelSource) {
288
			ISaveableModelSource source = (ISaveableModelSource) input;
289
			return source.getModels();
290
		}
291
		return new ISaveableModel[] { this };
292
	}
293
294
	/* (non-Javadoc)
295
	 * @see org.eclipse.ui.ISaveableModelSource#getActiveModels()
296
	 */
297
	public ISaveableModel[] getActiveModels() {
298
		IEditorInput input= getEditorInput();
299
		if (input instanceof ISaveableModelSource) {
300
			ISaveableModelSource source = (ISaveableModelSource) input;
301
			return source.getActiveModels();
302
		}
303
		return new ISaveableModel[] { this };
304
	}
305
306
	/* (non-Javadoc)
307
	 * @see org.eclipse.ui.ISaveableModel#getName()
308
	 */
309
	public String getName() {
310
		return getPartName();
311
	}
312
313
	/* (non-Javadoc)
314
	 * @see org.eclipse.ui.ISaveableModel#getToolTipText()
315
	 */
316
	public String getToolTipText() {
317
		return getTitleToolTip();
318
	}
319
320
	/* (non-Javadoc)
321
	 * @see org.eclipse.ui.ISaveableModel#getImageDescriptor()
322
	 */
323
	public ImageDescriptor getImageDescriptor() {
324
		return ImageDescriptor.createFromImage(getTitleImage());
325
	}
271
}
326
}
272
327
(-)compare/org/eclipse/compare/CompareEditorInput.java (-2 / +7 lines)
Lines 23-30 Link Here
23
23
24
import org.eclipse.core.resources.IFile;
24
import org.eclipse.core.resources.IFile;
25
import org.eclipse.core.runtime.*;
25
import org.eclipse.core.runtime.*;
26
import org.eclipse.ui.IPersistableElement;
26
import org.eclipse.ui.*;
27
import org.eclipse.ui.IEditorInput;
28
27
29
import org.eclipse.jface.util.*;
28
import org.eclipse.jface.util.*;
30
import org.eclipse.jface.util.Assert;
29
import org.eclipse.jface.util.Assert;
Lines 88-93 Link Here
88
 * by passing a subclass of <code>CompareConfiguration</code> and by implementing the <code>prepareInput</code> method.
87
 * by passing a subclass of <code>CompareConfiguration</code> and by implementing the <code>prepareInput</code> method.
89
 * If a subclass cannot use the <code>DiffTreeViewer</code> which is installed by default in the
88
 * If a subclass cannot use the <code>DiffTreeViewer</code> which is installed by default in the
90
 * top left pane, method <code>createDiffViewer</code> can be overridden.
89
 * top left pane, method <code>createDiffViewer</code> can be overridden.
90
 * <p>
91
 * If subclasses of this class implement {@link ISaveableModelSource}, the compare editor will
92
 * pass these models through to the workbench. The editor will still show the dirty indicator 
93
 * if one of these underlying models is dirty. It is the reponsibility of subclasses that
94
 * implement this interface to call {@link #setDirty(boolean)} when the dirty state of
95
 * any of the models managed by the sublcass change dirty state.
91
 * 
96
 * 
92
 * @see CompareUI
97
 * @see CompareUI
93
 * @see CompareEditorInput
98
 * @see CompareEditorInput

Return to bug 126230