├── wiki ├── dreamscape │ ├── temp.md │ ├── notes.png │ ├── geonames.png │ ├── enter-task.png │ ├── login-lang.png │ ├── new-geoname.png │ ├── geonames-link.png │ ├── invalid-link.png │ ├── not-annotated.png │ ├── bishop-annotation.png │ └── select-annotations.png ├── mac-open-file-menu.png └── mac-open-file-button.png ├── lib ├── asm-5.0.1.jar ├── ecj-4.4.2.jar ├── asm-tree-5.0.1.jar ├── apache-el-8.0.27.jar ├── apache-jsp-8.0.27.jar ├── asm-commons-5.0.1.jar ├── jetty-schemas-3.1.jar ├── javax.servlet-api-3.1.0.jar ├── javax.annotation-api-1.2.jar ├── jetty-io-9.3.7.v20160115.jar ├── jetty-xml-9.3.7.v20160115.jar ├── apache-jsp-9.3.7.v20160115.jar ├── apache-jstl-9.3.7.v20160115.jar ├── jetty-http-9.3.7.v20160115.jar ├── jetty-jndi-9.3.7.v20160115.jar ├── jetty-plus-9.3.7.v20160115.jar ├── jetty-server-9.3.7.v20160115.jar ├── jetty-util-9.3.7.v20160115.jar ├── jetty-webapp-9.3.7.v20160115.jar ├── taglibs-standard-impl-1.2.5.jar ├── taglibs-standard-spec-1.2.5.jar ├── jetty-security-9.3.7.v20160115.jar ├── jetty-servlet-9.3.7.v20160115.jar └── jetty-annotations-9.3.7.v20160115.jar ├── src └── org │ ├── aw20 │ ├── logo │ │ └── aw20.jpg │ ├── jettydesktop │ │ ├── ui │ │ │ ├── ExecutorInterface.java │ │ │ ├── ConfigActionInterface.java │ │ │ ├── ServerConfigMap.java │ │ │ ├── Executor.java │ │ │ ├── awt │ │ │ │ ├── ServerTab.java │ │ │ │ └── ServerConfig.java │ │ │ └── Start.java │ │ └── rte │ │ │ ├── JettyRunTime.java │ │ │ └── webdefault.xml │ └── util │ │ ├── SocketUtil.java │ │ └── DateUtil.java │ └── voyanttools │ ├── resources │ └── voyant_small.png │ └── server │ └── ui │ ├── VoyantServerStartHeadless.java │ ├── ServerConfig.java │ ├── VoyantServerStart.java │ └── awt │ ├── NewJPanel.java │ ├── NewJPanel.form │ └── VoyantServerTab.java ├── .gitignore ├── README.md ├── server-settings.txt └── license-GPL3.txt /wiki/dreamscape/temp.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /lib/asm-5.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/asm-5.0.1.jar -------------------------------------------------------------------------------- /lib/ecj-4.4.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/ecj-4.4.2.jar -------------------------------------------------------------------------------- /lib/asm-tree-5.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/asm-tree-5.0.1.jar -------------------------------------------------------------------------------- /lib/apache-el-8.0.27.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/apache-el-8.0.27.jar -------------------------------------------------------------------------------- /lib/apache-jsp-8.0.27.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/apache-jsp-8.0.27.jar -------------------------------------------------------------------------------- /lib/asm-commons-5.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/asm-commons-5.0.1.jar -------------------------------------------------------------------------------- /lib/jetty-schemas-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-schemas-3.1.jar -------------------------------------------------------------------------------- /src/org/aw20/logo/aw20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/src/org/aw20/logo/aw20.jpg -------------------------------------------------------------------------------- /wiki/dreamscape/notes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/notes.png -------------------------------------------------------------------------------- /wiki/dreamscape/geonames.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/geonames.png -------------------------------------------------------------------------------- /wiki/mac-open-file-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/mac-open-file-menu.png -------------------------------------------------------------------------------- /lib/javax.servlet-api-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/javax.servlet-api-3.1.0.jar -------------------------------------------------------------------------------- /wiki/dreamscape/enter-task.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/enter-task.png -------------------------------------------------------------------------------- /wiki/dreamscape/login-lang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/login-lang.png -------------------------------------------------------------------------------- /wiki/dreamscape/new-geoname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/new-geoname.png -------------------------------------------------------------------------------- /wiki/mac-open-file-button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/mac-open-file-button.png -------------------------------------------------------------------------------- /lib/javax.annotation-api-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/javax.annotation-api-1.2.jar -------------------------------------------------------------------------------- /lib/jetty-io-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-io-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-xml-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-xml-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /wiki/dreamscape/geonames-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/geonames-link.png -------------------------------------------------------------------------------- /wiki/dreamscape/invalid-link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/invalid-link.png -------------------------------------------------------------------------------- /wiki/dreamscape/not-annotated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/not-annotated.png -------------------------------------------------------------------------------- /lib/apache-jsp-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/apache-jsp-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/apache-jstl-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/apache-jstl-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-http-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-http-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-jndi-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-jndi-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-plus-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-plus-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-server-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-server-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-util-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-util-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-webapp-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-webapp-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/taglibs-standard-impl-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/taglibs-standard-impl-1.2.5.jar -------------------------------------------------------------------------------- /lib/taglibs-standard-spec-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/taglibs-standard-spec-1.2.5.jar -------------------------------------------------------------------------------- /lib/jetty-security-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-security-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /lib/jetty-servlet-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-servlet-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /wiki/dreamscape/bishop-annotation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/bishop-annotation.png -------------------------------------------------------------------------------- /wiki/dreamscape/select-annotations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/wiki/dreamscape/select-annotations.png -------------------------------------------------------------------------------- /lib/jetty-annotations-9.3.7.v20160115.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/lib/jetty-annotations-9.3.7.v20160115.jar -------------------------------------------------------------------------------- /src/org/voyanttools/resources/voyant_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgsinclair/VoyantServer/master/src/org/voyanttools/resources/voyant_small.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | .project 6 | .metadata 7 | bin/ 8 | tmp/ 9 | work/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .tomcatplugin 17 | .settings/ 18 | /target 19 | src/main/webapp/WEB-INF/classes 20 | /_app 21 | /dist 22 | /VoyantServerNoNlp.zip 23 | /VoyantServer.zip 24 | /logs 25 | /data 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### With the passing of Stéfan Sinclair, this repository has been archived. #### 2 | #### Please see [voyanttools/VoyantServer](https://github.com/voyanttools/VoyantServer) for future development. #### 3 | 4 | ## Voyant Server ## 5 | 6 | Voyant Server is a web application launcher for Voyant Tools – it makes it easy to run a stand-alone instance of Voyant Tools on your local machine, which has several potential advantages (performance, security, privacy, reliability, etc.) compared to the [hosted version](http://voyant-tools.org). 7 | 8 | ## Installation ## 9 | 10 | See the [latest release](https://github.com/sgsinclair/VoyantServer/releases/latest) and download the VoyantServer zip file. Unzip the file (be sure to actually extract the contents into a real directory) and double-click on the VoyantServer.jar file (on Macs you may need to Ctrl-click on the VoyantServer.jar, select open and confirm the opening – this is because of security precautions in OS X). 11 | 12 | Once you open VoyantServer.jar a controller application will appear (that allows you stop stop the server, see error messages, change settings, etc.) and a new browser will also appear with Voyant Tools. That's it! 13 | 14 | ## License ## 15 | Voyant Server is released under the same license as JettyDesktop, the GNU General Public License v3.0 (see license-GPL3.txt in this directory). 16 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/ExecutorInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui; 27 | 28 | 29 | public interface ExecutorInterface { 30 | 31 | public void onServerStart(); 32 | public void onServerExit(); 33 | public void onConsole( String message ); 34 | public void onMemory(String memory); 35 | 36 | } -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/ConfigActionInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui; 27 | 28 | 29 | public interface ConfigActionInterface { 30 | 31 | public void onEdit( ServerConfigMap scm ); 32 | public void onDelete( ServerConfigMap scm ); 33 | public void onClose( ServerConfigMap scm ); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/org/aw20/util/SocketUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.util; 27 | 28 | import java.net.InetSocketAddress; 29 | import java.net.Socket; 30 | 31 | public class SocketUtil extends Object { 32 | 33 | public static boolean isRemotePortAlive( String ip, int port ){ 34 | return isRemotePortAlive( ip, port, 3000 ); 35 | } 36 | 37 | public static boolean isRemotePortAlive( String ip, int port, int timeoutMs ){ 38 | try{ 39 | 40 | Socket s = new Socket(); 41 | s.connect( new InetSocketAddress( ip, port ), timeoutMs ); 42 | s.close(); 43 | return true; 44 | 45 | }catch(Exception e){ 46 | return false; 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/VoyantServerStartHeadless.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.voyanttools.server.ui; 5 | 6 | import java.io.IOException; 7 | 8 | import org.aw20.jettydesktop.rte.JettyRunTime; 9 | import org.aw20.jettydesktop.ui.ConfigActionInterface; 10 | import org.aw20.jettydesktop.ui.Executor; 11 | import org.aw20.jettydesktop.ui.ExecutorInterface; 12 | import org.aw20.jettydesktop.ui.ServerConfigMap; 13 | 14 | /** 15 | * @author sgs 16 | * 17 | */ 18 | public class VoyantServerStartHeadless implements ConfigActionInterface, ExecutorInterface { 19 | 20 | /** 21 | * @throws IOException 22 | * 23 | */ 24 | public VoyantServerStartHeadless(ServerConfigMap serverConfigMap) throws IOException { 25 | Executor executor = new Executor(serverConfigMap, this); 26 | } 27 | 28 | /* (non-Javadoc) 29 | * @see org.aw20.jettydesktop.ui.ConfigActionInterface#onEdit(org.aw20.jettydesktop.ui.ServerConfigMap) 30 | */ 31 | @Override 32 | public void onEdit(ServerConfigMap scm) { 33 | onConsole("edit"); 34 | } 35 | 36 | /* (non-Javadoc) 37 | * @see org.aw20.jettydesktop.ui.ConfigActionInterface#onDelete(org.aw20.jettydesktop.ui.ServerConfigMap) 38 | */ 39 | @Override 40 | public void onDelete(ServerConfigMap scm) { 41 | onConsole("delete"); 42 | } 43 | 44 | /* (non-Javadoc) 45 | * @see org.aw20.jettydesktop.ui.ConfigActionInterface#onClose(org.aw20.jettydesktop.ui.ServerConfigMap) 46 | */ 47 | @Override 48 | public void onClose(ServerConfigMap scm) { 49 | onConsole("close"); 50 | } 51 | 52 | @Override 53 | public void onServerStart() { 54 | onConsole("server start"); 55 | } 56 | 57 | @Override 58 | public void onServerExit() { 59 | onConsole("server exit"); 60 | } 61 | 62 | @Override 63 | public void onConsole(String message) { 64 | System.out.println(message); 65 | if ( message.indexOf( JettyRunTime.JETTYSTARTED ) != -1 ) { 66 | System.out.println("\n\nPlease note that you will need to kill the Jetty process yourself since it's running separately."); 67 | } 68 | } 69 | 70 | @Override 71 | public void onMemory(String memory) { 72 | onConsole("memory"); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/ServerConfigMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui; 27 | 28 | import java.io.Serializable; 29 | import java.util.HashMap; 30 | 31 | public class ServerConfigMap extends HashMap implements Serializable { 32 | private static final long serialVersionUID = 1L; 33 | 34 | @SuppressWarnings("serial") 35 | public static ServerConfigMap getDefault(){ 36 | return new ServerConfigMap(){{ 37 | setName(""); 38 | setIP("127.0.0.1"); 39 | setPort("8888"); 40 | setWebFolder(""); 41 | setCurrentJVM(); 42 | setMemoryJVM("1024"); 43 | setLogsFile(false); 44 | setAllowInput(true); 45 | }}; 46 | } 47 | 48 | public void setName(String name){ 49 | put("SERVER_NAME", name); 50 | } 51 | 52 | public String getName(){ 53 | return get("SERVER_NAME"); 54 | } 55 | 56 | public void setIP(String ip){ 57 | put("SERVER_IP", ip); 58 | } 59 | 60 | public String getIP(){ 61 | return get("SERVER_IP"); 62 | } 63 | 64 | public void setPort(String port){ 65 | put("SERVER_PORT", port); 66 | } 67 | 68 | public String getPort(){ 69 | return get("SERVER_PORT"); 70 | } 71 | 72 | public void setWebFolder(String webfolder){ 73 | put("WEBFOLDER", webfolder); 74 | } 75 | 76 | public String getWebFolder(){ 77 | return get("WEBFOLDER"); 78 | } 79 | 80 | public void setCustomJVM(String customFolder){ 81 | put("CUSTOMJVM", customFolder); 82 | remove("CURRENTJVM"); 83 | } 84 | 85 | public String getCustomJVM(){ 86 | return get("CUSTOMJVM"); 87 | } 88 | 89 | public void setCurrentJVM(){ 90 | put("CURRENTJVM", "1"); 91 | remove("CUSTOMJVM"); 92 | } 93 | 94 | public String getCurrentJVM(){ 95 | return get("CURRENTJVM"); 96 | } 97 | 98 | public void setMemoryJVM(String memory){ 99 | put("MEMORYJVM", memory); 100 | } 101 | 102 | public String getMemoryJVM(){ 103 | return get("MEMORYJVM"); 104 | } 105 | 106 | public String getDefaultJVMArgs() { 107 | return get("DEFAULTJVM"); 108 | } 109 | 110 | public String getDefaultWebUri() { 111 | return get("DEFAULTURI"); 112 | } 113 | 114 | public void setDefaultJVMArgs(String args) { 115 | put("DEFAULTJVM", args); 116 | } 117 | 118 | public void setDefaultWebUri(String args) { 119 | put("DEFAULTURI", args.trim() ); 120 | } 121 | 122 | public void setLogsFile(boolean fileLogs) { 123 | put("LOGSFILE", fileLogs ? "true" : "false"); 124 | } 125 | 126 | public boolean getLogsFile() { 127 | return this.containsKey("LOGSFILE") && get("LOGSFILE").equals("true"); 128 | } 129 | 130 | public void setDataFolder(String folder) { 131 | put("DATAFOLDER", folder); 132 | } 133 | 134 | public String getDataFolder() { 135 | return get("DATAFOLDER"); 136 | } 137 | 138 | public void setAllowInput(boolean allow) { 139 | put("allow_input", allow ? "true" : "false"); 140 | } 141 | 142 | public boolean getAllowInput() { 143 | return this.containsKey("allow_input") && get("allow_input").equals("false") ? false : true; 144 | } 145 | } -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/ServerConfig.java: -------------------------------------------------------------------------------- 1 | package org.voyanttools.server.ui; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.net.URL; 8 | import java.util.Properties; 9 | 10 | import org.aw20.jettydesktop.ui.ServerConfigMap; 11 | 12 | public class ServerConfig { 13 | 14 | public static ServerConfigMap getStoredServerConfig() throws IOException { 15 | return getStoredServerConfig(getFile()); 16 | } 17 | public static ServerConfigMap getStoredServerConfig(File file) throws IOException { 18 | ServerConfigMap serverConfigMap = new ServerConfigMap(){{ 19 | setName("Voyant"); 20 | setIP(""); 21 | setPort("8888"); 22 | setWebFolder(System.getProperty("user.dir") + File.separator + "_app"); 23 | setCurrentJVM(); 24 | setMemoryJVM("1024"); 25 | setLogsFile(false); 26 | setAllowInput(true); 27 | }}; 28 | Properties properties = new Properties(); 29 | serverConfigMap.put("lastModified", String.valueOf(file.lastModified())); 30 | FileInputStream fis = new FileInputStream(file); 31 | properties.load(fis); 32 | fis.close(); 33 | for (String name : properties.stringPropertyNames()) { 34 | String val = properties.getProperty(name).trim(); 35 | String prop = System.getProperty("org.voyanttools.server."+name); // allow items to be overwritten on the command line 36 | if (val.isEmpty() && prop==null) { continue;} 37 | if (name.equals("port")) { 38 | serverConfigMap.setPort(prop==null ? val : prop); 39 | } 40 | else if (name.equals("memory")) { 41 | serverConfigMap.setMemoryJVM(prop==null ? val : prop); 42 | } 43 | else if (name.equals("data_directory")) { 44 | serverConfigMap.setDataFolder(prop==null ? val : prop); 45 | } 46 | else if (name.equals("uri_path")) { 47 | serverConfigMap.setDefaultWebUri(prop==null ? val : prop); 48 | } 49 | else if (name.equals("host")) { 50 | serverConfigMap.setIP(prop==null ? val : prop); 51 | } 52 | // else if (name.equals("logs_file")) { 53 | // serverConfigMap.setLogsFile(prop==null ? val.equals("true") : prop.equals("true")); 54 | // } 55 | else { 56 | serverConfigMap.put(name, properties.getProperty(name)); 57 | } 58 | } 59 | 60 | String dataFolder = serverConfigMap.getDataFolder(); 61 | if (dataFolder==null || dataFolder.isEmpty()) { 62 | File dataFile = new File("data"); 63 | if (dataFile.exists()) { 64 | serverConfigMap.setDataFolder(dataFile.getAbsolutePath()); 65 | } 66 | else { 67 | File voyantFile = new File(System.getProperty("java.io.tmpdir"), "VoyantServer"); 68 | if (!voyantFile.exists()) { 69 | if (!voyantFile.mkdir()) { 70 | throw new IOException("Can't create temporary directory: "+voyantFile); 71 | } 72 | } 73 | serverConfigMap.setDataFolder(voyantFile.getAbsolutePath()); 74 | } 75 | } 76 | 77 | File dataFile = new File(serverConfigMap.getDataFolder()); 78 | if (!dataFile.exists()) { 79 | throw new IOException("Data folder must already exist, VoyantServer won't create it: "+dataFile.getAbsolutePath()); 80 | } 81 | 82 | // set java.io.tmpdir for voyant data 83 | serverConfigMap.setDefaultJVMArgs((serverConfigMap.getDefaultJVMArgs()!=null ? serverConfigMap.getDefaultJVMArgs()+" " : "") +"-Djava.io.tmpdir="+new File(serverConfigMap.getDataFolder()).getAbsolutePath() ); 84 | 85 | String prop = System.getProperty("org.voyanttools.server.logs_file"); // allow items to be overwritten on the command line 86 | if (prop!=null || properties.getProperty("logs_file", "").equals("true")) { 87 | serverConfigMap.setLogsFile(prop==null ? true : prop.equals("true")); 88 | } 89 | 90 | return serverConfigMap; 91 | } 92 | 93 | public static boolean isModified(ServerConfigMap serverConfigMap) { 94 | File file = getFile(); 95 | return file.lastModified() > Long.valueOf(serverConfigMap.get("lastModified")); 96 | } 97 | 98 | private static File getFile() { 99 | return new File("server-settings.txt"); 100 | } 101 | 102 | public static void main(String[] args) throws IOException { 103 | ServerConfig.getStoredServerConfig(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /server-settings.txt: -------------------------------------------------------------------------------- 1 | ### Settings for VoyantServer ### 2 | 3 | # These are settings that define default values for VoyantServer. In most cases 4 | # the indicated values can be used (or blank to use a default). You can also 5 | # override the values in this settings file if you launch VoyantServer from the 6 | # command line by using -Dorg.voyanttools.server.SETTING=VALUE. For instance: 7 | # java -Dorg.voyanttools.server.memory=2048 -jar VoyantServer.jar headless=true 8 | 9 | # The port to use for the web server (default is 8888). If a port is already in use, 10 | # this can be changed (8889, etc.). If the server terminated unexpectedly the port 11 | # may continue being used and restarting the machine is one way of resetting things. 12 | port = 8888 13 | 14 | # The amount of memory in MB to allocate to the server. The default value here (1024) 15 | # is higher than needed in most cases, but with very large text collections, it may 16 | # need to be even higher (2048, 4096, etc.) 17 | memory = 1024 18 | 19 | # The absolute path to an existing parent directory that the server should use for data. 20 | # The server doesn't delete data when it's terminated but by default the data folder 21 | # can be a temporary directory that may disappear after a machine restart. 22 | # Leave this blank to use the default directory. The default directory will be a 23 | # temporary directory determined by your operation system UNLESS there's a folder 24 | # called data in the same directory as this settings file – in that case the data folder 25 | # will be used. If you want this behaviour, just create an empty data folder in this 26 | # directory (after that, you can zip up the parent folder and redistribute VoyantServer 27 | # with existing data – this can be used in conjunction with the uri_path below to open 28 | # up an existing corpus automatically (/?corpus=id where id is replaced by the real 29 | # corpus ID that you've created). If the data directory exists and you want to use it 30 | # leave this value blank. 31 | data_directory = 32 | 33 | # The URI path (after the domain) to use (default is /). This is a good way to provide 34 | # load a corpus by default, ex: uri_path = /?input=http://cbc.ca/news/ or /?corpus=333.333 35 | # (where 333.333 is an existing local corpus). 36 | # It's also possible to build a custom menu for the open menu on the front page. Separate 37 | # the corpus ID and a label by a colon and separate multiple entries by commas, making sure 38 | # to escape characters (like spaces), eg: /?openMenu=444.444:Corpus+One;555.555:Corpus+Two 39 | uri_path = / 40 | 41 | # This allows you to limit traffic to the specific host (domain or IP). By default (127.0.0.1) 42 | # it is set to be restrictive and to only accept local requests (in order to favour privacy). 43 | # VoyantServer is also a convenient way to host an instance of Voyant Tools that you might 44 | # want to have more widely accessible, in which case you should comment out this line or remove 45 | # the value. 46 | # host = 127.0.0.1 47 | 48 | # By default VoyantServer will direct output to the console window within the VoyantServer 49 | # application (this is a useful place to see what's happening, especially when things go 50 | # wrong); when in headless mode, logs are simply directed to the standard output. This 51 | # setting allows you to direct VoyantServer logs to a file instead, which is especially 52 | # useful when you want to leave a server running and detached from the console 53 | # value should be true or anything else for false (including blank). 54 | logs_file = 55 | 56 | # This option defines which corpora appear in the drop-down menu when the user opens an 57 | # existing corpus. If this is commented out or blank then the default value is used 58 | # (currently the Austen and Shakespeare corpora). Corpora are defined using a special 59 | # syntax: corpusID:label and multiple corpora are separated by semi-colon. For instance, 60 | # this would be the default: 61 | # open_menu = shakespeare:Shakespeare's Plays;austen:Austen's Novels 62 | open_menu = 63 | 64 | # This allows you to prevent Voyant from accepting any further input, in other words no new 65 | # documents can be added. That doesn't necessarily mean no new corpora can be created, there 66 | # may be a new corpus based on a subset of an existing corpus. The default value is true 67 | # (to allow new input), set this to false to prevent new input from being added. 68 | allow_input = true -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/VoyantServerStart.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.voyanttools.server.ui; 5 | 6 | import java.awt.BorderLayout; 7 | import java.awt.Dimension; 8 | import java.awt.EventQueue; 9 | import java.awt.Toolkit; 10 | import java.awt.event.ActionEvent; 11 | import java.awt.event.ActionListener; 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | import javax.swing.JFrame; 17 | import javax.swing.JMenu; 18 | import javax.swing.JMenuBar; 19 | import javax.swing.JMenuItem; 20 | import javax.swing.JTabbedPane; 21 | import javax.swing.UIManager; 22 | import javax.swing.WindowConstants; 23 | 24 | import org.aw20.jettydesktop.ui.ServerConfigMap; 25 | import org.aw20.jettydesktop.ui.Start; 26 | import org.voyanttools.server.ui.awt.VoyantServerTab; 27 | 28 | /** 29 | * @author sgs 30 | * 31 | */ 32 | public class VoyantServerStart extends Start { 33 | 34 | public static final String VERSION = "2.2"; 35 | 36 | private JFrame frame; 37 | 38 | private JTabbedPane tabbedPane; 39 | 40 | protected List serverConfigList; 41 | 42 | 43 | /** 44 | * @throws IOException 45 | * 46 | */ 47 | public VoyantServerStart(ServerConfigMap serverConfigMap) throws IOException { 48 | initialize(serverConfigMap); 49 | } 50 | 51 | 52 | public static void main(String[] args) { 53 | File file = new File(System.getProperty("user.dir"), "server-settings.txt"); 54 | for (String arg : args) { 55 | if (arg.startsWith("settings=") && arg.length()>9) { 56 | file = new File(arg.substring(9)); 57 | if (file.exists()==false) { 58 | file = new File(System.getProperty("user.dir"), "server-settings.txt"); 59 | } 60 | if (file.exists()==false) { 61 | throw new IllegalArgumentException("Could not find specified settings file: "+file); 62 | } 63 | } 64 | } 65 | final ServerConfigMap serverConfigMap; 66 | try { 67 | serverConfigMap = ServerConfig.getStoredServerConfig(file); 68 | } catch (IOException e1) { 69 | throw new RuntimeException(e1); 70 | } 71 | 72 | for (String string : args) { 73 | if (string.contains("headless=true")) { 74 | try { 75 | VoyantServerStartHeadless voyantServerStartHeadless = new VoyantServerStartHeadless(serverConfigMap); 76 | } catch (IOException e) { 77 | // TODO Auto-generated catch block 78 | e.printStackTrace(); 79 | } 80 | return; // don't create gui 81 | } 82 | } 83 | EventQueue.invokeLater(new Runnable() { 84 | public void run() { 85 | try { 86 | 87 | System.setProperty("apple.eawt.quitStrategy", "CLOSE_ALL_WINDOWS"); 88 | 89 | // only seems to work for Java 1.6< 90 | // take the menu bar off the jframe 91 | System.setProperty("apple.laf.useScreenMenuBar", "true"); 92 | // set the name of the application menu item 93 | System.setProperty("com.apple.mrj.application.apple.menu.about.name", "VoyantServer"); 94 | 95 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 96 | final VoyantServerStart window = new VoyantServerStart(serverConfigMap); 97 | window.frame.setVisible(true); 98 | 99 | if (System.getProperty("os.name").equals("Mac OS X")) 100 | { 101 | Runtime.getRuntime().addShutdownHook(new Thread() 102 | { 103 | @Override 104 | public void run() 105 | { 106 | window.stopServers(); 107 | } 108 | }); 109 | } 110 | 111 | } catch (Exception e) { 112 | e.printStackTrace(); 113 | } 114 | } 115 | }); 116 | } 117 | 118 | private void initialize(ServerConfigMap serverConfigMap) throws IOException { 119 | frame = new JFrame(); 120 | frame.setTitle("Voyant Server"); 121 | frame.setBounds(100, 100, 610, 414); 122 | frame.setMinimumSize( new Dimension(610, 414) ); 123 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 124 | frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/voyanttools/resources/voyant_small.png"))); 125 | 126 | frame.addWindowListener(new java.awt.event.WindowAdapter() { 127 | public void windowClosing(java.awt.event.WindowEvent e) { 128 | terminateApp(); 129 | } 130 | }); 131 | 132 | JMenuBar menuBar = new JMenuBar(); 133 | frame.setJMenuBar(menuBar); 134 | 135 | JMenu mnFile = new JMenu("File"); 136 | menuBar.add(mnFile); 137 | 138 | JMenuItem mntmExit = new JMenuItem("Exit"); 139 | mnFile.add(mntmExit); 140 | mntmExit.addActionListener(new ActionListener() { 141 | public void actionPerformed(ActionEvent e) { 142 | terminateApp(); 143 | } 144 | }); 145 | 146 | JMenu mnHelp = new JMenu("Help"); 147 | menuBar.add(mnHelp); 148 | 149 | JMenuItem mntmSupportSite = new JMenuItem("Visit Voyant Server Help Page"); 150 | mntmSupportSite.addActionListener(new ActionListener() { 151 | public void actionPerformed(ActionEvent e) { 152 | try { 153 | java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://docs.voyant-tools.org/voyant-server/")); 154 | } catch (IOException e1) { 155 | e1.printStackTrace(); 156 | } 157 | } 158 | }); 159 | mnHelp.add(mntmSupportSite); 160 | 161 | // We need to add a new tab 162 | VoyantServerTab sT = new VoyantServerTab(this, serverConfigMap); 163 | 164 | frame.getContentPane().add(sT, BorderLayout.CENTER); 165 | } 166 | 167 | private void stopServers() { 168 | VoyantServerTab sT = (VoyantServerTab)frame.getContentPane().getComponent(0); 169 | if ( sT.isServerRunning() ) { 170 | sT.stopServer(); 171 | } 172 | } 173 | protected boolean terminateApp() { 174 | stopServers(); 175 | System.exit(1); 176 | return true; 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/rte/JettyRunTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.rte; 27 | 28 | import java.io.OutputStreamWriter; 29 | import java.io.PrintWriter; 30 | import java.net.InetSocketAddress; 31 | import java.net.ServerSocket; 32 | import java.net.Socket; 33 | import java.util.ArrayList; 34 | import java.util.List; 35 | 36 | import org.eclipse.jetty.apache.jsp.JettyJasperInitializer; 37 | import org.eclipse.jetty.plus.annotation.ContainerInitializer; 38 | import org.eclipse.jetty.server.Server; 39 | import org.eclipse.jetty.webapp.Configuration; 40 | import org.eclipse.jetty.webapp.WebAppContext; 41 | 42 | public class JettyRunTime extends Object { 43 | 44 | public static String JETTYSTARTED = "... Jetty has started."; 45 | 46 | public static void main(String[] args) { 47 | System.out.println( "Jetty Version: " + Server.getVersion() ); 48 | 49 | if ( args.length == 3 ) 50 | System.out.println( "http://*:" + args[0] ); 51 | else 52 | System.out.println( "http://" + args[0] + ":" + args[1] ); 53 | 54 | try { 55 | if ( args.length == 3 ) 56 | new JettyRunTime( null, args[0], args[1], args[2] ); 57 | else 58 | new JettyRunTime( args[0], args[1], args[2], args[3] ); 59 | } catch (Exception e) { 60 | System.out.println( e.getMessage() ); 61 | } 62 | } 63 | 64 | private Server server; 65 | 66 | public JettyRunTime( String ip, String port, String webapp, String adminport ) throws Exception{ 67 | System.out.println( "Jetty starting up ... please wait" ); 68 | 69 | // Set JSP to use Standard JavaC always 70 | System.setProperty("org.apache.jasper.compiler.disablejsr199", "false"); 71 | 72 | if ( ip == null ) 73 | server = new Server( Integer.valueOf(port) ); 74 | else 75 | server = new Server( InetSocketAddress.createUnresolved(ip, Integer.valueOf(port)) ); 76 | 77 | int aport = Integer.valueOf(adminport); 78 | if ( aport > 0 ){ 79 | new adminPort(aport); 80 | } 81 | 82 | WebAppContext context = new WebAppContext(); 83 | 84 | // This webapp will use jsps and jstl. We need to enable the 85 | // AnnotationConfiguration in order to correctly 86 | // set up the jsp container 87 | Configuration.ClassList classlist = Configuration.ClassList 88 | .setServerDefault( server ); 89 | classlist.addBefore( 90 | "org.eclipse.jetty.webapp.JettyWebXmlConfiguration", 91 | "org.eclipse.jetty.annotations.AnnotationConfiguration" ); 92 | 93 | // Set the ContainerIncludeJarPattern so that jetty examines these 94 | // container-path jars for tlds, web-fragments etc. 95 | // If you omit the jar that contains the jstl .tlds, the jsp engine will 96 | // scan for them instead. 97 | context.setAttribute( 98 | "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", 99 | ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$" ); 100 | 101 | 102 | context.setDescriptor( webapp + "/WEB-INF/web.xml"); 103 | context.setResourceBase( webapp ); 104 | context.setContextPath("/"); 105 | context.setParentLoaderPriority(true); 106 | context.setDefaultsDescriptor("org/aw20/jettydesktop/rte/webdefault.xml"); 107 | 108 | server.setHandler(context); 109 | server.start(); 110 | 111 | System.out.println( JETTYSTARTED ); 112 | } 113 | 114 | /** 115 | * Ensure the jsp engine is initialized correctly 116 | */ 117 | private List jspInitializers() 118 | { 119 | JettyJasperInitializer sci = new JettyJasperInitializer(); 120 | ContainerInitializer initializer = new ContainerInitializer(sci, null); 121 | List initializers = new ArrayList(); 122 | initializers.add(initializer); 123 | return initializers; 124 | } 125 | class adminPort extends Thread { 126 | 127 | ServerSocket ss; 128 | Socket s; 129 | int port; 130 | PrintWriter pw; 131 | 132 | public adminPort( int port ){ 133 | this.port = port; 134 | setDaemon(true); 135 | start(); 136 | } 137 | 138 | public void run(){ 139 | try { 140 | ss = new ServerSocket(port); 141 | s = ss.accept(); 142 | pw = new PrintWriter( new OutputStreamWriter( s.getOutputStream() ) ); 143 | 144 | for(;;){ 145 | Thread.sleep(2000); 146 | 147 | long freeMem = (Runtime.getRuntime().freeMemory() / 1024000); 148 | long totalMem = (Runtime.getRuntime().totalMemory() / 1024000); 149 | long usedMem = totalMem - freeMem; 150 | pw.println("Memory Usage: " + usedMem + "MB of " + totalMem + "MB "); 151 | pw.flush(); 152 | 153 | } 154 | 155 | } catch (Exception e) { 156 | System.out.println(e); 157 | } 158 | 159 | } 160 | 161 | } 162 | 163 | } -------------------------------------------------------------------------------- /src/org/aw20/util/DateUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 AW2.0 Ltd 3 | * 4 | * org.aw20 is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * Free Software Foundation,version 3. 7 | * 8 | * OpenBD is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with org.aw20. If not, see http://www.gnu.org/licenses/ 15 | * 16 | * Additional permission under GNU GPL version 3 section 7 17 | * 18 | * If you modify this Program, or any covered work, by linking or combining 19 | * it with any of the JARS listed in the README.txt (or a modified version of 20 | * (that library), containing parts covered by the terms of that JAR, the 21 | * licensors of this Program grant you additional permission to convey the 22 | * resulting work. 23 | * 24 | * $Id: FileUtil.java 2981 2012-08-08 21:01:27Z alan $ 25 | */ 26 | package org.aw20.util; 27 | 28 | import java.text.DateFormat; 29 | import java.text.ParsePosition; 30 | import java.text.SimpleDateFormat; 31 | import java.util.Date; 32 | 33 | public class DateUtil extends Object { 34 | 35 | public static long SECS_MS = 1000; 36 | public static long MINS_MS = 60 * SECS_MS; 37 | public static long HOUR_MS = 60 * MINS_MS; 38 | public static long DAY_MS = 24 * HOUR_MS; 39 | public static long WEEK_MS = 7 * DAY_MS; 40 | public static long MONTH_MS = 31 * DAY_MS; 41 | public static long YEAR_MS = 52 * WEEK_MS; 42 | 43 | public static java.util.Date parseHttpDate( String _dateStr ){ 44 | if ( _dateStr == null ) return null; 45 | 46 | int c1 = _dateStr.lastIndexOf(" "); 47 | 48 | if ( c1 != -1 ) 49 | _dateStr = _dateStr.substring( 0, c1 ).trim(); 50 | 51 | return parseDate( _dateStr, "EEE, d MMM yyyy HH:mm:ss" ); 52 | } 53 | 54 | public static String getCookieDate( long l ){ 55 | return getDateString( l, "EEE, dd-MMM-yyyy HH:mm:ss" ) + " GMT"; 56 | } 57 | 58 | public static String getCookieDate( Date _date ){ 59 | return getDateString( _date, "EEE, dd-MMM-yyyy HH:mm:ss" ) + " GMT"; 60 | } 61 | 62 | public static String getHttpDate( long l ){ 63 | return getDateString( l, "EEE, d MMM yyyy HH:mm:ss" ) + " GMT"; 64 | } 65 | 66 | public static String getHttpDate( java.util.Date _date ){ 67 | return getDateString( _date, "EEE, d MMM yyyy HH:mm:ss" ) + " GMT"; 68 | } 69 | 70 | public static String getDateString( java.util.Date _date, String _pattern ){ 71 | return new SimpleDateFormat( _pattern ).format(_date); 72 | } 73 | 74 | public static String getDateString( long _epoch, String _pattern ){ 75 | return new SimpleDateFormat( _pattern ).format(_epoch); 76 | } 77 | 78 | public static String getJSONDate( long l ){ 79 | return getDateString( l, "yyyy-MM-dd'T'HH:mm:ss" ); 80 | } 81 | 82 | public static String getJSONDate( java.util.Date _date ){ 83 | return getDateString( _date, "yyyy-MM-dd'T'HH:mm:ss" ); 84 | } 85 | 86 | public static String getSQLDate( java.util.Date _date ){ 87 | return getDateString( _date, "yyyy-MM-dd HH:mm:ss" ); 88 | } 89 | 90 | public static java.util.Date parseJSONDate( String _dateStr ){ 91 | return parseDate( _dateStr, "yyyy-MM-dd'T'HH:mm:ss" ); 92 | } 93 | 94 | public static java.util.Date parseDate( String sDate, String _datePattern ){ 95 | sDate = (sDate != null) ? sDate.trim() : null; 96 | 97 | /* if the date is null or empty, no point in going forward */ 98 | if ( sDate == null || sDate.length() == 0 ) 99 | return null; 100 | 101 | ParsePosition pp; 102 | java.util.Date d = null; 103 | DateFormat df = new SimpleDateFormat(_datePattern); 104 | df.setLenient(false); 105 | 106 | try { 107 | pp = new ParsePosition(0); 108 | d = df.parse(sDate,pp); 109 | if ( pp.getIndex()!=sDate.length() ) { 110 | d = null; 111 | } 112 | }catch (Exception ex1) { 113 | return null; 114 | } 115 | return d; 116 | } 117 | 118 | 119 | public static String formatAge( long age ){ 120 | if ( age < 0 ) age = age * -1; 121 | 122 | StringBuffer ageString = new StringBuffer( 32 ); 123 | 124 | //-- Years 125 | long years = age / YEAR_MS; 126 | if ( years > 0 ){ 127 | ageString.append( years + " year" ); 128 | if ( years > 1 ) ageString.append( "s" ); 129 | 130 | ageString.append( " " ); 131 | age = age - ( years * YEAR_MS ); 132 | } 133 | 134 | //-- Months 135 | long months = age / MONTH_MS; 136 | if ( months > 0 ){ 137 | ageString.append( months + " month" ); 138 | if ( months > 1 ) ageString.append( "s" ); 139 | 140 | ageString.append( " " ); 141 | age = age - ( months * MONTH_MS ); 142 | } 143 | 144 | //-- Days 145 | long days = age / DAY_MS; 146 | if ( days > 0 ){ 147 | ageString.append( days + " day" ); 148 | if ( days > 1 ) ageString.append( "s" ); 149 | 150 | ageString.append( " " ); 151 | age = age - ( days * DAY_MS ); 152 | } 153 | 154 | //-- Hours 155 | long hours = age / HOUR_MS; 156 | if ( hours > 0 ){ 157 | ageString.append( hours + " hour" ); 158 | if ( hours > 1 ) ageString.append( "s" ); 159 | 160 | ageString.append( " " ); 161 | age = age - ( hours * HOUR_MS ); 162 | } 163 | 164 | //-- Minutes 165 | long mins = age / MINS_MS; 166 | if ( mins > 0 ){ 167 | ageString.append( mins + " min" ); 168 | if ( mins > 1 ) ageString.append( "s" ); 169 | 170 | ageString.append( " " ); 171 | age = age - ( mins * MINS_MS ); 172 | } 173 | 174 | //-- Seconds 175 | long seconds = age / SECS_MS; 176 | if ( seconds > 0 ){ 177 | ageString.append( seconds + " sec" ); 178 | if ( seconds > 1 ) ageString.append( "s" ); 179 | ageString.append( " " ); 180 | } 181 | 182 | return ageString.toString().trim(); 183 | } 184 | 185 | public static Date getFromJavaScriptDate( String jsDateStr ){ 186 | return DateUtil.parseDate(jsDateStr, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 187 | } 188 | 189 | } 190 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/Executor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui; 27 | 28 | import java.io.BufferedReader; 29 | import java.io.File; 30 | import java.io.FileWriter; 31 | import java.io.IOException; 32 | import java.io.InputStream; 33 | import java.io.InputStreamReader; 34 | import java.io.PrintWriter; 35 | import java.io.Writer; 36 | import java.net.InetSocketAddress; 37 | import java.net.Socket; 38 | import java.net.URLEncoder; 39 | import java.util.ArrayList; 40 | import java.util.List; 41 | 42 | import org.aw20.jettydesktop.rte.JettyRunTime; 43 | import org.aw20.util.SocketUtil; 44 | 45 | public class Executor extends Object { 46 | 47 | /** 48 | * 49 | * "C:\Program Files (x86)\Java\jre6\bin\javaw.exe" -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:55560 -Dfile.encoding=Cp1252 -classpath C:\github\jettydesktop\bin org.aw20.jettydesktop.ui.Executor 50 | */ 51 | 52 | private Process process; 53 | private ExecutorInterface executorI; 54 | private boolean bRun = true; 55 | private Thread ioconsumers[]; 56 | private adminPortWatcher AdminPortWatcher = null; 57 | private int adminPort; 58 | 59 | public Executor(ServerConfigMap options, ExecutorInterface executorI) throws IOException { 60 | this.executorI = executorI; 61 | 62 | // Check to see if this server is already running 63 | if (SocketUtil.isRemotePortAlive(options.getIP(), Integer.parseInt(options.getPort()))) { 64 | throw new IOException("Port#" + options.getPort() + " appears to be in use already"); 65 | } 66 | 67 | findFreePort(); 68 | 69 | // Start up the server 70 | String USR_HOME = System.getProperty("user.dir") + File.separator; 71 | 72 | String JDK_HOME; 73 | if (options.getCurrentJVM() == null) 74 | JDK_HOME = options.getCustomJVM() + File.separator + "bin" + File.separator; 75 | else 76 | JDK_HOME = System.getProperty("java.home") + File.separator + "bin" + File.separator; 77 | 78 | if (new File(JDK_HOME, "javaw.exe").exists() ) 79 | JDK_HOME += "javaw.exe"; 80 | else if (new File(JDK_HOME, "javaw").exists() ) 81 | JDK_HOME += "javaw"; 82 | else 83 | JDK_HOME += "java"; 84 | 85 | List programArgs = new ArrayList(); 86 | programArgs.add(JDK_HOME); 87 | 88 | // force UTF-8 89 | programArgs.add("-Dfile.encoding=UTF-8"); 90 | 91 | if (options.getAllowInput()==false) { 92 | programArgs.add("-Dorg.voyanttools.server.allowinput=false"); 93 | } 94 | 95 | if (options.containsKey("open_menu")) { 96 | String openMenu = options.get("open_menu"); 97 | if (openMenu!=null && openMenu.isEmpty()==false) { 98 | programArgs.add("-Dorg.voyanttools.voyant.openmenu=\""+URLEncoder.encode(openMenu, "UTF-8")+"\""); 99 | } 100 | } 101 | 102 | if (options.getMemoryJVM() != null) 103 | programArgs.add("-Xmx" + options.getMemoryJVM() + "m"); 104 | 105 | if ( options.getDefaultJVMArgs() != null ) 106 | programArgs.add( options.getDefaultJVMArgs() ); 107 | 108 | programArgs.add("-classpath"); 109 | programArgs.add(getClasspath(USR_HOME)); 110 | 111 | programArgs.add(JettyRunTime.class.getName()); 112 | 113 | if (options.getIP().length() > 0) 114 | programArgs.add(options.getIP()); 115 | 116 | programArgs.add(options.getPort()); 117 | programArgs.add(options.getWebFolder()); 118 | programArgs.add( String.valueOf(adminPort) ); 119 | 120 | ProcessBuilder pb = new ProcessBuilder(programArgs); 121 | 122 | System.out.print("Command: "); 123 | for (String arg : programArgs) { 124 | System.out.print(arg+" "); 125 | } 126 | System.err.println(""); 127 | 128 | // Start the process 129 | process = pb.start(); 130 | 131 | if (executorI != null) { 132 | executorI.onServerStart(); 133 | } 134 | 135 | ioconsumers = new Thread[2]; 136 | ioconsumers[1] = new ioConsumer(process.getInputStream()); 137 | if (options.getLogsFile()) { 138 | File dir = new File(options.getDataFolder(), "logs"); 139 | if (dir.exists()==false) { 140 | if (!dir.mkdir()) { 141 | System.err.println("Can't create logs directory: "+dir); 142 | throw new IOException("Can't create logs directory: "+dir); 143 | } 144 | } 145 | File out = new File(dir, "jetty.log"); 146 | if (executorI!=null) { 147 | executorI.onConsole("Logging to file: "+out.getAbsolutePath()); 148 | } 149 | FileWriter outWriter = new FileWriter(out, true); 150 | ioconsumers[0] = new ioFileConsumer(process.getErrorStream(), outWriter); 151 | } 152 | else { 153 | ioconsumers[0] = new ioConsumer(process.getErrorStream()); 154 | } 155 | 156 | if ( adminPort > 0 ){ 157 | try{ 158 | AdminPortWatcher = new adminPortWatcher(); 159 | }catch(IOException ioe){ 160 | AdminPortWatcher = null; 161 | } 162 | } 163 | } 164 | 165 | 166 | private void findFreePort(){ 167 | try{ 168 | adminPort = 34000; 169 | 170 | for ( int x=0; x < 1000; x++ ){ 171 | adminPort += x; 172 | 173 | Socket s = new Socket(); 174 | s.connect( new InetSocketAddress( "127.0.0.1", adminPort ), 1000 ); 175 | s.close(); 176 | } 177 | 178 | adminPort = -1; 179 | 180 | }catch(Exception e){ 181 | executorI.onConsole("Using Free AdminPort=" + adminPort ); 182 | return; 183 | } 184 | } 185 | 186 | 187 | class adminPortWatcher extends Thread { 188 | 189 | BufferedReader br; 190 | Socket s; 191 | 192 | public adminPortWatcher() throws IOException{ 193 | s = new Socket(); 194 | s.connect( new InetSocketAddress( "127.0.0.1", adminPort ), 1000 ); 195 | br = new BufferedReader(new InputStreamReader(s.getInputStream())); 196 | start(); 197 | } 198 | 199 | public void run(){ 200 | try { 201 | Thread.sleep(5000); 202 | } catch (InterruptedException e) { 203 | return; 204 | } 205 | 206 | while (bRun) { 207 | String line; 208 | try { 209 | while ((line = br.readLine()) != null) { 210 | if (executorI != null) 211 | executorI.onMemory(line); 212 | } 213 | } catch (IOException e) { 214 | break; 215 | } 216 | } 217 | 218 | try { 219 | br.close(); 220 | s.close(); 221 | } catch (IOException e) {} 222 | 223 | } 224 | } 225 | 226 | 227 | class ioConsumer extends Thread { 228 | 229 | BufferedReader br; 230 | 231 | public ioConsumer(InputStream io) { 232 | br = new BufferedReader(new InputStreamReader(io)); 233 | start(); 234 | } 235 | 236 | public void run() { 237 | 238 | while (bRun) { 239 | String line; 240 | try { 241 | while ((line = br.readLine()) != null) { 242 | if (executorI != null) 243 | executorI.onConsole(line); 244 | } 245 | } catch (IOException e) { 246 | break; 247 | } 248 | } 249 | 250 | try { 251 | br.close(); 252 | } catch (IOException e) {} 253 | 254 | if (executorI != null) { 255 | executorI.onServerExit(); 256 | } 257 | } 258 | } 259 | 260 | class ioFileConsumer extends Thread { 261 | BufferedReader br; 262 | PrintWriter wr; 263 | 264 | public ioFileConsumer(InputStream io, Writer wr) { 265 | br = new BufferedReader(new InputStreamReader(io)); 266 | this.wr = new PrintWriter(wr); 267 | start(); 268 | } 269 | 270 | public void run() { 271 | 272 | while (bRun) { 273 | String line; 274 | try { 275 | while ((line = br.readLine()) != null) { 276 | if (executorI != null) { 277 | wr.println(line); 278 | wr.flush(); 279 | } 280 | } 281 | } catch (IOException e) { 282 | break; 283 | } 284 | } 285 | 286 | try { 287 | br.close(); 288 | wr.close(); 289 | } catch (IOException e) {} 290 | 291 | 292 | if (executorI != null) { 293 | executorI.onServerExit(); 294 | } 295 | } 296 | } 297 | 298 | public boolean isWebAppRunning() { 299 | return true; 300 | } 301 | 302 | public void exit() { 303 | process.destroy(); 304 | bRun = false; 305 | ioconsumers[0].interrupt(); 306 | ioconsumers[1].interrupt(); 307 | 308 | if ( AdminPortWatcher != null ) 309 | AdminPortWatcher.interrupt(); 310 | } 311 | 312 | private String getClasspath(String usrdir) { 313 | StringBuilder sb = new StringBuilder(64); 314 | 315 | // if (new File(usrdir, "jettydesktop.jar").isFile()) { 316 | // sb.append(usrdir + "jettydesktop.jar"); 317 | if (new File(usrdir, "VoyantServer.jar").isFile()) { 318 | sb.append(usrdir + "VoyantServer.jar"); 319 | } else { 320 | sb.append(usrdir + "bin").append(File.pathSeparator + usrdir + "lib/*"); /* + File.separator + "jetty-all-9.3.9.M1-uber.jar") 321 | .append(File.pathSeparator + usrdir + "lib" + File.separator + "servlet-api-3.1.0.jar") 322 | .append(File.pathSeparator + usrdir + "lib" + File.separator + "jasper-6.0.45.jar") 323 | .append(File.pathSeparator + usrdir + "lib" + File.separator + "tomcat-juli-9.0.0.M4.jar") 324 | .append(File.pathSeparator + usrdir + "lib" + File.separator + "jsp-api-2.0.jar");*/ 325 | } 326 | 327 | return sb.toString(); 328 | } 329 | 330 | } 331 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/awt/ServerTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui.awt; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.Dimension; 30 | import java.awt.Font; 31 | import java.awt.GridBagConstraints; 32 | import java.awt.GridBagLayout; 33 | import java.awt.Insets; 34 | import java.awt.Panel; 35 | import java.awt.event.ActionEvent; 36 | import java.awt.event.ActionListener; 37 | import java.io.IOException; 38 | 39 | import javax.swing.BorderFactory; 40 | import javax.swing.JButton; 41 | import javax.swing.JLabel; 42 | import javax.swing.JOptionPane; 43 | import javax.swing.JPanel; 44 | import javax.swing.JScrollPane; 45 | import javax.swing.JTextArea; 46 | import javax.swing.text.DefaultCaret; 47 | 48 | import org.aw20.jettydesktop.rte.JettyRunTime; 49 | import org.aw20.jettydesktop.ui.ConfigActionInterface; 50 | import org.aw20.jettydesktop.ui.Executor; 51 | import org.aw20.jettydesktop.ui.ExecutorInterface; 52 | import org.aw20.jettydesktop.ui.ServerConfigMap; 53 | import org.aw20.util.DateUtil; 54 | 55 | public class ServerTab extends JPanel implements ExecutorInterface{ 56 | private static final long serialVersionUID = 1L; 57 | 58 | private final ServerConfigMap serverConfigMap; 59 | private final ConfigActionInterface configActionI; 60 | private JButton startstopButton; 61 | private JButton editConfigButton; 62 | private JButton deleteButton; 63 | private JButton gotoButton; 64 | 65 | private Executor executor = null; 66 | private JTextArea textArea; 67 | private JLabel labelStatus; 68 | private JButton btnClose; 69 | private JPanel panel; 70 | private JLabel RemoteMemoryLabel; 71 | 72 | public ServerTab(ServerConfigMap _serverConfigMap, ConfigActionInterface _configActionI ) { 73 | this.serverConfigMap = _serverConfigMap; 74 | this.configActionI = _configActionI; 75 | 76 | setLayout(new BorderLayout(0, 0)); 77 | 78 | JScrollPane jConsoleScrollPane = new JScrollPane(); 79 | jConsoleScrollPane.setMinimumSize( new Dimension(400, 500) ); 80 | 81 | textArea = new JTextArea(); 82 | textArea.setTabSize(2); 83 | textArea.setFont(new Font("Courier New", Font.PLAIN, 12)); 84 | textArea.setEditable(false); 85 | 86 | DefaultCaret caret = (DefaultCaret) textArea.getCaret(); 87 | caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); 88 | 89 | jConsoleScrollPane.setViewportView(textArea); 90 | add(jConsoleScrollPane, BorderLayout.CENTER); 91 | 92 | 93 | Panel panel_1 = new Panel(); 94 | add(panel_1, BorderLayout.SOUTH); 95 | GridBagLayout gbl_panel_1 = new GridBagLayout(); 96 | gbl_panel_1.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0, 0}; 97 | gbl_panel_1.rowHeights = new int[]{0, 0}; 98 | gbl_panel_1.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE}; 99 | gbl_panel_1.rowWeights = new double[]{0.0, Double.MIN_VALUE}; 100 | panel_1.setLayout(gbl_panel_1); 101 | 102 | editConfigButton = new JButton("Edit"); 103 | editConfigButton.addActionListener(new ActionListener() { 104 | public void actionPerformed(ActionEvent e) { 105 | configActionI.onEdit(serverConfigMap); 106 | } 107 | }); 108 | 109 | btnClose = new JButton("Close"); 110 | btnClose.addActionListener(new ActionListener() { 111 | public void actionPerformed(ActionEvent e) { 112 | configActionI.onClose(serverConfigMap); 113 | } 114 | }); 115 | 116 | 117 | GridBagConstraints gbc_btnClose = new GridBagConstraints(); 118 | gbc_btnClose.insets = new Insets(5,5,5,5); 119 | gbc_btnClose.gridx = 0; 120 | gbc_btnClose.gridy = 0; 121 | panel_1.add(btnClose, gbc_btnClose); 122 | GridBagConstraints gbc_button_3 = new GridBagConstraints(); 123 | gbc_button_3.insets = new Insets(5, 5, 5, 5); 124 | gbc_button_3.gridx = 1; 125 | gbc_button_3.gridy = 0; 126 | panel_1.add(editConfigButton, gbc_button_3); 127 | 128 | JButton clearButton = new JButton("Clear"); 129 | clearButton.addActionListener(new ActionListener() { 130 | public void actionPerformed(ActionEvent e) { 131 | textArea.setText(""); 132 | } 133 | }); 134 | 135 | deleteButton = new JButton("Delete"); 136 | deleteButton.addActionListener(new ActionListener() { 137 | public void actionPerformed(ActionEvent e) { 138 | int result = JOptionPane.showConfirmDialog( getParent(), "Do you wish to delete this server?"); 139 | if ( result == JOptionPane.OK_OPTION ){ 140 | configActionI.onDelete(serverConfigMap); 141 | } 142 | } 143 | }); 144 | GridBagConstraints gbc_button_4 = new GridBagConstraints(); 145 | gbc_button_4.insets = new Insets(5, 5, 5, 5); 146 | gbc_button_4.gridx = 2; 147 | gbc_button_4.gridy = 0; 148 | panel_1.add(deleteButton, gbc_button_4); 149 | 150 | GridBagConstraints gbc_btnClear = new GridBagConstraints(); 151 | gbc_btnClear.insets = new Insets(5, 5, 5, 5); 152 | gbc_btnClear.gridx = 3; 153 | gbc_btnClear.gridy = 0; 154 | panel_1.add(clearButton, gbc_btnClear); 155 | 156 | startstopButton = new JButton("Start Server"); 157 | startstopButton.addActionListener(new ActionListener() { 158 | public void actionPerformed(ActionEvent e) { 159 | if ( executor == null ){ 160 | startServer(); 161 | }else{ 162 | stopServer(); 163 | } 164 | } 165 | }); 166 | GridBagConstraints gbc_button_1 = new GridBagConstraints(); 167 | gbc_button_1.anchor = GridBagConstraints.EAST; 168 | gbc_button_1.insets = new Insets(5, 5,5, 5); 169 | gbc_button_1.gridx = 5; 170 | gbc_button_1.gridy = 0; 171 | panel_1.add(startstopButton, gbc_button_1); 172 | 173 | gotoButton = new JButton("Open WebApp"); 174 | gotoButton.setEnabled(false); 175 | gotoButton.addActionListener(new ActionListener() { 176 | public void actionPerformed(ActionEvent e) { 177 | if ( !executor.isWebAppRunning() ) 178 | return; 179 | 180 | try { 181 | String host = serverConfigMap.getIP(); 182 | if ( host == null || host.length() == 0 ) 183 | host = "127.0.0.1"; 184 | 185 | String defaultUri = serverConfigMap.getDefaultWebUri(); 186 | if ( defaultUri == null ) 187 | defaultUri = "/"; 188 | 189 | java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://" + host + ":" + serverConfigMap.getPort() + defaultUri )); 190 | } catch (IOException e1) { 191 | e1.printStackTrace(); 192 | } 193 | } 194 | }); 195 | GridBagConstraints gbc_button_2 = new GridBagConstraints(); 196 | gbc_button_2.anchor = GridBagConstraints.EAST; 197 | gbc_button_2.insets = new Insets(5, 5, 5, 5); 198 | gbc_button_2.gridx = 6; 199 | gbc_button_2.gridy = 0; 200 | panel_1.add(gotoButton, gbc_button_2); 201 | 202 | panel = new JPanel(); 203 | add(panel, BorderLayout.NORTH); 204 | panel.setLayout(new BorderLayout(0, 0)); 205 | 206 | 207 | labelStatus = new JLabel("Last Updated"); 208 | panel.add(labelStatus, BorderLayout.WEST); 209 | labelStatus.setBorder( BorderFactory.createEmptyBorder(3, 3, 3, 3) ); 210 | 211 | RemoteMemoryLabel = new JLabel("Memory Usage: 0 / 0 MB "); 212 | panel.add(RemoteMemoryLabel, BorderLayout.EAST); 213 | } 214 | 215 | public boolean isServerRunning(){ 216 | return (executor != null); 217 | } 218 | 219 | public void stopServer(){ 220 | startstopButton.setEnabled(false); 221 | startstopButton.setText( "Stopping..." ); 222 | executor.exit(); 223 | } 224 | 225 | private void startServer(){ 226 | startstopButton.setEnabled(false); 227 | startstopButton.setText( "Starting..." ); 228 | try { 229 | executor = new Executor(serverConfigMap, this ); 230 | } catch (IOException e) { 231 | onConsole( e.getMessage() ); 232 | startstopButton.setEnabled(true); 233 | startstopButton.setText( "Start Server" ); 234 | } 235 | } 236 | 237 | public ServerConfigMap getConfig(){ 238 | return serverConfigMap; 239 | } 240 | 241 | public void setConfig(ServerConfigMap scm){ 242 | serverConfigMap.clear(); 243 | serverConfigMap.putAll( scm ); 244 | } 245 | 246 | public void onMemory( String m ){ 247 | RemoteMemoryLabel.setText(m); 248 | } 249 | 250 | @Override 251 | public synchronized void onConsole(String message) { 252 | textArea.append(message); 253 | textArea.append("\r\n"); 254 | labelStatus.setText( "Console updated: " + DateUtil.getHttpDate(System.currentTimeMillis()) ); 255 | 256 | if ( message.indexOf( JettyRunTime.JETTYSTARTED ) != -1 ) 257 | gotoButton.setEnabled(true); 258 | } 259 | 260 | @Override 261 | public void onServerStart() { 262 | onConsole( "Server Starting" ); 263 | gotoButton.setEnabled(false); 264 | editConfigButton.setEnabled(false); 265 | deleteButton.setEnabled(false); 266 | btnClose.setEnabled(false); 267 | startstopButton.setEnabled(true); 268 | startstopButton.setText("Stop Server"); 269 | } 270 | 271 | @Override 272 | public synchronized void onServerExit() { 273 | if ( executor == null ) 274 | return; 275 | 276 | onConsole("Server terminated."); 277 | gotoButton.setEnabled(false); 278 | editConfigButton.setEnabled(true); 279 | deleteButton.setEnabled(true); 280 | startstopButton.setEnabled(true); 281 | btnClose.setEnabled(true); 282 | startstopButton.setText("Start Server"); 283 | 284 | executor = null; 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/rte/webdefault.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | Default web.xml file. 12 | This file is applied to a Web application before it's own WEB_INF/web.xml file 13 | 14 | 15 | 16 | default 17 | org.eclipse.jetty.servlet.DefaultServlet 18 | 19 | aliases 20 | false 21 | 22 | 23 | acceptRanges 24 | true 25 | 26 | 27 | dirAllowed 28 | true 29 | 30 | 31 | welcomeServlets 32 | false 33 | 34 | 35 | redirectWelcome 36 | false 37 | 38 | 39 | maxCacheSize 40 | 256000000 41 | 42 | 43 | maxCachedFileSize 44 | 200000000 45 | 46 | 47 | maxCachedFiles 48 | 2048 49 | 50 | 51 | gzip 52 | true 53 | 54 | 55 | useFileMappedBuffer 56 | false 57 | 58 | 59 | resourceCache 60 | resourceCache 61 | 62 | 68 | 0 69 | 70 | 71 | 72 | default 73 | / 74 | 75 | 76 | 79 | jsp 80 | org.apache.jasper.servlet.JspServlet 81 | 82 | logVerbosityLevel 83 | DEBUG 84 | 85 | 86 | fork 87 | false 88 | 89 | 90 | xpoweredBy 91 | false 92 | 93 | 99 | 0 100 | 101 | 102 | 103 | jsp 104 | *.jsp 105 | *.jspf 106 | *.jspx 107 | *.xsp 108 | *.JSP 109 | *.JSPF 110 | *.JSPX 111 | *.XSP 112 | 113 | 114 | 115 | 116 | 117 | 30 118 | 119 | 120 | 121 | 122 | index.html 123 | index.htm 124 | index.jsp 125 | 126 | 127 | 128 | 129 | 130 | ar 131 | ISO-8859-6 132 | 133 | 134 | be 135 | ISO-8859-5 136 | 137 | 138 | bg 139 | ISO-8859-5 140 | 141 | 142 | ca 143 | ISO-8859-1 144 | 145 | 146 | cs 147 | ISO-8859-2 148 | 149 | 150 | da 151 | ISO-8859-1 152 | 153 | 154 | de 155 | ISO-8859-1 156 | 157 | 158 | el 159 | ISO-8859-7 160 | 161 | 162 | en 163 | ISO-8859-1 164 | 165 | 166 | es 167 | ISO-8859-1 168 | 169 | 170 | et 171 | ISO-8859-1 172 | 173 | 174 | fi 175 | ISO-8859-1 176 | 177 | 178 | fr 179 | ISO-8859-1 180 | 181 | 182 | hr 183 | ISO-8859-2 184 | 185 | 186 | hu 187 | ISO-8859-2 188 | 189 | 190 | is 191 | ISO-8859-1 192 | 193 | 194 | it 195 | ISO-8859-1 196 | 197 | 198 | iw 199 | ISO-8859-8 200 | 201 | 202 | ja 203 | Shift_JIS 204 | 205 | 206 | ko 207 | EUC-KR 208 | 209 | 210 | lt 211 | ISO-8859-2 212 | 213 | 214 | lv 215 | ISO-8859-2 216 | 217 | 218 | mk 219 | ISO-8859-5 220 | 221 | 222 | nl 223 | ISO-8859-1 224 | 225 | 226 | no 227 | ISO-8859-1 228 | 229 | 230 | pl 231 | ISO-8859-2 232 | 233 | 234 | pt 235 | ISO-8859-1 236 | 237 | 238 | ro 239 | ISO-8859-2 240 | 241 | 242 | ru 243 | ISO-8859-5 244 | 245 | 246 | sh 247 | ISO-8859-5 248 | 249 | 250 | sk 251 | ISO-8859-2 252 | 253 | 254 | sl 255 | ISO-8859-2 256 | 257 | 258 | sq 259 | ISO-8859-2 260 | 261 | 262 | sr 263 | ISO-8859-5 264 | 265 | 266 | sv 267 | ISO-8859-1 268 | 269 | 270 | tr 271 | ISO-8859-9 272 | 273 | 274 | uk 275 | ISO-8859-5 276 | 277 | 278 | zh 279 | GB2312 280 | 281 | 282 | zh_TW 283 | Big5 284 | 285 | 286 | 287 | 288 | 289 | Disable TRACE 290 | / 291 | TRACE 292 | 293 | 294 | 295 | 296 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/Start.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.Dimension; 30 | import java.awt.EventQueue; 31 | import java.awt.Toolkit; 32 | import java.awt.event.ActionEvent; 33 | import java.awt.event.ActionListener; 34 | import java.io.File; 35 | import java.io.FileInputStream; 36 | import java.io.FileOutputStream; 37 | import java.io.IOException; 38 | import java.io.ObjectInputStream; 39 | import java.io.ObjectOutputStream; 40 | import java.util.ArrayList; 41 | import java.util.Arrays; 42 | import java.util.List; 43 | 44 | import javax.swing.JFrame; 45 | import javax.swing.JMenu; 46 | import javax.swing.JMenuBar; 47 | import javax.swing.JMenuItem; 48 | import javax.swing.JOptionPane; 49 | import javax.swing.JTabbedPane; 50 | import javax.swing.UIManager; 51 | import javax.swing.WindowConstants; 52 | 53 | import org.aw20.jettydesktop.ui.awt.ServerConfig; 54 | import org.aw20.jettydesktop.ui.awt.ServerTab; 55 | 56 | public class Start implements ConfigActionInterface { 57 | private static String VERSION = "2.0.8"; 58 | 59 | private List serverConfigList; 60 | 61 | private JFrame frame; 62 | private JMenu mnServer; 63 | private JMenuItem mAddServerMenuItem; 64 | private JTabbedPane tabbedPane; 65 | 66 | /** 67 | * Launch the application. 68 | */ 69 | public static void main(String[] args) { 70 | EventQueue.invokeLater(new Runnable() { 71 | public void run() { 72 | try { 73 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 74 | Start window = new Start(); 75 | window.frame.setVisible(true); 76 | } catch (Exception e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | }); 81 | } 82 | 83 | /** 84 | * Create the application. 85 | */ 86 | public Start() { 87 | loadSettings(); 88 | initialize(); 89 | } 90 | 91 | private void saveSettings(){ 92 | ObjectOutputStream OS; 93 | try { 94 | FileOutputStream out = new FileOutputStream( new File("jettydesktop.settings") ); 95 | OS = new ObjectOutputStream( out ); 96 | OS.writeObject( serverConfigList ); 97 | out.flush(); 98 | out.close(); 99 | } catch (IOException e) {} 100 | } 101 | 102 | 103 | private void loadSettings(){ 104 | ObjectInputStream ois; 105 | try { 106 | FileInputStream in = new FileInputStream( new File("jettydesktop.settings") ); 107 | ois = new ObjectInputStream(in); 108 | serverConfigList = (java.util.List)ois.readObject(); 109 | in.close(); 110 | } catch (Exception e) { 111 | serverConfigList = new ArrayList(); 112 | } 113 | } 114 | 115 | 116 | /** 117 | * Initialise the contents of the frame. 118 | */ 119 | private void initialize() { 120 | frame = new JFrame(); 121 | frame.setTitle("JettyDesktop v" + VERSION + " by aw2.0 Ltd"); 122 | frame.setBounds(100, 100, 610, 414); 123 | frame.setMinimumSize( new Dimension(610, 414) ); 124 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 125 | frame.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/org/aw20/logo/aw20.jpg"))); 126 | 127 | frame.addWindowListener(new java.awt.event.WindowAdapter() { 128 | public void windowClosing(java.awt.event.WindowEvent e) { 129 | terminateApp(); 130 | } 131 | }); 132 | 133 | JMenuBar menuBar = new JMenuBar(); 134 | frame.setJMenuBar(menuBar); 135 | 136 | JMenu mnFile = new JMenu("File"); 137 | menuBar.add(mnFile); 138 | 139 | JMenuItem mntmExit = new JMenuItem("Exit"); 140 | mnFile.add(mntmExit); 141 | mntmExit.addActionListener(new ActionListener() { 142 | public void actionPerformed(ActionEvent e) { 143 | terminateApp(); 144 | } 145 | }); 146 | 147 | mnServer = new JMenu("Web App"); 148 | menuBar.add(mnServer); 149 | 150 | mAddServerMenuItem = new JMenuItem("< add webapp >"); 151 | mAddServerMenuItem.addActionListener(new ActionListener() { 152 | public void actionPerformed(ActionEvent e) { 153 | openConfig( ServerConfigMap.getDefault() ); 154 | } 155 | }); 156 | rebuildServerMenu(); 157 | 158 | JMenu mnHelp = new JMenu("Help"); 159 | menuBar.add(mnHelp); 160 | 161 | JMenuItem mntmSupportSite = new JMenuItem("Visit Home Page"); 162 | mntmSupportSite.addActionListener(new ActionListener() { 163 | public void actionPerformed(ActionEvent e) { 164 | try { 165 | java.awt.Desktop.getDesktop().browse(java.net.URI.create("https://github.com/aw20/jettydesktop/")); 166 | } catch (IOException e1) { 167 | e1.printStackTrace(); 168 | } 169 | } 170 | }); 171 | mnHelp.add(mntmSupportSite); 172 | 173 | JMenuItem mntmBugSite = new JMenuItem("Report Bug/Feature"); 174 | mntmBugSite.addActionListener(new ActionListener() { 175 | public void actionPerformed(ActionEvent e) { 176 | try { 177 | java.awt.Desktop.getDesktop().browse(java.net.URI.create("https://github.com/aw20/jettydesktop/issues")); 178 | } catch (IOException e1) { 179 | e1.printStackTrace(); 180 | } 181 | } 182 | }); 183 | mnHelp.add(mntmBugSite); 184 | 185 | JMenuItem mntmAWSite = new JMenuItem("Visit aw2.0 Ltd"); 186 | mntmAWSite.addActionListener(new ActionListener() { 187 | public void actionPerformed(ActionEvent e) { 188 | try { 189 | java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://aw20.is/")); 190 | } catch (IOException e1) { 191 | e1.printStackTrace(); 192 | } 193 | } 194 | }); 195 | mnHelp.add(mntmAWSite); 196 | mnHelp.addSeparator(); 197 | 198 | JMenuItem mntmAbout = new JMenuItem("About"); 199 | mntmAbout.addActionListener(new ActionListener() { 200 | public void actionPerformed(ActionEvent e) { 201 | JOptionPane.showMessageDialog (null, "Designed/Developed by aw2.0 Ltd\r\nhttp://aw20.is/\r\n\r\nGPLv3.0 License\r\nv" + VERSION + " September 2013", "About JettyDesktop", JOptionPane.INFORMATION_MESSAGE); 202 | } 203 | }); 204 | 205 | 206 | mnHelp.add(mntmAbout); 207 | 208 | tabbedPane = new JTabbedPane(JTabbedPane.TOP); 209 | frame.getContentPane().add(tabbedPane, BorderLayout.CENTER); 210 | } 211 | 212 | protected boolean terminateApp() { 213 | int totalRunning = 0; 214 | for ( int x=0; x < tabbedPane.getComponentCount(); x++ ){ 215 | ServerTab sT = (ServerTab)tabbedPane.getComponent(x); 216 | if ( sT.isServerRunning() ) 217 | totalRunning++; 218 | } 219 | 220 | if ( totalRunning == 0 ) 221 | System.exit(1); 222 | 223 | int result = JOptionPane.showConfirmDialog( this.frame, "You have " + totalRunning + " server(s) still running.\r\n\r\nDo you still wish to terminate?\r\n"); 224 | if ( result == JOptionPane.OK_OPTION ){ 225 | for ( int x=0; x < tabbedPane.getComponentCount(); x++ ){ 226 | ServerTab sT = (ServerTab)tabbedPane.getComponent(x); 227 | if ( sT.isServerRunning() ) 228 | sT.stopServer(); 229 | } 230 | System.exit(1); 231 | } 232 | 233 | return false; 234 | } 235 | 236 | private void rebuildServerMenu(){ 237 | mnServer.removeAll(); 238 | 239 | mnServer.add( mAddServerMenuItem ); 240 | 241 | if ( serverConfigList.isEmpty() ) 242 | return; 243 | 244 | mnServer.addSeparator(); 245 | 246 | // Get the names 247 | String[] names = new String[serverConfigList.size()]; 248 | for ( int x=0; x < names.length; x++ ) 249 | names[x] = serverConfigList.get(x).getName(); 250 | 251 | Arrays.sort( names ); 252 | 253 | for ( int x=0; x < names.length; x++ ){ 254 | 255 | JMenuItem menu = new JMenuItem(names[x]); 256 | menu.addActionListener(new ActionListener() { 257 | public void actionPerformed(ActionEvent e) { 258 | openServer( ((JMenuItem)e.getSource()).getText() ); 259 | } 260 | }); 261 | 262 | mnServer.add( menu ); 263 | } 264 | } 265 | 266 | 267 | protected void openServer(String servername) { 268 | 269 | // See if that one is already open in the tabs 270 | for ( int x=0; x < tabbedPane.getComponentCount(); x++ ){ 271 | ServerTab sT = (ServerTab)tabbedPane.getComponent(x); 272 | if ( sT.getConfig().getName().equals(servername) ){ 273 | tabbedPane.setSelectedIndex(x); 274 | return; 275 | } 276 | } 277 | 278 | // We need to add a new tab 279 | ServerTab sT = new ServerTab( get(servername), this ); 280 | tabbedPane.add(sT, servername); 281 | tabbedPane.setSelectedComponent(sT); 282 | } 283 | 284 | 285 | private ServerConfigMap get(String name){ 286 | for ( int x=0; x < serverConfigList.size(); x++ ){ 287 | if ( serverConfigList.get(x).getName().equals( name ) ){ 288 | return serverConfigList.get(x); 289 | } 290 | } 291 | return null; 292 | } 293 | 294 | 295 | private void openConfig( ServerConfigMap serverConfigMap ){ 296 | ServerConfig popup = new ServerConfig( serverConfigMap ); 297 | popup.setVisible(true); 298 | if ( popup.getConfig() == null ) 299 | return; 300 | 301 | ServerConfigMap scm = popup.getConfig(); 302 | 303 | // We need to run through the list see if its already there 304 | boolean bFound = false; 305 | for ( int x=0; x < serverConfigList.size(); x++ ){ 306 | if ( serverConfigList.get(x).getName().equals( scm.getName() ) ){ 307 | serverConfigList.set(x, scm); 308 | bFound = true; 309 | break; 310 | } 311 | } 312 | 313 | if ( !bFound ) 314 | serverConfigList.add(scm); 315 | 316 | saveSettings(); 317 | rebuildServerMenu(); 318 | 319 | // Update the reference if it is used in an active TAB 320 | for ( int x=0; x < tabbedPane.getComponentCount(); x++ ){ 321 | ServerTab sT = (ServerTab)tabbedPane.getComponent(x); 322 | if ( sT.getConfig().getName().equals(scm.getName()) ){ 323 | sT.setConfig(scm); 324 | break; 325 | } 326 | } 327 | } 328 | 329 | @Override 330 | public void onEdit(ServerConfigMap scm) { 331 | openConfig(scm); 332 | } 333 | 334 | @Override 335 | public void onDelete(ServerConfigMap scm) { 336 | 337 | // Remove from the tabs 338 | onClose(scm); 339 | 340 | // Remove from the list 341 | for ( int x=0; x < serverConfigList.size(); x++ ){ 342 | if ( serverConfigList.get(x).getName().equals( scm.getName() ) ){ 343 | serverConfigList.remove(x); 344 | break; 345 | } 346 | } 347 | 348 | saveSettings(); 349 | rebuildServerMenu(); 350 | } 351 | 352 | @Override 353 | public void onClose(ServerConfigMap scm) { 354 | 355 | // Remove from the tabs 356 | for ( int x=0; x < tabbedPane.getComponentCount(); x++ ){ 357 | ServerTab sT = (ServerTab)tabbedPane.getComponent(x); 358 | if ( sT.getConfig().getName().equals(scm.getName()) ){ 359 | tabbedPane.remove(x); 360 | break; 361 | } 362 | } 363 | } 364 | 365 | } 366 | -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/awt/NewJPanel.java: -------------------------------------------------------------------------------- 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 | 7 | package org.voyanttools.server.ui.awt; 8 | 9 | /** 10 | * 11 | * @author sgs 12 | */ 13 | public class NewJPanel extends javax.swing.JPanel { 14 | 15 | /** 16 | * Creates new form NewJPanel 17 | */ 18 | public NewJPanel() { 19 | initComponents(); 20 | } 21 | 22 | /** 23 | * This method is called from within the constructor to initialize the form. 24 | * WARNING: Do NOT modify this code. The content of this method is always 25 | * regenerated by the Form Editor. 26 | */ 27 | @SuppressWarnings("unchecked") 28 | // //GEN-BEGIN:initComponents 29 | private void initComponents() { 30 | 31 | jLabel1 = new javax.swing.JLabel(); 32 | jButton1 = new javax.swing.JButton(); 33 | jTextField1 = new javax.swing.JTextField(); 34 | jTextField2 = new javax.swing.JTextField(); 35 | jLabel2 = new javax.swing.JLabel(); 36 | jLabel3 = new javax.swing.JLabel(); 37 | jLabel4 = new javax.swing.JLabel(); 38 | jButton2 = new javax.swing.JButton(); 39 | jPanel1 = new javax.swing.JPanel(); 40 | jLabel5 = new javax.swing.JLabel(); 41 | jLabel6 = new javax.swing.JLabel(); 42 | jScrollPane1 = new javax.swing.JScrollPane(); 43 | jTextArea1 = new javax.swing.JTextArea(); 44 | jLabel7 = new javax.swing.JLabel(); 45 | 46 | setBackground(new java.awt.Color(255, 255, 255)); 47 | 48 | jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/voyanttools/resources/voyant_small.png"))); // NOI18N 49 | jLabel1.setText("Voyant
Server"); 50 | 51 | jButton1.setText("Restart Server"); 52 | jButton1.setMargin(new java.awt.Insets(0, 0, 0, 0)); 53 | jButton1.setMaximumSize(new java.awt.Dimension(150, 29)); 54 | jButton1.setMinimumSize(new java.awt.Dimension(150, 29)); 55 | jButton1.addActionListener(new java.awt.event.ActionListener() { 56 | public void actionPerformed(java.awt.event.ActionEvent evt) { 57 | jButton1ActionPerformed(evt); 58 | } 59 | }); 60 | 61 | jTextField1.setText("8888"); 62 | jTextField1.addActionListener(new java.awt.event.ActionListener() { 63 | public void actionPerformed(java.awt.event.ActionEvent evt) { 64 | jTextField1ActionPerformed(evt); 65 | } 66 | }); 67 | 68 | jTextField2.setText("1024"); 69 | jTextField2.addActionListener(new java.awt.event.ActionListener() { 70 | public void actionPerformed(java.awt.event.ActionEvent evt) { 71 | jTextField2ActionPerformed(evt); 72 | } 73 | }); 74 | 75 | jLabel2.setText("MB"); 76 | 77 | jLabel3.setText("Port"); 78 | 79 | jLabel4.setText("Memory"); 80 | 81 | jButton2.setText("Open Web"); 82 | jButton2.setMargin(new java.awt.Insets(0, 0, 0, 0)); 83 | jButton2.setMaximumSize(new java.awt.Dimension(88, 29)); 84 | jButton2.setMinimumSize(new java.awt.Dimension(88, 29)); 85 | jButton2.addActionListener(new java.awt.event.ActionListener() { 86 | public void actionPerformed(java.awt.event.ActionEvent evt) { 87 | jButton2ActionPerformed(evt); 88 | } 89 | }); 90 | 91 | jLabel5.setText("jLabel5"); 92 | 93 | jLabel6.setText("jLabel6"); 94 | 95 | jTextArea1.setColumns(20); 96 | jTextArea1.setRows(5); 97 | jScrollPane1.setViewportView(jTextArea1); 98 | 99 | jLabel7.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N 100 | jLabel7.setText("Stéfan Sinclair & Geoffrey Rockwell"); 101 | 102 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 103 | jPanel1.setLayout(jPanel1Layout); 104 | jPanel1Layout.setHorizontalGroup( 105 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 106 | .addGroup(jPanel1Layout.createSequentialGroup() 107 | .addContainerGap() 108 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 109 | .addComponent(jScrollPane1) 110 | .addGroup(jPanel1Layout.createSequentialGroup() 111 | .addComponent(jLabel5) 112 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 113 | .addComponent(jLabel6)) 114 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 115 | .addGap(0, 0, Short.MAX_VALUE) 116 | .addComponent(jLabel7))) 117 | .addContainerGap()) 118 | ); 119 | jPanel1Layout.setVerticalGroup( 120 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 121 | .addGroup(jPanel1Layout.createSequentialGroup() 122 | .addContainerGap() 123 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 124 | .addComponent(jLabel5) 125 | .addComponent(jLabel6)) 126 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 127 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE) 128 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 129 | .addComponent(jLabel7) 130 | .addContainerGap()) 131 | ); 132 | 133 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 134 | this.setLayout(layout); 135 | layout.setHorizontalGroup( 136 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 137 | .addGroup(layout.createSequentialGroup() 138 | .addGap(18, 18, 18) 139 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE) 140 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 141 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 142 | .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE) 143 | .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 144 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE) 145 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 146 | .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING) 147 | .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)) 148 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 149 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 150 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 151 | .addGroup(layout.createSequentialGroup() 152 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 153 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 154 | .addComponent(jLabel2))) 155 | .addGap(6, 6, 6)) 156 | .addGroup(layout.createSequentialGroup() 157 | .addContainerGap() 158 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 159 | .addContainerGap()) 160 | ); 161 | layout.setVerticalGroup( 162 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 163 | .addGroup(layout.createSequentialGroup() 164 | .addContainerGap() 165 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 166 | .addGroup(layout.createSequentialGroup() 167 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 168 | .addComponent(jLabel3) 169 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 170 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 171 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 172 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 173 | .addComponent(jLabel2) 174 | .addComponent(jLabel4) 175 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 176 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) 177 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) 178 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 179 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 180 | .addGap(25, 25, 25)) 181 | ); 182 | }//
//GEN-END:initComponents 183 | 184 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed 185 | // TODO add your handling code here: 186 | }//GEN-LAST:event_jButton1ActionPerformed 187 | 188 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed 189 | // TODO add your handling code here: 190 | }//GEN-LAST:event_jTextField1ActionPerformed 191 | 192 | private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed 193 | // TODO add your handling code here: 194 | }//GEN-LAST:event_jTextField2ActionPerformed 195 | 196 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed 197 | // TODO add your handling code here: 198 | }//GEN-LAST:event_jButton2ActionPerformed 199 | 200 | 201 | // Variables declaration - do not modify//GEN-BEGIN:variables 202 | private javax.swing.JButton jButton1; 203 | private javax.swing.JButton jButton2; 204 | private javax.swing.JLabel jLabel1; 205 | private javax.swing.JLabel jLabel2; 206 | private javax.swing.JLabel jLabel3; 207 | private javax.swing.JLabel jLabel4; 208 | private javax.swing.JLabel jLabel5; 209 | private javax.swing.JLabel jLabel6; 210 | private javax.swing.JLabel jLabel7; 211 | private javax.swing.JPanel jPanel1; 212 | private javax.swing.JScrollPane jScrollPane1; 213 | private javax.swing.JTextArea jTextArea1; 214 | private javax.swing.JTextField jTextField1; 215 | private javax.swing.JTextField jTextField2; 216 | // End of variables declaration//GEN-END:variables 217 | } 218 | -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/awt/NewJPanel.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 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | -------------------------------------------------------------------------------- /src/org/voyanttools/server/ui/awt/VoyantServerTab.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.voyanttools.server.ui.awt; 5 | 6 | import java.awt.Font; 7 | import java.io.IOException; 8 | import java.net.URI; 9 | import java.net.URLConnection; 10 | import java.util.Timer; 11 | import java.util.TimerTask; 12 | 13 | import javax.swing.JButton; 14 | import javax.swing.JLabel; 15 | import javax.swing.JPanel; 16 | import javax.swing.JTextArea; 17 | import javax.swing.text.DefaultCaret; 18 | 19 | import org.aw20.jettydesktop.rte.JettyRunTime; 20 | import org.aw20.jettydesktop.ui.ConfigActionInterface; 21 | import org.aw20.jettydesktop.ui.Executor; 22 | import org.aw20.jettydesktop.ui.ExecutorInterface; 23 | import org.aw20.jettydesktop.ui.ServerConfigMap; 24 | import org.aw20.util.DateUtil; 25 | import org.voyanttools.server.ui.ServerConfig; 26 | import org.voyanttools.server.ui.VoyantServerStart; 27 | 28 | /** 29 | * @author sgs 30 | * 31 | */ 32 | public class VoyantServerTab extends JPanel implements ExecutorInterface{ 33 | private static final long serialVersionUID = 1L; 34 | 35 | private static final String stopServer = "Stop Server"; 36 | private static final String startServer = "Start Server"; 37 | 38 | private ServerConfigMap serverConfigMap; 39 | private final ConfigActionInterface configActionI; 40 | private JButton gotoButton; 41 | 42 | private Executor executor = null; 43 | private JTextArea textArea; 44 | private JLabel labelStatus; 45 | // private JButton btnClose; 46 | private JPanel panel; 47 | private JLabel RemoteMemoryLabel; 48 | 49 | 50 | private javax.swing.JButton startStopButton; 51 | private javax.swing.JLabel logoLabel; 52 | private javax.swing.JLabel memoryUnitLabel; 53 | private javax.swing.JLabel portLabel; 54 | private javax.swing.JLabel memoryLabel; 55 | private javax.swing.JPanel jPanel1; 56 | private javax.swing.JScrollPane jScrollPane1; 57 | private javax.swing.JTextField portTextField; 58 | private javax.swing.JTextField memoryTextField; 59 | 60 | public VoyantServerTab(ConfigActionInterface _configActionI, ServerConfigMap serverConfigMap) throws IOException { 61 | this.configActionI = _configActionI; 62 | this.serverConfigMap = serverConfigMap; 63 | 64 | initComponents(); 65 | startServer(); 66 | } 67 | 68 | private void initComponents() { 69 | logoLabel = new javax.swing.JLabel(); 70 | startStopButton = new javax.swing.JButton(); 71 | portTextField = new javax.swing.JTextField(); 72 | memoryTextField = new javax.swing.JTextField(); 73 | memoryUnitLabel = new javax.swing.JLabel(); 74 | portLabel = new javax.swing.JLabel(); 75 | memoryLabel = new javax.swing.JLabel(); 76 | gotoButton = new javax.swing.JButton(); 77 | jPanel1 = new javax.swing.JPanel(); 78 | labelStatus = new javax.swing.JLabel(); 79 | RemoteMemoryLabel = new javax.swing.JLabel(); 80 | jScrollPane1 = new javax.swing.JScrollPane(); 81 | textArea = new javax.swing.JTextArea(); 82 | 83 | textArea.setTabSize(2); 84 | textArea.setFont(new Font("Courier New", Font.PLAIN, 11)); 85 | textArea.setEditable(false); 86 | 87 | DefaultCaret caret = (DefaultCaret) textArea.getCaret(); 88 | caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); 89 | 90 | setBackground(new java.awt.Color(255, 255, 255)); 91 | 92 | logoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/voyanttools/resources/voyant_small.png"))); // NOI18N 93 | logoLabel.setText("

Voyant
Server

"); 94 | 95 | startStopButton.setText(stopServer); 96 | startStopButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); 97 | startStopButton.setMaximumSize(new java.awt.Dimension(150, 29)); 98 | startStopButton.setMinimumSize(new java.awt.Dimension(150, 29)); 99 | startStopButton.addActionListener(new java.awt.event.ActionListener() { 100 | public void actionPerformed(java.awt.event.ActionEvent evt) { 101 | startStopButton.setEnabled(false); 102 | if (evt.getActionCommand().equals(stopServer)) { 103 | stopServer(); 104 | } 105 | else { 106 | try { 107 | startServer(); 108 | } catch (IOException e) { 109 | onConsole(e.toString()); 110 | } 111 | } 112 | } 113 | }); 114 | startStopButton.setEnabled(false); 115 | 116 | portTextField.setText(serverConfigMap.getPort()); 117 | portTextField.addActionListener(new java.awt.event.ActionListener() { 118 | public void actionPerformed(java.awt.event.ActionEvent evt) { 119 | jTextField1ActionPerformed(evt); 120 | } 121 | }); 122 | 123 | memoryTextField.setText(serverConfigMap.getMemoryJVM()); 124 | memoryTextField.addActionListener(new java.awt.event.ActionListener() { 125 | public void actionPerformed(java.awt.event.ActionEvent evt) { 126 | jTextField2ActionPerformed(evt); 127 | } 128 | }); 129 | 130 | memoryUnitLabel.setText("MB"); 131 | 132 | portLabel.setText("Port"); 133 | 134 | memoryLabel.setText("Memory"); 135 | 136 | gotoButton.setText("Open Web"); 137 | gotoButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); 138 | gotoButton.setMaximumSize(new java.awt.Dimension(88, 29)); 139 | gotoButton.setMinimumSize(new java.awt.Dimension(88, 29)); 140 | gotoButton.addActionListener(new java.awt.event.ActionListener() { 141 | public void actionPerformed(java.awt.event.ActionEvent evt) { 142 | openWeb(); 143 | } 144 | }); 145 | 146 | labelStatus.setText("Console Last Updated…"); 147 | 148 | // RemoteMemoryLabel.setText("Memory Usage…"); 149 | 150 | textArea.setColumns(20); 151 | textArea.setRows(5); 152 | jScrollPane1.setViewportView(textArea); 153 | 154 | JLabel creditsLabel = new JLabel(); 155 | creditsLabel.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N 156 | creditsLabel.setText("Stéfan Sinclair & Geoffrey Rockwell (v"+VoyantServerStart.VERSION+")"); 157 | 158 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 159 | jPanel1.setLayout(jPanel1Layout); 160 | jPanel1Layout.setHorizontalGroup( 161 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 162 | .addGroup(jPanel1Layout.createSequentialGroup() 163 | .addContainerGap() 164 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 165 | .addComponent(jScrollPane1) 166 | .addGroup(jPanel1Layout.createSequentialGroup() 167 | .addComponent(labelStatus) 168 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 169 | .addComponent(RemoteMemoryLabel)) 170 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() 171 | .addGap(0, 0, Short.MAX_VALUE) 172 | .addComponent(creditsLabel))) 173 | .addContainerGap()) 174 | ); 175 | jPanel1Layout.setVerticalGroup( 176 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 177 | .addGroup(jPanel1Layout.createSequentialGroup() 178 | .addContainerGap() 179 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 180 | .addComponent(labelStatus) 181 | .addComponent(RemoteMemoryLabel)) 182 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 183 | .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE) 184 | .addComponent(creditsLabel)) 185 | ); 186 | 187 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 188 | this.setLayout(layout); 189 | layout.setHorizontalGroup( 190 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 191 | .addGroup(layout.createSequentialGroup() 192 | .addGap(18, 18, 18) 193 | .addComponent(logoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE) 194 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 195 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 196 | .addComponent(startStopButton, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE) 197 | .addComponent(gotoButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 198 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 93, Short.MAX_VALUE) 199 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 200 | .addComponent(portLabel, javax.swing.GroupLayout.Alignment.TRAILING) 201 | .addComponent(memoryLabel, javax.swing.GroupLayout.Alignment.TRAILING)) 202 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 203 | .addGroup(layout.createSequentialGroup() 204 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 205 | .addComponent(portTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 206 | .addGroup(layout.createSequentialGroup() 207 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 208 | .addComponent(memoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 209 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 210 | .addComponent(memoryUnitLabel))) 211 | .addGap(6, 6, 6)) 212 | .addGroup(layout.createSequentialGroup() 213 | .addContainerGap() 214 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 215 | .addContainerGap()) 216 | ); 217 | layout.setVerticalGroup( 218 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 219 | .addGroup(layout.createSequentialGroup() 220 | .addContainerGap() 221 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 222 | .addGroup(layout.createSequentialGroup() 223 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 224 | .addComponent(portLabel) 225 | .addComponent(portTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 226 | .addComponent(startStopButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 227 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 228 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 229 | .addComponent(memoryUnitLabel) 230 | .addComponent(memoryLabel) 231 | .addComponent(memoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 232 | .addComponent(gotoButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) 233 | .addComponent(logoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)) 234 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 235 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 236 | .addContainerGap()) 237 | ); 238 | } 239 | 240 | 241 | public boolean isServerRunning(){ 242 | return (executor != null); 243 | } 244 | 245 | public void stopServer(){ 246 | // startstopButton.setEnabled(false); 247 | // startstopButton.setText( "Stopping..." ); 248 | executor.exit(); 249 | } 250 | 251 | private void startServer() throws IOException{ 252 | if (ServerConfig.isModified(serverConfigMap)) { 253 | serverConfigMap = ServerConfig.getStoredServerConfig(); 254 | } 255 | serverConfigMap.setPort(portTextField.getText()); 256 | serverConfigMap.setMemoryJVM(memoryTextField.getText()); 257 | onConsole("*** Starting Voyant Server – Web page will open automatically when ready ***\n"); 258 | // startstopButton.setEnabled(false); 259 | // startstopButton.setText( "Starting..." ); 260 | try { 261 | executor = new Executor(serverConfigMap, this ); 262 | } catch (IOException e) { 263 | onConsole( e.getMessage() ); 264 | // startstopButton.setEnabled(true); 265 | // startstopButton.setText( "Start Server" ); 266 | } 267 | } 268 | 269 | public ServerConfigMap getConfig(){ 270 | return serverConfigMap; 271 | } 272 | 273 | public void setConfig(ServerConfigMap scm){ 274 | serverConfigMap.clear(); 275 | serverConfigMap.putAll( scm ); 276 | } 277 | 278 | public void onMemory( String m ){ 279 | // RemoteMemoryLabel.setText(m); 280 | } 281 | 282 | @Override 283 | public synchronized void onConsole(String message) { 284 | textArea.append(message); 285 | textArea.append("\r\n"); 286 | labelStatus.setText( "Console updated: " + DateUtil.getHttpDate(System.currentTimeMillis()) ); 287 | 288 | if ( message.indexOf( JettyRunTime.JETTYSTARTED ) != -1 ) { 289 | startStopButton.setEnabled(true); 290 | startStopButton.setText("Stop Server"); 291 | openWeb(); 292 | } 293 | 294 | else if (message.indexOf( "Server terminated") != -1) { 295 | startStopButton.setEnabled(true); 296 | startStopButton.setText(startServer); 297 | } 298 | // gotoButton.setEnabled(true); 299 | } 300 | 301 | @Override 302 | public void onServerStart() { 303 | onConsole( "Server Starting" ); 304 | // new WebOpener().run(); 305 | // gotoButton.setEnabled(false); 306 | // editConfigButton.setEnabled(false); 307 | // deleteButton.setEnabled(false); 308 | // btnClose.setEnabled(false); 309 | // startstopButton.setEnabled(true); 310 | // startstopButton.setText("Stop Server"); 311 | } 312 | 313 | @Override 314 | public synchronized void onServerExit() { 315 | if ( executor == null ) 316 | return; 317 | 318 | onConsole("Server terminated."); 319 | // gotoButton.setEnabled(false); 320 | // editConfigButton.setEnabled(true); 321 | // deleteButton.setEnabled(true); 322 | // startstopButton.setEnabled(true); 323 | // btnClose.setEnabled(true); 324 | // startstopButton.setText("Start Server"); 325 | 326 | executor = null; 327 | } 328 | 329 | private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) { 330 | // TODO add your handling code here: 331 | } 332 | 333 | private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) { 334 | // TODO add your handling code here: 335 | } 336 | 337 | private void openWeb() { 338 | if ( executor!=null && !executor.isWebAppRunning() ) 339 | return; 340 | 341 | try { 342 | URI uri = getUri(); 343 | java.awt.Desktop.getDesktop().browse(uri); 344 | } catch (IOException e1) { 345 | e1.printStackTrace(); 346 | } 347 | 348 | } 349 | 350 | private URI getUri() { 351 | String host = serverConfigMap.getIP(); 352 | if ( host == null || host.length() == 0 ) 353 | host = "127.0.0.1"; 354 | 355 | String defaultUri = serverConfigMap.getDefaultWebUri(); 356 | if ( defaultUri == null ) 357 | defaultUri = "/"; 358 | 359 | return java.net.URI.create("http://" + host + ":" + serverConfigMap.getPort() + defaultUri ); 360 | 361 | } 362 | 363 | private class WebOpener extends TimerTask { 364 | 365 | @Override 366 | public void run() { 367 | boolean isReady = false; 368 | 369 | if (executor==null || !executor.isWebAppRunning()) {isReady=false;} 370 | else { 371 | URI uri = getUri(); 372 | try { 373 | URLConnection con = uri.toURL().openConnection(); 374 | System.err.println(con.getContent()); 375 | isReady = true; 376 | } catch (Exception e) { 377 | // e.printStackTrace(); 378 | } 379 | } 380 | if (isReady) { 381 | openWeb(); 382 | } 383 | else { 384 | Timer timer = new Timer(); 385 | timer.schedule(new WebOpener(), 100); 386 | } 387 | } 388 | 389 | } 390 | 391 | } 392 | -------------------------------------------------------------------------------- /src/org/aw20/jettydesktop/ui/awt/ServerConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * JettyDesktop is free software: you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * Free Software Foundation,version 3. 5 | * 6 | * JettyDesktop is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License 12 | * If not, see http://www.gnu.org/licenses/ 13 | * 14 | * Additional permission under GNU GPL version 3 section 7 15 | * 16 | * If you modify this Program, or any covered work, by linking or combining 17 | * it with any of the JARS listed in the README.txt (or a modified version of 18 | * (that library), containing parts covered by the terms of that JAR, the 19 | * licensors of this Program grant you additional permission to convey the 20 | * resulting work. 21 | * 22 | * https://github.com/aw20/jettydesktop 23 | * 24 | * May 2013 25 | */ 26 | package org.aw20.jettydesktop.ui.awt; 27 | 28 | import java.awt.BorderLayout; 29 | import java.awt.Dimension; 30 | import java.awt.FlowLayout; 31 | import java.awt.GridBagConstraints; 32 | import java.awt.GridBagLayout; 33 | import java.awt.Insets; 34 | import java.awt.event.ActionEvent; 35 | import java.awt.event.ActionListener; 36 | import java.io.File; 37 | import java.net.Inet4Address; 38 | import java.net.UnknownHostException; 39 | 40 | import javax.swing.JButton; 41 | import javax.swing.JDialog; 42 | import javax.swing.JFileChooser; 43 | import javax.swing.JLabel; 44 | import javax.swing.JOptionPane; 45 | import javax.swing.JPanel; 46 | import javax.swing.JRadioButton; 47 | import javax.swing.JTextField; 48 | import javax.swing.border.EmptyBorder; 49 | import javax.swing.border.TitledBorder; 50 | 51 | import org.aw20.jettydesktop.ui.ServerConfigMap; 52 | 53 | public class ServerConfig extends JDialog { 54 | private static final long serialVersionUID = 1L; 55 | private final JPanel contentPanel = new JPanel(); 56 | private JTextField textFieldServerName; 57 | private JTextField textFieldCustomJVM; 58 | private JTextField textFieldMemoryJVM; 59 | private JTextField textFieldWebFolder; 60 | private JTextField textServerPort; 61 | private JTextField textServerIP; 62 | private JRadioButton rdbtnCurrentJVM, rdbtnCustomJVM; 63 | 64 | private ServerConfigMap currentConfigMap = null; 65 | private JTextField textJVMArgs; 66 | private JTextField textDefaultURI; 67 | 68 | public ServerConfig( ServerConfigMap serverConfigMap ) { 69 | setModal(true); 70 | setResizable(false); 71 | setTitle("Web Configuration"); 72 | setBounds(100, 100, 450, 398); 73 | getContentPane().setLayout(new BorderLayout()); 74 | contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); 75 | getContentPane().add(contentPanel, BorderLayout.CENTER); 76 | contentPanel.setLayout(new BorderLayout(0, 0)); 77 | { 78 | JPanel panel = new JPanel(); 79 | panel.setBorder(new TitledBorder(null, "Server Name", TitledBorder.LEADING, TitledBorder.TOP, null, null)); 80 | contentPanel.add(panel, BorderLayout.NORTH); 81 | GridBagLayout gbl_panel = new GridBagLayout(); 82 | gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0}; 83 | gbl_panel.rowHeights = new int[]{0, 0, 0}; 84 | gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; 85 | gbl_panel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE}; 86 | panel.setLayout(gbl_panel); 87 | { 88 | JLabel lblName = new JLabel("Name:"); 89 | GridBagConstraints gbc_lblName = new GridBagConstraints(); 90 | gbc_lblName.insets = new Insets(5, 5, 5, 5); 91 | gbc_lblName.anchor = GridBagConstraints.EAST; 92 | gbc_lblName.gridx = 0; 93 | gbc_lblName.gridy = 0; 94 | panel.add(lblName, gbc_lblName); 95 | } 96 | { 97 | textFieldServerName = new JTextField(); 98 | GridBagConstraints gbc_textFieldServerName = new GridBagConstraints(); 99 | gbc_textFieldServerName.gridwidth = 2; 100 | gbc_textFieldServerName.insets = new Insets(5, 5, 5, 5); 101 | gbc_textFieldServerName.fill = GridBagConstraints.HORIZONTAL; 102 | gbc_textFieldServerName.gridx = 1; 103 | gbc_textFieldServerName.gridy = 0; 104 | panel.add(textFieldServerName, gbc_textFieldServerName); 105 | textFieldServerName.setColumns(10); 106 | } 107 | { 108 | JLabel lblIpAddress = new JLabel("IP Address:"); 109 | GridBagConstraints gbc_lblIpAddress = new GridBagConstraints(); 110 | gbc_lblIpAddress.anchor = GridBagConstraints.EAST; 111 | gbc_lblIpAddress.insets = new Insets(5, 5, 5, 5); 112 | gbc_lblIpAddress.gridx = 0; 113 | gbc_lblIpAddress.gridy = 1; 114 | panel.add(lblIpAddress, gbc_lblIpAddress); 115 | } 116 | { 117 | textServerIP = new JTextField(); 118 | GridBagConstraints gbc_textServerIP = new GridBagConstraints(); 119 | gbc_textServerIP.insets = new Insets(5, 5, 5, 5); 120 | gbc_textServerIP.fill = GridBagConstraints.HORIZONTAL; 121 | gbc_textServerIP.gridx = 1; 122 | gbc_textServerIP.gridy = 1; 123 | panel.add(textServerIP, gbc_textServerIP); 124 | textServerIP.setColumns(10); 125 | } 126 | { 127 | JLabel lblNewLabel_1 = new JLabel("Port:"); 128 | GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); 129 | gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST; 130 | gbc_lblNewLabel_1.insets = new Insets(5, 5, 5, 5); 131 | gbc_lblNewLabel_1.gridx = 2; 132 | gbc_lblNewLabel_1.gridy = 1; 133 | panel.add(lblNewLabel_1, gbc_lblNewLabel_1); 134 | } 135 | { 136 | textServerPort = new JTextField(); 137 | GridBagConstraints gbc_textServerPort = new GridBagConstraints(); 138 | gbc_textServerPort.fill = GridBagConstraints.HORIZONTAL; 139 | gbc_textServerPort.gridx = 3; 140 | gbc_textServerPort.gridy = 1; 141 | panel.add(textServerPort, gbc_textServerPort); 142 | textServerPort.setColumns(10); 143 | } 144 | } 145 | { 146 | JPanel panel = new JPanel(); 147 | panel.setBorder(new TitledBorder(null, "Web Application", TitledBorder.LEADING, TitledBorder.TOP, null, null)); 148 | contentPanel.add(panel, BorderLayout.CENTER); 149 | GridBagLayout gbl_panel = new GridBagLayout(); 150 | gbl_panel.columnWidths = new int[]{0, 0, 0, 0}; 151 | gbl_panel.rowHeights = new int[]{0, 0, 0}; 152 | gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE}; 153 | gbl_panel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE}; 154 | panel.setLayout(gbl_panel); 155 | { 156 | JLabel lblNewLabel = new JLabel("Web Folder:"); 157 | GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); 158 | gbc_lblNewLabel.insets = new Insets(5, 5, 5, 5); 159 | gbc_lblNewLabel.anchor = GridBagConstraints.EAST; 160 | gbc_lblNewLabel.gridx = 0; 161 | gbc_lblNewLabel.gridy = 0; 162 | panel.add(lblNewLabel, gbc_lblNewLabel); 163 | } 164 | { 165 | textFieldWebFolder = new JTextField(); 166 | GridBagConstraints gbc_textFieldWebFolder = new GridBagConstraints(); 167 | gbc_textFieldWebFolder.insets = new Insets(5, 5, 5, 5); 168 | gbc_textFieldWebFolder.fill = GridBagConstraints.HORIZONTAL; 169 | gbc_textFieldWebFolder.gridx = 1; 170 | gbc_textFieldWebFolder.gridy = 0; 171 | panel.add(textFieldWebFolder, gbc_textFieldWebFolder); 172 | textFieldWebFolder.setColumns(10); 173 | } 174 | { 175 | JButton btnWebAppBrowse = new JButton("browse"); 176 | btnWebAppBrowse.addActionListener(new ActionListener() { 177 | public void actionPerformed(ActionEvent e) { 178 | 179 | JFileChooser chooser = new JFileChooser(); 180 | chooser.setCurrentDirectory(new java.io.File(".")); 181 | chooser.setDialogTitle("Choose Web App Folder"); 182 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 183 | chooser.setAcceptAllFileFilterUsed(false); 184 | 185 | if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { 186 | File webApp = chooser.getSelectedFile(); 187 | textFieldWebFolder.setText(webApp.getAbsolutePath()); 188 | } 189 | 190 | } 191 | }); 192 | GridBagConstraints gbc_btnWebAppBrowse = new GridBagConstraints(); 193 | gbc_btnWebAppBrowse.insets = new Insets(0, 0, 5, 0); 194 | gbc_btnWebAppBrowse.gridx = 2; 195 | gbc_btnWebAppBrowse.gridy = 0; 196 | panel.add(btnWebAppBrowse, gbc_btnWebAppBrowse); 197 | } 198 | { 199 | JLabel lblDefaultUri = new JLabel("Default URI:"); 200 | GridBagConstraints gbc_lblDefaultUri = new GridBagConstraints(); 201 | gbc_lblDefaultUri.anchor = GridBagConstraints.EAST; 202 | gbc_lblDefaultUri.insets = new Insets(5, 5, 5, 5); 203 | gbc_lblDefaultUri.gridx = 0; 204 | gbc_lblDefaultUri.gridy = 1; 205 | panel.add(lblDefaultUri, gbc_lblDefaultUri); 206 | } 207 | { 208 | textDefaultURI = new JTextField(); 209 | GridBagConstraints gbc_textDefaultURI = new GridBagConstraints(); 210 | gbc_textDefaultURI.insets = new Insets(5, 5, 5, 5); 211 | gbc_textDefaultURI.fill = GridBagConstraints.HORIZONTAL; 212 | gbc_textDefaultURI.gridx = 1; 213 | gbc_textDefaultURI.gridy = 1; 214 | panel.add(textDefaultURI, gbc_textDefaultURI); 215 | textDefaultURI.setColumns(10); 216 | } 217 | } 218 | { 219 | JPanel panel = new JPanel(); 220 | panel.setBorder(new TitledBorder(null, "Java Virtual Machine", TitledBorder.LEADING, TitledBorder.TOP, null, null)); 221 | contentPanel.add(panel, BorderLayout.SOUTH); 222 | GridBagLayout gbl_panel = new GridBagLayout(); 223 | gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0}; 224 | gbl_panel.rowHeights = new int[]{0, 0, 0, 0, 0}; 225 | gbl_panel.columnWeights = new double[]{0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE}; 226 | gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; 227 | panel.setLayout(gbl_panel); 228 | { 229 | JLabel lblRuntime = new JLabel("Runtime:"); 230 | GridBagConstraints gbc_lblRuntime = new GridBagConstraints(); 231 | gbc_lblRuntime.insets = new Insets(5, 5, 5, 5); 232 | gbc_lblRuntime.gridx = 0; 233 | gbc_lblRuntime.gridy = 0; 234 | panel.add(lblRuntime, gbc_lblRuntime); 235 | } 236 | { 237 | rdbtnCurrentJVM = new JRadioButton( System.getProperty("java.vm.name") + " " + System.getProperty("java.version") + " " + System.getProperty("java.vm.version") ); 238 | rdbtnCurrentJVM.addActionListener(new ActionListener() { 239 | public void actionPerformed(ActionEvent e) { 240 | rdbtnCustomJVM.setSelected(false); 241 | } 242 | }); 243 | GridBagConstraints gbc_rdbtnCurrentJVM = new GridBagConstraints(); 244 | gbc_rdbtnCurrentJVM.gridwidth = 2; 245 | gbc_rdbtnCurrentJVM.anchor = GridBagConstraints.WEST; 246 | gbc_rdbtnCurrentJVM.insets = new Insets(5, 5, 5, 5); 247 | gbc_rdbtnCurrentJVM.gridx = 1; 248 | gbc_rdbtnCurrentJVM.gridy = 0; 249 | panel.add(rdbtnCurrentJVM, gbc_rdbtnCurrentJVM); 250 | } 251 | { 252 | rdbtnCustomJVM = new JRadioButton("Custom JVM"); 253 | rdbtnCustomJVM.addActionListener(new ActionListener() { 254 | public void actionPerformed(ActionEvent e) { 255 | rdbtnCurrentJVM.setSelected(false); 256 | } 257 | }); 258 | GridBagConstraints gbc_rdbtnCustomJVM = new GridBagConstraints(); 259 | gbc_rdbtnCustomJVM.anchor = GridBagConstraints.WEST; 260 | gbc_rdbtnCustomJVM.insets = new Insets(5, 5, 5, 5); 261 | gbc_rdbtnCustomJVM.gridx = 1; 262 | gbc_rdbtnCustomJVM.gridy = 1; 263 | panel.add(rdbtnCustomJVM, gbc_rdbtnCustomJVM); 264 | } 265 | { 266 | textFieldCustomJVM = new JTextField(); 267 | GridBagConstraints gbc_textFieldCustomJVM = new GridBagConstraints(); 268 | gbc_textFieldCustomJVM.insets = new Insets(5, 5, 5, 5); 269 | gbc_textFieldCustomJVM.fill = GridBagConstraints.HORIZONTAL; 270 | gbc_textFieldCustomJVM.gridx = 2; 271 | gbc_textFieldCustomJVM.gridy = 1; 272 | panel.add(textFieldCustomJVM, gbc_textFieldCustomJVM); 273 | textFieldCustomJVM.setColumns(10); 274 | } 275 | { 276 | JButton btnBrowseCustomJVM = new JButton("browse"); 277 | btnBrowseCustomJVM.addActionListener(new ActionListener() { 278 | public void actionPerformed(ActionEvent e) { 279 | 280 | JFileChooser chooser = new JFileChooser(); 281 | chooser.setCurrentDirectory(new java.io.File(".")); 282 | chooser.setDialogTitle("Choose Java Runtime Folder"); 283 | chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 284 | chooser.setAcceptAllFileFilterUsed(false); 285 | 286 | if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { 287 | File webApp = chooser.getSelectedFile(); 288 | textFieldCustomJVM.setText(webApp.getAbsolutePath()); 289 | } 290 | 291 | } 292 | }); 293 | GridBagConstraints gbc_btnBrowseCustomJVM = new GridBagConstraints(); 294 | gbc_btnBrowseCustomJVM.insets = new Insets(5, 0, 5, 0); 295 | gbc_btnBrowseCustomJVM.gridx = 3; 296 | gbc_btnBrowseCustomJVM.gridy = 1; 297 | panel.add(btnBrowseCustomJVM, gbc_btnBrowseCustomJVM); 298 | } 299 | { 300 | JLabel lblJvmArguments = new JLabel("JVM Arguments"); 301 | GridBagConstraints gbc_lblJvmArguments = new GridBagConstraints(); 302 | gbc_lblJvmArguments.anchor = GridBagConstraints.EAST; 303 | gbc_lblJvmArguments.insets = new Insets(5, 25, 5, 5); 304 | gbc_lblJvmArguments.gridx = 1; 305 | gbc_lblJvmArguments.gridy = 2; 306 | panel.add(lblJvmArguments, gbc_lblJvmArguments); 307 | } 308 | { 309 | textJVMArgs = new JTextField(); 310 | GridBagConstraints gbc_textJVMArgs = new GridBagConstraints(); 311 | gbc_textJVMArgs.insets = new Insets(5, 5, 5, 5); 312 | gbc_textJVMArgs.fill = GridBagConstraints.HORIZONTAL; 313 | gbc_textJVMArgs.gridx = 2; 314 | gbc_textJVMArgs.gridy = 2; 315 | panel.add(textJVMArgs, gbc_textJVMArgs); 316 | textJVMArgs.setColumns(10); 317 | } 318 | { 319 | JLabel lblMemory = new JLabel("Memory:"); 320 | GridBagConstraints gbc_lblMemory = new GridBagConstraints(); 321 | gbc_lblMemory.anchor = GridBagConstraints.EAST; 322 | gbc_lblMemory.insets = new Insets(5, 5, 0, 5); 323 | gbc_lblMemory.gridx = 0; 324 | gbc_lblMemory.gridy = 3; 325 | panel.add(lblMemory, gbc_lblMemory); 326 | } 327 | { 328 | textFieldMemoryJVM = new JTextField(); 329 | GridBagConstraints gbc_textFieldMemoryJVM = new GridBagConstraints(); 330 | gbc_textFieldMemoryJVM.anchor = GridBagConstraints.WEST; 331 | gbc_textFieldMemoryJVM.insets = new Insets(5, 5, 0, 5); 332 | gbc_textFieldMemoryJVM.gridx = 1; 333 | gbc_textFieldMemoryJVM.gridy = 3; 334 | textFieldMemoryJVM.setMinimumSize( new Dimension(100, textFieldMemoryJVM.getHeight()) ); 335 | panel.add(textFieldMemoryJVM, gbc_textFieldMemoryJVM); 336 | textFieldMemoryJVM.setColumns(10); 337 | } 338 | { 339 | JLabel lblMb = new JLabel("MB"); 340 | GridBagConstraints gbc_lblMb = new GridBagConstraints(); 341 | gbc_lblMb.anchor = GridBagConstraints.WEST; 342 | gbc_lblMb.insets = new Insets(5, 5, 0, 5); 343 | gbc_lblMb.gridx = 2; 344 | gbc_lblMb.gridy = 3; 345 | panel.add(lblMb, gbc_lblMb); 346 | } 347 | } 348 | { 349 | JPanel buttonPane = new JPanel(); 350 | buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 351 | getContentPane().add(buttonPane, BorderLayout.SOUTH); 352 | { 353 | JButton okButton = new JButton("OK"); 354 | okButton.addActionListener(new ActionListener() { 355 | public void actionPerformed(ActionEvent arg0) { 356 | if ( validateSettings() ) 357 | dispose(); 358 | } 359 | }); 360 | okButton.setActionCommand("OK"); 361 | buttonPane.add(okButton); 362 | getRootPane().setDefaultButton(okButton); 363 | } 364 | { 365 | JButton cancelButton = new JButton("Cancel"); 366 | cancelButton.addActionListener(new ActionListener() { 367 | public void actionPerformed(ActionEvent e) { 368 | dispose(); 369 | } 370 | }); 371 | cancelButton.setActionCommand("Cancel"); 372 | buttonPane.add(cancelButton); 373 | } 374 | } 375 | 376 | setValues(serverConfigMap); 377 | } 378 | 379 | public ServerConfigMap getConfig(){ 380 | return currentConfigMap; 381 | } 382 | 383 | private boolean validateSettings(){ 384 | String tmp; 385 | ServerConfigMap config = new ServerConfigMap(); 386 | 387 | // Server Name 388 | tmp = textFieldServerName.getText().trim(); 389 | if ( tmp.length() == 0 ){ 390 | JOptionPane.showMessageDialog(this, "Invalid server name"); 391 | return false; 392 | }else 393 | config.setName(tmp); 394 | 395 | // Server IP 396 | tmp = textServerIP.getText().trim(); 397 | if ( tmp.length() != 0 && !isValidIP(tmp) ){ 398 | JOptionPane.showMessageDialog(this, "Invalid IP address"); 399 | return false; 400 | }else 401 | config.setIP(tmp); 402 | 403 | // Server Port 404 | tmp = textServerPort.getText().trim(); 405 | if ( !isValidNumber(tmp) ){ 406 | JOptionPane.showMessageDialog(this, "Invalid server port"); 407 | return false; 408 | }else 409 | config.setPort(tmp); 410 | 411 | // WebApp folder 412 | tmp = textFieldWebFolder.getText().trim(); 413 | if ( tmp.length() == 0 && !new File(tmp + File.separator + "WEB-INF", "web.xml").isFile() ){ 414 | JOptionPane.showMessageDialog(this, "Invalid web directory"); 415 | return false; 416 | }else 417 | config.setWebFolder(tmp); 418 | 419 | tmp = textDefaultURI.getText(); 420 | if ( tmp.length() > 0 ) 421 | config.setDefaultWebUri( tmp ); 422 | 423 | 424 | // JVM 425 | if ( rdbtnCurrentJVM.isSelected() ){ 426 | config.setCurrentJVM(); 427 | }else{ 428 | tmp = textFieldCustomJVM.getText().trim(); 429 | if ( tmp.length() == 0 && !new File(tmp,"bin").isDirectory() ){ 430 | JOptionPane.showMessageDialog(this, "Invalid Java directory"); 431 | return false; 432 | }else 433 | config.setCustomJVM(tmp); 434 | } 435 | 436 | 437 | // Default JVM ARGs 438 | tmp = textJVMArgs.getText(); 439 | if ( tmp.length() > 0 ) 440 | config.setDefaultJVMArgs( tmp ); 441 | 442 | 443 | // Memory 444 | tmp = textFieldMemoryJVM.getText().trim(); 445 | if ( !isValidNumber(tmp) ){ 446 | JOptionPane.showMessageDialog(this, "Invalid memory value"); 447 | return false; 448 | }else 449 | config.setMemoryJVM(tmp); 450 | 451 | // All is good 452 | currentConfigMap = config; 453 | return true; 454 | } 455 | 456 | private boolean isValidNumber(String t){ 457 | try{ 458 | Integer.valueOf(t); 459 | }catch(Exception e){ 460 | return false; 461 | } 462 | return true; 463 | } 464 | 465 | private boolean isValidIP(String t){ 466 | if ( t.length() == 0 ) 467 | return false; 468 | 469 | try { 470 | Inet4Address.getByName(t); 471 | return true; 472 | } catch (UnknownHostException e) { 473 | return false; 474 | } 475 | } 476 | 477 | private void setValues( ServerConfigMap serverConfigMap ){ 478 | textFieldServerName.setText( serverConfigMap.getName() ); 479 | textServerPort.setText( serverConfigMap.getPort() ); 480 | textServerIP.setText( serverConfigMap.getIP() ); 481 | 482 | textFieldWebFolder.setText( serverConfigMap.getWebFolder() ); 483 | 484 | textFieldMemoryJVM.setText( serverConfigMap.getMemoryJVM() ); 485 | 486 | if ( serverConfigMap.getCurrentJVM() != null ){ 487 | textFieldCustomJVM.setText( serverConfigMap.getCustomJVM() ); 488 | rdbtnCurrentJVM.setSelected(true); 489 | rdbtnCustomJVM.setSelected(false); 490 | }else{ 491 | rdbtnCurrentJVM.setSelected(false); 492 | rdbtnCustomJVM.setSelected(true); 493 | } 494 | 495 | String defaultJVMArgs = serverConfigMap.getDefaultJVMArgs(); 496 | if ( defaultJVMArgs == null ){ 497 | textJVMArgs.setText(""); 498 | }else{ 499 | textJVMArgs.setText(defaultJVMArgs); 500 | } 501 | 502 | String defaultWebUri = serverConfigMap.getDefaultWebUri(); 503 | if ( defaultWebUri == null ){ 504 | textDefaultURI.setText("/"); 505 | }else{ 506 | textDefaultURI.setText(defaultWebUri); 507 | } 508 | } 509 | } 510 | -------------------------------------------------------------------------------- /license-GPL3.txt: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 3, 29 June 2007 4 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for 12 | software and other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | the GNU General Public License is intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. We, the Free Software Foundation, use the 19 | GNU General Public License for most of our software; it applies also to 20 | any other work released this way by its authors. You can apply it to 21 | your programs, too. 22 | 23 | When we speak of free software, we are referring to freedom, not 24 | price. Our General Public Licenses are designed to make sure that you 25 | have the freedom to distribute copies of free software (and charge for 26 | them if you wish), that you receive source code or can get it if you 27 | want it, that you can change the software or use pieces of it in new 28 | free programs, and that you know you can do these things. 29 | 30 | To protect your rights, we need to prevent others from denying you 31 | these rights or asking you to surrender the rights. Therefore, you have 32 | certain responsibilities if you distribute copies of the software, or if 33 | you modify it: responsibilities to respect the freedom of others. 34 | 35 | For example, if you distribute copies of such a program, whether 36 | gratis or for a fee, you must pass on to the recipients the same 37 | freedoms that you received. You must make sure that they, too, receive 38 | or can get the source code. And you must show them these terms so they 39 | know their rights. 40 | 41 | Developers that use the GNU GPL protect your rights with two steps: 42 | (1) assert copyright on the software, and (2) offer you this License 43 | giving you legal permission to copy, distribute and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains 46 | that there is no warranty for this free software. For both users' and 47 | authors' sake, the GPL requires that modified versions be marked as 48 | changed, so that their problems will not be attributed erroneously to 49 | authors of previous versions. 50 | 51 | Some devices are designed to deny users access to install or run 52 | modified versions of the software inside them, although the manufacturer 53 | can do so. This is fundamentally incompatible with the aim of 54 | protecting users' freedom to change the software. The systematic 55 | pattern of such abuse occurs in the area of products for individuals to 56 | use, which is precisely where it is most unacceptable. Therefore, we 57 | have designed this version of the GPL to prohibit the practice for those 58 | products. If such problems arise substantially in other domains, we 59 | stand ready to extend this provision to those domains in future versions 60 | of the GPL, as needed to protect the freedom of users. 61 | 62 | Finally, every program is threatened constantly by software patents. 63 | States should not allow patents to restrict development and use of 64 | software on general-purpose computers, but in those that do, we wish to 65 | avoid the special danger that patents applied to a free program could 66 | make it effectively proprietary. To prevent this, the GPL assures that 67 | patents cannot be used to render the program non-free. 68 | 69 | The precise terms and conditions for copying, distribution and 70 | modification follow. 71 | 72 | TERMS AND CONDITIONS 73 | 74 | 0. Definitions. 75 | 76 | "This License" refers to version 3 of the GNU General Public License. 77 | 78 | "Copyright" also means copyright-like laws that apply to other kinds of 79 | works, such as semiconductor masks. 80 | 81 | "The Program" refers to any copyrightable work licensed under this 82 | License. Each licensee is addressed as "you". "Licensees" and 83 | "recipients" may be individuals or organizations. 84 | 85 | To "modify" a work means to copy from or adapt all or part of the work 86 | in a fashion requiring copyright permission, other than the making of an 87 | exact copy. The resulting work is called a "modified version" of the 88 | earlier work or a work "based on" the earlier work. 89 | 90 | A "covered work" means either the unmodified Program or a work based 91 | on the Program. 92 | 93 | To "propagate" a work means to do anything with it that, without 94 | permission, would make you directly or secondarily liable for 95 | infringement under applicable copyright law, except executing it on a 96 | computer or modifying a private copy. Propagation includes copying, 97 | distribution (with or without modification), making available to the 98 | public, and in some countries other activities as well. 99 | 100 | To "convey" a work means any kind of propagation that enables other 101 | parties to make or receive copies. Mere interaction with a user through 102 | a computer network, with no transfer of a copy, is not conveying. 103 | 104 | An interactive user interface displays "Appropriate Legal Notices" 105 | to the extent that it includes a convenient and prominently visible 106 | feature that (1) displays an appropriate copyright notice, and (2) 107 | tells the user that there is no warranty for the work (except to the 108 | extent that warranties are provided), that licensees may convey the 109 | work under this License, and how to view a copy of this License. If 110 | the interface presents a list of user commands or options, such as a 111 | menu, a prominent item in the list meets this criterion. 112 | 113 | 1. Source Code. 114 | 115 | The "source code" for a work means the preferred form of the work 116 | for making modifications to it. "Object code" means any non-source 117 | form of a work. 118 | 119 | A "Standard Interface" means an interface that either is an official 120 | standard defined by a recognized standards body, or, in the case of 121 | interfaces specified for a particular programming language, one that 122 | is widely used among developers working in that language. 123 | 124 | The "System Libraries" of an executable work include anything, other 125 | than the work as a whole, that (a) is included in the normal form of 126 | packaging a Major Component, but which is not part of that Major 127 | Component, and (b) serves only to enable use of the work with that 128 | Major Component, or to implement a Standard Interface for which an 129 | implementation is available to the public in source code form. A 130 | "Major Component", in this context, means a major essential component 131 | (kernel, window system, and so on) of the specific operating system 132 | (if any) on which the executable work runs, or a compiler used to 133 | produce the work, or an object code interpreter used to run it. 134 | 135 | The "Corresponding Source" for a work in object code form means all 136 | the source code needed to generate, install, and (for an executable 137 | work) run the object code and to modify the work, including scripts to 138 | control those activities. However, it does not include the work's 139 | System Libraries, or general-purpose tools or generally available free 140 | programs which are used unmodified in performing those activities but 141 | which are not part of the work. For example, Corresponding Source 142 | includes interface definition files associated with source files for 143 | the work, and the source code for shared libraries and dynamically 144 | linked subprograms that the work is specifically designed to require, 145 | such as by intimate data communication or control flow between those 146 | subprograms and other parts of the work. 147 | 148 | The Corresponding Source need not include anything that users 149 | can regenerate automatically from other parts of the Corresponding 150 | Source. 151 | 152 | The Corresponding Source for a work in source code form is that 153 | same work. 154 | 155 | 2. Basic Permissions. 156 | 157 | All rights granted under this License are granted for the term of 158 | copyright on the Program, and are irrevocable provided the stated 159 | conditions are met. This License explicitly affirms your unlimited 160 | permission to run the unmodified Program. The output from running a 161 | covered work is covered by this License only if the output, given its 162 | content, constitutes a covered work. This License acknowledges your 163 | rights of fair use or other equivalent, as provided by copyright law. 164 | 165 | You may make, run and propagate covered works that you do not 166 | convey, without conditions so long as your license otherwise remains 167 | in force. You may convey covered works to others for the sole purpose 168 | of having them make modifications exclusively for you, or provide you 169 | with facilities for running those works, provided that you comply with 170 | the terms of this License in conveying all material for which you do 171 | not control copyright. Those thus making or running the covered works 172 | for you must do so exclusively on your behalf, under your direction 173 | and control, on terms that prohibit them from making any copies of 174 | your copyrighted material outside their relationship with you. 175 | 176 | Conveying under any other circumstances is permitted solely under 177 | the conditions stated below. Sublicensing is not allowed; section 10 178 | makes it unnecessary. 179 | 180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 181 | 182 | No covered work shall be deemed part of an effective technological 183 | measure under any applicable law fulfilling obligations under article 184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 185 | similar laws prohibiting or restricting circumvention of such 186 | measures. 187 | 188 | When you convey a covered work, you waive any legal power to forbid 189 | circumvention of technological measures to the extent such circumvention 190 | is effected by exercising rights under this License with respect to 191 | the covered work, and you disclaim any intention to limit operation or 192 | modification of the work as a means of enforcing, against the work's 193 | users, your or third parties' legal rights to forbid circumvention of 194 | technological measures. 195 | 196 | 4. Conveying Verbatim Copies. 197 | 198 | You may convey verbatim copies of the Program's source code as you 199 | receive it, in any medium, provided that you conspicuously and 200 | appropriately publish on each copy an appropriate copyright notice; 201 | keep intact all notices stating that this License and any 202 | non-permissive terms added in accord with section 7 apply to the code; 203 | keep intact all notices of the absence of any warranty; and give all 204 | recipients a copy of this License along with the Program. 205 | 206 | You may charge any price or no price for each copy that you convey, 207 | and you may offer support or warranty protection for a fee. 208 | 209 | 5. Conveying Modified Source Versions. 210 | 211 | You may convey a work based on the Program, or the modifications to 212 | produce it from the Program, in the form of source code under the 213 | terms of section 4, provided that you also meet all of these conditions: 214 | 215 | a) The work must carry prominent notices stating that you modified 216 | it, and giving a relevant date. 217 | 218 | b) The work must carry prominent notices stating that it is 219 | released under this License and any conditions added under section 220 | 7. This requirement modifies the requirement in section 4 to 221 | "keep intact all notices". 222 | 223 | c) You must license the entire work, as a whole, under this 224 | License to anyone who comes into possession of a copy. This 225 | License will therefore apply, along with any applicable section 7 226 | additional terms, to the whole of the work, and all its parts, 227 | regardless of how they are packaged. This License gives no 228 | permission to license the work in any other way, but it does not 229 | invalidate such permission if you have separately received it. 230 | 231 | d) If the work has interactive user interfaces, each must display 232 | Appropriate Legal Notices; however, if the Program has interactive 233 | interfaces that do not display Appropriate Legal Notices, your 234 | work need not make them do so. 235 | 236 | A compilation of a covered work with other separate and independent 237 | works, which are not by their nature extensions of the covered work, 238 | and which are not combined with it such as to form a larger program, 239 | in or on a volume of a storage or distribution medium, is called an 240 | "aggregate" if the compilation and its resulting copyright are not 241 | used to limit the access or legal rights of the compilation's users 242 | beyond what the individual works permit. Inclusion of a covered work 243 | in an aggregate does not cause this License to apply to the other 244 | parts of the aggregate. 245 | 246 | 6. Conveying Non-Source Forms. 247 | 248 | You may convey a covered work in object code form under the terms 249 | of sections 4 and 5, provided that you also convey the 250 | machine-readable Corresponding Source under the terms of this License, 251 | in one of these ways: 252 | 253 | a) Convey the object code in, or embodied in, a physical product 254 | (including a physical distribution medium), accompanied by the 255 | Corresponding Source fixed on a durable physical medium 256 | customarily used for software interchange. 257 | 258 | b) Convey the object code in, or embodied in, a physical product 259 | (including a physical distribution medium), accompanied by a 260 | written offer, valid for at least three years and valid for as 261 | long as you offer spare parts or customer support for that product 262 | model, to give anyone who possesses the object code either (1) a 263 | copy of the Corresponding Source for all the software in the 264 | product that is covered by this License, on a durable physical 265 | medium customarily used for software interchange, for a price no 266 | more than your reasonable cost of physically performing this 267 | conveying of source, or (2) access to copy the 268 | Corresponding Source from a network server at no charge. 269 | 270 | c) Convey individual copies of the object code with a copy of the 271 | written offer to provide the Corresponding Source. This 272 | alternative is allowed only occasionally and noncommercially, and 273 | only if you received the object code with such an offer, in accord 274 | with subsection 6b. 275 | 276 | d) Convey the object code by offering access from a designated 277 | place (gratis or for a charge), and offer equivalent access to the 278 | Corresponding Source in the same way through the same place at no 279 | further charge. You need not require recipients to copy the 280 | Corresponding Source along with the object code. If the place to 281 | copy the object code is a network server, the Corresponding Source 282 | may be on a different server (operated by you or a third party) 283 | that supports equivalent copying facilities, provided you maintain 284 | clear directions next to the object code saying where to find the 285 | Corresponding Source. Regardless of what server hosts the 286 | Corresponding Source, you remain obligated to ensure that it is 287 | available for as long as needed to satisfy these requirements. 288 | 289 | e) Convey the object code using peer-to-peer transmission, provided 290 | you inform other peers where the object code and Corresponding 291 | Source of the work are being offered to the general public at no 292 | charge under subsection 6d. 293 | 294 | A separable portion of the object code, whose source code is excluded 295 | from the Corresponding Source as a System Library, need not be 296 | included in conveying the object code work. 297 | 298 | A "User Product" is either (1) a "consumer product", which means any 299 | tangible personal property which is normally used for personal, family, 300 | or household purposes, or (2) anything designed or sold for incorporation 301 | into a dwelling. In determining whether a product is a consumer product, 302 | doubtful cases shall be resolved in favor of coverage. For a particular 303 | product received by a particular user, "normally used" refers to a 304 | typical or common use of that class of product, regardless of the status 305 | of the particular user or of the way in which the particular user 306 | actually uses, or expects or is expected to use, the product. A product 307 | is a consumer product regardless of whether the product has substantial 308 | commercial, industrial or non-consumer uses, unless such uses represent 309 | the only significant mode of use of the product. 310 | 311 | "Installation Information" for a User Product means any methods, 312 | procedures, authorization keys, or other information required to install 313 | and execute modified versions of a covered work in that User Product from 314 | a modified version of its Corresponding Source. The information must 315 | suffice to ensure that the continued functioning of the modified object 316 | code is in no case prevented or interfered with solely because 317 | modification has been made. 318 | 319 | If you convey an object code work under this section in, or with, or 320 | specifically for use in, a User Product, and the conveying occurs as 321 | part of a transaction in which the right of possession and use of the 322 | User Product is transferred to the recipient in perpetuity or for a 323 | fixed term (regardless of how the transaction is characterized), the 324 | Corresponding Source conveyed under this section must be accompanied 325 | by the Installation Information. But this requirement does not apply 326 | if neither you nor any third party retains the ability to install 327 | modified object code on the User Product (for example, the work has 328 | been installed in ROM). 329 | 330 | The requirement to provide Installation Information does not include a 331 | requirement to continue to provide support service, warranty, or updates 332 | for a work that has been modified or installed by the recipient, or for 333 | the User Product in which it has been modified or installed. Access to a 334 | network may be denied when the modification itself materially and 335 | adversely affects the operation of the network or violates the rules and 336 | protocols for communication across the network. 337 | 338 | Corresponding Source conveyed, and Installation Information provided, 339 | in accord with this section must be in a format that is publicly 340 | documented (and with an implementation available to the public in 341 | source code form), and must require no special password or key for 342 | unpacking, reading or copying. 343 | 344 | 7. Additional Terms. 345 | 346 | "Additional permissions" are terms that supplement the terms of this 347 | License by making exceptions from one or more of its conditions. 348 | Additional permissions that are applicable to the entire Program shall 349 | be treated as though they were included in this License, to the extent 350 | that they are valid under applicable law. If additional permissions 351 | apply only to part of the Program, that part may be used separately 352 | under those permissions, but the entire Program remains governed by 353 | this License without regard to the additional permissions. 354 | 355 | When you convey a copy of a covered work, you may at your option 356 | remove any additional permissions from that copy, or from any part of 357 | it. (Additional permissions may be written to require their own 358 | removal in certain cases when you modify the work.) You may place 359 | additional permissions on material, added by you to a covered work, 360 | for which you have or can give appropriate copyright permission. 361 | 362 | Notwithstanding any other provision of this License, for material you 363 | add to a covered work, you may (if authorized by the copyright holders of 364 | that material) supplement the terms of this License with terms: 365 | 366 | a) Disclaiming warranty or limiting liability differently from the 367 | terms of sections 15 and 16 of this License; or 368 | 369 | b) Requiring preservation of specified reasonable legal notices or 370 | author attributions in that material or in the Appropriate Legal 371 | Notices displayed by works containing it; or 372 | 373 | c) Prohibiting misrepresentation of the origin of that material, or 374 | requiring that modified versions of such material be marked in 375 | reasonable ways as different from the original version; or 376 | 377 | d) Limiting the use for publicity purposes of names of licensors or 378 | authors of the material; or 379 | 380 | e) Declining to grant rights under trademark law for use of some 381 | trade names, trademarks, or service marks; or 382 | 383 | f) Requiring indemnification of licensors and authors of that 384 | material by anyone who conveys the material (or modified versions of 385 | it) with contractual assumptions of liability to the recipient, for 386 | any liability that these contractual assumptions directly impose on 387 | those licensors and authors. 388 | 389 | All other non-permissive additional terms are considered "further 390 | restrictions" within the meaning of section 10. If the Program as you 391 | received it, or any part of it, contains a notice stating that it is 392 | governed by this License along with a term that is a further 393 | restriction, you may remove that term. If a license document contains 394 | a further restriction but permits relicensing or conveying under this 395 | License, you may add to a covered work material governed by the terms 396 | of that license document, provided that the further restriction does 397 | not survive such relicensing or conveying. 398 | 399 | If you add terms to a covered work in accord with this section, you 400 | must place, in the relevant source files, a statement of the 401 | additional terms that apply to those files, or a notice indicating 402 | where to find the applicable terms. 403 | 404 | Additional terms, permissive or non-permissive, may be stated in the 405 | form of a separately written license, or stated as exceptions; 406 | the above requirements apply either way. 407 | 408 | 8. Termination. 409 | 410 | You may not propagate or modify a covered work except as expressly 411 | provided under this License. Any attempt otherwise to propagate or 412 | modify it is void, and will automatically terminate your rights under 413 | this License (including any patent licenses granted under the third 414 | paragraph of section 11). 415 | 416 | However, if you cease all violation of this License, then your 417 | license from a particular copyright holder is reinstated (a) 418 | provisionally, unless and until the copyright holder explicitly and 419 | finally terminates your license, and (b) permanently, if the copyright 420 | holder fails to notify you of the violation by some reasonable means 421 | prior to 60 days after the cessation. 422 | 423 | Moreover, your license from a particular copyright holder is 424 | reinstated permanently if the copyright holder notifies you of the 425 | violation by some reasonable means, this is the first time you have 426 | received notice of violation of this License (for any work) from that 427 | copyright holder, and you cure the violation prior to 30 days after 428 | your receipt of the notice. 429 | 430 | Termination of your rights under this section does not terminate the 431 | licenses of parties who have received copies or rights from you under 432 | this License. If your rights have been terminated and not permanently 433 | reinstated, you do not qualify to receive new licenses for the same 434 | material under section 10. 435 | 436 | 9. Acceptance Not Required for Having Copies. 437 | 438 | You are not required to accept this License in order to receive or 439 | run a copy of the Program. Ancillary propagation of a covered work 440 | occurring solely as a consequence of using peer-to-peer transmission 441 | to receive a copy likewise does not require acceptance. However, 442 | nothing other than this License grants you permission to propagate or 443 | modify any covered work. These actions infringe copyright if you do 444 | not accept this License. Therefore, by modifying or propagating a 445 | covered work, you indicate your acceptance of this License to do so. 446 | 447 | 10. Automatic Licensing of Downstream Recipients. 448 | 449 | Each time you convey a covered work, the recipient automatically 450 | receives a license from the original licensors, to run, modify and 451 | propagate that work, subject to this License. You are not responsible 452 | for enforcing compliance by third parties with this License. 453 | 454 | An "entity transaction" is a transaction transferring control of an 455 | organization, or substantially all assets of one, or subdividing an 456 | organization, or merging organizations. If propagation of a covered 457 | work results from an entity transaction, each party to that 458 | transaction who receives a copy of the work also receives whatever 459 | licenses to the work the party's predecessor in interest had or could 460 | give under the previous paragraph, plus a right to possession of the 461 | Corresponding Source of the work from the predecessor in interest, if 462 | the predecessor has it or can get it with reasonable efforts. 463 | 464 | You may not impose any further restrictions on the exercise of the 465 | rights granted or affirmed under this License. For example, you may 466 | not impose a license fee, royalty, or other charge for exercise of 467 | rights granted under this License, and you may not initiate litigation 468 | (including a cross-claim or counterclaim in a lawsuit) alleging that 469 | any patent claim is infringed by making, using, selling, offering for 470 | sale, or importing the Program or any portion of it. 471 | 472 | 11. Patents. 473 | 474 | A "contributor" is a copyright holder who authorizes use under this 475 | License of the Program or a work on which the Program is based. The 476 | work thus licensed is called the contributor's "contributor version". 477 | 478 | A contributor's "essential patent claims" are all patent claims 479 | owned or controlled by the contributor, whether already acquired or 480 | hereafter acquired, that would be infringed by some manner, permitted 481 | by this License, of making, using, or selling its contributor version, 482 | but do not include claims that would be infringed only as a 483 | consequence of further modification of the contributor version. For 484 | purposes of this definition, "control" includes the right to grant 485 | patent sublicenses in a manner consistent with the requirements of 486 | this License. 487 | 488 | Each contributor grants you a non-exclusive, worldwide, royalty-free 489 | patent license under the contributor's essential patent claims, to 490 | make, use, sell, offer for sale, import and otherwise run, modify and 491 | propagate the contents of its contributor version. 492 | 493 | In the following three paragraphs, a "patent license" is any express 494 | agreement or commitment, however denominated, not to enforce a patent 495 | (such as an express permission to practice a patent or covenant not to 496 | sue for patent infringement). To "grant" such a patent license to a 497 | party means to make such an agreement or commitment not to enforce a 498 | patent against the party. 499 | 500 | If you convey a covered work, knowingly relying on a patent license, 501 | and the Corresponding Source of the work is not available for anyone 502 | to copy, free of charge and under the terms of this License, through a 503 | publicly available network server or other readily accessible means, 504 | then you must either (1) cause the Corresponding Source to be so 505 | available, or (2) arrange to deprive yourself of the benefit of the 506 | patent license for this particular work, or (3) arrange, in a manner 507 | consistent with the requirements of this License, to extend the patent 508 | license to downstream recipients. "Knowingly relying" means you have 509 | actual knowledge that, but for the patent license, your conveying the 510 | covered work in a country, or your recipient's use of the covered work 511 | in a country, would infringe one or more identifiable patents in that 512 | country that you have reason to believe are valid. 513 | 514 | If, pursuant to or in connection with a single transaction or 515 | arrangement, you convey, or propagate by procuring conveyance of, a 516 | covered work, and grant a patent license to some of the parties 517 | receiving the covered work authorizing them to use, propagate, modify 518 | or convey a specific copy of the covered work, then the patent license 519 | you grant is automatically extended to all recipients of the covered 520 | work and works based on it. 521 | 522 | A patent license is "discriminatory" if it does not include within 523 | the scope of its coverage, prohibits the exercise of, or is 524 | conditioned on the non-exercise of one or more of the rights that are 525 | specifically granted under this License. You may not convey a covered 526 | work if you are a party to an arrangement with a third party that is 527 | in the business of distributing software, under which you make payment 528 | to the third party based on the extent of your activity of conveying 529 | the work, and under which the third party grants, to any of the 530 | parties who would receive the covered work from you, a discriminatory 531 | patent license (a) in connection with copies of the covered work 532 | conveyed by you (or copies made from those copies), or (b) primarily 533 | for and in connection with specific products or compilations that 534 | contain the covered work, unless you entered into that arrangement, 535 | or that patent license was granted, prior to 28 March 2007. 536 | 537 | Nothing in this License shall be construed as excluding or limiting 538 | any implied license or other defenses to infringement that may 539 | otherwise be available to you under applicable patent law. 540 | 541 | 12. No Surrender of Others' Freedom. 542 | 543 | If conditions are imposed on you (whether by court order, agreement or 544 | otherwise) that contradict the conditions of this License, they do not 545 | excuse you from the conditions of this License. If you cannot convey a 546 | covered work so as to satisfy simultaneously your obligations under this 547 | License and any other pertinent obligations, then as a consequence you may 548 | not convey it at all. For example, if you agree to terms that obligate you 549 | to collect a royalty for further conveying from those to whom you convey 550 | the Program, the only way you could satisfy both those terms and this 551 | License would be to refrain entirely from conveying the Program. 552 | 553 | 13. Use with the GNU Affero General Public License. 554 | 555 | Notwithstanding any other provision of this License, you have 556 | permission to link or combine any covered work with a work licensed 557 | under version 3 of the GNU Affero General Public License into a single 558 | combined work, and to convey the resulting work. The terms of this 559 | License will continue to apply to the part which is the covered work, 560 | but the special requirements of the GNU Affero General Public License, 561 | section 13, concerning interaction through a network will apply to the 562 | combination as such. 563 | 564 | 14. Revised Versions of this License. 565 | 566 | The Free Software Foundation may publish revised and/or new versions of 567 | the GNU General Public License from time to time. Such new versions will 568 | be similar in spirit to the present version, but may differ in detail to 569 | address new problems or concerns. 570 | 571 | Each version is given a distinguishing version number. If the 572 | Program specifies that a certain numbered version of the GNU General 573 | Public License "or any later version" applies to it, you have the 574 | option of following the terms and conditions either of that numbered 575 | version or of any later version published by the Free Software 576 | Foundation. If the Program does not specify a version number of the 577 | GNU General Public License, you may choose any version ever published 578 | by the Free Software Foundation. 579 | 580 | If the Program specifies that a proxy can decide which future 581 | versions of the GNU General Public License can be used, that proxy's 582 | public statement of acceptance of a version permanently authorizes you 583 | to choose that version for the Program. 584 | 585 | Later license versions may give you additional or different 586 | permissions. However, no additional obligations are imposed on any 587 | author or copyright holder as a result of your choosing to follow a 588 | later version. 589 | 590 | 15. Disclaimer of Warranty. 591 | 592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 600 | 601 | 16. Limitation of Liability. 602 | 603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 611 | SUCH DAMAGES. 612 | 613 | 17. Interpretation of Sections 15 and 16. 614 | 615 | If the disclaimer of warranty and limitation of liability provided 616 | above cannot be given local legal effect according to their terms, 617 | reviewing courts shall apply local law that most closely approximates 618 | an absolute waiver of all civil liability in connection with the 619 | Program, unless a warranty or assumption of liability accompanies a 620 | copy of the Program in return for a fee. 621 | 622 | END OF TERMS AND CONDITIONS 623 | --------------------------------------------------------------------------------