This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
|Summary:||Can not open files by double clicking in the OS file manager|
|Product:||platform||Reporter:||Petr Jiricka <pjiricka>|
|Component:||Launchers&CLI||Assignee:||Libor Fischmeistr <lfischmeistr>|
|Severity:||blocker||CC:||anebuzelsky, bunam, eleftrik, issues, jmcbade, johnny_beans, letssurf, mkleint, razvanphp, sanjayyadav007, tboudreau|
|OS:||Mac OS X|
|Issue Type:||ENHANCEMENT||Exception Reporter:|
|Bug Depends on:||235558|
patch proposed by Tim
my changes to the applemenu module
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 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
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 <firstname.lastname@example.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 email@example.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.
Comment 29 bunam 2014-08-29 08:31:36 UTC
This AppleScript do the job : https://github.com/bunam/NetBeans-Open
Comment 30 Jaroslav Havlin 2014-09-12 13:07:06 UTC
*** Bug 246941 has been marked as a duplicate of this bug. ***
Comment 31 Jaroslav Havlin 2014-11-14 11:06:33 UTC
*** Bug 248009 has been marked as a duplicate of this bug. ***
Comment 32 tareqtms 2015-07-10 05:23:25 UTC
Having the same issue in my new Mac OS X Yosemite 10.10.4 and Netbeans version 8.0.2
Comment 33 TheKarateKid 2015-09-28 19:45:12 UTC
This still does not work on OS X Yosemite 10.10.5 and Netbeans 8.0.2. Do the developers have any plans to fix this in Netbeans 8.1 or a future version?
Comment 34 sgd5026 2016-05-12 23:36:27 UTC
This still does not work on OS X Yosemite 10.10.5 and Netbeans 8.1
Comment 35 schrulli 2017-02-25 12:32:30 UTC
This still does not work on MacOS Sierra and Netbeans 8.2