Author: ericwa
Date: Wed Mar 19 08:09:03 2014
New Revision: 10584
URL: http://svn.gna.org/viewcvs/etoile?rev=10584&view=rev
Log:
Typewriter: Add a 'Revert' menu item
Modified:
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/MainMenu.xib
Modified:
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m?rev=10584&r1=10583&r2=10584&view=diff
==============================================================================
---
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
(original)
+++
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
Wed Mar 19 08:09:03 2014
@@ -413,6 +413,44 @@
}
}
+- (CORevision*) revisionToRevertTo
+{
+ NSArray *notes = [self selectedNotePersistentRoots];
+ if ([notes count] == 1)
+ {
+ COPersistentRoot *note = notes[0];
+ CORevision *inspectedRevision = [note currentRevision];
+ while (inspectedRevision != nil
+ && ![inspectedRevision.commitDescriptor.identifier
isEqualToString: @"org.etoile.CoreObject.checkpoint"])
+ {
+ inspectedRevision = [inspectedRevision parentRevision];
+ }
+ return inspectedRevision;
+ }
+ return nil;
+}
+
+- (void)revertDocumentToSaved:(id)sender
+{
+ NSArray *notes = [self selectedNotePersistentRoots];
+ if ([notes count] == 1)
+ {
+ COPersistentRoot *note = notes[0];
+ CORevision *revisionToRevertTo = [self revisionToRevertTo];
+
+ if (revisionToRevertTo == nil)
+ {
+ // TODO: Disable the menu item in this case
+ NSLog(@"Can't revert");
+ return;
+ }
+
+ [self commitChangesInBlock: ^{
+ note.currentRevision = revisionToRevertTo;
+ } withIdentifier: @"org.etoile.CoreObject.revert"
descriptionArguments: @[]];
+ }
+}
+
#pragma mark - EWUndoManagerDelegate
- (void) undo
@@ -753,8 +791,12 @@
ETAssert(![selectedNote hasChanges]);
aBlock();
-
- identifier = [@"org.etoile.Typewriter." stringByAppendingString:
identifier];
+
+ // FIXME: Ugly. We should probably always use constants to refer to the
fully-qualified names
+ if (![identifier hasPrefix: @"org.etoile.CoreObject"])
+ {
+ identifier = [@"org.etoile.Typewriter."
stringByAppendingString: identifier];
+ }
NSMutableDictionary *metadata = [NSMutableDictionary new];
if (args != nil)
Modified:
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/MainMenu.xib
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/MainMenu.xib?rev=10584&r1=10583&r2=10584&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/MainMenu.xib
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/MainMenu.xib
Wed Mar 19 08:09:03 2014
@@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">13C64</string>
- <string key="IBDocument.InterfaceBuilderVersion">4514</string>
+ <string key="IBDocument.InterfaceBuilderVersion">5053</string>
<string key="IBDocument.AppKitVersion">1265.19</string>
<string key="IBDocument.HIToolboxVersion">697.40</string>
<object class="NSMutableDictionary"
key="IBDocument.PluginVersions">
<string
key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string key="NS.object.0">4514</string>
+ <string key="NS.object.0">5053</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSCustomObject</string>
@@ -246,6 +246,14 @@
<string
key="NSTitle">Checkpoint</string>
<string
key="NSKeyEquiv">s</string>
<int
key="NSKeyEquivModMask">1048576</int>
+ <int
key="NSMnemonicLoc">2147483647</int>
+
<reference key="NSOnImage" ref="1033313550"/>
+
<reference key="NSMixedImage" ref="310636482"/>
+ </object>
+ <object
class="NSMenuItem" id="486033848">
+
<reference key="NSMenu" ref="720053764"/>
+ <string
key="NSTitle">Revert</string>
+ <string
key="NSKeyEquiv"/>
<int
key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="1033313550"/>
<reference key="NSMixedImage" ref="310636482"/>
@@ -1974,6 +1982,14 @@
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection"
key="connection">
+ <string
key="label">revertDocumentToSaved:</string>
+ <reference key="source"
ref="1014"/>
+ <reference key="destination"
ref="486033848"/>
+ </object>
+ <int key="connectionID">578</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection"
key="connection">
<string
key="label">addFontTrait:</string>
<reference key="source"
ref="739804602"/>
<reference key="destination"
ref="481459203"/>
@@ -2107,6 +2123,7 @@
<reference
ref="810810972"/>
<reference
ref="182822630"/>
<reference
ref="979792788"/>
+ <reference
ref="486033848"/>
</array>
<reference key="parent"
ref="379814623"/>
</object>
@@ -3007,6 +3024,11 @@
<object class="IBObjectRecord">
<int key="objectID">573</int>
<reference key="object"
ref="979792788"/>
+ <reference key="parent"
ref="720053764"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">576</int>
+ <reference key="object"
ref="486033848"/>
<reference key="parent"
ref="720053764"/>
</object>
</array>
@@ -3154,6 +3176,7 @@
<string
key="570.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string
key="571.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string
key="573.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string
key="576.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string
key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string
key="73.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string
key="74.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3169,7 +3192,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary"
key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">575</int>
+ <int key="maxID">578</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray"
key="referencedPartialClassDescriptions">
@@ -3322,6 +3345,8 @@
</object>
</dictionary>
<dictionary class="NSMutableDictionary"
key="outlets">
+ <string
key="addNoteButton">NSButton</string>
+ <string
key="addTagButton">NSButton</string>
<string
key="notesTable">NSTableView</string>
<string
key="searchfield">NSSearchField</string>
<string
key="splitView">NSSplitView</string>
@@ -3329,6 +3354,14 @@
<string
key="textView">EWTextView</string>
</dictionary>
<dictionary class="NSMutableDictionary"
key="toOneOutletInfosByName">
+ <object
class="IBToOneOutletInfo" key="addNoteButton">
+ <string
key="name">addNoteButton</string>
+ <string
key="candidateClassName">NSButton</string>
+ </object>
+ <object
class="IBToOneOutletInfo" key="addTagButton">
+ <string
key="name">addTagButton</string>
+ <string
key="candidateClassName">NSButton</string>
+ </object>
<object
class="IBToOneOutletInfo" key="notesTable">
<string
key="name">notesTable</string>
<string
key="candidateClassName">NSTableView</string>
@@ -3359,26 +3392,16 @@
<string
key="className">EWUndoWindowController</string>
<string
key="superclassName">EWUtilityWindowController</string>
<dictionary class="NSMutableDictionary"
key="actions">
- <string key="redo:">id</string>
<string
key="selectiveRedo:">id</string>
<string
key="selectiveUndo:">id</string>
- <string key="undo:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary"
key="actionInfosByName">
- <object class="IBActionInfo"
key="redo:">
- <string
key="name">redo:</string>
- <string
key="candidateClassName">id</string>
- </object>
<object class="IBActionInfo"
key="selectiveRedo:">
<string
key="name">selectiveRedo:</string>
<string
key="candidateClassName">id</string>
</object>
<object class="IBActionInfo"
key="selectiveUndo:">
<string
key="name">selectiveUndo:</string>
- <string
key="candidateClassName">id</string>
- </object>
- <object class="IBActionInfo"
key="undo:">
- <string
key="name">undo:</string>
<string
key="candidateClassName">id</string>
</object>
</dictionary>
_______________________________________________
Etoile-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-cvs