Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / AbstractPathTableDelegate.java
blob8f0bbf95b7b8b45ce4f00a97e10eb7106b7e819d
1 /*
2 * Copyright (c) 2008 David Kocher. All rights reserved.
3 * http://cyberduck.ch/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * Bug fixes, suggestions and comments should be sent to:
16 * dkocher@cyberduck.ch
19 package ch.cyberduck.ui.cocoa;
21 import ch.cyberduck.core.NullComparator;
22 import ch.cyberduck.core.Path;
23 import ch.cyberduck.ui.browser.Column;
24 import ch.cyberduck.ui.browser.PathTooltipService;
25 import ch.cyberduck.binding.application.NSTableColumn;
26 import ch.cyberduck.ui.comparator.ExtensionComparator;
27 import ch.cyberduck.ui.comparator.FileTypeComparator;
28 import ch.cyberduck.ui.comparator.FilenameComparator;
29 import ch.cyberduck.ui.comparator.GroupComparator;
30 import ch.cyberduck.ui.comparator.OwnerComparator;
31 import ch.cyberduck.ui.comparator.PermissionsComparator;
32 import ch.cyberduck.ui.comparator.RegionComparator;
33 import ch.cyberduck.ui.comparator.SizeComparator;
34 import ch.cyberduck.ui.comparator.TimestampComparator;
35 import ch.cyberduck.ui.comparator.VersionComparator;
37 import org.apache.log4j.Logger;
39 import java.util.Comparator;
41 /**
42 * @version $Id$
44 public abstract class AbstractPathTableDelegate extends AbstractTableDelegate<Path> {
45 private static Logger log = Logger.getLogger(AbstractTableDelegate.class);
47 private PathTooltipService tooltip = new PathTooltipService();
49 protected AbstractPathTableDelegate(final NSTableColumn selectedColumn) {
50 super(selectedColumn);
53 /**
54 * @return A tooltip string containing the size and modification date of the path
56 @Override
57 public String tooltip(Path file) {
58 return tooltip.getTooltip(file);
61 @Override
62 public Comparator<Path> getSortingComparator() {
63 final boolean ascending = this.isSortedAscending();
64 final String identifier = this.selectedColumnIdentifier();
65 switch(Column.valueOf(identifier)) {
66 case icon:
67 case kind:
68 return new FileTypeComparator(ascending);
69 case extension:
70 return new ExtensionComparator(ascending);
71 case filename:
72 return new FilenameComparator(ascending);
73 case size:
74 return new SizeComparator(ascending);
75 case modified:
76 return new TimestampComparator(ascending);
77 case owner:
78 return new OwnerComparator(ascending);
79 case group:
80 return new GroupComparator(ascending);
81 case permission:
82 return new PermissionsComparator(ascending);
83 case region:
84 return new RegionComparator(ascending);
85 case version:
86 return new VersionComparator(ascending);
87 default:
88 log.error(String.format("Unknown column identifier %s", identifier));
89 return new NullComparator<Path>();