mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 22:52:26 +00:00
Centralized actions inside MPDocumetnWindowController
This commit is contained in:
@@ -510,7 +510,7 @@
|
||||
4C26C34A18D8D5A300CF1A1C /* PreviewView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreviewView.xib; sourceTree = "<group>"; };
|
||||
4C2724D51778FF1A00FD8456 /* NSUUID+KeePassKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSUUID+KeePassKit.h"; sourceTree = "<group>"; };
|
||||
4C2724D61778FF1A00FD8456 /* NSUUID+KeePassKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSUUID+KeePassKit.m"; sourceTree = "<group>"; };
|
||||
4C2B0B7419F66F6400E48913 /* MPTargetItemResolving.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTargetItemResolving.h; sourceTree = "<group>"; };
|
||||
4C2B0B7419F66F6400E48913 /* MPTargetNodeResolving.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPTargetNodeResolving.h; sourceTree = "<group>"; };
|
||||
4C2C8B331787500E009649F3 /* UnprotectedWarningView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UnprotectedWarningView.xib; sourceTree = "<group>"; };
|
||||
4C2E381A16D11FF900037A9D /* 03_ServerTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 03_ServerTemplate.pdf; sourceTree = "<group>"; };
|
||||
4C2E381B16D11FF900037A9D /* 04_KlipperTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 04_KlipperTemplate.pdf; sourceTree = "<group>"; };
|
||||
@@ -1683,7 +1683,7 @@
|
||||
children = (
|
||||
4CF6C715176F5183007A811D /* MPServerRequestHandling.h */,
|
||||
4CA0B30D15BCB6FD00654E32 /* MPSettingsTab.h */,
|
||||
4C2B0B7419F66F6400E48913 /* MPTargetItemResolving.h */,
|
||||
4C2B0B7419F66F6400E48913 /* MPTargetNodeResolving.h */,
|
||||
);
|
||||
name = Protocolls;
|
||||
sourceTree = "<group>";
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5056" systemVersion="13E28" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment defaultVersion="1080" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5056"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MPGroupInspectorViewController">
|
||||
@@ -18,21 +18,18 @@
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="37" customClass="HNHScrollView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="257" height="261"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<clipView key="contentView" id="HjA-kA-fcX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="257" height="261"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view translatesAutoresizingMaskIntoConstraints="NO" id="38" customClass="HNHScrollDocumentViewAdapter">
|
||||
<rect key="frame" x="0.0" y="0.0" width="257" height="261"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="24">
|
||||
<rect key="frame" x="18" y="242" width="35" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Name" id="25">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -41,7 +38,6 @@
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="23" customClass="HNHRoundedTextField">
|
||||
<rect key="frame" x="20" y="212" width="217" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="26">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -53,7 +49,6 @@
|
||||
</textField>
|
||||
<button horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="5">
|
||||
<rect key="frame" x="18" y="184" width="67" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="14" id="pWR-o1-KI6"/>
|
||||
</constraints>
|
||||
@@ -67,7 +62,6 @@
|
||||
</button>
|
||||
<button focusRingType="exterior" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="4">
|
||||
<rect key="frame" x="206" y="183" width="31" height="19"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="31" id="l5I-EF-dHs"/>
|
||||
</constraints>
|
||||
@@ -82,7 +76,6 @@
|
||||
</button>
|
||||
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="229">
|
||||
<rect key="frame" x="18" y="128" width="222" height="26"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="230">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
@@ -102,7 +95,6 @@
|
||||
</popUpButton>
|
||||
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="240">
|
||||
<rect key="frame" x="18" y="73" width="222" height="26"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="242">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="menu"/>
|
||||
@@ -120,7 +112,6 @@
|
||||
</popUpButton>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="264">
|
||||
<rect key="frame" x="18" y="160" width="40" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Search" id="265">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -129,7 +120,6 @@
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="276">
|
||||
<rect key="frame" x="18" y="105" width="53" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Autotype" id="277">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -138,7 +128,6 @@
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fnw-qz-IZU" customClass="HNHRoundedTextField">
|
||||
<rect key="frame" x="20" y="20" width="217" height="22"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="VeF-V7-i2I">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
@@ -150,7 +139,6 @@
|
||||
</textField>
|
||||
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6Lw-XW-x20">
|
||||
<rect key="frame" x="18" y="50" width="107" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Autotype Sequence" id="6FG-UZ-Adh">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
|
||||
@@ -73,9 +73,9 @@
|
||||
<constraint firstAttribute="width" constant="32" id="3027"/>
|
||||
<constraint firstAttribute="height" constant="32" id="3028"/>
|
||||
</constraints>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSActionTemplate" id="2999"/>
|
||||
<imageCell key="cell" alignment="left" imageScaling="proportionallyUpOrDown" image="NSActionTemplate" id="2999"/>
|
||||
<connections>
|
||||
<action selector="pickIcon:" target="-1" id="IZz-hu-GkW"/>
|
||||
<action selector="pickIcon:" target="-2" id="6wh-Ka-Thl"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="3013">
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "KPKVersion.h"
|
||||
#import "MPEntrySearchContext.h"
|
||||
#import "MPTargetNodeResolving.h"
|
||||
|
||||
/**
|
||||
* Posted when a new group was added to the document.
|
||||
@@ -59,7 +60,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
@class KPKNode;
|
||||
@class MPEditSession;
|
||||
|
||||
@interface MPDocument : NSDocument
|
||||
@interface MPDocument : NSDocument <MPTargetNodeResolving>
|
||||
|
||||
|
||||
@property (nonatomic, readonly, assign) BOOL encrypted;
|
||||
@@ -164,6 +165,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
- (KPKEntry *)createEntry:(KPKGroup *)parent;
|
||||
- (KPKAttribute *)createCustomAttribute:(KPKEntry *)entry;
|
||||
|
||||
- (void)deleteNode:(KPKNode *)node;
|
||||
- (void)deleteGroup:(KPKGroup *)group;
|
||||
- (void)deleteEntry:(KPKEntry *)entry;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#import "MPConstants.h"
|
||||
#import "MPSavePanelAccessoryViewController.h"
|
||||
#import "MPTreeDelegate.h"
|
||||
#import "MPTargetItemResolving.h"
|
||||
#import "MPTargetNodeResolving.h"
|
||||
|
||||
|
||||
#import "DDXMLNode.h"
|
||||
@@ -512,7 +512,19 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
return newAttribute;
|
||||
}
|
||||
|
||||
- (void)deleteNode:(KPKNode *)node {
|
||||
if([node asGroup]) {
|
||||
[self deleteGroup:[node asGroup]];
|
||||
}
|
||||
else if([node asEntry]) {
|
||||
[self deleteEntry:[node asEntry]];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteEntry:(KPKEntry *)entry {
|
||||
if(!entry) {
|
||||
return; // Nothing to do;
|
||||
}
|
||||
if(self.useTrash) {
|
||||
if([self isItemTrashed:entry]) {
|
||||
return; // Entry is already trashed
|
||||
@@ -615,11 +627,13 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
}
|
||||
|
||||
- (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)anItem {
|
||||
id target = [NSApp targetForAction:@selector(targetItemForAction)];
|
||||
KPKNode *targetNode = [target targetItemForAction];
|
||||
KPKEntry *targetEntry = [targetNode asEntry];
|
||||
KPKGroup *targetGroup = [targetNode asGroup];
|
||||
|
||||
id<MPTargetNodeResolving> entryResolver = [NSApp targetForAction:@selector(currentTargetEntry)];
|
||||
id<MPTargetNodeResolving> groupResolver = [NSApp targetForAction:@selector(currentTargetGroup)];
|
||||
id<MPTargetNodeResolving> nodeResolver = [NSApp targetForAction:@selector(currentTargetNode)];
|
||||
KPKNode *targetNode = [nodeResolver currentTargetNode];
|
||||
KPKEntry *targetEntry = [entryResolver currentTargetEntry];
|
||||
KPKGroup *targetGroup = [groupResolver currentTargetGroup];
|
||||
|
||||
if(self.encrypted || self.isReadOnly) { return NO; }
|
||||
|
||||
BOOL valid = self.selectedItem ? self.selectedItem.isEditable : YES;
|
||||
@@ -640,9 +654,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
valid &= ![self isItemTrashed:self.selectedItem];
|
||||
break;
|
||||
case MPActionCloneEntry:
|
||||
//case MPActionCloneEntryWithOptions:
|
||||
valid &= (nil != self.selectedItem);
|
||||
valid &= self.selectedEntry == self.selectedItem;
|
||||
valid &= (nil != targetEntry);
|
||||
break;
|
||||
case MPActionEmptyTrash:
|
||||
valid &= ([self.trash.groups count] + [self.trash.entries count]) > 0;
|
||||
@@ -720,6 +732,18 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
[self.trash clear];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark MPTargetNodeResolving
|
||||
|
||||
- (KPKEntry *)currentTargetEntry {
|
||||
return self.selectedEntry;
|
||||
}
|
||||
|
||||
- (KPKGroup *)currentTargetGroup {
|
||||
return self.selectedGroup;
|
||||
}
|
||||
|
||||
|
||||
# pragma mark File Watching
|
||||
- (void) _watchForFileChanges:(BOOL)watch {
|
||||
}
|
||||
|
||||
@@ -45,8 +45,9 @@
|
||||
|
||||
- (IBAction)lock:(id)sender;
|
||||
- (IBAction)createGroup:(id)sender;
|
||||
- (IBAction)createEntry:(id)sender;
|
||||
- (IBAction)delete:(id)sender;
|
||||
|
||||
- (IBAction)pickIcon:(id)sender;
|
||||
- (IBAction)pickExpiryDate:(id)sender;
|
||||
|
||||
#pragma mark Helper
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#import "MPContextToolbarButton.h"
|
||||
#import "KPKTree.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKCompositeKey.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MPAlertContext) {
|
||||
@@ -326,15 +327,25 @@ typedef void (^MPPasswordChangedBlock)(BOOL didChangePassword);
|
||||
}
|
||||
|
||||
- (void)createGroup:(id)sender {
|
||||
[self.outlineViewController createGroup:nil];
|
||||
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroup)];
|
||||
KPKGroup *group = [target currentTargetGroup];
|
||||
MPDocument *document = self.document;
|
||||
if(!group) {
|
||||
group = document.root;
|
||||
}
|
||||
[document createGroup:group];
|
||||
}
|
||||
|
||||
- (void)createEntry:(id)sender {
|
||||
[self.outlineViewController createEntry:nil];
|
||||
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetGroup)];
|
||||
KPKGroup *group = [target currentTargetGroup];
|
||||
[(MPDocument *)self.document createEntry:group];
|
||||
}
|
||||
|
||||
- (void)pickIcon:(id)sender {
|
||||
[self.inspectorViewController pickIcon:sender];
|
||||
- (void)delete:(id)sender {
|
||||
id<MPTargetNodeResolving> target = [NSApp targetForAction:@selector(currentTargetNode)];
|
||||
KPKNode *node = [target currentTargetNode];
|
||||
[self.document deleteNode:node];
|
||||
}
|
||||
|
||||
- (void)pickExpiryDate:(id)sender {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPContextBarViewController.h"
|
||||
#import "MPTargetItemResolving.h"
|
||||
#import "MPTargetNodeResolving.h"
|
||||
|
||||
APPKIT_EXTERN NSString *const MPEntryTableUserNameColumnIdentifier;
|
||||
APPKIT_EXTERN NSString *const MPEntryTableTitleColumnIdentifier;
|
||||
@@ -32,7 +32,7 @@ typedef NS_ENUM( NSUInteger, MPCopyContentTypeTag) {
|
||||
@class MPDocumentWindowController;
|
||||
@class MPDocument;
|
||||
|
||||
@interface MPEntryViewController : MPViewController <NSTableViewDelegate, MPTargetItemResolving>
|
||||
@interface MPEntryViewController : MPViewController <NSTableViewDelegate, MPTargetNodeResolving>
|
||||
|
||||
@property (weak,readonly) NSTableView *entryTable;
|
||||
@property (readonly, strong) NSArrayController *entryArrayController;
|
||||
|
||||
@@ -340,7 +340,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
}
|
||||
|
||||
#pragma mark MPTargetItemResolving
|
||||
- (KPKNode *)targetItemForAction {
|
||||
- (KPKEntry *)currentTargetEntry {
|
||||
NSInteger activeRow = [self.entryTable clickedRow];
|
||||
/* Fallback to selection e.g. for toolbar actions */
|
||||
if(activeRow < 0 ) {
|
||||
@@ -352,6 +352,15 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (KPKNode *)currentTargetNode {
|
||||
KPKEntry *entry = [self currentTargetEntry];
|
||||
if(entry) {
|
||||
return entry;
|
||||
}
|
||||
MPDocument *document = [[self windowController] document];
|
||||
return document.selectedItem;
|
||||
}
|
||||
|
||||
#pragma mark MPDocument Notifications
|
||||
- (void)_didChangeCurrentItem:(NSNotification *)notification {
|
||||
MPDocument *document = [notification object];
|
||||
@@ -597,21 +606,21 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
|
||||
#pragma mark Actions
|
||||
- (void)copyPassword:(id)sender {
|
||||
KPKEntry *selectedEntry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||
if(selectedEntry) {
|
||||
[self _copyToPasteboard:[selectedEntry.password finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)copyUsername:(id)sender {
|
||||
KPKEntry *selectedEntry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||
if(selectedEntry) {
|
||||
[self _copyToPasteboard:[selectedEntry.username finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)copyCustomAttribute:(id)sender {
|
||||
KPKEntry *selectedEntry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||
if(selectedEntry && [selectedEntry isKindOfClass:[KPKEntry class]]) {
|
||||
NSUInteger index = [sender tag];
|
||||
NSAssert((index >= 0) && (index < [selectedEntry.customAttributes count]), @"Index for custom field needs to be valid");
|
||||
@@ -621,14 +630,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
}
|
||||
|
||||
- (void)copyURL:(id)sender {
|
||||
KPKEntry *selectedEntry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||
if(selectedEntry) {
|
||||
[self _copyToPasteboard:[selectedEntry.url finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openURL:(id)sender {
|
||||
KPKEntry *selectedEntry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *selectedEntry = [[self currentTargetNode] asEntry];
|
||||
if(selectedEntry && [selectedEntry.url length] > 0) {
|
||||
NSURL *webURL = [NSURL URLWithString:[selectedEntry.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
|
||||
NSString *scheme = [webURL scheme];
|
||||
@@ -650,7 +659,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender {
|
||||
KPKEntry *entry = [[self targetItemForAction] asEntry];
|
||||
KPKEntry *entry = [[self currentTargetNode] asEntry];
|
||||
if(!entry) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[self.bottomBar setBorderType:HNHBorderTop|HNHBorderHighlight];
|
||||
|
||||
|
||||
[[self.noSelectionInfo cell] setBackgroundStyle:NSBackgroundStyleRaised];
|
||||
[[self.itemImageView cell] setBackgroundStyle:NSBackgroundStyleRaised];
|
||||
[self.tabView bind:NSSelectedIndexBinding toObject:self withKeyPath:@"activeTab" options:nil];
|
||||
@@ -304,6 +304,7 @@ typedef NS_ENUM(NSUInteger, MPContentTab) {
|
||||
[self.itemNameTextField setHidden:NO];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark MPDocument Notifications
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
//
|
||||
|
||||
#import "MPViewController.h"
|
||||
#import "MPTargetItemResolving.h"
|
||||
#import "MPTargetNodeResolving.h"
|
||||
|
||||
APPKIT_EXTERN NSString *const MPOutlineViewDidChangeGroupSelection;
|
||||
|
||||
@class HNHGradientView;
|
||||
@class MPDocument;
|
||||
|
||||
@interface MPOutlineViewController : MPViewController <MPTargetItemResolving, NSOutlineViewDelegate, NSMenuDelegate>
|
||||
@interface MPOutlineViewController : MPViewController <MPTargetNodeResolving, NSOutlineViewDelegate, NSMenuDelegate>
|
||||
|
||||
|
||||
@property (weak) IBOutlet HNHGradientView *bottomBar;
|
||||
@@ -23,8 +23,6 @@ APPKIT_EXTERN NSString *const MPOutlineViewDidChangeGroupSelection;
|
||||
- (void)showOutline;
|
||||
- (void)regsiterNotificationsForDocument:(MPDocument *)document;
|
||||
|
||||
- (void)createGroup:(id)sender;
|
||||
- (void)createEntry:(id)sender;
|
||||
/**
|
||||
* Retrieves the current item for the current mouse location
|
||||
* @return Item under mouse. If the mouse isn't inside the view, nil is returned
|
||||
|
||||
@@ -7,22 +7,23 @@
|
||||
//
|
||||
|
||||
#import "MPOutlineViewController.h"
|
||||
#import "MPOutlineDataSource.h"
|
||||
#import "MPActionHelper.h"
|
||||
#import "MPConstants.h"
|
||||
#import "MPContextMenuHelper.h"
|
||||
#import "MPDocument.h"
|
||||
#import "MPDocumentWindowController.h"
|
||||
#import "MPContextMenuHelper.h"
|
||||
#import "MPConstants.h"
|
||||
#import "MPActionHelper.h"
|
||||
#import "MPIconHelper.h"
|
||||
#import "MPNotifications.h"
|
||||
#import "MPOutlineContextMenuDelegate.h"
|
||||
#import "MPOutlineDataSource.h"
|
||||
|
||||
#import "KPKTree.h"
|
||||
#import "KPKNode.h"
|
||||
#import "KPKTimeInfo.h"
|
||||
#import "KPKEntry.h"
|
||||
#import "KPKGroup.h"
|
||||
#import "KPKNode+IconImage.h"
|
||||
#import "KPKMetaData.h"
|
||||
#import "KPKNode.h"
|
||||
#import "KPKNode+IconImage.h"
|
||||
#import "KPKTimeInfo.h"
|
||||
#import "KPKTree.h"
|
||||
#import "KPKUTIs.h"
|
||||
|
||||
#import "HNHGradientView.h"
|
||||
@@ -136,17 +137,12 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
#pragma mark Custom Setter/Getter
|
||||
- (void)setDatabaseNameWrapper:(NSString *)databaseNameWrapper {
|
||||
if(![_databaseNameWrapper isEqualToString:databaseNameWrapper]) {
|
||||
if([databaseNameWrapper length] == 0) {
|
||||
_databaseNameWrapper = NSLocalizedString(@"DATABASE", "Default name database");
|
||||
}
|
||||
else {
|
||||
_databaseNameWrapper= [databaseNameWrapper copy];
|
||||
}
|
||||
_databaseNameWrapper = (databaseNameWrapper.length == 0) ? NSLocalizedString(@"DATABASE", "Default name database") : [databaseNameWrapper copy];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark MPTargetItemResolving
|
||||
- (KPKNode *)targetItemForAction {
|
||||
#pragma mark MPTargetNodeResolving
|
||||
- (KPKGroup *)currentTargetGroup {
|
||||
NSInteger row = [self.outlineView clickedRow];
|
||||
if( row < 0 ) {
|
||||
row = [self.outlineView selectedRow];
|
||||
@@ -154,6 +150,15 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
return [[self.outlineView itemAtRow:row] representedObject];
|
||||
}
|
||||
|
||||
- (KPKNode *)currentTargetNode {
|
||||
KPKGroup *group = [self currentTargetGroup];
|
||||
if(group) {
|
||||
return group;
|
||||
}
|
||||
MPDocument *document = [[self windowController] document];
|
||||
return document.selectedItem;
|
||||
}
|
||||
|
||||
#pragma mark Notifications
|
||||
- (void)regsiterNotificationsForDocument:(MPDocument *)document {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didAddGroup:) name:MPDocumentDidAddGroupNotification object:document];
|
||||
@@ -197,24 +202,6 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
#pragma mark -
|
||||
#pragma mark Actions
|
||||
|
||||
- (void)createGroup:(id)sender {
|
||||
KPKGroup *group = [[self targetItemForAction] asGroup];
|
||||
MPDocument *document = [[self windowController] document];
|
||||
if(!group) {
|
||||
group = document.root;
|
||||
}
|
||||
[document createGroup:group];
|
||||
}
|
||||
|
||||
- (void)createEntry:(id)sender {
|
||||
MPDocument *document = [[self windowController] document];
|
||||
[document createEntry:[[self targetItemForAction] asGroup]];
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender {
|
||||
[[[self windowController] document] deleteGroup:[[self targetItemForAction] asGroup]];
|
||||
}
|
||||
|
||||
- (void)_doubleClickedGroup:(id)sender {
|
||||
[[self windowController] showInspector:sender];
|
||||
}
|
||||
@@ -290,7 +277,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
|
||||
if(![document validateUserInterfaceItem:menuItem]) {
|
||||
return NO;
|
||||
}
|
||||
id selected = [[self targetItemForAction] asGroup];
|
||||
id selected = [[self currentTargetNode] asGroup];
|
||||
if(!selected) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,15 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
@class KPKEntry;
|
||||
@class KPKGroup;
|
||||
@class KPKNode;
|
||||
|
||||
@protocol MPTargetItemResolving <NSObject>
|
||||
@protocol MPTargetNodeResolving <NSObject>
|
||||
|
||||
@required
|
||||
- (KPKNode *)targetItemForAction;
|
||||
@optional
|
||||
- (KPKNode *)currentTargetNode;
|
||||
- (KPKGroup *)currentTargetGroup;
|
||||
- (KPKEntry *)currentTargetEntry;
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user