Lines 36-42
Link Here
|
36 |
* A CompareEditor takes a ICompareEditorInput as input. |
36 |
* A CompareEditor takes a ICompareEditorInput as input. |
37 |
* Most functionality is delegated to the ICompareEditorInput. |
37 |
* Most functionality is delegated to the ICompareEditorInput. |
38 |
*/ |
38 |
*/ |
39 |
public class CompareEditor extends EditorPart implements IReusableEditor, ISaveableModelSource, ISaveableModel { |
39 |
public class CompareEditor extends EditorPart implements IReusableEditor, ISaveablesSource { |
40 |
|
40 |
|
41 |
/** |
41 |
/** |
42 |
* 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 59-64
Link Here
|
59 |
private Control fControl; |
59 |
private Control fControl; |
60 |
/** the outline page */ |
60 |
/** the outline page */ |
61 |
private CompareOutlinePage fOutlinePage; |
61 |
private CompareOutlinePage fOutlinePage; |
|
|
62 |
|
63 |
private CompareSaveable fSaveable; |
62 |
/** enable outline */ |
64 |
/** enable outline */ |
63 |
|
65 |
|
64 |
|
66 |
|
Lines 258-268
Link Here
|
258 |
*/ |
260 |
*/ |
259 |
public boolean isDirty() { |
261 |
public boolean isDirty() { |
260 |
IEditorInput input= getEditorInput(); |
262 |
IEditorInput input= getEditorInput(); |
261 |
if (input instanceof ISaveableModelSource) { |
263 |
if (input instanceof ISaveablesSource) { |
262 |
ISaveableModelSource sms = (ISaveableModelSource) input; |
264 |
ISaveablesSource sms = (ISaveablesSource) input; |
263 |
ISaveableModel[] models = sms.getModels(); |
265 |
Saveable[] models = sms.getSaveables(); |
264 |
for (int i = 0; i < models.length; i++) { |
266 |
for (int i = 0; i < models.length; i++) { |
265 |
ISaveableModel model = models[i]; |
267 |
Saveable model = models[i]; |
266 |
if (model.isDirty()) |
268 |
if (model.isDirty()) |
267 |
return true; |
269 |
return true; |
268 |
} |
270 |
} |
Lines 280-327
Link Here
|
280 |
} |
282 |
} |
281 |
|
283 |
|
282 |
/* (non-Javadoc) |
284 |
/* (non-Javadoc) |
283 |
* @see org.eclipse.ui.ISaveableModelSource#getModels() |
285 |
* @see org.eclipse.ui.ISaveablesSource#getModels() |
284 |
*/ |
286 |
*/ |
285 |
public ISaveableModel[] getModels() { |
287 |
public Saveable[] getSaveables() { |
286 |
IEditorInput input= getEditorInput(); |
288 |
IEditorInput input= getEditorInput(); |
287 |
if (input instanceof ISaveableModelSource) { |
289 |
if (input instanceof ISaveablesSource) { |
288 |
ISaveableModelSource source = (ISaveableModelSource) input; |
290 |
ISaveablesSource source = (ISaveablesSource) input; |
289 |
return source.getModels(); |
291 |
return source.getSaveables(); |
290 |
} |
292 |
} |
291 |
return new ISaveableModel[] { this }; |
293 |
return new Saveable[] { getSaveable() }; |
292 |
} |
294 |
} |
293 |
|
295 |
|
294 |
/* (non-Javadoc) |
296 |
private Saveable getSaveable() { |
295 |
* @see org.eclipse.ui.ISaveableModelSource#getActiveModels() |
297 |
if (fSaveable == null) { |
296 |
*/ |
298 |
fSaveable = new CompareSaveable(); |
297 |
public ISaveableModel[] getActiveModels() { |
|
|
298 |
IEditorInput input= getEditorInput(); |
299 |
if (input instanceof ISaveableModelSource) { |
300 |
ISaveableModelSource source = (ISaveableModelSource) input; |
301 |
return source.getActiveModels(); |
302 |
} |
299 |
} |
303 |
return new ISaveableModel[] { this }; |
300 |
return fSaveable; |
304 |
} |
301 |
} |
305 |
|
302 |
|
306 |
/* (non-Javadoc) |
303 |
/* (non-Javadoc) |
307 |
* @see org.eclipse.ui.ISaveableModel#getName() |
304 |
* @see org.eclipse.ui.ISaveablesSource#getActiveModels() |
308 |
*/ |
305 |
*/ |
309 |
public String getName() { |
306 |
public Saveable[] getActiveSaveables() { |
310 |
return getPartName(); |
307 |
IEditorInput input= getEditorInput(); |
|
|
308 |
if (input instanceof ISaveablesSource) { |
309 |
ISaveablesSource source = (ISaveablesSource) input; |
310 |
return source.getActiveSaveables(); |
311 |
} |
312 |
return new Saveable[] { getSaveable() }; |
311 |
} |
313 |
} |
|
|
314 |
|
315 |
private class CompareSaveable extends Saveable { |
312 |
|
316 |
|
313 |
/* (non-Javadoc) |
317 |
public String getName() { |
314 |
* @see org.eclipse.ui.ISaveableModel#getToolTipText() |
318 |
return CompareEditor.this.getPartName(); |
315 |
*/ |
319 |
} |
316 |
public String getToolTipText() { |
|
|
317 |
return getTitleToolTip(); |
318 |
} |
319 |
|
320 |
|
320 |
/* (non-Javadoc) |
321 |
public String getToolTipText() { |
321 |
* @see org.eclipse.ui.ISaveableModel#getImageDescriptor() |
322 |
return CompareEditor.this.getTitleToolTip(); |
322 |
*/ |
323 |
} |
323 |
public ImageDescriptor getImageDescriptor() { |
324 |
|
324 |
return ImageDescriptor.createFromImage(getTitleImage()); |
325 |
public ImageDescriptor getImageDescriptor() { |
|
|
326 |
return ImageDescriptor.createFromImage(CompareEditor.this.getTitleImage()); |
327 |
} |
328 |
|
329 |
public void doSave(IProgressMonitor monitor) throws CoreException { |
330 |
CompareEditor.this.doSave(monitor); |
331 |
} |
332 |
|
333 |
public boolean isDirty() { |
334 |
return CompareEditor.this.isDirty(); |
335 |
} |
336 |
|
337 |
public boolean equals(Object object) { |
338 |
return object == this; |
339 |
} |
340 |
|
341 |
public int hashCode() { |
342 |
return CompareEditor.this.hashCode(); |
343 |
} |
325 |
} |
344 |
} |
326 |
} |
345 |
} |
327 |
|
346 |
|