Bug 138943 - Can not open files by double clicking in the OS file manager
Can not open files by double clicking in the OS file manager
Status: REOPENED
Product: platform
Classification: Unclassified
Component: Launchers&CLI
6.x
All Mac OS X
: P2 with 4 votes (vote)
: 6.x
Assigned To: Libor Fischmeistr
issues@platform
:
: 187438 191708 (view as bug list)
Depends on: 235558
Blocks: 137169
  Show dependency treegraph
 
Reported: 2008-07-03 12:52 UTC by Petr Jiricka
Modified: 2014-02-10 14:15 UTC (History)
8 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments
patch proposed by Tim (3.04 KB, text/plain)
2008-07-04 14:58 UTC, dlipin
Details
my changes to the applemenu module (9.07 KB, patch)
2008-09-30 12:46 UTC, Milos Kleint
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2008-07-03 12:52:34 UTC
1. Use a file manager application (e.g. Finder on Mac OS X) to locate a text file, e.g. THIRDPARTYLICENSE.txt from the
NetBeans installation.
2. Right-click the file and choose Open With -> Other...
3. Change the "Enable" combo box to "All Applications"
4. Browse the NetBeans application, e.g. "NetBeans 6.1.app"
5. Click Open
=> NetBeans is started, but the file is not opened in NetBeans

Reproduced on Mac OS X, but the same problem may be present on Windows and Linux too (can anyone confirm?).
Comment 1 dlipin 2008-07-03 13:17:14 UTC
I cannot reproduce it on Windows and Linux (old FC4) so likely MacOSX-specific.
Comment 2 dlipin 2008-07-04 11:18:51 UTC
CC-ing Tim. He send me the e-mail with the following info (just for the record):

It looks like handleOpenFile() is wrong - the best it could do now would be to cause a file chooser to open.
A quick look at the code for handleOpenFile() shows it to be wrong - it would just open a file chooser if it did 
anything at all.

Anyway, here's what handleOpenFile() should probably look like - I haven't tested it though.

Things to check and tune:
 - can ApplicationEvent.getFilename() ever return a list of files?
 - does handleOpenApplication() perform the same role as handleOpenFile() if no copy of NB was running?  If so, needs 
to be handled, including making sure it is not really run until all modules are loaded

Anyway, the attached patch should give it at least a shot at working.  However, I see:

But if we ever want NB to be on the Open With menu, that's going to be a bit of a challenge - see:
http://developer.apple.com/documentation/Java/Reference/1.5.0/appledoc/api/com/apple/eawt/ApplicationListener.html
"These events are sent only if the bound application has file types listed in the Info.plist entries Document Types or 
CFBundleDocumentTypes."

I suspect the event may still be sent if you choose Open With -> Other -> NetBeans.

To do this semi-right, the build process that creates the NB application bundle would need to run some sort of custom 
Ant task that finds all file extensions that the copy of NetBeans it is bundling can read, and generate the Info.plist 
that lists those file types in the metadata that describes NB to Mac OS.

Doable, but won't help for any newly downloaded modules - you need to be superuser to edit the Info.plist of an 
installed application.

Of course, hard-coding a set of file types we know we want to accept would be a start. 
Comment 3 dlipin 2008-07-04 14:58:16 UTC
Created attachment 63948 [details]
patch proposed by Tim
Comment 4 _ tboudreau 2008-07-04 16:34:54 UTC
Caveat:  whether in handleOpenFile() or in handleOpenApplication() (reading the docs further, probably handleOpenFile() is what will be called) when a user 
double clicks a file in Finder and chooses Open With -> ...NetBeans, the documentation mentions that the event will be sent "after AWT is initialized".  That 
will be way too early in the startup sequence for the applemenu module to have registered its handler.

So my guess is, doing this without an already-running copy of NetBeans probably means adding the ApplicationListener much earlier in startup and trying to 
open the file after the main window is initialized.
Comment 5 _ tboudreau 2008-07-04 16:39:10 UTC
Also apropos:
http://lists.apple.com/archives/java-dev/2003/oct/msg00482.html

Comment 6 Milan Kubec 2008-07-11 16:57:50 UTC
Tim how can I test the fix? 'Open with' action on MacOSX only allows to select Something.app and I don't know how to create such launcher from sources. Is 
it even possible to debug something launched via .app launcher?
Comment 7 _ tboudreau 2008-07-11 19:17:45 UTC
> I don't know how to create such launcher from sources

I'm not sure what you mean - could you clarify?

In case I was being unclear:  Basically, any Mac OS X application directory contains a file Contents/Info.plist

That file can contain a static list of file types the application can open.  

Right now NetBeans' Info.plist does not contain any data about file types it handles, so NetBeans only appears on the Open With menu.

To put it on the Open menu, we would want to generate a list of file types NB handles when the Mac application bundle is generated.

Does that help?
Comment 8 Milan Kubec 2008-07-11 20:53:40 UTC
> I'm not sure what you mean - could you clarify?

I mean that if I invoke Open With I can only select application, but IDE built from sources (with the fix) is not MacOSX application, so I cannot test it.

I assume that the file Info.plist needs to be generated during IDE installation by installer.

Comment 9 _ tboudreau 2008-07-14 02:50:23 UTC
Run the Ant script in installer/mac to build the mac application structure (I see there is installer/mac/newbuild - not sure what that is, maybe the thing that 
does the new mpkg installers?)
Comment 10 dlipin 2008-07-18 08:10:13 UTC
Both ant scripts in installer/mac (not used at the moment, not up-to-date) and installer/mac/newbuild will build the 
installers (wrapped in .dmg), neither will build the .app structure.
The Info.plist that is used now (need some token replacement), is located at installer/mac/newbuild/netBeans.
Comment 11 Milos Kleint 2008-09-30 12:37:17 UTC
I have added the following snippet to the Info.plist file inside the netbeans.app.

	<key>CFBundleDocumentTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeName</key>
			<string>com.sun.java-source</string>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>LSItemContentTypes</key>
			<array>
				<string>com.sun.java-source</string>
			</array>
		</dict>
	</array>

After some moving around of the netbeans.app (probably for apple to recognize the change), I was able to select netbeans
as the editor for a java file in the finder.
HOWEVER the our listener's ApplicationListener.handleOpenFile (ApplicationEvent e) was never called by the environment.
I've tried moving the listener registration to ModuleInstall.validate() which is the most early point in startup a
module can execute it's code. I got the ApplicationListener.handleOpenApplication (ApplicationEvent e) method called
(thus the listener is correctly registered) but the handleOpenFile() method was never called.

-> I might have done something wrong, but the finder environment behaves as if it's setup correctly.

See for description of CFBundleDocumentTypes element in Info.plist
http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431-101685

See for a list of default content types
http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/utilist/chapter_4_section_1.html#//apple_ref/doc/uid/TP40001319-CH205-CHDIJFGJ


Reassigning to installer, as we need the entries in the Info.plist first as a prerequisite to fix the (possible) bug in
our code that opens the file badly. Right now (without the Info.plist content) our code is not called at all.

I'm running the latest 1.5.0_16 java.
Comment 12 Milos Kleint 2008-09-30 12:46:09 UTC
Created attachment 70888 [details]
my changes to the applemenu module
Comment 13 dlipin 2008-09-30 16:20:00 UTC
I`ve made the changed in installer to pick-up "public.shell-script" type (.sh and .command files).
http://hg.netbeans.org/main/rev/3aa6e1e3686c
(please let me know it is not enough)
.sh files editing support is included in the ideX cluster and therefore is available in every NetBeans distro.

I thought of com.sun.java-sources - but it will not work in non-Java distros and who knows what bugs it could introduce.

Passing back to core.

PS. As the long term solution we should dynamically add different CFBundleTypeName keys depending on the packs selected 
in installer. To do that we should have the full list of file extensions that we want to register and which module 
(better - cluster) is the editor support for that file type located at.
Comment 14 Quality Engineering 2008-10-01 05:59:27 UTC
Integrated into 'main-golden', will be available in build *200810010201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/3aa6e1e3686c
User: Dmitry Lipin <dlipin@netbeans.org>
Log: Temporary workaround for #138943 : register .sh files for the .app
Comment 15 _ tboudreau 2008-10-02 23:25:21 UTC
> but the handleOpenFile() method was never called

Probably the best place to ask about this is on java-dev@lists.apple.com - or I can put you in touch with someone from Apple.
Comment 16 Milos Kleint 2008-10-06 07:53:32 UTC
dlipin: with your changes, the sh files have netbeans in the preferred list for opening. That's good. However I'm not
sure we should be shipping with the change in 6.5, especially if the file opening doesn't actually work and is only
setup for sh files.

I've asked on java-dev@apple about the problem. 
http://lists.apple.com/archives/Java-dev/2008/Oct/msg00059.html
Comment 17 Milos Kleint 2008-10-08 07:22:38 UTC
according to this message
http://lists.apple.com/archives/Java-dev/2008/Oct/msg00077.html
the fact that we are using a shell script to start netbeans prohibits us from opening the file from finder. The shell
script blocks the OS from calling the java event callback.

closing as wontfix. 
Comment 18 Petr Jiricka 2009-09-24 11:02:45 UTC
Another user request for this feature:
http://forums.netbeans.org/topic17804.html
Comment 19 dlipin 2010-09-15 17:58:35 UTC
*** Bug 187438 has been marked as a duplicate of this bug. ***
Comment 20 letssurf 2011-07-08 14:49:02 UTC
Is this still not possible?
Comment 21 toxikman 2011-08-13 06:54:59 UTC
I agree, it's kind of odd that you can't open a simple file from the Finder and have NetBeans open it? Every other IDE/Text-Editor on the planet has this simple functionality. With NetBeans, you are forced to either use File->Open or Drag'n'Drop the file.

Can someone devise a simple work-around, such as writing a temporary file that you look for at startup? Something like "HeyNetBeans-OnceYouHaveLoadedThenOpenFileXXX"   The startup sh script could generate that file based on what the Finder wishes to open, assuming it's true that the launched IDE can't get at this information from the OS.
Comment 22 bluescrubbie 2012-10-15 23:30:02 UTC
Another year gone by - is netbeans still technically unable to open files from Finder?
Comment 23 bluescrubbie 2012-10-15 23:30:22 UTC
Another year gone by - is netbeans still technically unable to open files from Finder?
Comment 24 marvi 2012-10-31 09:07:05 UTC
Anyone working on this?
Comment 25 Jiri Rechtacek 2012-11-01 04:16:49 UTC
*** Bug 191708 has been marked as a duplicate of this bug. ***
Comment 26 Jiri Rechtacek 2012-11-01 04:21:27 UTC
IFAIK the current launcher for Mac doesn't allow to make this association. Any patch/hints are welcome.
Comment 27 jorahood 2013-04-03 02:11:47 UTC
Just adding another comment that some solution to this would be very much appreciated.
Comment 28 eleftrik 2013-04-04 08:03:21 UTC
This bug has been reported almost 5 years ago, and AFAIK there is still no solution.
I think this is a basic functionality for an IDE/editor.
I gave up. Moved to another IDE for Mac OS. Sorry for my useless comment.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo