Skip to content

Commit

Permalink
Fix #4138.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jan 24, 2010
1 parent 093b753 commit 5aba7ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
35 changes: 24 additions & 11 deletions source/ch/cyberduck/ui/cocoa/ConnectionController.java
Expand Up @@ -367,7 +367,15 @@ public void setPkLabel(NSTextField pkLabel) {

public void setKeychainCheckbox(NSButton keychainCheckbox) {
this.keychainCheckbox = keychainCheckbox;
this.keychainCheckbox.setState(NSCell.NSOffState);
this.keychainCheckbox.setState(Preferences.instance().getBoolean("connection.login.useKeychain")
&& Preferences.instance().getBoolean("connection.login.addKeychain") ? NSCell.NSOnState : NSCell.NSOffState);
this.keychainCheckbox.setTarget(this.id());
this.keychainCheckbox.setAction(Foundation.selector("keychainCheckboxClicked:"));
}

public void keychainCheckboxClicked(final NSButton sender) {
final boolean enabled = sender.state() == NSCell.NSOnState;
Preferences.instance().setProperty("connection.login.addKeychain", enabled);
}

@Outlet
Expand Down Expand Up @@ -404,8 +412,6 @@ public void setPkCheckbox(NSButton pkCheckbox) {
this.pkCheckbox.setTarget(this.id());
this.pkCheckbox.setAction(Foundation.selector("pkCheckboxSelectionDidChange:"));
this.pkCheckbox.setState(NSCell.NSOffState);
this.pkCheckbox.setEnabled(
Preferences.instance().getProperty("connection.protocol.default").equals(Protocol.SFTP.getIdentifier()));
}

private NSOpenPanel publicKeyPanel;
Expand Down Expand Up @@ -503,16 +509,28 @@ public void setToggleOptionsButton(NSButton b) {

public static ConnectionController instance(final WindowController parent) {
if(!controllers.containsKey(parent)) {
final ConnectionController controller = new ConnectionController(parent) {
final ConnectionController c = new ConnectionController(parent) {
@Override
protected void invalidate() {
controllers.remove(parent);
super.invalidate();
}
};
controllers.put(parent, controller);
c.loadBundle();
controllers.put(parent, c);
}
final ConnectionController c = controllers.get(parent);
c.init();
return c;
}

protected void init() {
passField.setStringValue("");
final boolean enabled = Preferences.instance().getBoolean("connection.login.useKeychain");
keychainCheckbox.setEnabled(enabled);
if(!enabled) {
keychainCheckbox.setState(NSCell.NSOffState);
}
return controllers.get(parent);
}

@Override
Expand Down Expand Up @@ -629,11 +647,6 @@ else if(connectmodePopup.titleOfSelectedItem().equals(CONNECTMODE_PASSIVE)) {
}
((BrowserController) parent).mount(host);
}
this.reset();
}

private void reset() {
passField.setStringValue("");
Preferences.instance().setProperty("connection.toggle.options", this.toggleOptionsButton.state());
}
}
5 changes: 4 additions & 1 deletion source/ch/cyberduck/ui/cocoa/LoginController.java
Expand Up @@ -121,14 +121,17 @@ public void passFieldTextDidChange(NSNotification notification) {

public void setKeychainCheckbox(NSButton keychainCheckbox) {
this.keychainCheckbox = keychainCheckbox;
this.keychainCheckbox.setEnabled(Preferences.instance().getBoolean("connection.login.useKeychain"));
this.keychainCheckbox.setState(Preferences.instance().getBoolean("connection.login.useKeychain")
&& Preferences.instance().getBoolean("connection.login.addKeychain") ? NSCell.NSOnState : NSCell.NSOffState);
this.keychainCheckbox.setTarget(this.id());
this.keychainCheckbox.setAction(Foundation.selector("keychainCheckboxClicked:"));
}

public void keychainCheckboxClicked(final NSButton sender) {
credentials.setUseKeychain(sender.state() == NSCell.NSOnState);
final boolean enabled = sender.state() == NSCell.NSOnState;
credentials.setUseKeychain(enabled);
Preferences.instance().setProperty("connection.login.addKeychain", enabled);
}

@Outlet
Expand Down

0 comments on commit 5aba7ae

Please sign in to comment.