diff --git a/Tests/Foundation/CPStringTest.j b/Tests/Foundation/CPStringTest.j index 1c4b5b5e0..01a35256c 100644 --- a/Tests/Foundation/CPStringTest.j +++ b/Tests/Foundation/CPStringTest.j @@ -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 diff --git a/Tests/Foundation/CPSubclassableDictionaryTest.j b/Tests/Foundation/CPSubclassableDictionaryTest.j index bc410b858..b1d962db1 100644 --- a/Tests/Foundation/CPSubclassableDictionaryTest.j +++ b/Tests/Foundation/CPSubclassableDictionaryTest.j @@ -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 \ No newline at end of file diff --git a/Tests/Foundation/CPURLTest.j b/Tests/Foundation/CPURLTest.j index 1c2a16156..e2dae3bd8 100644 --- a/Tests/Foundation/CPURLTest.j +++ b/Tests/Foundation/CPURLTest.j @@ -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 diff --git a/Tests/Manual/CPOutlineViewTest/AppController.j b/Tests/Manual/CPOutlineViewTest/AppController.j index 8e080afc7..b0866f50a 100644 --- a/Tests/Manual/CPOutlineViewTest/AppController.j +++ b/Tests/Manual/CPOutlineViewTest/AppController.j @@ -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; } diff --git a/Tests/Manual/CPSearchField/AppController.j b/Tests/Manual/CPSearchField/AppController.j index fdf3be6b8..e239f293b 100644 --- a/Tests/Manual/CPSearchField/AppController.j +++ b/Tests/Manual/CPSearchField/AppController.j @@ -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 diff --git a/Tests/Manual/TableTest/GroupRowTest/AppController.j b/Tests/Manual/TableTest/GroupRowTest/AppController.j index 1b9d493a9..92a382d3c 100644 --- a/Tests/Manual/TableTest/GroupRowTest/AppController.j +++ b/Tests/Manual/TableTest/GroupRowTest/AppController.j @@ -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]; diff --git a/Tests/Manual/TableTest/OldTest/AppController.j b/Tests/Manual/TableTest/OldTest/AppController.j index 2c0d275f1..36fda9fb7 100644 --- a/Tests/Manual/TableTest/OldTest/AppController.j +++ b/Tests/Manual/TableTest/OldTest/AppController.j @@ -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 diff --git a/Tests/Manual/TableTest/VariableRows/AppController.j b/Tests/Manual/TableTest/VariableRows/AppController.j index 25a447bca..4faf78a5b 100644 --- a/Tests/Manual/TableTest/VariableRows/AppController.j +++ b/Tests/Manual/TableTest/VariableRows/AppController.j @@ -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; } diff --git a/Tests/Manual/UndoRedoWithMenuUpdate/AppController.j b/Tests/Manual/UndoRedoWithMenuUpdate/AppController.j index 3b0ab7ab4..7da23c129 100644 --- a/Tests/Manual/UndoRedoWithMenuUpdate/AppController.j +++ b/Tests/Manual/UndoRedoWithMenuUpdate/AppController.j @@ -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