/******************************************************************************* | |
* Copyright 2011 Chair for Applied Software Engineering, | |
* Technische Universitaet Muenchen. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
******************************************************************************/ | |
package org.eclipse.emf.emfstore.client.model.impl; | |
import org.eclipse.emf.common.command.Command; | |
import org.eclipse.emf.emfstore.client.model.Configuration; | |
import org.eclipse.emf.emfstore.client.model.changeTracking.commands.CommandObserver; | |
/** | |
* The operation persister may be registered as an {@link CommandObserver} on a given | |
* stack and saves each time when a command has been completed, as long as {@link Configuration#isAutoSaveEnabled()} | |
* returns true. | |
* | |
* @author emueller | |
* | |
*/ | |
public class OperationPersister implements CommandObserver { | |
private final ProjectSpaceBase projectSpace; | |
/** | |
* Constructor. | |
* | |
* @param projectSpace | |
* the project space holding the operations to be saved | |
*/ | |
public OperationPersister(ProjectSpaceBase projectSpace) { | |
this.projectSpace = projectSpace; | |
} | |
/** | |
* | |
* {@inheritDoc} | |
* | |
* @see org.eclipse.emf.emfstore.client.model.changeTracking.commands.CommandObserver#commandStarted(org.eclipse.emf.common.command.Command) | |
*/ | |
public void commandStarted(Command command) { | |
} | |
/** | |
* | |
* {@inheritDoc} | |
* | |
* @see org.eclipse.emf.emfstore.client.model.changeTracking.commands.CommandObserver#commandCompleted(org.eclipse.emf.common.command.Command) | |
*/ | |
public void commandCompleted(Command command) { | |
if (Configuration.isAutoSaveEnabled()) { | |
projectSpace.save(); | |
} | |
} | |
/** | |
* | |
* {@inheritDoc} | |
* | |
* @see org.eclipse.emf.emfstore.client.model.changeTracking.commands.CommandObserver#commandFailed(org.eclipse.emf.common.command.Command, | |
* java.lang.Exception) | |
*/ | |
public void commandFailed(Command command, Exception exception) { | |
} | |
} |