|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Dirty state change notification |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracebuilder.eclipse; |
|
20 |
|
21 import org.eclipse.ui.IPropertyListener; |
|
22 import org.eclipse.ui.IWorkbenchPartConstants; |
|
23 |
|
24 /** |
|
25 * Dirty state change notification |
|
26 * |
|
27 */ |
|
28 final class JFaceDirtyStateListener implements IPropertyListener { |
|
29 |
|
30 /** |
|
31 * Workbench monitor |
|
32 */ |
|
33 private WorkbenchEditorMonitor monitor; |
|
34 |
|
35 /** |
|
36 * Source to be monitored |
|
37 */ |
|
38 private JFaceDocumentWrapper source; |
|
39 |
|
40 /** |
|
41 * Constructor |
|
42 * |
|
43 * @param monitor |
|
44 * the workbench monitor |
|
45 * @param source |
|
46 * source to be monitored |
|
47 */ |
|
48 JFaceDirtyStateListener(WorkbenchEditorMonitor monitor, |
|
49 JFaceDocumentWrapper source) { |
|
50 this.monitor = monitor; |
|
51 this.source = source; |
|
52 } |
|
53 |
|
54 /* |
|
55 * (non-Javadoc) |
|
56 * |
|
57 * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, |
|
58 * int) |
|
59 */ |
|
60 public void propertyChanged(Object obj, int propId) { |
|
61 if (propId == IWorkbenchPartConstants.PROP_DIRTY) { |
|
62 if (!source.getTextEditor().isDirty()) { |
|
63 monitor.sourceSaved(source); |
|
64 } |
|
65 } |
|
66 } |
|
67 } |