├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.xml ├── build ├── classes │ └── cz │ │ └── kec │ │ └── nb │ │ └── nodejs │ │ ├── Bundle.properties │ │ ├── JSOutputListener.class │ │ ├── NodeJSOptionsOptionsPanelController.class │ │ ├── NodeJSOptionsPanel$1.class │ │ ├── NodeJSOptionsPanel$2.class │ │ ├── NodeJSOptionsPanel.class │ │ ├── RunNode$1.class │ │ ├── RunNode$2.class │ │ ├── RunNode.class │ │ ├── WinPath.class │ │ ├── images │ │ └── win.png │ │ └── layer.xml ├── cluster │ ├── .lastModified │ ├── config │ │ └── Modules │ │ │ └── cz-kec-nb-nodejs.xml │ ├── modules │ │ └── cz-kec-nb-nodejs.jar │ └── update_tracking │ │ └── cz-kec-nb-nodejs.xml └── public-package-jars │ ├── org-jdesktop-layout.jar │ ├── org-netbeans-modules-editor-lib2.jar │ ├── org-netbeans-modules-options-api.jar │ ├── org-openide-awt.jar │ ├── org-openide-filesystems.jar │ ├── org-openide-io.jar │ ├── org-openide-loaders.jar │ ├── org-openide-nodes.jar │ ├── org-openide-text.jar │ ├── org-openide-util-lookup.jar │ └── org-openide-util.jar ├── danielkec.jks ├── manifest.mf ├── pom.xml └── src └── main ├── java └── cz │ └── kec │ └── nb │ └── nodejs │ ├── JSOutputListener.java │ ├── KillAllNodeAction.java │ ├── MultiOSCmd.java │ ├── NodeJSOptionsOptionsPanelController.java │ ├── NodeJSOptionsPanel.form │ ├── NodeJSOptionsPanel.java │ ├── RunNode.java │ ├── WinPath.java │ ├── images │ └── test.js │ └── ioactions │ └── StopAction.java ├── nbm └── manifest.mf └── resources └── cz └── kec └── nb └── nodejs ├── Bundle.properties ├── layer.xml ├── stop-icon.png └── win.png /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | script: mvn verify 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ===================[English]======================= 2 | END-USER LICENSE AGREEMENT ("EULA") 3 | 4 | IMPORTANT-READ CAREFULLY: This End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and Syntea software group a.s. By installing, copying, or otherwise using this SOFTWARE, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use this SOFTWARE. 5 | 6 | 1. Freeware 7 | You may use this SOFTWARE without charge. 8 | 9 | 2. Distribution of SOFTWARE. 10 | You may make copies of the SOFTWARE as you wish; give exact copies of the original SOFTWARE to anyone; and distribute the SOFTWARE in its unmodified form via electronic means. You may not charge any fees for the copy or use of the SOFTWARE itself. You must not represent in any way that you are selling the SOFTWARE itself. Your distribution of the SOFTWARE will not entitle you to any compensation from Syntea software group a.s. You must distribute a copy of this EULA with any copy of the SOFTWARE and anyone to whom you distribute the SOFTWARE is subject to this EULA. 11 | 12 | 3. RESTRICTIONS 13 | 3.1 You may not reverse engineer, de-compile, or disassemble the SOFTWARE. 14 | 3.2 You may not rent, lease, or lend the SOFTWARE. 15 | 3.3 You may not use the SOFTWARE to perform any unauthorized transfer of information or for any illegal purpose. 16 | 17 | 4. NO WARRANTIES 18 | Syntea software group a.s. expressly disclaims any warranty for the SOFTWARE. THE SOFTWARE AND ANY RELATED DOCUMENTATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OR MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT. THE ENTIRE RISK ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE REMAINS WITH YOU. 19 | 20 | ====================[Česky]======================= 21 | LICENČNÍ UJEDNÁNÍ 22 | 23 | ČTĚTE POZORNĚ: Toto je licenční ujednání mezi vaší osobou a firmou Syntea software group a.s. Instalací, kopírováním nebo jiným požíváním tohoto SOFTWARU, souhlasíte s podmínkami tohoto ujednání. Pokud s těmito podmínkami nesouhlasíte, neinstalujte, nebo jinak nepoužívejte tento SOFTWARE. 24 | 25 | 1. Freeware (software, který je distribuován bezplatně) 26 | Tento SOFTWARE můžete používat bezplatně, za předpokladu dodržení podmínek tohoto licenčního ujednání. 27 | 28 | 2. Distribuce tohoto SOFTWARU 29 | Můžete vytvářet nezměněné kopie tohoto SOFTWARU bez omezení a poskytovat je komukoli, distribuovat jakoukoli formou. Avšak nesmíte si účtovat žádnou peněžní ani jinou odměnu za kopie nebo užití tohoto SOFTWARU. Nesmíte se žádným způsobem prezentovat jako prodejce toho SOFTWARU. Tato kopie SOFTWARU vás nijak neopravňuje vyžadovat na firmě Syntea software group a.s. žádné finanční ani jiné kopmpenzace. Toto licenční ujednání musíte distribuovat spolu s jakoukoli kopií tohoto SOFTWARU a kdokoli, komu poskytnete kopii tohoto SOFTWARU, je povinen jej používat v souladu s tímto ujednaním. 30 | 31 | 3. Co nesmíte 32 | 3.1 Nesmíte se pokoušet o dekompilovat ani jinak zjišťovat jak SOFTWARE pracuje. 33 | 3.2 Nesmíte si účtovat žádnou odměnu za používání tohoto SOFTWARU, za jeho půjčování či jinou formu poskytování tohoto SOFTWARU. 34 | 3.3 Nesmíte tento SOFTWARE používat v rozporu s tímto ujednáním, zákony České republiky nebo dalšími platnými zákony. 35 | 36 | 4. Žádná záruka 37 | Syntea software group a.s. se zříká jakékoli odpovědnosti s jakoukoli škodou nebo újmou plynoucí, nebo způsobené tímto SOFTWAREM. SOFTWARE A JAKÁKOLI S NÍM SPOJENÁ DOKUMENTACE JE POSKYTOVÁN BEZ JAKÉKOLI ZÁRUKY JAKÉHOKOLI DRUHU. 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo](http://plugins.netbeans.org/data/images/1298478790845_nbndjs.png) 2 | 3 | Node.js support in Netbeans IDE. Node.js installation is required, you can edit execution command in options/miscellaneous/Node.js. On windows you will see a bubble notification in the right left corner which says plugin reconfigured cmd in options for running node on win. Then you can run again with expected results. 4 | 5 | ![Screenshot](http://plugins.netbeans.org/nbpluginportal/files/images/1298478790953_Screenshot-jDEF_-_NetBeans_IDE_6.9.1.png) 6 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Builds, tests, and runs the project cz.kec.nb.nodejs. 7 | 8 | 9 | -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/Bundle.properties: -------------------------------------------------------------------------------- 1 | AdvancedOption_DisplayName_NodeJSOptions=Node.js 2 | AdvancedOption_Keywords_NodeJSOptions=node.js javascript 3 | AdvancedOption_Tooltip_NodeJSOptions=Node.js runner 4 | CTL_RunNode=Run with Node.js 5 | OpenIDE-Module-Display-Category=JavaScript 6 | OpenIDE-Module-Long-Description=\ 7 | NodeJS for NetBeans IDE
2009 \u00a9 Syntea software group a.s.\ 8 | \n
\nExecute selected javascript file with editable command. \ 9 | Default command is node /blah/blah/some.js.\ 10 |
\nWorks with Linux, Windows and shoud work on Mac too!\ 11 | \n


\n


\nDaniel Kec 12 | OpenIDE-Module-Name=NodeJS 13 | NodeJSOptionsPanel.jLabel1.text=Default run command: 14 | NodeJSOptionsPanel.jEditorPane1.text=cd ${workingdir};\nnode ${selectedfile}; 15 | NodeJSOptionsPanel.jButton1.text=Reset 16 | OpenIDE-Module-Short-Description=Node.js support in Netbeans IDE 17 | NodeJSOptionsPanel.jButton2.text=Reset for Windows 18 | -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/JSOutputListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/JSOutputListener.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/NodeJSOptionsOptionsPanelController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/NodeJSOptionsOptionsPanelController.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel$1.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel$2.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/NodeJSOptionsPanel.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/RunNode$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/RunNode$1.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/RunNode$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/RunNode$2.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/RunNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/RunNode.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/WinPath.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/WinPath.class -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/images/win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/classes/cz/kec/nb/nodejs/images/win.png -------------------------------------------------------------------------------- /build/classes/cz/kec/nb/nodejs/layer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /build/cluster/.lastModified: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/cluster/.lastModified -------------------------------------------------------------------------------- /build/cluster/config/Modules/cz-kec-nb-nodejs.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | false 6 | false 7 | true 8 | modules/cz-kec-nb-nodejs.jar 9 | false 10 | 11 | -------------------------------------------------------------------------------- /build/cluster/modules/cz-kec-nb-nodejs.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/cluster/modules/cz-kec-nb-nodejs.jar -------------------------------------------------------------------------------- /build/cluster/update_tracking/cz-kec-nb-nodejs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /build/public-package-jars/org-jdesktop-layout.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-jdesktop-layout.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-netbeans-modules-editor-lib2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-netbeans-modules-editor-lib2.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-netbeans-modules-options-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-netbeans-modules-options-api.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-awt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-awt.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-filesystems.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-filesystems.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-io.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-io.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-loaders.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-loaders.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-nodes.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-nodes.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-text.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-text.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-util-lookup.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-util-lookup.jar -------------------------------------------------------------------------------- /build/public-package-jars/org-openide-util.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/build/public-package-jars/org-openide-util.jar -------------------------------------------------------------------------------- /danielkec.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/danielkec.jks -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | OpenIDE-Module: cz.kec.nb.nodejs 3 | OpenIDE-Module-Layer: cz/kec/nb/nodejs/layer.xml 4 | OpenIDE-Module-Localizing-Bundle: cz/kec/nb/nodejs/Bundle.properties 5 | OpenIDE-Module-Specification-Version: 2.1 6 | 7 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | cz.kec.nb 6 | NodeJS 7 | 2.2-SNAPSHOT 8 | nbm 9 | 10 | NodeJS 11 | 12 | 13 | 14 | In NetBeans IDE execute selected javascript file with editable command. 15 | 16 | 17 | Run with NodeJS Plugin 18 | UTF-8 19 | Freeware 20 | RELEASE80 21 | 22 | 23 | 24 | 29 | 30 | netbeans 31 | NetBeans 32 | http://bits.netbeans.org/maven2/ 33 | 34 | false 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.netbeans.api 42 | org-netbeans-modules-options-api 43 | RELEASE80 44 | 45 | 46 | org.netbeans.api 47 | org-openide-util 48 | RELEASE80 49 | 50 | 51 | org.netbeans.api 52 | org-netbeans-modules-editor-lib2 53 | RELEASE80 54 | 55 | 56 | org.netbeans.api 57 | org-openide-text 58 | RELEASE80 59 | 60 | 61 | org.netbeans.api 62 | org-openide-filesystems 63 | RELEASE80 64 | 65 | 66 | org.netbeans.api 67 | org-openide-loaders 68 | RELEASE80 69 | 70 | 71 | org.netbeans.api 72 | org-openide-io 73 | RELEASE80 74 | 75 | 76 | org.netbeans.api 77 | org-openide-awt 78 | RELEASE80 79 | 80 | 81 | org.netbeans.api 82 | org-openide-nodes 83 | RELEASE80 84 | 85 | 86 | org.netbeans.api 87 | org-openide-util-lookup 88 | RELEASE80 89 | 90 | 91 | org.netbeans.api 92 | org-openide-windows 93 | RELEASE80 94 | 95 | 96 | 97 | 98 | 99 | 100 | src/main/resources 101 | true 102 | 103 | 104 | 105 | 106 | org.codehaus.mojo 107 | nbm-maven-plugin 108 | 3.13 109 | true 110 | 111 | Daniel Kec 112 | ./danielkec.jks 113 | danielkec 114 | ${keystore.heslo} 115 | false 116 | https://github.com/danielkec/NodeJS 117 | Freeware 118 | ./LICENSE 119 | 120 | cz.kec.nb.nodejs 121 | cz.kec.nb.nodejs.ioactions 122 | 123 | 124 | 125 | 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-compiler-plugin 130 | 2.5.1 131 | 132 | 1.7 133 | 1.7 134 | 135 | 136 | 137 | 138 | org.apache.maven.plugins 139 | maven-jar-plugin 140 | 2.4 141 | 142 | 143 | true 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/JSOutputListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | 12 | package cz.kec.nb.nodejs; 13 | 14 | import java.util.Scanner; 15 | import javax.swing.text.JTextComponent; 16 | import org.netbeans.api.editor.EditorRegistry; 17 | import org.openide.cookies.EditorCookie; 18 | import org.openide.filesystems.FileObject; 19 | import org.openide.loaders.DataObject; 20 | import org.openide.loaders.DataObjectNotFoundException; 21 | import org.openide.windows.OutputEvent; 22 | import org.openide.windows.OutputListener; 23 | 24 | /** 25 | * JSOutputListener 26 | * 27 | * @author Daniel Kec 28 | * @since 23.2.2011 29 | * @version 1.0 30 | * @class cz.kec.nb.nodejs.JSOutputListener 31 | */ 32 | public class JSOutputListener implements OutputListener{ 33 | private final EditorCookie ec; 34 | private final FileObject fo; 35 | private final int line; 36 | public JSOutputListener(FileObject fo,int line) throws DataObjectNotFoundException { 37 | this.fo = fo; 38 | this.ec = DataObject.find(fo).getLookup().lookup(EditorCookie.class); 39 | this.line = line; 40 | } 41 | 42 | @Override 43 | public void outputLineSelected(OutputEvent oe) { 44 | 45 | } 46 | 47 | @Override 48 | public void outputLineAction(OutputEvent oe) { 49 | ec.open(); 50 | if (EditorRegistry.lastFocusedComponent() != null) { 51 | JTextComponent target = EditorRegistry.lastFocusedComponent(); 52 | String text = target.getText(); 53 | selectError(text, target); 54 | } 55 | } 56 | 57 | @Override 58 | public void outputLineCleared(OutputEvent oe) { 59 | 60 | } 61 | 62 | private void selectError(String text, JTextComponent target) { 63 | 64 | Scanner scanner = new Scanner(text); 65 | int lineCount = 0; 66 | int charCount = 0; 67 | int lineStart = 0; 68 | while(scanner.hasNextLine()){ 69 | lineCount++; 70 | lineStart = charCount; 71 | charCount = charCount + (scanner.nextLine().length())+("\n".length()); 72 | if(lineCount==line){ 73 | target.select(lineStart, charCount - ("\n".length())); // Select line with error 74 | break; 75 | } 76 | 77 | } 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/KillAllNodeAction.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Syntea software group a.s. 2 | * 3 | * This file may be used, copied, modified and distributed only in accordance 4 | * with the terms of the limited licence contained in the accompanying 5 | * file LICENSE.TXT. 6 | * 7 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 8 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 9 | */ 10 | package cz.kec.nb.nodejs; 11 | 12 | import java.awt.Color; 13 | import java.awt.event.ActionEvent; 14 | import java.awt.event.ActionListener; 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.io.InputStreamReader; 18 | import java.util.concurrent.atomic.AtomicBoolean; 19 | import org.openide.awt.ActionID; 20 | import org.openide.awt.ActionReference; 21 | import org.openide.awt.ActionReferences; 22 | import org.openide.awt.ActionRegistration; 23 | import org.openide.util.Exceptions; 24 | import org.openide.windows.IOColorLines; 25 | import org.openide.windows.IOProvider; 26 | import org.openide.windows.InputOutput; 27 | import org.openide.windows.OutputWriter; 28 | 29 | @ActionID( 30 | category = "NodeJS", 31 | id = "cz.kec.nb.nodejs.KillAllNodeAction" 32 | ) 33 | @ActionRegistration( 34 | iconBase = "cz/kec/nb/nodejs/stop-icon.png", 35 | displayName = "Stop All NodeJS instances" 36 | ) 37 | @ActionReferences(value = { 38 | @ActionReference(path = "Menu/BuildProject", position = 1201), 39 | @ActionReference(path = "Editors/text/javascript/Popup", position = 401)}) 40 | public final class KillAllNodeAction implements ActionListener { 41 | 42 | @Override 43 | public void actionPerformed(ActionEvent e) { 44 | try { 45 | String[] cmd = MultiOSCmd.createKillCmd(); 46 | if (cmd == null) { 47 | return; 48 | } 49 | 50 | 51 | final InputOutput io = IOProvider.getDefault().getIO("Killing all Node.js instances", false); 52 | final OutputWriter out = io.getOut(); 53 | OutputWriter erout = io.getErr(); 54 | io.select(); 55 | io.setOutputVisible(true); 56 | out.reset(); 57 | 58 | IOColorLines.println(io, WinPath.concatStringArray(cmd), Color.lightGray); 59 | 60 | final Process proc = Runtime.getRuntime().exec(cmd); 61 | 62 | final BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream())); 63 | final BufferedReader readerr = new BufferedReader(new InputStreamReader(proc.getErrorStream())); 64 | // thx to Andrew Skiba http://andskiba.blogspot.com/2011/09/nodejs-plugin-for-netbeans-and-daemons.html 65 | final AtomicBoolean done = new AtomicBoolean(false); 66 | new Thread(new Runnable() { 67 | @Override 68 | public void run() { 69 | try { 70 | while (!done.get()) { 71 | Thread.sleep(50); 72 | while (read.ready()) { 73 | out.println(read.readLine()); 74 | } 75 | while (readerr.ready()) { 76 | printErrLine(readerr.readLine(), io); 77 | //erout.println(readerr.readLine()); 78 | } 79 | 80 | } 81 | 82 | read.close(); 83 | readerr.close(); 84 | 85 | } catch (Exception ex) { 86 | Exceptions.printStackTrace(ex); 87 | } 88 | } 89 | }).start(); 90 | new Thread(new Runnable() { 91 | @Override 92 | public void run() { 93 | try { 94 | proc.waitFor(); 95 | } catch (InterruptedException ex) { 96 | Exceptions.printStackTrace(ex); 97 | } finally { 98 | done.set(true); 99 | } 100 | } 101 | }).start(); 102 | 103 | } catch (Exception ex) { 104 | Exceptions.printStackTrace(ex); 105 | } 106 | } 107 | 108 | /** 109 | * Prints the err line with hyperlinks to the source files 110 | * @throws IOException 111 | */ 112 | private void printErrLine(String line, InputOutput io) throws IOException { 113 | 114 | IOColorLines.println(io, line, Color.RED); 115 | 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/MultiOSCmd.java: -------------------------------------------------------------------------------- 1 | /* Copyright 2013 Syntea software group a.s. 2 | * 3 | * This file may be used, copied, modified and distributed only in accordance 4 | * with the terms of the limited licence contained in the accompanying 5 | * file LICENSE.TXT. 6 | * 7 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 8 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 9 | */ 10 | package cz.kec.nb.nodejs; 11 | 12 | import static cz.kec.nb.nodejs.RunNode.loadIcon; 13 | import java.util.regex.Matcher; 14 | import org.openide.awt.NotificationDisplayer; 15 | import org.openide.filesystems.FileObject; 16 | import org.openide.util.NbPreferences; 17 | 18 | /** 19 | * @author Daniel Kec 20 | */ 21 | 22 | 23 | public class MultiOSCmd { 24 | public static String[] createRunCmd(FileObject fo){ 25 | String[] cmd = null; 26 | String command = NbPreferences.forModule(NodeJSOptionsPanel.class).get("COMMAND", "cd ${workingdir};\nnode ${selectedfile};"); 27 | if(System.getProperty("os.name").toLowerCase().contains("windows")){ 28 | String wdir = WinPath.winfixPath(fo.getParent().toURL().getPath()); 29 | System.out.println("Working dir "+wdir); 30 | command = command.replaceAll("\\$\\{selectedfile\\}", fo.getNameExt()); 31 | command = command.replaceAll("\\$\\{workingdir\\}", Matcher.quoteReplacement(wdir)); 32 | if(command.contains(";")){ 33 | // win settings bubble 34 | NotificationDisplayer.getDefault().notify("NodeJS",loadIcon(), "Windows with Unix settings detected reseting cmd options. Please run again.", null); 35 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("COMMAND", "cd ${workingdir} && node ${selectedfile}"); 36 | return cmd; 37 | } 38 | cmd = new String[]{"cmd", "/c",command}; 39 | }else{ 40 | command = command.replaceAll("\\$\\{selectedfile\\}", fo.getNameExt()); 41 | command = command.replaceAll("\\$\\{workingdir\\}", fo.getParent().toURL().getPath()); 42 | cmd = new String[]{"/bin/sh", "-c", command}; 43 | } 44 | return cmd; 45 | } 46 | public static String[] createKillCmd(){ 47 | String[] cmd = null; 48 | String command = NbPreferences.forModule(NodeJSOptionsPanel.class).get("KILL_COMMAND", "cd ${workingdir};\nnode ${selectedfile};"); 49 | if(System.getProperty("os.name").toLowerCase().contains("windows")){ 50 | if(command.contains(";")){ 51 | // win settings bubble 52 | NotificationDisplayer.getDefault().notify("NodeJS",loadIcon(), "Windows with Unix settings detected reseting cmd options. Please run again.", null); 53 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("KILL_COMMAND", "taskkill /F /IM node.exe"); 54 | return cmd; 55 | } 56 | cmd = new String[]{"cmd", "/c",command}; 57 | }else{ 58 | cmd = new String[]{"/bin/sh", "-c", command}; 59 | } 60 | return cmd; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/NodeJSOptionsOptionsPanelController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | package cz.kec.nb.nodejs; 12 | 13 | import java.beans.PropertyChangeListener; 14 | import java.beans.PropertyChangeSupport; 15 | import javax.swing.JComponent; 16 | import org.netbeans.spi.options.OptionsPanelController; 17 | import org.openide.util.HelpCtx; 18 | import org.openide.util.Lookup; 19 | 20 | public final class NodeJSOptionsOptionsPanelController extends OptionsPanelController { 21 | 22 | private NodeJSOptionsPanel panel; 23 | private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); 24 | private boolean changed; 25 | 26 | @Override 27 | public void update() { 28 | getPanel().load(); 29 | changed = false; 30 | } 31 | 32 | @Override 33 | public void applyChanges() { 34 | getPanel().store(); 35 | changed = false; 36 | } 37 | 38 | @Override 39 | public void cancel() { 40 | // need not do anything special, if no changes have been persisted yet 41 | } 42 | 43 | @Override 44 | public boolean isValid() { 45 | return getPanel().valid(); 46 | } 47 | 48 | @Override 49 | public boolean isChanged() { 50 | return changed; 51 | } 52 | 53 | @Override 54 | public HelpCtx getHelpCtx() { 55 | return null; // new HelpCtx("...ID") if you have a help set// no help set 56 | } 57 | 58 | @Override 59 | public JComponent getComponent(Lookup masterLookup) { 60 | return getPanel(); 61 | } 62 | 63 | @Override 64 | public void addPropertyChangeListener(PropertyChangeListener l) { 65 | pcs.addPropertyChangeListener(l); 66 | } 67 | 68 | @Override 69 | public void removePropertyChangeListener(PropertyChangeListener l) { 70 | pcs.removePropertyChangeListener(l); 71 | } 72 | 73 | private NodeJSOptionsPanel getPanel() { 74 | if (panel == null) { 75 | panel = new NodeJSOptionsPanel(this); 76 | } 77 | return panel; 78 | } 79 | 80 | void changed() { 81 | if (!changed) { 82 | changed = true; 83 | pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true); 84 | } 85 | pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/NodeJSOptionsPanel.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 |
129 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/NodeJSOptionsPanel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | package cz.kec.nb.nodejs; 12 | 13 | import org.openide.util.NbPreferences; 14 | 15 | final class NodeJSOptionsPanel extends javax.swing.JPanel { 16 | private static final long serialVersionUID = 4066708521896652031L; 17 | 18 | private final NodeJSOptionsOptionsPanelController controller; 19 | private String nodeBin; 20 | 21 | NodeJSOptionsPanel(NodeJSOptionsOptionsPanelController controller) { 22 | this.controller = controller; 23 | initComponents(); 24 | // TODO listen to changes in form fields and call controller.changed() 25 | } 26 | 27 | /** This method is called from within the constructor to 28 | * initialize the form. 29 | * WARNING: Do NOT modify this code. The content of this method is 30 | * always regenerated by the Form Editor. 31 | */ 32 | // //GEN-BEGIN:initComponents 33 | private void initComponents() { 34 | 35 | jLabel1 = new javax.swing.JLabel(); 36 | jScrollPane1 = new javax.swing.JScrollPane(); 37 | runCommandjEditorPane1 = new javax.swing.JEditorPane(); 38 | jButton1 = new javax.swing.JButton(); 39 | resetForWinjButton2 = new javax.swing.JButton(); 40 | jLabel2 = new javax.swing.JLabel(); 41 | jScrollPane2 = new javax.swing.JScrollPane(); 42 | killCommandjEditorPane2 = new javax.swing.JEditorPane(); 43 | 44 | org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(NodeJSOptionsPanel.class, "NodeJSOptionsPanel.jLabel1.text")); // NOI18N 45 | 46 | runCommandjEditorPane1.setText(org.openide.util.NbBundle.getMessage(NodeJSOptionsPanel.class, "NodeJSOptionsPanel.runCommandjEditorPane1.text")); // NOI18N 47 | runCommandjEditorPane1.setFocusCycleRoot(false); 48 | jScrollPane1.setViewportView(runCommandjEditorPane1); 49 | 50 | org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(NodeJSOptionsPanel.class, "NodeJSOptionsPanel.jButton1.text")); // NOI18N 51 | jButton1.addActionListener(new java.awt.event.ActionListener() { 52 | public void actionPerformed(java.awt.event.ActionEvent evt) { 53 | jButton1ActionPerformed(evt); 54 | } 55 | }); 56 | 57 | org.openide.awt.Mnemonics.setLocalizedText(resetForWinjButton2, org.openide.util.NbBundle.getMessage(NodeJSOptionsPanel.class, "NodeJSOptionsPanel.resetForWinjButton2.text")); // NOI18N 58 | resetForWinjButton2.addActionListener(new java.awt.event.ActionListener() { 59 | public void actionPerformed(java.awt.event.ActionEvent evt) { 60 | resetForWinjButton2ActionPerformed(evt); 61 | } 62 | }); 63 | 64 | org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(NodeJSOptionsPanel.class, "NodeJSOptionsPanel.jLabel2.text")); // NOI18N 65 | 66 | killCommandjEditorPane2.setText("taskkill /F /IM node.exe"); // NOI18N 67 | jScrollPane2.setViewportView(killCommandjEditorPane2); 68 | 69 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 70 | this.setLayout(layout); 71 | layout.setHorizontalGroup( 72 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 73 | .addGroup(layout.createSequentialGroup() 74 | .addContainerGap() 75 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 76 | .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING) 77 | .addComponent(jScrollPane1) 78 | .addGroup(layout.createSequentialGroup() 79 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 80 | .addComponent(jLabel1) 81 | .addGroup(layout.createSequentialGroup() 82 | .addComponent(jButton1) 83 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 84 | .addComponent(resetForWinjButton2)) 85 | .addComponent(jLabel2)) 86 | .addGap(0, 298, Short.MAX_VALUE))) 87 | .addContainerGap()) 88 | ); 89 | layout.setVerticalGroup( 90 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 91 | .addGroup(layout.createSequentialGroup() 92 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 93 | .addComponent(jLabel1) 94 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 95 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) 96 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 97 | .addComponent(jLabel2) 98 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 99 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE) 100 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 101 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 102 | .addComponent(jButton1) 103 | .addComponent(resetForWinjButton2))) 104 | ); 105 | }// //GEN-END:initComponents 106 | 107 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 108 | runCommandjEditorPane1.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("COMMAND", "cd ${workingdir};\nnode ${selectedfile};")); 109 | killCommandjEditorPane2.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("KILL_COMMAND","killall node;")); 110 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("COMMAND", "cd ${workingdir};\nnode ${selectedfile};"); 111 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("KILL_COMMAND", "killall node;"); 112 | 113 | }//GEN-LAST:event_jButton1ActionPerformed 114 | 115 | private void resetForWinjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetForWinjButton2ActionPerformed 116 | // reset for windows 117 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("COMMAND", "cd ${workingdir} && node ${selectedfile}"); 118 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("KILL_COMMAND", "taskkill /F /IM node.exe"); 119 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("NODE_EXEC_PATH", "C:\\Program Files\\nodejs\\node.exe"); 120 | runCommandjEditorPane1.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("COMMAND", "cd ${workingdir} && node ${selectedfile}")); 121 | killCommandjEditorPane2.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("KILLCOMMAND","taskkill /F /IM node.exe")); 122 | }//GEN-LAST:event_resetForWinjButton2ActionPerformed 123 | 124 | void load() { 125 | // TODO read settings and initialize GUI 126 | // Example: 127 | // someCheckBox.setSelected(Preferences.userNodeForPackage(NodeJSOptionsPanel.class).getBoolean("someFlag", false)); 128 | // or for org.openide.util with API spec. version >= 7.4: 129 | // someCheckBox.setSelected(NbPreferences.forModule(NodeJSOptionsPanel.class).getBoolean("someFlag", false)); 130 | // or: 131 | // someTextField.setText(SomeSystemOption.getDefault().getSomeStringProperty()); 132 | runCommandjEditorPane1.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("COMMAND","cd ${workingdir};\nnode ${selectedfile};")); 133 | killCommandjEditorPane2.setText(NbPreferences.forModule(NodeJSOptionsPanel.class).get("KILL_COMMAND","killall node;")); 134 | } 135 | 136 | void store() { 137 | // TODO store modified settings 138 | // Example: 139 | // Preferences.userNodeForPackage(NodeJSOptionsPanel.class).putBoolean("someFlag", someCheckBox.isSelected()); 140 | // or for org.openide.util with API spec. version >= 7.4: 141 | // NbPreferences.forModule(NodeJSOptionsPanel.class).putBoolean("someFlag", someCheckBox.isSelected()); 142 | // or: 143 | // SomeSystemOption.getDefault().setSomeStringProperty(someTextField.getText()); 144 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("COMMAND", runCommandjEditorPane1.getText()); 145 | NbPreferences.forModule(NodeJSOptionsPanel.class).put("KILL_COMMAND", killCommandjEditorPane2.getText()); 146 | } 147 | 148 | boolean valid() { 149 | return true; 150 | } 151 | 152 | // Variables declaration - do not modify//GEN-BEGIN:variables 153 | private javax.swing.JButton jButton1; 154 | private javax.swing.JLabel jLabel1; 155 | private javax.swing.JLabel jLabel2; 156 | private javax.swing.JScrollPane jScrollPane1; 157 | private javax.swing.JScrollPane jScrollPane2; 158 | private javax.swing.JEditorPane killCommandjEditorPane2; 159 | private javax.swing.JButton resetForWinjButton2; 160 | private javax.swing.JEditorPane runCommandjEditorPane1; 161 | // End of variables declaration//GEN-END:variables 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/RunNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | package cz.kec.nb.nodejs; 12 | 13 | import cz.kec.nb.nodejs.ioactions.StopAction; 14 | import java.awt.Color; 15 | import java.io.BufferedReader; 16 | import java.io.IOException; 17 | import java.io.InputStreamReader; 18 | import java.util.concurrent.atomic.AtomicBoolean; 19 | import java.util.regex.Matcher; 20 | import java.util.regex.Pattern; 21 | import javax.swing.Action; 22 | import javax.swing.Icon; 23 | import javax.swing.ImageIcon; 24 | import org.openide.awt.ActionID; 25 | import org.openide.awt.ActionReference; 26 | import org.openide.awt.ActionReferences; 27 | import org.openide.awt.ActionRegistration; 28 | import org.openide.cookies.EditorCookie; 29 | import org.openide.filesystems.FileObject; 30 | import org.openide.loaders.DataObject; 31 | import org.openide.nodes.Node; 32 | import org.openide.util.Exceptions; 33 | import org.openide.util.HelpCtx; 34 | import org.openide.util.NbBundle; 35 | import org.openide.util.NbPreferences; 36 | import org.openide.util.actions.CookieAction; 37 | import org.openide.windows.IOColorLines; 38 | import org.openide.windows.IOProvider; 39 | import org.openide.windows.InputOutput; 40 | import org.openide.windows.OutputWriter; 41 | /** 42 | * @author Daniel Kec,Andrew Skiba 43 | */ 44 | @ActionID(id = "cz.kec.nb.nodejs.RunNode", category = "NodeJS") 45 | @ActionRegistration(displayName = "#CTL_RunNode", lazy = false) 46 | @ActionReferences(value = { 47 | @ActionReference(path = "Editors/text/javascript/Popup", position = 400), 48 | @ActionReference(path = "Loaders/text/javascript/Actions", position = 150)}) 49 | public final class RunNode extends CookieAction { 50 | 51 | /** 52 | * Load the win icon for the win settings bubble 53 | * @return 54 | */ 55 | public static Icon loadIcon(){ 56 | return new ImageIcon(RunNode.class.getResource("win.png")); 57 | } 58 | 59 | private static final long serialVersionUID = -3853106497059314882L; 60 | private FileObject fo; 61 | private EditorCookie editorCookie; 62 | /** 63 | * Happen when Run Node.js is selected 64 | * @param activatedNodes 65 | */ 66 | @Override 67 | protected void performAction(Node[] activatedNodes) { 68 | try { 69 | DataObject dataObject = activatedNodes[0].getLookup().lookup(DataObject.class); 70 | editorCookie = activatedNodes[0].getLookup().lookup(EditorCookie.class); 71 | editorCookie.saveDocument(); 72 | 73 | fo = dataObject.getPrimaryFile(); 74 | fo.toURL(); 75 | fo.getParent().toURL(); 76 | StopAction sopka = new StopAction(); 77 | final InputOutput io = IOProvider.getDefault().getIO("Node.js " + fo.getName(),false, new Action[]{sopka}, null); 78 | sopka.setIo(io); 79 | final OutputWriter out = io.getOut(); 80 | OutputWriter erout = io.getErr(); 81 | io.select(); 82 | io.setOutputVisible(true); 83 | out.reset(); 84 | // multi OS thing 85 | String[] cmd = MultiOSCmd.createRunCmd(fo); 86 | if(cmd==null)return; 87 | 88 | 89 | IOColorLines.println(io, WinPath.concatStringArray(cmd), Color.lightGray); 90 | final Process proc = Runtime.getRuntime().exec(cmd); 91 | 92 | final BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream())); 93 | final BufferedReader readerr = new BufferedReader(new InputStreamReader(proc.getErrorStream())); 94 | // thx to Andrew Skiba http://andskiba.blogspot.com/2011/09/nodejs-plugin-for-netbeans-and-daemons.html 95 | final AtomicBoolean done = new AtomicBoolean(false); 96 | new Thread(new Runnable() { 97 | @Override 98 | public void run() { 99 | try { 100 | while (!done.get()) { 101 | Thread.sleep(50); 102 | while (read.ready()) { 103 | out.println(read.readLine()); 104 | } 105 | while (readerr.ready()) { 106 | printErrLine(readerr.readLine(), io); 107 | //erout.println(readerr.readLine()); 108 | } 109 | 110 | } 111 | 112 | read.close(); 113 | readerr.close(); 114 | 115 | } catch (Exception ex) { 116 | Exceptions.printStackTrace(ex); 117 | } 118 | } 119 | }).start(); 120 | new Thread(new Runnable() { 121 | @Override 122 | public void run() { 123 | try { 124 | proc.waitFor(); 125 | } catch (InterruptedException ex) { 126 | Exceptions.printStackTrace(ex); 127 | } 128 | finally { 129 | done.set(true); 130 | } 131 | } 132 | }).start(); 133 | 134 | } catch (Exception ex) { 135 | Exceptions.printStackTrace(ex); 136 | } 137 | 138 | } 139 | 140 | /** 141 | * Prints the err line with hyperlinks to the source files 142 | * @throws IOException 143 | */ 144 | private void printErrLine(String line, InputOutput io) throws IOException { 145 | String file = null; 146 | int lineNum = 0; 147 | int colNum = 0; 148 | Pattern mask = Pattern.compile("\\((.*\\.js):(\\d*)\\:(\\d*)\\)"); 149 | Matcher m = mask.matcher(line); 150 | while (m.find()) { 151 | file = m.group(1); 152 | lineNum = Integer.parseInt(m.group(2)); 153 | colNum = Integer.parseInt(m.group(3)); 154 | } 155 | if (file == null) { 156 | IOColorLines.println(io, line, Color.RED); 157 | return; 158 | } else { 159 | IOColorLines.println(io, line, new JSOutputListener(this.fo,lineNum), true, Color.BLUE); 160 | } 161 | } 162 | 163 | @Override 164 | protected int mode() { 165 | return CookieAction.MODE_EXACTLY_ONE; 166 | } 167 | 168 | @Override 169 | public String getName() { 170 | return NbBundle.getMessage(RunNode.class, "CTL_RunNode"); 171 | } 172 | 173 | @Override 174 | protected Class[] cookieClasses() { 175 | return new Class[]{DataObject.class}; 176 | } 177 | 178 | @Override 179 | protected void initialize() { 180 | super.initialize(); 181 | // see org.openide.util.actions.SystemAction.iconResource() Javadoc for more details 182 | putValue("noIconInMenu", Boolean.TRUE); 183 | } 184 | 185 | @Override 186 | public HelpCtx getHelpCtx() { 187 | return HelpCtx.DEFAULT_HELP; 188 | } 189 | 190 | @Override 191 | protected boolean asynchronous() { 192 | return false; 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/WinPath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | package cz.kec.nb.nodejs; 12 | 13 | import java.io.File; 14 | 15 | public class WinPath { 16 | /** 17 | * Fix file path so it can be used on win with Runtime.execute 18 | */ 19 | public static String winfixPath(String path){ 20 | String fixed =(new File(path)).getAbsolutePath(); 21 | fixed = fixed.replaceAll("\\%20"," "); 22 | return "\""+fixed+"\""; 23 | } 24 | 25 | public static boolean isWindows(){ 26 | return System.getProperty("os.name").toLowerCase().contains("windows"); 27 | } 28 | 29 | public static String concatStringArray(String[] arr){ 30 | StringBuilder sb = new StringBuilder(); 31 | for (String tok : arr) { 32 | sb.append(tok).append(" "); 33 | } 34 | return sb.toString(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/images/test.js: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | console.log("Hello Worlds"); 7 | 8 | var http = require('http'); 9 | 10 | // Configure our HTTP server to respond with Hello World to all requests. 11 | var server = http.createServer(function (request, response) { 12 | response.writeHead(200, {"Content-Type": "text/plain"}); 13 | response.end("Hello World\n"); 14 | }); 15 | 16 | // Listen on port 8000, IP defaults to 127.0.0.1 17 | server.listen(8000); 18 | 19 | // Put a friendly message on the terminal 20 | console.log("Server running at http://127.0.0.1:8000/"); -------------------------------------------------------------------------------- /src/main/java/cz/kec/nb/nodejs/ioactions/StopAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Syntea software group a.s. 3 | * 4 | * This file may be used, copied, modified and distributed only in accordance 5 | * with the terms of the limited licence contained in the accompanying 6 | * file LICENSE.TXT. 7 | * 8 | * Tento soubor muze byt pouzit, kopirovan, modifikovan a siren pouze v souladu 9 | * s licencnimi podminkami uvedenymi v prilozenem souboru LICENSE.TXT. 10 | */ 11 | package cz.kec.nb.nodejs.ioactions; 12 | 13 | import cz.kec.nb.nodejs.MultiOSCmd; 14 | import cz.kec.nb.nodejs.RunNode; 15 | import cz.kec.nb.nodejs.WinPath; 16 | import java.awt.Color; 17 | import java.awt.event.ActionEvent; 18 | import java.beans.PropertyChangeListener; 19 | import java.io.BufferedReader; 20 | import java.io.IOException; 21 | import java.io.InputStreamReader; 22 | import java.util.Arrays; 23 | import java.util.HashMap; 24 | import java.util.concurrent.atomic.AtomicBoolean; 25 | import javax.swing.Action; 26 | import javax.swing.ImageIcon; 27 | import org.openide.util.Exceptions; 28 | import org.openide.windows.IOColorLines; 29 | import org.openide.windows.InputOutput; 30 | import org.openide.windows.OutputWriter; 31 | 32 | /** 33 | * 34 | * @author Daniel Kec 35 | */ 36 | public class StopAction implements Action { 37 | 38 | private HashMap hashMap = new HashMap<>(); 39 | private boolean enabled; 40 | private InputOutput io; 41 | private OutputWriter out; 42 | 43 | public void setIo(InputOutput io) { 44 | this.io = io; 45 | this.out = io.getOut(); 46 | } 47 | 48 | public StopAction() { 49 | hashMap.put(Action.SMALL_ICON, new ImageIcon(RunNode.class.getResource("stop-icon.png"))); 50 | hashMap.put(Action.NAME,"Kill all node.js processes"); 51 | hashMap.put(Action.SHORT_DESCRIPTION, "Kill all node.js processes"); 52 | } 53 | 54 | @Override 55 | public Object getValue(String key) { 56 | return hashMap.get(key); 57 | } 58 | 59 | @Override 60 | public void putValue(String key, Object value) { 61 | hashMap.put(key, value); 62 | } 63 | 64 | @Override 65 | public void setEnabled(boolean b) { 66 | this.enabled = b; 67 | } 68 | 69 | @Override 70 | public boolean isEnabled() { 71 | return true; 72 | } 73 | 74 | @Override 75 | public void addPropertyChangeListener(PropertyChangeListener listener) { 76 | } 77 | 78 | @Override 79 | public void removePropertyChangeListener(PropertyChangeListener listener) { 80 | } 81 | 82 | @Override 83 | public void actionPerformed(ActionEvent e) { 84 | try { 85 | String[] cmd = MultiOSCmd.createKillCmd(); 86 | if (cmd == null) { 87 | return; 88 | } 89 | 90 | IOColorLines.println(this.io, WinPath.concatStringArray(cmd), Color.lightGray); 91 | final Process proc = Runtime.getRuntime().exec(cmd); 92 | 93 | final BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream())); 94 | final BufferedReader readerr = new BufferedReader(new InputStreamReader(proc.getErrorStream())); 95 | // thx to Andrew Skiba http://andskiba.blogspot.com/2011/09/nodejs-plugin-for-netbeans-and-daemons.html 96 | final AtomicBoolean done = new AtomicBoolean(false); 97 | new Thread(new Runnable() { 98 | @Override 99 | public void run() { 100 | try { 101 | while (!done.get()) { 102 | Thread.sleep(50); 103 | while (read.ready()) { 104 | out.println(read.readLine()); 105 | } 106 | while (readerr.ready()) { 107 | //printErrLine(readerr.readLine(), io); 108 | IOColorLines.println(io, readerr.readLine(), Color.RED); 109 | } 110 | 111 | } 112 | 113 | read.close(); 114 | readerr.close(); 115 | 116 | } catch (Exception ex) { 117 | Exceptions.printStackTrace(ex); 118 | } 119 | } 120 | }).start(); 121 | new Thread(new Runnable() { 122 | @Override 123 | public void run() { 124 | try { 125 | proc.waitFor(); 126 | } catch (InterruptedException ex) { 127 | Exceptions.printStackTrace(ex); 128 | } finally { 129 | done.set(true); 130 | } 131 | } 132 | }).start(); 133 | } catch (IOException ex) { 134 | Exceptions.printStackTrace(ex); 135 | } 136 | 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/nbm/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | OpenIDE-Module: cz.kec.nb.nodejs 3 | OpenIDE-Module-Display-Category: JavaScript 4 | OpenIDE-Module-Localizing-Bundle: cz/kec/nb/nodejs/Bundle.properties 5 | OpenIDE-Module-Layer: cz/kec/nb/nodejs/layer.xml 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/cz/kec/nb/nodejs/Bundle.properties: -------------------------------------------------------------------------------- 1 | AdvancedOption_DisplayName_NodeJSOptions=Node.js 2 | AdvancedOption_Keywords_NodeJSOptions=node.js javascript 3 | AdvancedOption_Tooltip_NodeJSOptions=Node.js runner 4 | CTL_RunNode=Run with Node.js 5 | OpenIDE-Module-Display-Category=JavaScript 6 | OpenIDE-Module-Long-Description=\ 7 | NodeJS for NetBeans IDE
2009 \u00a9 Syntea software group a.s.\ 8 | \n
\nExecute selected javascript file with editable command. \ 9 | Default command is node /blah/blah/some.js.\ 10 |
\nWorks with Linux, Windows and shoud work on Mac too!\ 11 | \n


\n


\nDaniel Kec 12 | OpenIDE-Module-Name=NodeJS 13 | NodeJSOptionsPanel.jLabel1.text=Default run command: 14 | NodeJSOptionsPanel.jButton1.text=Reset 15 | OpenIDE-Module-Short-Description=Node.js support in Netbeans IDE 16 | NodeJSOptionsPanel.jLabel2.text=Default kill command: 17 | NodeJSOptionsPanel.runCommandjEditorPane1.text=cd ${workingdir} && node ${selectedfile} 18 | NodeJSOptionsPanel.resetForWinjButton2.text=Reset for Windows 19 | -------------------------------------------------------------------------------- /src/main/resources/cz/kec/nb/nodejs/layer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 21 | 33 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/cz/kec/nb/nodejs/stop-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/src/main/resources/cz/kec/nb/nodejs/stop-icon.png -------------------------------------------------------------------------------- /src/main/resources/cz/kec/nb/nodejs/win.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danielkec/NodeJS/587d18e7dc2ca3ed5caa7154501f53aded2f2fc5/src/main/resources/cz/kec/nb/nodejs/win.png --------------------------------------------------------------------------------