Created
January 11, 2011 13:14
-
-
Save orlaqp/774396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import <AppKit/CPView.j> | |
@import <AppKit/CPOutlineView.j> | |
@import "../Models/Menu.j" | |
@import "../Controllers/WorkflowViewController.j" | |
@import "../Controllers/MenuController.j" | |
@import "WorkflowTreeViewTemplate.j" | |
@implementation JobsManagerView : CPView | |
{ | |
CPSplitView _verticalSplitView; | |
CPSplitView _horizontalSplitView; | |
CPView _leftView; | |
CPView _rightView; | |
CPScrollView _scrollView; | |
Menu _menu @accessors(property=menu); | |
WorkflowViewController _workflowViewController; | |
} | |
- (id) initWithFrame:(CGRect)aRect | |
{ | |
self = [super initWithFrame: aRect]; | |
if (self) | |
{ | |
[self setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
_verticalSplitter = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([self bounds]), CGRectGetHeight([self bounds]))]; | |
[_verticalSplitter setDelegate:self]; | |
[_verticalSplitter setVertical:YES]; | |
[_verticalSplitter setIsPaneSplitter:YES]; | |
[_verticalSplitter setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
_leftView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, 250, CGRectGetHeight([_verticalSplitter bounds]))]; | |
[_leftView setBackgroundColor:[CPColor colorWithCalibratedRed:224.0/255.0 green:236.0/255.0 blue:250.0/255.0 alpha:0.7]]; | |
//[_leftView setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable]; | |
_rightView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([_verticalSplitter bounds]) - 250, CGRectGetHeight([_verticalSplitter bounds]))]; | |
//[_rightView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
[_verticalSplitter addSubview:_leftView]; | |
[_verticalSplitter addSubview:_rightView]; | |
[self prepareLeftView:[_leftView bounds]]; | |
[self prepareRightView:_rightView]; | |
[self addSubview:_verticalSplitter]; | |
} | |
return self; | |
} | |
- (void)prepareLeftView:(CGRect)aRect | |
{ | |
//[_leftView addSubview:[self createOutlineView:CGRectMake(0, 12, CGRectGetWidth(aRect), CGRectGetHeight(aRect) - 25)]]; | |
//[_leftView addSubview:[self createAccordionView:aRect]]; | |
// Create the Default Outline View | |
_menu = [Menu menuWithTitle:@"Root" children:[ | |
[Menu menuWithTitle:@"MODULE" andImagePath:@"Resources/module.png"], | |
[Menu menuWithTitle:@"MACHINE" andImagePath:@"Resources/machine.png"], | |
[Menu menuWithTitle:@"TSP" andImagePath:@"Resources/thumbnails.png"], | |
[Menu menuWithTitle:@"STUDIO" andImagePath:@"Resources/studio.png"]] | |
]; | |
var rowHeight = 24.0; | |
var columnWidth = CGRectGetWidth(aRect) - 3; //215.0; | |
var _scrollView = [[CPScrollView alloc] initWithFrame:aRect]; | |
[_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
[_scrollView setAutohidesScrollers:YES]; | |
// Create outline view control | |
var _outlineView = [[CPOutlineView alloc] initWithFrame:aRect]; | |
//[_outlineView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
[_outlineView setDelegate:self]; | |
[_outlineView setDataSource:self]; | |
[_outlineView setAllowsColumnResizing:YES]; | |
[_outlineView setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle]; | |
[_outlineView setBackgroundColor:[CPColor colorWithCalibratedRed:224.0/255.0 green:236.0/255.0 blue:250.0/255.0 alpha:0.7]]; | |
[_outlineView setAllowsMultipleSelection:NO]; | |
[_outlineView expandItem:nil expandChildren:NO]; | |
[_outlineView setRowHeight:rowHeight]; | |
// [_outlineView setIntercellSpacing:CPSizeMake(0.0, 10.0)] | |
[_outlineView setCornerView:nil]; | |
[_outlineView setHeaderView:nil]; | |
var column = [[CPTableColumn alloc] initWithIdentifier:@"One"]; | |
[column setWidth:columnWidth]; | |
var dataView = [[WorkflowTreeViewTemplate alloc] initWithFrame:CGRectMake(0,0, columnWidth, rowHeight)]; | |
[dataView setAutoresizingMask: CPViewWidthSizable | CPViewHeightSizable]; | |
[column setDataView:dataView]; | |
[_outlineView addTableColumn:column]; | |
[_outlineView setOutlineTableColumn:column]; | |
[_scrollView setDocumentView:_outlineView]; | |
[_leftView addSubview:_scrollView]; | |
} | |
- (void)prepareRightView:(CPView)rightView | |
{ | |
_horizontalSplitView = [[CPSplitView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([rightView bounds]), CGRectGetHeight([rightView bounds]))]; | |
[_horizontalSplitView setDelegate:self]; | |
[_horizontalSplitView setVertical:NO]; | |
[_horizontalSplitView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
var topView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([rightView bounds]), (CGRectGetHeight([rightView bounds]) / 2))]; | |
[topView setAutoresizingMask:CPViewHeightSizable | CPViewWidthSizable]; | |
var bottomView = [[CPView alloc] initWithFrame:CGRectMake(5, CGRectGetHeight([rightView bounds]) / 2, CGRectGetWidth([rightView bounds]), CGRectGetHeight([rightView bounds]) / 2)]; | |
[bottomView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable ]; | |
[bottomView setBackgroundColor:[CPColor colorWithCalibratedRed:237.0/255.0 green:241.0/255.0 blue:244.0/255.0 alpha:0.9]]; | |
[_horizontalSplitView addSubview:topView]; | |
[_horizontalSplitView addSubview:bottomView]; | |
_workflowViewController = [WorkflowViewController controllerWithFrame:CGRectMake(0, 0, CGRectGetWidth([topView bounds]), CGRectGetHeight([topView bounds]))] | |
[topView addSubview: [_workflowViewController workflowView]]; | |
[rightView addSubview:_horizontalSplitView]; | |
} | |
// Delegates/Notifications for CPOutlineView | |
- (id)outlineView:(CPOutlineView)theOutlineView child:(int)theIndex ofItem:(id)theItem | |
{ | |
if (theItem === nil) | |
theItem = [self menu]; | |
// CPLog.debug(@"child: %i ofItem:%@ : %@", theIndex, theItem, [[theItem children] objectAtIndex:theIndex]); | |
return [[theItem children] objectAtIndex:theIndex]; | |
} | |
- (BOOL)outlineView:(CPOutlineView)theOutlineView isItemExpandable:(id)theItem | |
{ | |
if (theItem === nil) | |
theItem = [self menu]; | |
if ([theItem command] == "") | |
return true; | |
// CPLog.debug(@"isItemExpandable:%@ : %@", theItem, [[theItem children] count] > 0); | |
return [[theItem children] count] > 0; | |
} | |
- (int)outlineView:(CPOutlineView)theOutlineView numberOfChildrenOfItem:(id)theItem | |
{ | |
if (theItem === nil) | |
theItem = [self menu]; | |
// CPLog.debug(@"numberOfChildrenOfItem:%@ : %i", theItem, [[theItem children] count]); | |
return [[theItem children] count]; | |
} | |
- (id)outlineView:(CPOutlineView)anOutlineView objectValueForTableColumn:(CPTableColumn)theColumn byItem:(id)theItem | |
{ | |
if (theItem === nil) | |
theItem = [self menu]; | |
// CPLog.debug(@"objectValueForTableColumn:%@ byItem:%@ : %@", theColumn, theItem, [theItem title]); | |
//return [theItem title] + " (" + [theItem count] + ")"; | |
return theItem; | |
} | |
- (void)outlineViewItemWillExpand:(CPNotification)aNotification | |
{ | |
//debugger; | |
var expadingItem = [[aNotification userInfo] objectForKey:@"CPObject"]; | |
if ([expadingItem command] != "") | |
return; | |
var tree = [MenuController retrieveTree:[[expadingItem title] lowercaseString]]; | |
if ([tree children] == nil) | |
[expadingItem children:nil]; | |
else | |
[expadingItem setChildren:[CPArray arrayWithArray:[tree children]]]; | |
} | |
// ************************* | |
- (void)outlineViewSelectionDidChange:(CPNotification)aNotification | |
{ | |
var outlineView = [aNotification object]; | |
var selectedItem = [outlineView itemAtRow:[outlineView selectedRow]]; | |
var parameters = [CPString jsonFromQueryString:[selectedItem command]]; | |
[_workflowViewController filterGrid:parameters]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment