我有我重新加工成Webstart的[启动的]配置的Swing应用程序启动从谷歌浏览器上下文菜单中JNLP。我的JNLP快到了,但我感到困惑的是下一步:链接到Chrome上下文菜单。尝试通过自定义扩展
应用程序是一个JSON浏览器/操纵这在目前需要一个URL的JSON文件,它驶入一个JFrame和解析JSON树,让你浏览它。如上所述,您目前必须提供要检索和格式化的网址。
我真的很想能够做的就是导航到JSON文件,比方说,Chrome和右键单击“在JSON查看器中查看”。对于示例Proof Of Concept,[加载jnlp文件]我使用他们提供的Oracle'记事本'jnlp作为示例。
我已经建立了我基本的manifest.json文件和JavaScript项,然后试图婴儿床的一些 “deployJava.js” 文件
清单文件:
{
"name": "JSON Viewer",
"version": "1.0",
"manifest_version": 2,
"description": "Launch JSON viewer.",
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [ "contextMenus" ],
"background": {
"scripts": ["jsonview.js"]
}
}
JavaScript文件:
var title = "Edit JSON";
var id = chrome.contextMenus.create({"title": title, "contexts": ["page"],
"onclick": loadJsonViewer });
console.log("'" + context + "' item:" + id);
function loadJsonViewer(info, tab) {
//info is OnLoadData
alert(info.pageUrl);
var url = "http://java.sun.com/javase/technologies/desktop/javawebstart/apps/notepad.jnlp";
launchWebStartApplication(url);
}
// launch the specified JNLP application using the passed in jnlp file
// the jnlp file does not need to have a codebase
// this requires JRE 7 or above to work
// if machine has no JRE 7 or above, we will try to auto-install and then launch
/(function will return false if JRE auto-install failed)
function launchWebStartApplication (jnlp) {
var jnlpDocbase = null;
// use document.documentURI for docbase
if (document.documentURI) {
jnlpDocbase = document.documentURI;
}
// fallback to document.URL if documentURI not available
if (jnlpDocbase == null) {
jnlpDocbase = document.URL;
}
document.location = jnlp;
return true;
}
到目前为止,我已经很成功,在我努力:(
中号我认为模式是我试图抽出启动JNLP的实际行,因为我没有嵌入或创建任何“嵌入式”启动按钮(通常情况下是这样),但是我认为这是公平的。
我的主要问题,因为我这条路线犁下来就是:难道这甚至工作?如果是这样,那么为了调出并创建一个小程序,“看不见”嵌入标记的最好方式是看起来需要它。
完美,非常感谢! –