From 852006ed22379585dbbd0be5becb511dfac2f1fb Mon Sep 17 00:00:00 2001 From: German Laullon Date: Thu, 10 Jun 2010 01:28:27 -0700 Subject: [PATCH] initial blame functionality on tree view --- GitX.xcodeproj/project.pbxproj | 33 ++ PBGitHistoryController.h | 5 + PBGitHistoryController.m | 23 ++ PBGitHistoryView.xib | 661 +++++++++++++++------------------ PBGitTree.h | 1 + PBGitTree.m | 16 +- html/views/blame/blame.js | 5 + html/views/blame/index.html | 9 + 8 files changed, 380 insertions(+), 373 deletions(-) create mode 100644 html/views/blame/blame.js create mode 100644 html/views/blame/index.html diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index 8467246..c0ade2f 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -22,6 +22,8 @@ /* Begin PBXBuildFile section */ 056438B70ED0C40B00985397 /* DetailViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 056438B60ED0C40B00985397 /* DetailViewTemplate.png */; }; + 31F8A73611C0CE5300517F78 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 31F8A73511C0CE5300517F78 /* index.html */; }; + 31F8A75411C0D0F800517F78 /* blame.js in Sources */ = {isa = PBXBuildFile; fileRef = 31F8A75311C0D0F800517F78 /* blame.js */; }; 3BC07F4C0ED5A5C5009A7768 /* HistoryViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */; }; 3BC07F4D0ED5A5C5009A7768 /* CommitViewTemplate.png in Resources */ = {isa = PBXBuildFile; fileRef = 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */; }; 47DBDB580E94EDE700671A1E /* DBPrefsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 47DBDB570E94EDE700671A1E /* DBPrefsWindowController.m */; }; @@ -218,6 +220,8 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 31F8A73511C0CE5300517F78 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = ""; }; + 31F8A75311C0D0F800517F78 /* blame.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = blame.js; sourceTree = ""; }; 32CA4F630368D1EE00C91783 /* GitX_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GitX_Prefix.pch; sourceTree = ""; }; 3BC07F4A0ED5A5C5009A7768 /* HistoryViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = HistoryViewTemplate.png; path = Images/HistoryViewTemplate.png; sourceTree = ""; }; 3BC07F4B0ED5A5C5009A7768 /* CommitViewTemplate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = CommitViewTemplate.png; path = Images/CommitViewTemplate.png; sourceTree = ""; }; @@ -509,6 +513,7 @@ 29B97314FDCFA39411CA2CEA /* GitTest */ = { isa = PBXGroup; children = ( + 31F8A73911C0CE6C00517F78 /* html */, F5886A080ED5D26B0066E74C /* SpeedTest */, 913D5E420E5563FD00CECEA2 /* cli */, F57CC43E0E05E472000472E2 /* Aux */, @@ -593,6 +598,32 @@ name = Frameworks; sourceTree = ""; }; + 31F8A73411C0CE5300517F78 /* blame */ = { + isa = PBXGroup; + children = ( + 31F8A73511C0CE5300517F78 /* index.html */, + 31F8A75311C0D0F800517F78 /* blame.js */, + ); + name = blame; + path = html/views/blame; + sourceTree = ""; + }; + 31F8A73911C0CE6C00517F78 /* html */ = { + isa = PBXGroup; + children = ( + 31F8A73A11C0CE7400517F78 /* views */, + ); + name = html; + sourceTree = ""; + }; + 31F8A73A11C0CE7400517F78 /* views */ = { + isa = PBXGroup; + children = ( + 31F8A73411C0CE5300517F78 /* blame */, + ); + name = views; + sourceTree = ""; + }; 47DBDB920E94F47200671A1E /* Preference Icons */ = { isa = PBXGroup; children = ( @@ -1044,6 +1075,7 @@ D8A4BD081134AD2900E92D51 /* MergeTemplate.png in Resources */, D8A4BD091134AD2900E92D51 /* RebaseTemplate.png in Resources */, D828AEEC112F411100F09D11 /* CloneRepositoryTemplate.png in Resources */, + 31F8A73611C0CE5300517F78 /* index.html in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1185,6 +1217,7 @@ D8295D2A1130A1DC00C838E8 /* PBGitHistoryList.m in Sources */, D8295DE01130E43900C838E8 /* PBGitHistoryGrapher.m in Sources */, D8E105471157C18200FC28A4 /* PBQLTextView.m in Sources */, + 31F8A75411C0D0F800517F78 /* blame.js in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index e96b87a..9af9c61 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -7,6 +7,7 @@ // #import +#import #import "PBGitCommit.h" #import "PBGitTree.h" #import "PBViewController.h" @@ -37,6 +38,9 @@ IBOutlet NSButton *allBranchesFilterItem; IBOutlet NSButton *localRemoteBranchesFilterItem; IBOutlet NSButton *selectedBranchFilterItem; + + IBOutlet WebView *webViewFileViwer; + IBOutlet NSSegmentedCell *displayControl; IBOutlet id webView; int selectedCommitDetailsIndex; @@ -89,4 +93,5 @@ - (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset; - (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset; +- (IBAction)updateFileViwer:(id)sender; @end diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index e9559c8..b3a1c88 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -79,6 +79,11 @@ //[scopeBarView setTopShade:207/255.0 bottomShade:180/255.0]; [self updateBranchFilterMatrix]; + NSString *path = [NSString stringWithFormat:@"html/views/%@", @"blame"]; + NSString* file = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path]; + NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:file]]; + [[webViewFileViwer mainFrame] loadRequest:request]; + [super awakeFromNib]; } @@ -211,6 +216,7 @@ if ([(NSString *)context isEqualToString: @"treeChange"]) { [self updateQuicklookForce: NO]; [self saveFileBrowserSelection]; + [self updateFileViwer:nil]; return; } @@ -688,4 +694,21 @@ return iconRect; } +- (IBAction)updateFileViwer:(id)sender +{ + + NSArray *objects = [treeController selectedObjects]; + NSArray *content = [treeController content]; + + if ([objects count] && [content count]) { + PBGitTree *treeItem = [objects objectAtIndex:0]; + currentFileBrowserSelectionPath = [treeItem.fullPath componentsSeparatedByString:@"/"]; + + id script = [webViewFileViwer windowScriptObject]; + + [script callWebScriptMethod:@"showFileBlame" + withArguments:[NSArray arrayWithObjects:[treeItem contents:[displayControl selectedSegment]], nil]]; + } + +} @end diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 8641614..799df17 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -2,10 +2,10 @@ 1050 - 10C540 + 10D573 762 - 1038.25 - 458.00 + 1038.29 + 460.00 YES @@ -21,7 +21,7 @@ YES - + YES @@ -111,7 +111,7 @@ 289 - {{805, 3}, {37, 25}} + {{848, 3}, {37, 25}} YES @@ -126,7 +126,7 @@ -2033958657 163 - + NSImage NSQuickLookTemplate @@ -297,7 +297,7 @@ 10 - {{0, -2}, {852, 5}} + {{0, -2}, {895, 5}} {0, 0} @@ -325,7 +325,7 @@ NO - {{0, 402}, {852, 30}} + {{0, 583}, {895, 30}} PBGitGradientBarView @@ -342,7 +342,7 @@ 10 - {{0, 143}, {852, 5}} + {{0, 116}, {895, 5}} {0, 0} @@ -374,13 +374,13 @@ 4352 - {852, 129} + {895, 102} YES 256 - {852, 17} + {895, 17} @@ -394,7 +394,7 @@ YES SubjectColumn - 549 + 592 40 1000 @@ -559,7 +559,7 @@ 0 - {{0, 17}, {852, 129}} + {{0, 17}, {895, 102}} @@ -592,7 +592,7 @@ YES - {852, 17} + {895, 17} @@ -601,7 +601,7 @@ - {852, 146} + {895, 119} 560 @@ -645,7 +645,7 @@ 265 - {{662, 2}, {180, 19}} + {{705, 2}, {180, 19}} YES @@ -745,12 +745,12 @@ - {{0, 146}, {852, 24}} + {{0, 119}, {895, 24}} PBGitGradientBarView - {852, 170} + {895, 143} NSView @@ -762,7 +762,7 @@ 18 - {852, 232} + {895, 440} YES @@ -797,12 +797,12 @@ public.url-name - {{1, 0}, {851, 233}} + {{1, 0}, {894, 441}} - + YES @@ -824,7 +824,7 @@ YES - {852, 232} + {895, 440} Details @@ -860,7 +860,7 @@ 4368 - {191, 232} + {159, 440} YES @@ -871,7 +871,7 @@ YES - 188 + 156 16 1000 @@ -914,7 +914,7 @@ 0 - {{1, 1}, {191, 232}} + {{1, 1}, {159, 440}} @@ -924,7 +924,7 @@ 256 - {{192, 1}, {15, 232}} + {{160, 1}, {15, 440}} _doScroller: @@ -942,7 +942,7 @@ 0.99801189999999995 - {208, 234} + {176, 442} 18 @@ -951,259 +951,139 @@ QSAAAEEgAABBmAAAQZgAAA - + - 4370 + 268 YES - - - 2304 - + + + 274 + YES - - - 2322 - {545, 120} - - - - - - Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Et harumd und lookum like Greek to me, dereud facilis est er expedit distinct. Nam liber te conscient to factor tum poen legum odioque civiuda - - - YES - - YES - NSFont - NSParagraphStyle - - - YES - - Monaco - 10 - 16 - - - 3 - - YES - - 0.0 - - - 56 - - - 112 - - - 168 - - - 224 - - - 280 - - - 336 - - - 392 - - - 448 - - - 504 - - - 560 - - - 616 - - - 672 - - - 728 - - - 784 - - - 840 - - - 896 - - - 952 - - - 1008 - - - 1064 - - - 1120 - - - 1176 - - - 1232 - - - 1288 - - - 1344 - - - 1400 - - - 1456 - - - 1512 - - - 1568 - - - 1624 - - - 1680 - - - 1736 - - - - - - - - - YES - - - 6 - - - - 545 - 1 - - - 11233 - 0 - - - - YES - - YES - NSBackgroundColor - NSColor - - - YES - - 6 - System - selectedTextBackgroundColor - - - - 6 - System - selectedTextColor - - - - - - - YES - - YES - NSColor - NSUnderline - - - YES - - 1 - MCAwIDEAA - - - - - - - 7 - {1186, 1e+07} - {0, 0} - + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name - {{1, 1}, {628, 232}} - - - - - - {4, -5} - 1 + {720, 411} + + + + + + YES + YES + + + + 266 + + YES + + + 289 + {{673, 3}, {37, 25}} + + YES + + -2080244224 + 134217728 + QuickLook + + + -2033958657 + 163 + + + + 400 + 75 + + + + + 292 + {{41, 3}, {118, 25}} + + YES + + -2080244224 + 0 + + + + YES + + Show + Detailed View + YES + 2 + + + Blame + Tree View + 9 + 2 + + + 2 + + + + + 10 + {{0, -2}, {720, 5}} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxMTkAA + + + 3 + 2 + 0 + NO + - 4 - - - - 256 - {{629, 1}, {15, 217}} - - - _doScroller: - 0.030031680000000002 - - - - -2147483392 - {{-100, -100}, {87, 18}} - - 1 - - _doScroller: - 1 - 0.94565220000000005 + {{0, 412}, {720, 30}} + + PBGitGradientBarView - {{209, 0}, {645, 234}} + {{177, 0}, {720, 442}} - - 18 - - - + NSView - {{-1, -1}, {854, 234}} + {{-1, -1}, {897, 442}} YES 2 - {852, 232} + {895, 440} Tree @@ -1222,18 +1102,18 @@ - {{0, 171}, {852, 232}} + {{0, 144}, {895, 440}} NSView - {852, 403} + {895, 584} 2 HistoryViewSplitView - {852, 432} + {895, 613} NSView @@ -1612,35 +1492,6 @@ 290 - - - value: selection.textContents - - - - - - value: selection.textContents - value - selection.textContents - - YES - - YES - NSAllowsEditingMultipleValuesSelection - NSConditionallySetsEditable - - - YES - - - - - 2 - - - 291 - predicate: filterPredicate @@ -1882,14 +1733,6 @@ 395 - - - controller - - - - 396 - enabled: selectedCommitDetailsIndex @@ -1906,6 +1749,54 @@ 398 + + + enabled: selectedCommitDetailsIndex + + + + + + enabled: selectedCommitDetailsIndex + enabled + selectedCommitDetailsIndex + 2 + + + 416 + + + + toggleQLPreviewPanel: + + + + 419 + + + + webViewFileViwer + + + + 425 + + + + displayControl + + + + 426 + + + + updateFileViwer: + + + + 429 + @@ -2155,23 +2046,11 @@ YES - + - - 11 - - - YES - - - - - - File Contents Scroll View - 10 @@ -2217,21 +2096,6 @@ - - 14 - - - - - 13 - - - - - 12 - - - 311 @@ -2426,6 +2290,66 @@ + + 399 + + + YES + + + + + + + 400 + + + YES + + + + + + File Show Control Toolbar + + + 401 + + + YES + + + + + + 402 + + + YES + + + + + + 408 + + + + + 414 + + + + + 415 + + + + + 424 + + + @@ -2434,11 +2358,6 @@ YES -3.IBPluginDependency 10.IBPluginDependency - 11.IBPluginDependency - 12.CustomClassName - 12.IBPluginDependency - 13.IBPluginDependency - 14.IBPluginDependency 15.CustomClassName 15.IBPluginDependency 16.IBPluginDependency @@ -2516,8 +2435,18 @@ 388.IBPluginDependency 39.IBPluginDependency 39.ImportedFromIB2 + 399.IBPluginDependency 4.IBAttributePlaceholdersKey 4.IBPluginDependency + 400.IBPluginDependency + 401.IBPluginDependency + 402.IBAttributePlaceholdersKey + 402.IBPluginDependency + 408.IBPluginDependency + 414.IBPluginDependency + 415.IBPluginDependency + 415.IBSegmentedControlInspectorSelectedSegmentMetadataKey + 424.IBPluginDependency 46.IBEditorWindowLastContentRect 46.IBPluginDependency 48.IBPluginDependency @@ -2534,11 +2463,6 @@ YES com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - PBQLTextView - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin PBQLOutlineView com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2678,6 +2602,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin YES @@ -2686,7 +2611,23 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{463, 486}, {852, 432}} + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + ToolTip + + ToolTip + + Quick Look + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.WebKitIBPlugin + {{178, 101}, {895, 613}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2722,7 +2663,7 @@ - 398 + 429 @@ -2803,6 +2744,7 @@ showCommitsFromTree: showInFinderAction: toggleQLPreviewPanel: + updateFileViwer: YES @@ -2821,6 +2763,7 @@ id id id + id @@ -2831,6 +2774,7 @@ cherryPickButton commitController commitList + displayControl fileBrowser historySplitView localRemoteBranchesFilterItem @@ -2843,6 +2787,7 @@ treeController upperToolbarView webView + webViewFileViwer YES @@ -2850,6 +2795,7 @@ NSButton NSArrayController NSTableView + NSSegmentedCell NSOutlineView PBCollapsibleSplitView NSButton @@ -2862,6 +2808,7 @@ NSTreeController PBGitGradientBarView id + WebView @@ -2918,18 +2865,6 @@ PBQLOutlineView.h - - PBQLTextView - NSTextView - - controller - PBGitHistoryController - - - IBProjectSource - PBQLTextView.h - - PBRefController NSObject @@ -3683,14 +3618,6 @@ NSControl - - NSText - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSText.h - - NSTextField NSControl @@ -3707,14 +3634,6 @@ AppKit.framework/Headers/NSTextFieldCell.h - - NSTextView - NSText - - IBFrameworkSource - AppKit.framework/Headers/NSTextView.h - - NSTreeController NSObjectController diff --git a/PBGitTree.h b/PBGitTree.h index d48ab6e..60a0b46 100644 --- a/PBGitTree.h +++ b/PBGitTree.h @@ -39,5 +39,6 @@ @property(readonly) NSArray* children; @property(readonly) NSString* fullPath; @property(readonly) NSString* contents; +- (NSString*) contents:(NSInteger)option; @end diff --git a/PBGitTree.m b/PBGitTree.m index 12c70a0..f353d9a 100644 --- a/PBGitTree.m +++ b/PBGitTree.m @@ -101,7 +101,7 @@ { if (!leaf) return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]]; - + if ([self isLocallyCached]) { NSData *data = [NSData dataWithContentsOfFile:localFileName]; NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; @@ -110,7 +110,19 @@ return string; } - return [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]]; + //return [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]]; + return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", self.path, nil]]; +} + +- (NSString*) contents:(NSInteger)option +{ + if (!leaf) + return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]]; + + if(option==0) + return [repository outputForArguments:[NSArray arrayWithObjects:@"show", [self refSpec], nil]]; + else + return [repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"blame", self.path, nil]]; } - (long long)fileSize diff --git a/html/views/blame/blame.js b/html/views/blame/blame.js new file mode 100644 index 0000000..f231700 --- /dev/null +++ b/html/views/blame/blame.js @@ -0,0 +1,5 @@ +var showFileBlame = function(txt) { + $("txt").style.display = ""; + $("txt").innerHTML="
"+txt+"
"; + return; +} diff --git a/html/views/blame/index.html b/html/views/blame/index.html new file mode 100644 index 0000000..2992ce2 --- /dev/null +++ b/html/views/blame/index.html @@ -0,0 +1,9 @@ + + + + + + +
hola
+ + \ No newline at end of file