|
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)); |
| 80 |
} |
87 |
} |
| 81 |
|
88 |
|
| 82 |
return changelog; |
89 |
return changelog; |
| 83 |
} |
90 |
} |
| 84 |
} |
91 |
} |
|
Lines 156-161
Link Here
|
| 156 |
|
163 |
|
| 157 |
clw.writeChangeLog(); |
164 |
clw.writeChangeLog(); |
| 158 |
|
165 |
|
|
|
166 |
final IEditorPart changeLogEditor = clw.getChangelog(); |
| 167 |
final String changeLogLocation = clw.getChangelogLocation(); |
| 168 |
|
| 169 |
changeLogEditor.addPropertyListener(new IPropertyListener() { |
| 170 |
|
| 171 |
public void propertyChanged(Object source, int propId) { |
| 172 |
// listen for save event |
| 173 |
if (propId == 257) { |
| 174 |
wasSaved = true; |
| 175 |
changeLogEditor.removePropertyListener(this); |
| 176 |
} |
| 177 |
} |
| 178 |
}); |
| 179 |
|
| 180 |
changeLogEditor.getSite().getPage().addPartListener(new IPartListener() { |
| 181 |
public void partActivated(IWorkbenchPart part) { |
| 182 |
} |
| 183 |
|
| 184 |
public void partBroughtToTop(IWorkbenchPart part) { |
| 185 |
} |
| 186 |
|
| 187 |
// listen for closed event |
| 188 |
public void partClosed(IWorkbenchPart part) { |
| 189 |
if (changeLogEditor.isDirty() && !wasSaved) { |
| 190 |
File file = new File(changeLogLocation); |
| 191 |
file.delete(); |
| 192 |
} |
| 193 |
changeLogEditor.getSite().getPage().removePartListener(this); |
| 194 |
} |
| 195 |
|
| 196 |
public void partDeactivated(IWorkbenchPart part) { |
| 197 |
} |
| 198 |
|
| 199 |
public void partOpened(IWorkbenchPart part) { |
| 200 |
} |
| 201 |
|
| 202 |
}); |
| 203 |
|
| 159 |
return null; |
204 |
return null; |
| 160 |
} |
205 |
} |
| 161 |
|
206 |
|