Skip to content

Commit

Permalink
Fix #8039.
Browse files Browse the repository at this point in the history
Former-commit-id: a2910214cc5c798e8700dd09a0b17462f898c109
  • Loading branch information
dkocher committed Oct 7, 2014
1 parent f60abca commit c5424ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
8 changes: 4 additions & 4 deletions source/ch/cyberduck/ui/cocoa/BrowserController.java
Expand Up @@ -2758,9 +2758,11 @@ public void downloadButtonClicked(final ID sender) {
public void uploadButtonClicked(final ID sender) {
uploadPanel = NSOpenPanel.openPanel();
uploadPanel.setCanChooseDirectories(true);
uploadPanel.setCanChooseFiles(session.getFeature(Touch.class).isSupported(
new UploadTargetFinder(workdir).find(this.getSelectedPath())
));
uploadPanel.setCanCreateDirectories(false);
uploadPanel.setTreatsFilePackagesAsDirectories(true);
uploadPanel.setCanChooseFiles(true);
uploadPanel.setAllowsMultipleSelection(true);
uploadPanel.setPrompt(LocaleFactory.localizedString("Upload"));
if(uploadPanel.respondsToSelector(Foundation.selector("setShowsHiddenFiles:"))) {
Expand Down Expand Up @@ -3775,9 +3777,7 @@ else if(action.equals(Foundation.selector("newBrowserButtonClicked:"))) {
return this.isMounted();
}
else if(action.equals(Foundation.selector("uploadButtonClicked:"))) {
return this.isBrowser() && this.isMounted() && session.getFeature(Touch.class).isSupported(
new UploadTargetFinder(workdir).find(this.getSelectedPath())
);
return this.isBrowser() && this.isMounted();
}
else if(action.equals(Foundation.selector("syncButtonClicked:"))) {
return this.isBrowser() && this.isMounted();
Expand Down
29 changes: 20 additions & 9 deletions source/ch/cyberduck/ui/cocoa/BrowserTableDataSource.java
Expand Up @@ -284,7 +284,7 @@ public boolean acceptDrop(final NSTableView view, final Path destination, final
log.debug(String.format("Accept drop for destination %s", destination));
}
if(info.draggingPasteboard().availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.URLPboardType)) != null) {
NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.URLPboardType);
final NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.URLPboardType);
// Mount .webloc URLs dragged to browser window
if(o != null) {
if(o.isKindOfClass(Rococoa.createClass("NSArray", NSArray._Class.class))) {
Expand All @@ -300,7 +300,7 @@ public boolean acceptDrop(final NSTableView view, final Path destination, final
}
if(controller.isMounted()) {
if(info.draggingPasteboard().availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.FilenamesPboardType)) != null) {
NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.FilenamesPboardType);
final NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.FilenamesPboardType);
// A file drag has been received by another application; upload to the dragged directory
if(o != null) {
if(o.isKindOfClass(Rococoa.createClass("NSArray", NSArray._Class.class))) {
Expand Down Expand Up @@ -364,7 +364,7 @@ public NSUInteger validateDrop(final NSTableView view, final Path destination, f
}
if(info.draggingPasteboard().availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.URLPboardType)) != null) {
// Dragging URLs to mount new session
NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.URLPboardType);
final NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.URLPboardType);
if(o != null) {
if(o.isKindOfClass(Rococoa.createClass("NSArray", NSArray._Class.class))) {
final NSArray elements = Rococoa.cast(o, NSArray.class);
Expand All @@ -391,15 +391,26 @@ public NSUInteger validateDrop(final NSTableView view, final Path destination, f
log.warn("Dragging destination is null.");
return NSDraggingInfo.NSDragOperationNone;
}
final Touch feature = controller.getSession().getFeature(Touch.class);
if(!feature.isSupported(destination)) {
// Target file system does not support creating files. Creating files is not supported
// for example in root of cloud storage accounts.
return NSDraggingInfo.NSDragOperationNone;
}
// Files dragged form other application
if(info.draggingPasteboard().availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.FilenamesPboardType)) != null) {
this.setDropRowAndDropOperation(view, destination, row);
final NSObject o = info.draggingPasteboard().propertyListForType(NSPasteboard.FilenamesPboardType);
if(o != null) {
if(o.isKindOfClass(Rococoa.createClass("NSArray", NSArray._Class.class))) {
final NSArray elements = Rococoa.cast(o, NSArray.class);
for(int i = 0; i < elements.count().intValue(); i++) {
final Local local = LocalFactory.createLocal(elements.objectAtIndex(new NSUInteger(i)).toString());
if(local.isFile()) {
final Touch feature = controller.getSession().getFeature(Touch.class);
if(!feature.isSupported(destination)) {
// Target file system does not support creating files. Creating files is not supported
// for example in root of cloud storage accounts.
return NSDraggingInfo.NSDragOperationNone;
}
}
}
}
}
return NSDraggingInfo.NSDragOperationCopy;
}
// Files dragged from browser
Expand Down

0 comments on commit c5424ba

Please sign in to comment.