diff --git a/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.h b/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.h index c823ceb3321d3db9b45aa7f38d34a9d82225b224..f5cb776cc6aa1174699ba73b1b86cc6875f00ffe 100644 --- a/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.h +++ b/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.h @@ -45,6 +45,9 @@ @property (nonatomic, retain) NSString * propertiesJson; @property (readonly) NSArray * properties; +///! The image contained at the imageUrl or nil if there is no image. +@property (nonatomic, strong) UIImage * image; + // Actions //! Take the values from the raw entity. - (void)initializeFromRawEntity:(CISDOBIpadRawEntity *)rawEntity; diff --git a/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.m b/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.m index ce2c3adde4536dab005f855eae0248c64e9bf710..93c002df53dd01601b279e7002ea72cbe57810e0 100644 --- a/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.m +++ b/openbis-ipad/BisKit/Classes/CISDOBIpadEntity.m @@ -37,6 +37,8 @@ @dynamic childrenPermIdsJson; @dynamic propertiesJson; +@synthesize image; + - (NSArray *)properties { [self willAccessValueForKey: @"properties"]; diff --git a/openbis-ipad/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate b/openbis-ipad/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate index c1bb18ae55cac755d737f19347057e3affb6ae6b..d199bf20f38be6841c033b9bebb507d03723cc76 100644 Binary files a/openbis-ipad/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate and b/openbis-ipad/openBIS/openBIS.xcodeproj/project.xcworkspace/xcuserdata/cramakri.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/openbis-ipad/openBIS/openBIS/CISDOBDetailViewController.m b/openbis-ipad/openBIS/openBIS/CISDOBDetailViewController.m index 21c1cc00fe0b5c074b54a4dbf2976ba6962394d7..b210be3c7e6394923bf5487499c926381844d828 100644 --- a/openbis-ipad/openBIS/openBIS/CISDOBDetailViewController.m +++ b/openbis-ipad/openBIS/openBIS/CISDOBDetailViewController.m @@ -29,6 +29,8 @@ @property (strong, nonatomic) UIPopoverController *masterPopoverController; @property (readonly) CISDOBIpadEntity *detailItem; +- (void)requestServerSync; +- (void)configureViewProvisionally; - (void)configureView; - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath; @end @@ -36,11 +38,18 @@ @implementation CISDOBDetailViewController #pragma mark - Managing the detail item +- (void)requestServerSync +{ + // Ask the server to synchronize the detail object and nofiy me when the complete data is available + SuccessBlock success = ^(id result) { [self configureView]; }; + [self.openBisModel syncSelectedObjectOnSuccess: success]; +} - (void)selectionDidChange { // Update the view. - [self configureView]; + [self configureViewProvisionally]; + [self requestServerSync]; if (self.masterPopoverController != nil) { [self.masterPopoverController dismissPopoverAnimated:YES]; @@ -49,19 +58,23 @@ - (CISDOBIpadEntity *)detailItem { return [self.openBisModel selectedObject]; } +- (void)configureViewProvisionally +{ + // We have a detail item which might not be up-to-date. Update the user interface. + [self configureView]; +} + - (void)configureView { - // Update the user interface for the detail item. + // The detail item is now up-to-date. Update the user interface. if (!self.detailItem) return; self.summaryHeaderLabel.text = [self.detailItem.summaryHeader description]; self.summaryLabel.text = [self.detailItem.summary description]; self.identifierLabel.text = [self.detailItem.identifier description]; - if (self.detailItem.imageUrl) { - NSURL *imageUrl = [NSURL URLWithString: self.detailItem.imageUrl]; - NSData *imageData = [NSData dataWithContentsOfURL: imageUrl]; - self.imageView.image =[UIImage imageWithData: imageData]; + if (self.detailItem.image) { + self.imageView.image = self.detailItem.image; } [self.propertiesTableView reloadData]; @@ -71,7 +84,7 @@ { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. - [self configureView]; + [self configureViewProvisionally]; } - (void)didReceiveMemoryWarning diff --git a/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.h b/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.h index 865c2ee0364eb7be8f81a647bdc3b69fff04c494..e1b5e6334f5de4c51ea20e630276701fc86d2565 100644 --- a/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.h +++ b/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.h @@ -21,6 +21,7 @@ // #import <Foundation/Foundation.h> +#import "CISDOBShared.h" @class CISDOBIpadEntity; @@ -51,5 +52,9 @@ - (BOOL)insertNewObjectOrError:(NSError **)error; //!< Return YES if operation succeeded - (BOOL)deleteObjectAtIndexPath:(NSIndexPath *)indexPath error:(NSError **)error; //!< Return YES if operation succeeded +// Server Communication +//! Get the selected object from the server and invoke the succes block when the data is here +- (void)syncSelectedObjectOnSuccess:(SuccessBlock)success; + @end diff --git a/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.m b/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.m index 33da2d3f605a68d3e2084504b7aafae8022f5fb9..b96ba398f4890b19b3678d286023ea811aca9152 100644 --- a/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.m +++ b/openbis-ipad/openBIS/openBIS/CISDOBOpenBisModel.m @@ -88,6 +88,20 @@ return [context save: error]; } +#pragma mark - Server Communication +- (void)syncSelectedObjectOnSuccess:(SuccessBlock)success +{ + // Update the image + if (_selectedObject.imageUrl) { + NSURL *imageUrl = [NSURL URLWithString: _selectedObject.imageUrl]; + NSData *imageData = [NSData dataWithContentsOfURL: imageUrl]; + _selectedObject.image = [UIImage imageWithData: imageData]; + success(_selectedObject); + } else { + success(_selectedObject); + } +} + #pragma mark - Fetched results controller - (NSFetchedResultsController *)fetchedResultsController