RefController: Refactor ref menu to its own class

This commit is contained in:
Pieter de Bie
2008-11-01 23:16:41 +01:00
parent a9dad9dd31
commit 058fbcff58
5 changed files with 84 additions and 30 deletions
+6
View File
@@ -71,6 +71,7 @@
F5E92A230E88569500056E75 /* new_file.png in Resources */ = {isa = PBXBuildFile; fileRef = F5E92A220E88569500056E75 /* new_file.png */; };
F5EF8C8E0E9D4A5D0050906B /* PBWebController.m in Sources */ = {isa = PBXBuildFile; fileRef = F5EF8C8D0E9D4A5D0050906B /* PBWebController.m */; };
F5FC41F40EBCBD4300191D80 /* PBGitXProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */; };
F5FC43FE0EBD08EE00191D80 /* PBRefMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FC43FD0EBD08EE00191D80 /* PBRefMenuItem.m */; };
F5FE6C030EB13BC900F30D12 /* PBServicesController.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FE6C020EB13BC900F30D12 /* PBServicesController.m */; };
F5FF4E180E0829C20006317A /* PBGitRevList.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E170E0829C20006317A /* PBGitRevList.m */; };
F5FF4E7A0E082E440006317A /* PBGitGrapher.m in Sources */ = {isa = PBXBuildFile; fileRef = F5FF4E790E082E440006317A /* PBGitGrapher.m */; };
@@ -208,6 +209,8 @@
F5FC41F20EBCBD4300191D80 /* PBGitXProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitXProtocol.h; sourceTree = "<group>"; };
F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitXProtocol.m; sourceTree = "<group>"; };
F5FC43C30EBD050800191D80 /* PBRefContextDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRefContextDelegate.h; sourceTree = "<group>"; };
F5FC43FC0EBD08EE00191D80 /* PBRefMenuItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRefMenuItem.h; sourceTree = "<group>"; };
F5FC43FD0EBD08EE00191D80 /* PBRefMenuItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBRefMenuItem.m; sourceTree = "<group>"; };
F5FE6C010EB13BC900F30D12 /* PBServicesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBServicesController.h; sourceTree = "<group>"; };
F5FE6C020EB13BC900F30D12 /* PBServicesController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBServicesController.m; sourceTree = "<group>"; };
F5FF4E160E0829C20006317A /* PBGitRevList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevList.h; sourceTree = "<group>"; };
@@ -471,6 +474,8 @@
F56174550E058893001DCD79 /* PBGitTree.h */,
F56174560E058893001DCD79 /* PBGitTree.m */,
F5FC43C30EBD050800191D80 /* PBRefContextDelegate.h */,
F5FC43FC0EBD08EE00191D80 /* PBRefMenuItem.h */,
F5FC43FD0EBD08EE00191D80 /* PBRefMenuItem.m */,
);
name = History;
sourceTree = "<group>";
@@ -661,6 +666,7 @@
F50A41230EBB875D00208746 /* PBNiceSplitView.m in Sources */,
F5FC41F40EBCBD4300191D80 /* PBGitXProtocol.m in Sources */,
F574A2850EAE2EAC003F2CB1 /* PBRefController.m in Sources */,
F5FC43FE0EBD08EE00191D80 /* PBRefMenuItem.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
+11 -11
View File
@@ -2091,14 +2091,6 @@
</object>
<int key="connectionID">255</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">refController</string>
<reference key="source" ref="568231003"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">258</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
@@ -2107,6 +2099,14 @@
</object>
<int key="connectionID">259</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="568231003"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">260</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2947,7 +2947,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">259</int>
<int key="maxID">260</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3172,13 +3172,13 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>contextMenuDelegate</string>
<string>historyController</string>
<string>refController</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>PBGitHistoryController</string>
<string>PBRefController</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
+3 -19
View File
@@ -8,17 +8,7 @@
#import "PBRefController.h"
#import "PBGitRevisionCell.h"
@interface RefMenuItem : NSMenuItem
{
PBGitRef *ref;
PBGitCommit *commit;
}
@property (retain) PBGitCommit *commit;
@property (retain) PBGitRef *ref;
@end
@implementation RefMenuItem
@synthesize ref, commit;
@end
#import "PBRefMenuItem.h"
@implementation PBRefController
@@ -27,7 +17,7 @@
[commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]];
}
- (void) removeRef:(RefMenuItem *) sender
- (void) removeRef:(PBRefMenuItem *) sender
{
int ret = 1;
[historyController.repository outputForArguments:[NSArray arrayWithObjects:@"update-ref", @"-d", [[sender ref] ref], nil] retValue: &ret];
@@ -42,13 +32,7 @@
- (NSArray *) menuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit
{
RefMenuItem *item = [[RefMenuItem alloc] initWithTitle:@"Remove"
action:@selector(removeRef:)
keyEquivalent: @""];
[item setTarget: self];
[item setRef: ref];
[item setCommit:commit];
return [NSArray arrayWithObject: item];
return [PBRefMenuItem defaultMenuItemsForRef:ref commit:commit target:self];
}
# pragma mark Tableview delegate methods
+23
View File
@@ -0,0 +1,23 @@
//
// PBRefMenuItem.h
// GitX
//
// Created by Pieter de Bie on 01-11-08.
// Copyright 2008 Pieter de Bie. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "PBGitRef.h"
#import "PBGitCommit.h"
@interface PBRefMenuItem : NSMenuItem {
PBGitRef *ref;
PBGitCommit *commit;
}
@property (retain) PBGitCommit *commit;
@property (retain) PBGitRef *ref;
+ (NSArray *)defaultMenuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit target:(id)target;
@end
+41
View File
@@ -0,0 +1,41 @@
//
// PBRefMenuItem.m
// GitX
//
// Created by Pieter de Bie on 01-11-08.
// Copyright 2008 Pieter de Bie. All rights reserved.
//
#import "PBRefMenuItem.h"
@implementation PBRefMenuItem
@synthesize ref, commit;
+ (NSArray *)defaultMenuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit target:(id)target
{
NSMutableArray *array = [NSMutableArray array];
NSString *type = [ref type];
if ([type isEqualToString:@"remote"])
type = @"remote branch";
else if ([type isEqualToString:@"head"])
type = @"branch";
[array addObject:[[PBRefMenuItem alloc] initWithTitle:[@"Delete " stringByAppendingString:type]
action:@selector(removeRef:)
keyEquivalent: @""]];
[array addObject:[[PBRefMenuItem alloc] initWithTitle:[@"Checkout " stringByAppendingString:type]
action:@selector(checkoutRef:)
keyEquivalent: @""]];
for (PBRefMenuItem *item in array)
{
[item setTarget: target];
[item setRef: ref];
[item setCommit:commit];
}
return array;
}
@end