Skip to content

Commit

Permalink
Support for #46
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jan 14, 2007
1 parent 0038603 commit 9e12f48
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 50 deletions.
7 changes: 4 additions & 3 deletions source/ch/cyberduck/ui/cocoa/CDAbstractTableDelegate.java
Expand Up @@ -173,7 +173,8 @@ public boolean isSortedAscending() {
public Comparator getSortingComparator() {
final boolean ascending = this.isSortedAscending();
String identifier = this.selectedColumnIdentifier();
if (identifier.equals(CDBrowserTableDataSource.TYPE_COLUMN)) {
if (identifier.equals(CDBrowserTableDataSource.ICON_COLUMN)
|| identifier.equals(CDBrowserTableDataSource.KIND_COLUMN)) {
return new FileTypeComparator(ascending);
}
else if (identifier.equals(CDBrowserTableDataSource.FILENAME_COLUMN)) {
Expand Down Expand Up @@ -217,7 +218,7 @@ public int compare(Object o1, Object o2) {
}

public String toString() {
return CDBrowserTableDataSource.TYPE_COLUMN;
return CDBrowserTableDataSource.ICON_COLUMN;
}
}

Expand Down Expand Up @@ -311,7 +312,7 @@ public int compare(Object o1, Object o2) {
}

public String toString() {
return CDBrowserTableDataSource.TYPE_COLUMN;
return CDBrowserTableDataSource.OWNER_COLUMN;
}
}

Expand Down
119 changes: 74 additions & 45 deletions source/ch/cyberduck/ui/cocoa/CDBrowserController.java
Expand Up @@ -1009,7 +1009,7 @@ public String tableViewToolTipForCell(NSTableView view, NSCell cell, NSMutableRe
= new NSSelector("setResizingMask", new Class[]{int.class});
{
NSTableColumn c = new NSTableColumn();
c.setIdentifier(CDBrowserTableDataSource.TYPE_COLUMN);
c.setIdentifier(CDBrowserTableDataSource.ICON_COLUMN);
c.headerCell().setStringValue("");
c.setMinWidth(20f);
c.setWidth(20f);
Expand Down Expand Up @@ -1141,6 +1141,23 @@ protected void _updateBrowserColumns(NSTableView table) {
c.setDataCell(new NSTextFieldCell());
table.addTableColumn(c);
}
table.removeTableColumn(table.tableColumnWithIdentifier(CDBrowserTableDataSource.KIND_COLUMN));
if(Preferences.instance().getBoolean("browser.columnKind")) {
NSTableColumn c = new NSTableColumn();
c.headerCell().setStringValue(NSBundle.localizedString("Kind", "A column in the browser"));
c.setIdentifier(CDBrowserTableDataSource.KIND_COLUMN);
c.setMinWidth(50f);
c.setWidth(80f);
c.setMaxWidth(500f);
if(setResizableMaskSelector.implementedByClass(NSTableColumn.class)) {
c.setResizingMask(NSTableColumn.AutoresizingMask | NSTableColumn.UserResizingMask);
}
else {
c.setResizable(true);
}
c.setDataCell(new NSTextFieldCell());
table.addTableColumn(c);
}
table.setIndicatorImage(((CDTableDelegate) table.delegate()).isSortedAscending() ?
NSImage.imageNamed("NSAscendingSortIndicator") :
NSImage.imageNamed("NSDescendingSortIndicator"),
Expand Down Expand Up @@ -1174,13 +1191,7 @@ public void collectionItemChanged(Object item) {
});
this.bookmarkTable.setDelegate(this.bookmarkTableDelegate = new CDAbstractTableDelegate() {
public void tableRowDoubleClicked(final Object sender) {
if(bookmarkTable.numberOfSelectedRows() == 1) {
final Host selected = (Host) HostCollection.instance().get(bookmarkTable.selectedRow());
CDBrowserController.this.mount(selected);
if(Preferences.instance().getBoolean("browser.closeDrawer")) {
bookmarkDrawer.close();
}
}
CDBrowserController.this.connectBookmarkButtonClicked(sender);
}

public void enterKeyPressed(final Object sender) {
Expand Down Expand Up @@ -1357,6 +1368,16 @@ public void searchFieldTextDidChange(NSNotification notification) {
// Manage Bookmarks
// ----------------------------------------------------------

public void connectBookmarkButtonClicked(final Object sender) {
if(bookmarkTable.numberOfSelectedRows() == 1) {
final Host selected = (Host) HostCollection.instance().get(bookmarkTable.selectedRow());
CDBrowserController.this.mount(selected);
if(Preferences.instance().getBoolean("browser.closeDrawer")) {
bookmarkDrawer.close();
}
}
}

private NSButton editBookmarkButton; // IBOutlet

public void setEditBookmarkButton(NSButton editBookmarkButton) {
Expand Down Expand Up @@ -1582,15 +1603,15 @@ public void setEncodingPopup(NSPopUpButton encodingPopup) {
this.encodingPopup.selectItemWithTitle(Preferences.instance().getProperty("browser.charset.encoding"));
}

public void encodingButtonClicked(final Object sender) {
String e = null;
if(sender instanceof NSMenuItem) {
e = ((NSMenuItem) sender).title();
}
if(sender instanceof NSPopUpButton) {
e = this.encodingPopup.titleOfSelectedItem();
}
final String encoding = e;
public void encodingButtonClicked(final NSPopUpButton sender) {
this.encodingChanged(sender.titleOfSelectedItem());
}

public void encodingMenuClicked(final NSMenuItem sender) {
this.encodingChanged(sender.title());
}

public void encodingChanged(final String encoding) {
if(null == encoding) {
return;
}
Expand All @@ -1609,7 +1630,7 @@ public void run() {

public void cleanup() {
session.getHost().setEncoding(encoding);
reloadButtonClicked(sender);
reloadButtonClicked(null);
}
});
}
Expand Down Expand Up @@ -2326,20 +2347,17 @@ public void cleanup() {
}
}

public void showHiddenFilesClicked(final Object sender) {
if(sender instanceof NSMenuItem) {
NSMenuItem item = (NSMenuItem) sender;
if(item.state() == NSCell.OnState) {
this.setShowHiddenFiles(false);
item.setState(NSCell.OffState);
}
else if(item.state() == NSCell.OffState) {
this.setShowHiddenFiles(true);
item.setState(NSCell.OnState);
}
if(this.isMounted()) {
this.reloadData(true);
}
public void showHiddenFilesClicked(final NSMenuItem sender) {
if(sender.state() == NSCell.OnState) {
this.setShowHiddenFiles(false);
sender.setState(NSCell.OffState);
}
else if(sender.state() == NSCell.OffState) {
this.setShowHiddenFiles(true);
sender.setState(NSCell.OnState);
}
if(this.isMounted()) {
this.reloadData(true);
}
}

Expand Down Expand Up @@ -2992,12 +3010,14 @@ public boolean validateMenuItem(NSMenuItem item) {
if(identifier.equals("showHiddenFilesClicked:")) {
item.setState((this.getFileFilter() instanceof NullPathFilter) ? NSCell.OnState : NSCell.OffState);
}
if(identifier.equals("encodingButtonClicked:")) {
if(identifier.equals("encodingMenuClicked:")) {
if(this.isMounted()) {
item.setState(this.session.getEncoding().equalsIgnoreCase(item.title()) ? NSCell.OnState : NSCell.OffState);
item.setState(this.session.getEncoding().equalsIgnoreCase(
item.title()) ? NSCell.OnState : NSCell.OffState);
}
else {
item.setState(Preferences.instance().getProperty("browser.charset.encoding").equalsIgnoreCase(item.title()) ? NSCell.OnState : NSCell.OffState);
item.setState(Preferences.instance().getProperty("browser.charset.encoding").equalsIgnoreCase(
item.title()) ? NSCell.OnState : NSCell.OffState);
}
}
if(identifier.equals("browserSwitchClicked:")) {
Expand Down Expand Up @@ -3046,9 +3066,12 @@ private boolean validateItem(String identifier) {
}
return false;
}
if(identifier.equals("encodingButtonClicked:")) {
if(identifier.equals("encodingMenuClicked:")) {
return !isBusy();
}
if(identifier.equals("connectBookmarkButtonClicked:")) {
return bookmarkTable.numberOfSelectedRows() == 1;
}
if(identifier.equals("deleteBookmarkButtonClicked:")) {
return bookmarkTable.selectedRow() != -1;
}
Expand All @@ -3060,20 +3083,26 @@ private boolean validateItem(String identifier) {
String editorPath = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(
Preferences.instance().getProperty("editor.bundleIdentifier"));
if(editorPath != null) {
Path selected = this.getSelectedPath();
if(selected != null) {
return this.isEditable(selected);
for(Iterator i = this.getSelectedPaths().iterator(); i.hasNext();) {
final Path selected = (Path) i.next();
if(!this.isEditable(selected)) {
return false;
}
}
return true;
}
}
return false;
}
if(identifier.equals("editMenuClicked:")) {
if(this.isMounted()) {
Path selected = this.getSelectedPath();
if(selected != null) {
return this.isEditable(selected);
for(Iterator i = this.getSelectedPaths().iterator(); i.hasNext();) {
final Path selected = (Path) i.next();
if(!this.isEditable(selected)) {
return false;
}
}
return true;
}
return false;
}
Expand Down Expand Up @@ -3296,13 +3325,13 @@ public NSToolbarItem toolbarItemForItemIdentifier(NSToolbar toolbar, String item
item.setView(this.encodingPopup);
// Add a menu representation for text mode of toolbar
NSMenuItem encodingMenu = new NSMenuItem(NSBundle.localizedString(TOOLBAR_ENCODING, "Toolbar item"),
new NSSelector("encodingButtonClicked", new Class[]{Object.class}),
new NSSelector("encodingMenuClicked", new Class[]{Object.class}),
"");
String[] charsets = ((CDMainController)NSApplication.sharedApplication().delegate()).availableCharsets();
NSMenu charsetMenu = new NSMenu();
for(int i = 0; i < charsets.length; i++) {
charsetMenu.addItem(new NSMenuItem(charsets[i],
new NSSelector("encodingButtonClicked", new Class[]{Object.class}),
new NSSelector("encodingMenuClicked", new Class[]{Object.class}),
""));
}
encodingMenu.setSubmenu(charsetMenu);
Expand Down Expand Up @@ -3370,7 +3399,7 @@ public NSToolbarItem toolbarItemForItemIdentifier(NSToolbar toolbar, String item
item.setAction(new NSSelector("editButtonClicked", new Class[]{Object.class}));
// Add a menu representation for text mode of toolbar
NSMenuItem toolbarMenu = new NSMenuItem(NSBundle.localizedString(TOOLBAR_EDIT, "Toolbar item"),
new NSSelector("editButtonClicked", new Class[]{Object.class}),
new NSSelector("editMenuClicked", new Class[]{Object.class}),
"");
NSMenu editMenu = new NSMenu();
editMenu.setAutoenablesItems(true);
Expand Down
9 changes: 7 additions & 2 deletions source/ch/cyberduck/ui/cocoa/CDBrowserTableDataSource.java
Expand Up @@ -50,12 +50,13 @@ public abstract class CDBrowserTableDataSource extends NSObject {
NOT_FOUND_ICON.setSize(new NSSize(16f, 16f));
}

public static final String TYPE_COLUMN = "TYPE";
public static final String ICON_COLUMN = "ICON";
public static final String FILENAME_COLUMN = "FILENAME";
public static final String SIZE_COLUMN = "SIZE";
public static final String MODIFIED_COLUMN = "MODIFIED";
public static final String OWNER_COLUMN = "OWNER";
public static final String PERMISSIONS_COLUMN = "PERMISSIONS";
public static final String KIND_COLUMN = "KIND";
// virtual column to implement keyboard selection
protected static final String TYPEAHEAD_COLUMN = "TYPEAHEAD";

Expand Down Expand Up @@ -175,7 +176,7 @@ else if (item.attributes.isFile()) {

public Object objectValueForItem(Path item, String identifier) {
if (null != item) {
if (identifier.equals(TYPE_COLUMN)) {
if (identifier.equals(ICON_COLUMN)) {
return this.iconforPath(item);
}
if (identifier.equals(FILENAME_COLUMN)) {
Expand Down Expand Up @@ -206,6 +207,10 @@ public Object objectValueForItem(Path item, String identifier) {
return new NSAttributedString(item.attributes.getPermission().toString(),
CDTableCell.PARAGRAPH_DICTIONARY_LEFT_ALIGNEMENT);
}
if (identifier.equals(KIND_COLUMN)) {
return new NSAttributedString(item.kind(),
CDTableCell.PARAGRAPH_DICTIONARY_LEFT_ALIGNEMENT);
}
throw new IllegalArgumentException("Unknown identifier: " + identifier);
}
log.warn("objectValueForItem:"+item+","+identifier);
Expand Down

0 comments on commit 9e12f48

Please sign in to comment.