// // PLSConnection2Controller.m // Pulse // // Created by Matt Attaway on 3/3/14. // Copyright (c) 2014 Zen of the Monkey. All rights reserved. // #import "PLSConnectionController.h" #import "PLSOverseer.h" @interface PLSConnectionController () @end @implementation PLSConnectionController - (id)initWithWindow:(NSWindow *)window { self = [super initWithWindow:window]; if (self) { // Initialization code here. } return self; } - (void)windowDidLoad { [super windowDidLoad]; } - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView { return [self.connections count]; } - (NSView*)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { if(row == -1) { return nil; } PLSOverseer *os = [self.connections objectAtIndex:row]; NSTableCellView* cell = [tableView makeViewWithIdentifier:@"connectionCell" owner:self]; [cell.textField setStringValue:os.port]; [cell.imageView setImage:[self getStatusImage:os]]; return cell; } - (void)tableViewSelectionDidChange:(NSNotification *)aNotification { [self updateFields]; } - (void)updateFields { NSInteger row = [self.tableView selectedRow]; PLSOverseer* os = self.connections[row]; [self.portField setStringValue:os.port]; [self.userField setStringValue:os.user]; [self.pathField setStringValue:os.path]; [self.clientField setStringValue:os.client]; self.enableAutoSubmitBox.state = os.enableAutoSubmit; [self.statusIcon setImage:[self getStatusImage:os]]; if(os.disabled) { [self.statusField setStringValue:@"Updates paused"]; [self.statusButton setTitle:@"Resume Updates"]; } else if(os.connectionDown) { [self.statusField setStringValue:@"Server unavailable"]; [self.statusButton setTitle:@"Pause Updates"]; } else if (os.needsLogin) { [self.statusField setStringValue:@"Login to resume updates"]; [self.statusButton setTitle:@"Pause Updates"]; } else { [self.statusField setStringValue:@"Connected"]; [self.statusButton setTitle:@"Pause Updates"]; } } - (NSImage*)getStatusImage:(PLSOverseer*)os { if(os.disabled || os.connectionDown) { return [NSImage imageNamed:@"NSStatusUnavailable"]; } else if (os.needsLogin) { return [NSImage imageNamed:@"NSStatusPartiallyAvailable"]; } else { return [NSImage imageNamed:@"NSStatusAvailable"]; } } - (IBAction)updateSelectedConnection:(id)sender { NSString *identifier = [sender identifier]; PLSOverseer* os = self.connections[[self.tableView selectedRow]]; if([sender isKindOfClass:[NSTextField class]]) { [os setValue:[(NSTextField*)sender stringValue] forKey:identifier]; } else if([sender isKindOfClass:[NSButton class]]) { if([identifier isEqual:@"changeUpdateState"]) { os.disabled = !os.disabled; } else if([identifier isEqual:@"enableAutoSubmit"]) { os.enableAutoSubmit = [(NSButton*)sender state]; } } // make sure the fields are all up-to-date [self updateFields]; // update the table as well NSIndexSet* rowSet = [NSIndexSet indexSetWithIndex:[self.tableView selectedRow]]; NSIndexSet* colSet = [NSIndexSet indexSetWithIndex:0]; [self.tableView reloadDataForRowIndexes:rowSet columnIndexes:colSet]; } - (IBAction)add:(id)sender { PLSOverseer* os = [[PLSOverseer alloc] init]; [self.connections addObject:os]; [self.tableView reloadData]; NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:[self.connections count]-1]; [self.tableView selectRowIndexes:indexSet byExtendingSelection:false]; } - (IBAction)remove:(id)sender { NSInteger row = [self.tableView selectedRow]; [self.tableView abortEditing]; if(row != -1) { [self.connections removeObjectAtIndex:row]; [self.tableView reloadData]; } NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:[self.connections count]-1]; [self.tableView selectRowIndexes:indexSet byExtendingSelection:false]; } -(void)showWindow:(id)sender { [super showWindow:sender]; [self.tableView reloadData]; for( PLSOverseer* os in self.connections ) { [os pauseTracking]; } NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:0]; [self.tableView selectRowIndexes:indexSet byExtendingSelection:false]; } - (void)windowWillClose:(NSNotification *)notification { // on the off chance we didn't set them while editing, update the selected object on the way out PLSOverseer* sos = [self.connections objectAtIndex:[self.tableView selectedRow]]; sos.port = [self.portField stringValue]; sos.user = [self.userField stringValue]; sos.path = [self.pathField stringValue]; sos.client = [self.clientField stringValue]; // write out all the connection to the preferences NSMutableArray* osSettings = [[NSMutableArray alloc] init]; for(PLSOverseer* os in self.connections) { [osSettings addObject:[os getSettings]]; } NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:osSettings forKey:@"connections"]; [defaults synchronize]; } - (IBAction)launchSelectFile:(id)sender { NSOpenPanel* panel = [NSOpenPanel openPanel]; [panel setCanChooseFiles:NO]; [panel setAllowsMultipleSelection:NO]; [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:YES]; [panel setPrompt:@"Select"]; [panel setDirectoryURL:[NSURL URLWithString:[self.pathField stringValue]]]; if ( [panel runModal] == NSOKButton ) { NSArray *files = [panel URLs]; [self.pathField setStringValue:[files[0] path]]; [self updateSelectedConnection:self.pathField]; } } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#10 | 8702 | Matt Attaway |
Add the ability to pause updates on a connection After some fun today where I added a gazillion files while running automated tests I realized there is is much to be said for being able to pause your automated friend. This change adds the ability to pause updates on a connection. Syncs and file events are not tracked while updates are paused. Paused connections are also not used when figuring out what the state icon should be. Also fix a bug related to all of this where a server coming online while in the connection dialog would not cause the icon to update. We now do an icon state check after coming out of the connection dialog. In addition, we use the proper timer when coming out of the connection dialog, not always the sync timer. User visible change |
||
#9 | 8692 | Matt Attaway |
Add auto-submit capability to Pulse If you so choose you may now configure Pulse to automatically submit files as soon as they are changed. This is done as part of the file event watcher; files are opened with reconcile and if configured to do so immediately submitted with a boilerplate commit message. For obvious reasons auto-commit is off by default. User visible change |
||
#8 | 8691 | Matt Attaway |
Fix sundry connection dialog bugs * Table text is now updated when the port changes * Path is properly set when set using the browse button * On close we set all of the values for the selected connection on the off chance our text field event didn’t fire User visible bug fixes |
||
#7 | 8686 | Matt Attaway |
Swap in new connection dialog There’s still a fair amount of polish to do, but it’s good enough to replace the old connection dialog. User visible change |
||
#6 | 8575 | Matt Attaway |
Automatically handle Unicode servers; stub out login handling There's a lot going on in this change: * Fixed a bug where charset was always set to none * Added protocol on PLSOverseer so that something can properly handle login errors * PLSAppDelegate implements stubs for the PLSOverseer protocol * PLSOverseers automatically configure themselves for Unicode servers now * Ripped out handleCommonErrors: because it turns out I want to handle the same error in multiple ways. Next step is to properly handle 'p4 login' and request a password. User visible changes. |
||
#5 | 8537 | Matt Attaway |
Rework Pulse startup to (sorta) support real users Instead of repopulating the system with my test data it now pops up the connection dialog if there are no existing connections. This change also fixes a bug where the PLSConnection object wasn’t being refreshed when settings were changed on an Overseer. |
||
#4 | 8536 | Matt Attaway | Save out connections when closing the dialog | ||
#3 | 8523 | Matt Attaway |
Prevent double start call to FSEvents This was a bit of shuffling, but the behavior is much tidier now. Overseers do not start overseeing until they are explicitly told to do so. This makes their behavior much more predictable. |
||
#2 | 8522 | Matt Attaway |
Clean up the behavior of the connections dialog All of the Overseers are now paused while the connection dialog is up so that the user can fiddle with their settings in peace. |
||
#1 | 8519 | Matt Attaway |
Finally add a connections dialog to manage connections It’s taken a week to figure out how to manage windows and tabelviews, but this change adds a crude connection dialog to add and remove connections as well as save them out to the preferences file. More to do to make it more sane, but it works for now! |