# HG changeset patch # User Jaroslav Tulach # Date 1364626527 -3600 # Node ID 615c4158fbbb88e81e56fadb2aa59d4759c2391f # Parent 8da928058d887be9029784c81eefbaab8c19c27b Initial attempt to start and connect to NetBeans JavaScript debugger diff -r 8da928058d88 -r 615c4158fbbb ide/debugger/pom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ide/debugger/pom.xml Sat Mar 30 07:55:27 2013 +0100 @@ -0,0 +1,135 @@ + + + 4.0.0 + + ide + org.apidesign.bck2brwsr + 0.6-SNAPSHOT + + + org.apidesign.bck2brwsr.ide + debugger + 0.6-SNAPSHOT + nbm + + Debugger + + + UTF-8 + + ${netbeans.run.params.ide} + + + + + + netbeans + NetBeans + http://bits.netbeans.org/maven2/ + + false + + + + + + + org.netbeans.api + org-netbeans-api-annotations-common + + + org.netbeans.modules + org-netbeans-modules-web-browser-api + + + org-openide-util + org.netbeans.api + jar + + + org-openide-util-lookup + org.netbeans.api + jar + + + org-netbeans-modules-projectapi + org.netbeans.api + jar + + + org.netbeans.modules + org-netbeans-modules-web-webkit-debugging + RELEASE73 + + + org.netbeans.api + org-openide-awt + RELEASE73 + + + org.netbeans.modules + org-netbeans-modules-web-javascript-debugger + RELEASE73 + + + org.netbeans.api + org-netbeans-api-debugger + RELEASE73 + + + + + + + org.codehaus.mojo + nbm-maven-plugin + 3.9 + true + + + + org.netbeans.modules:org-netbeans-modules-web-browser-api + impl + org.netbeans.modules.web.browser.api = 20130326-ee33814e2cc6 + + + org.netbeans.modules:org-netbeans-modules-web-webkit-debugging + impl + org.netbeans.modules.web.webkit.debugging = 20130326-ee33814e2cc6 + + + org.netbeans.modules:org-netbeans-modules-web-common + impl + org.netbeans.modules.web.common = 20130326-ee33814e2cc6 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.6 + 1.6 + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + true + + + + + diff -r 8da928058d88 -r 615c4158fbbb ide/debugger/src/main/java/org/apidesign/bck2brwsr/debugger/DebugBck2Brwsr.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ide/debugger/src/main/java/org/apidesign/bck2brwsr/debugger/DebugBck2Brwsr.java Sat Mar 30 07:55:27 2013 +0100 @@ -0,0 +1,101 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.bck2brwsr.debugger; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.MalformedURLException; +import java.net.URL; +import org.netbeans.api.debugger.Session; +import org.netbeans.api.project.Project; +import org.netbeans.modules.web.browser.api.BrowserSupport; +import org.netbeans.modules.web.browser.api.WebBrowser; +import org.netbeans.modules.web.browser.api.WebBrowsers; +import org.netbeans.modules.web.webkit.debugging.api.WebKitDebugging; +import org.netbeans.modules.web.webkit.debugging.spi.netbeansdebugger.NetBeansJavaScriptDebuggerFactory; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; +import org.openide.awt.HtmlBrowser; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; + +/** + * + * @author Jaroslav Tulach + */ +@ActionID(category = "Debug", id = "org.apidesign.bck2brwsr.Debug") +@ActionRegistration(displayName = "Bck2brwsr debugger", asynchronous = true) +@ActionReference(path = "Menu/DebugProject", position = 33333) +public final class DebugBck2Brwsr implements ActionListener { + private final Project project; + + public DebugBck2Brwsr(Project p) { + this.project = p; + } + + + @Override + public void actionPerformed(ActionEvent e) { + try { + URL url = new URL("http://localhost:8383/HTML5Application/index.html"); + BrowserSupport.getDefaultEmbedded().load(url, project.getProjectDirectory()); + /* + for (WebBrowser web : WebBrowsers.getInstance().getAll(true)) { + HtmlBrowser.Impl impl = web.getHtmlBrowserFactory().createHtmlBrowserImpl(); + WebKitDebugging wkd = impl.getLookup().lookup(WebKitDebugging.class); + if (wkd != null) { + impl.setURL(url); + Session session = startSession(wkd, project.getLookup()); + System.err.println("debugging : " + session.getCurrentLanguage()); + return; + } + // Collection res = pane.getLookup().lookupAll(Object.class); + System.err.println("res: " + wkd); + } + */ + } catch (MalformedURLException ex) { + Exceptions.printStackTrace(ex); + } + } + + private static Session startSession(WebKitDebugging wkd, Lookup context) { + final String sevenThree = "org.netbeans.modules.web.webkit.debugging.spi.netbeansdebugger.NetBeansJavaScriptDebuggerFactory"; + final String sevenFour = "org.netbeans.modules.web.webkit.debugging.spi.JavaScriptDebuggerFactory"; + + Class cls; + try { + cls = Class.forName(sevenFour); + } catch (ClassNotFoundException ex1) { + try { + cls = Class.forName(sevenThree); + } catch (ClassNotFoundException ex) { + throw new IllegalStateException("Can't start debug session", ex); + } + } + + Object inst = Lookup.getDefault().lookup(cls); + + try { + java.lang.reflect.Method m = cls.getMethod("createDebuggingSession", WebKitDebugging.class, Lookup.class); + return (Session)m.invoke(inst, wkd, context); + } catch (Exception ex) { + throw new IllegalStateException(ex); + } + } +} diff -r 8da928058d88 -r 615c4158fbbb ide/debugger/src/main/nbm/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ide/debugger/src/main/nbm/manifest.mf Sat Mar 30 07:55:27 2013 +0100 @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +OpenIDE-Module-Localizing-Bundle: org/apidesign/bck2brwsr/debugger/Bundle.properties diff -r 8da928058d88 -r 615c4158fbbb ide/debugger/src/main/resources/org/apidesign/bck2brwsr/debugger/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ide/debugger/src/main/resources/org/apidesign/bck2brwsr/debugger/Bundle.properties Sat Mar 30 07:55:27 2013 +0100 @@ -0,0 +1,23 @@ +# +# Back 2 Browser Bytecode Translator +# Copyright (C) 2012 Jaroslav Tulach +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. Look for COPYING file in the top folder. +# If not, see http://opensource.org/licenses/GPL-2.0. +# + +# Localized module labels. Defaults taken from POM (, , ) if unset. +#OpenIDE-Module-Name= +#OpenIDE-Module-Short-Description= +#OpenIDE-Module-Long-Description= +#OpenIDE-Module-Display-Category= diff -r 8da928058d88 -r 615c4158fbbb ide/pom.xml --- a/ide/pom.xml Wed Mar 27 16:51:21 2013 +0100 +++ b/ide/pom.xml Sat Mar 30 07:55:27 2013 +0100 @@ -12,6 +12,7 @@ pom IDE Support + debugger editor