Actions for add and remove of window associations stubbed

Autotype inspector binding extended
This commit is contained in:
michael starke
2014-02-14 22:39:55 +01:00
parent 62bec29ec8
commit f634ed09d0
5 changed files with 46 additions and 13 deletions

View File

@@ -855,7 +855,7 @@
</constraints>
<buttonCell key="cell" type="roundRect" bezelStyle="roundedRect" image="NSAddTemplate" imagePosition="only" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5J6-uD-iK6">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="controlContent"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="AAj-Ak-z46">

View File

@@ -35,7 +35,6 @@ NSString *const kMPApplciationNameKey = @"applicationName";
}
- (void)_didPressHotKey {
// copy items to pasteboard
NSArray *documents = [NSApp orderedDocuments];
MPDocument *currentDocument = nil;
for(MPDocument *openDocument in documents) {

View File

@@ -55,6 +55,9 @@
- (IBAction)addCustomField:(id)sender;
- (IBAction)removeCustomField:(id)sender;
- (IBAction)addWindowAssociation:(id)sender;
- (IBAction)removeWindowAssociation:(id)sender;
- (void)beginEditing;
- (void)endEditing;

View File

@@ -115,17 +115,17 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
#pragma mark -
#pragma mark Actions
- (IBAction)addCustomField:(id)sender {
- (void)addCustomField:(id)sender {
MPDocument *document = [[self windowController] document];
[document createCustomAttribute:self.entry];
}
- (IBAction)removeCustomField:(id)sender {
- (void)removeCustomField:(id)sender {
NSUInteger index = [sender tag];
KPKAttribute *attribute = self.entry.customAttributes[index];
[self.entry removeCustomAttribute:attribute];
}
- (IBAction)saveAttachment:(id)sender {
- (void)saveAttachment:(id)sender {
KPKBinary *binary = self.entry.binaries[[sender tag]];
NSSavePanel *savePanel = [NSSavePanel savePanel];
[savePanel setCanCreateDirectories:YES];
@@ -138,7 +138,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}];
}
- (IBAction)addAttachment:(id)sender {
- (void)addAttachment:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseFiles:YES];
@@ -153,11 +153,20 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}];
}
- (IBAction)removeAttachment:(id)sender {
- (void)removeAttachment:(id)sender {
KPKBinary *binary = self.entry.binaries[[sender tag]];
[self.entry removeBinary:binary];
}
- (void)addWindowAssociation:(id)sender {
}
- (void)removeWindowAssociation:(id)sender {
NSInteger row = [self.windowAssociationsTableView selectedRow];
if(row > - 1 && row < [self.entry.autotype.associations count]) {
}
}
#pragma mark Editing
- (void)beginEditing {
[self _toggleEditing:YES];
@@ -285,14 +294,31 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
}
- (void)_bindCustomFields {
[_customFieldsController bind:NSContentArrayBinding toObject:self.entry withKeyPath:@"customAttributes" options:nil];
if(self.entry) {
[_customFieldsController bind:NSContentArrayBinding toObject:self.entry withKeyPath:@"customAttributes" options:nil];
}
else if ([_customFieldsController content] != nil ) {
[_customFieldsController unbind:NSContentArrayBinding];
[_customFieldsController setContent:nil];
}
}
- (void)_bindAutotype {
[self.enableAutotypeCheckButton bind:NSValueBinding toObject:self.entry.autotype withKeyPath:@"isEnabled" options:nil];
[self.customEntrySequenceTextField bind:NSEnabledBinding toObject:self.entry.autotype withKeyPath:@"isEnabled" options:nil];
[self.customEntrySequenceTextField bind:NSValueBinding toObject:self.entry.autotype withKeyPath:@"defaultSequence" options:nil];
[_windowAssociationsController bind:NSContentArrayBinding toObject:self.entry.autotype withKeyPath:@"associations" options:nil];
if(self.entry) {
[self.enableAutotypeCheckButton bind:NSValueBinding toObject:self.entry.autotype withKeyPath:@"isEnabled" options:nil];
[self.customEntrySequenceTextField bind:NSEnabledBinding toObject:self.entry.autotype withKeyPath:@"isEnabled" options:nil];
[self.customEntrySequenceTextField bind:NSValueBinding toObject:self.entry.autotype withKeyPath:@"defaultSequence" options:nil];
[_windowAssociationsController bind:NSContentArrayBinding toObject:self.entry.autotype withKeyPath:@"associations" options:nil];
}
else {
[self.enableAutotypeCheckButton unbind:NSValueBinding];
[self.customEntrySequenceTextField unbind:NSEnabledBinding];
[self.customEntrySequenceTextField unbind:NSValueBinding];
if([_windowAssociationsController content] != nil) {
[_windowAssociationsController unbind:NSContentArrayBinding];
[_windowAssociationsController setContent:nil];
}
}
}
- (void)_toggleEditing:(BOOL)edit {
@@ -313,7 +339,7 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
[_notesTextView setSelectable:edit];
[_modifiedTextField setEditable:edit];
[_modifiedTextField setSelectable:edit];
}
@end

View File

@@ -10,6 +10,11 @@
"KPK_GROUP_COPY_%@" = "Kopie von %@";
"KPK_ENTRY_COPY_%@" = "Kopie von %@";
/* Validation Errors */
"ERROR_WINDOW_TITLE_VALIDATION_FAILED" = "The Format of the Window Title is not valid!";
"ERROR_ATTRIBUTE_KEY_VALIDATION_FAILED" = "The Attribute Key is not unique!";
"ERROR_AUTOTYPE_SEQUENCE_VALIDATION_FAILED" = "Tht Autotype Sequence is not valid!";
/* Errors */
"ERROR_CORRUPT_TREE" = "The internal file structure is corrupted!";
"ERROR_INVALID_FIELD_SIZE" = "A data filed has an incorrect size!";