Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327365

Summary: Need methods in internal Cocoa classes
Product: [Eclipse Project] Platform Reporter: Prakash Rangaraj <prakash>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: enhancement    
Priority: P3 CC: lshanmug, skovatch
Version: 3.7   
Target Milestone: 3.7 M3   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Prakash Rangaraj CLA 2010-10-08 16:30:25 EDT
I'm trying to make use of NSApplication.arrangeInFront & NSWindow.setRepresentedFilename for few mac tweaks. It would be great to have those methods in the SWT Cocoa internal classes (without them I'm unable to proceed).

These methods are not directly used in SWT, so there is no reason for SWT to add them. Thats why I decided to bribe with a beer for the person who adds these :-)
Comment 1 Scott Kovatch CLA 2010-10-08 20:32:58 EDT
Can't you just use OS.sel_registerName() to define them for yourself? They're just selectors. I guess they would be more convenient if they were callable from Java.

setRepresentedFileName is a feature I know folks have been looking for, so that's no problem at all. arrangeInFront implies you're adding a Window menu, or going to make one available. What are you adding there?
Comment 2 Prakash Rangaraj CLA 2010-10-09 01:39:27 EDT
(In reply to comment #1)
> Can't you just use OS.sel_registerName() to define them for yourself? They're
> just selectors. I guess they would be more convenient if they were callable
> from Java.

    For both the methods, I'm currently doing that.

// on the class level
private static final long sel_setRepresentedFilename = OS
			.sel_registerName("setRepresentedFilename:");

//elsewhere in a method
NSWindow nsWindow = window.getShell().view.window();
NSString filePathString = NSString.stringWith(path);
OS.objc_msgSend(nsWindow.id, sel_setRepresentedFilename, filePathString.id);

This is currently working fine for me. I'm on Cocoa 64 bit and not sure whether this will work fine in 32 bit, (where its int all over the methods instead of long). 


> setRepresentedFileName is a feature I know folks have been looking for, so
> that's no problem at all. arrangeInFront implies you're adding a Window menu,
> or going to make one available. What are you adding there?

     If you haven't noticed, Minimize & Zoom added to the Window menu in the recent Cocoa nightly builds. The last missing standard mac menu item in the Windows menu is 'Bring All to Front' one. (and a fix for Bug# 187052)
Comment 3 Scott Kovatch CLA 2010-10-12 12:53:32 EDT
Added arrangeInFront:, setRepresentedFilename: and setRepresentedURL:. One might be easier to use than the other.
Comment 4 Scott Kovatch CLA 2010-10-12 12:55:18 EDT
I forgot about 32 vs 64 bit. It will be easier to call these from Java, since the SWT hides that from you. Fixed > 20101012.
Comment 5 Prakash Rangaraj CLA 2010-10-12 13:19:54 EDT
Thanks Scott!

Remind me of the beer when we meet :-)