Permalink
Browse files

Show an appropriate error when no docs are found.

  • Loading branch information...
1 parent e208fc0 commit 8bfe0fecda9189882c33af432b0afad2dc63294d @beelsebob committed Dec 24, 2012
Showing with 560 additions and 32 deletions.
  1. +2 −0 Stash/STAAppDelegate.h
  2. +40 −3 Stash/STAAppDelegate.m
  3. +518 −29 Stash/en.lproj/MainMenu.xib
@@ -26,6 +26,7 @@
@property (weak) IBOutlet NSSearchField *inPageSearchField;
@property (weak) IBOutlet NSTableView *indexingDocsetsView;
@property (weak) IBOutlet NSScrollView *indexingDocsetsContainer;
+@property (weak) IBOutlet NSView *docsetsNotFoundView;
- (IBAction)toggleStashWindow:(id)sender;
- (IBAction)search:(id)sender;
@@ -35,5 +36,6 @@
- (IBAction)hideSearchBar:(id)sender;
- (IBAction)showFindUI;
- (IBAction)searchWithinPage:(id)sender;
+- (IBAction)addDocumentation:(id)sender;
@end
@@ -90,6 +90,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[[self openStashMenuItem] setKeyEquivalent:[NSString stringWithCharacters:&c length:1]];
[[self openStashMenuItem] setKeyEquivalentModifierMask:[[self preferencesController] keyboardShortcutModifierFlags]];
+ [[[self resultWebView] preferences] setJavaEnabled:NO];
+ [[[self resultWebView] preferences] setJavaScriptEnabled:NO];
+ [[[self resultWebView] preferences] setJavaScriptCanOpenWindowsAutomatically:NO];
+ [[[self resultWebView] preferences] setPlugInsEnabled:NO];
+
void(^handler)(NSEvent *) = ^(NSEvent *e)
{
if (![[self preferencesController] isMonitoringForEvents] && ![self isWaitingForDocsetInput])
@@ -160,7 +165,15 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
[[self searchField] setEnabled:YES];
[[self searchField] selectText:self];
[[self indexingDocsetsContainer] setHidden:YES];
- [[self titleView] setStringValue:@""];
+ if ([[self docsets] count] > 0)
+ {
+ [[self titleView] setStringValue:@""];
+ }
+ else
+ {
+ [[self titleView] setStringValue:@"Stash Could Not Find Any Documentation"];
+ [[self docsetsNotFoundView] setHidden:NO];
+ }
});
}];
});
@@ -217,6 +230,32 @@ - (IBAction)searchWithinPage:(id)sender
wrap:YES];
}
+#define STADocumentationBookmarksKey @"DocsBookmarks"
+
+- (IBAction)addDocumentation:(id)sender
+{
+ [[self docsetsNotFoundView] setHidden:YES];
+ NSString *lastRoot = [[self docsetRoots] objectAtIndex:0];
+ NSString *lastPath = [[[[lastRoot stringByAppendingPathComponent:@"Developer"] stringByAppendingPathComponent:@"Shared"] stringByAppendingPathComponent:@"Documentation"] stringByAppendingPathComponent:@"DocSets"];
+ [self requestAccessToDirectory:lastPath
+ continuation:^(NSURL *selectedRoot)
+ {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^()
+ {
+ NSError *err = nil;
+ NSData *bookmark = [selectedRoot bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope | NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess
+ includingResourceValuesForKeys:@[]
+ relativeToURL:nil
+ error:&err];
+ NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
+ documentationBookmarks = documentationBookmarks ? : @[];
+ documentationBookmarks = [documentationBookmarks containsObject:bookmark] ? documentationBookmarks : [documentationBookmarks arrayByAddingObject:bookmark];
+ [[NSUserDefaults standardUserDefaults] setObject:documentationBookmarks forKey:STADocumentationBookmarksKey];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+ });
+ }];
+}
+
- (void)searchAgain:(BOOL)backwards
{
[[self resultWebView] searchFor:[[self inPageSearchField] stringValue]
@@ -289,8 +328,6 @@ - (void)readExistingIndexes
[self setDocsets:docsets];
}
-#define STADocumentationBookmarksKey @"DocsBookmarks"
-
- (void)refreshExistingBookmarksWithContinuation:(void(^)(void))cont
{
NSArray *documentationBookmarks = [[NSUserDefaults standardUserDefaults] arrayForKey:STADocumentationBookmarksKey];
Oops, something went wrong.

0 comments on commit 8bfe0fe

Please sign in to comment.