moving more code to @properties, ReferenceBuilder WIP

This commit is contained in:
michael starke
2014-12-05 02:57:10 +01:00
parent a47bba23b0
commit 90f844f87e
11 changed files with 137 additions and 45 deletions

View File

@@ -284,6 +284,7 @@
4CE2961518429AA5005F01CE /* MPAutotypeKeyPress.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE2961418429AA5005F01CE /* MPAutotypeKeyPress.m */; };
4CE296191842A166005F01CE /* MPAutotypePaste.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE296181842A166005F01CE /* MPAutotypePaste.m */; };
4CE298EB1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE298EA1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m */; };
4CE30ACC1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE30ACB1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m */; };
4CE39ABF16ECE34A000FE29D /* MPIconSelectViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */; };
4CE39AC416ECE4F7000FE29D /* MPPopupImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE39AC316ECE4F7000FE29D /* MPPopupImageView.m */; };
4CE3E62617AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CE3E62517AB0D2D00D9E4B4 /* MPAttachmentTableDataSource.m */; };
@@ -893,6 +894,8 @@
4CE296181842A166005F01CE /* MPAutotypePaste.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypePaste.m; sourceTree = "<group>"; };
4CE298E91795FC2A00DF7BDB /* MPEntryContextMenuDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPEntryContextMenuDelegate.h; sourceTree = "<group>"; };
4CE298EA1795FC2A00DF7BDB /* MPEntryContextMenuDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryContextMenuDelegate.m; sourceTree = "<group>"; };
4CE30ACA1A312B7F0063FCC6 /* MPReferenceBuilderViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPReferenceBuilderViewController.h; sourceTree = "<group>"; };
4CE30ACB1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPReferenceBuilderViewController.m; sourceTree = "<group>"; };
4CE39ABD16ECE34A000FE29D /* MPIconSelectViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPIconSelectViewController.h; sourceTree = "<group>"; };
4CE39ABE16ECE34A000FE29D /* MPIconSelectViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIconSelectViewController.m; sourceTree = "<group>"; };
4CE39AC216ECE4F7000FE29D /* MPPopupImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPopupImageView.h; sourceTree = "<group>"; };
@@ -1090,6 +1093,7 @@
4C2C8B331787500E009649F3 /* UnprotectedWarningView.xib */,
6021FE7918E15FF300C3BC51 /* DatePickingView.xib */,
4C26C34A18D8D5A300CF1A1C /* PreviewView.xib */,
4C99E6A41A30FDFD00E2BA8D /* ReferenceBuilderView.xib */,
4C74DD05177BD1640034A9DB /* MPCustomFieldView.h */,
4C74DD06177BD1640034A9DB /* MPCustomFieldView.m */,
4CE8247316E2F2B900573141 /* MPOverlayView.h */,
@@ -1106,7 +1110,6 @@
4C5FE9AD17843CE20001D5A8 /* MPSelectedAttachmentTableCellView.m */,
4CCEDE28179F203B008402BE /* MPOutlineView.h */,
4CCEDE29179F203B008402BE /* MPOutlineView.m */,
4C99E6A41A30FDFD00E2BA8D /* ReferenceBuilderView.xib */,
);
name = Views;
sourceTree = "<group>";
@@ -1711,6 +1714,8 @@
4C1E9884185F71A800943563 /* MPContextBarViewController.m */,
4C26C34818D8D5A300CF1A1C /* MPPreviewViewController.h */,
4C26C34918D8D5A300CF1A1C /* MPPreviewViewController.m */,
4CE30ACA1A312B7F0063FCC6 /* MPReferenceBuilderViewController.h */,
4CE30ACB1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m */,
);
name = "View Controller";
sourceTree = "<group>";
@@ -2405,6 +2410,7 @@
4C88C66918D9F8D600F43852 /* MPTemporaryFileStorageCenter.m in Sources */,
4C245B79176E1E3D0086100E /* HTTPAuthenticationRequest.m in Sources */,
4C245B7A176E1E3D0086100E /* HTTPConnection.m in Sources */,
4CE30ACC1A312B7F0063FCC6 /* MPReferenceBuilderViewController.m in Sources */,
4C6F228C19A4AA700012310C /* MPAutotypeDelay.m in Sources */,
4C245B7B176E1E3D0086100E /* HTTPMessage.m in Sources */,
4C3C4EA718D6FEA100153127 /* TTTStringTransformers.m in Sources */,

View File

@@ -620,7 +620,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IpW-b2-jWu" customClass="HNHRoundedTextField">
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="IpW-b2-jWu" customClass="HNHRoundedTextField">
<rect key="frame" x="20" y="20" width="212" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="Zfy-mh-1TF"/>

View File

@@ -87,7 +87,6 @@
BOOL missingModifier = self.modifierFlags == 0;
BOOL onlyModifiers = MPIsFlagSetInOptions(flags, self.modifierFlags) || (self.modifierFlags != 0 && flags != 0);
BOOL isInvalid = onlyModifiers || missingModifier;
NSLog(@"%@ valid:%d", self, !isInvalid);
return !isInvalid;
}

View File

@@ -705,7 +705,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell";
MPDoubleClickTitleAction action = [[NSUserDefaults standardUserDefaults] integerForKey:kMPSettingsKeyDoubleClickTitleAction];
switch(action) {
case MPDoubleClickTitleActionInspect:
[[self windowController] showInspector:nil];
[(MPDocumentWindowController *)self.windowController showInspector:nil];
break;
case MPDoubleClickTitleActionIgnore:
break;

View File

@@ -203,7 +203,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell";
#pragma mark Actions
- (void)_doubleClickedGroup:(id)sender {
[[self windowController] showInspector:sender];
[(MPDocumentWindowController *)self.windowController showInspector:sender];
}
#pragma mark NSOutlineViewDelegate

View File

@@ -41,8 +41,7 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
return self;
}
- (void)dealloc
{
- (void)dealloc {
if(_clearPasteboardOnShutdown) {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@@ -64,8 +63,7 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
}
}
- (void)stashObjects
{
- (void)stashObjects {
self.stashedObjects = [NSMutableArray array];
for (NSPasteboardItem *item in [[NSPasteboard generalPasteboard] pasteboardItems]) {
NSPasteboardItem *newItem = [[NSPasteboardItem alloc] init];
@@ -79,10 +77,8 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
}
}
- (void)restoreObjects
{
if (self.stashedObjects)
{
- (void)restoreObjects {
if (self.stashedObjects) {
[[NSPasteboard generalPasteboard] clearContents];
[[NSPasteboard generalPasteboard] writeObjects:self.stashedObjects];
self.stashedObjects = nil;
@@ -116,10 +112,18 @@ NSString *const MPPasteBoardControllerDidClearClipboard = @"com.hicknhack.macpas
- (void)_setupBindings {
NSUserDefaultsController *userDefaultsController = [NSUserDefaultsController sharedUserDefaultsController];
NSString *clearOnShutdownKeyPath = [NSString stringWithFormat:@"values.%@", kMPSettingsKeyClearPasteboardOnQuit];
[self bind:NSStringFromSelector(@selector(clearPasteboardOnShutdown)) toObject:userDefaultsController withKeyPath:clearOnShutdownKeyPath options:nil];
NSString *clearTimoutKeyPath = [NSString stringWithFormat:@"values.%@", kMPSettingsKeyPasteboardClearTimeout];
[self bind:NSStringFromSelector(@selector(clearTimeout)) toObject:userDefaultsController withKeyPath:clearTimoutKeyPath options:nil];
NSString *clearOnShutdownKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyClearPasteboardOnQuit];
NSString *clearTimoutKeyPath = [MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyPasteboardClearTimeout];
[self bind:NSStringFromSelector(@selector(clearPasteboardOnShutdown))
toObject:userDefaultsController
withKeyPath:clearOnShutdownKeyPath
options:nil];
[self bind:NSStringFromSelector(@selector(clearTimeout))
toObject:userDefaultsController
withKeyPath:clearTimoutKeyPath
options:nil];
}
@end

View File

@@ -0,0 +1,16 @@
//
// MPReferenceBuilderViewController.h
// MacPass
//
// Created by Michael Starke on 05/12/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPViewController.h"
@interface MPReferenceBuilderViewController : MPViewController
@property (weak) IBOutlet NSPopUpButton *valuePopUpButton;
@property (weak) IBOutlet NSPopUpButton *searchKeyPopUpButton;
@property (weak) IBOutlet NSTextField *searchStringTextField;
@end

View File

@@ -0,0 +1,49 @@
//
// MPReferenceBuilderViewController.m
// MacPass
//
// Created by Michael Starke on 05/12/14.
// Copyright (c) 2014 HicknHack Software GmbH. All rights reserved.
//
#import "MPReferenceBuilderViewController.h"
@interface MPReferenceBuilderViewController ()
@end
@implementation MPReferenceBuilderViewController
- (NSString *)nibName {
return @"ReferenceBuilderView";
}
//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
// self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
// if(self) {
// }
// return self;
//}
- (void)didLoadView {
[self.searchKeyPopUpButton setMenu:[self _allocateAttributeItemMenu:YES withTitle:NSLocalizedString(@"SEARCH_VALUE", "")]];
[self.valuePopUpButton setMenu:[self _allocateAttributeItemMenu:NO withTitle:NSLocalizedString(@"OUTPUT_VALUE", "")]];
}
- (NSMenu *)_allocateAttributeItemMenu:(BOOL)allowCustomAttributes withTitle:(NSString *)title {
NSMenu *menu = [[NSMenu alloc] init];
/* first item is button label */
[menu addItemWithTitle:title action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"UUID","") action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"TITLE","") action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"USERNAME","") action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"PASSWORD","") action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"URL","") action:NULL keyEquivalent:@""];
[menu addItemWithTitle:NSLocalizedString(@"NOTES","") action:NULL keyEquivalent:@""];
if(allowCustomAttributes) {
[menu addItemWithTitle:NSLocalizedString(@"CUSTOM_ATTRIBUTE","") action:NULL keyEquivalent:@""];
}
return menu;
}
@end

View File

@@ -10,10 +10,12 @@
@interface MPViewController : NSViewController
@property (nonatomic, readonly) NSWindowController *windowController;
- (void)didLoadView;
- (NSResponder *)reconmendedFirstResponder;
/* Returns the associated window controller */
- (id)windowController;
- (void)updateResponderChain;

View File

@@ -20,8 +20,8 @@
// override
}
- (id)windowController {
return [[[self view] window] windowController];
- (NSWindowController *)windowController {
return [self.view.window windowController];
}
#pragma mark Responder Chain

View File

@@ -5,63 +5,79 @@
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner"/>
<customObject id="-2" userLabel="File's Owner" customClass="MPReferenceBuilderViewController">
<connections>
<outlet property="searchKeyPopUpButton" destination="b4e-k2-WPS" id="6xo-a4-89X"/>
<outlet property="searchStringTextField" destination="IFf-vC-3vk" id="SEI-2b-OuL"/>
<outlet property="valuePopUpButton" destination="IZP-Gd-jdU" id="QVB-Tg-ccT"/>
<outlet property="view" destination="c22-O7-iKe" id="hQR-up-044"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="308" height="98"/>
<rect key="frame" x="0.0" y="0.0" width="553" height="62"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IZP-Gd-jdU">
<rect key="frame" x="20" y="61" width="93" height="19"/>
<popUpButtonCell key="cell" type="roundRect" title="Reference" bezelStyle="roundedRect" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" pullsDown="YES" id="KPf-xE-gde">
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IZP-Gd-jdU">
<rect key="frame" x="20" y="21" width="45" height="19"/>
<popUpButtonCell key="cell" type="roundRect" bezelStyle="roundedRect" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="KPf-xE-gde">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
<menu key="menu" id="Vxk-eO-bbf">
<items>
<menuItem title="Reference" hidden="YES" id="142-bE-IMZ"/>
<menuItem title="Get" state="on" id="142-bE-IMZ"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="b4e-k2-WPS">
<rect key="frame" x="121" y="61" width="63" height="19"/>
<popUpButtonCell key="cell" type="roundRect" title="where" bezelStyle="roundedRect" alignment="center" lineBreakMode="truncatingTail" borderStyle="border" imageScaling="proportionallyDown" inset="2" pullsDown="YES" id="Aob-tW-bUP">
<popUpButton horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="b4e-k2-WPS">
<rect key="frame" x="73" y="21" width="85" height="19"/>
<popUpButtonCell key="cell" type="roundRect" title="Matching" bezelStyle="roundedRect" alignment="center" lineBreakMode="truncatingTail" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" selectedItem="yT1-XL-k6a" id="Aob-tW-bUP">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="titleBar" size="12"/>
<font key="font" metaFont="cellTitle"/>
<menu key="menu" id="j2A-qj-k7L">
<items>
<menuItem title="where" hidden="YES" id="yT1-XL-k6a">
<menuItem title="Matching" state="on" id="yT1-XL-k6a">
<modifierMask key="keyEquivalentModifierMask" shift="YES"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="IFf-vC-3vk">
<rect key="frame" x="192" y="60" width="96" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="fNP-ye-2bD">
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IFf-vC-3vk">
<rect key="frame" x="167" y="20" width="321" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="100" id="Seu-01-P53"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="for value" drawsBackground="YES" id="fNP-ye-2bD">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="T2o-aJ-JmD">
<rect key="frame" x="172" y="18" width="116" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Use Reference" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Kqx-qm-nMG">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tBp-JK-7fU">
<rect key="frame" x="108" y="18" width="56" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Cancel" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="lU5-sf-dGU">
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="T2o-aJ-JmD">
<rect key="frame" x="496" y="18" width="37" height="25"/>
<buttonCell key="cell" type="roundTextured" title="Use" bezelStyle="texturedRounded" alignment="center" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Kqx-qm-nMG">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</subviews>
<point key="canvasLocation" x="313" y="450"/>
<constraints>
<constraint firstItem="IFf-vC-3vk" firstAttribute="leading" secondItem="b4e-k2-WPS" secondAttribute="trailing" constant="9" id="9lR-zK-sJ9"/>
<constraint firstItem="b4e-k2-WPS" firstAttribute="centerY" secondItem="IZP-Gd-jdU" secondAttribute="centerY" id="9px-3a-ML8"/>
<constraint firstItem="T2o-aJ-JmD" firstAttribute="leading" secondItem="IFf-vC-3vk" secondAttribute="trailing" constant="8" id="KB2-TQ-vOj"/>
<constraint firstItem="IFf-vC-3vk" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="167" id="PiJ-8F-1y4"/>
<constraint firstAttribute="bottom" secondItem="IFf-vC-3vk" secondAttribute="bottom" constant="20" symbolic="YES" id="Rga-Nr-tJC"/>
<constraint firstItem="IZP-Gd-jdU" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="20" symbolic="YES" id="YZS-8V-uJC"/>
<constraint firstItem="IFf-vC-3vk" firstAttribute="centerY" secondItem="b4e-k2-WPS" secondAttribute="centerY" id="clf-Jb-991"/>
<constraint firstAttribute="trailing" secondItem="T2o-aJ-JmD" secondAttribute="trailing" constant="20" id="dMd-nR-6ud"/>
<constraint firstItem="IFf-vC-3vk" firstAttribute="centerY" secondItem="T2o-aJ-JmD" secondAttribute="centerY" id="dOS-yX-VrJ"/>
<constraint firstItem="IFf-vC-3vk" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" constant="20" symbolic="YES" id="oz5-jn-4bS"/>
<constraint firstItem="b4e-k2-WPS" firstAttribute="leading" secondItem="IZP-Gd-jdU" secondAttribute="trailing" constant="8" id="qDi-8f-siN"/>
</constraints>
<point key="canvasLocation" x="578.5" y="225"/>
</customView>
</objects>
</document>