5 import com.quantum.model.BookmarkCollection;
6 import com.quantum.view.subset.SubsetContentProvider;
8 import org.eclipse.core.resources.ISaveContext;
9 import org.eclipse.core.resources.ISaveParticipant;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.Path;
14 class QuantumSaveParticipant implements ISaveParticipant {
17 * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(ISaveContext)
19 public void doneSaving(ISaveContext context) {
22 * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(ISaveContext)
24 public void prepareToSave(ISaveContext context) throws CoreException {
28 * @see org.eclipse.core.resources.ISaveParticipant#rollback(ISaveContext)
30 public void rollback(ISaveContext context) {
34 * @see org.eclipse.core.resources.ISaveParticipant#saving(ISaveContext)
36 public void saving(ISaveContext context) throws CoreException {
37 switch (context.getKind()) {
38 case ISaveContext.FULL_SAVE :
39 QuantumPlugin quantumPluginInstance = QuantumPlugin.getDefault();
40 // save the plug in state
41 if (BookmarkCollection.getInstance().isAnythingChanged()
42 || SubsetContentProvider.getInstance().hasChanged()) {
44 int saveNumber = context.getSaveNumber();
45 String saveFileName = Messages.getString("QuantumPlugin.saveDir") + "-" + Integer.toString(saveNumber) + Messages.getString("QuantumPlugin.saveFileExtension"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
46 File f = quantumPluginInstance.getStateLocation().append(saveFileName).toFile();
48 // if we fail to write, an exception is thrown and we do not update the path
49 quantumPluginInstance.writeImportantState(f);
51 context.map(new Path(Messages.getString("QuantumPlugin.saveDir")), new Path(saveFileName)); //$NON-NLS-1$
52 context.needSaveNumber();
55 System.out.println("Not saving unchanged bookmarks"); //$NON-NLS-1$
58 case ISaveContext.PROJECT_SAVE :
59 // get the project related to this save operation
60 //IProject project = context.getProject();
61 // save its information, if necessary
63 case ISaveContext.SNAPSHOT :
64 // This operation needs to be really fast because
65 // snapshots can be requested frequently by the