Skip to content

Commit

Permalink
Merge pull request #193 in ITERATE/cyberduck from bugfix/SPECTRA-37-t…
Browse files Browse the repository at this point in the history
…itle-appendix to master

* commit 'e5fdd7ac699219707735fbc758cb3cb1ea452226 [formerly 1b4d9125623be2bc0a246cb15a6b59c7bae3ff7f]':
  Add text if more than one item.
  Add (n more) suffix if multiple items in transfer list.


Former-commit-id: 9ad7919a909f49b6c2a155b215d7bfe61579adbd
  • Loading branch information
automerge committed Feb 22, 2016
2 parents fca29aa + e5fdd7a commit 7d5c1cc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
20 changes: 16 additions & 4 deletions osx/src/main/java/ch/cyberduck/ui/cocoa/ProgressController.java
Expand Up @@ -56,6 +56,7 @@

import java.text.MessageFormat;
import java.util.Date;
import java.util.List;

/**
* @version $Id$
Expand Down Expand Up @@ -248,10 +249,21 @@ public void setFilesPopup(final NSPopUpButton p) {
this.filesPopup = p;
this.filesPopup.setTarget(this.id());
this.filesPopup.removeAllItems();
for(TransferItem i : transfer.getRoots()) {
NSMenuItem item = this.filesPopup.menu().addItemWithTitle_action_keyEquivalent(i.remote.getName(), Foundation.selector("reveal:"), StringUtils.EMPTY);
item.setRepresentedObject(i.remote.getAbsolute());
item.setImage(IconCacheFactory.<NSImage>get().fileIcon(i.remote, 16));
final List<TransferItem> items = transfer.getRoots();
for(int i = 0; i < items.size(); i++) {
final TransferItem entry = items.get(i);
final NSMenuItem item = this.filesPopup.menu().addItemWithTitle_action_keyEquivalent(entry.remote.getName(), null, StringUtils.EMPTY);
if(i == 0) {
if(items.size() > 1) {
item.setTitle(String.format("%s (%d more)", entry.remote.getName(), items.size() - 1));
}
else {
item.setTitle(entry.remote.getName());
}
}
else {
item.setTitle(entry.remote.getName());
}
}
this.filesPopupMenuDelegate = new TransferMenuDelegate(transfer);
this.filesPopup.menu().setDelegate(this.filesPopupMenuDelegate.id());
Expand Down
Expand Up @@ -34,10 +34,8 @@
import org.rococoa.cocoa.foundation.NSInteger;

import java.util.ArrayList;
import java.util.List;

/**
* @version $Id$
*/
public class TransferMenuDelegate extends AbstractMenuDelegate {

private Transfer transfer;
Expand All @@ -60,9 +58,8 @@ public NSInteger numberOfItemsInMenu(NSMenu menu) {

@Override
public boolean menuUpdateItemAtIndex(NSMenu menu, NSMenuItem item, NSInteger index, boolean cancel) {
final TransferItem entry
= new ArrayList<TransferItem>(transfer.getRoots()).get(index.intValue());
item.setTitle(entry.remote.getName());
final List<TransferItem> items = transfer.getRoots();
final TransferItem entry = new ArrayList<TransferItem>(items).get(index.intValue());
if(entry.local != null) {
item.setRepresentedObject(entry.local.getAbsolute());
if(entry.local.exists()) {
Expand Down
Expand Up @@ -177,12 +177,22 @@ private void Progress(String message)

private void SetRootPaths()
{
List srcRoots = _transfer.getRoots();
List items = _transfer.getRoots();
IList<string> roots = new List<string>();
for (int i = 0; i < srcRoots.size(); i++)
for (int i = 0; i < items.size(); i++)
{
TransferItem item = (TransferItem) srcRoots.get(i);
roots.Add(item.remote.getName());
TransferItem item = (TransferItem) items.get(i);
if(i == 0) {
if(items.size() > 1) {
roots.Add(String.Format("{0} ({1} more)", item.remote.getName(), items.size() - 1));
}
else {
roots.Add(item.remote.getName());
}
}
else {
roots.Add(item.remote.getName());
}
}
View.PopulateRoots(roots);
}
Expand Down

0 comments on commit 7d5c1cc

Please sign in to comment.