From e85b4dfb2ecf6f56959101f57d21754c8eb41e66 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Thu, 17 Aug 2023 15:15:43 +0200 Subject: [PATCH] Skip prompt to copy URL on failure creating share. --- .../core/worker/DownloadShareWorker.java | 5 - .../core/worker/UploadShareWorker.java | 5 - .../cocoa/controller/BrowserController.java | 118 +++++++++--------- .../ui/controller/BrowserController.cs | 8 +- 4 files changed, 65 insertions(+), 71 deletions(-) diff --git a/core/src/main/java/ch/cyberduck/core/worker/DownloadShareWorker.java b/core/src/main/java/ch/cyberduck/core/worker/DownloadShareWorker.java index 115c458771c..2fd48853407 100644 --- a/core/src/main/java/ch/cyberduck/core/worker/DownloadShareWorker.java +++ b/core/src/main/java/ch/cyberduck/core/worker/DownloadShareWorker.java @@ -61,11 +61,6 @@ public DescriptiveUrl run(final Session session) throws BackgroundException { } } - @Override - public DescriptiveUrl initialize() { - return DescriptiveUrl.EMPTY; - } - @Override public String getActivity() { return MessageFormat.format(LocaleFactory.localizedString("Prepare {0} ({1})", "Status"), diff --git a/core/src/main/java/ch/cyberduck/core/worker/UploadShareWorker.java b/core/src/main/java/ch/cyberduck/core/worker/UploadShareWorker.java index 52bc14e1b99..5a8aba52432 100644 --- a/core/src/main/java/ch/cyberduck/core/worker/UploadShareWorker.java +++ b/core/src/main/java/ch/cyberduck/core/worker/UploadShareWorker.java @@ -61,11 +61,6 @@ public DescriptiveUrl run(final Session session) throws BackgroundException { } } - @Override - public DescriptiveUrl initialize() { - return DescriptiveUrl.EMPTY; - } - @Override public String getActivity() { return MessageFormat.format(LocaleFactory.localizedString("Prepare {0} ({1})", "Status"), diff --git a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java index 02f4ce36670..1b4e404ec08 100644 --- a/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java +++ b/osx/src/main/java/ch/cyberduck/ui/cocoa/controller/BrowserController.java @@ -2572,38 +2572,40 @@ public void shareFileButtonClicked(final ID sender) { new DownloadShareWorker(file, null, PasswordCallbackFactory.get(this), new PromptShareeCallback(pool.getHost(), this)) { @Override public void cleanup(final DescriptiveUrl url) { - // Display - final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"), - MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()), - LocaleFactory.localizedString("Continue", "Credentials"), - null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null, - null)) { - @Override - public void callback(final int returncode) { - switch(returncode) { - case SheetCallback.CANCEL_OPTION: - final NSPasteboard pboard = NSPasteboard.generalPasteboard(); - pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null); - if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) { - log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType)); - } + if(null != url) { + // Display + final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"), + MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()), + LocaleFactory.localizedString("Continue", "Credentials"), + null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null, + null)) { + @Override + public void callback(final int returncode) { + switch(returncode) { + case SheetCallback.CANCEL_OPTION: + final NSPasteboard pboard = NSPasteboard.generalPasteboard(); + pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null); + if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) { + log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType)); + } + } } - } - @Override - public NSView getAccessoryView(final NSAlert alert) { - if(null == url.getUrl()) { - return null; + @Override + public NSView getAccessoryView(final NSAlert alert) { + if(null == url.getUrl()) { + return null; + } + final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22)); + field.setEditable(false); + field.setSelectable(true); + field.cell().setWraps(false); + field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES)); + return field; } - final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22)); - field.setEditable(false); - field.setSelectable(true); - field.cell().setWraps(false); - field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES)); - return field; - } - }; - alert.beginSheet(BrowserController.this); + }; + alert.beginSheet(BrowserController.this); + } } } ) @@ -2617,37 +2619,39 @@ public void requestFilesButtonClicked(final ID sender) { new UploadShareWorker(file, null, PasswordCallbackFactory.get(this), new PromptShareeCallback(pool.getHost(), this)) { @Override public void cleanup(final DescriptiveUrl url) { - final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"), - MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()), - LocaleFactory.localizedString("Continue", "Credentials"), - null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null, - null)) { - @Override - public void callback(final int returncode) { - switch(returncode) { - case SheetCallback.CANCEL_OPTION: - final NSPasteboard pboard = NSPasteboard.generalPasteboard(); - pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null); - if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) { - log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType)); - } + if(null != url) { + final AlertController alert = new AlertController(NSAlert.alert(LocaleFactory.localizedString("Share…", "Main"), + MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS"), file.getName()), + LocaleFactory.localizedString("Continue", "Credentials"), + null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null, + null)) { + @Override + public void callback(final int returncode) { + switch(returncode) { + case SheetCallback.CANCEL_OPTION: + final NSPasteboard pboard = NSPasteboard.generalPasteboard(); + pboard.declareTypes(NSArray.arrayWithObject(NSString.stringWithString(NSPasteboard.StringPboardType)), null); + if(!pboard.setStringForType(url.getUrl(), NSPasteboard.StringPboardType)) { + log.error(String.format("Error writing URL to %s", NSPasteboard.StringPboardType)); + } + } } - } - @Override - public NSView getAccessoryView(final NSAlert alert) { - if(null == url.getUrl()) { - return null; + @Override + public NSView getAccessoryView(final NSAlert alert) { + if(null == url.getUrl()) { + return null; + } + final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22)); + field.setEditable(false); + field.setSelectable(true); + field.cell().setWraps(false); + field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES)); + return field; } - final NSTextField field = NSTextField.textfieldWithFrame(new NSRect(0, 22)); - field.setEditable(false); - field.setSelectable(true); - field.cell().setWraps(false); - field.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes(url.getUrl(), TRUNCATE_MIDDLE_ATTRIBUTES)); - return field; - } - }; - alert.beginSheet(BrowserController.this); + }; + alert.beginSheet(BrowserController.this); + } } } ) diff --git a/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs b/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs index 0c2f17f529c..1c4f8ee9bbd 100644 --- a/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs +++ b/windows/src/main/csharp/ch/cyberduck/ui/controller/BrowserController.cs @@ -3682,11 +3682,11 @@ public override void cleanup(object result) { DescriptiveUrl url = (DescriptiveUrl)result; // Display - if (!DescriptiveUrl.EMPTY.@equals(url)) + if (null != url) { string title = LocaleFactory.localizedString("Share…", "Main"); string commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Continue", "Credentials"), - LocaleFactory.localizedString("Copy", "Main")); + null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null); _controller.CommandBox(title, title, MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS") + "\n\n{1}", _file.getName(), url.getUrl()), commandButtons, false, null, TaskDialogIcon.Information, @@ -3727,11 +3727,11 @@ public override void cleanup(object result) { DescriptiveUrl url = (DescriptiveUrl)result; // Display - if (!DescriptiveUrl.EMPTY.@equals(url)) + if (null != url) { string title = LocaleFactory.localizedString("Share…", "Main"); string commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Continue", "Credentials"), - LocaleFactory.localizedString("Copy", "Main")); + null != url.getUrl() ? LocaleFactory.localizedString("Copy", "Main") : null); _controller.CommandBox(title, title, MessageFormat.format(LocaleFactory.localizedString("You have successfully created a share link for {0}.", "SDS") + "\n\n{1}", _file.getName(), url.getUrl()), commandButtons, false, null, TaskDialogIcon.Information,