Author: ericwa
Date: Mon Mar 24 08:57:03 2014
New Revision: 10626
URL: http://svn.gna.org/viewcvs/etoile?rev=10626&view=rev
Log:
Typewriter: number new tags and tag groups. Include the name in the commit
descriptors
Modified:
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/TODO.md
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/Commits/org.etoile.Typewriter.json
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=10626&r1=10625&r2=10626&view=diff
==============================================================================
---
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
(original)
+++
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/EWTypewriterWindowController.m
Mon Mar 24 08:57:03 2014
@@ -256,6 +256,36 @@
#pragma mark - IBActions
+- (NSString *) untitledTagNameForIndex: (NSUInteger)index
+{
+ if (index == 1)
+ return @"New Tag";
+ return [NSString stringWithFormat: @"New Tag %d", (int)index];
+}
+
+- (BOOL) isTagNameInUse: (NSString *)aName
+{
+ for (COTagGroup *tagGroup in self.tagLibrary.tagGroups)
+ {
+ for (COTag *tag in tagGroup.content)
+ {
+ if ([tag.name isEqualToString: aName])
+ return YES;
+ }
+ }
+ return NO;
+}
+
+- (NSString *) untitledTagName
+{
+ NSUInteger i = 1;
+ while ([self isTagNameInUse: [self untitledTagNameForIndex: i]])
+ {
+ i++;
+ }
+ return [self untitledTagNameForIndex: i];
+}
+
- (IBAction) addTag:(id)sender
{
COTagGroup *targetTagGroup = [self tagGroupOfSelectedRow];
@@ -266,25 +296,54 @@
}
__block COTag *newTag = nil;
+ __block NSString *name = [self untitledTagName];
[self commitChangesInBlock: ^{
newTag = [[COTag alloc] initWithObjectGraphContext: [[self
tagLibrary] objectGraphContext]];
- newTag.name = @"New Tag";
+ newTag.name = name;
[targetTagGroup addObject: newTag];
- } withIdentifier: @"add-tag" descriptionArguments: @[]];
+ } withIdentifier: @"add-tag" descriptionArguments: @[name]];
[tagListDataSource setNextSelection: [[EWTagGroupTagPair alloc]
initWithTagGroup: targetTagGroup.UUID tag:newTag.UUID]];
[tagListDataSource reloadData];
}
+- (NSString *) untitledTagGroupNameForIndex: (NSUInteger)index
+{
+ if (index == 1)
+ return @"New Tag Group";
+ return [NSString stringWithFormat: @"New Tag Group %d", (int)index];
+}
+
+- (BOOL) isTagGroupNameInUse: (NSString *)aName
+{
+ for (COTagGroup *tagGroup in self.tagLibrary.tagGroups)
+ {
+ if ([tagGroup.name isEqualToString: aName])
+ return YES;
+ }
+ return NO;
+}
+
+- (NSString *) untitledTagGroupName
+{
+ NSUInteger i = 1;
+ while ([self isTagGroupNameInUse: [self untitledTagGroupNameForIndex:
i]])
+ {
+ i++;
+ }
+ return [self untitledTagGroupNameForIndex: i];
+}
+
- (IBAction) addTagGroup:(id)sender
{
__block COTagGroup *newTagGroup = nil;
+ __block NSString *name = [self untitledTagGroupName];
[self commitChangesInBlock: ^{
newTagGroup = [[COTagGroup alloc] initWithObjectGraphContext:
[[self tagLibrary] objectGraphContext]];
- newTagGroup.name = @"New Tag Group";
+ newTagGroup.name = name;
[[[self tagLibrary] mutableArrayValueForKey: @"tagGroups"]
addObject: newTagGroup];
- } withIdentifier: @"add-tag-group" descriptionArguments: @[]];
+ } withIdentifier: @"add-tag-group" descriptionArguments: @[name]];
[tagListDataSource setNextSelection: [[EWTagGroupTagPair alloc]
initWithTagGroup: newTagGroup.UUID tag:nil]];
[tagListDataSource reloadData];
@@ -294,6 +353,8 @@
- (NSString *) untitledDocumentNameForIndex: (NSUInteger)index
{
+ if (index == 1)
+ return @"Untitled Note";
return [NSString stringWithFormat: @"Untitled Note %d", (int)index];
}
@@ -324,17 +385,18 @@
- (IBAction) addNote:(id)sender
{
__block COPersistentRoot *newNote = nil;
+ __block NSString *name = [self untitledDocumentName];
[self commitChangesInBlock: ^{
newNote = [self.editingContext
insertNewPersistentRootWithEntityName: @"TypewriterDocument"];
- newNote.name = [self untitledDocumentName];
+ newNote.name = name;
COTag *currentTag = [self clickedOrSelectedTag];
if (currentTag != nil)
{
[currentTag addObject: [newNote rootObject]];
}
- } withIdentifier: @"add-note" descriptionArguments: @[]];
+ } withIdentifier: @"add-note" descriptionArguments: @[name]];
[noteListDataSource setNextSelection: newNote.UUID];
[noteListDataSource reloadData];
Modified: trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/TODO.md
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/TODO.md?rev=10626&r1=10625&r2=10626&view=diff
==============================================================================
--- trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/TODO.md
(original)
+++ trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/TODO.md Mon Mar
24 08:57:03 2014
@@ -5,8 +5,8 @@
- [x] Don't create Default Tag Group
- [ ] Delete' is enabled in the menus for All Notes
- [ ] if not tag group exists, new tags you create remain invisible (and the
button and menu actions are not disabled)⦠I guess the solution is to create
a New Tag Group at the same time, if there is none.
-- [ ] name a new tag group just Untitled Tag Group X
-- [ ] a new tag could be named Untitled X
+- [x] name a new tag group just Untitled Tag Group X
+- [x] a new tag could be named Untitled X
- [ ] a way to give a name to a checkpoint
- [ ] some way to see the list of all the checkpoints
- [ ] have Revert show a panel listing all the checkpoints, so you can pick
the one you want
Modified:
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/Commits/org.etoile.Typewriter.json
URL:
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/Commits/org.etoile.Typewriter.json?rev=10626&r1=10625&r2=10626&view=diff
==============================================================================
---
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/Commits/org.etoile.Typewriter.json
(original)
+++
trunk/Etoile/Frameworks/CoreObject/Samples/Typewriter/en.lproj/Commits/org.etoile.Typewriter.json
Mon Mar 24 08:57:03 2014
@@ -21,7 +21,7 @@
"add-note":
{
"type": "creation",
- "shortDescription": "Create note"
+ "shortDescription": "Create note '%@'"
},
"rename-note":
{
@@ -52,7 +52,7 @@
"add-tag":
{
"type": "creation",
- "shortDescription": "Create tag"
+ "shortDescription": "Create tag '%@'"
},
"rename-tag":
{
@@ -75,7 +75,7 @@
"add-tag-group":
{
"type": "creation",
- "shortDescription": "Create tag group"
+ "shortDescription": "Create tag group '%@'"
},
"rename-tag-group":
{
_______________________________________________
Etoile-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-cvs