mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-16 21:41:18 +00:00
More capp_linting.
Reviewed by me.
This commit is contained in:
1 parent
2d1fd1b3a5
commit
0ab92c77bd
11 files changed
+260
-236
No files matched your search
@@ -6,19 +6,19 @@
|
||||
|
||||
- (void)testStringByReplacingOccurrencesOfStringWithString
|
||||
{
|
||||
var expectedString = @"hello world. A new world!";
|
||||
var dummyString = @"hello woold. A new woold!";
|
||||
var actualString = [dummyString stringByReplacingOccurrencesOfString:@"woold" withString:@"world"];
|
||||
[self assertTrue:(expectedString === actualString)
|
||||
var expectedString = @"hello world. A new world!",
|
||||
dummyString = @"hello woold. A new woold!",
|
||||
actualString = [dummyString stringByReplacingOccurrencesOfString:@"woold" withString:@"world"];
|
||||
|
||||
[self assertTrue:(expectedString === actualString)
|
||||
message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString];
|
||||
|
||||
}
|
||||
|
||||
- (void)testStringByReplacingWithRegexCharacters
|
||||
{
|
||||
var stringToTest = "${foo} {foo}",
|
||||
result = [stringToTest stringByReplacingOccurrencesOfString:"${foo}" withString:"BAR"];
|
||||
|
||||
|
||||
[self assert:result equals:"BAR {foo}"];
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
expectedString = "2 X 3 = 6",
|
||||
dummyString = @"",
|
||||
actualString = [dummyString stringByAppendingFormat:format, 2, 3, 6];
|
||||
|
||||
[self assertTrue:(expectedString === actualString)
|
||||
|
||||
[self assertTrue:(expectedString === actualString)
|
||||
message:"stringByAppendingFormat: expected:" + expectedString + " actual:" + actualString];
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
[self assert:"42" equals:str];
|
||||
|
||||
str = [[CPString alloc] initWithFormat:"%f", 42.2];
|
||||
[self assert:"42.2" equals:str];
|
||||
[self assert:"42.2" equals:str];
|
||||
}
|
||||
|
||||
- (void)testStringWithFormat
|
||||
@@ -70,7 +70,7 @@
|
||||
[self assert:"42" equals:str];
|
||||
|
||||
str = [CPString stringWithFormat:"%f", 42.2];
|
||||
[self assert:"42.2" equals:str];
|
||||
[self assert:"42.2" equals:str];
|
||||
}
|
||||
|
||||
- (void)testLength
|
||||
@@ -97,16 +97,16 @@
|
||||
|
||||
- (void)testStringByPaddingToLength
|
||||
{
|
||||
[self assert:"onebcd"
|
||||
equals:["one" stringByPaddingToLength:6
|
||||
withString:"abcdefg"
|
||||
startingAtIndex:1]];
|
||||
[self assert:"onebcd"
|
||||
equals:["one" stringByPaddingToLength:6
|
||||
withString:"abcdefg"
|
||||
startingAtIndex:1]];
|
||||
}
|
||||
|
||||
- (void)testComponentsSeparatedByString
|
||||
{
|
||||
[self assert:["arash", "francisco", "ross", "tom"]
|
||||
equals:["arash.francisco.ross.tom" componentsSeparatedByString:"."]];
|
||||
equals:["arash.francisco.ross.tom" componentsSeparatedByString:"."]];
|
||||
}
|
||||
|
||||
- (void)testSubstringFromIndex
|
||||
@@ -146,9 +146,9 @@
|
||||
[" -N00", NO],
|
||||
[" 00", NO],
|
||||
[" -00", NO],
|
||||
[" -+001", NO],
|
||||
[" -+001", NO],
|
||||
];
|
||||
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++)
|
||||
[self assert:[testStrings[i][0] boolValue] equals:testStrings[i][1]];
|
||||
}
|
||||
@@ -161,14 +161,14 @@
|
||||
["Abcd", "Abcd", "Abcd"],
|
||||
["A long string", "A longer string", "A long"]
|
||||
];
|
||||
|
||||
|
||||
var testStringsCaseless = [
|
||||
["hElLo", "HeLiCoPtEr", "hEl"],
|
||||
["tEsTeR", "TaSeR", "t"],
|
||||
["aBcD", "AbCd", "aBcD"],
|
||||
["a LoNg StRiNg", "A lOnGeR sTrInG", "a LoNg"]
|
||||
];
|
||||
|
||||
|
||||
for (var i = 0; i < testStringsCase.length; i++)
|
||||
[self assert: [testStringsCase[i][0] commonPrefixWithString:testStringsCase[i][1]]
|
||||
equals: testStringsCase[i][2]];
|
||||
@@ -187,9 +187,9 @@
|
||||
[" monkey-Cow", " Monkey-cow"],
|
||||
["tHe QuicK bRowN-Fox JumPed_Over +the LaZy%dog", "The Quick Brown-fox Jumped_over +the Lazy%dog"]
|
||||
];
|
||||
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++)
|
||||
[self assert:[testStrings[i][0] capitalizedString] equals:testStrings[i][1]];
|
||||
[self assert:[testStrings[i][0] capitalizedString] equals:testStrings[i][1]];
|
||||
}
|
||||
|
||||
- (void)testUppercaseString
|
||||
@@ -197,7 +197,7 @@
|
||||
var str = "This is a test";
|
||||
[self assert:[str uppercaseString] equals:"THIS IS A TEST"];
|
||||
}
|
||||
|
||||
|
||||
- (void)testLowercaseString
|
||||
{
|
||||
var str = "This Is A TEST";
|
||||
@@ -240,9 +240,11 @@
|
||||
["tmp/scratch", ["tmp", "scratch"]],
|
||||
["/tmp/scratch", ["/", "tmp", "scratch"]]
|
||||
]
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++) {
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++)
|
||||
{
|
||||
var result = [testStrings[i][0] pathComponents];
|
||||
|
||||
[self assertTrue:[result isEqualToArray:testStrings[i][1]] message:"Expected [" + testStrings[i][1] + "] was [" + result + "]"];
|
||||
}
|
||||
}
|
||||
@@ -256,7 +258,7 @@
|
||||
["scratch", "scratch"],
|
||||
["/", "/"]
|
||||
];
|
||||
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++)
|
||||
[self assert:testStrings[i][1] equals:[testStrings[i][0] lastPathComponent]];
|
||||
}
|
||||
@@ -270,7 +272,7 @@
|
||||
["/tmp", ""],
|
||||
["scratch", ""],
|
||||
];
|
||||
|
||||
|
||||
for (var i = 0; i < testStrings.length; i++)
|
||||
[self assert:testStrings[i][1] equals:[testStrings[i][0] pathExtension]];
|
||||
}
|
||||
@@ -316,40 +318,40 @@
|
||||
|
||||
- (void)testComponentsSeparatedByCharactersInSetEmptyString
|
||||
{
|
||||
[self assert:[""]
|
||||
equals:["" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
[self assert:[""]
|
||||
equals:["" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
}
|
||||
|
||||
- (void)testComponentsSeparatedByCharactersInSetStringWithoutCharactersFromSet
|
||||
{
|
||||
[self assert:["Abradab"]
|
||||
equals:["Abradab" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
[self assert:["Abradab"]
|
||||
equals:["Abradab" componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
}
|
||||
|
||||
- (void)testComponentsSeparatedByCharactersInSet
|
||||
{
|
||||
[self assert:["Baku", "baku", "to", "jest", "", "skład."]
|
||||
equals:["Baku baku to jest skład." componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
[self assert:["Baku", "baku", "to", "jest", "", "skład."]
|
||||
equals:["Baku baku to jest skład." componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
}
|
||||
|
||||
- (void)testComponentsSeparatedByCharactersInSetLeadingAndTrailingCharacterFromSet
|
||||
{
|
||||
[self assert:["", "Test", ""]
|
||||
equals:[" Test " componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
[self assert:["", "Test", ""]
|
||||
equals:[" Test " componentsSeparatedByCharactersInSet:[CPCharacterSet whitespaceCharacterSet]]];
|
||||
}
|
||||
|
||||
- (void)testComponentsSeparatedByCharactersExceptionRaiseOnNilSeparator
|
||||
- (void)testComponentsSeparatedByCharactersExceptionRaiseOnNilSeparator
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
[[CPString string] componentsSeparatedByCharactersInSet:nil];
|
||||
[self assert:false];
|
||||
[self assert:false];
|
||||
}
|
||||
catch (anException)
|
||||
{
|
||||
[self assert:[anException name] equals:CPInvalidArgumentException];
|
||||
{
|
||||
[self assert:[anException name] equals:CPInvalidArgumentException];
|
||||
[self assert:[anException reason] equals:@"componentsSeparatedByCharactersInSet: the separator can't be 'nil'"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testIsEqual
|
||||
|
||||
@@ -2,32 +2,32 @@
|
||||
|
||||
@implementation MyDict : CPDictionary
|
||||
{
|
||||
int a;
|
||||
int a;
|
||||
}
|
||||
|
||||
+ (id)alloc
|
||||
{
|
||||
return class_createInstance(self);
|
||||
return class_createInstance(self);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if(self)
|
||||
{
|
||||
_a = "Bob";
|
||||
}
|
||||
return self;
|
||||
self = [super init];
|
||||
|
||||
if(self)
|
||||
_a = "Bob";
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPString)secondaryName
|
||||
{
|
||||
return "Saget";
|
||||
return "Saget";
|
||||
}
|
||||
|
||||
- (CPString)name
|
||||
{
|
||||
return _a;
|
||||
return _a;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -37,26 +37,30 @@
|
||||
|
||||
- (void)testThatMyDictContainsReplacedNameSelector
|
||||
{
|
||||
var target = [[MyDict alloc] init];
|
||||
[OJAssert assert:@"Bob" equals:[target name]];
|
||||
var target = [[MyDict alloc] init];
|
||||
|
||||
[OJAssert assert:@"Bob" equals:[target name]];
|
||||
}
|
||||
|
||||
- (void)testThatMyDictDoesHaveNewSelector
|
||||
{
|
||||
var target = [[MyDict alloc] init];
|
||||
[OJAssert assert:@"Saget" equals:[target secondaryName]];
|
||||
var target = [[MyDict alloc] init];
|
||||
|
||||
[OJAssert assert:@"Saget" equals:[target secondaryName]];
|
||||
}
|
||||
|
||||
- (void)testThatDictionaryDoesNotHaveReplacedName
|
||||
{
|
||||
var target = [[CPDictionary alloc] init];
|
||||
[OJAssert assert:@"Bob" notEqual:[target name]];
|
||||
var target = [[CPDictionary alloc] init];
|
||||
|
||||
[OJAssert assert:@"Bob" notEqual:[target name]];
|
||||
}
|
||||
|
||||
- (void)testThatTollFreeDoesNotHaveNewSelector
|
||||
{
|
||||
var target = {};
|
||||
[OJAssert assertThrows:function() { [target secondaryName]; }];
|
||||
var target = {};
|
||||
|
||||
[OJAssert assertThrows:function() { [target secondaryName]; }];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -15,7 +15,6 @@ var exampleProtocol = "http",
|
||||
|
||||
@implementation CPURLTest : OJTestCase
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)testAbsolute
|
||||
@@ -23,17 +22,17 @@ var exampleProtocol = "http",
|
||||
var pathString = exampleFullPath,
|
||||
urlString = exampleURL,
|
||||
url = [CPURL URLWithString:urlString];
|
||||
|
||||
|
||||
[self assert:[url baseURL] equals:nil];
|
||||
|
||||
|
||||
[self assert:[url relativeString] equals:urlString];
|
||||
[self assert:[url absoluteString] equals:urlString];
|
||||
|
||||
|
||||
[self assert:[url relativePath] equals:pathString];
|
||||
[self assert:[url path] equals:pathString];
|
||||
|
||||
|
||||
[self assert:[url absoluteURL] same:url];
|
||||
|
||||
|
||||
[self assert:[url scheme] equals:exampleProtocol];
|
||||
[self assert:[url user] equals:exampleUser];
|
||||
[self assert:[url password] equals:examplePassword];
|
||||
@@ -41,7 +40,7 @@ var exampleProtocol = "http",
|
||||
[self assert:[url port] equals:examplePort];
|
||||
[self assert:[url parameterString] equals:exampleQuery];
|
||||
[self assert:[url fragment] equals:exampleAnchor];
|
||||
|
||||
|
||||
[self assert:[url pathExtension] equals:"php"];
|
||||
[self assert:[url lastPathComponent] equals:examplePathRelative];
|
||||
}
|
||||
@@ -55,13 +54,13 @@ var exampleProtocol = "http",
|
||||
url = [CPURL URLWithString:urlString relativeToURL:baseURL];
|
||||
|
||||
[self assert:[url baseURL] equals:baseURL];
|
||||
|
||||
|
||||
[self assert:[url relativeString] equals:urlString];
|
||||
[self assert:[url absoluteString] equals:exampleURL];
|
||||
|
||||
[self assert:[url relativePath] equals:pathString];
|
||||
[self assert:[url path] equals:exampleFullPath];
|
||||
|
||||
|
||||
[self assert:[url absoluteURL] notSame:url];
|
||||
|
||||
[self assert:[url scheme] equals:exampleProtocol];
|
||||
@@ -102,7 +101,6 @@ var exampleProtocol = "http",
|
||||
|
||||
[self assert:[url pathExtension] equals:"php"];
|
||||
[self assert:[url lastPathComponent] equals:examplePathRelative];
|
||||
|
||||
}
|
||||
|
||||
- (void)testURLToString
|
||||
|
||||
@@ -16,7 +16,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
@implementation Menu : CPObject
|
||||
{
|
||||
Menu _menu @accessors(property=menu);
|
||||
|
||||
|
||||
CPString _title @accessors(property=title);
|
||||
CPArray _children @accessors(property=children);
|
||||
}
|
||||
@@ -43,7 +43,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
_title = theTitle;
|
||||
[self setChildren:theChildren];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -55,35 +55,31 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
- (void)insertSubmenu:(Menu)theItem atIndex:(int)theIndex
|
||||
{
|
||||
// CPLog.debug(@"insert menu: %@ in menu: %@ at index: %i", theItem, self, theIndex);
|
||||
|
||||
|
||||
if ([[self children] containsObject:theItem])
|
||||
return;
|
||||
|
||||
|
||||
if ([theItem menu])
|
||||
[theItem removeFromMenu];
|
||||
|
||||
|
||||
[theItem setMenu:self];
|
||||
|
||||
if (theIndex === -1)
|
||||
{
|
||||
[[self children] addObject:theItem];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self children] insertObject:theItem atIndex:theIndex];
|
||||
}
|
||||
|
||||
[[self children] insertObject:theItem atIndex:theIndex];
|
||||
|
||||
// CPLog.debug(@"%@ children: %@", self, [self children]);
|
||||
}
|
||||
|
||||
- (void)removeFromMenu
|
||||
{
|
||||
// CPLog.debug(@"remove menu: %@ from menu: %@", self, [self menu]);
|
||||
|
||||
|
||||
[[[self menu] children] removeObject:self];
|
||||
|
||||
|
||||
CPLog.debug([[self menu] children]);
|
||||
|
||||
|
||||
[self setMenu:nil];
|
||||
}
|
||||
|
||||
@@ -91,10 +87,10 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theChildren === nil)
|
||||
theChildren = [];
|
||||
|
||||
|
||||
if (_children === theChildren)
|
||||
return;
|
||||
|
||||
|
||||
var childIndex = [theChildren count];
|
||||
while (childIndex--)
|
||||
{
|
||||
@@ -113,7 +109,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
_title = [theCoder decodeObjectForKey:@"MenuTitleKey"];
|
||||
[self setChildren:[theCoder decodeObjectForKey:@"MenuChildrenKey"]];
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -130,7 +126,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
Menu _menu @accessors(property=menu);
|
||||
CPOutlineView _outlineView;
|
||||
|
||||
|
||||
CPArray _draggedItems;
|
||||
}
|
||||
|
||||
@@ -187,26 +183,25 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
// ]]
|
||||
// ]]
|
||||
]];
|
||||
|
||||
|
||||
var scrollView = [[CPScrollView alloc] initWithFrame:[contentView bounds]];
|
||||
|
||||
|
||||
|
||||
_outlineView = [[CPOutlineView alloc] initWithFrame:[contentView bounds]];
|
||||
|
||||
|
||||
var column = [[CPTableColumn alloc] initWithIdentifier:@"One"];
|
||||
[_outlineView addTableColumn:column];
|
||||
[_outlineView setOutlineTableColumn:column];
|
||||
|
||||
|
||||
[_outlineView addTableColumn:[[CPTableColumn alloc] initWithIdentifier:@"Two"]];
|
||||
|
||||
[_outlineView registerForDraggedTypes:[CustomOutlineViewDragType]];
|
||||
|
||||
|
||||
[_outlineView setDataSource:self];
|
||||
[_outlineView setAllowsMultipleSelection:YES];
|
||||
[_outlineView expandItem:nil expandChildren:YES];
|
||||
// [_outlineView setRowHeight:50.0];
|
||||
// [_outlineView setRowHeight:50.0];
|
||||
// [_outlineView setIntercellSpacing:CPSizeMake(0.0, 10.0)]
|
||||
|
||||
|
||||
[scrollView setDocumentView:_outlineView];
|
||||
[theWindow setContentView:scrollView];
|
||||
|
||||
@@ -221,9 +216,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
|
||||
// CPLog.debug(@"child: %i ofItem:%@ : %@", theIndex, theItem, [[theItem children] objectAtIndex:theIndex]);
|
||||
|
||||
|
||||
return [[theItem children] objectAtIndex:theIndex];
|
||||
}
|
||||
|
||||
@@ -231,9 +226,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
|
||||
// CPLog.debug(@"isItemExpandable:%@ : %@", theItem, [[theItem children] count] > 0);
|
||||
|
||||
|
||||
return [[theItem children] count] > 0;
|
||||
}
|
||||
|
||||
@@ -241,9 +236,9 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
|
||||
// CPLog.debug(@"numberOfChildrenOfItem:%@ : %i", theItem, [[theItem children] count]);
|
||||
|
||||
|
||||
return [[theItem children] count];
|
||||
}
|
||||
|
||||
@@ -251,31 +246,31 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
// if ([theColumn identifier] === @"Two")
|
||||
// return @"Two";
|
||||
|
||||
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
|
||||
// CPLog.debug(@"objectValueForTableColumn:%@ byItem:%@ : %@", theColumn, theItem, [theItem title]);
|
||||
|
||||
|
||||
return [theItem title];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(CPOutlineView)anOutlineView writeItems:(CPArray)theItems toPasteboard:(CPPasteBoard)thePasteBoard
|
||||
{
|
||||
_draggedItems = theItems;
|
||||
[thePasteBoard declareTypes:[CustomOutlineViewDragType] owner:self];
|
||||
[thePasteBoard declareTypes:[CustomOutlineViewDragType] owner:self];
|
||||
[thePasteBoard setData:[CPKeyedArchiver archivedDataWithRootObject:theItems] forType:CustomOutlineViewDragType];
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id < CPDraggingInfo >)theInfo proposedItem:(id)theItem proposedChildIndex:(int)theIndex
|
||||
{
|
||||
CPLog.debug(@"validate item: %@ at index: %i", theItem, theIndex);
|
||||
|
||||
|
||||
if (theItem === nil)
|
||||
[anOutlineView setDropItem:nil dropChildIndex:theIndex];
|
||||
|
||||
|
||||
[anOutlineView setDropItem:theItem dropChildIndex:theIndex];
|
||||
|
||||
return CPDragOperationEvery;
|
||||
@@ -285,16 +280,17 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
|
||||
// CPLog.debug(@"drop item: %@ at index: %i", theItem, theIndex);
|
||||
|
||||
|
||||
var menuIndex = [_draggedItems count];
|
||||
|
||||
while (menuIndex--)
|
||||
{
|
||||
var menu = [_draggedItems objectAtIndex:menuIndex];
|
||||
|
||||
|
||||
// CPLog.debug(@"move item: %@ to: %@ index: %@", menu, theItem, theIndex);
|
||||
|
||||
|
||||
if (menu === theItem)
|
||||
continue;
|
||||
|
||||
@@ -302,7 +298,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
[theItem insertSubmenu:menu atIndex:theIndex];
|
||||
theIndex += 1;
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,16 +15,16 @@ var categories = ["firstName","lastName"],
|
||||
CPTextField predicateField;
|
||||
|
||||
CPSearchField searchField;
|
||||
CPMenu searchMenuTemplate;
|
||||
CPMenu searchMenuTemplate;
|
||||
|
||||
CPArray searchCategoryIndexes;
|
||||
CPInteger searchCategoryIndex;
|
||||
CPArray searchCategoryIndexes;
|
||||
CPInteger searchCategoryIndex;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
searchCategoryIndex = 0;
|
||||
searchCategoryIndexes = [CPArray arrayWithArray:[1, 2]];
|
||||
searchCategoryIndex = 0;
|
||||
searchCategoryIndexes = [CPArray arrayWithArray:[1, 2]];
|
||||
|
||||
searchField = [[CPSearchField alloc] initWithFrame:CPMakeRect(30,72,150,30)];
|
||||
|
||||
@@ -75,7 +75,7 @@ var categories = ["firstName","lastName"],
|
||||
[self updateFilter:searchField];
|
||||
|
||||
[theWindow center];
|
||||
[theWindow orderFront:self];
|
||||
[theWindow orderFront:self];
|
||||
}
|
||||
|
||||
- (void)awakeFromCib
|
||||
@@ -105,24 +105,24 @@ var categories = ["firstName","lastName"],
|
||||
- (void)_updateSearchMenuTemplate
|
||||
{
|
||||
for (var i = 0; i < searchCategoryIndexes.length; ++i)
|
||||
[[searchMenuTemplate itemAtIndex:i + 1] setState:CPOffState];
|
||||
[[searchMenuTemplate itemAtIndex:i + 1] setState:CPOffState];
|
||||
|
||||
[[searchMenuTemplate itemAtIndex:searchCategoryIndex + 1] setState:CPOnState];
|
||||
[[searchMenuTemplate itemAtIndex:searchCategoryIndex + 1] setState:CPOnState];
|
||||
[searchField setSearchMenuTemplate:searchMenuTemplate];
|
||||
}
|
||||
|
||||
- (void)updateFilter:(id)sender
|
||||
{
|
||||
var searchString = [sender stringValue];
|
||||
[self filteredArrayWithString:searchString];
|
||||
var searchString = [sender stringValue];
|
||||
[self filteredArrayWithString:searchString];
|
||||
}
|
||||
|
||||
- (void)filteredArrayWithString:(CPString)value
|
||||
{
|
||||
var keyPath = categories[searchCategoryIndex],
|
||||
predicate = [CPPredicate predicateWithFormat:@"%K CONTAINS %@", keyPath, value];
|
||||
var keyPath = categories[searchCategoryIndex],
|
||||
predicate = [CPPredicate predicateWithFormat:@"%K CONTAINS %@", keyPath, value];
|
||||
|
||||
[predicateField setStringValue:[predicate predicateFormat]];
|
||||
[predicateField setStringValue:[predicate predicateFormat]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -28,7 +28,6 @@
|
||||
[tableView setDelegate:self];
|
||||
[tableView setDataSource:self];
|
||||
|
||||
|
||||
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
|
||||
[iconView setImageScaling:CPScaleNone];
|
||||
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
|
||||
@@ -48,15 +47,15 @@
|
||||
|
||||
[column setMaxWidth:500.0];
|
||||
[column setWidth:200.0];
|
||||
|
||||
|
||||
[tableView addTableColumn:column];
|
||||
}
|
||||
|
||||
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)];
|
||||
|
||||
|
||||
[scrollView setDocumentView:tableView];
|
||||
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
|
||||
[contentView addSubview:scrollView];
|
||||
|
||||
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)];
|
||||
@@ -69,7 +68,6 @@
|
||||
[tableView setDelegate:self];
|
||||
[tableView setDataSource:self];
|
||||
|
||||
|
||||
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
|
||||
[iconView setImageScaling:CPScaleNone];
|
||||
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
|
||||
@@ -89,15 +87,15 @@
|
||||
|
||||
[column setMaxWidth:500.0];
|
||||
[column setWidth:200.0];
|
||||
|
||||
|
||||
[tableView addTableColumn:column];
|
||||
}
|
||||
|
||||
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight([contentView bounds]) / 2, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)];
|
||||
|
||||
|
||||
[scrollView setDocumentView:tableView];
|
||||
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
|
||||
[contentView addSubview:scrollView];
|
||||
|
||||
[theWindow orderFront:self];
|
||||
@@ -113,7 +111,7 @@
|
||||
{
|
||||
if ([aColumn identifier] === "icons")
|
||||
return iconImage;
|
||||
|
||||
|
||||
return aRow;
|
||||
}
|
||||
|
||||
@@ -121,7 +119,7 @@
|
||||
{
|
||||
var groups = [];
|
||||
|
||||
for(var i = 0; i < 100; i+=5)
|
||||
for(var i = 0; i < 100; i += 5)
|
||||
groups.push(i);
|
||||
|
||||
return [groups containsObject:aRow];
|
||||
|
||||
@@ -16,16 +16,15 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
|
||||
dataSet1 = [],
|
||||
dataSet2 = [],
|
||||
dataSet3 = [];
|
||||
|
||||
for(var i = 1; i < 10; i++)
|
||||
|
||||
for (var i = 1; i < 10; i++)
|
||||
{
|
||||
dataSet1[i - 1] = [CPNumber numberWithInt:i];
|
||||
dataSet2[i - 1] = [CPNumber numberWithInt:i+10];
|
||||
dataSet3[i - 1] = [CPNumber numberWithInt:i+20];
|
||||
dataSet2[i - 1] = [CPNumber numberWithInt:i + 10];
|
||||
dataSet3[i - 1] = [CPNumber numberWithInt:i + 20];
|
||||
}
|
||||
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,700,500) styleMask:CPClosableWindowMask],
|
||||
@@ -37,7 +36,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView setAllowsColumnSelection:YES];
|
||||
[tableView setUsesAlternatingRowBackgroundColors:YES];
|
||||
[tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]];
|
||||
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
|
||||
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
|
||||
[tableView setVerticalMotionCanBeginDrag:NO];
|
||||
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
|
||||
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
|
||||
@@ -46,7 +45,6 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView setSelectionHighlightColor:[CPColor redColor]];
|
||||
[tableView setDataSource:self];
|
||||
|
||||
|
||||
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
|
||||
[iconView setImageScaling:CPScaleNone];
|
||||
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
|
||||
@@ -67,7 +65,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[column setMinWidth:50.0];
|
||||
[column setMaxWidth:500.0];
|
||||
[column setWidth:75.0];
|
||||
|
||||
|
||||
[column setEditable:YES];
|
||||
[tableView addTableColumn:column];
|
||||
|
||||
@@ -78,10 +76,10 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
// we offset this scrollview to make sure all the coordinates are calculated correctly
|
||||
// bad things can happen when the tableview doesn't sit at (0,0)
|
||||
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(200, 50, CGRectGetWidth([contentView bounds]) - 200, CGRectGetHeight([contentView bounds]) -200)];
|
||||
|
||||
|
||||
[scrollView setDocumentView:tableView];
|
||||
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
|
||||
[contentView addSubview:scrollView];
|
||||
|
||||
[theWindow orderFront:self];
|
||||
@@ -176,7 +174,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
{
|
||||
|
||||
var window2 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
|
||||
|
||||
|
||||
tableView2 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];
|
||||
|
||||
[tableView2 setAllowsMultipleSelection:YES];
|
||||
@@ -202,11 +200,11 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[column setSortDescriptorPrototype:desc];
|
||||
[[column headerView] setStringValue:"Number "+i];
|
||||
|
||||
[column setWidth:i*75];
|
||||
[column setWidth:i * 75];
|
||||
[column setMinWidth:50.0];
|
||||
|
||||
[column setEditable:YES];
|
||||
|
||||
|
||||
[tableView2 addTableColumn:column];
|
||||
}
|
||||
|
||||
@@ -216,19 +214,18 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[tableView2 setRowHeight:32.0];
|
||||
[scrollView setDocumentView:tableView2];
|
||||
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
|
||||
[[window2 contentView] addSubview:scrollView];
|
||||
|
||||
//[scrollView setAutohidesScrollers:YES];
|
||||
|
||||
|
||||
[window2 orderFront:self];
|
||||
}
|
||||
|
||||
- (void)sourceList
|
||||
{
|
||||
var window3 = [[CPWindow alloc] initWithContentRect:CGRectMake(450, 250, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask];
|
||||
|
||||
|
||||
tableView3 = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 200.0, 500.0)];
|
||||
|
||||
[tableView3 setAllowsMultipleSelection:NO];
|
||||
@@ -247,7 +244,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[column setMinWidth:50.0];
|
||||
[column setEditable:YES];
|
||||
[tableView3 addTableColumn:column];
|
||||
|
||||
|
||||
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist2"];
|
||||
[[column headerView] setStringValue:"Source List 2"];
|
||||
[tableView3 addTableColumn:column];
|
||||
@@ -257,25 +254,25 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[scrollView3 setDocumentView:tableView3];
|
||||
[scrollView3 setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
||||
|
||||
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0/255.0, 153.0/255.0, 209.0/255.0,1.0, 33.0/255.0, 94.0/255.0, 208.0/255.0,1.0], [0,1], 2),
|
||||
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(123.0/255.0) blue:(218.0/255.0) alpha:1.0],
|
||||
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0/255.0) green:(92.0/255.0) blue:(207.0/255.0) alpha:1.0];
|
||||
var sourceListActiveGradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [255.0 / 255.0, 153.0 / 255.0, 209.0 / 255.0, 1.0, 33.0 / 255.0, 94.0 / 255.0, 208.0 / 255.0, 1.0], [0, 1], 2),
|
||||
sourceListActiveTopLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(123.0 / 255.0) blue:(218.0 / 255.0) alpha:1.0],
|
||||
sourceListActiveBottomLineColor = [CPColor colorWithCalibratedRed:(255.0 / 255.0) green:(92.0 / 255.0) blue:(207.0 / 255.0) alpha:1.0];
|
||||
[tableView3 setSelectionGradientColors:[CPDictionary dictionaryWithObjects:[sourceListActiveGradient, sourceListActiveTopLineColor, sourceListActiveBottomLineColor] forKeys:[CPSourceListGradient, CPSourceListTopLineColor, CPSourceListBottomLineColor]]];
|
||||
|
||||
|
||||
[[window3 contentView] addSubview:scrollView3];
|
||||
|
||||
[scrollView3 setAutohidesScrollers:YES];
|
||||
|
||||
[window3 orderFront:self];
|
||||
|
||||
[window3 orderFront:self];
|
||||
}
|
||||
|
||||
- (int)numberOfRowsInTableView:(CPTableView)atableView
|
||||
{
|
||||
if(atableView === tableView)
|
||||
if (atableView === tableView)
|
||||
return dataSet1.length;
|
||||
else if(atableView === tableView2)
|
||||
else if (atableView === tableView2)
|
||||
return dataSet2.length;
|
||||
else if(atableView === tableView3)
|
||||
else if (atableView === tableView3)
|
||||
return dataSet3.length;
|
||||
}
|
||||
|
||||
@@ -283,21 +280,21 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
{
|
||||
if ([aColumn identifier] === "icons")
|
||||
return iconImage;
|
||||
|
||||
|
||||
if (aTableView === tableView)
|
||||
return String(dataSet1[aRow]* ([[aTableView tableColumns] indexOfObject:aColumn] + 1));
|
||||
return String(dataSet1[aRow] * ([[aTableView tableColumns] indexOfObject:aColumn] + 1));
|
||||
else if (aTableView === tableView2)
|
||||
return String(dataSet2[aRow]);
|
||||
else if(aTableView === tableView3)
|
||||
else if (aTableView === tableView3)
|
||||
return String(dataSet3[aRow]);
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
{
|
||||
//CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
|
||||
|
||||
var newDescriptors = [aTableView sortDescriptors];
|
||||
|
||||
|
||||
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
|
||||
[aTableView reloadData];
|
||||
}
|
||||
@@ -341,7 +338,7 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
}
|
||||
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
if(aTableView === tableView3)
|
||||
if (aTableView === tableView3)
|
||||
return YES;
|
||||
else
|
||||
return NO;
|
||||
@@ -349,21 +346,21 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView willDisplayView:(CPView)aView forTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
//CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
|
||||
//CPLogConsole(_cmd + " column: " + [tableColumn identifier] + " row:" + row)
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView setObjectValue:(id)aValue forTableColumn:(CPTableColumn)tableColumn row:(int)row
|
||||
{
|
||||
if(aTableView === tableView3)
|
||||
if (aTableView === tableView3)
|
||||
dataSet3[row] = aValue;
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
|
||||
{
|
||||
//CPLogConsole(_cmd + [oldDescriptors description]);
|
||||
|
||||
|
||||
var newDescriptors = [aTableView sortDescriptors];
|
||||
|
||||
|
||||
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
|
||||
[aTableView reloadData];
|
||||
}
|
||||
@@ -374,57 +371,57 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
return NO;
|
||||
|
||||
var data = [rowIndexes, [aTableView UID]];
|
||||
|
||||
|
||||
var encodedData = [CPKeyedArchiver archivedDataWithRootObject:data];
|
||||
[pboard declareTypes:[CPArray arrayWithObject:tableTestDragType] owner:self];
|
||||
[pboard setData:encodedData forType:tableTestDragType];
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView
|
||||
validateDrop:(id)info
|
||||
proposedRow:(CPInteger)row
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView
|
||||
validateDrop:(id)info
|
||||
proposedRow:(CPInteger)row
|
||||
proposedDropOperation:(CPTableViewDropOperation)operation
|
||||
{
|
||||
|
||||
[[aTableView window] orderFront:nil];
|
||||
|
||||
if(aTableView === tableView)
|
||||
if (aTableView === tableView)
|
||||
[aTableView setDropRow:row dropOperation:CPTableViewDropOn];
|
||||
else
|
||||
else
|
||||
[aTableView setDropRow:row dropOperation:CPTableViewDropAbove];
|
||||
|
||||
|
||||
return CPDragOperationMove;
|
||||
}
|
||||
|
||||
- (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id)info row:(int)row dropOperation:(CPTableViewDropOperation)operation
|
||||
{
|
||||
{
|
||||
var pboard = [info draggingPasteboard],
|
||||
rowData = [pboard dataForType:tableTestDragType],
|
||||
tables = [tableView, tableView2],
|
||||
dataSets = [dataSet1, dataSet2];
|
||||
|
||||
dataSets = [dataSet1, dataSet2];
|
||||
|
||||
rowData = [CPKeyedUnarchiver unarchiveObjectWithData:rowData];
|
||||
|
||||
|
||||
var sourceIndexes = rowData[0],
|
||||
sourceTableUID = rowData[1];
|
||||
|
||||
|
||||
var index = (aTableView == tableView) ? 1 : 0;
|
||||
|
||||
|
||||
var destinationTable = tables[1 - index],
|
||||
sourceTable = tables[index],
|
||||
destinationDataSet = dataSets[1 - index],
|
||||
sourceDataSet = dataSets[index];
|
||||
|
||||
if(operation | CPDragOperationMove)
|
||||
if (operation | CPDragOperationMove)
|
||||
{
|
||||
if (sourceTableUID == [aTableView UID])
|
||||
{
|
||||
[destinationDataSet moveIndexes:sourceIndexes toIndex:row];
|
||||
[destinationTable reloadData];
|
||||
var destIndexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(row, [sourceIndexes count])];
|
||||
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
|
||||
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -434,19 +431,19 @@ tableTestDragType = @"CPTableViewTestDragType";
|
||||
[destinationDataSet insertObjects:sourceObjects atIndexes:destIndexes];
|
||||
[destinationTable reloadData];
|
||||
[destinationTable selectRowIndexes:destIndexes byExtendingSelection:NO];
|
||||
|
||||
|
||||
[sourceDataSet removeObjectsAtIndexes:sourceIndexes];
|
||||
[sourceTable reloadData];
|
||||
[sourceTable selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
|
||||
[sourceTable selectRowIndexes:[CPIndexSet indexSet] byExtendingSelection:NO];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView didEndDraggedImage:(CPImage)anImage atPosition:(CGPoint)aPoint operation:(CPDragOperation)anOperation
|
||||
{
|
||||
//for convenience
|
||||
//for convenience
|
||||
}
|
||||
|
||||
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
|
||||
|
||||
@@ -39,7 +39,7 @@ var tableTestDragType = "tableTestDragType";
|
||||
[table setDelegate:self];
|
||||
[table setUsesAlternatingRowBackgroundColors:YES];
|
||||
|
||||
[table setGridStyleMask:CPTableViewSolidVerticalGridLineMask|CPTableViewSolidHorizontalGridLineMask];
|
||||
[table setGridStyleMask:CPTableViewSolidVerticalGridLineMask | CPTableViewSolidHorizontalGridLineMask];
|
||||
[table setAllowsMultipleSelection:YES];
|
||||
[table registerForDraggedTypes:[tableTestDragType]];
|
||||
|
||||
@@ -113,21 +113,21 @@ var tableTestDragType = "tableTestDragType";
|
||||
- (BOOL)tableView:(CPTableView)aTableView writeRowsWithIndexes:(CPIndexSet)rowIndexes toPasteboard:(CPPasteboard)pboard
|
||||
{
|
||||
var data = [rowIndexes, [aTableView UID]];
|
||||
|
||||
|
||||
var encodedData = [CPKeyedArchiver archivedDataWithRootObject:data];
|
||||
[pboard declareTypes:[CPArray arrayWithObject:tableTestDragType] owner:self];
|
||||
[pboard setData:encodedData forType:tableTestDragType];
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView
|
||||
validateDrop:(id)info
|
||||
proposedRow:(CPInteger)row
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView
|
||||
validateDrop:(id)info
|
||||
proposedRow:(CPInteger)row
|
||||
proposedDropOperation:(CPTableViewDropOperation)operation
|
||||
{
|
||||
[aTableView setDropRow:(row) dropOperation:CPTableViewDropOn];
|
||||
|
||||
|
||||
return CPDragOperationMove;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
//this will be called whenver the user clicks on an autoenabled menu
|
||||
- (BOOL)validateMenuItem:(id)anItem
|
||||
{
|
||||
switch([anItem tag])
|
||||
switch ([anItem tag])
|
||||
{
|
||||
case @"Undo" :
|
||||
[anItem setTitle:[undoManager undoMenuItemTitle]];
|
||||
@@ -118,10 +118,10 @@
|
||||
- (void)update
|
||||
{
|
||||
var cnt = [_items count];
|
||||
for(var i=0; i<cnt; ++i)
|
||||
for (var i = 0; i < cnt; ++i)
|
||||
{
|
||||
var item = [_items objectAtIndex:i];
|
||||
if([[item target] respondsToSelector:@selector(validateMenuItem:)])
|
||||
if ([[item target] respondsToSelector:@selector(validateMenuItem:)])
|
||||
[item _setEnabledByMenu:[[item target] validateMenuItem:item]];
|
||||
else
|
||||
[item _setEnabledByMenu:[item isEnabled]]; /// BD Change from NO
|
||||
@@ -216,7 +216,7 @@
|
||||
if (!newMenu)
|
||||
return;
|
||||
|
||||
if([newMenu autoenablesItems])
|
||||
if ([newMenu autoenablesItems])
|
||||
[newMenu update];
|
||||
// Unhighlight any previously highlighted item.
|
||||
[newMenu _highlightItemAtIndex:CPNotFound];
|
||||
|
||||
@@ -30,7 +30,7 @@ var DefaultDictionary = nil,
|
||||
[DefaultDictionary setObject:@"feedback @nospam@ yourcompany.com" forKey:@"organization.email"];
|
||||
[DefaultDictionary setObject:@"http://yourcompany.com" forKey:@"organization.url"];
|
||||
[DefaultDictionary setObject:@"com.yourcompany" forKey:@"organization.identifier"];
|
||||
|
||||
|
||||
var date = new Date(),
|
||||
months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
||||
|
||||
@@ -90,7 +90,7 @@ var DefaultDictionary = nil,
|
||||
|
||||
[set addObjectsFromArray:[temporaryDictionary allKeys]];
|
||||
[set addObjectsFromArray:[DefaultDictionary allKeys]];
|
||||
|
||||
|
||||
return [set objectEnumerator];
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ function config(/*va_args*/)
|
||||
case "--get": shouldGet = YES;
|
||||
break;
|
||||
|
||||
case "-l":
|
||||
case "-l":
|
||||
case "--list": shouldList = YES;
|
||||
break;
|
||||
|
||||
@@ -164,14 +164,14 @@ function config(/*va_args*/)
|
||||
{
|
||||
var key = nil,
|
||||
keyEnumerator = [configuration storedKeyEnumerator];
|
||||
|
||||
|
||||
while (key = [keyEnumerator nextObject])
|
||||
print(key + '=' + [configuration valueForKey:key]);
|
||||
}
|
||||
else if (shouldGet)
|
||||
{
|
||||
var value = [configuration valueForKey:key];
|
||||
|
||||
|
||||
if (value)
|
||||
print(value);
|
||||
}
|
||||
|
||||
+58
-29
@@ -71,27 +71,33 @@ function gen(/*va_args*/)
|
||||
var args = ["capp gen"].concat(Array.prototype.slice.call(arguments));
|
||||
var options = parser.parse(args, null, null, true);
|
||||
|
||||
if (options.args.length > 1) {
|
||||
if (options.args.length > 1)
|
||||
{
|
||||
parser.printUsage(options);
|
||||
OS.exit(1);
|
||||
}
|
||||
|
||||
if (options.listTemplates) {
|
||||
if (options.listTemplates)
|
||||
{
|
||||
listTemplates();
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.listFrameworks) {
|
||||
if (options.listFrameworks)
|
||||
{
|
||||
listFrameworks();
|
||||
return;
|
||||
}
|
||||
|
||||
var destination = options.args[0];
|
||||
|
||||
if (!destination) {
|
||||
if (!destination)
|
||||
{
|
||||
if (options.justFrameworks)
|
||||
destination = ".";
|
||||
else {
|
||||
|
||||
else
|
||||
{
|
||||
parser.printUsage(options);
|
||||
OS.exit(1);
|
||||
}
|
||||
@@ -114,9 +120,8 @@ function gen(/*va_args*/)
|
||||
configuration = options.noconfig ? [Configuration defaultConfiguration] : [Configuration userConfiguration];
|
||||
|
||||
var frameworks = options.frameworks;
|
||||
if (!options.noFrameworks) {
|
||||
if (!options.noFrameworks)
|
||||
frameworks.push("Objective-J", "Foundation", "AppKit");
|
||||
}
|
||||
|
||||
if (options.justFrameworks)
|
||||
createFrameworksInFile(frameworks, destinationProject, options.symlink, options.useCappBuild, options.force);
|
||||
@@ -174,7 +179,9 @@ function gen(/*va_args*/)
|
||||
|
||||
createFrameworksInFile(frameworks, frameworkDestination, options.symlink, options.useCappBuild);
|
||||
}
|
||||
else {
|
||||
|
||||
else
|
||||
{
|
||||
stream.print("Directory already exists");
|
||||
OS.exit(1);
|
||||
}
|
||||
@@ -195,7 +202,8 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
|
||||
//destinationFrameworks.mkdirs(); // redundant
|
||||
destinationDebugFrameworks.mkdirs();
|
||||
|
||||
if (build) {
|
||||
if (build)
|
||||
{
|
||||
if (!(SYSTEM.env["CAPP_BUILD"] || SYSTEM.env["STEAM_BUILD"]))
|
||||
throw "CAPP_BUILD or STEAM_BUILD must be defined";
|
||||
|
||||
@@ -204,16 +212,21 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
|
||||
var sourceFrameworks = builtFrameworks.join("Release"),
|
||||
sourceDebugFrameworks = builtFrameworks.join("Debug");
|
||||
|
||||
frameworks.forEach(function(framework) {
|
||||
frameworks.forEach(function(framework)
|
||||
{
|
||||
installFramework(sourceFrameworks.join(framework), destinationFrameworks.join(framework), force, symlink);
|
||||
installFramework(sourceDebugFrameworks.join(framework), destinationDebugFrameworks.join(framework), force, symlink);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
else
|
||||
{
|
||||
// Frameworks. Search frameworks paths
|
||||
frameworks.forEach(function(framework) {
|
||||
frameworks.forEach(function(framework)
|
||||
{
|
||||
// Need a special case for Objective-J
|
||||
if (framework === "Objective-J") {
|
||||
if (framework === "Objective-J")
|
||||
{
|
||||
// Objective-J. Take from OBJJ_HOME.
|
||||
var objjHome = FILE.path(OBJJ.OBJJ_HOME);
|
||||
var objjPath = objjHome.join("Frameworks", "Objective-J");
|
||||
@@ -227,9 +240,11 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
|
||||
|
||||
var found;
|
||||
|
||||
for (var i = 0, found = false; !found && i < OBJJ.objj_frameworks.length; i++) {
|
||||
for (var i = 0, found = false; !found && i < OBJJ.objj_frameworks.length; i++)
|
||||
{
|
||||
var sourceFramework = FILE.path(OBJJ.objj_frameworks[i]).join(framework);
|
||||
if (FILE.isDirectory(sourceFramework)) {
|
||||
if (FILE.isDirectory(sourceFramework))
|
||||
{
|
||||
installFramework(sourceFramework, destinationFrameworks.join(framework), force, symlink);
|
||||
found = true;
|
||||
}
|
||||
@@ -237,9 +252,11 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
|
||||
if (!found)
|
||||
stream.print("\0yellow(Warning:\0) Couldn't find framework \0cyan(" + framework +"\0)");
|
||||
|
||||
for (var i = 0, found = false; !found && i < OBJJ.objj_debug_frameworks.length; i++) {
|
||||
for (var i = 0, found = false; !found && i < OBJJ.objj_debug_frameworks.length; i++)
|
||||
{
|
||||
var sourceDebugFramework = FILE.path(OBJJ.objj_debug_frameworks[i]).join(framework);
|
||||
if (FILE.isDirectory(sourceDebugFramework)) {
|
||||
if (FILE.isDirectory(sourceDebugFramework))
|
||||
{
|
||||
installFramework(sourceDebugFramework, destinationDebugFrameworks.join(framework), force, symlink);
|
||||
found = true;
|
||||
}
|
||||
@@ -250,16 +267,21 @@ function createFrameworksInFile(/*Array*/ frameworks, /*String*/ aFile, /*Boolea
|
||||
}
|
||||
}
|
||||
|
||||
function installFramework(source, dest, force, symlink) {
|
||||
if (dest.exists()) {
|
||||
if (force) {
|
||||
function installFramework(source, dest, force, symlink)
|
||||
{
|
||||
if (dest.exists())
|
||||
{
|
||||
if (force)
|
||||
dest.rmtree();
|
||||
} else {
|
||||
|
||||
else
|
||||
{
|
||||
stream.print("\0yellow(Warning:\0) " + dest + " already exists. Use --force to overwrite.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (source.exists()) {
|
||||
if (source.exists())
|
||||
{
|
||||
stream.print((symlink ? "Symlinking " : "Copying ") + source + " to " + dest);
|
||||
if (symlink)
|
||||
FILE.symlink(source, dest);
|
||||
@@ -299,24 +321,31 @@ function toIdentifier(/*String*/ aString)
|
||||
return identifier;
|
||||
}
|
||||
|
||||
function listTemplates() {
|
||||
FILE.list(templatesDirectory).forEach(function(templateName) {
|
||||
function listTemplates()
|
||||
{
|
||||
FILE.list(templatesDirectory).forEach(function(templateName)
|
||||
{
|
||||
stream.print(templateName);
|
||||
});
|
||||
}
|
||||
|
||||
function listFrameworks() {
|
||||
function listFrameworks()
|
||||
{
|
||||
stream.print("Frameworks:");
|
||||
OBJJ.objj_frameworks.forEach(function(frameworksDirectory) {
|
||||
OBJJ.objj_frameworks.forEach(function(frameworksDirectory)
|
||||
{
|
||||
stream.print(" " + frameworksDirectory);
|
||||
FILE.list(frameworksDirectory).forEach(function(templateName) {
|
||||
FILE.list(frameworksDirectory).forEach(function(templateName)
|
||||
{
|
||||
stream.print(" + " + templateName);
|
||||
});
|
||||
});
|
||||
stream.print("Frameworks (Debug):");
|
||||
OBJJ.objj_debug_frameworks.forEach(function(frameworksDirectory) {
|
||||
OBJJ.objj_debug_frameworks.forEach(function(frameworksDirectory)
|
||||
{
|
||||
stream.print(" " + frameworksDirectory);
|
||||
FILE.list(frameworksDirectory).forEach(function(frameworkName) {
|
||||
FILE.list(frameworksDirectory).forEach(function(frameworkName)
|
||||
{
|
||||
stream.print(" + " + frameworkName);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user