Commits

Tuukka Norri committed 4a877a0

Disabled some menu items when there isn't a database connection

  • Participants
  • Parent commits 3f6610e

Comments (0)

Files changed (2)

File BaseTenAssistant/Sources/BXAController.m

 	{
 		retval = YES; // YES by default
 		if(action == @selector(upgradeSchema:))
-			retval = ([self canUpgradeSchema] || ![self hasBaseTenSchema]);
+			retval = ([mContext isConnected] && ([self canUpgradeSchema] || ![self hasBaseTenSchema]));
 		else if(action == @selector(removeSchema:))
-			retval = [self hasBaseTenSchema];
+			retval = ([mContext isConnected] && [self hasBaseTenSchema]);
 		else if(action == @selector(exportLog:))
 			retval = [self canExportLog];
 		else if(action == @selector(importDataModel:))
 			retval = [self canImportDataModel];
-		else if(action == @selector(disconnect:) || action == @selector(reload:))
+		else if(action == @selector(disconnect:) || action == @selector(reload:) || action == @selector (refreshCacheTables:) || action == @selector (prune:))
 			retval = ([mContext isConnected] && ![mProgressPanel isVisible]);
 		else if(action == @selector(getInfo:))
 			retval = ([[mEntities selectedObjects] count] > 0);

File BaseTenAssistant/Sources/BXAInspectorPanelController.m

 	}
 }
 
+
 #pragma mark Initialisation & Dealloc
 
 + (void)initialize
 		
 		NSRect frame = [[NSScreen mainScreen] frame];
 		gLastPoint = NSMakePoint (0.0, frame.origin.y + frame.size.height);
-								  
-		[self setKeys:[NSArray arrayWithObject:@"entity"] triggerChangeNotificationsForDependentKey:@"entityTitle"];
-		[self setKeys:[NSArray arrayWithObject:@"entity"] triggerChangeNotificationsForDependentKey:@"entityName"];
-		[self setKeys:[NSArray arrayWithObject:@"entity"] triggerChangeNotificationsForDependentKey:@"entityIcon"];		
 	}	
 }
 
+
 + (id) inspectorPanelController
 {
 	static BXAInspectorPanelController* sInspector;
 	return sInspector;
 }
 
+
 - (NSWindow *) windowPrototype: (NSRect) contentRect
 {
 	NSUInteger windowStyle = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSUtilityWindowMask;
 	return window;
 }
 
+
 - (id) init
 {
 	if ((self = [super initWithWindowNibName: @"InspectorView"]))
 	return self;
 }
 
+
 - (void) awakeFromNib
 {
 	NSWindow* window = [self windowPrototype: [mEntityAttributesView frame]];
 	return [NSPredicate predicateWithFormat: @"value.isExcluded == false && value.isDeprecated == false"];
 }
 
+
++ (NSSet *) keyPathsForValuesAffectingEntityTitle
+{
+	return [NSSet setWithObject: @"entity"];
+}
+
+
 - (NSString *) entityTitle
 {
 	NSString* outTitle;
 	return outTitle;
 }
 
+
++ (NSSet *) keyPathsForValuesAffectingEntityName
+{
+	return [NSSet setWithObject: @"entity"];
+}
+
+
 - (NSString *) entityName
 {
 	if([self entity] == nil)
 		return [[self entity] name];
 }
 
+
++ (NSSet *) keyPathsForValuesAffectingEntityIcon
+{
+	return [NSSet setWithObject: @"entity"];
+}
+
+
 - (NSImage *) entityIcon
 {
 	NSImage* outImage = nil;
 	return outImage;
 }
 
+
 - (BOOL) isWindowVisible
 {
 	return [[self window] isVisible];
 }
 
+
 - (IBAction) closeWindow: (id) sender;
 {
 	[[self window] performClose: sender];
 	[self bind:@"entity" toObject: observable withKeyPath: keypath options:nil];
 }
 
+
 - (void) observeValueForKeyPath: (NSString *) keyPath ofObject: (id) object 
 						 change: (NSDictionary *) change context: (void *) context
 {
 		[super observeValueForKeyPath: keyPath ofObject: object change: change context: context];
 	}
 }
-
-
 @end