Skip to content

Commit

Permalink
[#23] adding the UI for the new relation window
Browse files Browse the repository at this point in the history
  • Loading branch information
fernyb committed Jul 20, 2011
1 parent 884ecb2 commit 1b270c3
Show file tree
Hide file tree
Showing 3 changed files with 187 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/SJDuplicateTableWindowController.j
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
[[self window] makeFirstResponder:labelInputName];
}

@end
@end
174 changes: 174 additions & 0 deletions client/SJRelationNewWindowController.j
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
@import <Foundation/CPObject.j>

@implementation SJRelationNewWindowController : CPWindowController
{
id controller @accessors;
}

- (id)initWithParentController:(id)aController
{
self = [super init];
[self setController:aController];
[self setup];
return self;
}

- (CPString)tableName
{
return [controller tableName];
}

- (void)setup
{
var rect = CGRectMake(0, 0, 350, 350);
[self setWindow:[[CPWindow alloc] initWithContentRect:rect styleMask:CPDocModalWindowMask]];
[self addTableBox];
[self addReferencesBox];
[self addActionBox];
[self addButtons];
}

- (void)addTableBox
{
var rect = CGRectMake(0, 0, 350, 250);
var contentView = [[self window] contentView];

var tableBox = [[CPBox alloc] initWithFrame:CGRectMake(10, 10, CGRectGetWidth(rect) - 20, 50)];
var tableBoxName = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[tableBoxName setStringValue:@"Table: "+ [self tableName]];
[tableBoxName sizeToFit];
[tableBoxName setFrameOrigin:CGPointMake(10, 10)];
[contentView addSubview:tableBoxName];

[tableBox setFrameOrigin:CGPointMake(10, 30)];
var columnLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[columnLabel setStringValue:@"Column:"];
[columnLabel sizeToFit];
[columnLabel setFrame:CGRectMake(0,0, 90, CGRectGetHeight([columnLabel frame]))];
[columnLabel setFrameOrigin:CGPointMake(10, 14)];
[[tableBox contentView] addSubview:columnLabel];

var columnPopBtn = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0,0, 210, 24)];
[columnPopBtn setFrameOrigin:CGPointMake(110, 10)];
[[tableBox contentView] addSubview:columnPopBtn];

[contentView addSubview:tableBox];
}

- (void)addReferencesBox
{
var rect = CGRectMake(0, 0, 350, 250);
var contentView = [[self window] contentView];

var tableBox = [[CPBox alloc] initWithFrame:CGRectMake(10, 120, CGRectGetWidth(rect) - 20, 80)];
var tableBoxName = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[tableBoxName setStringValue:@"References "];
[tableBoxName sizeToFit];
[tableBoxName setFrameOrigin:CGPointMake(10, 90)];
[contentView addSubview:tableBoxName];

[tableBox setFrameOrigin:CGPointMake(10, 110)];

var tableLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[tableLabel setStringValue:@"Table:"];
[tableLabel sizeToFit];
[tableLabel setFrame:CGRectMake(0,0, 90, CGRectGetHeight([tableLabel frame]))];
[tableLabel setFrameOrigin:CGPointMake(10, 14)];
[[tableBox contentView] addSubview:tableLabel];

var tablePopupBtn = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0,0, 210, 24)];
[tablePopupBtn setFrameOrigin:CGPointMake(110, 10)];
[[tableBox contentView] addSubview:tablePopupBtn];


var columnLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[columnLabel setStringValue:@"Column:"];
[columnLabel sizeToFit];
[columnLabel setFrame:CGRectMake(0,0, 90, CGRectGetHeight([columnLabel frame]))];
[columnLabel setFrameOrigin:CGPointMake(10, 44)];
[[tableBox contentView] addSubview:columnLabel];

var columnPopBtn = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0,0, 210, 24)];
[columnPopBtn setFrameOrigin:CGPointMake(110, 42)];
[[tableBox contentView] addSubview:columnPopBtn];

[contentView addSubview:tableBox];
}


- (void)addActionBox
{
var rect = CGRectMake(0, 0, 350, 250);
var contentView = [[self window] contentView];

var tableBox = [[CPBox alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(rect) - 20, 80)];
var tableBoxName = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[tableBoxName setStringValue:@"Action"];
[tableBoxName sizeToFit];
[tableBoxName setFrameOrigin:CGPointMake(10, 200)];
[contentView addSubview:tableBoxName];

[tableBox setFrameOrigin:CGPointMake(10, 220)];

var tableLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[tableLabel setStringValue:@"On update:"];
[tableLabel sizeToFit];
[tableLabel setFrame:CGRectMake(0,0, 90, CGRectGetHeight([tableLabel frame]))];
[tableLabel setFrameOrigin:CGPointMake(10, 14)];
[[tableBox contentView] addSubview:tableLabel];

var tablePopupBtn = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0,0, 210, 24)];
[tablePopupBtn setFrameOrigin:CGPointMake(110, 10)];
[[tableBox contentView] addSubview:tablePopupBtn];


var columnLabel = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[columnLabel setStringValue:@"On delete:"];
[columnLabel sizeToFit];
[columnLabel setFrame:CGRectMake(0,0, 90, CGRectGetHeight([columnLabel frame]))];
[columnLabel setFrameOrigin:CGPointMake(10, 44)];
[[tableBox contentView] addSubview:columnLabel];

var columnPopBtn = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0,0, 210, 24)];
[columnPopBtn setFrameOrigin:CGPointMake(110, 42)];
[[tableBox contentView] addSubview:columnPopBtn];

[contentView addSubview:tableBox];
}

- (void)addButtons
{
var contentView = [[self window] contentView];
var contentViewRect = [contentView frame];

var cancelBtn = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetWidth(contentViewRect) - (75 * 2 + 20), 310, 75, 30)];
[cancelBtn setTitle:@"Cancel"];
[cancelBtn sizeToFit];
[cancelBtn setTarget:self];
[cancelBtn setAction:@selector(cancelBtnAction:)];

var cancelBtnSize = [cancelBtn frame].size;
cancelBtnSize.width = 75;
[cancelBtn setFrameSize:cancelBtnSize];
[contentView addSubview:cancelBtn];

var addBtn = [[CPButton alloc] initWithFrame:CGRectMake(CGRectGetWidth(contentViewRect) - (75 + 10), 310, 75, 30)];
[addBtn setTitle:@"Add"];
[addBtn sizeToFit];
[addBtn setFrameSize:cancelBtnSize];
[addBtn setTarget:self];
[addBtn setAction:@selector(addBtnAction:)];
[contentView addSubview:addBtn];
}

- (void)cancelBtnAction:(CPButton)sender
{
[CPApp endSheet:[self window]];
}

- (void)addBtnAction:(CPButton)sender
{
// Here make request for new relation
}

@end
13 changes: 12 additions & 1 deletion client/SJRelationsTabController.j
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
@import "SJTabBaseController.j"
@import "SJConstants.j"
@import "Categories/CPTableView+Categories.j"

@import "SJRelationNewWindowController.j"

@implementation SJRelationsTabController : SJTabBaseController
{
CPArray relations;
CPButtonBar bottomBar;
SJRelationNewWindowController newRelWinController;
}

// View Did Set is only called when the [self view] is set.
Expand Down Expand Up @@ -75,6 +76,15 @@

- (void)addRelationAction:(CPButton)sender
{
if (!newRelWinController) {
newRelWinController = [[SJRelationNewWindowController alloc] initWithParentController:self];
}

[CPApp beginSheet: [newRelWinController window]
modalForWindow: [[self contentView] window]
modalDelegate: self
didEndSelector: null
contextInfo: null];
}

- (void)removeRelationAction:(CPButton)sender
Expand All @@ -83,6 +93,7 @@

- (void)refreshAction:(CPButton)sender
{
[self retrieveRelations];
}

// Called when the tab is selected and the view will be displayed.
Expand Down

0 comments on commit 1b270c3

Please sign in to comment.