Skip to content

Commit

Permalink
Fix #8933 and #8928.
Browse files Browse the repository at this point in the history
Former-commit-id: cfb1f46c788de365ba989f292e9e5ed05a47b16a
  • Loading branch information
dkocher committed Jul 17, 2015
1 parent cc773e2 commit 2de8a19
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions source/ch/cyberduck/ui/cocoa/PromptLoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,18 @@ public void setPkCheckbox(NSButton pkCheckbox) {
@Action
public void pkCheckboxSelectionChanged(final NSButton sender) {
if(sender.state() == NSCell.NSOnState) {
try {
final Local selected = select(this, new SheetCallback() {
@Override
public void callback(final int returncode) {
//
select(this, new SheetCallback() {
@Override
public void callback(final int returncode) {
if(returncode == SheetCallback.DEFAULT_OPTION) {
final NSObject selected = select.filenames().lastObject();
if(selected != null) {
credentials.setIdentity(LocalFactory.get(selected.toString()));
update();
}
}
});
credentials.setIdentity(selected);
update();
}
catch(LoginCanceledException e) {
//
}
}
});
}
else {
credentials.setIdentity(null);
Expand Down Expand Up @@ -365,23 +364,27 @@ public void callback(final int returncode) {
private NSOpenPanel select;

public Local select(final Local identity) throws LoginCanceledException {
return this.select(parent, new SheetCallback() {
final Local selected = this.select(parent, new SheetCallback() {
@Override
public void callback(final int returncode) {
//
}
});
if(null == selected) {
throw new LoginCanceledException();
}
return selected;
}

protected Local select(final WindowController parent, final SheetCallback callback) throws LoginCanceledException {
protected Local select(final WindowController parent, final SheetCallback callback) {
final SheetController sheet = new SheetController(parent) {
@Override
public void callback(final int returncode) {
callback.callback(returncode);
}

@Override
public void beginSheet() {
public void beginSheet(final NSWindow window) {
select = NSOpenPanel.openPanel();
select.setCanChooseDirectories(false);
select.setCanChooseFiles(true);
Expand All @@ -404,6 +407,6 @@ public NSWindow window() {
return LocalFactory.get(selected.toString());
}
}
throw new LoginCanceledException();
return null;
}
}

0 comments on commit 2de8a19

Please sign in to comment.