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 |
|