Permalink
Browse files

#2732: Fix table information panel stuck on activities view.

  • Loading branch information...
stuconnolly committed Mar 15, 2017
1 parent 95250e0 commit 8222c8f7ecafc6a19c9002b347fa63f6f01143f3
Showing with 48 additions and 37 deletions.
  1. +9 −8 Source/SPDatabaseDocument.m
  2. +10 −5 Source/SPTableInfo.h
  3. +29 −24 Source/SPTableInfo.m
@@ -5794,7 +5794,7 @@ - (void)handleSchemeCommand:(NSDictionary*)commandDict
);
}
- (void)registerActivity:(NSDictionary*)commandDict
- (void)registerActivity:(NSDictionary *)commandDict
{
[runningActivitiesArray addObject:commandDict];
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPActivitiesUpdateNotification object:self];
@@ -5832,23 +5832,24 @@ - (void)removeRegisteredActivity:(NSInteger)pid
[[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:SPActivitiesUpdateNotification object:self];
}
- (void)setActivityPaneHidden:(NSNumber*)hide
- (void)setActivityPaneHidden:(NSNumber *)hide
{
if(hide.boolValue) {
[tableInfoScrollView setHidden:YES];
[documentActivityScrollView setHidden:NO];
} else {
if (hide.boolValue) {
[documentActivityScrollView setHidden:YES];
[tableInfoScrollView setHidden:NO];
}
else {
[tableInfoScrollView setHidden:YES];
[documentActivityScrollView setHidden:NO];
}
}
- (NSArray*)runningActivities
- (NSArray *)runningActivities
{
return (NSArray*)runningActivitiesArray;
}
- (NSDictionary*)shellVariables
- (NSDictionary *)shellVariables
{
if(!_isConnected) return @{};
View
@@ -28,14 +28,19 @@
//
// More info at <https://github.com/sequelpro/sequelpro>
@class SPTableView;
@class SPTablesList;
@class SPTableData;
@class SPDatabaseDocument;
@interface SPTableInfo : NSObject
{
IBOutlet NSTableView *infoTable;
IBOutlet id tableList;
IBOutlet id tableListInstance;
IBOutlet id tableDataInstance;
IBOutlet id tableDocumentInstance;
IBOutlet SPTableView *tableList;
IBOutlet SPTablesList *tableListInstance;
IBOutlet SPTableData *tableDataInstance;
IBOutlet SPDatabaseDocument *tableDocumentInstance;
IBOutlet NSTableView *infoTable;
IBOutlet NSTableView *activitiesTable;
IBOutlet NSScrollView *tableInfoScrollView;
View
@@ -63,19 +63,20 @@ - (id)init
- (void)awakeFromNib
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableChanged:)
name:SPTableChangedNotification
object:tableDocumentInstance];
selector:@selector(tableChanged:)
name:SPTableChangedNotification
object:tableDocumentInstance];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(tableChanged:)
name:SPTableInfoChangedNotification
object:tableDocumentInstance];
selector:@selector(tableChanged:)
name:SPTableInfoChangedNotification
object:tableDocumentInstance];
// Register activities update notifications for add/remove BASH commands etc.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(updateActivities)
name:SPActivitiesUpdateNotification
object:nil];
selector:@selector(updateActivities)
name:SPActivitiesUpdateNotification
object:nil];
// Add activities header
[activities addObject:@{@"name" : NSLocalizedString(@"ACTIVITIES", @"header for activities pane")}];
@@ -147,6 +148,7 @@ - (void)tableChanged:(NSNotification *)notification
}
[infoTable reloadData];
return;
}
@@ -195,8 +197,10 @@ - (void)tableChanged:(NSNotification *)notification
if([[tableStatus objectForKey:@"Data_length"] unboxNull]) {
[info addObject:[NSString stringWithFormat:NSLocalizedString(@"size: %@", @"Table Info Section : table size on disk"), [NSString stringForByteSize:[[tableStatus objectForKey:@"Data_length"] longLongValue]]]];
}
NSString *tableEnc = [tableDataInstance tableEncoding];
NSString *tableColl = [tableStatus objectForKey:@"Collation"];
if([tableColl length]) {
// instead of @"latin1 (latin1_german_ci)" we can just show @"latin1 (german_ci)"
if([tableColl hasPrefix:[NSString stringWithFormat:@"%@_",tableEnc]]) tableColl = [tableColl substringFromIndex:([tableEnc length]+1)];
@@ -382,11 +386,11 @@ - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
return (row == 0 ? 25 : [tableView rowHeight]);
}
- (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
- (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(NSInteger)rowIndex
{
if (rowIndex == 0) return YES;
if (aTableView == infoTable) {
if (tableView == infoTable) {
return NO;
}
else {
@@ -396,7 +400,7 @@ - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(NSInteger)rowIndex
return NO;
}
- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
if (rowIndex > 0) return NO;
@@ -411,14 +415,15 @@ - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn
[infoTable deselectAll:nil];
[activitiesTable deselectAll:nil];
[self updateActivities];
return NO;
}
- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex mouseLocation:(NSPoint)mouseLocation
- (NSString *)tableView:(NSTableView *)tableView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex mouseLocation:(NSPoint)mouseLocation
{
if (aTableView == activitiesTable) {
if (tableView == activitiesTable) {
if (rowIndex == 0) return @"";
if (mouseLocation.x > rect->origin.x + rect->size.width - 30) {
@@ -437,23 +442,23 @@ - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
return nil;
}
- (BOOL)tableView:(NSTableView *)aTableView isGroupRow:(NSInteger)row
- (BOOL)tableView:(NSTableView *)tableView isGroupRow:(NSInteger)row
{
// This makes the top row (TABLE INFORMATION/ACTIVITIES) have the diff styling
return (row == 0);
return row == 0;
}
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
{
if (aTableView == infoTable) {
if (rowIndex > 0 && [[aTableColumn identifier] isEqualToString:@"info"]) {
[(ImageAndTextCell*)aCell setImage:[NSImage imageNamed:@"table-property"]];
[(ImageAndTextCell*)aCell setIndentationLevel:1];
[(ImageAndTextCell*)aCell setDrawsBackground:NO];
if (tableView == infoTable) {
if (rowIndex > 0 && [[tableColumn identifier] isEqualToString:@"info"]) {
[(ImageAndTextCell*)cell setImage:[NSImage imageNamed:@"table-property"]];
[(ImageAndTextCell*)cell setIndentationLevel:1];
[(ImageAndTextCell*)cell setDrawsBackground:NO];
}
else {
[(ImageAndTextCell*)aCell setImage:nil];
[(ImageAndTextCell*)aCell setIndentationLevel:0];
[(ImageAndTextCell*)cell setImage:nil];
[(ImageAndTextCell*)cell setIndentationLevel:0];
}
}
}

0 comments on commit 8222c8f

Please sign in to comment.