forked from bettar/miele-lxiv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnonymizationTemplateNamePanelController.mm
61 lines (45 loc) · 1.83 KB
/
AnonymizationTemplateNamePanelController.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*=========================================================================
Program: OsiriX
Copyright (c) OsiriX Team
All rights reserved.
Distributed under GNU - LGPL
See http://www.osirix-viewer.com/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#import "AnonymizationTemplateNamePanelController.h"
@implementation AnonymizationTemplateNamePanelController
@synthesize nameField;
@synthesize okButton;
@synthesize cancelButton;
@synthesize replaceValues;
-(void)observeTextDidChangeNotification:(NSNotification*)notif {
if ([self.replaceValues containsObject:self.nameField.stringValue])
self.okButton.title = NSLocalizedString(@"Replace", NULL);
else self.okButton.title = NSLocalizedString(@"Save", NULL);
[self.okButton setEnabled:self.nameField.stringValue.length > 0 ];
}
-(id)initWithReplaceValues:(NSArray*)values {
self = [super initWithWindowNibName:@"AnonymizationTemplateNamePanel"];
[self window]; // load
self.replaceValues = values;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(observeTextDidChangeNotification:) name:NSControlTextDidChangeNotification object:self.nameField];
[self observeTextDidChangeNotification:NULL];
return self;
}
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSControlTextDidChangeNotification object:self.nameField];
self.replaceValues = NULL;
[super dealloc];
}
-(NSString*)value {
return self.nameField.stringValue;
}
-(IBAction)okButtonAction:(id)sender {
[NSApp endSheet:self.window];
}
-(IBAction)cancelButtonAction:(id)sender {
[NSApp endSheet:self.window returnCode:NSRunAbortedResponse];
}
@end