2 * Copyright (c) 2008 David Kocher. All rights reserved.
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
;
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
);
54 * @return A tooltip string containing the size and modification date of the path
57 public String
tooltip(Path file
) {
58 return tooltip
.getTooltip(file
);
62 public Comparator
<Path
> getSortingComparator() {
63 final boolean ascending
= this.isSortedAscending();
64 final String identifier
= this.selectedColumnIdentifier();
65 switch(Column
.valueOf(identifier
)) {
68 return new FileTypeComparator(ascending
);
70 return new ExtensionComparator(ascending
);
72 return new FilenameComparator(ascending
);
74 return new SizeComparator(ascending
);
76 return new TimestampComparator(ascending
);
78 return new OwnerComparator(ascending
);
80 return new GroupComparator(ascending
);
82 return new PermissionsComparator(ascending
);
84 return new RegionComparator(ascending
);
86 return new VersionComparator(ascending
);
88 log
.error(String
.format("Unknown column identifier %s", identifier
));
89 return new NullComparator
<Path
>();