*** empty log message ***

This commit is contained in:
David Kocher
2005-10-11 22:00:04 +00:00
parent 1369e8ca39
commit 77f1c9a46e
76 changed files with 1397 additions and 2943 deletions
+1
View File
@@ -968,6 +968,7 @@ source/ch/cyberduck/Attic/connection/.DS_Store svneol=native#unset
source/ch/cyberduck/Attic/connection/ftp/.DS_Store svneol=native#unset
source/ch/cyberduck/Attic/connection/http/.DS_Store svneol=native#unset
source/ch/cyberduck/Attic/connection/sftp/.DS_Store svneol=native#unset
source/com/unsanity/smartcrashreports/SmartCrashReportsInstall.o -text
sv.lproj/Bookmark.nib/keyedobjects.nib -text
sv.lproj/Bookmark.strings svneol=native#unset
sv.lproj/Browser.nib/keyedobjects.nib -text
+8
View File
@@ -4,6 +4,14 @@ http://cyberduck.ch/
Last modified: $Date$
Cyberduck is an open source SFTP (SSH Secure File Transfer) and FTP browser licenced under the GPL for the Mac.
2.5.1
- [Feature] Rename files inline in browser view
- [Feature] Dragging files to application icon will upload to frontmost browser
_ [Feature] Universal Binary (ppc/intel)
- [Bugfix] Don't recurse into directories when deleting symbolic links
- [Bugfix] Updated application and document icon
- [Bugfix] Overwriting group writable files
2.5
- [Feature] Graphical interface refinements
- [Bugfix] Caching issue with multiple connections to the same host
-4
View File
@@ -37,10 +37,6 @@
(<a href="http://zathras.de">UKPrefsPanel</a>)
</p>
<p>
This product includes software developed by <b>Troy Stephens</b>
(<a href="http://homepage.mac.com/troy_stephens/software/objects/IconFamily/">IconFamily</a>)
</p>
<p>
This product includes software developed by <b>Arthur van Hoff</b> and <b>Rick Blair</b>
(<a href="http://jmdns.sf.net">jmdns</a>)
</p>
+36 -24
View File
@@ -52,11 +52,7 @@
4739EFAB0856990900405FD3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 479982AF05F54B1600F81519 /* Carbon.framework */; };
4739EFAC0856990900405FD3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47C761EA06A88D7600B464FF /* SystemConfiguration.framework */; };
4739EFB30856991200405FD3 /* Local.h in Headers */ = {isa = PBXBuildFile; fileRef = 475D187C0805E24B00166B8A /* Local.h */; };
4739EFB40856991200405FD3 /* IconFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 475D187E0805E24B00166B8A /* IconFamily.h */; };
4739EFB50856991200405FD3 /* NSString+CarbonFSSpecCreation.h in Headers */ = {isa = PBXBuildFile; fileRef = 475D189E0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.h */; };
4739EFB70856991200405FD3 /* Local.m in Sources */ = {isa = PBXBuildFile; fileRef = 475D187B0805E24B00166B8A /* Local.m */; };
4739EFB80856991200405FD3 /* NSString+CarbonFSSpecCreation.m in Sources */ = {isa = PBXBuildFile; fileRef = 475D189F0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.m */; };
4739EFB90856991200405FD3 /* IconFamily.m in Sources */ = {isa = PBXBuildFile; fileRef = 475D187D0805E24B00166B8A /* IconFamily.m */; };
4739EFBB0856991200405FD3 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4725BE0A05D2E27000C7CCBD /* JavaVM.framework */; };
4739EFBC0856991200405FD3 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
4739EFBD0856991200405FD3 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 479982AF05F54B1600F81519 /* Carbon.framework */; };
@@ -135,6 +131,11 @@
475D17C00805D54C00166B8A /* download2.icns in Resources */ = {isa = PBXBuildFile; fileRef = 475D17B60805D54C00166B8A /* download2.icns */; };
475D17C10805D54C00166B8A /* download1.icns in Resources */ = {isa = PBXBuildFile; fileRef = 475D17B70805D54C00166B8A /* download1.icns */; };
475D17C20805D54C00166B8A /* download4.icns in Resources */ = {isa = PBXBuildFile; fileRef = 475D17B80805D54C00166B8A /* download4.icns */; };
47649C8508E5614A00207DC9 /* SmartCrashReportsInstall.h in Headers */ = {isa = PBXBuildFile; fileRef = 47649C8308E5614A00207DC9 /* SmartCrashReportsInstall.h */; };
47649E0908E563C500207DC9 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 47983764072AD73700FA3CDB /* Security.framework */; };
47649E4508E563D000207DC9 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 476DEBE10629C6FB005EF4B1 /* CoreFoundation.framework */; };
47649EDD08E563D600207DC9 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 479982AF05F54B1600F81519 /* Carbon.framework */; };
4764A09C08E565EC00207DC9 /* SmartCrashReportsInstall.o in Frameworks */ = {isa = PBXBuildFile; fileRef = 4764A09B08E565EC00207DC9 /* SmartCrashReportsInstall.o */; };
4764B48108B7835E00441096 /* SKWSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 4764B47D08B7835E00441096 /* SKWSegmentedControl.m */; };
4764B48208B7835E00441096 /* SKWSegmentedControlWindowProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 4764B47E08B7835E00441096 /* SKWSegmentedControlWindowProxy.m */; };
4764B48308B7835E00441096 /* SKWSegmentedControlWindowProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4764B47F08B7835E00441096 /* SKWSegmentedControlWindowProxy.h */; };
@@ -282,7 +283,6 @@
/* Begin PBXFileReference section */
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
47026427087DC91C008837FD /* en */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/IDisk.strings; sourceTree = "<group>"; };
4702642B087DC92C008837FD /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/IDisk.strings; sourceTree = "<group>"; };
@@ -1130,10 +1130,8 @@
475D17B80805D54C00166B8A /* download4.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = download4.icns; sourceTree = "<group>"; };
475D187B0805E24B00166B8A /* Local.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Local.m; sourceTree = "<group>"; };
475D187C0805E24B00166B8A /* Local.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Local.h; path = source/ch/cyberduck/core/Local.h; sourceTree = SOURCE_ROOT; };
475D187D0805E24B00166B8A /* IconFamily.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IconFamily.m; sourceTree = "<group>"; };
475D187E0805E24B00166B8A /* IconFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IconFamily.h; sourceTree = "<group>"; };
475D189E0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CarbonFSSpecCreation.h"; sourceTree = "<group>"; };
475D189F0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+CarbonFSSpecCreation.m"; sourceTree = "<group>"; };
47649C8308E5614A00207DC9 /* SmartCrashReportsInstall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartCrashReportsInstall.h; sourceTree = "<group>"; };
4764A09B08E565EC00207DC9 /* SmartCrashReportsInstall.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; name = SmartCrashReportsInstall.o; path = source/com/unsanity/smartcrashreports/SmartCrashReportsInstall.o; sourceTree = "<group>"; };
4764B47D08B7835E00441096 /* SKWSegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKWSegmentedControl.m; sourceTree = "<group>"; };
4764B47E08B7835E00441096 /* SKWSegmentedControlWindowProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKWSegmentedControlWindowProxy.m; sourceTree = "<group>"; };
4764B47F08B7835E00441096 /* SKWSegmentedControlWindowProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKWSegmentedControlWindowProxy.h; sourceTree = "<group>"; };
@@ -1431,6 +1429,10 @@
buildActionMask = 2147483647;
files = (
471D2C5205A2505500675163 /* Cocoa.framework in Frameworks */,
47649E0908E563C500207DC9 /* Security.framework in Frameworks */,
47649E4508E563D000207DC9 /* CoreFoundation.framework in Frameworks */,
47649EDD08E563D600207DC9 /* Carbon.framework in Frameworks */,
4764A09C08E565EC00207DC9 /* SmartCrashReportsInstall.o in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1526,6 +1528,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
4764A09B08E565EC00207DC9 /* SmartCrashReportsInstall.o */,
47DC7F4308694B5A00B9DD7D /* DotMacKit.framework */,
4739F03D08569B5E00405FD3 /* Growl.framework */,
4739EFFB08569A8100405FD3 /* Keychain.framework */,
@@ -1536,7 +1539,6 @@
4725BE0A05D2E27000C7CCBD /* JavaVM.framework */,
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */,
29B97325FDCFA39411CA2CEA /* Foundation.framework */,
29B97324FDCFA39411CA2CEA /* AppKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -1762,10 +1764,6 @@
47685DD80759706B00C744E1 /* Local.java */,
475D187C0805E24B00166B8A /* Local.h */,
475D187B0805E24B00166B8A /* Local.m */,
475D189E0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.h */,
475D189F0805E2FD00166B8A /* NSString+CarbonFSSpecCreation.m */,
475D187E0805E24B00166B8A /* IconFamily.h */,
475D187D0805E24B00166B8A /* IconFamily.m */,
474152EB06C4F08A00AC0BD2 /* Login.java */,
47729074080D5957007126E4 /* Keychain.java */,
47983749072AD67800FA3CDB /* Keychain.h */,
@@ -1856,6 +1854,7 @@
4741532B06C4F08A00AC0BD2 /* com */ = {
isa = PBXGroup;
children = (
47649C8108E5614A00207DC9 /* unsanity */,
4741532C06C4F08A00AC0BD2 /* enterprisedt */,
4741533806C4F08A00AC0BD2 /* sshtools */,
);
@@ -2481,6 +2480,22 @@
name = bookmark;
sourceTree = "<group>";
};
47649C8108E5614A00207DC9 /* unsanity */ = {
isa = PBXGroup;
children = (
47649C8208E5614A00207DC9 /* smartcrashreports */,
);
path = unsanity;
sourceTree = "<group>";
};
47649C8208E5614A00207DC9 /* smartcrashreports */ = {
isa = PBXGroup;
children = (
47649C8308E5614A00207DC9 /* SmartCrashReportsInstall.h */,
);
path = smartcrashreports;
sourceTree = "<group>";
};
479815EA0728DCA000FA3CDB /* growl */ = {
isa = PBXGroup;
children = (
@@ -2736,6 +2751,7 @@
47494C4107EC6B4200B34D53 /* CDOutlineView.h in Headers */,
47494C4307EC6B4200B34D53 /* CDListView.h in Headers */,
47FD45330801EAEE00716715 /* UKPrefsPanel.h in Headers */,
47649C8508E5614A00207DC9 /* SmartCrashReportsInstall.h in Headers */,
4764B48308B7835E00441096 /* SKWSegmentedControlWindowProxy.h in Headers */,
4764B48408B7835E00441096 /* SKWSegmentedControl.h in Headers */,
);
@@ -2781,8 +2797,6 @@
buildActionMask = 2147483647;
files = (
4739EFB30856991200405FD3 /* Local.h in Headers */,
4739EFB40856991200405FD3 /* IconFamily.h in Headers */,
4739EFB50856991200405FD3 /* NSString+CarbonFSSpecCreation.h in Headers */,
470E56D608BE3E1F00BDF3CD /* TinAlias.h in Headers */,
470E56D708BE3E1F00BDF3CD /* TinFSFork.h in Headers */,
470E56D808BE3E1F00BDF3CD /* TinFSRefItem.h in Headers */,
@@ -3391,8 +3405,6 @@
buildActionMask = 2147483647;
files = (
4739EFB70856991200405FD3 /* Local.m in Sources */,
4739EFB80856991200405FD3 /* NSString+CarbonFSSpecCreation.m in Sources */,
4739EFB90856991200405FD3 /* IconFamily.m in Sources */,
470E56D508BE3E1E00BDF3CD /* MacOSXForkerIO.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -4232,7 +4244,10 @@
4716D8B70877533B00938886 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = ppc;
ARCHS = (
ppc,
i386,
);
COPY_PHASE_STRIP = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -4398,10 +4413,7 @@
47D286C70855740C008142CF /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
ARCHS = ppc;
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = "\"$(SRCROOT)/build\"";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
@@ -4412,7 +4424,7 @@
JAVA_COMPILER_TARGET_VM_VERSION = 1.4;
MACOSX_DEPLOYMENT_TARGET = 10.3;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_LDFLAGS = "-lz";
OTHER_REZFLAGS = "";
PRODUCT_NAME = Cyberduck;
SECTORDER_FLAGS = "";
+1 -1
View File
@@ -10,7 +10,7 @@ CP=ditto --rsrc
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.4/Home
default:
# xcodebuild -project Spotlight\ Importer/Spotlight\ Importer.xcodeproj -target Spotlight\ Importer -configuration $(BUILDSTYLE)
xcodebuild -project Spotlight\ Importer/Spotlight\ Importer.xcodeproj -target Spotlight\ Importer -configuration $(BUILDSTYLE)
# xcodebuild -project Upload\ Automator\ Action/Upload\ Automator\ Action.xcodeproj -target Upload\ files -configuration $(BUILDSTYLE)
# xcodebuild -project Download\ Automator\ Action/Download\ Automator\ Action.xcodeproj -target Download\ files -configuration $(BUILDSTYLE)
xcodebuild -project $(PROJECT) -target build -configuration $(BUILDSTYLE)
+3 -2
View File
@@ -1,5 +1,5 @@
[WORK_IN_PROGRESS] Automator Actions
[WORK_IN_PROGRESS] SSH shell access (using Send Command...)
[2.6] Automator Actions
[2.6] SSH shell access (using Send Command...)
[????] Group bookmarks (Outline View)
[????] Calculate folder sizes
[????] Selecting remote server timezone in synchronization dialog
@@ -21,3 +21,4 @@
[????] Replace FTP api com.enterprisedt with org.apache.commons.net.ftp
[????] Exclusion lists for synchronization (e.g. skip CVS dirs)
[????] Outline view in synchronization dialog
[????] Transfer throttling
+1 -1
View File
@@ -1,2 +1,2 @@
cyberduck.version.major=2
cyberduck.version.minor=5
cyberduck.version.minor=5.1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+11 -3
View File
@@ -99,13 +99,21 @@ index() {
for lproj in `ls . | grep lproj`; do
language=$lproj;
echo "*** Indexing Help of $language Localization...";
/Developer/Applications/Utilities/Help\ Indexer.app/Contents/MacOS/Help\ Indexer $language/Cyberduck\ Help/ -ShowProgress YES -RemoteRoot http://cyberduck.ch/help/`basename $language .lproj`/ -PreferNetworkFiles YES -TigerIndexing YES
cp -R $language/Cyberduck\ Help/ $language/Cyberduck\ Help.bak/
find $language/Cyberduck\ Help/ -type d -name CVS -print0 | xargs -0 rm -rf
/Developer/Applications/Utilities/Help\ Indexer.app/Contents/MacOS/Help\ Indexer $language/Cyberduck\ Help/ -PantherIndexing YES -ShowProgress YES -RemoteRoot http://cyberduck.ch/help/`basename $language .lproj`/ -PreferNetworkFiles YES -TigerIndexing YES
mv $language/Cyberduck\ Help.bak/CVS $language/Cyberduck\ Help/
rm -rf $language/Cyberduck\ Help.bak/
done;
}
else
{
echo "*** Status of $language Localization...";
/Developer/Applications/Utilities/Help\ Indexer.app/Contents/MacOS/Help\ Indexer $language/Cyberduck\ Help/ -ShowProgress YES -RemoteRoot http://cyberduck.ch/help/`basename $language .lproj`/ -PreferNetworkFiles YES -TigerIndexing YES
echo "*** Indexing Help of $language Localization...";
cp -R $language/Cyberduck\ Help/ $language/Cyberduck\ Help.bak/
find $language/Cyberduck\ Help/ -type d -name CVS -print0 | xargs -0 rm -rf
/Developer/Applications/Utilities/Help\ Indexer.app/Contents/MacOS/Help\ Indexer $language/Cyberduck\ Help/ -PantherIndexing YES -ShowProgress YES -RemoteRoot http://cyberduck.ch/help/`basename $language .lproj`/ -PreferNetworkFiles YES -TigerIndexing YES
mv $language/Cyberduck\ Help.bak/CVS $language/Cyberduck\ Help/
rm -rf $language/Cyberduck\ Help.bak/
}
fi;
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4 -1
View File
@@ -23,5 +23,8 @@
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
if (UnsanitySCR_CanInstall(FALSE)) {
UnsanitySCR_Install(FALSE);
}
return NSApplicationMain(argc, (const char **) argv);
}
+1 -1
View File
@@ -47,7 +47,7 @@ public class AttributedList implements List {
protected static final String HIDDEN = "HIDDEN";
//file listing has changed
protected static final String INVALID = "INVALID";
public static final String INVALID = "INVALID";
private Attributes attributes;
+4 -6
View File
@@ -38,7 +38,9 @@ public class Cache extends HashMap {
}
public void invalidate(Path path) {
this.get(path).getAttributes().put(AttributedList.INVALID, Boolean.TRUE);
if(this.containsKey(path)) {
this.get(path).getAttributes().put(AttributedList.INVALID, Boolean.TRUE);
}
}
/**
@@ -46,7 +48,7 @@ public class Cache extends HashMap {
* @return true if the file listing of the given path has been changed since caching
*/
public boolean isInvalid(Path path) {
if(this.exists(path)) {
if(this.containsKey(path)) {
return this.get(path).getAttributes().get(AttributedList.INVALID).equals(Boolean.TRUE);
}
return false;
@@ -61,10 +63,6 @@ public class Cache extends HashMap {
return (AttributedList)super.get(path.getAbsolute());
}
public boolean exists(Path path) {
return this.get(path) != null;
}
/**
*
* @param path
+3 -2
View File
@@ -319,7 +319,7 @@ public class Host {
}
public void setCredentials(String username, String password, boolean addToKeychain) {
this.setCredentials(new Login(this, username, password, addToKeychain));
this.setCredentials(new Login(this.getHostname(), this.getProtocol(), username, password, addToKeychain));
}
public Login getCredentials() {
@@ -377,8 +377,9 @@ public class Host {
*/
public void setPort(int port) {
this.port = port;
if(-1 == port)
if(-1 == port) {
port = Host.getDefaultPort(this.getProtocol());
}
}
public int getPort() {
-183
View File
@@ -1,183 +0,0 @@
// IconFamily.h
// IconFamily class interface
// by Troy Stephens, Thomas Schnitzer, David Remahl, Nathan Day and Ben Haller
// version 0.5.1
//
// Project Home Page:
// http://homepage.mac.com/troy_stephens/software/objects/IconFamily/
//
// Problems, shortcomings, and uncertainties that I'm aware of are flagged
// with "NOTE:". Please address bug reports, bug fixes, suggestions, etc.
// to me at troy_stephens@mac.com
//
// This code is provided as-is, with no warranty, in the hope that it will be
// useful. However, it appears to work fine on Mac OS X 10.1.4. :-)
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
// This class is a Cocoa/Objective-C wrapper for the Mac OS X Carbon API's
// "icon family" data type. Its main purpose is to enable Cocoa applications
// to easily create custom file icons from NSImage instances, and thus take
// advantage of Mac OS X's new 128x128 RGBA "thumbnail" icon format to provide
// richly detailed thumbnail previews of the files' contents.
//
// Using IconFamily, this becomes as simple as:
//
// id iconFamily = [IconFamily iconFamilyWithThumbnailsOfImage:anImage];
// [iconFamily setAsCustomIconForFile:anExistingFile];
//
// You can also write an icon family to an .icns file using the -writeToFile:
// method.
@interface IconFamily : NSObject
{
IconFamilyHandle hIconFamily;
}
// Convenience methods. These use the corresponding -init methods to return
// an autoreleased IconFamily instance.
//
// NOTE: +iconFamily relies on -init, which is currently broken (see -init).
+ (IconFamily*) iconFamily;
+ (IconFamily*) iconFamilyWithContentsOfFile:(NSString*)path;
+ (IconFamily*) iconFamilyWithIconOfFile:(NSString*)path;
+ (IconFamily*) iconFamilyWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
+ (IconFamily*) iconFamilyWithSystemIcon:(int)fourByteCode;
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image;
+ (IconFamily*) iconFamilyWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
// Initializes as a new, empty IconFamily. This is IconFamily's designated
// initializer method.
//
// NOTE: This method is broken until we figure out how to create a valid new
// IconFamilyHandle! In the meantime, use -initWithContentsOfFile: to
// load an existing .icns file that you can use as a starting point, and
// use -setIconFamilyElement:fromBitmapImageRep: to replace its
// elements. This is what the "MakeThumbnail" demo app does.
- init;
// Initializes an IconFamily by loading the contents of an .icns file.
- initWithContentsOfFile:(NSString*)path;
// Initializes an IconFamily from an existing Carbon IconFamilyHandle.
- initWithIconFamilyHandle:(IconFamilyHandle)hNewIconFamily;
// Initializes an IconFamily by loading the Finder icon that's assigned to a
// file.
- initWithIconOfFile:(NSString*)path;
// Initializes an IconFamily by referencing a standard system icon.
- initWithSystemIcon:(int)fourByteCode;
// Initializes an IconFamily by creating its elements from a resampled
// NSImage. The second form of this method allows you to specify the degree
// of antialiasing to be used in resampling the image, by passing in one of
// the NSImageInterpolation... constants that are defined in
// NSGraphicsContext.h. The first form of this initializer simply calls the
// second form with imageInterpolation set to NSImageInterpolationHigh, which
// produces highly smoothed thumbnails.
- initWithThumbnailsOfImage:(NSImage*)image;
- initWithThumbnailsOfImage:(NSImage*)image usingImageInterpolation:(NSImageInterpolation)imageInterpolation;
// Writes the icon family to an .icns file.
- (BOOL) writeToFile:(NSString*)path;
// Sets the image data for one of the icon family's elements from an
// NSBitmapImageRep. The "elementType" parameter must be one of the icon
// family element types listed below, and the format of the "bitmapImageRep"
// must match the corresponding requirements specified below. Regardless of
// the elementType, the bitmapImageRep must also be non-planar and have 8 bits
// per sample.
//
// elementType dimensions format
// ------------------- ---------- ---------------------------------------
// kThumbnail32BitData 128 x 128 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kThumbnail8BitMask 128 x 128 32-bit RGBA or 8-bit intensity
// kLarge32BitData 32 x 32 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kLarge8BitMask 32 x 32 32-bit RGBA or 8-bit intensity
// kLarge1BitMask 32 x 32 32-bit RGBA, 8-bit intensity, or 1-bit
// kSmall32BitData 16 x 16 32-bit RGBA, 32-bit RGB, or 24-bit RGB
// kSmall8BitMask 16 x 16 32-bit RGBA or 8-bit intensity
// kSmall1BitMask 16 x 16 32-bit RGBA, 8-bit intensity, or 1-bit
//
// When an RGBA image is supplied to set a "Mask" element, the mask data is
// taken from the image's alpha channel.
//
// NOTE: Setting an IconFamily's kLarge1BitMask seems to damage the IconFamily
// for some as yet unknown reason. (If you then assign the icon family
// as a file's custom icon using -setAsCustomIconForFile:, the custom
// icon doesn't appear for the file in the Finder.) However, both
// custom icon display and mouse-click hit-testing in the Finder seem to
// work fine when we only set the other four elements (thus keeping the
// existing kLarge1BitMask from the valid icon family from which we
// initialized the IconFamily via -initWithContentsOfFile:, since
// IconFamily's -init method is currently broken...), so it seems safe
// to just leave the kLarge1BitMask alone.
- (BOOL) setIconFamilyElement:(OSType)elementType
fromBitmapImageRep:(NSBitmapImageRep*)bitmapImageRep;
// Gets the image data for one of the icon family's elements as a new, 32-bit
// RGBA NSBitmapImageRep. The specified elementType should be one of
// kThumbnail32BitData, kLarge32BitData, or kSmall32BitData.
//
// The returned NSBitmapImageRep will have the corresponding 8-bit mask data
// in its alpha channel, or a fully opaque alpha channel if the icon family
// has no 8-bit mask data for the specified alpha channel.
//
// Returns nil if the requested element cannot be retrieved (e.g. if the
// icon family has no such 32BitData element).
- (NSBitmapImageRep*) bitmapImageRepWithAlphaForIconFamilyElement:(OSType)elementType;
// Creates and returns an NSImage that contains the icon family's various
// elements as its NSImageReps.
- (NSImage*) imageWithAllReps;
// NOTE: Planned method -- not yet implemented.
//
// Gets the image data for one of the icon family's elements as a new
// NSBitmapImageRep. The specified elementType should be one of
// kThumbnail32BitData, kThumbnail32BitMask, kLarge32BitData, kLarge8BitMask,
// kLarge1BitMask, kSmall32BitData, kSmall8BitMask, or kSmall1BitMask.
// - (NSBitmapImageRep*) bitmapImageRepForIconFamilyElement:(OSType)elementType;
// Writes the icon family to the resource fork of the specified file as its
// kCustomIconResource, and sets the necessary Finder bits so the icon will
// be displayed for the file in Finder views.
- (BOOL) setAsCustomIconForFile:(NSString*)path;
- (BOOL) setAsCustomIconForFile:(NSString*)path withCompatibility:(BOOL)compat;
// Same as the -setAsCustomIconForFile:... methods, but for folders (directories).
- (BOOL) setAsCustomIconForDirectory:(NSString*)path;
- (BOOL) setAsCustomIconForDirectory:(NSString*)path withCompatibility:(BOOL)compat;
// Removes the custom icon (if any) from the specified file's resource fork,
// and clears the necessary Finder bits for the file. (Note that this is a
// class method, so you don't need an instance of IconFamily to invoke it.)
+ (BOOL) removeCustomIconFromFile:(NSString*)path;
@end
// Methods for interfacing with the Carbon Scrap Manager (analogous to and
// interoperable with the Cocoa Pasteboard).
@interface IconFamily (ScrapAdditions)
+ (BOOL) canInitWithScrap;
+ (IconFamily*) iconFamilyWithScrap;
- initWithScrap;
- (BOOL) putOnScrap;
@end
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -16,7 +16,7 @@ extern "C" {
* Signature: (Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Keychain_getInternetPasswordFromKeychain
(JNIEnv *, jobject, jstring, jstring, jint, jstring);
(JNIEnv *, jobject, jstring, jstring, jstring);
/*
* Class: ch_cyberduck_core_Keychain
@@ -40,7 +40,7 @@ JNIEXPORT void JNICALL Java_ch_cyberduck_core_Keychain_addPasswordToKeychain
* Signature: (Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_ch_cyberduck_core_Keychain_addInternetPasswordToKeychain
(JNIEnv *, jobject, jstring, jstring, jint, jstring, jstring);
(JNIEnv *, jobject, jstring, jstring, jstring, jstring);
/*
* Class: ch_cyberduck_core_Keychain
+2 -2
View File
@@ -54,13 +54,13 @@ public class Keychain {
}
}
public native String getInternetPasswordFromKeychain(String protocol, String serviceName, int port, String user);
public native String getInternetPasswordFromKeychain(String protocol, String serviceName, String user);
public native String getPasswordFromKeychain(String serviceName, String user);
public native void addPasswordToKeychain(String serviceName, String user, String password);
public native void addInternetPasswordToKeychain(String protocol, String serviceName, int port, String user, String password);
public native void addInternetPasswordToKeychain(String protocol, String serviceName, String user, String password);
public native boolean hasCertificate(byte[] certificate);
+4 -4
View File
@@ -38,13 +38,13 @@ NSString *convertToNSString(JNIEnv *env, jstring javaString)
return converted;
}
JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Keychain_getInternetPasswordFromKeychain(JNIEnv *env, jobject this, jstring jProtocol, jstring jService,jint jPort,jstring jAccount) {
JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Keychain_getInternetPasswordFromKeychain(JNIEnv *env, jobject this, jstring jProtocol, jstring jService,jstring jAccount) {
SecProtocolType protocol;
const char *protocolString = (*env)->GetStringUTFChars(env, jProtocol, JNI_FALSE);
memcpy(&protocol, protocolString, 4);
NSString *password = [[Keychain defaultKeychain] passwordForInternetServer:convertToNSString(env, jService) forAccount:convertToNSString(env, jAccount) port:(UInt16)jPort path:@"" inSecurityDomain:@"" protocol:protocol auth:kSecAuthenticationTypeDefault];
NSString *password = [[Keychain defaultKeychain] passwordForInternetServer:convertToNSString(env, jService) forAccount:convertToNSString(env, jAccount) port:0 path:@"" inSecurityDomain:@"" protocol:protocol auth:kSecAuthenticationTypeDefault];
return (*env)->NewStringUTF(env, [password UTF8String]);
}
@@ -56,14 +56,14 @@ JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Keychain_getPasswordFromKeychai
return (*env)->NewStringUTF(env, [password UTF8String]);
}
JNIEXPORT void JNICALL Java_ch_cyberduck_core_Keychain_addInternetPasswordToKeychain(JNIEnv *env, jobject this, jstring jProtocol,jstring jService,jint jPort,jstring jUsername, jstring jPassword
JNIEXPORT void JNICALL Java_ch_cyberduck_core_Keychain_addInternetPasswordToKeychain(JNIEnv *env, jobject this, jstring jProtocol,jstring jService,jstring jUsername, jstring jPassword
)
{
SecProtocolType protocol;
const char *protocolString = (*env)->GetStringUTFChars(env, jProtocol, JNI_FALSE);
memcpy(&protocol, protocolString, 4);
[[Keychain defaultKeychain] addInternetPassword:convertToNSString(env, jPassword) onServer:convertToNSString(env, jService) forAccount:convertToNSString(env, jUsername) port:(UInt16)jPort path:@"" inSecurityDomain:@"" protocol:protocol auth:kSecAuthenticationTypeDefault replaceExisting:YES];
[[Keychain defaultKeychain] addInternetPassword:convertToNSString(env, jPassword) onServer:convertToNSString(env, jService) forAccount:convertToNSString(env, jUsername) port:0 path:@"" inSecurityDomain:@"" protocol:protocol auth:kSecAuthenticationTypeDefault replaceExisting:YES];
}
JNIEXPORT void JNICALL Java_ch_cyberduck_core_Keychain_addPasswordToKeychain(JNIEnv *env, jobject this, jstring jService, jstring jUsername, jstring jPass)
-7
View File
@@ -83,7 +83,6 @@ public class Local extends File {
public void setProgress(int progress) {
if(Preferences.instance().getBoolean("queue.download.updateIcon")) {
if(-1 == progress) {
this.removeCustomIcon();
this.removeResourceFork();
}
else {
@@ -113,12 +112,6 @@ public class Local extends File {
*/
public native void setIconFromFile(String path, String icon);
public void removeCustomIcon() {
this.removeCustomIcon(this.getAbsolute());
}
public native void removeCustomIcon(String path);
public Permission getPermission() {
NSDictionary fileAttributes = NSPathUtilities.fileAttributes(this.getAbsolutePath(), true);
return new Permission(((Integer)fileAttributes.objectForKey(NSPathUtilities.FilePosixPermissions)).intValue());
-20
View File
@@ -22,7 +22,6 @@
#import <Carbon/Carbon.h>
#import <CoreServices/CoreServices.h>
#import <Cocoa/Cocoa.h>
#import <IconFamily.h>
// Simple utility to convert java strings to NSStrings
NSString *convertToNSString(JNIEnv *env, jstring javaString)
@@ -52,10 +51,6 @@ JNIEXPORT void JNICALL Java_ch_cyberduck_core_Local_setIconFromExtension(JNIEnv
if([workspace respondsToSelector:@selector(setIcon:forFile:options:)]) {
[workspace setIcon:image forFile:convertToNSString(env, path) options:NSExcludeQuickDrawElementsIconCreationOption];
}
else {
id iconFamily = [IconFamily iconFamilyWithThumbnailsOfImage:image];
[iconFamily setAsCustomIconForFile:convertToNSString(env, path)];
}
[pool release];
}
@@ -66,20 +61,5 @@ JNIEXPORT void JNICALL Java_ch_cyberduck_core_Local_setIconFromFile(JNIEnv *env,
if([workspace respondsToSelector:@selector(setIcon:forFile:options:)]) {
[workspace setIcon:[NSImage imageNamed:convertToNSString(env, icon)] forFile:convertToNSString(env, path) options:NSExcludeQuickDrawElementsIconCreationOption];
}
else {
id iconFamily = [IconFamily iconFamilyWithThumbnailsOfImage:[NSImage imageNamed:convertToNSString(env, icon)]];
[iconFamily setAsCustomIconForFile:convertToNSString(env, path)];
}
[pool release];
}
JNIEXPORT void JNICALL Java_ch_cyberduck_core_Local_removeCustomIcon(JNIEnv *env, jobject this, jstring path)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[IconFamily removeCustomIconFromFile:convertToNSString(env, path)];
[pool release];
}
+10 -24
View File
@@ -33,7 +33,6 @@ public class Login {
private String serviceName;
private String protocol;
private int port;
private String user;
private transient String pass;
private String privateKeyFile;
@@ -56,27 +55,18 @@ public class Login {
public String getInternetPasswordFromKeychain() {
int pool = NSAutoreleasePool.push();
log.info("Fetching password from Keychain for:"+this.getUsername());
String password = Keychain.instance().getInternetPasswordFromKeychain(this.protocol,
this.serviceName, this.port, this.getUsername());
this.serviceName, this.getUsername());
NSAutoreleasePool.pop(pool);
return password;
}
public void addInternetPasswordToKeychain() {
if(this.shouldBeAddedToKeychain && !this.isAnonymousLogin()) {
int pool = NSAutoreleasePool.push();
Keychain.instance().addInternetPasswordToKeychain(this.protocol,
this.serviceName, this.port, this.getUsername(), this.getPassword());
NSAutoreleasePool.pop(pool);
}
}
public void addPasswordToKeychain() {
if(this.shouldBeAddedToKeychain && !this.isAnonymousLogin()) {
int pool = NSAutoreleasePool.push();
Keychain.instance().addPasswordToKeychain(this.serviceName, this.getUsername(), this.getPassword());
this.serviceName, this.getUsername(), this.getPassword());
NSAutoreleasePool.pop(pool);
}
}
@@ -89,27 +79,23 @@ public class Login {
}
/**
* @param h The service to use when looking up the password in the keychain
* @param hostname The service to use when looking up the password in the keychain
* @param user Login with this username
* @param pass Passphrase
*/
public Login(Host h, String user, String pass) {
this(h,
user,
pass,
false);
public Login(String hostname, String protocol, String user, String pass) {
this(hostname, protocol, user, pass, false);
}
/**
* @param h The serviceName to use when looking up the password in the keychain
* @param hostname The serviceName to use when looking up the password in the keychain
* @param user Login with this username
* @param pass Passphrase
* @param shouldBeAddedToKeychain if the credential should be added to the keychain uppon successful login
*/
public Login(Host h, String user, String pass, boolean shouldBeAddedToKeychain) {
this.serviceName = h.getHostname();
this.protocol = h.getProtocol();
this.port = h.getPort();
public Login(String hostname, String protocol, String user, String pass, boolean shouldBeAddedToKeychain) {
this.serviceName = hostname;
this.protocol = protocol;
this.shouldBeAddedToKeychain = shouldBeAddedToKeychain;
this.init(user, pass);
}
@@ -1,20 +0,0 @@
#import <Foundation/Foundation.h>
#import <Carbon/Carbon.h>
@interface NSString (CarbonFSSpecCreation)
// Fills in the given FSRef struct so it specifies the file whose path is in this string.
// If the file doesn't exist, and "createFile" is YES, this method will attempt to create
// an empty file with the specified path. (The caller should insure that the directory
// the file is to be placed in already exists.)
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile;
// Fills in the given FSSpec struct so it specifies the file whose path is in this string.
// If the file doesn't exist, and "createFile" is YES, this method will attempt to create
// an empty file with the specified path. (The caller should insure that the directory
// the file is to be placed in already exists.)
- (BOOL) getFSSpec:(FSSpec*)fsSpec createFileIfNecessary:(BOOL)createFile;
@end
@@ -1,66 +0,0 @@
#import "NSString+CarbonFSSpecCreation.h"
@implementation NSString (CarbonFSSpecCreation)
- (BOOL) getFSRef:(FSRef*)fsRef createFileIfNecessary:(BOOL)createFile
{
NSFileManager* fileManager = [NSFileManager defaultManager];
CFURLRef urlRef;
Boolean gotFSRef;
// Check whether the file exists already. If not, create an empty file if requested.
if (![fileManager fileExistsAtPath:self]) {
if (createFile) {
if (![@"" writeToFile:self atomically:YES]) {
return NO;
}
} else {
return NO;
}
}
// Create a CFURL with the specified POSIX path.
urlRef = CFURLCreateWithFileSystemPath( kCFAllocatorDefault,
(CFStringRef) self,
kCFURLPOSIXPathStyle,
FALSE /* isDirectory */ );
if (urlRef == NULL) {
// printf( "** Couldn't make a CFURLRef for the file.\n" );
return NO;
}
// Try to create an FSRef from the URL. (If the specified file doesn't exist, this
// function will return false, but if we've reached this code we've already insured
// that the file exists.)
gotFSRef = CFURLGetFSRef( urlRef, fsRef );
CFRelease( urlRef );
if (!gotFSRef) {
// printf( "** Couldn't get an FSRef for the file.\n" );
return NO;
}
return YES;
}
- (BOOL) getFSSpec:(FSSpec*)fsSpec createFileIfNecessary:(BOOL)createFile
{
FSRef fsRef;
if (![self getFSRef:&fsRef createFileIfNecessary:createFile])
return NO;
if (FSGetCatalogInfo( &fsRef,
kFSCatInfoNone,
NULL,
NULL,
fsSpec,
NULL ) != noErr) {
// printf( "** Couldn't get an FSSpec for the file.\n" );
return NO;
}
return YES;
}
@end
+6 -4
View File
@@ -47,6 +47,8 @@ public abstract class Path {
public static final int DIRECTORY_TYPE = 2;
public static final int SYMBOLIC_LINK_TYPE = 4;
public static final String DELIMITER = "/";
protected void finalize() throws Throwable {
log.debug("finalize > "+this.toString());
super.finalize();
@@ -141,7 +143,7 @@ public abstract class Path {
this.setPath(parent+name);
}
else {
this.setPath(parent+"/"+name);
this.setPath(parent+DELIMITER+name);
}
}
@@ -174,7 +176,7 @@ public abstract class Path {
this.parent.attributes.setType(Path.DIRECTORY_TYPE);
}
else {//if (index == 0) //parent is root
this.parent = PathFactory.createPath(this.getSession(), "/");
this.parent = PathFactory.createPath(this.getSession(), DELIMITER);
this.parent.attributes.setType(Path.DIRECTORY_TYPE);
}
}
@@ -253,7 +255,7 @@ public abstract class Path {
* @return true if this paths points to '/'
*/
public boolean isRoot() {
return this.getAbsolute().equals("/") || this.getAbsolute().indexOf('/') == -1;
return this.getAbsolute().equals(DELIMITER) || this.getAbsolute().indexOf('/') == -1;
}
/**
@@ -261,7 +263,7 @@ public abstract class Path {
*/
public String getName() {
if(this.isRoot()) {
return "/";
return DELIMITER;
}
String abs = this.getAbsolute();
int index = abs.lastIndexOf('/');
+3 -1
View File
@@ -109,7 +109,9 @@ public abstract class Preferences {
defaults.put("browser.charset.encoding", "UTF-8");
defaults.put("browser.doubleclick.edit", "false");
defaults.put("editor.name", "SubEthaEdit");
defaults.put("browser.closeDrawer", "false");
defaults.put("editor.name", "SubEthaEdit");
defaults.put("editor.bundleIdentifier", "de.codingmonkeys.SubEthaEdit");
defaults.put("editor.disabledFiles", "pdf ps exe bin jpeg jpg jp2 gif tif ico icns tiff bmp pict sgi tga png psd " +
"hqx sea dmg zip sit tar gz tgz bz2 avi qtl bom pax pgp" +
-12
View File
@@ -46,17 +46,5 @@ public class Proxy {
public static native int getSOCKSProxyPort();
public static boolean isSOCKSAuthenticationEnabled() {
Login l = new Login(new Host("socks", getSOCKSProxyHost(), getSOCKSProxyPort()),
getSOCKSProxyUser(), null);
return l.getInternetPasswordFromKeychain() != null;
}
public static native String getSOCKSProxyUser();
public static String getSOCKSProxyPassword() {
Login l = new Login(new Host("socks", getSOCKSProxyHost(), getSOCKSProxyPort()),
getSOCKSProxyUser(), null);
return l.getInternetPasswordFromKeychain();
};
}
+9 -18
View File
@@ -37,52 +37,43 @@ JNIEXPORT jboolean JNICALL Java_ch_cyberduck_core_Proxy_isSOCKSProxyEnabled(JNIE
JNIEXPORT jint JNICALL Java_ch_cyberduck_core_Proxy_getSOCKSProxyPort(JNIEnv *env,
jobject this)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSNumber *port = [Proxy getSOCKSProxyPort];
[pool release];
return [port intValue];
return [[Proxy getSOCKSProxyPort] intValue];
}
JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Proxy_getSOCKSProxyHost(JNIEnv *env,
jobject this)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString * host = [Proxy getSOCKSProxyHost];
[pool release];
return convertToJString(env, host);
return convertToJString(env, [Proxy getSOCKSProxyHost]);
}
JNIEXPORT jstring JNICALL Java_ch_cyberduck_core_Proxy_getSOCKSProxyUser(JNIEnv *env,
jobject this) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *user = [Proxy getSOCKSProxyUser];
[pool release];
return convertToJString(env, user);
return convertToJString(env, [Proxy getSOCKSProxyUser]);
}
@implementation Proxy
//+ (BOOL)usePassiveFTP
//{
// NSDictionary *proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
// return [[proxies objectForKey:(NSString *)kSCPropNetProxiesFTPPassive] boolValue];
//}
+ (BOOL)isSOCKSProxyEnabled
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
[pool release];
return [[proxies objectForKey:(NSString *)kSCPropNetProxiesSOCKSEnable] boolValue];
}
+ (NSString *)getSOCKSProxyHost
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
[pool release];
return [proxies objectForKey:(NSString *)kSCPropNetProxiesSOCKSProxy];
}
+ (NSNumber *)getSOCKSProxyPort
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSDictionary *proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
[pool release];
return [proxies objectForKey:(NSNumber *)kSCPropNetProxiesSOCKSPort];
}
+2 -2
View File
@@ -119,7 +119,7 @@ public class FTPPath extends Path {
if (notifyObservers) {
session.addPathToHistory(this);
}
if (refresh || !session.cache().exists(this) || session.cache().isInvalid(this)) {
if (refresh || !session.cache().containsKey(this) || session.cache().isInvalid(this)) {
AttributedList files;
if(session.cache().isInvalid(this)) {
files = new AttributedList(session.cache().get(this).getAttributes());
@@ -265,7 +265,7 @@ public class FTPPath extends Path {
session.log(Message.PROGRESS, NSBundle.localizedString("Deleting", "Status", "")+" "+this.getName());
session.FTP.delete(this.getName());
}
else if (this.attributes.isDirectory()) {
else if (this.attributes.isDirectory() && !this.attributes.isSymbolicLink()) {
List files = this.list(true, false);
if(files != null) {
java.util.Iterator iterator = files.iterator();
+4 -7
View File
@@ -117,14 +117,11 @@ public class FTPSession extends Session {
this.FTP.setStrictReturnCodes(true);
if (Proxy.isSOCKSProxyEnabled()) {
log.info("Using SOCKS Proxy");
FTPClient.initSOCKS(Proxy.getSOCKSProxyPort(),
Proxy.getSOCKSProxyHost());
if (Proxy.isSOCKSAuthenticationEnabled()) {
log.info("Using SOCKS Proxy Authentication");
FTPClient.initSOCKSAuthentication(Proxy.getSOCKSProxyUser(),
Proxy.getSOCKSProxyPassword());
}
FTPClient.initSOCKS(Proxy.getSOCKSProxyPort(), Proxy.getSOCKSProxyHost());
}
else {
FTPClient.clearSOCKS();
}
this.FTP.setConnectMode(this.host.getFTPConnectMode());
this.log(Message.PROGRESS, NSBundle.localizedString("FTP connection opened", "Status", ""));
this.login();
@@ -88,14 +88,11 @@ public class FTPSSession extends FTPSession {
this.FTP.setStrictReturnCodes(true);
if (Proxy.isSOCKSProxyEnabled()) {
log.info("Using SOCKS Proxy");
FTPClient.initSOCKS(Proxy.getSOCKSProxyPort(),
Proxy.getSOCKSProxyHost());
if (Proxy.isSOCKSAuthenticationEnabled()) {
log.info("Using SOCKS Proxy Authentication");
FTPClient.initSOCKSAuthentication(Proxy.getSOCKSProxyUser(),
Proxy.getSOCKSProxyPassword());
}
FTPClient.initSOCKS(Proxy.getSOCKSProxyPort(), Proxy.getSOCKSProxyHost());
}
else {
FTPClient.clearSOCKS();
}
this.FTP.setConnectMode(this.host.getFTPConnectMode());
this.log(Message.PROGRESS, NSBundle.localizedString("FTP connection opened", "Status", ""));
((FTPSClient) this.FTP).auth();
+8 -4
View File
@@ -19,11 +19,14 @@ package ch.cyberduck.core.sftp;
*/
import ch.cyberduck.core.*;
import com.apple.cocoa.foundation.NSBundle;
import com.apple.cocoa.foundation.NSDictionary;
import com.sshtools.j2ssh.SshException;
import com.sshtools.j2ssh.io.UnsignedInteger32;
import com.sshtools.j2ssh.sftp.*;
import org.apache.log4j.Logger;
import java.io.*;
@@ -99,7 +102,7 @@ public class SFTPPath extends Path {
if(notifyObservers) {
session.addPathToHistory(this);
}
if (refresh || !session.cache().exists(this) || session.cache().isInvalid(this)) {
if (refresh || !session.cache().containsKey(this) || session.cache().isInvalid(this)) {
AttributedList files = null;
if(session.cache().isInvalid(this)) {
files = new AttributedList(session.cache().get(this).getAttributes());
@@ -254,7 +257,7 @@ public class SFTPPath extends Path {
session.log(Message.PROGRESS, NSBundle.localizedString("Deleting", "Status", "")+" "+this.getName());
session.SFTP.removeFile(this.getAbsolute());
}
else if(this.attributes.isDirectory()) {
else if (this.attributes.isDirectory() && !this.attributes.isSymbolicLink()) {
List files = this.list(true, false);
if(files != null) {
java.util.Iterator iterator = files.iterator();
@@ -481,6 +484,7 @@ public class SFTPPath extends Path {
if(in == null) {
throw new IOException("Unable to buffer data");
}
boolean exists = this.exists();
SftpFile f = null;
if(this.status.isResume()) {
f = session.SFTP.openFile(this.getAbsolute(),
@@ -493,7 +497,7 @@ public class SFTPPath extends Path {
SftpSubsystemClient.OPEN_WRITE | //File open flag, opens the file for writing.
SftpSubsystemClient.OPEN_TRUNCATE); //File open flag, forces an existing file with the same name to be truncated to zero length when creating a file by specifying OPEN_CREATE.
}
if(Preferences.instance().getBoolean("queue.upload.changePermissions")) {
if(!exists && Preferences.instance().getBoolean("queue.upload.changePermissions")) {
Permission perm = null;
if(Preferences.instance().getBoolean("queue.upload.permissions.useDefault")) {
perm = new Permission(Preferences.instance().getProperty("queue.upload.permissions.default"));
@@ -520,7 +524,7 @@ public class SFTPPath extends Path {
}
}
this.upload(out, in);
if(Preferences.instance().getBoolean("queue.upload.preserveDate")) {
if(!exists && Preferences.instance().getBoolean("queue.upload.preserveDate")) {
FileAttributes attrs = new FileAttributes();
attrs.setTimes(f.getAttributes().getAccessedTime(),
new UnsignedInteger32(this.getLocal().getTimestamp().getTime()/1000));
@@ -162,13 +162,9 @@ public class SFTPSession extends Session {
properties.setPrefCSComp(Preferences.instance().getProperty("ssh.compression"));
if(Proxy.isSOCKSProxyEnabled()) {
log.info("Using SOCKS Proxy");
properties.setTransportProvider(SshConnectionProperties.USE_SOCKS5_PROXY); //todo V4?
properties.setTransportProvider(SshConnectionProperties.USE_SOCKS4_PROXY);
properties.setProxyHost(Proxy.getSOCKSProxyHost());
properties.setProxyPort(Proxy.getSOCKSProxyPort());
if(Proxy.isSOCKSAuthenticationEnabled()) {
properties.setProxyUsername(Proxy.getSOCKSProxyUser());
properties.setProxyPassword(Proxy.getSOCKSProxyPassword());
}
}
SSH.connect(properties, this.getHostKeyVerificationController());
if(SSH.isConnected()) {
@@ -60,4 +60,4 @@ public class CDBookmarkCell extends CDTableCell {
new NSRect(cellFrame.origin().x(), cellFrame.origin().y()+27, cellFrame.size().width()-5, cellFrame.size().height()));
}
}
}
}
@@ -33,7 +33,6 @@ import ch.cyberduck.core.*;
* @version $Id$
*/
public class CDBookmarkTableDataSource extends Collection {
private static Logger log = Logger.getLogger(CDBookmarkTableDataSource.class);
private static final File BOOKMARKS_FILE_USER
@@ -68,22 +67,6 @@ public class CDBookmarkTableDataSource extends Collection {
return instance;
}
public void sort(NSTableColumn tableColumn, final boolean ascending) {
if (tableColumn.identifier().equals("BOOKMARK")) {
Collections.sort(this,
new Comparator() {
public int compare(Object o1, Object o2) {
Host h1 = (Host) o1;
Host h2 = (Host) o2;
if (ascending) {
return h1.getHostname().compareToIgnoreCase(h2.getHostname());
}
return -h1.getHostname().compareToIgnoreCase(h2.getHostname());
}
});
}
}
private static final NSImage DOCUMENT_ICON;
static {
+34 -23
View File
@@ -49,7 +49,7 @@ public class CDBrowserCell extends NSBrowserCell {
protected CDBrowserCell(NSCoder decoder, long token) {
super(decoder, token);
}
protected void encodeWithCoder(NSCoder encoder) {
super.encodeWithCoder(encoder);
}
@@ -80,8 +80,7 @@ public class CDBrowserCell extends NSBrowserCell {
public void setPath(Path path) {
this.path = path;
this.setLeaf(path.attributes.isFile());
//this.setEnabled(path.attributes.isReadable());
this.setAttributedStringValue(new NSAttributedString(this.path.getName(),
this.setAttributedStringValue(new NSAttributedString(this.path.getName(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
NSImage image;
if (path.attributes.isSymbolicLink()) {
@@ -100,37 +99,49 @@ public class CDBrowserCell extends NSBrowserCell {
this.setIcon(image);
}
protected static final float HEIGHT = 17f;
protected static final float HEIGHT = 19f;
public void drawWithFrameInView(NSRect cellFrame, NSView controlView) {
public void editWithFrameInView(NSRect rect, NSView controlView, NSText text, Object object, NSEvent event) {
if(controlView instanceof NSMatrix) {
((NSMatrix)controlView).sendAction();
}
super.editWithFrameInView(rect, controlView, text, object, event);
}
public void drawWithFrameInView(NSRect cellFrame, NSView controlView) {
super.drawWithFrameInView(new NSRect(cellFrame.x(), cellFrame.y(),
cellFrame.width(), CDBrowserCell.HEIGHT), controlView);
}
public void drawInteriorWithFrameInView(NSRect cellFrame, NSView controlView) {
if(this.icon() != null) {
cellFrame = new NSRect(cellFrame.x(), cellFrame.y(),
cellFrame.width(), CDBrowserCell.HEIGHT);
NSRect iconRect = new NSRect(cellFrame.x(),
cellFrame.y(),
this.icon().size().width()+4,
CDBrowserCell.HEIGHT);
NSRect textRect = new NSRect(cellFrame.x()+2+this.icon().size().width()+2,
cellFrame.y(),
cellFrame.width()-2-this.icon().size().width()-2,
CDBrowserCell.HEIGHT);
if(controlView.isFlipped())
this.icon().compositeToPoint(new NSPoint(iconRect.x()+2,
cellFrame = new NSRect(cellFrame.x(), cellFrame.y(),
cellFrame.width(), CDBrowserCell.HEIGHT);
NSRect iconRect = new NSRect(cellFrame.x(), cellFrame.y(),
this.icon().size().width()+4,
CDBrowserCell.HEIGHT);
NSRect textRect = new NSRect(cellFrame.x()+4+this.icon().size().width()+4,
cellFrame.y(),
cellFrame.width()-4-this.icon().size().width()-4,
CDBrowserCell.HEIGHT);
super.drawInteriorWithFrameInView(textRect,
controlView);
if(this.isHighlighted()) {
NSRect selectionRect = new NSRect(cellFrame.x(), cellFrame.y(),
this.icon().size().width()+4+4, CDBrowserCell.HEIGHT);
NSColor background = this.highlightColorInView(controlView); background.set();
NSBezierPath.fillRect(selectionRect);
}
if(controlView.isFlipped()) {
this.icon().compositeToPoint(new NSPoint(iconRect.x()+4,
iconRect.y()+(iconRect.size().height()+this.icon().size().height())/2),
NSImage.CompositeSourceOver);
else
this.icon().compositeToPoint(new NSPoint(iconRect.x()+2,
}
else {
this.icon().compositeToPoint(new NSPoint(iconRect.x()+4,
iconRect.y()+(iconRect.size().height()-this.icon().size().height())/2),
NSImage.CompositeSourceOver);
super.drawInteriorWithFrameInView(textRect,
controlView);
}
}
else super.drawInteriorWithFrameInView(cellFrame, controlView);
}
}
@@ -21,52 +21,78 @@ package ch.cyberduck.ui.cocoa;
import com.apple.cocoa.application.NSBrowser;
import com.apple.cocoa.application.NSBrowserCell;
import com.apple.cocoa.application.NSTableColumn;
import com.apple.cocoa.application.NSTextFieldCell;
import com.apple.cocoa.application.NSColor;
import com.apple.cocoa.foundation.NSNotification;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathFactory;
import ch.cyberduck.core.NullComparator;
import java.util.Comparator;
/**
* @version $Id$
*/
public class CDBrowserColumnViewModel extends CDBrowserTableDataSource {
public class CDBrowserColumnViewModel extends CDBrowserTableDataSource implements CDTableDelegate {
public CDBrowserColumnViewModel(CDBrowserController controller) {
super(controller);
}
public boolean isColumnEditable(NSTableColumn tableColumn) {
return false;
}
public void enterKeyPressed(Object sender) {
}
public void deleteKeyPressed(Object sender) {
}
public boolean isSortedAscending() {
return true;
}
public Comparator getSortingComparator() {
return new NullComparator();
}
public int browserNumberOfRowsInColumn(NSBrowser sender, int col) {
if(controller.isMounted()) {
String absolute = this.pathOfColumn(sender, col);
return this.childs(PathFactory.createPath(controller.workdir().getSession(),
absolute)).size();
}
return 0;
}
public void browserWillDisplayCell(NSBrowser sender, NSBrowserCell cell, int row, int col) {
String absolute = this.pathOfColumn(sender, col);
if(cell instanceof CDBrowserCell) {
Path path = (Path)this.childs(PathFactory.createPath(controller.workdir().getSession(),
absolute)).get(row);
((CDBrowserCell)cell).setPath(path);
if(this.controller.isConnected()) {
//((CDBrowserCell)cell).setTextColor(NSColor.controlTextColor());
}
else {
//((CDBrowserCell)cell).setTextColor(NSColor.disabledControlTextColor());
}
}
}
private String pathOfColumn(NSBrowser sender, int column) {
if(0 == column) {
return "/";
}
//Returns a string representing the path from the first column up to, but not including, the column at index column.
return sender.pathToColumn(column);
}
public void sort(NSTableColumn tableColumn, final boolean ascending) {
// column view is not sortable
}
if(controller.isMounted()) {
return this.childs(PathFactory.createPath(controller.workdir().getSession(),
this.pathOfColumn(sender, col))).size();
}
return 0;
}
public void browserWillDisplayCell(NSBrowser sender, NSBrowserCell cell, int row, int col) {
if(cell instanceof CDBrowserCell) {
Path path = (Path)this.childs(PathFactory.createPath(controller.workdir().getSession(),
this.pathOfColumn(sender, col))).get(row);
((CDBrowserCell)cell).setPath(path);
}
// if (cell instanceof NSTextFieldCell) {
// if (CDBrowserController.this.isConnected()) {
// ((NSTextFieldCell) cell).setTextColor(NSColor.controlTextColor());
// }
// else {
// ((NSTextFieldCell) cell).setTextColor(NSColor.disabledControlTextColor());
// }
// }
}
public void controlTextDidEndEditing(NSNotification aNotification) {
}
public String pathOfColumn(NSBrowser sender, int column) {
if(0 == column) {
return Path.DELIMITER;
}
//Returns a string representing the path from the first column up to, but not including, the column at index column.
return sender.pathToColumn(column);
}
}
@@ -20,7 +20,6 @@ package ch.cyberduck.ui.cocoa;
import ch.cyberduck.core.*;
import ch.cyberduck.core.Queue;
import ch.cyberduck.core.ftp.FTPSession;
import ch.cyberduck.ui.cocoa.odb.Editor;
import com.apple.cocoa.application.*;
import com.apple.cocoa.foundation.*;
@@ -107,8 +106,7 @@ public class CDBrowserController extends CDWindowController implements Observer
if (userObj != null) {
host.setCredentials((String) args.objectForKey("Username"), (String) args.objectForKey("Password"));
}
Session session = this.init(host);
session.mount(this.getEncoding(), this.getFileComparator(), this.getFileFilter());
this.init(host).mount(this.getEncoding(), this.getComparator(), this.getFileFilter());
return null;
}
@@ -146,7 +144,7 @@ public class CDBrowserController extends CDWindowController implements Observer
folder);
}
}
for (Iterator i = path.list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter()).iterator(); i.hasNext();) {
for (Iterator i = path.list(false, this.getEncoding(), this.getComparator(), this.getFileFilter()).iterator(); i.hasNext();) {
result.addObject(((Path) i.next()).getName());
}
}
@@ -216,7 +214,7 @@ public class CDBrowserController extends CDWindowController implements Observer
this.workdir().getAbsolute(),
(String) args.objectForKey("Path"));
path.delete();
this.workdir().list(true, encoding, this.getFileComparator(), this.getFileFilter());
this.workdir().list(true, encoding, this.getComparator(), this.getFileFilter());
}
return null;
}
@@ -390,8 +388,19 @@ public class CDBrowserController extends CDWindowController implements Observer
return this.encoding;
}
protected Comparator getFileComparator() {
return this.getSelectedBrowserModel().getComparator();
protected Comparator getComparator() {
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
return ((CDTableDelegate)this.browserListView.delegate()).getSortingComparator();
}
case OUTLINE_VIEW: {
return ((CDTableDelegate)this.browserOutlineView.delegate()).getSortingComparator();
}
case COLUMN_VIEW: {
return ((CDTableDelegate)this.browserColumnView.delegate()).getSortingComparator();
}
}
return null;
}
private boolean showHiddenFiles;
@@ -431,27 +440,20 @@ public class CDBrowserController extends CDWindowController implements Observer
this.window().makeFirstResponder(this.getSelectedBrowserView());
}
private void reloadPathPopup() {
pathPopupItems.clear();
pathPopupButton.removeAllItems();
if(this.isMounted()) {
this.addPathToPopup(workdir);
for (Path p = workdir; !p.isRoot();) {
p = p.getParent();
this.addPathToPopup(p);
}
}
}
private void reloadData() {
log.debug("reloadData");
this.reloadPathPopup();
this.getSelectedBrowserView().reloadData();
if(this.isMounted()) {
this.infoLabel.setStringValue(this.getSelectedBrowserView().numberOfRows() + " " +
NSBundle.localizedString("files", ""));
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
this.infoLabel.setStringValue(this.browserListView.numberOfRows() + " " +
NSBundle.localizedString("files", ""));
this.browserListView.reloadData();
break;
}
case OUTLINE_VIEW: {
this.infoLabel.setStringValue(this.browserOutlineView.numberOfRows() + " " +
NSBundle.localizedString("files", ""));
this.browserOutlineView.reloadData();
for(int i = 0; i < this.browserOutlineView.numberOfRows(); i++) {
Path p = (Path)this.browserOutlineView.itemAtRow(i);
if(p.attributes.isDirectory()) {
@@ -462,15 +464,18 @@ public class CDBrowserController extends CDWindowController implements Observer
}
break;
}
// case COLUMN_VIEW: {
// if(this.isMounted()) {
// this.browserColumnView.setPath(workdir().getAbsolute());
// this.browserColumnView.reloadColumn(browserColumnView.lastColumn());
// this.browserColumnView.setPath(workdir().getAbsolute());
// this.browserColumnView.validateVisibleColumns();
// }
// break;
}
case COLUMN_VIEW: {
this.infoLabel.setStringValue(this.browserColumnView.matrixInColumn(this.browserColumnView.lastVisibleColumn()).numberOfRows() + " " +
NSBundle.localizedString("files", ""));
this.browserColumnView.setPath(this.workdir().getAbsolute());
for(int col = 0; col < this.browserColumnView.numberOfVisibleColumns(); col++) {
if(this.workdir().getAbsolute().equals(
this.browserColumnModel.pathOfColumn(this.browserColumnView, col))) {
this.browserColumnView.reloadColumn(col);
}
}
}
}
}
else {
this.infoLabel.setStringValue("");
@@ -486,14 +491,19 @@ public class CDBrowserController extends CDWindowController implements Observer
private void selectRow(int row, boolean expand) {
log.debug("selectRow:"+row);
this.getSelectedBrowserView().selectRow(row, expand);
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
this.browserListView.selectRow(row, expand);
}
case OUTLINE_VIEW: {
this.browserOutlineView.selectRow(row, expand);
}
case COLUMN_VIEW: {
}
}
this.getFocus();
}
private int getClickedRow() {
return this.getSelectedBrowserView().clickedRow();
}
protected Path getSelectedPath() {
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
@@ -502,9 +512,9 @@ public class CDBrowserController extends CDWindowController implements Observer
case OUTLINE_VIEW: {
return (Path)this.browserOutlineView.itemAtRow(this.browserOutlineView.selectedRow());
}
// case COLUMN_VIEW: {
// return ((CDBrowserCell)this.browserColumnView.selectedCell()).getPath();
// }
case COLUMN_VIEW: {
return ((CDBrowserCell)this.browserColumnView.selectedCell()).getPath();
}
}
return null;
}
@@ -530,33 +540,48 @@ public class CDBrowserController extends CDWindowController implements Observer
}
return selectedFiles;
}
// case COLUMN_VIEW: {
// java.util.Enumeration iterator = this.browserColumnView.selectedCells().objectEnumerator();
// List files = new ArrayList();
// while (iterator.hasMoreElements()) {
// files.add(((CDBrowserCell)iterator.nextElement()).getPath());
// }
// return files;
// }
case COLUMN_VIEW: {
List files = new ArrayList();
if(this.browserColumnView.selectedCells() != null) {
java.util.Enumeration iterator = this.browserColumnView.selectedCells().objectEnumerator();
while (iterator.hasMoreElements()) {
files.add(((CDBrowserCell)iterator.nextElement()).getPath());
}
}
return files;
}
}
return null;
}
private int getSelectionCount() {
return this.getSelectedBrowserView().numberOfSelectedRows();
}
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
return this.browserListView.numberOfSelectedRows();
}
case OUTLINE_VIEW: {
return this.browserOutlineView.numberOfSelectedRows();
}
case COLUMN_VIEW: {
if(this.browserColumnView.selectedCells() != null) {
return this.browserColumnView.selectedCells().count();
}
}
}
return 0;
}
private void deselectAll() {
this.getSelectedBrowserView().deselectAll(null);
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
this.browserListView.deselectAll(null);
}
case OUTLINE_VIEW: {
this.browserOutlineView.deselectAll(null);
}
}
}
// public void browserColumnViewRowClicked(Object sender) {
// this.browserSelectionDidChange(null);
// if(!((NSBrowserCell)this.browserColumnView.selectedCell()).isLeaf()) {
// this.browserRowDoubleClicked(sender);
// }
// }
public void update(final Observable o, final Object arg) {
if(!Thread.currentThread().getName().equals("main") && !Thread.currentThread().getName().equals("AWT-AppKit")) {
this.invoke(new Runnable() {
@@ -567,7 +592,7 @@ public class CDBrowserController extends CDWindowController implements Observer
return;
}
if (arg instanceof Path) {
this.workdir = (Path) arg;
this.setWorkdir((Path) arg);
this.reloadData();
}
else if (arg instanceof Message) {
@@ -592,7 +617,12 @@ public class CDBrowserController extends CDWindowController implements Observer
this.statusLabel.display();
}
else if (msg.getTitle().equals(Message.REFRESH)) {
this.reloadButtonClicked(null);
if(msg.getContent() != null) {
this.reloadDirectory(((Path)msg.getContent()).copy(this.workdir().getSession()));
}
else {
this.reloadDirectory(this.workdir());
}
}
else if (msg.getTitle().equals(Message.OPEN)) {
progressIndicator.startAnimation(this);
@@ -636,22 +666,7 @@ public class CDBrowserController extends CDWindowController implements Observer
this.logView = logView;
}
// private NSButton interruptButton;
//
// public void setInterruptButton(NSButton interruptButton) {
// this.interruptButton = interruptButton;
// this.interruptButton.setTarget(this);
// this.interruptButton.setAction(new NSSelector("interruptButtonClicked", new Class[]{Object.class}));
// this.interruptButton.setEnabled(true);
// }
//
// public void interruptButtonClicked(Object sender) {
// if(this.isMounted()) {
// this.session.interrupt();
// }
// }
public NSTableView getSelectedBrowserView() {
public NSView getSelectedBrowserView() {
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
return this.browserListView;
@@ -659,22 +674,33 @@ public class CDBrowserController extends CDWindowController implements Observer
case OUTLINE_VIEW: {
return this.browserOutlineView;
}
// case COLUMN_VIEW: {
// return this.browserColumnView;
// }
case COLUMN_VIEW: {
return this.browserColumnView;
}
}
return null;
}
public CDBrowserTableDataSource getSelectedBrowserModel() {
return (CDBrowserTableDataSource)this.getSelectedBrowserView().dataSource();
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
return (CDBrowserTableDataSource)this.browserListView.dataSource();
}
case OUTLINE_VIEW: {
return (CDBrowserTableDataSource)this.browserOutlineView.dataSource();
}
case COLUMN_VIEW: {
return this.browserColumnModel;
}
}
return null;
}
private NSSegmentedControl browserSwitchView;
private static final int LIST_VIEW = 0;
private static final int OUTLINE_VIEW = 1;
// private static final int COLUMN_VIEW = 2;
private static final int COLUMN_VIEW = 2;
public void setBrowserSwitchView(NSSegmentedControl browserSwitchView) {
this.browserSwitchView = browserSwitchView;
@@ -706,13 +732,49 @@ public class CDBrowserController extends CDWindowController implements Observer
this.searchField.setNextKeyView(this.getSelectedBrowserView());
}
private class CDAbstractBrowserTableDelegate extends CDAbstractTableDelegate {
public boolean isColumnEditable(NSTableColumn tableColumn) {
return tableColumn.identifier().equals(CDBrowserTableDataSource.FILENAME_COLUMN);
}
public void enterKeyPressed(Object sender) {
CDBrowserController.this.insideButtonClicked(sender);
}
public void deleteKeyPressed(Object sender) {
CDBrowserController.this.deleteFileButtonClicked(sender);
}
public void tableColumnClicked(NSTableView tableView, NSTableColumn tableColumn) {
List selected = CDBrowserController.this.getSelectedPaths();
if (this.selectedColumnIdentifier().equals(tableColumn.identifier())) {
this.setSortedAscending(!this.isSortedAscending());
}
else {
tableView.setIndicatorImage(null, tableView.tableColumnWithIdentifier(this.selectedColumnIdentifier()));
this.setSelectedColumn(tableColumn);
}
tableView.setIndicatorImage(this.isSortedAscending() ?
NSImage.imageNamed("NSAscendingSortIndicator") :
NSImage.imageNamed("NSDescendingSortIndicator"),
tableColumn);
tableView.deselectAll(null);
tableView.reloadData();
for (Iterator i = selected.iterator(); i.hasNext();) {
tableView.selectRowIndexes(new NSIndexSet(
CDBrowserController.this.getSelectedBrowserModel().indexOf(tableView, (Path)i.next())),
true);
}
}
}
private CDBrowserOutlineViewModel browserOutlineModel;
private NSOutlineView browserOutlineView; // IBOutlet
private CDTableDelegate browserOutlineViewDelegate;
public void setBrowserOutlineView(NSOutlineView browserOutlineView) {
this.browserOutlineView = browserOutlineView;
this.browserOutlineView.setTarget(this);
this.browserOutlineView.setDoubleAction(new NSSelector("browserRowDoubleClicked", new Class[]{Object.class}));
// receive drag events from types
this.browserOutlineView.registerForDraggedTypes(new NSArray(new Object[]{
"QueuePboardType",
@@ -737,7 +799,61 @@ public class CDBrowserController extends CDWindowController implements Observer
this.browserOutlineView);
}
this.browserOutlineView.setDataSource(this.browserOutlineModel = new CDBrowserOutlineViewModel(this));
this.browserOutlineView.setDelegate(this.browserOutlineModel);
this.browserOutlineView.setDelegate(this.browserOutlineViewDelegate = new CDAbstractBrowserTableDelegate() {
public void outlineViewWillDisplayCell(NSOutlineView outlineView, Object cell,
NSTableColumn tableColumn, Path item) {
String identifier = (String) tableColumn.identifier();
if (identifier.equals(CDBrowserTableDataSource.FILENAME_COLUMN)) {
NSImage icon;
if (item.attributes.isSymbolicLink()) {
icon = CDBrowserTableDataSource.SYMLINK_ICON;
}
else if (item.attributes.isDirectory()) {
icon = CDBrowserTableDataSource.FOLDER_ICON;
}
else if (item.attributes.isFile()) {
icon = CDIconCache.instance().get(item.getExtension());
}
else {
icon = CDBrowserTableDataSource.NOT_FOUND_ICON;
}
icon.setSize(new NSSize(16f, 16f));
((CDOutlineCell) cell).setIcon(icon);
((CDOutlineCell) cell).setAttributedStringValue(new NSAttributedString(item.getName(),
CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY));
}
if (cell instanceof NSTextFieldCell) {
if (CDBrowserController.this.isConnected()) {
((NSTextFieldCell) cell).setTextColor(NSColor.controlTextColor());
}
else {
((NSTextFieldCell) cell).setTextColor(NSColor.disabledControlTextColor());
}
}
}
public void outlineViewItemDidExpand(NSNotification notification) {
Path p = (Path) notification.userInfo().allValues().lastObject();
p.getSession().cache().setExpanded(p, true);
}
public void outlineViewItemDidCollapse(NSNotification notification) {
Path p = (Path) notification.userInfo().allValues().lastObject();
p.getSession().cache().setExpanded(p, false);
}
public String outlineViewToolTipForCell(NSOutlineView view, NSCell cell, NSMutableRect rect, NSTableColumn tableColumn,
Object item, NSPoint mouseLocation) {
if (item instanceof Path) {
Path p = (Path)item;
return p.getAbsolute() + "\n"
+ Status.getSizeAsString(p.attributes.getSize()) + "\n"
+ p.attributes.getTimestampAsString();
}
return null;
}
});
{
NSTableColumn c = new NSTableColumn();
c.headerCell().setStringValue(NSBundle.localizedString("Filename", "A column in the browser"));
@@ -752,7 +868,23 @@ public class CDBrowserController extends CDWindowController implements Observer
else {
c.setResizable(true);
}
c.setDataCell(new CDOutlineCell());
NSTextFieldCell cell = new CDOutlineCell() {
public void selectAndEditWithFrameInView(NSRect rect, NSView view, NSText text, Object object, int selStart, int selLength) {
super.selectAndEditWithFrameInView(new NSRect(rect.x()+20, rect.y(), rect.width()-20, rect.height()),
view, text, object, selStart, selLength);
}
public void editWithFrameInView(NSRect rect, NSView view, NSText text, Object object, NSEvent event) {
super.editWithFrameInView(new NSRect(rect.x()+20, rect.y(), rect.width()-20, rect.height()),
view, text, object, event);
}
};
{
cell.setEditable(true);
cell.setTarget(browserListView.target());
cell.setAction(browserListView.action());
}
c.setDataCell(cell);
c.dataCell().setAlignment(NSText.LeftTextAlignment);
this.browserOutlineView.addTableColumn(c);
this.browserOutlineView.setOutlineTableColumn(c);
@@ -761,11 +893,10 @@ public class CDBrowserController extends CDWindowController implements Observer
private CDBrowserListViewModel browserListModel;
private NSTableView browserListView; // IBOutlet
private CDTableDelegate browserListViewDelegate;
public void setBrowserListView(NSTableView browserListView) {
this.browserListView = browserListView;
this.browserListView.setTarget(this);
this.browserListView.setDoubleAction(new NSSelector("browserRowDoubleClicked", new Class[]{Object.class}));
// receive drag events from types
this.browserListView.registerForDraggedTypes(new NSArray(new Object[]{
"QueuePboardType",
@@ -790,7 +921,31 @@ public class CDBrowserController extends CDWindowController implements Observer
this.browserListView);
}
this.browserListView.setDataSource(this.browserListModel = new CDBrowserListViewModel(this));
this.browserListView.setDelegate(this.browserListModel);
this.browserListView.setDelegate(this.browserListViewDelegate = new CDAbstractBrowserTableDelegate() {
public void tableViewWillDisplayCell(NSTableView tableView, Object cell, NSTableColumn tableColumn, int row) {
if(cell instanceof NSTextFieldCell) {
if(CDBrowserController.this.isConnected()) {
((NSTextFieldCell)cell).setTextColor(NSColor.controlTextColor());
}
else {
((NSTextFieldCell)cell).setTextColor(NSColor.disabledControlTextColor());
}
}
}
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if (row < getSelectedBrowserModel().childs(CDBrowserController.this.workdir()).size()) {
Path p = (Path) getSelectedBrowserModel().childs(CDBrowserController.this.workdir()).get(row);
return p.getAbsolute() + "\n"
+ Status.getSizeAsString(p.attributes.getSize()) + "\n"
+ p.attributes.getTimestampAsString();
}
return null;
}
});
NSSelector setResizableMaskSelector
= new NSSelector("setResizingMask", new Class[]{int.class});
{
@@ -806,7 +961,6 @@ public class CDBrowserController extends CDWindowController implements Observer
else {
c.setResizable(true);
}
c.setEditable(false);
c.setDataCell(new NSImageCell());
c.dataCell().setAlignment(NSText.CenterTextAlignment);
this.browserListView.addTableColumn(c);
@@ -824,45 +978,56 @@ public class CDBrowserController extends CDWindowController implements Observer
else {
c.setResizable(true);
}
c.setEditable(false);
c.setDataCell(new NSTextFieldCell());
NSTextFieldCell cell = new NSTextFieldCell();
{
cell.setEditable(true);
cell.setTarget(browserListView.target());
cell.setAction(browserListView.action());
}
c.setDataCell(cell);
c.dataCell().setAlignment(NSText.LeftTextAlignment);
this.browserListView.addTableColumn(c);
}
}
// private CDBrowserColumnViewModel browserColumnModel;
// private NSBrowser browserColumnView; // IBOutlet
//
// public void setBrowserColumnView(NSBrowser browserColumnView) {
// this.browserColumnView = browserColumnView;
// this.browserColumnView.setTarget(this);
// this.browserColumnView.setAction(new NSSelector("browserColumnViewRowClicked", new Class[]{Object.class}));
// this.browserColumnView.setDoubleAction(new NSSelector("browserRowDoubleClicked", new Class[]{Object.class}));
// this.browserColumnView.setAcceptsArrowKeys(true);
// this.browserColumnView.setSendsActionOnArrowKeys(true);
// this.browserColumnView.setMaxVisibleColumns(5);
// this.browserColumnView.setAllowsEmptySelection(true);
// this.browserColumnView.setAllowsMultipleSelection(true);
// this.browserColumnView.setAllowsBranchSelection(true);
// this.browserColumnView.setPathSeparator("/");
// this.browserColumnView.setReusesColumns(false);
// this.browserColumnView.setSeparatesColumns(false);
// this.browserColumnView.setTitled(false);
// this.browserColumnView.setHasHorizontalScroller(false);
//
// this.browserColumnView.setDelegate(this.browserColumnModel = new CDBrowserColumnViewModel(this));
// // Make the browser user our custom browser cell.
// this.browserColumnView.setNewCellClass(CDBrowserCell.class);
// this.browserColumnView.setNewMatrixClass(CDBrowserMatrix.class);
// }
private CDBrowserColumnViewModel browserColumnModel;
private NSBrowser browserColumnView; // IBOutlet
public void browserRowDoubleClicked(Object sender) {
log.debug("browserRowDoubleClicked:"+sender);
if(this.getClickedRow() != -1) { // make sure double click was not in table header
this.insideButtonClicked(sender);
public void setBrowserColumnView(NSBrowser browserColumnView) {
this.browserColumnView = browserColumnView;
this.browserColumnView.setTarget(this);
this.browserColumnView.setAction(new NSSelector("browserColumnViewRowClicked", new Class[]{Object.class}));
this.browserColumnView.setAcceptsArrowKeys(true);
this.browserColumnView.setSendsActionOnArrowKeys(true);
this.browserColumnView.setMaxVisibleColumns(5);
this.browserColumnView.setAllowsEmptySelection(true);
this.browserColumnView.setAllowsMultipleSelection(true);
this.browserColumnView.setAllowsBranchSelection(true);
this.browserColumnView.setPathSeparator(Path.DELIMITER);
this.browserColumnView.setReusesColumns(false);
this.browserColumnView.setSeparatesColumns(false);
this.browserColumnView.setTitled(false);
this.browserColumnView.setHasHorizontalScroller(false);
this.browserColumnView.setDelegate(this.browserColumnModel = new CDBrowserColumnViewModel(this));
// Make the browser user our custom browser cell.
this.browserColumnView.setNewCellClass(CDBrowserCell.class);
this.browserColumnView.setNewMatrixClass(CDBrowserMatrix.class);
// for(int i = 0; i < this.browserColumnView.maxVisibleColumns(); i++) {
// this.browserColumnView.matrixInColumn(i).setDelegate(this.browserColumnModel);
// }
}
public void browserColumnViewRowClicked(Object sender) {
Path selected = this.getSelectedPath(); //last row selected
if(selected.attributes.isDirectory()) {
selected.list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
}
if(selected.attributes.isFile()) {
this.setWorkdir(selected.getParent());
}
this.browserSelectionDidChange(null);
}
public void browserSelectionDidChange(NSNotification notification) {
if (this.inspector != null && this.inspector.window().isVisible()) {
@@ -968,7 +1133,7 @@ public class CDBrowserController extends CDWindowController implements Observer
c.dataCell().setAlignment(NSText.LeftTextAlignment);
table.addTableColumn(c);
}
table.setIndicatorImage(((CDBrowserTableDataSource)table.dataSource()).isSortedAscending() ?
table.setIndicatorImage(((CDTableDelegate)table.delegate()).isSortedAscending() ?
NSImage.imageNamed("NSAscendingSortIndicator") :
NSImage.imageNamed("NSDescendingSortIndicator"),
table.tableColumnWithIdentifier(Preferences.instance().getProperty("browser.sort.column")));
@@ -983,12 +1148,32 @@ public class CDBrowserController extends CDWindowController implements Observer
private CDBookmarkTableDataSource bookmarkModel;
private NSTableView bookmarkTable; // IBOutlet
private CDTableDelegate bookmarkTableDelegate;
public void setBookmarkTable(NSTableView bookmarkTable) {
this.bookmarkTable = bookmarkTable;
this.bookmarkTable.setTarget(this);
this.bookmarkTable.setDoubleAction(new NSSelector("bookmarkTableRowDoubleClicked", new Class[]{Object.class}));
this.bookmarkTable.setDataSource(this.bookmarkModel = CDBookmarkTableDataSource.instance());
this.bookmarkTable.setDelegate(this.bookmarkTableDelegate = new CDAbstractTableDelegate() {
public void enterKeyPressed(Object sender) {
log.debug("enterKeyPressed:" + sender);
CDBrowserController.this.bookmarkTableRowDoubleClicked(sender);
}
public void deleteKeyPressed(Object sender) {
log.debug("enterKeyPressed:" + sender);
CDBrowserController.this.deleteBookmarkButtonClicked(sender);
}
public void tableColumnClicked(NSTableView view, NSTableColumn tableColumn) {
}
public String toolTipForItem(Object item) {
return null;
}
});
// receive drag events from types
this.bookmarkTable.registerForDraggedTypes(new NSArray(new Object[]
{
@@ -996,6 +1181,11 @@ public class CDBrowserController extends CDWindowController implements Observer
NSPasteboard.FilesPromisePboardType,
"HostPBoardType" //moving bookmarks
}));
(NSNotificationCenter.defaultCenter()).addObserver(this,
new NSSelector("bookmarkSelectionDidChange", new Class[]{NSNotification.class}),
NSTableView.TableViewSelectionDidChangeNotification,
this.bookmarkTable);
this.bookmarkTable.setRowHeight(45f);
NSSelector setResizableMaskSelector
= new NSSelector("setResizingMask", new Class[]{int.class});
@@ -1006,7 +1196,6 @@ public class CDBrowserController extends CDWindowController implements Observer
c.setMinWidth(32f);
c.setWidth(32f);
c.setMaxWidth(32f);
c.setEditable(false);
if(setResizableMaskSelector.implementedByClass(NSTableColumn.class)) {
c.setResizingMask(NSTableColumn.AutoresizingMask);
}
@@ -1023,7 +1212,6 @@ public class CDBrowserController extends CDWindowController implements Observer
c.setMinWidth(50f);
c.setWidth(200f);
c.setMaxWidth(500f);
c.setEditable(false);
if(setResizableMaskSelector.implementedByClass(NSTableColumn.class)) {
c.setResizingMask(NSTableColumn.AutoresizingMask);
}
@@ -1045,13 +1233,6 @@ public class CDBrowserController extends CDWindowController implements Observer
this.bookmarkTable.setAllowsColumnSelection(false);
this.bookmarkTable.setAllowsColumnReordering(false);
this.bookmarkTable.sizeToFit();
(NSNotificationCenter.defaultCenter()).addObserver(this,
new NSSelector("bookmarkSelectionDidChange", new Class[]{NSNotification.class}),
NSTableView.TableViewSelectionDidChangeNotification,
this.bookmarkTable);
this.bookmarkTable.setDataSource(this.bookmarkModel = CDBookmarkTableDataSource.instance());
this.bookmarkTable.setDelegate(this.bookmarkModel);
}
public void bookmarkSelectionDidChange(NSNotification notification) {
@@ -1062,9 +1243,10 @@ public class CDBrowserController extends CDWindowController implements Observer
public void bookmarkTableRowDoubleClicked(Object sender) {
log.debug("bookmarkTableRowDoubleClicked");
if (this.bookmarkTable.selectedRow() != -1) {
Host h = (Host) bookmarkModel.get(bookmarkTable.selectedRow());
this.mount(h, h.getEncoding());
Host h = (Host) this.bookmarkModel.get(bookmarkTable.selectedRow());
this.mount(h, h.getEncoding());
if(Preferences.instance().getBoolean("browser.closeDrawer")) {
this.bookmarkDrawer.close();
}
}
@@ -1154,7 +1336,7 @@ public class CDBrowserController extends CDWindowController implements Observer
log.debug("quickConnectSelectionChanged");
String input = ((NSControl) sender).stringValue();
try {
for (Iterator iter = bookmarkModel.iterator(); iter.hasNext();) {
for (Iterator iter = this.bookmarkModel.iterator(); iter.hasNext();) {
Host h = (Host) iter.next();
if (h.getNickname().equals(input)) {
this.mount(h);
@@ -1220,7 +1402,7 @@ public class CDBrowserController extends CDWindowController implements Observer
public void editBookmarkButtonClicked(Object sender) {
this.bookmarkDrawer.open();
CDBookmarkController controller = new CDBookmarkController(bookmarkTable,
(Host) bookmarkModel.get(bookmarkTable.selectedRow()));
(Host) this.bookmarkModel.get(bookmarkTable.selectedRow()));
controller.window().makeKeyAndOrderFront(null);
}
@@ -1246,8 +1428,8 @@ public class CDBrowserController extends CDWindowController implements Observer
}
this.bookmarkModel.add(item);
this.bookmarkTable.reloadData();
this.bookmarkTable.selectRow(bookmarkModel.lastIndexOf(item), false);
this.bookmarkTable.scrollRowToVisible(bookmarkModel.lastIndexOf(item));
this.bookmarkTable.selectRow(this.bookmarkModel.lastIndexOf(item), false);
this.bookmarkTable.scrollRowToVisible(this.bookmarkModel.lastIndexOf(item));
CDBookmarkController controller = new CDBookmarkController(bookmarkTable, item);
controller.window().makeKeyAndOrderFront(null);
}
@@ -1276,7 +1458,7 @@ public class CDBrowserController extends CDWindowController implements Observer
NSBundle.localizedString("Cancel", ""),
null)) {
case NSAlertPanel.DefaultReturn:
bookmarkModel.remove(i - j);
this.bookmarkModel.remove(i - j);
j++;
break;
case NSAlertPanel.AlternateReturn:
@@ -1319,13 +1501,13 @@ public class CDBrowserController extends CDWindowController implements Observer
public void backButtonClicked(Object sender) {
log.debug("backButtonClicked");
this.deselectAll();
this.session.getPreviousPath().list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
this.session.getPreviousPath().list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
public void forwardButtonClicked(Object sender) {
log.debug("forwardButtonClicked");
this.deselectAll();
this.session.getForwardPath().list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
this.session.getForwardPath().list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
private NSSegmentedControl upButton; // IBOutlet
@@ -1340,46 +1522,12 @@ public class CDBrowserController extends CDWindowController implements Observer
log.debug("upButtonClicked");
this.deselectAll();
Path previous = this.workdir();
List listing = this.workdir().getParent().list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
List listing = this.workdir().getParent().list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
if(listing.contains(previous)) {
this.selectRow((Path)listing.get(listing.indexOf(previous)), false);
}
}
public void enterKeyPressed(Object sender) {
log.debug("enterKeyPressed:" + sender);
if (sender == this.bookmarkTable) {
this.bookmarkTableRowDoubleClicked(sender);
}
if (sender == this.getSelectedBrowserView()) {
if (this.getSelectionCount() > 0) {
switch(this.browserSwitchView.selectedSegment()) {
case LIST_VIEW: {
this.insideButtonClicked(sender);
break;
}
case OUTLINE_VIEW: {
this.browserOutlineView.expandItem(this.getSelectedPath());
break;
}
// case COLUMN_VIEW: {
// break;
// }
}
}
}
}
public void deleteKeyPressed(Object sender) {
log.debug("deleteKeyPressed:" + sender);
if (sender == this.bookmarkTable) {
this.deleteBookmarkButtonClicked(sender);
}
else {
this.deleteFileButtonClicked(sender);
}
}
private static final NSImage DISK_ICON = NSImage.imageNamed("disk.tiff");
private List pathPopupItems = new ArrayList();
@@ -1402,7 +1550,7 @@ public class CDBrowserController extends CDWindowController implements Observer
public void pathPopupSelectionChanged(Object sender) {
Path p = (Path) pathPopupItems.get(pathPopupButton.indexOfSelectedItem());
this.deselectAll();
p.list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
p.list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
private static final NSImage FOLDER_ICON = NSImage.imageNamed("folder16.tiff");
@@ -1541,11 +1689,14 @@ public class CDBrowserController extends CDWindowController implements Observer
public void reloadButtonClicked(Object sender) {
log.debug("reloadButtonClicked");
//bug: doesn't reload child items in outline view
this.reloadDirectory(this.workdir());
}
private void reloadDirectory(Path directory) {
if (this.isMounted()) {
List selected = this.getSelectedPaths();
this.deselectAll();
List listing = this.workdir().list(true, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
List listing = directory.list(true, this.getEncoding(), this.getComparator(), this.getFileFilter());
for(Iterator iter = selected.iterator(); iter.hasNext(); ) {
Path p = (Path)iter.next();
if(listing.contains(p)) {
@@ -1669,7 +1820,7 @@ public class CDBrowserController extends CDWindowController implements Observer
}
else if(this.getSelectionCount() > 0) {
int i = 0;
Iterator iter = null;
Iterator iter;
for(iter = this.getSelectedPaths().iterator(); i < 10 && iter.hasNext(); ) {
Path p = (Path)iter.next();
files.add(p);
@@ -1714,7 +1865,7 @@ public class CDBrowserController extends CDWindowController implements Observer
p = (Path)i.next();
p.delete();
}
this.workdir().list(true, encoding, this.getFileComparator(), this.getFileFilter());
this.workdir().list(true, encoding, this.getComparator(), this.getFileFilter());
}
}
}
@@ -1844,28 +1995,26 @@ public class CDBrowserController extends CDWindowController implements Observer
public void insideButtonClicked(Object sender) {
log.debug("insideButtonClicked");
Path p = this.getSelectedPath(); //last row selected
if (p.attributes.isDirectory()) {
this.deselectAll();
p.list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
}
if (p.attributes.isFile() || this.getSelectionCount() > 1) {
if (Preferences.instance().getBoolean("browser.doubleclick.edit")) {
this.editButtonClicked(null);
if (this.getSelectionCount() > 0) {
Path selected = this.getSelectedPath(); //last row selected
if(selected.attributes.isDirectory()) {
this.deselectAll();
selected.list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
else {
this.downloadButtonClicked(null);
else if(selected.attributes.isFile() || this.getSelectionCount() > 1) {
if(Preferences.instance().getBoolean("browser.doubleclick.edit")) {
this.editButtonClicked(null);
}
else {
this.downloadButtonClicked(null);
}
}
}
}
private CDWindowController connectionController;
}
public void connectButtonClicked(Object sender) {
log.debug("connectButtonClicked");
if(null == connectionController) {
connectionController = new CDConnectionController(this);
}
CDWindowController connectionController = new CDConnectionController(this);
this.beginSheet(connectionController.window(), connectionController,
new NSSelector("connectionSheetDidEnd", new Class[]{NSWindow.class, int.class, Object.class}),
null);
@@ -1890,7 +2039,7 @@ public class CDBrowserController extends CDWindowController implements Observer
}
if (this.isMounted()) {
this.deselectAll();
this.workdir().list(false, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
this.workdir().list(false, this.getEncoding(), this.getComparator(), this.getFileFilter());
}
}
}
@@ -1937,12 +2086,12 @@ public class CDBrowserController extends CDWindowController implements Observer
Path workdir = this.workdir();
for (Iterator iter = q.getRoots().iterator(); iter.hasNext();) {
Path p = (Path) iter.next();
PathFactory.createPath(workdir.getSession(), p.getAbsolute()).rename(workdir.getAbsolute() + "/" + p.getName());
PathFactory.createPath(workdir.getSession(), p.getAbsolute()).rename(workdir.getAbsolute() + Path.DELIMITER + p.getName());
p.getParent().invalidate();
}
}
pboard.setPropertyListForType(null, "PathPBoardType");
workdir.list(true, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
workdir.list(true, this.getEncoding(), this.getComparator(), this.getFileFilter());
this.reloadData();
}
}
@@ -1993,6 +2142,19 @@ public class CDBrowserController extends CDWindowController implements Observer
return this.workdir;
}
private void setWorkdir(Path workdir) {
this.workdir = workdir;
this.pathPopupItems.clear();
this.pathPopupButton.removeAllItems();
if(this.isMounted()) {
this.addPathToPopup(workdir);
for (Path p = workdir; !p.isRoot();) {
p = p.getParent();
this.addPathToPopup(p);
}
}
}
private Observer transcript;
private Session init(Host host) {
@@ -2009,15 +2171,15 @@ public class CDBrowserController extends CDWindowController implements Observer
new CDX509TrustManagerController(this));
}
host.setLoginController(new CDLoginController(this));
this.workdir = null;
this.setWorkdir(null);
this.reloadData();
session.addObserver(transcript = new CDTranscriptController(this.logView));
this.window().setTitle(host.getProtocol() + ":" + host.getCredentials().getUsername() + "@" + host.getHostname());
CDBookmarkTableDataSource.instance().exportBookmark(host, this.getRepresentedFile());
this.bookmarkModel.exportBookmark(host, this.getRepresentedFile());
if(this.getRepresentedFile().exists()) {
this.window().setRepresentedFilename(this.getRepresentedFile().getAbsolutePath());
}
session.addObserver((Observer) this);
session.addObserver((Observer)this);
this.getFocus();
return this.session;
}
@@ -2039,12 +2201,12 @@ public class CDBrowserController extends CDWindowController implements Observer
log.debug("mount:" + host);
if(this.isMounted()) {
if(this.session.getHost().getURL().equals(host.getURL())) {
Path home = PathFactory.createPath(session, "/");
Path home = PathFactory.createPath(session, Path.DELIMITER);
if(host.hasReasonableDefaultPath()) {
home = PathFactory.createPath(session, host.getDefaultPath());
}
home.attributes.setType(Path.DIRECTORY_TYPE);
home.list(true, this.getEncoding(), this.getFileComparator(), this.getFileFilter());
home.list(true, this.getEncoding(), this.getComparator(), this.getFileFilter());
return session;
}
}
@@ -2070,7 +2232,7 @@ public class CDBrowserController extends CDWindowController implements Observer
}
}
});
session.mount(encoding, getFileComparator(), getFileFilter());
session.mount(encoding, getComparator(), getFileFilter());
session.deleteObserver(observer);
}
}.start();
@@ -2344,7 +2506,7 @@ public class CDBrowserController extends CDWindowController implements Observer
return false;
}
if(identifier.equals("sendCustomCommandClicked:")) {
return (this.session instanceof FTPSession) && this.isConnected();
return this.isConnected();
}
if (identifier.equals("gotoButtonClicked:")) {
return this.isMounted();
@@ -2465,10 +2627,10 @@ public class CDBrowserController extends CDWindowController implements Observer
new NSSelector("browserSwitchClicked", new Class[]{Object.class}),
""));
viewSubmenu.itemWithTitle(NSBundle.localizedString("Outline", "Toolbar item")).setTag(1);
// viewSubmenu.addItem(new NSMenuItem(NSBundle.localizedString("Column", "Toolbar item"),
// new NSSelector("browserSwitchClicked", new Class[]{Object.class}),
// ""));
// viewSubmenu.itemWithTitle(NSBundle.localizedString("Column", "Toolbar item")).setTag(2);
viewSubmenu.addItem(new NSMenuItem(NSBundle.localizedString("Column", "Toolbar item"),
new NSSelector("browserSwitchClicked", new Class[]{Object.class}),
""));
viewSubmenu.itemWithTitle(NSBundle.localizedString("Column", "Toolbar item")).setTag(2);
viewMenu.setSubmenu(viewSubmenu);
item.setMenuFormRepresentation(viewMenu);
item.setMinSize(this.browserSwitchView.frame().size());
@@ -46,27 +46,22 @@ public class CDBrowserListViewModel extends CDBrowserTableDataSource {
return 0;
}
public void tableViewWillDisplayCell(NSTableView tableView, Object cell, NSTableColumn tableColumn, int row) {
if(cell instanceof NSTextFieldCell) {
if(this.controller.isConnected()) {
((NSTextFieldCell)cell).setTextColor(NSColor.controlTextColor());
public void tableViewSetObjectValueForLocation(NSTableView view, Object value, NSTableColumn tableColumn, int row) {
String identifier = (String) tableColumn.identifier();
if (identifier.equals(FILENAME_COLUMN)) {
Path p = (Path) this.childs(this.controller.workdir()).get(row);
if(!p.getName().equals(value)) {
p.rename(value.toString());
}
else {
((NSTextFieldCell)cell).setTextColor(NSColor.disabledControlTextColor());
}
}
}
public boolean tableViewShouldEditLocation(NSTableView tableview, NSTableColumn tableColumn, int row) {
return false;
}
}
}
public Object tableViewObjectValueForLocation(NSTableView tableView, NSTableColumn tableColumn, int row) {
List childs = this.childs(this.controller.workdir());
if (row < childs.size()) {
String identifier = (String) tableColumn.identifier();
Path p = (Path) childs.get(row);
if (identifier.equals("TYPE")) {
if (identifier.equals(TYPE_COLUMN)) {
NSImage icon;
if (p.attributes.isSymbolicLink()) {
icon = SYMLINK_ICON;
@@ -83,23 +78,23 @@ public class CDBrowserListViewModel extends CDBrowserTableDataSource {
icon.setSize(new NSSize(16f, 16f));
return icon;
}
if (identifier.equals("FILENAME")) {
if (identifier.equals(FILENAME_COLUMN)) {
return new NSAttributedString(p.getName(), CDTableCell. TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("TYPEAHEAD")) {
return p.getName();
}
if (identifier.equals("SIZE")) {
if (identifier.equals(SIZE_COLUMN)) {
return new NSAttributedString(Status.getSizeAsString(p.attributes.getSize()), CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("MODIFIED")) {
if (identifier.equals(MODIFIED_COLUMN)) {
return new NSGregorianDate((double) p.attributes.getTimestamp().getTime() / 1000,
NSDate.DateFor1970);
}
if (identifier.equals("OWNER")) {
if (identifier.equals(OWNER_COLUMN)) {
return new NSAttributedString(p.attributes.getOwner(), CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("PERMISSIONS")) {
if (identifier.equals(PERMISSIONS_COLUMN)) {
return new NSAttributedString(p.attributes.getPermission().toString(), CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
throw new IllegalArgumentException("Unknown identifier: " + identifier);
@@ -184,10 +179,10 @@ public class CDBrowserListViewModel extends CDBrowserTableDataSource {
Queue q = Queue.createQueue(dict);
for (Iterator iter = q.getRoots().iterator(); iter.hasNext();) {
Path p = PathFactory.createPath(selected.getSession(), ((Path) iter.next()).getAbsolute());
p.rename(selected.getAbsolute()+"/"+p.getName());
p.rename(selected.getAbsolute()+Path.DELIMITER+p.getName());
}
this.controller.workdir().list(true, this.controller.getEncoding(),
controller.getFileComparator(), controller.getFileFilter());
controller.getComparator(), controller.getFileFilter());
}
}
return true;
@@ -261,13 +256,6 @@ public class CDBrowserListViewModel extends CDBrowserTableDataSource {
NSPasteboard.pasteboardWithName(NSPasteboard.DragPboard).declareTypes(null, null);
}
public int draggingSourceOperationMaskForLocal(boolean local) {
log.debug("draggingSourceOperationMaskForLocal:" + local);
if (local)
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
return NSDraggingInfo.DragOperationCopy;
}
/**
* @return the names (not full paths) of the files that the receiver promises to create at dropDestination.
* This method is invoked when the drop has been accepted by the destination and the destination, in the case of another
@@ -301,15 +289,4 @@ public class CDBrowserListViewModel extends CDBrowserTableDataSource {
}
return promisedDragNames;
}
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if (row < this.childs(this.controller.workdir()).size()) {
Path p = (Path) this.childs(this.controller.workdir()).get(row);
return p.getAbsolute() + "\n"
+ Status.getSizeAsString(p.attributes.getSize()) + "\n"
+ p.attributes.getTimestampAsString();
}
return null;
}
}
+229 -202
View File
@@ -25,220 +25,247 @@ import org.apache.log4j.Logger;
import ch.cyberduck.core.*;
import java.util.Iterator;
/**
* @version $Id$
*/
public class CDBrowserMatrix extends NSMatrix {
private static Logger log = Logger.getLogger(CDBrowserMatrix.class);
private static Logger log = Logger.getLogger(CDBrowserMatrix.class);
public CDBrowserMatrix() {
super();
public CDBrowserMatrix() {
this.init();
}
public CDBrowserMatrix(NSRect frameRect) {
super(frameRect);
this.init();
}
public CDBrowserMatrix(NSRect frameRect, int mode, NSCell cell, int numRows, int numColumns) {
super(frameRect, mode, cell, numRows, numColumns);
this.init();
}
public CDBrowserMatrix(NSRect frameRect, int mode, Class clazz, int numRows, int numColumns) {
super(frameRect, mode, clazz, numRows, numColumns);
this.init();
}
private void init() {
// receive drag events from types
// this.registerForDraggedTypes(new NSArray(new Object[]{
// "QueuePboardType",
// NSPasteboard.FilenamesPboardType, //accept files dragged from the Finder for uploading
// NSPasteboard.FilesPromisePboardType} //accept file promises made myself but then interpret them as QueuePboardType
// ));
}
public NSSize cellSize() {
return new NSSize(super.cellSize().width(), CDBrowserCell.HEIGHT);
}
public CDBrowserMatrix(NSRect frameRect) {
super(frameRect);
this.init();
}
public NSSize intercellSpacing() {
return NSSize.ZeroSize;
}
// Dropping files onto the browser
public CDBrowserMatrix(NSRect frameRect, int mode, NSCell cell, int numRows, int numColumns) {
super(frameRect, mode, cell, numRows, numColumns);
this.init();
}
public int draggingEntered (NSDraggingInfo info) {
log.debug("draggingEntered");
return this.draggingEnteredOrUpdated(info);
}
public int draggingUpdated(NSDraggingInfo info) {
log.debug("draggingUpdated");
return this.draggingEnteredOrUpdated(info);
}
private int draggingEnteredOrUpdated(NSDraggingInfo info) {
this.deselectAllCells();
NSPoint location = this.convertPointFromView(this.window().mouseLocationOutsideOfEventStream(),
null);
int row = this.rowForPoint(location); int col = this.columnForPoint(location);
if(this.cellAtLocation(row, col) != null) {
CDBrowserCell cell = (CDBrowserCell)this.cellAtLocation(row, col);
Path selected = cell.getPath();
if(selected.attributes.isDirectory()) {
this.selectCellAtLocation(row, col);
return NSDraggingInfo.DragOperationCopy;
}
}
public CDBrowserMatrix(NSRect frameRect, int mode, Class clazz, int numRows, int numColumns) {
super(frameRect, mode, clazz, numRows, numColumns);
this.init();
}
private void init() {
this.registerForDraggedTypes(new NSArray(new Object[]{
"QueuePboardType",
NSPasteboard.FilenamesPboardType, //accept files dragged from the Finder for uploading
NSPasteboard.FilesPromisePboardType} //accept file promises made myself but then interpret them as QueuePboardType
));
this.setCellSize(new NSSize(super.cellSize().width(), CDBrowserCell.HEIGHT));
}
public NSSize cellSize() {
return new NSSize(super.cellSize().width(), CDBrowserCell.HEIGHT);
}
public NSSize intercellSpacing() {
return NSSize.ZeroSize;
}
public int draggingEntered (NSDraggingInfo info) {
return this.draggingEnteredOrUpdated(info);
}
public int draggingUpdated(NSDraggingInfo info) {
return this.draggingEnteredOrUpdated(info);
}
private int draggingEnteredOrUpdated(NSDraggingInfo info) {
this.deselectAllCells();
NSPoint location = this.convertPointFromView(this.window().mouseLocationOutsideOfEventStream(),
null);
int row = this.rowForPoint(location);
int col = this.columnForPoint(location);
if(this.cellAtLocation(row, col) != null) {
CDBrowserCell cell = (CDBrowserCell)this.cellAtLocation(row, col);
Path selected = cell.getPath();
if(selected.attributes.isDirectory()) {
this.selectCellAtLocation(row, col);
return NSDraggingInfo.DragOperationCopy;
}
}
return NSDraggingInfo.DragOperationNone;
}
public void draggingEnded(NSDraggingInfo info) {
this.deselectAllCells();
}
public void draggingExited(NSDraggingInfo info) {
this.deselectAllCells();
}
public boolean prepareForDragOperation(NSDraggingInfo info) {
return true;
}
public boolean performDragOperation(NSDraggingInfo info) {
log.debug("performDragOperation");
NSPoint location = this.convertPointFromView(this.window().mouseLocationOutsideOfEventStream(),
null);
int row = this.rowForPoint(location); int col = this.columnForPoint(location);
if(this.cellAtLocation(row, col) != null) {
CDBrowserCell cell = (CDBrowserCell)this.cellAtLocation(row, col);
Path selected = cell.getPath();
NSPasteboard infoPboard = info.draggingPasteboard();
if (infoPboard.availableTypeFromArray(new NSArray(NSPasteboard.FilenamesPboardType)) != null) {
NSArray filesList = (NSArray) infoPboard.propertyListForType(NSPasteboard.FilenamesPboardType);
Queue q = new UploadQueue(); //todo set browser as observer
Session session = selected.getSession().copy();
for (int i = 0; i < filesList.count(); i++) {
log.debug("Filename:"+filesList.objectAtIndex(i));
Path p = PathFactory.createPath(session,
selected.getAbsolute(),
new Local((String) filesList.objectAtIndex(i)));
q.addRoot(p);
}
if (q.numberOfRoots() > 0) {
CDQueueController.instance().startItem(q);
return true;
}
}
// else {
// NSPasteboard pboard = NSPasteboard.pasteboardWithName("QueuePBoard");
// log.debug("availableTypeFromArray:QueuePBoardType: " + pboard.availableTypeFromArray(new NSArray("QueuePBoardType")));
// if (pboard.availableTypeFromArray(new NSArray("QueuePBoardType")) != null) {
// NSArray elements = (NSArray) pboard.propertyListForType("QueuePBoardType");
// for (int i = 0; i < elements.count(); i++) {
// NSDictionary dict = (NSDictionary) elements.objectAtIndex(i);
// if (selected.attributes.isDirectory()) {
// Queue q = Queue.createQueue(dict);
// for (Iterator iter = q.getRoots().iterator(); iter.hasNext();) {
// Path p = (Path) iter.next();
// p.rename(selected.getAbsolute() + "/" + p.getName());
// }
// return true;
// }
// }
// }
// }
}
return false;
}
// Dragging files outside of browser
}
private Path promisedFile = null;
public void mouseDown(NSEvent event) {
if(event.clickCount() == 1) {
NSEvent next = NSApplication.sharedApplication().nextEventMatchingMask(NSEvent.LeftMouseUpMask | NSEvent.LeftMouseDraggedMask,
(NSDate)NSDate.distantFuture(), //why does this declare Object?
NSApplication.EventTrackingRunLoopMode,
false); //remove event from queue
if(next.type() == 6) { //NSEvent.LeftMouseDraggedMask
NSPoint location = this.convertPointFromView(this.window().mouseLocationOutsideOfEventStream(),
null);
int row = this.rowForPoint(location); int col = this.columnForPoint(location);
if(this.cellAtLocation(row, col) != null) {
CDBrowserCell cell = (CDBrowserCell)this.cellAtLocation(row, col);
this.promisedFile = cell.getPath();
public void draggingEnded(NSDraggingInfo info) {
this.deselectAllCells();
}
NSMutableArray fileTypes = new NSMutableArray();
// Queue q = new DownloadQueue();
if (this.promisedFile.attributes.isFile()) {
if (this.promisedFile.getExtension() != null) {
fileTypes.addObject(this.promisedFile.getExtension());
}
else {
fileTypes.addObject(NSPathUtilities.FileTypeRegular);
}
}
else if (this.promisedFile.attributes.isDirectory()) {
fileTypes.addObject("'fldr'");
}
else {
fileTypes.addObject(NSPathUtilities.FileTypeUnknown);
}
// q.addRoot(this.promisedFile);
// Writing data for private use when the item gets dragged to the transfer queue.
// NSPasteboard queuePboard = NSPasteboard.pasteboardWithName("QueuePBoard");
// queuePboard.declareTypes(new NSArray("QueuePBoardType"), null);
// if (queuePboard.setPropertyListForType(new NSArray(q.getAsDictionary()), "QueuePBoardType")) {
// log.debug("QueuePBoardType data sucessfully written to pasteboard");
public void draggingExited(NSDraggingInfo info) {
this.deselectAllCells();
}
public boolean prepareForDragOperation(NSDraggingInfo info) {
return true;
}
public boolean performDragOperation(NSDraggingInfo info) {
log.debug("performDragOperation");
NSPoint location = this.convertPointFromView(this.window().mouseLocationOutsideOfEventStream(),
null);
int row = this.rowForPoint(location); int col = this.columnForPoint(location);
if(this.cellAtLocation(row, col) != null) {
CDBrowserCell cell = (CDBrowserCell)this.cellAtLocation(row, col);
Path selected = cell.getPath();
NSPasteboard infoPboard = info.draggingPasteboard();
if (infoPboard.availableTypeFromArray(new NSArray(NSPasteboard.FilenamesPboardType)) != null) {
NSArray filesList = (NSArray) infoPboard.propertyListForType(NSPasteboard.FilenamesPboardType);
Queue q = new UploadQueue(); //todo set browser as observer
Session session = selected.getSession().copy();
for (int i = 0; i < filesList.count(); i++) {
log.debug("Filename:"+filesList.objectAtIndex(i));
Path p = PathFactory.createPath(session,
selected.getAbsolute(),
new Local((String) filesList.objectAtIndex(i)));
q.addRoot(p);
}
if (q.numberOfRoots() > 0) {
CDQueueController.instance().startItem(q);
return true;
}
}
else {
NSPasteboard pboard = NSPasteboard.pasteboardWithName("QueuePBoard");
log.debug("availableTypeFromArray:QueuePBoardType: " + pboard.availableTypeFromArray(new NSArray("QueuePBoardType")));
if (pboard.availableTypeFromArray(new NSArray("QueuePBoardType")) != null) {
NSArray elements = (NSArray) pboard.propertyListForType("QueuePBoardType");// get the data from pasteboard
for (int i = 0; i < elements.count(); i++) {
NSDictionary dict = (NSDictionary) elements.objectAtIndex(i);
if (selected.attributes.isDirectory()) {
Queue q = Queue.createQueue(dict);
for (Iterator iter = q.getRoots().iterator(); iter.hasNext();) {
Path p = PathFactory.createPath(selected.getSession(), ((Path) iter.next()).getAbsolute());
p.rename(selected.getAbsolute()+Path.DELIMITER+p.getName());
}
//todo
// this.controller.workdir().list(true, this.controller.getEncoding(),
// controller.getFileComparator(), controller.getFileFilter());
}
}
return true;
}
}
}
return false;
}
/**
* The files dragged from the browser to the Finder
*/
private Path[] promisedDragPaths;
public void mouseDown(NSEvent event) {
if(event.clickCount() == 1) {
NSEvent next = NSApplication.sharedApplication().nextEventMatchingMask(NSEvent.LeftMouseUpMask | NSEvent.LeftMouseDraggedMask,
(NSDate)NSDate.distantFuture(), //why does this declare Object?
NSApplication.EventTrackingRunLoopMode,
false); //remove event from queue
if(next.type() == NSEvent.LeftMouseDragged) {
NSPoint location = this.convertPointFromView(event.locationInWindow(), null);
int row = this.rowForPoint(location);
int col = this.columnForPoint(location);
NSMutableArray fileTypes = new NSMutableArray();
if(this.cellAtLocation(row, col) != null) {
if(this.selectedCells() != null) {
Queue q = new DownloadQueue();
Session session = null;
NSArray selectedCells = this.selectedCells();
java.util.Enumeration iterator = selectedCells.objectEnumerator();
this.promisedDragPaths = new Path[selectedCells.count()];
for (int i = 0; iterator.hasMoreElements(); i++) {
Path p = ((CDBrowserCell)iterator.nextElement()).getPath();
if(null == session) {
session = p.getSession().copy();
}
promisedDragPaths[i] = p.copy(session);
if (promisedDragPaths[i].attributes.isFile()) {
if (promisedDragPaths[i].getExtension() != null) {
fileTypes.addObject(promisedDragPaths[i].getExtension());
}
else {
fileTypes.addObject(NSPathUtilities.FileTypeRegular);
}
}
else if (promisedDragPaths[i].attributes.isDirectory()) {
fileTypes.addObject("'fldr'");
}
else {
fileTypes.addObject(NSPathUtilities.FileTypeUnknown);
}
q.addRoot(promisedDragPaths[i]);
}
// Writing data for private use when the item gets dragged to the transfer queue.
NSPasteboard queuePboard = NSPasteboard.pasteboardWithName("QueuePBoard");
queuePboard.declareTypes(new NSArray("QueuePBoardType"), null);
if (queuePboard.setPropertyListForType(new NSArray(q.getAsDictionary()), "QueuePBoardType")) {
log.debug("QueuePBoardType data sucessfully written to pasteboard");
}
NSRect imageRect = new NSRect(new NSPoint(location.x() - 16, location.y() - 16),
new NSSize(32, 32));
this.dragPromisedFilesOfTypes(fileTypes, imageRect, this, true, event);
return;
}
}
}
}
super.mouseDown(event);
}
// @see http://www.cocoabuilder.com/archive/message/2005/10/5/118857
public void finishedDraggingImage(NSImage image, NSPoint point, int operation) {
log.debug("finishedDraggingImage:" + operation);
NSPasteboard.pasteboardWithName(NSPasteboard.DragPboard).declareTypes(null, null);
}
public int draggingSourceOperationMaskForLocal(boolean local) {
log.debug("draggingSourceOperationMaskForLocal:" + local);
if (local)
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
return NSDraggingInfo.DragOperationCopy;
}
public NSArray namesOfPromisedFilesDroppedAtDestination(java.net.URL dropDestination) {
log.debug("namesOfPromisedFilesDroppedAtDestination:" + dropDestination);
NSMutableArray promisedDragNames = new NSMutableArray();
if (null != dropDestination) {
Queue q = new DownloadQueue();
for (int i = 0; i < this.promisedDragPaths.length; i++) {
try {
this.promisedDragPaths[i].setLocal(new Local(java.net.URLDecoder.decode(dropDestination.getPath(), "UTF-8"),
this.promisedDragPaths[i].getName()));
//this.promisedDragPaths[i].getLocal().createNewFile();
q.addRoot(this.promisedDragPaths[i]);
promisedDragNames.addObject(this.promisedDragPaths[i].getName());
}
catch (java.io.UnsupportedEncodingException e) {
log.error(e.getMessage());
}
// catch(java.io.IOException e) {
// log.error(e.getMessage());
// }
NSRect imageRect = new NSRect(new NSPoint(location.x() - 16, location.y() - 16),
new NSSize(32, 32));
this.dragPromisedFilesOfTypes(fileTypes, imageRect, this, true, event);
return;
}
}
}
super.mouseDown(event);
}
// @see http://www.cocoabuilder.com/archive/message/2005/10/5/118857
public void finishedDraggingImage(NSImage image, NSPoint point, int operation) {
log.debug("finishedDraggingImage:" + operation);
NSPasteboard.pasteboardWithName(NSPasteboard.DragPboard).declareTypes(null, null);
}
public int draggingSourceOperationMaskForLocal(boolean local) {
log.debug("draggingSourceOperationMaskForLocal:" + local);
if (local)
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
return NSDraggingInfo.DragOperationCopy;
}
public NSArray namesOfPromisedFilesDroppedAtDestination(java.net.URL dropDestination) {
log.debug("namesOfPromisedFilesDroppedAtDestination:" + dropDestination);
NSMutableArray promisedDragNames = new NSMutableArray();
if (null != dropDestination) {
Queue q = new DownloadQueue();
try {
this.promisedFile.setLocal(new Local(java.net.URLDecoder.decode(dropDestination.getPath(), "UTF-8"),
this.promisedFile.getName()));
q.addRoot(this.promisedFile);
promisedDragNames.addObject(this.promisedFile.getName());
}
catch (java.io.UnsupportedEncodingException e) {
log.error(e.getMessage());
}
if (q.numberOfRoots() > 0) {
CDQueueController.instance().startItem(q);
}
}
return promisedDragNames;
}
}
if (q.numberOfRoots() > 0) {
CDQueueController.instance().startItem(q);
}
}
return promisedDragNames;
}
public String toolTip(NSCell cell) {
if(cell instanceof CDBrowserCell) {
Path p = ((CDBrowserCell)cell).getPath();
return p.getAbsolute() + "\n"
+ Status.getSizeAsString(p.attributes.getSize()) + "\n"
+ p.attributes.getTimestampAsString();
}
return null;
}
}
@@ -30,38 +30,25 @@ import java.util.*;
* @version $Id$
*/
public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
private static Logger log = Logger.getLogger(CDBrowserOutlineViewModel.class);
private static final NSImage SYMLINK_ICON = NSImage.imageNamed("symlink.tiff");
private static final NSImage FOLDER_ICON = NSImage.imageNamed("folder16.tiff");
private static final NSImage NOT_FOUND_ICON = NSImage.imageNamed("notfound.tiff");
public CDBrowserOutlineViewModel(CDBrowserController controller) {
super(controller);
}
public void outlineViewItemDidExpand(NSNotification notification) {
Path p = (Path) notification.userInfo().allValues().lastObject();
p.getSession().cache().setExpanded(p, true);
}
public void outlineViewItemDidCollapse(NSNotification notification) {
Path p = (Path) notification.userInfo().allValues().lastObject();
p.getSession().cache().setExpanded(p, false);
}
public boolean outlineViewShouldEditTableColumn(NSOutlineView outlineView,
NSTableColumn tableColumn, Object item) {
return false;
}
public int indexOf(NSTableView tableView, Path p) {
public int indexOf(NSView tableView, Path p) {
//bug: the rowForItem method does not use p.equals() therefore only returns a valid value
//if the exact reference is passed
return ((NSOutlineView)tableView).rowForItem(p);
}
public boolean outlineViewIsItemExpandable(NSOutlineView outlineView, Path item) {
if (null == item) {
item = controller.workdir();
}
return item.attributes.isDirectory();
}
public int outlineViewNumberOfChildrenOfItem(NSOutlineView outlineView, Path item) {
if (controller.isMounted()) {
if (null == item) {
@@ -75,45 +62,6 @@ public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
return 0;
}
public boolean outlineViewIsItemExpandable(NSOutlineView outlineView, Path item) {
if (null == item) {
item = controller.workdir();
}
return item.attributes.isDirectory();
}
public void outlineViewWillDisplayCell(NSOutlineView outlineView, Object cell,
NSTableColumn tableColumn, Path item) {
String identifier = (String) tableColumn.identifier();
if (identifier.equals("FILENAME")) {
NSImage icon;
if (item.attributes.isSymbolicLink()) {
icon = SYMLINK_ICON;
}
else if (item.attributes.isDirectory()) {
icon = FOLDER_ICON;
}
else if (item.attributes.isFile()) {
icon = CDIconCache.instance().get(item.getExtension());
}
else {
icon = NOT_FOUND_ICON;
}
icon.setSize(new NSSize(16f, 16f));
((CDOutlineCell) cell).setIcon(icon);
((CDOutlineCell) cell).setAttributedStringValue(new NSAttributedString(item.getName(),
CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY));
}
if (cell instanceof NSTextFieldCell) {
if (this.controller.isConnected()) {
((NSTextFieldCell) cell).setTextColor(NSColor.controlTextColor());
}
else {
((NSTextFieldCell) cell).setTextColor(NSColor.disabledControlTextColor());
}
}
}
/**
* Invoked by outlineView, and returns the child item at the specified index. Children
* of a given parent item are accessed sequentially. If item is null, this method should
@@ -129,28 +77,38 @@ public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
return null;
}
public void outlineViewSetObjectValueForItem(NSOutlineView outlineView, Object value,
NSTableColumn tableColumn, Path p) {
String identifier = (String) tableColumn.identifier();
if (identifier.equals(FILENAME_COLUMN)) {
if(!p.getName().equals(value)) {
p.rename(value.toString());
}
}
}
public Object outlineViewObjectValueForItem(NSOutlineView outlineView, NSTableColumn tableColumn, Path item) {
if (null != item) {
String identifier = (String) tableColumn.identifier();
if (identifier.equals("FILENAME")) {
if (identifier.equals(FILENAME_COLUMN)) {
return new NSAttributedString(item.getName(), CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("TYPEAHEAD")) {
return item.getName();
}
if (identifier.equals("SIZE")) {
if (identifier.equals(SIZE_COLUMN)) {
return new NSAttributedString(Status.getSizeAsString(item.attributes.getSize()),
CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("MODIFIED")) {
if (identifier.equals(MODIFIED_COLUMN)) {
return new NSGregorianDate((double) item.attributes.getTimestamp().getTime() / 1000,
NSDate.DateFor1970);
}
if (identifier.equals("OWNER")) {
if (identifier.equals(OWNER_COLUMN)) {
return new NSAttributedString(item.attributes.getOwner(),
CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
if (identifier.equals("PERMISSIONS")) {
if (identifier.equals(PERMISSIONS_COLUMN)) {
return new NSAttributedString(item.attributes.getPermission().toString(),
CDTableCell.TABLE_CELL_PARAGRAPH_DICTIONARY);
}
@@ -238,7 +196,7 @@ public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
Queue q = Queue.createQueue(dict);
for (Iterator iter = q.getRoots().iterator(); iter.hasNext();) {
Path p = PathFactory.createPath(controller.workdir().getSession(), ((Path) iter.next()).getAbsolute());
p.rename(destination.getAbsolute() + "/" + p.getName());
p.rename(destination.getAbsolute() +Path.DELIMITER+ p.getName());
}
destination.invalidate();
NSRunLoop.currentRunLoop().addTimerForMode(new NSTimer(0.1f, controller,
@@ -304,14 +262,6 @@ public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
NSPasteboard.pasteboardWithName(NSPasteboard.DragPboard).declareTypes(null, null);
}
public int draggingSourceOperationMaskForLocal(boolean local) {
log.debug("draggingSourceOperationMaskForLocal:" + local);
if (local) {
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
}
return NSDraggingInfo.DragOperationCopy;
}
/**
* @return the names (not full paths) of the files that the receiver promises to create at dropDestination.
* This method is invoked when the drop has been accepted by the destination and the destination, in the case of another
@@ -341,15 +291,4 @@ public class CDBrowserOutlineViewModel extends CDBrowserTableDataSource {
}
return promisedDragNames;
}
public String outlineViewToolTipForCell(NSOutlineView ov, NSCell cell, NSMutableRect rect, NSTableColumn tc,
Object item, NSPoint mouseLocation) {
if (item instanceof Path) {
Path p = (Path)item;
return p.getAbsolute() + "\n"
+ Status.getSizeAsString(p.attributes.getSize()) + "\n"
+ p.attributes.getTimestampAsString();
}
return null;
}
}
@@ -24,33 +24,35 @@ import ch.cyberduck.core.Preferences;
import ch.cyberduck.core.AttributedList;
import com.apple.cocoa.application.*;
import com.apple.cocoa.foundation.NSIndexSet;
import com.apple.cocoa.foundation.NSArray;
import org.apache.log4j.Logger;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.net.URL;
/**
* @version $Id$
*/
public abstract class CDBrowserTableDataSource {//implements NSTableView.DataSource {
public abstract class CDBrowserTableDataSource {
private static Logger log = Logger.getLogger(CDBrowserTableDataSource.class);
protected static final NSImage SYMLINK_ICON = NSImage.imageNamed("symlink.tiff");
protected static final NSImage FOLDER_ICON = NSImage.imageNamed("folder16.tiff");
protected static final NSImage NOT_FOUND_ICON = NSImage.imageNamed("notfound.tiff");
public static final String TYPE_COLUMN = "TYPE";
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";
protected static final String TYPE_COLUMN = "TYPE";
protected static final String FILENAME_COLUMN = "FILENAME";
protected static final String SIZE_COLUMN = "SIZE";
protected static final String MODIFIED_COLUMN = "MODIFIED";
protected static final String OWNER_COLUMN = "OWNER";
protected static final String PERMISSIONS_COLUMN = "PERMISSIONS";
protected AttributedList childs(Path path) {
return path.list(false, controller.getEncoding(), false,
this.getComparator(), controller.getFileFilter());
controller.getComparator(), controller.getFileFilter());
}
protected CDBrowserController controller;
@@ -59,114 +61,7 @@ public abstract class CDBrowserTableDataSource {//implements NSTableView.DataSou
this.controller = controller;
}
// ----------------------------------------------------------
// Sorting
// ----------------------------------------------------------
private Boolean sortAscending;
protected void setSortedAscending(boolean sortAscending) {
//cache custom sorting preference
this.sortAscending = Boolean.valueOf(sortAscending);
//set default value
Preferences.instance().setProperty("browser.sort.ascending", sortAscending);
}
protected boolean isSortedAscending() {
if (null == this.sortAscending) {
//return default value
return Preferences.instance().getBoolean("browser.sort.ascending");
}
return this.sortAscending.booleanValue();
}
private NSTableColumn selectedColumn;
private void setSelectedColumn(NSTableColumn selectedColumn) {
this.selectedColumn = selectedColumn;
//set default value
Preferences.instance().setProperty("browser.sort.column", this.selectedColumnIdentifier());
}
protected String selectedColumnIdentifier() {
if (null == this.selectedColumn) {
//return default value
return Preferences.instance().getProperty("browser.sort.column");
}
//return previously set custom sorting preference
return (String) this.selectedColumn.identifier();
}
public void sort(List files) {
if (files != null) {
Collections.sort(files, this.getComparator());
}
}
public Comparator getComparator() {
final boolean ascending = this.isSortedAscending();
String identifier = this.selectedColumnIdentifier();
if (identifier.equals(TYPE_COLUMN)) {
return new FileTypeComparator(ascending);
}
else if (identifier.equals(FILENAME_COLUMN)) {
return new FilenameComparator(ascending);
}
else if (identifier.equals(SIZE_COLUMN)) {
return new SizeComparator(ascending);
}
else if (identifier.equals(MODIFIED_COLUMN)) {
return new TimestampComparator(ascending);
}
else if (identifier.equals(OWNER_COLUMN)) {
return new OwnerComparator(ascending);
}
else if (identifier.equals(PERMISSIONS_COLUMN)) {
return new PermissionsComparator(ascending);
}
log.error("Unknown column identifier:" + identifier);
return null;
}
// ----------------------------------------------------------
// TableView/OutlineView Delegate methods
// ----------------------------------------------------------
public boolean selectionShouldChangeInTableView(NSTableView tableView) {
return true;
}
public boolean selectionShouldChangeInOutlineView(NSTableView tableView) {
return true;
}
public void outlineViewDidClickTableColumn(NSOutlineView tableView, NSTableColumn tableColumn) {
this.tableViewDidClickTableColumn(tableView, tableColumn);
}
public void tableViewDidClickTableColumn(NSOutlineView tableView, NSTableColumn tableColumn) {
List selected = controller.getSelectedPaths();
if (this.selectedColumnIdentifier().equals(tableColumn.identifier())) {
this.setSortedAscending(!this.isSortedAscending());
}
else {
tableView.setIndicatorImage(null, tableView.tableColumnWithIdentifier(this.selectedColumnIdentifier()));
this.setSelectedColumn(tableColumn);
}
tableView.setIndicatorImage(this.isSortedAscending() ?
NSImage.imageNamed("NSAscendingSortIndicator") :
NSImage.imageNamed("NSDescendingSortIndicator"),
tableColumn);
tableView.deselectAll(null);
tableView.reloadData();
for (Iterator i = selected.iterator(); i.hasNext();) {
tableView.selectRowIndexes(new NSIndexSet(this.indexOf(tableView, (Path)i.next())), true);
}
}
public int indexOf(NSTableView tableView, Path p) {
public int indexOf(NSView tableView, Path p) {
return this.childs(controller.workdir()).indexOf(p);
}
@@ -174,27 +69,6 @@ public abstract class CDBrowserTableDataSource {//implements NSTableView.DataSou
return this.childs(controller.workdir()).contains(p);
}
/**
* Returns true to permit aTableView to select the row at rowIndex, false to deny permission.
* The delegate can implement this method to disallow selection of particular rows.
*/
public boolean tableViewShouldSelectRow(NSTableView aTableView, int rowIndex) {
return true;
}
public boolean outlineViewShouldSelectItem(NSOutlineView outlineView, Object item) {
return true;
}
/**
* Returns true to permit aTableView to edit the cell at rowIndex in aTableColumn, false to deny permission.
* The delegate can implemen this method to disallow editing of specific cells.
*/
public boolean tableViewShouldEditLocation(NSTableView view, NSTableColumn tableColumn, int row) {
return false;
}
// ----------------------------------------------------------
// NSDraggingSource
// ----------------------------------------------------------
@@ -204,138 +78,9 @@ public abstract class CDBrowserTableDataSource {//implements NSTableView.DataSou
}
public int draggingSourceOperationMaskForLocal(boolean local) {
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
log.debug("draggingSourceOperationMaskForLocal:" + local);
if (local)
return NSDraggingInfo.DragOperationMove | NSDraggingInfo.DragOperationCopy;
return NSDraggingInfo.DragOperationCopy;
}
private class FileTypeComparator extends BrowserComparator {
public FileTypeComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
Path p1 = (Path) o1;
Path p2 = (Path) o2;
if (p1.attributes.isDirectory() && p2.attributes.isDirectory()) {
return 0;
}
if (p1.attributes.isFile() && p2.attributes.isFile()) {
return 0;
}
if (p1.attributes.isFile()) {
return ascending ? 1 : -1;
}
return ascending ? -1 : 1;
}
public String toString() {
return TYPE_COLUMN;
}
}
private class FilenameComparator extends BrowserComparator {
public FilenameComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
Path p1 = (Path) o1;
Path p2 = (Path) o2;
if (ascending) {
return p1.getName().compareToIgnoreCase(p2.getName());
}
return -p1.getName().compareToIgnoreCase(p2.getName());
}
public String toString() {
return FILENAME_COLUMN;
}
}
private class SizeComparator extends BrowserComparator {
public SizeComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
double p1 = ((Path) o1).attributes.getSize();
double p2 = ((Path) o2).attributes.getSize();
if (p1 > p2) {
return ascending ? 1 : -1;
}
else if (p1 < p2) {
return ascending ? -1 : 1;
}
return 0;
}
public String toString() {
return SIZE_COLUMN;
}
}
private class TimestampComparator extends BrowserComparator {
public TimestampComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
Path p1 = (Path) o1;
Path p2 = (Path) o2;
if (ascending) {
return p1.attributes.getTimestamp().compareTo(p2.attributes.getTimestamp());
}
return -p1.attributes.getTimestamp().compareTo(p2.attributes.getTimestamp());
}
public String toString() {
return MODIFIED_COLUMN;
}
}
private class OwnerComparator extends BrowserComparator {
public OwnerComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
Path p1 = (Path) o1;
Path p2 = (Path) o2;
if (ascending) {
return p1.attributes.getOwner().compareToIgnoreCase(p2.attributes.getOwner());
}
return -p1.attributes.getOwner().compareToIgnoreCase(p2.attributes.getOwner());
}
public String toString() {
return TYPE_COLUMN;
}
}
private class PermissionsComparator extends BrowserComparator {
public PermissionsComparator(boolean ascending) {
super(ascending);
}
public int compare(Object o1, Object o2) {
int p1 = Integer.parseInt(((Path) o1).attributes.getPermission().getOctalCode());
int p2 = Integer.parseInt(((Path) o2).attributes.getPermission().getOctalCode());
if (p1 > p2) {
return ascending ? 1 : -1;
}
else if (p1 < p2) {
return ascending ? -1 : 1;
}
return 0;
}
public String toString() {
return PERMISSIONS_COLUMN;
}
}
}
}
@@ -47,9 +47,9 @@ public class CDConnectionController extends CDWindowController {
this.bookmarksPopup = bookmarksPopup;
this.bookmarksPopup.setImage(NSImage.imageNamed("bookmarks.tiff"));
this.bookmarksPopup.setToolTip(NSBundle.localizedString("Bookmarks", ""));
Iterator i = CDBookmarkTableDataSource.instance().iterator();
while(i.hasNext()) {
bookmarksPopup.addItem(i.next().toString());
Iterator iter = CDBookmarkTableDataSource.instance().iterator();
while(iter.hasNext()) {
bookmarksPopup.addItem(iter.next().toString());
}
this.bookmarksPopup.setTarget(this);
this.bookmarksPopup.setAction(new NSSelector("bookmarksPopupSelectionChanged", new Class[]{Object.class}));
@@ -91,7 +91,6 @@ public class CDConnectionController extends CDWindowController {
this.bookmarkSelectionDidChange((Host)history.get(index));
}
private Rendezvous rendezvous;
private Observer observer;
private NSPopUpButton rendezvousPopup;
@@ -109,8 +108,7 @@ public class CDConnectionController extends CDWindowController {
this.rendezvousPopup.setToolTip("Bonjour");
this.rendezvousPopup.setTarget(this);
this.rendezvousPopup.setAction(new NSSelector("rendezvousSelectionDidChange", new Class[]{Object.class}));
this.rendezvous = Rendezvous.instance();
this.rendezvous.addObserver(this.observer = new Observer() {
Rendezvous.instance().addObserver(this.observer = new Observer() {
public void update(final Observable o, final Object arg) {
log.debug("update:"+o+","+arg);
CDConnectionController.this.invoke(new Runnable() {
@@ -130,14 +128,14 @@ public class CDConnectionController extends CDWindowController {
});
}
});
String[] cachedServices = this.rendezvous.getServices();
String[] cachedServices = Rendezvous.instance().getServices();
for(int i = 0; i < cachedServices.length; i++) {
this.addItemToRendezvousPopup(cachedServices[i]);
}
}
public void rendezvousSelectionDidChange(Object sender) {
this.bookmarkSelectionDidChange((Host)rendezvous.getService(rendezvousPopup.titleOfSelectedItem()));
this.bookmarkSelectionDidChange((Host)Rendezvous.instance().getService(rendezvousPopup.titleOfSelectedItem()));
}
private NSPopUpButton protocolPopup;
@@ -173,21 +171,21 @@ public class CDConnectionController extends CDWindowController {
}
private NSComboBox hostPopup;
private Object quickConnectDataSource;
private Object hostPopupDataSource;
public void setHostPopup(NSComboBox hostPopup) {
this.hostPopup = hostPopup;
this.hostPopup.setTarget(this);
this.hostPopup.setAction(new NSSelector("hostSelectionDidChange", new Class[]{Object.class}));
this.hostPopup.setUsesDataSource(true);
this.hostPopup.setDataSource(this.quickConnectDataSource = new Object() {
this.hostPopup.setDataSource(this.hostPopupDataSource = new Object() {
public int numberOfItemsInComboBox(NSComboBox combo) {
return CDBookmarkTableDataSource.instance().size();
}
public Object comboBoxObjectValueForItemAtIndex(NSComboBox combo, int row) {
if(row < this.numberOfItemsInComboBox(combo)) {
return ((Host)CDBookmarkTableDataSource.instance().get(row)).getHostname();
return ((Host) CDBookmarkTableDataSource.instance().get(row)).getHostname();
}
return null;
}
@@ -230,6 +228,20 @@ public class CDConnectionController extends CDWindowController {
this.portField = portField;
}
public void portFieldTextDidChange(Object sender) {
if(null == this.portField.stringValue() || this.portField.stringValue().equals("")) {
if(protocolPopup.selectedItem().title().equals(Session.SFTP_STRING)) {
this.portField.setStringValue(""+Session.SSH_PORT);
}
if(protocolPopup.selectedItem().title().equals(Session.FTP_STRING)) {
this.portField.setStringValue(""+Session.FTP_PORT);
}
if(protocolPopup.selectedItem().title().equals(Session.FTP_TLS_STRING)) {
this.portField.setStringValue(""+Session.FTP_PORT);
}
}
}
private NSTextField usernameField;
public void setUsernameField(NSTextField usernameField) {
@@ -394,6 +406,7 @@ public class CDConnectionController extends CDWindowController {
public void windowWillClose(NSNotification notification) {
NSNotificationCenter.defaultCenter().removeObserver(this);
Rendezvous.instance().deleteObserver(this.observer);
instances.removeObject(this);
}
@@ -401,37 +414,41 @@ public class CDConnectionController extends CDWindowController {
super.awakeFromNib();
this.window().setReleasedWhenClosed(true);
// Notify the updateURLLabel() method if the user types.
//ControlTextDidChangeNotification
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("updateURLLabel", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
hostPopup);
this.hostPopup);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("hostFieldTextDidChange", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
hostPopup);
this.hostPopup);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("updateURLLabel", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
pathField);
this.pathField);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("updateURLLabel", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
portField);
this.portField);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("portFieldTextDidChange", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
this.portField);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("updateURLLabel", new Class[]{Object.class}),
NSControl.ControlTextDidChangeNotification,
usernameField);
this.usernameField);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("getPasswordFromKeychain", new Class[]{Object.class}),
NSControl.ControlTextDidEndEditingNotification,
hostPopup);
this.hostPopup);
NSNotificationCenter.defaultCenter().addObserver(this,
new NSSelector("getPasswordFromKeychain", new Class[]{Object.class}),
NSControl.ControlTextDidEndEditingNotification,
usernameField);
this.usernameField);
this.usernameField.setStringValue(Preferences.instance().getProperty("connection.login.name"));
if(Preferences.instance().getProperty("connection.protocol.default").equals(Session.FTP)) {
@@ -457,7 +474,7 @@ public class CDConnectionController extends CDWindowController {
public void getPasswordFromKeychain(Object sender) {
if(hostPopup.stringValue() != null && !hostPopup.stringValue().equals("") &&
usernameField.stringValue() != null && !usernameField.stringValue().equals("")) {
String protocol = null;
String protocol = Preferences.instance().getProperty("connection.protocol.default");
if(protocolPopup.selectedItem().title().equals(Session.SFTP_STRING)) {
protocol = Session.SFTP;
}
@@ -467,14 +484,7 @@ public class CDConnectionController extends CDWindowController {
else if(protocolPopup.selectedItem().title().equals(Session.FTP_TLS_STRING)) {
protocol = Session.FTP_TLS;
}
else {
protocol = Preferences.instance().getProperty("connection.protocol.default");
}
Login l = new Login(new Host(protocol,
hostPopup.stringValue(),
Integer.parseInt(portField.stringValue())),
usernameField.stringValue(),
null);
Login l = new Login(hostPopup.stringValue(), protocol, usernameField.stringValue(), null);
String passFromKeychain = l.getInternetPasswordFromKeychain();
if(null == passFromKeychain || passFromKeychain.equals("")) {
passFromKeychain = l.getPasswordFromKeychain(); //legacy support
@@ -484,7 +494,7 @@ public class CDConnectionController extends CDWindowController {
this.passField.setStringValue(passFromKeychain);
}
else {
log.info("Password for "+usernameField.stringValue()+" NOT found in Keychain");
log.info("Password for "+usernameField.stringValue()+" *not* found in Keychain");
this.passField.setStringValue("");
}
}
@@ -537,8 +547,6 @@ public class CDConnectionController extends CDWindowController {
public void connectionSheetDidEnd(NSWindow sheet, int returncode, Object contextInfo) {
sheet.orderOut(null);
NSNotificationCenter.defaultCenter().removeObserver(this);
this.rendezvous.deleteObserver(this.observer);
switch(returncode) {
case (NSAlertPanel.DefaultReturn):
Host host = null;
@@ -90,9 +90,9 @@ public class CDCreateFileController extends CDFileController {
}
List l = null;
if(filename.charAt(0) == '.')
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
else
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
if(l.contains(file))
return (Path)l.get(l.indexOf(file));
return null;
@@ -89,9 +89,9 @@ public class CDDuplicateFileController extends CDFileController {
p.upload();
List l = null;
if(filename.charAt(0) == '.')
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
else
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
if(l.contains(p))
return (Path)l.get(l.indexOf(p));
return null;
@@ -106,9 +106,9 @@ public class CDFolderController extends CDWindowController {
folder.mkdir(false);
List l = null;
if(filename.charAt(0) == '.')
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
else
l = workdir.list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
l = workdir.list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
if(l.contains(folder))
return (Path)l.get(l.indexOf(folder));
return null;
@@ -55,7 +55,7 @@ public class CDGotoController extends CDWindowController {
{
for(Iterator i = controller.workdir().list(false, controller.getEncoding(),
controller.getFileComparator(), controller.getFileFilter()).iterator(); i.hasNext(); ) {
controller.getComparator(), controller.getFileFilter()).iterator(); i.hasNext(); ) {
Path p = (Path)i.next();
if(p.attributes.isDirectory()) {
directories.add(p.getName());
@@ -124,6 +124,6 @@ public class CDGotoController extends CDWindowController {
else {
dir.setPath(filename);
}
dir.list(false, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
dir.list(false, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
}
}
+8 -9
View File
@@ -21,6 +21,8 @@ package ch.cyberduck.ui.cocoa;
import com.apple.cocoa.application.NSImage;
import com.apple.cocoa.application.NSView;
import com.apple.cocoa.application.NSWorkspace;
import com.apple.cocoa.application.NSText;
import com.apple.cocoa.application.NSEvent;
import com.apple.cocoa.foundation.NSCoder;
import com.apple.cocoa.foundation.NSPoint;
import com.apple.cocoa.foundation.NSRect;
@@ -70,13 +72,16 @@ public class CDIconCell extends CDTableCell {
notFoundIcon.setSize(new NSSize(32f, 32f));
}
public void drawInteriorWithFrameInView(NSRect cellFrame, NSView controlView) {
public void editWithFrameInView(NSRect nsRect, NSView nsView, NSText nsText, Object object, NSEvent nsEvent) {
super.editWithFrameInView(nsRect, nsView, nsText, object, nsEvent);
}
public void drawInteriorWithFrameInView(NSRect cellFrame, NSView controlView) {
if(queue != null) {
NSPoint cellPoint = cellFrame.origin();
NSSize cellSize = cellFrame.size();
// drawing file icon
NSImage fileIcon = null;
NSImage fileIcon = notFoundIcon;
NSImage arrowIcon = null;
if(queue instanceof DownloadQueue) {
@@ -100,16 +105,10 @@ public class CDIconCell extends CDTableCell {
if(queue.getRoot().getLocal().exists()) {
fileIcon = NSWorkspace.sharedWorkspace().iconForFileType(queue.getRoot().getExtension());
}
else {
fileIcon = notFoundIcon;
}
}
else if(queue.getRoot().getLocal().isDirectory()) {
fileIcon = folderIcon;
}
else {
fileIcon = notFoundIcon;
}
}
else {
fileIcon = multipleDocumentsIcon;
@@ -335,8 +335,8 @@ public class CDInfoController extends CDWindowController {
final Path file = (Path)this.files.get(0);
if(!this.filenameField.stringValue().equals(file.getName())) {
if(this.filenameField.stringValue().indexOf('/') == -1) {
file.rename(file.getParent().getAbsolute()+"/"+this.filenameField.stringValue());
controller.workdir().list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
file.rename(file.getParent().getAbsolute()+Path.DELIMITER+this.filenameField.stringValue());
controller.workdir().list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
}
else if(filenameField.stringValue().length() == 0) {
this.filenameField.setStringValue(file.getName());
@@ -393,6 +393,6 @@ public class CDInfoController extends CDWindowController {
f.changePermissions(permission,
this.recursiveCheckbox.state() == NSCell.OnState);
}
controller.workdir().list(true, controller.getEncoding(), controller.getFileComparator(), controller.getFileFilter());
controller.workdir().list(true, controller.getEncoding(), controller.getComparator(), controller.getFileFilter());
}
}
@@ -19,6 +19,12 @@
#import <Cocoa/Cocoa.h>
@interface CDListView : NSTableView {
@private
BOOL mBrowserWasDoubleClicked;
int mBrowserEditingColumn;
int mBrowserEditingRow;
NSMutableString *select_string;
NSTimer *select_timer;
}
+74 -14
View File
@@ -28,6 +28,11 @@
- (void)awakeFromNib
{
[self setTarget:self];
[self setAction:@selector(handleBrowserClick:)];
[self setDoubleAction:@selector(handleBrowserDoubleClick:)];
// browser typeahead selection
select_string = [[NSMutableString alloc] init];
select_timer = nil;
}
@@ -44,16 +49,71 @@
[super dealloc];
}
- (void)handleBrowserClick:(id)sender {
mBrowserWasDoubleClicked = NO;
NSPoint where = [self convertPoint:[[NSApp currentEvent] locationInWindow] fromView:nil];
int row = [self rowAtPoint:where];
int col = [self columnAtPoint:where];
if(row >= 0 && col >= 0) {
NSTableColumn *column = [[self tableColumns] objectAtIndex:col];
if([[self delegate] respondsToSelector:@selector(isColumnEditable:)]) {
if([[self delegate] isColumnEditable:column]) {
mBrowserEditingColumn = col;
mBrowserEditingRow = row;
NSValue *wrappedMouseLocation = [NSValue valueWithPoint:[NSEvent mouseLocation]];
[self performSelector:@selector(handleBrowserClickOffloaded:) withObject:wrappedMouseLocation afterDelay:0.5];
}
}
else {
NSLog(@"WARN: Tableview delegate does not respond to isColumnEditable:");
}
}
}
- (void)handleBrowserClickOffloaded:(NSValue *)inWrappedMouseLocation {
// UI: mouse must not have ben moved since first click, and must not have been double-clicked
if((!mBrowserWasDoubleClicked) && (NSEqualPoints([inWrappedMouseLocation pointValue], [NSEvent mouseLocation])) ) {
if(mBrowserEditingRow == [self selectedRow])
[self editColumn:mBrowserEditingColumn row:mBrowserEditingRow withEvent:nil select:YES];
}
mBrowserWasDoubleClicked = NO;
}
- (void)handleBrowserDoubleClick:(id)sender {
mBrowserWasDoubleClicked = YES;
if([self clickedRow] != -1) { // make sure double click was not in table header
if ([[self delegate] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self delegate] performSelector:@selector(enterKeyPressed:) withObject:self];
}
}
}
// make return and tab only end editing, and not cause other cells to edit
// Taken from http://borkware.com/quickies/one?topic=NSTableView
- (void) textDidEndEditing: (NSNotification *) notification
{
int textMovement = [[[notification userInfo] valueForKey:@"NSTextMovement"] intValue];
if (textMovement == NSReturnTextMovement || textMovement == NSTabTextMovement || textMovement == NSBacktabTextMovement) {
NSMutableDictionary *newInfo;
newInfo = [NSMutableDictionary dictionaryWithDictionary: [notification userInfo]];
[newInfo setObject: [NSNumber numberWithInt: NSIllegalTextMovement] forKey: @"NSTextMovement"];
notification = [NSNotification notificationWithName: [notification name]
object: [notification object]
userInfo: newInfo];
[super textDidEndEditing: notification];
[[self window] makeFirstResponder:self];
}
else {
[super textDidEndEditing: notification];
}
}
// Taken from http://www.cocoadev.com/index.pl?RightClickSelectInTableView
- (NSMenu *) menuForEvent:(NSEvent *) event
{
NSPoint where;
int row = -1, col = -1;
where = [self convertPoint:[event locationInWindow] fromView:nil];
row = [self rowAtPoint:where];
col = [self columnAtPoint:where];
NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
int row = [self rowAtPoint:where];
int col = [self columnAtPoint:where];
if(row >= 0) {
NSTableColumn *column = nil;
if(col >= 0) {
@@ -78,16 +138,16 @@
char key = [str length] ? [str characterAtIndex:0] : '\0';
if (key == NSCarriageReturnCharacter || key == NSEnterCharacter) {
if ([[self target] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self target] performSelector:@selector(enterKeyPressed:) withObject:self];
return;
if ([[self delegate] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self delegate] performSelector:@selector(enterKeyPressed:) withObject:self];
}
return;
}
else if (key == NSDeleteCharacter) {
if ([[self target] respondsToSelector:@selector(deleteKeyPressed:)]) {
[[self target] performSelector:@selector(deleteKeyPressed:) withObject:self];
return;
else if (key == NSDeleteFunctionKey || key == NSDeleteCharacter || key == NSBackspaceCharacter) {
if ([[self delegate] respondsToSelector:@selector(deleteKeyPressed:)]) {
[[self delegate] performSelector:@selector(deleteKeyPressed:) withObject:self];
}
return;
}
if ([[NSCharacterSet alphanumericCharacterSet] characterIsMember:key] &&
@@ -544,10 +544,28 @@ public class CDMainController extends CDController {
File f = new File(filename);
if(f.exists()) {
log.info("Found file: "+f.toString());
Host host = CDBookmarkTableDataSource.instance().importBookmark(f);
if(host != null) {
this.newDocument().mount(host);
return true;
if (f.getAbsolutePath().endsWith(".duck")) {
Host host = CDBookmarkTableDataSource.instance().importBookmark(f);
if(host != null) {
this.newDocument().mount(host);
return true;
}
}
else {
NSArray windows = NSApplication.sharedApplication().windows();
int count = windows.count();
while(0 != count--) {
NSWindow window = (NSWindow)windows.objectAtIndex(count);
CDBrowserController controller = CDBrowserController.controllerForWindow(window);
if(null != controller) {
Path workdir = controller.workdir();
Queue q = new UploadQueue(controller);
Session session = workdir.getSession().copy();
q.addRoot(PathFactory.createPath(session, workdir.getAbsolute(), new Local(f.getAbsolutePath())));
CDQueueController.instance().startItem(q);
break;
}
}
}
}
return false;
@@ -19,6 +19,12 @@
#import <Cocoa/Cocoa.h>
@interface CDOutlineView : NSOutlineView {
@private
BOOL mBrowserWasDoubleClicked;
int mBrowserEditingColumn;
int mBrowserEditingRow;
NSMutableString *select_string;
NSTimer *select_timer;
}
+92 -18
View File
@@ -28,6 +28,11 @@
- (void)awakeFromNib
{
[self setTarget:self];
[self setAction:@selector(handleBrowserClick:)];
[self setDoubleAction:@selector(handleBrowserDoubleClick:)];
// browser typeahead selection
select_string = [[NSMutableString alloc] init];
select_timer = nil;
}
@@ -44,21 +49,76 @@
[super dealloc];
}
- (void)handleBrowserClick:(id)sender {
NSPoint where = [self convertPoint:[[NSApp currentEvent] locationInWindow] fromView:nil];
int row = [self rowAtPoint:where];
int col = [self columnAtPoint:where];
if(row >= 0 && col >= 0) {
NSTableColumn *column = [[self tableColumns] objectAtIndex:col];
if([[self delegate] respondsToSelector:@selector(isColumnEditable:)]) {
if([[self delegate] isColumnEditable:column]) {
mBrowserEditingColumn = col;
mBrowserEditingRow = row;
NSValue *wrappedMouseLocation = [NSValue valueWithPoint:[NSEvent mouseLocation]];
[self performSelector:@selector(handleBrowserClickOffloaded:) withObject:wrappedMouseLocation afterDelay:0.5];
}
}
else {
NSLog(@"WARN: Tableview delegate does not respond to isColumnEditable:");
}
}
}
- (void)handleBrowserClickOffloaded:(NSValue *)inWrappedMouseLocation {
// UI: mouse must not have ben moved since first click, and must not have been double-clicked
if((!mBrowserWasDoubleClicked) && (NSEqualPoints([inWrappedMouseLocation pointValue], [NSEvent mouseLocation])) ) {
if(mBrowserEditingRow == [self selectedRow])
[self editColumn:mBrowserEditingColumn row:mBrowserEditingRow withEvent:nil select:YES];
}
mBrowserWasDoubleClicked = NO;
}
- (void)handleBrowserDoubleClick:(id)sender {
mBrowserWasDoubleClicked = YES;
if([self clickedRow] != -1) { // make sure double click was not in table header
if ([[self delegate] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self delegate] performSelector:@selector(enterKeyPressed:) withObject:self];
}
}
mBrowserWasDoubleClicked = NO;
}
- (BOOL)shouldCollapseAutoExpandedItemsForDeposited:(BOOL)deposited
{
return !deposited;
}
// make return and tab only end editing, and not cause other cells to edit
// Taken from http://borkware.com/quickies/one?topic=NSTableView
- (void) textDidEndEditing: (NSNotification *) notification
{
int textMovement = [[[notification userInfo] valueForKey:@"NSTextMovement"] intValue];
if (textMovement == NSReturnTextMovement || textMovement == NSTabTextMovement || textMovement == NSBacktabTextMovement) {
NSMutableDictionary *newInfo;
newInfo = [NSMutableDictionary dictionaryWithDictionary: [notification userInfo]];
[newInfo setObject: [NSNumber numberWithInt: NSIllegalTextMovement] forKey: @"NSTextMovement"];
notification = [NSNotification notificationWithName: [notification name]
object: [notification object]
userInfo: newInfo];
[super textDidEndEditing: notification];
[[self window] makeFirstResponder:self];
}
else {
[super textDidEndEditing: notification];
}
}
// Taken from http://www.cocoadev.com/index.pl?RightClickSelectInTableView
- (NSMenu *) menuForEvent:(NSEvent *) event
{
NSPoint where;
int row = -1, col = -1;
where = [self convertPoint:[event locationInWindow] fromView:nil];
row = [self rowAtPoint:where];
col = [self columnAtPoint:where];
NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
int row = [self rowAtPoint:where];
int col = [self columnAtPoint:where];
if(row >= 0) {
NSTableColumn *column = nil;
if(col >= 0) {
@@ -79,22 +139,36 @@
- (void)keyDown:(NSEvent *)event
{
NSString *str = [event characters];
char key = [str length] ? [str characterAtIndex:0] : '\0';
NSString *str = [event charactersIgnoringModifiers];
unichar key = [str length] ? [str characterAtIndex:0] : '\0';
if (key == NSCarriageReturnCharacter || key == NSEnterCharacter) {
if ([[self target] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self target] performSelector:@selector(enterKeyPressed:) withObject:self];
return;
if ([[self delegate] respondsToSelector:@selector(enterKeyPressed:)]) {
[[self delegate] performSelector:@selector(enterKeyPressed:) withObject:self];
}
return;
}
else if (key == NSDeleteCharacter) {
if ([[self target] respondsToSelector:@selector(deleteKeyPressed:)]) {
[[self target] performSelector:@selector(deleteKeyPressed:) withObject:self];
return;
else if (key == NSDeleteFunctionKey || key == NSDeleteCharacter || key == NSBackspaceCharacter) {
if ([[self delegate] respondsToSelector:@selector(deleteKeyPressed:)]) {
[[self delegate] performSelector:@selector(deleteKeyPressed:) withObject:self];
}
}
return;
}
else if (key == NSLeftArrowFunctionKey) { //left
id object = [self itemAtRow:[self selectedRow]];
if (object && [self isExpandable:object] && [self isItemExpanded:object]) {
[self collapseItem:object];
}
return;
}
else if (key == NSRightArrowFunctionKey) { //right
id object = [self itemAtRow:[self selectedRow]];
if (object && [self isExpandable:object] && ![self isItemExpanded:object]) {
[self expandItem:object];
}
return;
}
if ([[NSCharacterSet alphanumericCharacterSet] characterIsMember:key] &&
(![[NSCharacterSet controlCharacterSet] characterIsMember:key])) {
@@ -43,7 +43,19 @@ public class CDQueueController extends CDWindowController {
private NSToolbar toolbar;
// ----------------------------------------------------------
public void awakeFromNib() {
super.awakeFromNib();
this.toolbar = new NSToolbar("Queue Toolbar");
this.toolbar.setDelegate(this);
this.toolbar.setAllowsUserCustomization(true);
this.toolbar.setAutosavesConfiguration(true);
this.window().setDelegate(this);
this.window().setReleasedWhenClosed(false);
this.window().setToolbar(toolbar);
}
// ----------------------------------------------------------
// Outlets
// ----------------------------------------------------------
@@ -120,11 +132,11 @@ public class CDQueueController extends CDWindowController {
}
public void windowDidBecomeKey(NSNotification notification) {
this.tableViewSelectionChange();
this.updateTableViewSelection();
}
public void windowDidResignKey(NSNotification notification) {
this.tableViewSelectionChange();
this.updateTableViewSelection();
}
public void windowWillClose(NSNotification notification) {
@@ -133,13 +145,46 @@ public class CDQueueController extends CDWindowController {
private CDQueueTableDataSource queueModel;
private NSTableView queueTable; // IBOutlet
private CDTableDelegate delegate;
public void setQueueTable(NSTableView queueTable) {
public void setQueueTable(NSTableView queueTable) {
this.queueTable = queueTable;
this.queueTable.setTarget(this);
this.queueTable.setDoubleAction(new NSSelector("queueTableRowDoubleClicked", new Class[]{Object.class}));
this.queueTable.setDataSource(this.queueModel = CDQueueTableDataSource.instance());
this.queueTable.setDelegate(this);
this.queueTable.setDelegate(this.delegate = new CDAbstractTableDelegate() {
public void enterKeyPressed(Object sender) {
if(CDQueueController.this.queueTable.selectedRow() != -1) {
Queue item = (Queue)queueModel.get(CDQueueController.this.queueTable.selectedRow());
if(!item.isRunning()) {
reloadButtonClicked(sender);
}
}
}
public void deleteKeyPressed(Object sender) {
deleteButtonClicked(sender);
}
public void tableColumnClicked(NSTableView view, NSTableColumn tableColumn) {
}
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if(row < queueModel.numberOfRowsInTableView(tableView)) {
queueModel.get(row).toString();
}
return null;
}
public void tableViewSelectionIsChanging(NSNotification aNotification) {
updateTableViewSelection();
}
public void tableViewSelectionDidChange(NSNotification aNotification) {
updateTableViewSelection();
}
});
// receive drag events from types
// in fact we are not interested in file promises, but because the browser model can only initiate
// a drag with tableView.dragPromisedFilesOfTypes(), we listens for those events
@@ -148,6 +193,7 @@ public class CDQueueController extends CDWindowController {
"QueuePBoardType",
NSPasteboard.StringPboardType,
NSPasteboard.FilesPromisePboardType}));
this.queueTable.setRowHeight(50f);
NSSelector setResizableMaskSelector
= new NSSelector("setResizingMask", new Class[]{int.class});
@@ -157,7 +203,6 @@ public class CDQueueController extends CDWindowController {
c.setMinWidth(36f);
c.setWidth(36f);
c.setMaxWidth(36f);
c.setEditable(false);
if(setResizableMaskSelector.implementedByClass(NSTableColumn.class)) {
c.setResizingMask(NSTableColumn.AutoresizingMask);
}
@@ -174,7 +219,6 @@ public class CDQueueController extends CDWindowController {
c.setMinWidth(80f);
c.setWidth(300f);
c.setMaxWidth(1000f);
c.setEditable(false);
if(setResizableMaskSelector.implementedByClass(NSTableColumn.class)) {
c.setResizingMask(NSTableColumn.AutoresizingMask);
}
@@ -194,49 +238,46 @@ public class CDQueueController extends CDWindowController {
this.queueTable.sizeToFit();
}
private void tableViewSelectionChange() {
boolean key = this.window().isKeyWindow();
for(int i = 0; i < this.queueModel.size(); i++) {
this.queueModel.getController(i).setHighlighted(this.queueTable.isRowSelected(i) && key);
}
this.toolbar.validateVisibleItems();
if(this.queueTable.selectedRow() != -1) {
Queue q = (Queue)this.queueModel.get(this.queueTable.selectedRow());
if(q.numberOfRoots() == 1) {
this.urlField.setAttributedStringValue(new NSAttributedString(q.getRoot().getHost().getURL()+"/"+q.getRoot().getAbsolute(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
this.localField.setAttributedStringValue(new NSAttributedString(q.getRoot().getLocal().getAbsolute(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
}
else {
this.urlField.setAttributedStringValue(new NSAttributedString(q.getRoot().getHost().getURL(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
this.localField.setAttributedStringValue(new NSAttributedString(NSBundle.localizedString("Multiple files", ""),
// +" ("+q.numberOfJobs()+" "+NSBundle.localizedString("files", "")+")",
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
}
}
else {
this.urlField.setStringValue("");
this.localField.setStringValue("");
}
}
private void updateTableViewSelection() {
boolean key = window().isKeyWindow();
for(int i = 0; i < queueModel.size(); i++) {
queueModel.getController(i).setHighlighted(queueTable.isRowSelected(i) && key);
}
toolbar.validateVisibleItems();
if(queueTable.selectedRow() != -1) {
Queue q = (Queue)queueModel.get(queueTable.selectedRow());
if(q.numberOfRoots() == 1) {
urlField.setAttributedStringValue(new NSAttributedString(q.getRoot().getHost().getURL()
+Path.DELIMITER+q.getRoot().getAbsolute(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
localField.setAttributedStringValue(new NSAttributedString(q.getRoot().getLocal().getAbsolute(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
}
else {
urlField.setAttributedStringValue(new NSAttributedString(q.getRoot().getHost().getURL(),
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
localField.setAttributedStringValue(new NSAttributedString(NSBundle.localizedString("Multiple files", ""),
// +" ("+q.numberOfJobs()+" "+NSBundle.localizedString("files", "")+")",
TRUNCATE_MIDDLE_PARAGRAPH_DICTIONARY));
}
}
else {
urlField.setStringValue("");
localField.setStringValue("");
}
}
public void tableViewSelectionIsChanging(NSNotification notification) {
this.tableViewSelectionChange();
}
// ----------------------------------------------------------
//
// ----------------------------------------------------------
public void tableViewSelectionDidChange(NSNotification notification) {
this.tableViewSelectionChange();
}
private void reloadQueueTable() {
private void reloadQueueTable() {
this.queueTable.deselectAll(null);
while(this.queueTable.subviews().count() > 0) {
((NSView)this.queueTable.subviews().lastObject()).removeFromSuperviewWithoutNeedingDisplay();
}
this.queueTable.reloadData();
this.tableViewSelectionChange();
this.updateTableViewSelection();
}
public void removeItem(Queue queue) {
@@ -306,18 +347,6 @@ public class CDQueueController extends CDWindowController {
return this.window() != null && this.window().isVisible();
}
public void awakeFromNib() {
super.awakeFromNib();
this.toolbar = new NSToolbar("Queue Toolbar");
this.toolbar.setDelegate(this);
this.toolbar.setAllowsUserCustomization(true);
this.toolbar.setAutosavesConfiguration(true);
this.window().setDelegate(this);
this.window().setReleasedWhenClosed(false);
this.window().setToolbar(toolbar);
}
// ----------------------------------------------------------
// Toolbar Delegate
// ----------------------------------------------------------
@@ -378,10 +407,10 @@ public class CDQueueController extends CDWindowController {
item.setAction(new NSSelector("deleteButtonClicked", new Class[]{Object.class}));
return item;
}
if(itemIdentifier.equals("Clear")) {
item.setLabel(NSBundle.localizedString("Clear", ""));
item.setPaletteLabel(NSBundle.localizedString("Clear", ""));
item.setToolTip(NSBundle.localizedString("Clear", ""));
if(itemIdentifier.equals("Clean Up")) {
item.setLabel(NSBundle.localizedString("Clean Up", ""));
item.setPaletteLabel(NSBundle.localizedString("Clean Up", ""));
item.setToolTip(NSBundle.localizedString("Clean Up", ""));
item.setImage(NSImage.imageNamed("cleanAll.tiff"));
item.setTarget(this);
item.setAction(new NSSelector("clearButtonClicked", new Class[]{Object.class}));
@@ -392,18 +421,6 @@ public class CDQueueController extends CDWindowController {
return null;
}
public void queueTableRowDoubleClicked(Object sender) {
if(this.queueTable.selectedRow() != -1) {
Queue item = (Queue)this.queueModel.get(this.queueTable.selectedRow());
if(item.isRunning()) {
// this.stopButtonClicked(sender);
}
else {
this.reloadButtonClicked(sender);
}
}
}
public void paste(Object sender) {
log.debug("paste");
NSPasteboard pboard = NSPasteboard.pasteboardWithName("QueuePBoard");
@@ -464,7 +481,7 @@ public class CDQueueController extends CDWindowController {
}
}
public synchronized void openButtonClicked(Object sender) {
public void openButtonClicked(Object sender) {
if(this.queueTable.selectedRow() != -1) {
Queue q = (Queue)this.queueModel.get(this.queueTable.selectedRow());
Path f = q.getRoot();
@@ -494,7 +511,7 @@ public class CDQueueController extends CDWindowController {
}
}
public synchronized void revealButtonClicked(Object sender) {
public void revealButtonClicked(Object sender) {
if(this.queueTable.selectedRow() != -1) {
Queue q = (Queue)this.queueModel.get(this.queueTable.selectedRow());
Path f = q.getRoot();
@@ -524,16 +541,6 @@ public class CDQueueController extends CDWindowController {
}
}
public void enterKeyPressed(Object sender) {
log.debug("enterKeyPressed:" + sender);
this.queueTableRowDoubleClicked(sender);
}
public void deleteKeyPressed(Object sender) {
log.debug("deleteKeyPressed:" + sender);
this.deleteButtonClicked(sender);
}
public void deleteButtonClicked(Object sender) {
NSEnumerator iterator = queueTable.selectedRowEnumerator();
int j = 0;
@@ -559,13 +566,17 @@ public class CDQueueController extends CDWindowController {
this.reloadQueueTable();
}
public NSArray toolbarDefaultItemIdentifiers(NSToolbar toolbar) {
// ----------------------------------------------------------
// Toolbar Validation
// ----------------------------------------------------------
public NSArray toolbarDefaultItemIdentifiers(NSToolbar toolbar) {
return new NSArray(new Object[]{
"Resume",
"Reload",
"Stop",
"Remove",
"Clear",
"Clean Up",
NSToolbarItem.FlexibleSpaceItemIdentifier,
"Open",
"Show"
@@ -578,7 +589,7 @@ public class CDQueueController extends CDWindowController {
"Reload",
"Stop",
"Remove",
"Clear",
"Clean Up",
"Show",
"Open",
NSToolbarItem.CustomizeToolbarItemIdentifier,
@@ -635,7 +646,7 @@ public class CDQueueController extends CDWindowController {
if(identifier.equals("Open") || identifier.equals("openButtonClicked:")) {
return this.queueTable.numberOfSelectedRows() == 1;
}
if(identifier.equals("Clear")) {
if(identifier.equals("Clean Up")) {
return this.queueTable.numberOfRows() > 0;
}
if(identifier.equals("Remove") || identifier.equals("deleteButtonClicked:")) {
@@ -54,10 +54,6 @@ public class CDQueueTableDataSource extends Collection {
this.load();
}
public void sort(NSTableColumn tableColumn, final boolean ascending) {
//
}
public int numberOfRowsInTableView(NSTableView tableView) {
return this.size();
}
@@ -79,15 +75,6 @@ public class CDQueueTableDataSource extends Collection {
return null;
}
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if(row < numberOfRowsInTableView(tableView)) {
this.get(row).toString();
}
return null;
}
// ----------------------------------------------------------
// Drop methods
// ----------------------------------------------------------
@@ -169,8 +156,8 @@ public class CDQueueTableDataSource extends Collection {
}
return false;
}
// ----------------------------------------------------------
// ----------------------------------------------------------
// Data Manipulation
// ----------------------------------------------------------
@@ -73,7 +73,11 @@ public class CDTableCell extends NSCell {
PARAGRAPH_STYLE_RIGHT_ALIGNMENT.setLineBreakMode(NSParagraphStyle.LineBreakByTruncatingTail);
}
public void drawInteriorWithFrameInView(NSRect cellFrame, NSView controlView) {
public void editWithFrameInView(NSRect nsRect, NSView nsView, NSText nsText, Object object, NSEvent nsEvent) {
super.editWithFrameInView(nsRect, nsView, nsText, object, nsEvent);
}
public void drawInteriorWithFrameInView(NSRect cellFrame, NSView controlView) {
super.drawInteriorWithFrameInView(cellFrame, controlView);
this.highlighted = this.isHighlighted() && !this.highlightColorWithFrameInView(cellFrame, controlView).equals(NSColor.secondarySelectedControlColor());
@@ -167,4 +171,5 @@ public class CDTableCell extends NSCell {
NSAttributedString.FontAttributeName,
NSAttributedString.ForegroundColorAttributeName,
NSAttributedString.ParagraphStyleAttributeName});
}
@@ -0,0 +1,34 @@
package ch.cyberduck.ui.cocoa;
/*
* Copyright (c) 2005 David Kocher. All rights reserved.
* http://cyberduck.ch/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Bug fixes, suggestions and comments should be sent to:
* dkocher@cyberduck.ch
*/
import java.util.Comparator;
/**
* @version $Id$
*/
public interface CDTableDelegate {
public void enterKeyPressed(Object sender);
public void deleteKeyPressed(Object sender);
public boolean isSortedAscending();
public Comparator getSortingComparator();
}
@@ -219,11 +219,33 @@ public abstract class CDValidatorController extends CDWindowController implement
}
protected NSTableView fileTableView; // IBOutlet
private CDTableDelegate fileTableViewDelegate;
public void setFileTableView(NSTableView fileTableView) {
public void setFileTableView(NSTableView fileTableView) {
this.fileTableView = fileTableView;
this.fileTableView.setDataSource(this);
this.fileTableView.setDelegate(this);
this.fileTableView.setDelegate(this.fileTableViewDelegate = new CDAbstractTableDelegate() {
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if(row < numberOfRowsInTableView(tableView)) {
return workList.get(row).toString();
}
return null;
}
public void enterKeyPressed(Object sender) {
}
public void deleteKeyPressed(Object sender) {
}
public void tableColumnClicked(NSTableView view, NSTableColumn tableColumn) {
//
}
});
this.fileTableView.setRowHeight(17f);
// selection properties
this.fileTableView.setAllowsMultipleSelection(true);
@@ -536,12 +558,4 @@ public abstract class CDValidatorController extends CDWindowController implement
public int numberOfRowsInTableView(NSTableView tableView) {
return this.workList.size();
}
public String tableViewToolTipForCell(NSTableView tableView, NSCell cell, NSMutableRect rect,
NSTableColumn tc, int row, NSPoint mouseLocation) {
if(row < numberOfRowsInTableView(tableView)) {
return this.workList.get(row).toString();
}
return null;
}
}
@@ -0,0 +1,88 @@
/*!
@header SmartCrashReportsInstall
@abstract API to the Installer of Smart Crash Reports
@discussion This API allows you to painlessly install Smart Crash Reports from within your application. It will properly
detect the versions and whether it should upgrade/install over an older version on the user's computer.
In order to use this library, you have to add the following frameworks to your project:
<ul>
<li>/System/Library/Frameworks/Carbon.framework
<li>/System/Library/Frameworks/CoreFoundation.framework
<li>/System/Library/Frameworks/Security.framework
<li>/usr/lib/libz.1.2.3.dylib (or /usr/lib/libz.dylib).
</ul>
*/
#pragma once
#include <CoreFoundation/CoreFoundation.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
@enum UnsanitySCR_Install_ErrorCode
@abstract Result codes returned from the UnsanitySCR_Install() function
@discussion These error codes will be returned from the UnsanitySCR_Install() function.
@constant kUnsanitySCR_Install_NoError No error. Installation succeeded.
@constant kUnsanitySCR_Install_OutOfMemory Could not allocate needed memory for the installation.
@constant kUnsanitySCR_Install_InstalledGlobally Smart Crash Reports are already installed globally and this API can not install into /Library
as it would require additional fiddling with the authorization which is beyond the scope of this API.
@constant kUnsanitySCR_Install_NoPermissions Could not install because of file permission issues.
@constant kUnsanitySCR_Install_AuthFailure Could not install because user failed to authenticate for the global install.
@constant kUnsanitySCR_Install_WillNotInstall Could not install because a newer or same version of Smart Crash Reports is already installed.
*/
enum
{
kUnsanitySCR_Install_NoError = 0,
kUnsanitySCR_Install_OutOfMemory = -108,
kUnsanitySCR_Install_InstalledGlobally = -13,
kUnsanitySCR_Install_NoPermissions = -54,
kUnsanitySCR_Install_WillNotInstall = -14,
kUnsanitySCR_Install_AuthFailure = -111
} UnsanitySCR_Install_ErrorCode;
/*!
@function UnsanitySCR_InstalledVersion
@abstract Get the version of Smart Crash Reports installed on user's system.
@discussion Returns the version of Smart Crash Reports installed on user's system.
@param outOptionalIsInstalledGlobally If this is not NULL, the Boolean the param points to will hold TRUE if Smart Crash Reports are installed for all
users, or FALSE if they are installed for the current user only.
@result UInt32 containing the version of Smart Crash Reports (in CFBundleGetVersionNumber() format), or 0 if Smart Crash Reports
are not installed.
*/
UInt32 UnsanitySCR_InstalledVersion(Boolean* outOptionalIsInstalledGlobally);
/*!
@function UnsanitySCR_InstallableVersion
@abstract Get the version of Smart Crash Reports that this library can install.
@discussion Returns the version of Smart Crash Reports that this library can install.
@result UInt32 containing the version of Smart Crash Reports (in CFBundleGetVersionNumber() format) bundled in this library.
*/
UInt32 UnsanitySCR_InstallableVersion();
/*!
@function UnsanitySCR_CanInstall
@abstract Check whether this library can install Smart Crash Reports on user's system.
@discussion Returns whether Smart Crash Reports can be installed.
@param outOptionalAuthenticationWillBeRequired If this is not NULL, the Boolean the param points to will be set to TRUE if an authentication will be
required to install Smart Crash Reports.
@result TRUE if Smart Crash Reports can be installed, or FALSE if they are already installed (of the same or newer version).
*/
Boolean UnsanitySCR_CanInstall(Boolean* outOptionalAuthenticationWillBeRequired);
/*!
@function UnsanitySCR_Install
@abstract Attempt to install Smart Crash Reports on user's system.
@discussion Installs Smart Crash Reports from the library's archive, if possible.
@param inInstallGlobally If TRUE, a global installation will be attempted (provided the user can authenticate). If FALSE, Smart Crash Reports will
be installed for current user only.
@result One of the <code>UnsanitySCR_Install_ErrorCode</code> result codes.
*/
OSStatus UnsanitySCR_Install(Boolean inInstallGlobally);
#ifdef __cplusplus
}
#endif