Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How to goto URL from app?



Jason,

> My app descends from NSApplication, so I don't think I can assume it's
> an applet and use showDocument. Any tips?

You appear to have gotten a couple responses for NSWorkspace. Most likely the solution you want.
As a curiosity maybe I have some code that should support this 1.3 or 1.4, although I'm not sure tested with both real recently. I did just verify it working again this weekend with one or the other.
Part of my jnidirect package, for this the macnative.jnidirect.SignatureToApp class, you can test with the package included 'app' line command.
For example for the command...
app -u http://www.apple.com
This invokes a findApplication method of the SignatureToApp class, method name out and out stolen from the MRJFileUtils method. Heck, at least originally the code was based on a AppleScript SDK example.
With that you can go...

strarg = String arg with url.

if (byURL)
System.out.println("app: url " + strarg + ": path - " +
SignatureToApp.findApplication(strarg,true).getPath() + " >LAUNCHED");

The string goes through some simple parsing to try and decide if its a OSType creator, file extension, or URL parameter. The 'true' is a launch parameter, this not being functionality that was provided with the original MRJFileUtils method, URL launching was not either for that matter. The parameter has no meaning for an URL though it will always do the 'open' as was mentioned with NSWorkspace which should launch. The boolean is more applicable to application locating/launching. A java.io.File for the launched browser is returned if you're interested in what browser you actually launched.
You don't even have to assume you're Cocoa though.

Mike Hall <email@hidden>
<http://www.spacestar.net/users/mikehall>
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.