Revision: 23988
          http://sourceforge.net/p/bibdesk/svn/23988
Author:   hofman
Date:     2019-07-10 09:47:59 +0000 (Wed, 10 Jul 2019)
Log Message:
-----------
Add field for realm to authorization panel

Modified Paths:
--------------
    trunk/bibdesk/BDSKAuthenticationController.h
    trunk/bibdesk/BDSKAuthenticationController.m
    trunk/bibdesk/English.lproj/AuthenticationPanel.xib
    trunk/bibdesk/English.lproj/Localizable.strings
    trunk/bibdesk/French.lproj/AuthenticationPanel.xib
    trunk/bibdesk/German.lproj/AuthenticationPanel.xib

Modified: trunk/bibdesk/BDSKAuthenticationController.h
===================================================================
--- trunk/bibdesk/BDSKAuthenticationController.h        2019-07-10 09:04:45 UTC 
(rev 23987)
+++ trunk/bibdesk/BDSKAuthenticationController.h        2019-07-10 09:47:59 UTC 
(rev 23988)
@@ -43,6 +43,7 @@
 @interface BDSKAuthenticationController : NSWindowController {
     IBOutlet NSTextField *mainLabelField;
     IBOutlet NSTextField *smallLabelField;
+    IBOutlet NSTextField *separateRealmLabelField;
     IBOutlet NSTextField *passwordField;
     IBOutlet NSTextField *userField;
     IBOutlet NSButton *rememberButton;

Modified: trunk/bibdesk/BDSKAuthenticationController.m
===================================================================
--- trunk/bibdesk/BDSKAuthenticationController.m        2019-07-10 09:04:45 UTC 
(rev 23987)
+++ trunk/bibdesk/BDSKAuthenticationController.m        2019-07-10 09:47:59 UTC 
(rev 23988)
@@ -44,11 +44,24 @@
 
 - (NSString *)windowNibName { return @"AuthenticationPanel"; }
 
+- (void)adjustSizeOfTextField:(NSTextField *)textField {
+    NSRect windowFrame = [[self window] frame];
+    NSRect frame = [textField frame];
+    NSSize bestSize = [textField intrinsicContentSize];
+    float heightDelta = bestSize.height - NSHeight(frame);
+    frame.size.height += heightDelta;
+    frame.origin.y -= heightDelta;
+    [textField setFrame:frame];
+    windowFrame.size.height += heightDelta;
+    [[self window] setFrame:windowFrame display:NO];
+}
+
 - (void)setUpForChallenge:(NSURLAuthenticationChallenge *)challenge {
     NSWindow *window = [self window];
     NSURLProtectionSpace *space = [challenge protectionSpace];
     NSString *host = [space host];
-    NSString *realm = [space realm];
+    NSString *realm = [space realm] ?: @"";
+    BOOL realmNameIsSimple = [realm rangeOfCharacterFromSet:[NSCharacterSet 
whitespaceAndNewlineCharacterSet]].location == NSNotFound;
     NSString *message;
     
     if ([space port] != 0)
@@ -56,28 +69,49 @@
     
     if ([challenge previousFailureCount] == 0) {
         if ([space isProxy])
-            message = [NSString stringWithFormat:NSLocalizedString(@"To view 
this page, you need to log in to the %@ proxy server %@.", @"prompt string in 
authentication panel"), [space proxyType], host];
+            message = [NSString stringWithFormat:NSLocalizedString(@"To view 
this page, you must log in to the %@ proxy server %@.", "prompt string in 
authentication panel"), [space proxyType], host];
+        else if (realmNameIsSimple)
+            message = [NSString stringWithFormat:NSLocalizedString(@"To view 
this page, you must log in to area \"%@\" on %@.", @"prompt string in 
authentication panel"), realm, host];
         else
-            message = [NSString stringWithFormat:NSLocalizedString(@"To view 
this page, you need to log in to area \"%@\" on %@.", @"prompt string in 
authentication panel"), realm, host];
+            message = [NSString stringWithFormat:NSLocalizedString(@"To view 
this page, you must log in to this area on %@:", @"prompt string in 
authentication panel"), host];
     } else {
         if ([space isProxy])
-            message = [NSString stringWithFormat:NSLocalizedString(@"The name 
or password entered for the %@ proxy server %@ was incorrect. Please try 
again.", @"prompt string in authentication panel"), [space proxyType], host];
+            message = [NSString stringWithFormat:NSLocalizedString(@"The user 
name or password you entered for the %@ proxy server %@ was incorrect. Make 
sure you’re entering them correctly, and then try again.", @"prompt string in 
authentication panel"), [space proxyType], host];
+        else if (realmNameIsSimple)
+            message = [NSString stringWithFormat:NSLocalizedString(@"The user 
name or password you entered for area \"%@\" on %@ was incorrect. Make sure 
you’re entering them correctly, and then try again.", @"prompt string in 
authentication panel"), realm, host];
         else
-            message = [NSString stringWithFormat:NSLocalizedString(@"The name 
or password entered for area \"%@\" on %@ was incorrect. Please try again.", 
@"prompt string in authentication panel"), realm, host];
+            message = [NSString stringWithFormat:NSLocalizedString(@"The user 
name or password you entered for this area on %@ was incorrect. Make sure 
you’re entering them correctly, and then try again.", @"prompt string in 
authentication panel"), host];
     }
     
+    if ([space isProxy] == NO && realmNameIsSimple == NO) {
+        [separateRealmLabelField setHidden:NO];
+        [separateRealmLabelField setStringValue:realm];
+        [separateRealmLabelField setAutoresizingMask:NSViewMinYMargin | 
NSViewWidthSizable];
+        [self adjustSizeOfTextField:separateRealmLabelField];
+        [separateRealmLabelField setAutoresizingMask:NSViewMaxYMargin | 
NSViewWidthSizable];
+    } else {
+        // In the proxy or "simple" realm name case, we need to hide the 
'separateRealmLabel'
+        // and move the rest of the contents up appropriately to fill the 
space.
+        NSRect mainLabelFrame = [mainLabelField frame];
+        NSRect realmFrame = [separateRealmLabelField frame];
+        NSRect smallLabelFrame = [smallLabelField frame];
+        
+        // Find the distance between the 'smallLabel' and the label above it, 
initially the 'separateRealmLabel'.
+        // Then, find the current distance between 'smallLabel' and 
'mainLabel'.  The difference between
+        // these two is how much shorter the panel needs to be after hiding 
the 'separateRealmLabel'.
+        CGFloat smallLabelMargin = NSMinY(realmFrame) - 
NSMaxY(smallLabelFrame);
+        CGFloat smallLabelToMainLabel = NSMinY(mainLabelFrame) - 
NSMaxY(smallLabelFrame);
+        CGFloat deltaMargin = smallLabelToMainLabel - smallLabelMargin;
+        
+        [separateRealmLabelField setHidden:YES];
+        NSRect windowFrame = [[self window] frame];
+        windowFrame.size.height -= deltaMargin;
+        [[self window] setFrame:windowFrame display:NO];
+    }
+    
     [mainLabelField setStringValue:message];
+    [self adjustSizeOfTextField:mainLabelField];
     
-    NSRect windowFrame = [window frame];
-    NSRect frame = [mainLabelField frame];
-    NSSize bestSize = [mainLabelField intrinsicContentSize];
-    float heightDelta = bestSize.height - NSHeight(frame);
-    frame.size.height += heightDelta;
-    frame.origin.y -= heightDelta;
-    [mainLabelField setFrame:frame];
-    windowFrame.size.height += heightDelta;
-    [window setFrame:windowFrame display:NO];
-
     if ([space receivesCredentialSecurely])
         [smallLabelField setStringValue:
          NSLocalizedString(@"Your login information will be sent securely.", 
@"message in authentication panel")];

Modified: trunk/bibdesk/English.lproj/AuthenticationPanel.xib
===================================================================
--- trunk/bibdesk/English.lproj/AuthenticationPanel.xib 2019-07-10 09:04:45 UTC 
(rev 23987)
+++ trunk/bibdesk/English.lproj/AuthenticationPanel.xib 2019-07-10 09:47:59 UTC 
(rev 23988)
@@ -9,8 +9,10 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" 
customClass="BDSKAuthenticationController">
             <connections>
+                <outlet property="mainLabelField" destination="Z62-kH-PWf" 
id="W0p-EL-MaS"/>
                 <outlet property="passwordField" destination="Om9-Im-2TW" 
id="pG8-uY-Mx7"/>
                 <outlet property="rememberButton" destination="2eC-R6-U73" 
id="90L-9M-pGg"/>
+                <outlet property="separateRealmLabelField" 
destination="NsU-Hf-I18" id="9ND-SK-CgG"/>
                 <outlet property="smallLabelField" destination="R3d-dh-gcc" 
id="2DR-Xc-Fpg"/>
                 <outlet property="userField" destination="Ioj-IC-CtL" 
id="ImA-cf-RiG"/>
             </connections>
@@ -20,14 +22,14 @@
         <window title="Log In" allowsToolTipsWhenApplicationIsInactive="NO" 
autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" 
frameAutosaveName="" animationBehavior="default" id="34K-tn-3nf" 
customClass="BDSKNonBlockingPanel">
             <windowStyleMask key="styleMask" titled="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" 
rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="93" y="112" width="423" height="231"/>
+            <rect key="contentRect" x="93" y="112" width="423" height="253"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
             <view key="contentView" id="6Qo-QZ-gQo">
-                <rect key="frame" x="0.0" y="0.0" width="423" height="231"/>
+                <rect key="frame" x="0.0" y="0.0" width="423" height="253"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <textField verticalHuggingPriority="750" tag="1" 
id="Z62-kH-PWf">
-                        <rect key="frame" x="102" y="177" width="303" 
height="34"/>
+                        <rect key="frame" x="102" y="199" width="303" 
height="34"/>
                         <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" selectable="YES" 
sendsActionOnEndEditing="YES" alignment="left" tag="1" title="To view this 
page, you need to log in to area &quot;Some Realm&quot; on www.server.com." 
id="0hw-ga-Kc9">
                             <font key="font" metaFont="system"/>
@@ -102,7 +104,7 @@
                         </textFieldCell>
                     </textField>
                     <imageView id="E1I-PS-KYN">
-                        <rect key="frame" x="20" y="147" width="64" 
height="64"/>
+                        <rect key="frame" x="20" y="169" width="64" 
height="64"/>
                         <autoresizingMask key="autoresizingMask" 
flexibleMaxX="YES" flexibleMinY="YES"/>
                         <imageCell key="cell" refusesFirstResponder="YES" 
alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" 
id="7n0-nd-T2u"/>
                     </imageView>
@@ -132,6 +134,15 @@
                             <outlet property="nextKeyView" 
destination="Qvu-ig-u2f" id="QEn-89-K2U"/>
                         </connections>
                     </button>
+                    <textField verticalHuggingPriority="750" tag="3" 
id="NsU-Hf-I18">
+                        <rect key="frame" x="114" y="177" width="291" 
height="14"/>
+                        <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMaxY="YES"/>
+                        <textFieldCell key="cell" 
truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" 
state="on" alignment="left" tag="3" title="&lt;-- do not localize; will contain 
realm name --&gt;" id="VaN-La-rrz">
+                            <font key="font" metaFont="smallSystem"/>
+                            <color key="textColor" name="textColor" 
catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" 
name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
                 </subviews>
             </view>
             <point key="canvasLocation" x="322.5" y="-224.5"/>

Modified: trunk/bibdesk/English.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/bibdesk/French.lproj/AuthenticationPanel.xib
===================================================================
--- trunk/bibdesk/French.lproj/AuthenticationPanel.xib  2019-07-10 09:04:45 UTC 
(rev 23987)
+++ trunk/bibdesk/French.lproj/AuthenticationPanel.xib  2019-07-10 09:47:59 UTC 
(rev 23988)
@@ -9,8 +9,10 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" 
customClass="BDSKAuthenticationController">
             <connections>
+                <outlet property="mainLabelField" destination="Z62-kH-PWf" 
id="W0p-EL-MaS"/>
                 <outlet property="passwordField" destination="Om9-Im-2TW" 
id="pG8-uY-Mx7"/>
                 <outlet property="rememberButton" destination="2eC-R6-U73" 
id="90L-9M-pGg"/>
+                <outlet property="separateRealmLabelField" 
destination="NsU-Hf-I18" id="9ND-SK-CgG"/>
                 <outlet property="smallLabelField" destination="R3d-dh-gcc" 
id="2DR-Xc-Fpg"/>
                 <outlet property="userField" destination="Ioj-IC-CtL" 
id="ImA-cf-RiG"/>
             </connections>
@@ -20,14 +22,14 @@
         <window title="Log In" allowsToolTipsWhenApplicationIsInactive="NO" 
autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" 
frameAutosaveName="" animationBehavior="default" id="34K-tn-3nf" 
customClass="BDSKNonBlockingPanel">
             <windowStyleMask key="styleMask" titled="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" 
rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="93" y="112" width="423" height="231"/>
+            <rect key="contentRect" x="93" y="112" width="423" height="253"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
             <view key="contentView" id="6Qo-QZ-gQo">
-                <rect key="frame" x="0.0" y="0.0" width="423" height="231"/>
+                <rect key="frame" x="0.0" y="0.0" width="423" height="253"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <textField verticalHuggingPriority="750" tag="1" 
id="Z62-kH-PWf">
-                        <rect key="frame" x="102" y="177" width="303" 
height="34"/>
+                        <rect key="frame" x="102" y="199" width="303" 
height="34"/>
                         <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" selectable="YES" 
sendsActionOnEndEditing="YES" alignment="left" tag="1" title="To view this 
page, you need to log in to area &quot;Some Realm&quot; on www.server.com." 
id="0hw-ga-Kc9">
                             <font key="font" metaFont="system"/>
@@ -102,7 +104,7 @@
                         </textFieldCell>
                     </textField>
                     <imageView id="E1I-PS-KYN">
-                        <rect key="frame" x="20" y="147" width="64" 
height="64"/>
+                        <rect key="frame" x="20" y="169" width="64" 
height="64"/>
                         <autoresizingMask key="autoresizingMask" 
flexibleMaxX="YES" flexibleMinY="YES"/>
                         <imageCell key="cell" refusesFirstResponder="YES" 
alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" 
id="7n0-nd-T2u"/>
                     </imageView>
@@ -132,6 +134,15 @@
                             <outlet property="nextKeyView" 
destination="Qvu-ig-u2f" id="QEn-89-K2U"/>
                         </connections>
                     </button>
+                    <textField verticalHuggingPriority="750" tag="3" 
id="NsU-Hf-I18">
+                        <rect key="frame" x="114" y="177" width="291" 
height="14"/>
+                        <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMaxY="YES"/>
+                        <textFieldCell key="cell" 
truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" 
state="on" alignment="left" tag="3" title="&lt;-- do not localize; will contain 
realm name --&gt;" id="VaN-La-rrz">
+                            <font key="font" metaFont="smallSystem"/>
+                            <color key="textColor" name="textColor" 
catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" 
name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
                 </subviews>
             </view>
             <point key="canvasLocation" x="322.5" y="-224.5"/>

Modified: trunk/bibdesk/German.lproj/AuthenticationPanel.xib
===================================================================
--- trunk/bibdesk/German.lproj/AuthenticationPanel.xib  2019-07-10 09:04:45 UTC 
(rev 23987)
+++ trunk/bibdesk/German.lproj/AuthenticationPanel.xib  2019-07-10 09:47:59 UTC 
(rev 23988)
@@ -9,8 +9,10 @@
     <objects>
         <customObject id="-2" userLabel="File's Owner" 
customClass="BDSKAuthenticationController">
             <connections>
+                <outlet property="mainLabelField" destination="Z62-kH-PWf" 
id="W0p-EL-MaS"/>
                 <outlet property="passwordField" destination="Om9-Im-2TW" 
id="pG8-uY-Mx7"/>
                 <outlet property="rememberButton" destination="2eC-R6-U73" 
id="90L-9M-pGg"/>
+                <outlet property="separateRealmLabelField" 
destination="NsU-Hf-I18" id="9ND-SK-CgG"/>
                 <outlet property="smallLabelField" destination="R3d-dh-gcc" 
id="2DR-Xc-Fpg"/>
                 <outlet property="userField" destination="Ioj-IC-CtL" 
id="ImA-cf-RiG"/>
             </connections>
@@ -20,14 +22,14 @@
         <window title="Log In" allowsToolTipsWhenApplicationIsInactive="NO" 
autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" 
frameAutosaveName="" animationBehavior="default" id="34K-tn-3nf" 
customClass="BDSKNonBlockingPanel">
             <windowStyleMask key="styleMask" titled="YES"/>
             <windowPositionMask key="initialPositionMask" leftStrut="YES" 
rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="93" y="112" width="423" height="231"/>
+            <rect key="contentRect" x="93" y="112" width="423" height="253"/>
             <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
             <view key="contentView" id="6Qo-QZ-gQo">
-                <rect key="frame" x="0.0" y="0.0" width="423" height="231"/>
+                <rect key="frame" x="0.0" y="0.0" width="423" height="253"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <textField verticalHuggingPriority="750" tag="1" 
id="Z62-kH-PWf">
-                        <rect key="frame" x="102" y="177" width="303" 
height="34"/>
+                        <rect key="frame" x="102" y="199" width="303" 
height="34"/>
                         <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMinY="YES"/>
                         <textFieldCell key="cell" selectable="YES" 
sendsActionOnEndEditing="YES" alignment="left" tag="1" title="To view this 
page, you need to log in to area &quot;Some Realm&quot; on www.server.com." 
id="0hw-ga-Kc9">
                             <font key="font" metaFont="system"/>
@@ -102,7 +104,7 @@
                         </textFieldCell>
                     </textField>
                     <imageView id="E1I-PS-KYN">
-                        <rect key="frame" x="20" y="147" width="64" 
height="64"/>
+                        <rect key="frame" x="20" y="169" width="64" 
height="64"/>
                         <autoresizingMask key="autoresizingMask" 
flexibleMaxX="YES" flexibleMinY="YES"/>
                         <imageCell key="cell" refusesFirstResponder="YES" 
alignment="left" imageScaling="proportionallyDown" image="NSApplicationIcon" 
id="7n0-nd-T2u"/>
                     </imageView>
@@ -132,6 +134,15 @@
                             <outlet property="nextKeyView" 
destination="Qvu-ig-u2f" id="QEn-89-K2U"/>
                         </connections>
                     </button>
+                    <textField verticalHuggingPriority="750" tag="3" 
id="NsU-Hf-I18">
+                        <rect key="frame" x="114" y="177" width="291" 
height="14"/>
+                        <autoresizingMask key="autoresizingMask" 
widthSizable="YES" flexibleMaxY="YES"/>
+                        <textFieldCell key="cell" 
truncatesLastVisibleLine="YES" selectable="YES" sendsActionOnEndEditing="YES" 
state="on" alignment="left" tag="3" title="&lt;-- do not localize; will contain 
realm name --&gt;" id="VaN-La-rrz">
+                            <font key="font" metaFont="smallSystem"/>
+                            <color key="textColor" name="textColor" 
catalog="System" colorSpace="catalog"/>
+                            <color key="backgroundColor" 
name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                        </textFieldCell>
+                    </textField>
                 </subviews>
             </view>
             <point key="canvasLocation" x="322.5" y="-224.5"/>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to