// // SyncPanelController.m // Perforce // // Created by Adam Czubernat on 15.07.2013. // Copyright (c) 2013 Perforce Software, Inc. All rights reserved. // #import "SyncPanelController.h" #import "P4Workspace.h" @interface SyncPanelController () { __weak IBOutlet NSView *loadingView; __weak IBOutlet NSView *successView; __weak IBOutlet NSProgressIndicator *indicator; __weak IBOutlet NSTextField *progressLabel; __weak IBOutlet NSTextField *successLabel; } - (void)synchronize; - (void)syncStartedNotification:(NSNotification *)notification; - (void)syncFinishedNotification:(NSNotification *)notification; - (IBAction)cancelButtonPressed:(id)sender; - (IBAction)hideButtonPressed:(id)sender; @end @implementation SyncPanelController - (void)windowDidLoad { [super windowDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncStartedNotification:) name:P4SyncStartedNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncFinishedNotification:) name:P4SyncFinishedNotification object:nil]; if ([[P4Workspace sharedInstance] isSynchronizing]) progressLabel.stringValue = ([P4Workspace sharedInstance].syncDescription ?: @"Synchronizing files..."); else [self synchronize]; [self setPresentedView:loadingView]; [indicator startAnimation:nil]; } - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } #pragma mark - Private - (void)synchronize { progressLabel.stringValue = @"Synchronizing files..."; PSLog(@"Manual sync"); [[P4Workspace sharedInstance] syncWorkspace:nil response:nil]; } - (void)syncStartedNotification:(NSNotification *)notification { } - (void)syncFinishedNotification:(NSNotification *)notification { [indicator stopAnimation:nil]; P4Operation *operation = notification.object; NSArray *upToDate = [operation errorsWithCode:P4ErrorFileUpToDate]; [operation ignoreErrors:upToDate]; if (operation.errors) { if (![operation errorsWithCode:P4ErrorSessionExpired]) [[NSAlert alertWithError:operation.error] beginSheetModalForWindow:self.window.parentWindow modalDelegate:nil didEndSelector:nil contextInfo:NULL]; [self dismiss]; } else { if (upToDate) successLabel.stringValue = @"Files are up-to-date"; [self setPresentedView:successView animated:YES]; PSLog(@"SyncPanel finished %@", operation.response ?: @""); [self dismissAfter:2.0f]; } } #pragma mark - Actions - (IBAction)cancelButtonPressed:(id)sender PS_NOT_IMPLEMENTED - (IBAction)hideButtonPressed:(id)sender { [self dismiss]; } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 9421 | tjuricek |
Copying //guest/perforce_software/piper/... to //guest/tjuricek/piper/... |
||
//guest/perforce_software/piper/Perforce/Classes/WindowControllers/SyncPanelController.m | |||||
#1 | 8919 | Matt Attaway | Initial add of Piper, a lightweight Perforce client for artists and designers. |