Skip to content

Commit

Permalink
Skip prompt to copy URL on failure creating share.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Aug 17, 2023
1 parent 9875744 commit e85b4df
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2572,38 +2572,40 @@ public void shareFileButtonClicked(final ID sender) {
new DownloadShareWorker<Void>(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);
}
}
}
)
Expand All @@ -2617,37 +2619,39 @@ public void requestFilesButtonClicked(final ID sender) {
new UploadShareWorker<Void>(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);
}
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e85b4df

Please sign in to comment.