Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 214686 | Differences between
and this patch

Collapse All | Expand All

(-)InsertChangeLogKeyHandler.java (-1 / +48 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.linuxtools.changelog.core.actions;
12
package org.eclipse.linuxtools.changelog.core.actions;
13
13
14
import java.io.File;
15
14
import org.eclipse.core.commands.ExecutionEvent;
16
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
17
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.IHandler;
18
import org.eclipse.core.commands.IHandler;
Lines 22-27 Link Here
22
import org.eclipse.linuxtools.changelog.core.ChangeLogWriter;
24
import org.eclipse.linuxtools.changelog.core.ChangeLogWriter;
23
import org.eclipse.linuxtools.changelog.core.IParserChangeLogContrib;
25
import org.eclipse.linuxtools.changelog.core.IParserChangeLogContrib;
24
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.ui.IEditorPart;
27
import org.eclipse.ui.IPartListener;
28
import org.eclipse.ui.IPropertyListener;
29
import org.eclipse.ui.IWorkbenchPart;
25
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.IWorkbenchWindow;
26
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
31
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
27
32
Lines 33-38 Link Here
33
		IHandler, IWorkbenchWindowActionDelegate {
38
		IHandler, IWorkbenchWindowActionDelegate {
34
39
35
	private IEditorPart currentEditor;
40
	private IEditorPart currentEditor;
41
	private boolean wasSaved;
36
42
37
	public InsertChangeLogKeyHandler() {
43
	public InsertChangeLogKeyHandler() {
38
		super();
44
		super();
Lines 75-84 Link Here
75
						false));
81
						false));
76
82
77
				if (changelog == null) {
83
				if (changelog == null) {
84
					wasSaved = false;
78
					changelog = askChangeLogLocation(getDocumentLocation(
85
					changelog = askChangeLogLocation(getDocumentLocation(
79
							currentEditor, false));
86
							currentEditor, false));
87
				}else{
88
					wasSaved = true;
80
				}
89
				}
81
90
				
82
				return changelog;
91
				return changelog;
83
			}
92
			}
84
		}
93
		}
Lines 156-161 Link Here
156
165
157
		clw.writeChangeLog();
166
		clw.writeChangeLog();
158
167
168
		final IEditorPart changeLogEditor = clw.getChangelog(); 
169
		final String changeLogLocation = clw.getChangelogLocation();
170
		
171
		changeLogEditor.addPropertyListener(new IPropertyListener() {
172
			
173
			public void propertyChanged(Object source, int propId) {
174
				// listen for save event
175
				if (propId == 257) {
176
					wasSaved = true;
177
					changeLogEditor.removePropertyListener(this);
178
				}
179
			}
180
		});
181
182
		changeLogEditor.getSite().getPage().addPartListener(new IPartListener() {
183
			public void partActivated(IWorkbenchPart part) {
184
			}
185
186
			public void partBroughtToTop(IWorkbenchPart part) {
187
			}
188
189
			// listen for closed event
190
			public void partClosed(IWorkbenchPart part) {
191
				if (changeLogEditor.isDirty() && !wasSaved) {
192
					File file = new File(changeLogLocation);
193
					file.delete();
194
				}
195
				changeLogEditor.getSite().getPage().removePartListener(this);
196
			}
197
198
			public void partDeactivated(IWorkbenchPart part) {
199
			}
200
201
			public void partOpened(IWorkbenchPart part) {
202
			}
203
204
		});
205
159
		return null;
206
		return null;
160
	}
207
	}
161
208

Return to bug 214686