Skip to content
Snippets Groups Projects
Commit f47d5c71 authored by Sabine Teufl's avatar Sabine Teufl
Browse files

Code review

refs 311
parent dc9dbf88
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ import org.fortiss.tooling.kernel.utils.LoggingUtils;
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 3A80DC630AEA6971552C44802D7533A3
*/
// TODO: wie/warum ANOTHER EMF command? Was war denn der erste?
public class EMFTransactionalCommand implements Command {
/** The wrapped command. */
......
......@@ -166,9 +166,11 @@ public class EclipseResourceStorageProvider implements
new WorkspaceJob("ModelFileChangedJob") {
@Override
// TODO: muss man das so schreiben?
public IStatus runInWorkspace(IProgressMonitor monitor) {
synchronized (EclipseResourceStorageProvider.this) {
if (changeKind == IResourceDelta.ADDED) {
// TODO: copy&paste 1
try {
loadContext(file);
} catch (IOException ioex) {
......@@ -183,6 +185,7 @@ public class EclipseResourceStorageProvider implements
if (isLoaded(file)) {
handleChange(file);
} else {
// TODO: copy&paste 2
try {
loadContext(file);
} catch (IOException ioex) {
......@@ -194,6 +197,7 @@ public class EclipseResourceStorageProvider implements
}
// Refresh the top-level elements
// TODO: Dan wollte sowas als import static..
IPersistencyService.INSTANCE
.refreshTopLevelElements(EclipseResourceStorageProvider.this);
}
......@@ -207,6 +211,7 @@ public class EclipseResourceStorageProvider implements
ModelContext context = loadedContexts.get(file);
if (!context.getLastChangeWasIntended()) {
unloadContext(file);
// TODO: copy&paste 3
try {
loadContext(file);
} catch (final Exception e) {
......
......@@ -65,6 +65,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
private final IFile file;
/** The resource containing the model. */
// TODO: etwas lngerer Name als ein Buchstabe wre gut.
private final Resource r;
/** The editing domain used for this model. */
......@@ -77,15 +78,18 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
private final List<CommandStackListener> listeners = new LinkedList<CommandStackListener>();
/** Flag for remembering whether the last change of the file was intended. */
// TODO: was ist ein unintended change? Und was ist ein intended change?
private boolean lastChangeWasIntended = false;
/** The maximal ID used in this model (used to generate new IDs). */
private int maxId = -1;
/** Constructor. */
// TODO: Kommentar?
/* package */ModelContext(IFile file) throws IOException {
this.file = file;
// TODO: Dan wollte sowas ausgelagert, oder?
editingDomain = TransactionalEditingDomain.Factory.INSTANCE
.createEditingDomain();
rset = editingDomain.getResourceSet();
......@@ -185,6 +189,9 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
// we use a two-state save process, as otherwise inconsistencies in the
// model can lead to partially written files which are unreadable and
// thus cause data loss.
// TODO: was ist denn ein two-state save process? Google findet dafr
// keine Ergebnisse. Also wre eine Erklrung, was das ist, nett, da ich
// sonst trotzdem nicht wei, was der Code unten tolles macht.
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
r.save(bytes, buildOptionsMap());
monitor.worked(1);
......@@ -198,6 +205,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
performNotifyListeners(editingDomain.getCommandStack());
// TODO: Import static..
IPersistencyService.INSTANCE
.notifyTopLevelElementChanged(ModelContext.this);
......@@ -209,6 +217,8 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
* side effect! The {@link #lastChangeWasIntended} flag will be reset, so
* this method should only be called once per change event.
*/
// TODO: aber warum intended? und warum ndert ein "get" den Wert der
// Variable?
public synchronized boolean getLastChangeWasIntended() {
final boolean result = lastChangeWasIntended;
lastChangeWasIntended = false;
......@@ -243,6 +253,7 @@ class ModelContext implements ITopLevelElement, CommandStackListener {
}
/** Helper method for calling notifyListeners on the given stack. */
/* TODO: Kommentar unten notwendig? */
/* package */void performNotifyListeners(CommandStack commandStack) {
try {
Method notifyListenersMethod = BasicCommandStack.class
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment