Revision: 7458
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7458&view=rev
Author:   hofman
Date:     2011-08-30 16:55:32 +0000 (Tue, 30 Aug 2011)
Log Message:
-----------
convenience methods for template name properties

Modified Paths:
--------------
    trunk/SKDocumentController.m
    trunk/SKMainDocument.m
    trunk/SKNotesDocument.m
    trunk/SKTemplateManager.h
    trunk/SKTemplateManager.m

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2011-08-30 15:08:31 UTC (rev 7457)
+++ trunk/SKDocumentController.m        2011-08-30 16:55:32 UTC (rev 7458)
@@ -416,18 +416,16 @@
 
 - (NSArray *)fileExtensionsFromType:(NSString *)documentTypeName {
     NSArray *fileExtensions = [super fileExtensionsFromType:documentTypeName];
-    if ([fileExtensions count] == 0 && [[[SKTemplateManager sharedManager] 
customTemplateFiles] containsObject:documentTypeName])
-        fileExtensions = [NSArray arrayWithObjects:[documentTypeName 
pathExtension], nil];
-       return fileExtensions;
+    if ([fileExtensions count] == 0) {
+        NSString *fileExtension = [[SKTemplateManager sharedManager] 
fileNameExtensionForType:documentTypeName];
+        if (fileExtension)
+            fileExtensions = [NSArray arrayWithObject:fileExtension];
+       }
+    return fileExtensions;
 }
 
 - (NSString *)displayNameForType:(NSString *)documentTypeName{
-    NSString *displayName = nil;
-    if ([[[SKTemplateManager sharedManager] customTemplateFiles] 
containsObject:documentTypeName])
-        displayName = [documentTypeName stringByDeletingPathExtension];
-    else
-        displayName = [super displayNameForType:documentTypeName];
-    return displayName;
+    return [[SKTemplateManager sharedManager] 
displayNameForType:documentTypeName] ?: [super 
displayNameForType:documentTypeName];
 }
 
 @end

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2011-08-30 15:08:31 UTC (rev 7457)
+++ trunk/SKMainDocument.m      2011-08-30 16:55:32 UTC (rev 7458)
@@ -322,11 +322,7 @@
 }
 
 - (NSString *)fileNameExtensionForType:(NSString *)typeName 
saveOperation:(NSSaveOperationType)saveOperation {
-    NSString *fileExtension = nil;
-    fileExtension = [super fileNameExtensionForType:typeName 
saveOperation:saveOperation];
-    if (fileExtension == nil && [[[SKTemplateManager sharedManager] 
customTemplateFiles] containsObject:typeName])
-        fileExtension = [typeName pathExtension];
-    return fileExtension;
+    return [super fileNameExtensionForType:typeName 
saveOperation:saveOperation] ?: [[SKTemplateManager sharedManager] 
fileNameExtensionForType:typeName];
 }
 
 - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2011-08-30 15:08:31 UTC (rev 7457)
+++ trunk/SKNotesDocument.m     2011-08-30 16:55:32 UTC (rev 7458)
@@ -201,11 +201,7 @@
 }
 
 - (NSString *)fileNameExtensionForType:(NSString *)typeName 
saveOperation:(NSSaveOperationType)saveOperation {
-    NSString *fileExtension = nil;
-    fileExtension = [super fileNameExtensionForType:typeName 
saveOperation:saveOperation];
-    if (fileExtension == nil && [[[SKTemplateManager sharedManager] 
customTemplateFiles] containsObject:typeName])
-        fileExtension = [typeName pathExtension];
-    return fileExtension;
+    return [super fileNameExtensionForType:typeName 
saveOperation:saveOperation] ?: [[SKTemplateManager sharedManager] 
fileNameExtensionForType:typeName];
 }
 
 - (BOOL)prepareSavePanel:(NSSavePanel *)savePanel {

Modified: trunk/SKTemplateManager.h
===================================================================
--- trunk/SKTemplateManager.h   2011-08-30 15:08:31 UTC (rev 7457)
+++ trunk/SKTemplateManager.h   2011-08-30 16:55:32 UTC (rev 7458)
@@ -49,6 +49,8 @@
 - (void)resetCustomTemplateFiles;
 
 - (NSString *)pathForTemplateFile:(NSString *)filename;
+- (NSString *)fileNameExtensionForType:(NSString *)typeName;
+- (NSString *)displayNameForType:(NSString *)typeName;
 
 - (BOOL)isRichTextTemplateFile:(NSString *)templateFile;
 

Modified: trunk/SKTemplateManager.m
===================================================================
--- trunk/SKTemplateManager.m   2011-08-30 15:08:31 UTC (rev 7457)
+++ trunk/SKTemplateManager.m   2011-08-30 16:55:32 UTC (rev 7458)
@@ -95,6 +95,14 @@
     return fullPath;
 }
 
+- (NSString *)fileNameExtensionForType:(NSString *)typeName {
+    return [[self customTemplateFiles] containsObject:typeName] ? [typeName 
pathExtension] : nil;
+}
+
+- (NSString *)displayNameForType:(NSString *)typeName {
+    return [[self customTemplateFiles] containsObject:typeName] ? [typeName 
stringByDeletingPathExtension] : nil;
+}
+
 - (BOOL)isRichTextTemplateFile:(NSString *)templateFile {
     static NSSet *types = nil;
     if (types == nil)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to