Skip to content

Commit 7afe676

Browse files
Ensure required name fields cannot be set to an empty value
- In Preferences storyboar file - Set view controller as delegate of name fields - Assign each text field in file layout prefs panel a tag - Update combo box text field to continously update - Assign placeholder text of 'None' to separator string field - Accept automatic Xcode file changes - Add enum to give each tag a name - Make FileLayoutPreferencesViewController an NSTextFieldDelegate - Replace empty string input with appropriate default value - Resolves #64
1 parent 19d9230 commit 7afe676

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

BuildSettingExtractor/Preferences/Base.lproj/Preferences.storyboard

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="nfV-zh-Irh">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="nfV-zh-Irh">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16096"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="16097.2"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<scenes>
@@ -13,7 +13,7 @@
1313
<window key="window" title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" tabbingMode="disallowed" id="18y-cr-3oE">
1414
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
1515
<rect key="contentRect" x="268" y="0.0" width="480" height="270"/>
16-
<rect key="screenRect" x="0.0" y="0.0" width="1792" height="1097"/>
16+
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
1717
<connections>
1818
<outlet property="delegate" destination="nfV-zh-Irh" id="y0e-2f-rSH"/>
1919
</connections>
@@ -86,7 +86,7 @@
8686
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
8787
</tableHeaderCell>
8888
<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="izn-pK-Cyy">
89-
<font key="font" metaFont="menu" size="11"/>
89+
<font key="font" metaFont="controlContent" size="11"/>
9090
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
9191
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
9292
</textFieldCell>
@@ -103,7 +103,7 @@
103103
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="gz0-HR-Vz6">
104104
<rect key="frame" x="22" y="3" width="241" height="14"/>
105105
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="V1I-73-dY2">
106-
<font key="font" metaFont="menu" size="11"/>
106+
<font key="font" metaFont="controlContent" size="11"/>
107107
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
108108
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
109109
</textFieldCell>
@@ -190,7 +190,7 @@
190190
</textField>
191191
</gridCell>
192192
<gridCell row="yID-zz-wjv" column="HMW-Bu-KYY" headOfMergedCell="cus-Fs-WQD" id="cus-Fs-WQD">
193-
<textField key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Du2-6u-sqX">
193+
<textField key="contentView" verticalHuggingPriority="750" tag="101" translatesAutoresizingMaskIntoConstraints="NO" id="Du2-6u-sqX">
194194
<rect key="frame" x="135" y="243" width="100" height="21"/>
195195
<constraints>
196196
<constraint firstAttribute="width" constant="100" id="P2o-hZ-KaX"/>
@@ -205,11 +205,12 @@
205205
</textFieldCell>
206206
<connections>
207207
<accessibilityConnection property="title" destination="coG-6B-ZVS" id="H6t-xY-4qT"/>
208-
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameProject" id="cDw-RG-uUD">
208+
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameProject" id="Zin-Fd-Lzb">
209209
<dictionary key="options">
210210
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
211211
</dictionary>
212212
</binding>
213+
<outlet property="delegate" destination="mVV-zB-t1f" id="MiB-Pb-aVh"/>
213214
</connections>
214215
</textField>
215216
</gridCell>
@@ -226,7 +227,7 @@
226227
</textField>
227228
</gridCell>
228229
<gridCell row="fdy-IR-IrN" column="HMW-Bu-KYY" headOfMergedCell="ocC-fA-43R" id="ocC-fA-43R">
229-
<textField key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="W86-pJ-96U">
230+
<textField key="contentView" verticalHuggingPriority="750" tag="102" translatesAutoresizingMaskIntoConstraints="NO" id="W86-pJ-96U">
230231
<rect key="frame" x="135" y="216" width="100" height="21"/>
231232
<constraints>
232233
<constraint firstAttribute="width" constant="100" id="EzD-0q-Q0j"/>
@@ -243,6 +244,7 @@
243244
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
244245
</dictionary>
245246
</binding>
247+
<outlet property="delegate" destination="mVV-zB-t1f" id="FAV-TB-gzA"/>
246248
</connections>
247249
</textField>
248250
</gridCell>
@@ -259,7 +261,7 @@
259261
</textField>
260262
</gridCell>
261263
<gridCell row="KAl-yU-oLr" column="HMW-Bu-KYY" headOfMergedCell="f0V-v5-SRH" id="f0V-v5-SRH">
262-
<textField key="contentView" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZcT-Qp-Ibl">
264+
<textField key="contentView" verticalHuggingPriority="750" tag="103" translatesAutoresizingMaskIntoConstraints="NO" id="ZcT-Qp-Ibl">
263265
<rect key="frame" x="135" y="189" width="100" height="21"/>
264266
<constraints>
265267
<constraint firstAttribute="width" constant="100" id="o4d-Cc-Pp4"/>
@@ -271,9 +273,10 @@
271273
</textFieldCell>
272274
<connections>
273275
<accessibilityConnection property="title" destination="ApD-gw-uD5" id="YUV-Fq-B5t"/>
274-
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameSeparator" id="aYr-Nd-jpu">
276+
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSOutputFileNameSeparator" id="fuY-Ge-NPr">
275277
<dictionary key="options">
276278
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
279+
<string key="NSNullPlaceholder">None</string>
277280
</dictionary>
278281
</binding>
279282
</connections>
@@ -351,7 +354,7 @@
351354
</textField>
352355
</gridCell>
353356
<gridCell row="z8r-Rg-63W" column="HMW-Bu-KYY" headOfMergedCell="kGz-5d-tm4" id="kGz-5d-tm4">
354-
<comboBox key="contentView" horizontalHuggingPriority="249" verticalHuggingPriority="750" preferredMaxLayoutWidth="120" translatesAutoresizingMaskIntoConstraints="NO" id="OzR-eI-M7g">
357+
<comboBox key="contentView" horizontalHuggingPriority="249" verticalHuggingPriority="750" tag="104" preferredMaxLayoutWidth="120" translatesAutoresizingMaskIntoConstraints="NO" id="OzR-eI-M7g">
355358
<rect key="frame" x="135" y="48" width="123" height="25"/>
356359
<constraints>
357360
<constraint firstAttribute="width" priority="250" constant="120" id="3xZ-YE-mVX"/>
@@ -369,7 +372,12 @@
369372
</comboBoxCell>
370373
<connections>
371374
<accessibilityConnection property="title" destination="r8S-QW-u7V" id="XcD-Ue-oPz"/>
372-
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSDestinationFolderName" id="AsD-kr-Xii"/>
375+
<binding destination="FdP-VK-zkk" name="value" keyPath="values.TPSDestinationFolderName" id="oIj-8g-dRI">
376+
<dictionary key="options">
377+
<bool key="NSContinuouslyUpdatesValue" value="YES"/>
378+
</dictionary>
379+
</binding>
380+
<outlet property="delegate" destination="mVV-zB-t1f" id="ub4-2r-dJY"/>
373381
</connections>
374382
</comboBox>
375383
</gridCell>

BuildSettingExtractor/Preferences/FileLayoutPreferencesViewController.m

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
#import "FileLayoutPreferencesViewController.h"
1010
#import "AppConstants+Categories.h"
1111
#import "SampleFileStructureGenerator.h"
12+
#import "BuildSettingExtractor.h"
1213

14+
typedef NS_ENUM(NSUInteger, PreferencesInterfaceElementTags) {
15+
ProjectNameTextField = 101,
16+
SharedNameTextField = 102,
17+
SeparatorTextField = 103,
18+
DestinationFolderNameTextField = 104
19+
};
1320

14-
@interface FileLayoutPreferencesViewController () <NSOutlineViewDataSource, NSOutlineViewDelegate>
21+
#pragma mark -
22+
23+
@interface FileLayoutPreferencesViewController () <NSOutlineViewDataSource, NSOutlineViewDelegate, NSTextFieldDelegate>
1524
@property (weak) IBOutlet NSOutlineView *outlineView;
1625
@property Item *rootItem;
1726
@end
@@ -35,6 +44,21 @@ - (void)viewWillAppear {
3544
[self updateOutlineView];
3645
}
3746

47+
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor {
48+
if ([fieldEditor.string isEqualToString:@""]) {
49+
if (control.tag == ProjectNameTextField) {
50+
fieldEditor.string = BuildSettingExtractor.defaultProjectConfigName;
51+
}
52+
else if (control.tag == SharedNameTextField) {
53+
fieldEditor.string = BuildSettingExtractor.defaultSharedConfigName;
54+
}
55+
else if (control.tag == DestinationFolderNameTextField) {
56+
fieldEditor.string = BuildSettingExtractor.defaultDestinationFolderName;
57+
}
58+
}
59+
return YES;
60+
}
61+
3862
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
3963
[self updateOutlineView];
4064
}

0 commit comments

Comments
 (0)