Revision: 26224 http://sourceforge.net/p/bibdesk/svn/26224 Author: hofman Date: 2021-06-14 19:27:32 +0000 (Mon, 14 Jun 2021) Log Message: ----------- View based table views for default preferences
Modified Paths: -------------- trunk/bibdesk/Base.lproj/BibPref_Defaults.xib trunk/bibdesk/BibPref_Defaults.h trunk/bibdesk/BibPref_Defaults.m Modified: trunk/bibdesk/Base.lproj/BibPref_Defaults.xib =================================================================== --- trunk/bibdesk/Base.lproj/BibPref_Defaults.xib 2021-06-14 18:03:34 UTC (rev 26223) +++ trunk/bibdesk/Base.lproj/BibPref_Defaults.xib 2021-06-14 19:27:32 UTC (rev 26224) @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> <deployment identifier="macosx"/> <development version="8000" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> @@ -13,7 +13,6 @@ <outlet property="convertURLFieldsButton" destination="267" id="270"/> <outlet property="defaultFieldsTableView" destination="25" id="39"/> <outlet property="editGlobalMacroDefsButton" destination="181" id="184"/> - <outlet property="fieldTypeMenu" destination="172" id="202"/> <outlet property="globalMacroFileSheet" destination="215" id="226"/> <outlet property="globalMacroFilesTableView" destination="220" id="227"/> <outlet property="localFileOptionPopup" destination="354" id="364"/> @@ -251,9 +250,8 @@ <rect key="frame" x="1" y="1" width="392" height="98"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <tableView toolTip="These are custom BibTeX fields that are handled specially. Checking Default will add them to all entries when they are created." verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" headerView="336" id="25"> - <rect key="frame" x="0.0" y="0.0" width="402" height="73"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <tableView toolTip="These are custom BibTeX fields that are handled specially. Checking Default will add them to all entries when they are created." verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="sequential" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" headerView="336" viewBased="YES" translatesAutoresizingMaskIntoConstraints="NO" id="25"> + <rect key="frame" x="0.0" y="25" width="402" height="73"/> <size key="intercellSpacing" width="3" height="2"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> @@ -263,12 +261,41 @@ <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/> </tableHeaderCell> - <textFieldCell key="dataCell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="left" id="332"> + <textFieldCell key="dataCell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" alignment="left" id="332"> <font key="font" metaFont="message" size="11"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <prototypeCellViews> + <tableCellView id="Bu9-NQ-sdx"> + <rect key="frame" x="11" y="1" width="205" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <textField horizontalHuggingPriority="251" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="ksE-K5-UwC"> + <rect key="frame" x="-2" y="0.0" width="209" height="14"/> + <textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" id="eg9-ky-gk9"> + <customFormatter key="formatter" id="bAN-oc-udb" customClass="BDSKFieldNameFormatter"/> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <action selector="changeFieldName:" target="-2" id="6TC-GQ-czm"/> + </connections> + </textField> + </subviews> + <constraints> + <constraint firstItem="ksE-K5-UwC" firstAttribute="top" secondItem="Bu9-NQ-sdx" secondAttribute="top" id="8b6-2W-OLe"/> + <constraint firstAttribute="trailing" secondItem="ksE-K5-UwC" secondAttribute="trailing" id="aaQ-Bw-Vwp"/> + <constraint firstAttribute="bottom" secondItem="ksE-K5-UwC" secondAttribute="bottom" id="mih-zr-QwL"/> + <constraint firstItem="ksE-K5-UwC" firstAttribute="leading" secondItem="Bu9-NQ-sdx" secondAttribute="leading" id="qKr-CP-HNT"/> + </constraints> + <connections> + <outlet property="textField" destination="ksE-K5-UwC" id="La7-fD-X7k"/> + </connections> + </tableCellView> + </prototypeCellViews> </tableColumn> <tableColumn identifier="type" width="115" minWidth="27.41309" maxWidth="1000" id="170"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Type"> @@ -275,15 +302,51 @@ <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> </tableHeaderCell> - <popUpButtonCell key="dataCell" type="bevel" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="bezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="177"> + <popUpButtonCell key="dataCell" type="bevel" bezelStyle="rounded" alignment="left" controlSize="small" scrollable="YES" lineBreakMode="clipping" borderStyle="bezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="177"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="message" size="11"/> <menu key="menu" id="333"/> - <connections> - <outlet property="menu" destination="172" id="178"/> - </connections> </popUpButtonCell> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <prototypeCellViews> + <tableCellView id="Mr2-IN-bqY" customClass="BDSKControlTableCellView"> + <rect key="frame" x="218" y="1" width="116" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <popUpButton horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="ObZ-Wb-EZu"> + <rect key="frame" x="-5" y="0.0" width="121" height="14"/> + <popUpButtonCell key="cell" type="bevel" title="Textual" bezelStyle="rounded" controlSize="small" lineBreakMode="truncatingTail" imageScaling="proportionallyDown" inset="2" selectedItem="174" id="gIj-FD-Amk"> + <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> + <font key="font" metaFont="smallSystem"/> + <menu key="menu" id="4jH-jh-yx9"> + <items> + <menuItem title="Textual" id="174"/> + <menuItem title="Local File" id="175"/> + <menuItem title="Remote URL" id="173"/> + <menuItem title="Boolean" id="191"/> + <menuItem title="Three-value" id="201"/> + <menuItem title="Rating" id="192"/> + <menuItem title="Citation" id="249"/> + <menuItem title="Person" id="250"/> + </items> + </menu> + </popUpButtonCell> + <connections> + <action selector="changeFieldType:" target="-2" id="D0a-9P-lJ3"/> + </connections> + </popUpButton> + </subviews> + <constraints> + <constraint firstAttribute="bottom" secondItem="ObZ-Wb-EZu" secondAttribute="bottom" id="8Xy-be-L3h"/> + <constraint firstAttribute="trailing" secondItem="ObZ-Wb-EZu" secondAttribute="trailing" id="RK3-8h-pN3"/> + <constraint firstItem="ObZ-Wb-EZu" firstAttribute="leading" secondItem="Mr2-IN-bqY" secondAttribute="leading" id="fGb-r4-rDT"/> + <constraint firstItem="ObZ-Wb-EZu" firstAttribute="top" secondItem="Mr2-IN-bqY" secondAttribute="top" id="wro-53-uDt"/> + </constraints> + <connections> + <outlet property="control" destination="ObZ-Wb-EZu" id="53W-ca-3bS"/> + </connections> + </tableCellView> + </prototypeCellViews> </tableColumn> <tableColumn identifier="default" width="69.364260000000002" minWidth="10" maxWidth="1000" id="193"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Is Default"> @@ -290,11 +353,38 @@ <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/> </tableHeaderCell> - <buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="only" alignment="left" controlSize="small" inset="2" id="194"> + <buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="only" alignment="left" controlSize="small" scrollable="YES" lineBreakMode="clipping" inset="2" id="194"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> - <font key="font" metaFont="cellTitle"/> + <font key="font" metaFont="smallSystem"/> </buttonCell> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <prototypeCellViews> + <tableCellView id="VFR-1v-zAf" customClass="BDSKControlTableCellView"> + <rect key="frame" x="336" y="1" width="74" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <button horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="ZUV-ng-GFc"> + <rect key="frame" x="-1" y="-2" width="76" height="18"/> + <buttonCell key="cell" type="check" bezelStyle="regularSquare" imagePosition="only" controlSize="small" state="on" inset="2" id="9Xn-VK-l59"> + <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> + <font key="font" metaFont="smallSystem"/> + </buttonCell> + <connections> + <action selector="changeFieldIsDefault:" target="-2" id="vu3-7I-7oU"/> + </connections> + </button> + </subviews> + <constraints> + <constraint firstAttribute="trailing" secondItem="ZUV-ng-GFc" secondAttribute="trailing" id="0vx-76-tp6"/> + <constraint firstAttribute="bottom" secondItem="ZUV-ng-GFc" secondAttribute="bottom" id="IIG-4Q-vMX"/> + <constraint firstItem="ZUV-ng-GFc" firstAttribute="top" secondItem="VFR-1v-zAf" secondAttribute="top" id="TZL-7x-lwh"/> + <constraint firstItem="ZUV-ng-GFc" firstAttribute="leading" secondItem="VFR-1v-zAf" secondAttribute="leading" id="guX-jw-TlB"/> + </constraints> + <connections> + <outlet property="control" destination="ZUV-ng-GFc" id="YHN-es-NS4"/> + </connections> + </tableCellView> + </prototypeCellViews> </tableColumn> </tableColumns> <connections> @@ -303,6 +393,10 @@ </connections> </tableView> </subviews> + <constraints> + <constraint firstItem="25" firstAttribute="leading" secondItem="TXc-oJ-2Z3" secondAttribute="leading" id="CJu-yS-gUv"/> + <constraint firstItem="25" firstAttribute="top" secondItem="TXc-oJ-2Z3" secondAttribute="top" constant="25" id="ijw-jl-myl"/> + </constraints> </clipView> <constraints> <constraint firstAttribute="height" constant="100" id="P8n-CW-ShL"/> @@ -400,18 +494,6 @@ </constraints> <point key="canvasLocation" x="139" y="154"/> </customView> - <menu id="172" userLabel="TypeMenu"> - <items> - <menuItem title="Textual" id="174"/> - <menuItem title="Local File" id="175"/> - <menuItem title="Remote URL" id="173"/> - <menuItem title="Boolean" id="191"/> - <menuItem title="Three-value" id="201"/> - <menuItem title="Rating" id="192"/> - <menuItem title="Citation" id="249"/> - <menuItem title="Person" id="250"/> - </items> - </menu> <window title="Macro Files" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="Macro Files Window" animationBehavior="default" id="215" userLabel="Macro Files"> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> @@ -428,9 +510,8 @@ <rect key="frame" x="1" y="1" width="374" height="175"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" typeSelect="NO" headerView="339" id="220" customClass="BDSKTableView"> - <rect key="frame" x="0.0" y="0.0" width="374" height="150"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" typeSelect="NO" headerView="339" viewBased="YES" translatesAutoresizingMaskIntoConstraints="NO" id="220" customClass="BDSKTableView"> + <rect key="frame" x="0.0" y="25" width="374" height="150"/> <size key="intercellSpacing" width="3" height="2"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> @@ -446,6 +527,35 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> + <prototypeCellViews> + <tableCellView id="gr2-gu-WjU"> + <rect key="frame" x="11" y="1" width="342" height="17"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <textField horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="b7u-bT-lFM"> + <rect key="frame" x="-2" y="0.0" width="346" height="17"/> + <textFieldCell key="cell" lineBreakMode="truncatingMiddle" sendsActionOnEndEditing="YES" id="8fG-jp-L1K" customClass="BDSKFilePathCell"> + <font key="font" metaFont="system" size="12"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <action selector="changeGlobalMacroFile:" target="-2" id="Ikz-9t-99C"/> + <outlet property="delegate" destination="-2" id="hjW-YI-DEg"/> + </connections> + </textField> + </subviews> + <constraints> + <constraint firstAttribute="trailing" secondItem="b7u-bT-lFM" secondAttribute="trailing" id="qXW-bc-Gzi"/> + <constraint firstItem="b7u-bT-lFM" firstAttribute="leading" secondItem="gr2-gu-WjU" secondAttribute="leading" id="thR-nU-M9S"/> + <constraint firstItem="b7u-bT-lFM" firstAttribute="top" secondItem="gr2-gu-WjU" secondAttribute="top" id="wE2-jh-AP8"/> + <constraint firstAttribute="bottom" secondItem="b7u-bT-lFM" secondAttribute="bottom" id="znA-8b-uwr"/> + </constraints> + <connections> + <outlet property="textField" destination="b7u-bT-lFM" id="lBW-7t-kEV"/> + </connections> + </tableCellView> + </prototypeCellViews> </tableColumn> </tableColumns> <connections> @@ -454,6 +564,10 @@ </connections> </tableView> </subviews> + <constraints> + <constraint firstItem="220" firstAttribute="leading" secondItem="pg9-6x-bI4" secondAttribute="leading" id="72L-dN-sxR"/> + <constraint firstItem="220" firstAttribute="top" secondItem="pg9-6x-bI4" secondAttribute="top" constant="25" id="cyt-sd-t0I"/> + </constraints> </clipView> <scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="338"> <rect key="frame" x="1" y="161" width="359" height="15"/> Modified: trunk/bibdesk/BibPref_Defaults.h =================================================================== --- trunk/bibdesk/BibPref_Defaults.h 2021-06-14 18:03:34 UTC (rev 26223) +++ trunk/bibdesk/BibPref_Defaults.h 2021-06-14 19:27:32 UTC (rev 26224) @@ -73,6 +73,11 @@ @property (nonatomic) BOOL convertURLFields; +- (IBAction)changeFieldName:(id)sender; +- (IBAction)changeFieldType:(id)sender; +- (IBAction)changeFieldIsDefault:(id)sender; +- (IBAction)changeGlobalMacroFile:(id)sender; + - (IBAction)addRemoveDefaultField:(id)sender; - (IBAction)showTypeInfoEditor:(id)sender; Modified: trunk/bibdesk/BibPref_Defaults.m =================================================================== --- trunk/bibdesk/BibPref_Defaults.m 2021-06-14 18:03:34 UTC (rev 26223) +++ trunk/bibdesk/BibPref_Defaults.m 2021-06-14 19:27:32 UTC (rev 26224) @@ -46,6 +46,7 @@ #import "BDSKMacroWindowController.h" #import "BDSKPreferenceRecord.h" #import "BDSKTableView.h" +#import "BDSKControlTableCellView.h" #import "NSWindowController_BDSKExtensions.h" #import "NSString_BDSKExtensions.h" #import "NSPasteboard_BDSKExtensions.h" @@ -189,9 +190,10 @@ - (void)loadView { [super loadView]; - BDSKFieldNameFormatter *fieldNameFormatter = [[BDSKFieldNameFormatter alloc] init]; - [[[[defaultFieldsTableView tableColumns] objectAtIndex:0] dataCell] setFormatter:fieldNameFormatter]; - [fieldNameFormatter release]; + [defaultFieldsTableView sizeToFit]; + + [globalMacroFilesTableView sizeToFit]; + [globalMacroFilesTableView registerForDraggedTypes:[NSArray arrayWithObjects:(NSString *)kUTTypeFileURL, NSFilenamesPboardType, nil]]; NSWorkspace *sws = [NSWorkspace sharedWorkspace]; @@ -344,41 +346,6 @@ return 0; } -- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ - if (tableView == defaultFieldsTableView) { - return [[customFieldsArray objectAtIndex:row] objectForKey:[tableColumn identifier]]; - } else if (tableView == globalMacroFilesTableView) { - return [globalMacroFiles objectAtIndex:row]; - } - return nil; -} - -- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ - if (tableView == defaultFieldsTableView) { - NSString *colID = [tableColumn identifier]; - NSString *field = [[customFieldsArray objectAtIndex:row] objectForKey:FIELD_KEY]; - - if([colID isEqualToString:FIELD_KEY]){ - if([customFieldsSet containsObject:object]) - return; // don't add duplicate fields - [customFieldsSet removeObject:field]; - if([object isEqualToString:@""]){ - [customFieldsArray removeObjectAtIndex:row]; - }else{ - [[customFieldsArray objectAtIndex:row] setObject:object forKey:colID]; - [customFieldsSet addObject:object]; - } - }else{ - [[customFieldsArray objectAtIndex:row] setObject:object forKey:colID]; - } - [self updatePrefs]; - } else if (tableView == globalMacroFilesTableView) { - [globalMacroFiles replaceObjectAtIndex:row withObject:object]; - [sud setObject:globalMacroFiles forKey:BDSKGlobalMacroFilesKey]; - [globalMacroFilesTableView reloadData]; - } -} - #pragma mark | TableView Dragging - (NSDragOperation)tableView:(NSTableView*)tableView validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op{ @@ -417,27 +384,29 @@ #pragma mark TableView Delegate methods -- (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ +- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row { + NSTableCellView *view = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:self]; if (tableView == defaultFieldsTableView) { - - return YES; + NSString *identifier = [tableColumn identifier]; + NSDictionary *dict = [customFieldsArray objectAtIndex:row]; + id value = [dict objectForKey:identifier]; + NSString *field = nil; + NSControl *control = nil; + if ([identifier isEqualToString:FIELD_KEY]) { + control = [view textField]; + field = value; + } else { + control = [(BDSKControlTableCellView *)view control]; + field = [dict objectForKey:FIELD_KEY]; + } + [control setObjectValue:value]; + [control setEnabled:NO == [alwaysDisabledFields containsObject:field]]; } else if (tableView == globalMacroFilesTableView) { - return YES; + [[view textField] setObjectValue:[globalMacroFiles objectAtIndex:row]]; } - return NO; + return view; } -- (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{ - if (tableView == defaultFieldsTableView) { - NSString *field = [[customFieldsArray objectAtIndex:row] objectForKey:FIELD_KEY]; - - if([alwaysDisabledFields containsObject:field]) - [cell setEnabled:NO]; - else - [cell setEnabled:YES]; - } -} - - (void)tableViewSelectionDidChange:(NSNotification *)aNotification{ if ([[aNotification object] isEqual:defaultFieldsTableView]) { NSInteger row = [defaultFieldsTableView selectedRow]; @@ -460,7 +429,7 @@ NSBeep(); } -#pragma mark TableView Extended DataaSource +#pragma mark TableView Extended DataSource - (void)tableView:(NSTableView *)tv deleteRowsWithIndexes:(NSIndexSet *)rowIndexes { if (tv == globalMacroFilesTableView) { @@ -475,10 +444,10 @@ return tv == globalMacroFilesTableView; } -#pragma mark TableView Control Delegate +#pragma mark Control Text Editing Delegate - (BOOL)control:(NSControl *)control isValidObject:(id)object { - if (control == globalMacroFilesTableView) { + if ([globalMacroFilesTableView rowForView:control] != -1) { NSString *pathString = [object stringByStandardizingPath]; NSString *extension = [object pathExtension]; BOOL isDir = NO; @@ -502,6 +471,50 @@ return YES; } +#pragma mark TableView Cell Editing + +- (IBAction)changeFieldName:(id)sender { + NSInteger row = [defaultFieldsTableView rowForView:sender]; + NSString *field = [sender stringValue]; + + if ([customFieldsSet containsObject:field]) + return; // don't add duplicate fields + [customFieldsSet removeObject:[customFieldsArray objectAtIndex:row]]; + if ([field isEqualToString:@""]) { + [customFieldsArray removeObjectAtIndex:row]; + } else { + [[customFieldsArray objectAtIndex:row] setObject:field forKey:FIELD_KEY]; + [customFieldsSet addObject:field]; + } + [self updatePrefs]; +} + +- (IBAction)changeFieldType:(id)sender { + NSInteger row = [defaultFieldsTableView rowForView:sender]; + NSInteger fieldType = [sender integerValue]; + NSString *field = [[customFieldsArray objectAtIndex:row] objectForKey:FIELD_KEY]; + + [self updatePrefs]; +} + +- (IBAction)changeFieldIsDefault:(id)sender { + NSInteger row = [defaultFieldsTableView rowForView:sender]; + BOOL isDefault = ([sender state] == NSOnState); + NSString *field = [[customFieldsArray objectAtIndex:row] objectForKey:FIELD_KEY]; + + [self updatePrefs]; +} + +- (IBAction)changeGlobalMacroFile:(id)sender { + NSInteger row = [globalMacroFilesTableView rowForView:sender]; + NSString *path = [sender stringValue]; + if (row != -1 && [NSString isEmptyString:path] == NO) { + [globalMacroFiles replaceObjectAtIndex:row withObject:path]; + [sud setObject:globalMacroFiles forKey:BDSKGlobalMacroFilesKey]; + } + [globalMacroFilesTableView reloadData]; +} + #pragma mark Add and Del fields buttons - (IBAction)addRemoveDefaultField:(id)sender { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit