Permalink
Browse files

Improve the indexing UI greatly.

  • Loading branch information...
1 parent 3fd5035 commit 87199156365b80beccd6747bb3158babeddf90c0 @beelsebob committed Dec 24, 2012
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -48,6 +48,8 @@
1F50A3DE157BAAA400CF6068 /* Union@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C6157BAAA400CF6068 /* Union@2x.png */; };
1F50A3DF157BAAA400CF6068 /* Value.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C7157BAAA400CF6068 /* Value.png */; };
1F50A3E0157BAAA400CF6068 /* Value@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F50A3C8157BAAA400CF6068 /* Value@2x.png */; };
+ 1F747C1C1687D3B6006D2DFB /* Tick.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F747C1A1687D3B6006D2DFB /* Tick.png */; };
+ 1F747C1D1687D3B6006D2DFB /* Tick@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F747C1B1687D3B6006D2DFB /* Tick@2x.png */; };
1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */ = {isa = PBXBuildFile; fileRef = 1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */; };
1FBF3DE2157CAFD4007B8D97 /* STAPreferencesController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */; };
1FBF3DE6157CAFEC007B8D97 /* STAPreferencesController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1FBF3DE5157CAFEC007B8D97 /* STAPreferencesController.m */; };
@@ -123,6 +125,8 @@
1F50A3C6157BAAA400CF6068 /* Union@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Union@2x.png"; sourceTree = "<group>"; };
1F50A3C7157BAAA400CF6068 /* Value.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Value.png; sourceTree = "<group>"; };
1F50A3C8157BAAA400CF6068 /* Value@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Value@2x.png"; sourceTree = "<group>"; };
+ 1F747C1A1687D3B6006D2DFB /* Tick.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Tick.png; sourceTree = "<group>"; };
+ 1F747C1B1687D3B6006D2DFB /* Tick@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Tick@2x.png"; sourceTree = "<group>"; };
1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HorizontalSeparator.png; sourceTree = "<group>"; };
1F879AD81658F3CC004ABD2C /* Stash.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Stash.entitlements; sourceTree = "<group>"; };
1FBF3DE1157CAFD4007B8D97 /* STAPreferencesController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = STAPreferencesController.xib; sourceTree = "<group>"; };
@@ -266,6 +270,8 @@
1F50A3B0157BAAA400CF6068 /* Images */ = {
isa = PBXGroup;
children = (
+ 1F747C1A1687D3B6006D2DFB /* Tick.png */,
+ 1F747C1B1687D3B6006D2DFB /* Tick@2x.png */,
1F879AD61657AF2D004ABD2C /* HorizontalSeparator.png */,
1FBF3DE9157E3F22007B8D97 /* iOS.png */,
1FBF3DEA157E3F22007B8D97 /* iOS@2x.png */,
@@ -404,6 +410,8 @@
1FBF3DEF157E3F22007B8D97 /* MacOS.png in Resources */,
1FBF3DF0157E3F22007B8D97 /* MacOS@2x.png in Resources */,
1F879AD71657AF2D004ABD2C /* HorizontalSeparator.png in Resources */,
+ 1F747C1C1687D3B6006D2DFB /* Tick.png in Resources */,
+ 1F747C1D1687D3B6006D2DFB /* Tick@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -24,6 +24,8 @@
@property (strong) STAPreferencesController *preferencesController;
@property (weak) IBOutlet NSMatrix *searchMethodSelector;
@property (weak) IBOutlet NSSearchField *inPageSearchField;
+@property (weak) IBOutlet NSTableView *indexingDocsetsView;
+@property (weak) IBOutlet NSScrollView *indexingDocsetsContainer;
- (IBAction)toggleStashWindow:(id)sender;
- (IBAction)search:(id)sender;
View
@@ -17,6 +17,7 @@
@interface STAAppDelegate () <NSWindowDelegate>
+@property (copy) NSArray *indexingDocsets;
@property (copy) NSArray *docsets;
@property (copy) NSString *currentSearchString;
@property (strong) NSMutableArray *results;
@@ -32,25 +33,23 @@ - (void)searchAgain:(BOOL)backwards;
@implementation STAAppDelegate
{
+ NSMutableArray *_indexingDocsets;
NSMutableArray *_docsets;
+ dispatch_queue_t _docsetArrayEditingQueue;
}
-@synthesize window = _window;
-@synthesize statusMenu = _statusMenu;
-@synthesize openStashMenuItem = _openStashMenuItem;
-@synthesize statusItem = _statusItem;
-@synthesize resultsTable = _resultsTable;
-@synthesize resultWebView = _resultWebView;
-@synthesize titleView = _titleView;
-@synthesize searchField = _searchField;
-@synthesize preferencesController = _preferencesController;
-
-@synthesize docsets = _docsets;
-@synthesize currentSearchString = _currentSearchString;
-@synthesize results = _results;
-@synthesize sortedResults = _sortedResults;
+- (NSArray *)indexingDocsets
+{
+ return [_indexingDocsets copy];
+}
-@synthesize findUIShowing = _findUIShowing;
+- (void)setIndexingDocsets:(NSArray *)indexingDocsets
+{
+ if (indexingDocsets != _indexingDocsets)
+ {
+ _indexingDocsets = [indexingDocsets mutableCopy];
+ }
+}
- (NSArray *)docsets
{
@@ -67,9 +66,11 @@ - (void)setDocsets:(NSArray *)docsets
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
+ _docsetArrayEditingQueue = dispatch_queue_create("org.beelsebob.Stash.docsetArrayEditing", DISPATCH_QUEUE_SERIAL);
+
[self setPreferencesController:[[STAPreferencesController alloc] initWithNibNamed:@"STAPreferencesController" bundle:nil]];
[[self preferencesController] setDelegate:self];
-
+
STAIconShowingMode mode = [[self preferencesController] iconMode];
if (mode == STAIconShowingModeBoth || mode == STAIconShowingModeMenuBar)
@@ -157,12 +158,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[self searchField] setEnabled:YES];
[[self searchField] selectText:self];
+ [[self indexingDocsetsContainer] setHidden:YES];
[[self titleView] setStringValue:@""];
});
}];
});
}
+- (void)dealloc
+{
+ dispatch_release(_docsetArrayEditingQueue);
+}
+
- (void)showFindUI
{
[[self window] makeFirstResponder:[self inPageSearchField]];
@@ -220,11 +227,14 @@ - (void)searchAgain:(BOOL)backwards
- (void)readDocsetsWithContinuation:(void(^)(void))cont
{
[self setDocsets:@[]];
+ [self setIndexingDocsets:@[]];
[self readExistingIndexes];
dispatch_async(dispatch_get_main_queue(), ^()
{
[[self titleView] setStringValue:@"Stash is Indexing, Please Wait..."];
+ [[self indexingDocsetsContainer] setHidden:NO];
+ [[self indexingDocsetsView] reloadData];
});
[self refreshExistingBookmarksWithContinuation:^()
{
@@ -341,8 +351,6 @@ - (void)indexDocsetsWithPermissionInRoots:(NSArray *)roots withContinuation:(voi
{
NSError *err;
BOOL isDir;
- __block NSUInteger numDocsetsIndexing = 0;
- __block NSUInteger numDocsetsIndexed = 0;
__block BOOL finishedSearchingForDocsets = NO;
for (NSURL *root in roots)
{
@@ -355,35 +363,56 @@ - (void)indexDocsetsWithPermissionInRoots:(NSArray *)roots withContinuation:(voi
if (docsetExists && isDir)
{
NSString *docsetCachePath = [[[self pathForArchive] stringByAppendingPathComponent:[docsetURL lastPathComponent]] stringByAppendingPathExtension:@"stashidx"];
- numDocsetsIndexing++;
- STADocSet *indexedDocset = [STADocSet docSetWithURL:docsetURL
- cachePath:docsetCachePath
- onceIndexed:^(STADocSet *idx)
- {
- [NSKeyedArchiver archiveRootObject:idx toFile:docsetCachePath];
- numDocsetsIndexed++;
- if (numDocsetsIndexed == numDocsetsIndexing && finishedSearchingForDocsets)
- {
- cont();
- }
- }];
- if (nil != indexedDocset)
+
+ STADocSet *docset = [STADocSet docSetWithURL:docsetURL
+ cachePath:docsetCachePath
+ onceIndexed:^(STADocSet *idx)
+ {
+ [NSKeyedArchiver archiveRootObject:idx toFile:docsetCachePath];
+ dispatch_sync(_docsetArrayEditingQueue, ^()
+ {
+ [_indexingDocsets removeObjectIdenticalTo:idx];
+ [_docsets addObject:idx];
+ dispatch_async(dispatch_get_main_queue(), ^()
+ {
+ [[self indexingDocsetsView] reloadData];
+ });
+ if (finishedSearchingForDocsets && [_indexingDocsets count] == 0)
+ {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), cont);
+ }
+ });
+ }];
+ dispatch_sync(_docsetArrayEditingQueue, ^()
+ {
+ if ([_docsets indexOfObjectIdenticalTo:docset] == NSNotFound)
+ {
+ [_indexingDocsets addObject:docset];
+ }
+ });
+ if (nil != docset)
{
- [[self preferencesController] registerDocset:indexedDocset];
- [_docsets addObject:indexedDocset];
- if (![[[self preferencesController] enabledDocsets] containsObject:indexedDocset])
+ [[self preferencesController] registerDocset:docset];
+ if (![[[self preferencesController] enabledDocsets] containsObject:docset])
{
- [indexedDocset unload];
+ [docset unload];
}
}
}
}
}
+ dispatch_async(dispatch_get_main_queue(), ^()
+ {
+ [[self indexingDocsetsView] reloadData];
+ });
finishedSearchingForDocsets = YES;
- if (numDocsetsIndexed == numDocsetsIndexing)
- {
- cont();
- }
+ dispatch_sync(_docsetArrayEditingQueue, ^()
+ {
+ if (finishedSearchingForDocsets && [_indexingDocsets count] == 0)
+ {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), cont);
+ }
+ });
}
- (NSString *)pathForArchive
@@ -525,12 +554,7 @@ - (IBAction)setSearchMethod:(id)sender
#pragma mark - Table View Data Source
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
- return [[self sortedResults] count];
-}
-
-- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
-{
- return row < [[self sortedResults] count] ? [[[self sortedResults] objectAtIndex:row] symbolName] : @"";
+ return tableView == [self indexingDocsetsView] ? [[self docsets] count] + [[self indexingDocsets] count] : [[self sortedResults] count];
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
@@ -544,15 +568,55 @@ - (void)tableViewSelectionDidChange:(NSNotification *)notification
}
}
-- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
- return [[STASymbolTableViewCell alloc] init];
+ if (tableView == [self resultsTable])
+ {
+ STASymbolTableViewCell *view = [[STASymbolTableViewCell alloc] initWithFrame:NSZeroRect];
+ [view setSymbolName:row < [[self sortedResults] count] ? [[[self sortedResults] objectAtIndex:row] symbolName] : @""];
+ [view setSymbolTypeImage:NSImageFromSTASymbolType([[[self sortedResults] objectAtIndex:row] symbolType])];
+ [view setPlatformImage:NSImageFromSTAPlatform([[[[self sortedResults] objectAtIndex:row] docSet] platform])];
+ return view;
+ }
+ else
+ {
+ NSArray *allDocsets = [[[self docsets] arrayByAddingObjectsFromArray:[self indexingDocsets]] sortedArrayUsingComparator:^ NSComparisonResult (STADocSet *d1, STADocSet *d2)
+ {
+ return [[d1 name] compare:[d2 name]];
+ }];
+ if ([[tableColumn identifier] isEqualToString:@"docset"])
+ {
+ NSTextField *textField = [[NSTextField alloc] initWithFrame:NSZeroRect];
+ [textField setEditable:NO];
+ [textField setSelectable:NO];
+ [textField setBordered:NO];
+ [textField setDrawsBackground:NO];
+ [textField setBezeled:NO];
+ [[textField cell] setLineBreakMode:NSLineBreakByTruncatingTail];
+ [textField setStringValue:[[allDocsets objectAtIndex:row] name] ? : @""];
+ return textField;
+ }
+ else if ([[tableColumn identifier] isEqualToString:@"progress"] && [[self indexingDocsets] containsObject:[allDocsets objectAtIndex:row]])
+ {
+ NSProgressIndicator *twirler = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 16.0f, 16.0f)];
+ [twirler setStyle:NSProgressIndicatorSpinningStyle];
+ [twirler setControlSize:NSSmallControlSize];
+ [twirler startAnimation:self];
+ return twirler;
+ }
+ else
+ {
+ NSImageView *tick = [[NSImageView alloc] initWithFrame:NSZeroRect];
+ [tick setImage:[NSImage imageNamed:@"Tick"]];
+ return tick;
+ }
+ }
+ return nil;
}
-- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
+- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)row
{
- [cell setSymbolTypeImage:NSImageFromSTASymbolType([[[self sortedResults] objectAtIndex:row] symbolType])];
- [cell setPlatformImage:NSImageFromSTAPlatform([[[[self sortedResults] objectAtIndex:row] docSet] platform])];
+ return tableView == [self resultsTable];
}
#pragma mark - Prefs Delegate
@@ -8,9 +8,10 @@
#import <Cocoa/Cocoa.h>
-@interface STASymbolTableViewCell : NSTextFieldCell
+@interface STASymbolTableViewCell : NSView
-@property (strong) NSImage *symbolTypeImage;
-@property (strong) NSImage *platformImage;
+@property (strong,nonatomic) NSImage *symbolTypeImage;
+@property (strong,nonatomic) NSImage *platformImage;
+@property (copy ,nonatomic) NSString *symbolName;
@end
Oops, something went wrong.

0 comments on commit 8719915

Please sign in to comment.