diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 9937081..0000000 --- a/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (c) 2012 SuperMapiClient/jsBev -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -2.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/WEB-INF/lib/commons-beanutils-1.7.0.jar b/WEB-INF/lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/WEB-INF/lib/commons-beanutils-1.7.0.jar differ diff --git a/WEB-INF/lib/commons-collections-3.2.jar b/WEB-INF/lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/WEB-INF/lib/commons-collections-3.2.jar differ diff --git a/WEB-INF/lib/commons-fileupload-1.2.jar b/WEB-INF/lib/commons-fileupload-1.2.jar new file mode 100644 index 0000000..12539f5 Binary files /dev/null and b/WEB-INF/lib/commons-fileupload-1.2.jar differ diff --git a/WEB-INF/lib/commons-io-1.3.2.jar b/WEB-INF/lib/commons-io-1.3.2.jar new file mode 100644 index 0000000..865c9e4 Binary files /dev/null and b/WEB-INF/lib/commons-io-1.3.2.jar differ diff --git a/WEB-INF/lib/commons-lang-2.3.jar b/WEB-INF/lib/commons-lang-2.3.jar new file mode 100644 index 0000000..c33b353 Binary files /dev/null and b/WEB-INF/lib/commons-lang-2.3.jar differ diff --git a/WEB-INF/lib/commons-logging.jar b/WEB-INF/lib/commons-logging.jar new file mode 100644 index 0000000..6b0bdd4 Binary files /dev/null and b/WEB-INF/lib/commons-logging.jar differ diff --git a/WEB-INF/lib/ezmorph-1.0.4.jar b/WEB-INF/lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/WEB-INF/lib/ezmorph-1.0.4.jar differ diff --git a/WEB-INF/lib/flexjson-2.1.jar b/WEB-INF/lib/flexjson-2.1.jar new file mode 100644 index 0000000..aeedb7a Binary files /dev/null and b/WEB-INF/lib/flexjson-2.1.jar differ diff --git a/WEB-INF/lib/jsbev_v2.4.jar b/WEB-INF/lib/jsbev_v2.4.jar new file mode 100644 index 0000000..ca408a3 Binary files /dev/null and b/WEB-INF/lib/jsbev_v2.4.jar differ diff --git a/WEB-INF/lib/json-lib-2.2.3-jdk15.jar b/WEB-INF/lib/json-lib-2.2.3-jdk15.jar new file mode 100644 index 0000000..8c92fab Binary files /dev/null and b/WEB-INF/lib/json-lib-2.2.3-jdk15.jar differ diff --git a/WEB-INF/lib/log4j-1.2.14.jar b/WEB-INF/lib/log4j-1.2.14.jar new file mode 100644 index 0000000..6251307 Binary files /dev/null and b/WEB-INF/lib/log4j-1.2.14.jar differ diff --git a/WEB-INF/log4j.properties b/WEB-INF/log4j.properties new file mode 100644 index 0000000..b0825c5 --- /dev/null +++ b/WEB-INF/log4j.properties @@ -0,0 +1,31 @@ +log4j.rootLogger=INFO, stdout, logfile + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +#log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n +log4j.appender.stdout.layout.ConversionPattern=- %m%n + +log4j.appender.logfile=org.apache.log4j.RollingFileAppender +log4j.appender.logfile.File=${webapp_root}/bevfefefe.log +#${D_HOME}/bev1111.log +#${webapp.root}/log/bev.log +log4j.appender.logfile.MaxFileSize=5MB +# Keep three backup files. +log4j.appender.logfile.MaxBackupIndex=3 +# Pattern to output: date priority [category] - message +log4j.appender.logfile.layout=org.apache.log4j.PatternLayout +log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n + +log4j.logger.com.opensymphony.xwork2=ERROR + +# Control logging for other open source packages +log4j.logger.org.springframework=ERROR +log4j.logger.org.quartz=ERROR +log4j.logger.net.sf.ehcache=ERROR +log4j.logger.net.sf.navigator=ERROR +log4j.logger.org.apache.commons=ERROR +log4j.logger.org.apache.struts=ERROR + +# Struts OgnlUtil issues unimportant warnings +log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error +log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error \ No newline at end of file diff --git a/WEB-INF/src/META-INF/MANIFEST.MF b/WEB-INF/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..4a96e22 --- /dev/null +++ b/WEB-INF/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.bev.PageConfig + diff --git a/WEB-INF/src/com/bev/ConfigInfo.java b/WEB-INF/src/com/bev/ConfigInfo.java new file mode 100644 index 0000000..e298689 --- /dev/null +++ b/WEB-INF/src/com/bev/ConfigInfo.java @@ -0,0 +1,207 @@ +package com.bev; + +import com.bev.util.FileManger; +import flexjson.JSONSerializer; +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map; + +/** + * Created with IntelliJ IDEA. + * User: liuhong + * Date: 13-12-5 + * Time: 上午9:56 + * To change this template use File | Settings | File Templates. + */ +public class ConfigInfo { + public static JSONObject configObject = new JSONObject(); + + public static JSONObject jsCodeMap = new JSONObject(); + + public static String htmlStr = ""; + + public static String configInfoPath = null; + + public static void getConfigInfo(){ + String context = null; + try { + context = FileManger.readTxt(configInfoPath); + System.out.println(context); + configObject = JSONObject.fromObject(context); + } catch (IOException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + public static void resetJSCodeMap(){ + jsCodeMap = new JSONObject(); + JSONArray configArray = configObject.getJSONArray("configInfo"); + for(int i=0;i + * + * This method is called when a form has its tag value method equals to get. + * + * @param request the request send by the client to the server + * @param response the response send by the server to the client + * @throws javax.servlet.ServletException if an error occurred + * @throws IOException if an error occurred + */ + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + this.doRequest(request, response); + } + + /** + * The doPost method of the servlet.
+ * + * This method is called when a form has its tag value method equals to post. + * + * @param request the request send by the client to the server + * @param response the response send by the server to the client + * @throws ServletException if an error occurred + * @throws IOException if an error occurred + */ + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + this.doRequest(request, response); + } + + public void doRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { + String id = request.getParameter("id"); + String value = request.getParameter("value"); + String m = request.getParameter("m"); + String result = null; + + if(id!=null&&value!=null){ + String optionStr = request.getParameter("option"); + JSONObject option = null; + if(optionStr!=null){ + option = JSONObject.fromObject(optionStr); + } + this.modifyConfig(id,value,option); + result = "succed"; + } + else if(m!=null&&m.equals("createPage")){ + this.createPage(); + //result = "{\"src\":\"\"}" + } + if(result!=null){ + PrintWriter out = response.getWriter(); + out.print(result); + out.flush(); + out.close(); + } + } + + public void destroy() { + super.destroy(); // Just puts "destroy" string in log + // Put your code here + } + + public void getTempLate(){ + String templateName = "template1.html"; + JSONArray configInfo1 = ConfigInfo.configObject.getJSONArray("configInfo"); + for(int i=0;i + * + * @throws ServletException if an error occurs + */ + public void init() throws ServletException { + + } + + public void contextInitialized(ServletContextEvent sce){ + String rootpath = sce.getServletContext().getRealPath("/"); + + templatePath = sce.getServletContext().getInitParameter("templatePath"); + templatePath = rootpath+templatePath; + + demoPath = sce.getServletContext().getInitParameter("demopath"); + demoPath = rootpath+demoPath; + + String configInfoPath = sce.getServletContext().getInitParameter("configinfopath"); + ConfigInfo.configInfoPath = rootpath+configInfoPath; + ConfigInfo.getConfigInfo(); + ConfigInfo.resetJSCodeMap(); + + getTempLate(); + modiyDomeHtml(); + } + + public void contextDestroyed(ServletContextEvent sce) { + + } + + public void modiyDomeHtml(){ + String template1 = this.template; + + for(Iterator ite = ConfigInfo.jsCodeMap.entrySet().iterator(); ite.hasNext();){ + Map.Entry entry = (Map.Entry) ite.next(); + String id1 = (String) entry.getKey(); + JSONObject codeObj = (JSONObject) entry.getValue(); + String code = codeObj.getString("code"); + String defaultValue = codeObj.getString("defaultValue"); + + if(codeObj.has("options")){ + JSONObject options = codeObj.getJSONObject("options"); + String optionsStr = options.toString(); + code = code.replaceAll("\\$options",optionsStr); + } + else{ + code = code.replaceAll("\\$options","null"); + } + + code = code.replaceAll("\\$key",defaultValue); + template1 = template1.replaceAll("\\{_"+id1+"_\\}", code); + } + + ConfigInfo.htmlStr = template1; + } + + public void createPage(){ + FileManger.writeTxt(this.demoPath,ConfigInfo.htmlStr); + } + + public void modifyConfig(String id,String value,JSONObject option){ + ConfigInfo.modifyConfig(id,value,option); + getTempLate(); + modiyDomeHtml(); + //ConfigInfo.resetJSCodeMap(); + ConfigInfo.saveCurConfig(); + } +} diff --git a/WEB-INF/src/com/bev/Upload.java b/WEB-INF/src/com/bev/Upload.java new file mode 100644 index 0000000..56584a8 --- /dev/null +++ b/WEB-INF/src/com/bev/Upload.java @@ -0,0 +1,148 @@ +package com.bev; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Iterator; +import java.util.List; +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; + +@SuppressWarnings("serial") +public class Upload extends HttpServlet implements ServletContextListener { + private static String uploadPath = null; // 上传文件的目录 + private static Map uploadPathsMap = null; + private static String tempPath = null; // 临时文件目录 + File tempPathFile; + + @SuppressWarnings("unchecked") + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + String result = "{\"success\":true}"; + try { + // Create a factory for disk-based file items + DiskFileItemFactory factory = new DiskFileItemFactory(); + String s_fileName = new String(request.getParameter("name").getBytes("iso-8859-1"),"utf-8"); + StringBuilder sb_fileName=new StringBuilder(s_fileName); + String fileLocation=setLocationByFileName(sb_fileName); + String fileName=sb_fileName.toString(); + if(fileName.equals("")) + { + fileName=null; + result = "{\"success\":true}"; + } + setUploadPathBylocation(fileLocation); + initServlet(); +// String format = request.getParameter("format"); + // Set factory constraints + factory.setSizeThreshold(1048576); // 设置缓冲区大小,这里是1MB + factory.setRepository(tempPathFile);// 设置缓冲区目录 + + // Create a new file upload handler + ServletFileUpload upload = new ServletFileUpload(factory); + + // Set overall request size constraint + upload.setSizeMax(10485760); // 设置最大文件尺寸,这里是10MB + + List items = upload.parseRequest(request);// 得到所有的文件 + Iterator i = items.iterator(); + while (i.hasNext()) { + FileItem fi = (FileItem) i.next(); + //long size = fi.getSize(); + String fileName1 = fi.getName(); + if (fileName!=null&&fileName1!=null) { + //File fullFile = new File(fi.getName()); + //File savedFile = new File(uploadPath, fullFile.getName()); + File savedFile = new File(uploadPath, fileName); + fi.write(savedFile); + } + else{ + System.out.print("upload failed"); + result = "{\"success\":false}"; + break; + } + } + + } catch (Exception e) { + // 可以跳转出错页面 + e.printStackTrace(); + result = "{\"success\":false}"; + } + if(result!=null){ + PrintWriter out = response.getWriter(); + out.print(result); + out.flush(); + out.close(); + } + } + + private void initServlet() throws ServletException { + File uploadFile = new File(uploadPath); + if (!uploadFile.exists()) { + uploadFile.mkdirs(); + } + File tempPathFile = new File(tempPath); + if (!tempPathFile.exists()) { + tempPathFile.mkdirs(); + } + } + + public void contextInitialized(ServletContextEvent sce){ + uploadPathsMap=new HashMap(); + String rootpath = sce.getServletContext().getRealPath("/"); + + tempPath = sce.getServletContext().getInitParameter("tempUploadFilePath"); + tempPath = rootpath+tempPath; + + String imgPath= rootpath+sce.getServletContext().getInitParameter("uploadImgFilePath"); + uploadPathsMap.put("img",imgPath); + + String dataPath=rootpath+sce.getServletContext().getInitParameter("uploadDataFilePath"); + uploadPathsMap.put("data",dataPath); + } + + public void contextDestroyed(ServletContextEvent sce) { + + } + + private void setUploadPathBylocation(String location){ + if(location.equals("img")){ + uploadPath= uploadPathsMap.get("img"); + } + else if(location.equals("data")){ + uploadPath=uploadPathsMap.get("data"); + } + else{ + uploadPath= tempPath; + } + } + + private String setLocationByFileName(StringBuilder sb_fileName){ + String fileName=sb_fileName.toString(); + int dotLocation=fileName.lastIndexOf('.'); + String extend=fileName.substring(dotLocation+1); + + if(extend.equals("jpg")||extend.equals("png")||extend.equals("gif")||extend.equals("tiff")||extend.equals("bmp")){ + sb_fileName.replace(0,fileName.length(),"logo00.png"); + return "img"; + } + else if(extend.equals("rss")||extend.equals("xml")||extend.equals("kml")||extend.equals("json")){ + return "data"; + } + else{ + sb_fileName.replace(0,fileName.length(),""); + } + return ""; + } +} diff --git a/WEB-INF/src/com/bev/dataManager/GetDataServlet.java b/WEB-INF/src/com/bev/dataManager/GetDataServlet.java new file mode 100644 index 0000000..b6635bd --- /dev/null +++ b/WEB-INF/src/com/bev/dataManager/GetDataServlet.java @@ -0,0 +1,117 @@ +package com.bev.dataManager; + +import javax.servlet.ServletException; +//import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import java.io.IOException; +import java.io.PrintWriter; + +import com.bev.util.FileManger; +import org.apache.commons.fileupload.FileItem; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.*; + +/** + * Created with IntelliJ IDEA. + * User: trojan + * Date: 14-2-25 + * Time: 下午5:41 + * To change this template use File | Settings | File Templates. + */ +//@WebServlet(name = "GetDataServlet") +public class GetDataServlet extends HttpServlet implements ServletContextListener { + public static String rootPath=null; + public static String filePath=null; + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws + ServletException, IOException { + + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) throws + ServletException, IOException { + String fileStr=null; + try{ + String fileName=new String(request.getParameter("data").getBytes("iso-8859-1"),"utf-8"); + if(!fileName.equals("")) + { + ArrayList fileNameList=FileManger.getFileList(filePath); + if(fileName.equals("georss")){ + fileStr=getFileNameList("xml",fileNameList); + } + else if(fileName.equals("kml")){ + fileStr=getFileNameList("kml",fileNameList); + } + else if(fileName.equals("json")){ + fileStr=getFileNameList("json",fileNameList); + } + else{ + fileStr=FileManger.readTxt(filePath+"\\"+fileName); + } + } + //System.out.println(fileStr); + if(fileStr.equals("")||fileStr==null){ + fileStr="failed"; + } + } + catch(Exception ex){ + fileStr="failed"; + } + + if(fileStr!=null){ + PrintWriter out = response.getWriter(); + fileStr=new String(fileStr.getBytes("iso-8859-1"),"utf-8"); + out.print(fileStr); + out.flush(); + out.close(); + } + } + + public void contextInitialized(ServletContextEvent sce){ + rootPath = sce.getServletContext().getRealPath("/"); + + filePath = sce.getServletContext().getInitParameter("uploadDataFilePath"); + filePath=rootPath+filePath; + + System.out.println("ex"); + } + + public void contextDestroyed(ServletContextEvent sce) { + + } + + private String getExtend(String fileName){ + int dotLocation=fileName.lastIndexOf('.'); + String extend=fileName.substring(dotLocation+1); + return extend; + } + + private String getFileNameList(String extendType,ArrayList fileNameList){ + String fileStr=""; + String extend=null; + Iterator i = fileNameList.iterator(); + while(i.hasNext()){ + String file=(String)i.next(); + extend=getExtend(file); + if(extend.equals(extendType)){ + if(i.hasNext()) + { + fileStr+='"'+file+"\","; + } + else{ + fileStr+='"'+file+'"'; + } + } + } + fileStr="["+fileStr+"]"; + + return fileStr; + } +} diff --git a/WEB-INF/src/com/bev/util/Commen.java b/WEB-INF/src/com/bev/util/Commen.java new file mode 100644 index 0000000..e3b273c --- /dev/null +++ b/WEB-INF/src/com/bev/util/Commen.java @@ -0,0 +1,74 @@ +/** + * + */ +package com.bev.util; + +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author liuhong + * + */ +public class Commen { + + /** + * + */ + public Commen() { + // TODO Auto-generated constructor stub + } + + public static String join(ArrayList arr,String joinChar){ + String res = ""; + + for(int i=0;i 0) { + path = path.substring(0, path.indexOf("/WEB-INF/") + 1); + } + return path; + } + + public static String replaceBlank(String str) { + String dest = ""; + if (str!=null) { + Pattern p = Pattern.compile("\\s*|\t|\r|\n"); + Matcher m = p.matcher(str); + dest = m.replaceAll(""); + } + return dest; + } + + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/WEB-INF/src/com/bev/util/FileManger.java b/WEB-INF/src/com/bev/util/FileManger.java new file mode 100644 index 0000000..cabbd4b --- /dev/null +++ b/WEB-INF/src/com/bev/util/FileManger.java @@ -0,0 +1,74 @@ +package com.bev.util; + +import java.io.*; +import java.util.ArrayList; + +public class FileManger { + public static String readTxt1(String fileName) throws IOException { + BufferedReader br = new BufferedReader(new FileReader(fileName)); + String str = ""; + String r = br.readLine(); + while (r != null) { + str += r+"\n"; + r = br.readLine(); + } + return str; + } + public static String readTxt(String fileName) throws IOException { + String str = ""; + try { + File f1 = new File(fileName);// 打开文件 + FileInputStream in = new FileInputStream(f1); + // 指定读取文件时以UTF-8的格式读取 + BufferedReader br = new BufferedReader(new InputStreamReader(in, + "UTF-8")); // 读取文件 + String r = br.readLine(); + while (r != null) { + str += r+"\n"; + r = br.readLine(); + } + in.close();// 关闭读取 + } catch (Exception e1) {// 如果有错误,这里进行处理 + e1.printStackTrace();// 打印错误信息 + } + return str; + } + + public static void writeTxt(String path,String content) { + try { + content.replaceAll("\n", "\\n"); + File file = new File(path); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + + if (!file.isFile()) { + file.createNewFile(); + } + + FileWriter fw = null; + + OutputStreamWriter outputStream = new OutputStreamWriter(new FileOutputStream(file),"UTF-8"); + outputStream.write(content); + outputStream.flush(); + outputStream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static ArrayList getFileList(String path){ + ArrayList files = new ArrayList(); + File[] fileList = null; + File directory = new File(path); + if(directory.exists()){ + fileList = directory.listFiles(); + for(int i=0;i + + + + + log4jpath + WEB-INF\log4j.properties + + + templatePath + ./ + + + configinfopath + config\config.json + + + demopath + index.html + + + tempUploadFilePath + demo\temp + + + uploadImgFilePath + demo\img + + + uploadDataFilePath + demo\data + + + com.bev.PageConfig + + + com.bev.Upload + + + com.bev.dataManager.GetDataServlet + + + This is the description of my J2EE component + This is the display name of my J2EE component + config + com.bev.PageConfig + + + config + /config + + + upload + com.bev.Upload + + + upload + /fileupload + + + getData + com.bev.dataManager.GetDataServlet + + + getData + /getdata + + + index.html + welcome.html + + diff --git a/base/base.html b/base/base.html deleted file mode 100644 index a19a935..0000000 --- a/base/base.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - -
- -
- - - \ No newline at end of file diff --git a/js/jquery-1.8.2.js b/common/js/jquery.js similarity index 100% rename from js/jquery-1.8.2.js rename to common/js/jquery.js diff --git a/config.jsp b/config.jsp new file mode 100644 index 0000000..7abfbc6 --- /dev/null +++ b/config.jsp @@ -0,0 +1,76 @@ +<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> +<%@ page language="java" import="net.sf.json.JSONArray"%> +<%@ page language="java" import="net.sf.json.JSONObject"%> +<%@ page language="java" import="com.bev.ConfigInfo"%> +<% + JSONObject configObject = null; + String configObjectStr = null; + try{ + //configInfo = (String) request.getAttribute("configInfo"); + //configObj = JSONObject.fromObject(configInfo); + configObject = ConfigInfo.configObject; + configObjectStr = configObject.toString(); + } + catch (Exception e){ + System.out.println(e.getMessage()); + } + //String configInfo1 = configInfo.replaceAll("\"","\\\""); +%> + + + + + + SuperMap JavaScrpt Bev + + + + + + + +
+
+ +
+ + + \ No newline at end of file diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..7b6d443 --- /dev/null +++ b/config/config.json @@ -0,0 +1,439 @@ +{ + "configInfo":[ + { + "category":"选择模板", + "contents":[ + { + "type":"select", + "id":"templateSelect", + "title":null, + "jsCode":"", + "defaultValue":0, + "nameValues":[ + { + "name":"模板一", + "value":"template1.html" + }, + { + "name":"模板二", + "value":"template2.html" + }, + { + "name":"模板三", + "value":"template3.html" + } + ] + } + ] + }, + { + "category":"选择主题", + "contents":[ + { + "type":"select", + "id":"themeSelect", + "title":null, + "jsCode":"Bev.Theme.set(\"$key\");", + "defaultValue":1, + "nameValues":[ + { + "name":"蔚蓝", + "value":"bev-cupertino" + }, + { + "name":"经典", + "value":"bev-base" + }, + { + "name":"乌黑", + "value":"bev-black-tie" + } + ] + } + ] + }, + { + "category":"设置LOGO", + "contents":[ + { + "type":"checkbox_fileupload", + "id":"logoImageUpload", + "title":"设置LOGO图片:", + "jsCode":"setLogoImg(\"$key\")", + "defaultValue":"1,logo.png" + }, + { + "type":"checkbox_textArea", + "id":"logoTitle", + "title":"设置LOGO标题:", + "jsCode":"setLogoTitle(\"$key\")", + "defaultValue":"1,JavaScript Bev" + }, + ] + }, + { + "category":"设置地图参数", + "contents":[ + { + "type":"select", + "id":"mapServiceSelect", + "title":"选择基础底图服务:", + "jsCode":"createMap(\"$key\",$options);", + "defaultValue":1, + "nameValues":[ + { + "name":"SuperMap云服务", + "value":"supermapCloud" + }, + { + "name":"SuperMap iServer Java 6R服务", + "value":"iserver", + "options":[ + { + "type":"textArea", + "id":"url", + "title":"url:", + "defaultValue":"http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World" + }, + { + "type":"textArea", + "id":"layerName", + "title":"LayerName:", + "defaultValue":"World" + } + ] + }, + { + "name":"OpenStreet Map", + "value":"osm" + }, + { + "name":"天地图", + "value":"tianditu" + }, + { + "name":"ArcGis Online", + "value":"arcgis" + }, + { + "name":"百度地图", + "value":"baidu" + }, + { + "name":"Bing 地图", + "value":"bing" + }, + { + "name":"WMTS地图", + "value":"wmts", + "options":[ + { + "type":"textArea", + "id":"url", + "title":"URL:", + "defaultValue":"http://support.supermap.com.cn:8090/iserver/services/map-world/wmts100" + }, + { + "type":"textArea", + "id":"wmtsLayerName", + "title":"Name:", + "defaultValue":"World" + }, + { + "type":"textArea", + "id":"wmtsMatrixSet", + "title":"MatrixSet:", + "defaultValue":"GlobalCRS84Scale_World" + }, + { + "type":"select", + "id":"wmtsFormat", + "title":"Format:", + "defaultValue":"0", + "nameValues":[ + { + "name":"PNG", + "value":"image/png" + } + ] + }, + { + "type":"select", + "id":"resolution", + "title":"Resolution:", + "defaultValue":"0", + "nameValues":[ + { + "name":"GlobalCRS84Scale", + "value":"1.25764139776733,0.628820698883665,0.251528279553466,0.125764139776733,0.0628820698883665,0.0251528279553466,0.0125764139776733,0.00628820698883665,0.00251528279553466,0.00125764139776733,0.000628820698883665,0.000251528279553466,0.000125764139776733,0.0000628820698883665,0.0000251528279553466,0.0000125764139776733,0.00000628820698883665,0.00000251528279553466,0.00000125764139776733,0.000000628820698883665,0.00000025152827955346" + } + ] + }, + { + "type":"select", + "id":"requestEncoding", + "title":"requestEncoding:", + "defaultValue":"0", + "nameValues":[ + { + "name":"KVP", + "value":"KVP" + }, + { + "name":"SOAP", + "value":"SOAP" + }, + { + "name":"REST", + "value":"REST" + } + ] + } + ] + } + ] + }, + { + "type":"add_select", + "id":"overlayMapServerice", + "title":"添加业务图层服务:", + "jsCode":"$key", + "defaultValue":"[]", + "nameValues":[ + { + "name":"SuperMap iServer Java 6R服务", + "value":"iserver", + "options":[ + { + "type":"textArea", + "id":"url", + "title":"url:", + "defaultValue":"http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World" + }, + { + "type":"textArea", + "id":"layerName", + "title":"LayerName:", + "defaultValue":"LayerName" + } + ] + }, + { + "name":"WMTS地图", + "value":"wmts", + "options":[ + { + "type":"textArea", + "id":"title", + "title":"Name:", + "defaultValue":"wmsLayerName" + }, + { + "type":"textArea", + "id":"url", + "title":"URL:", + "defaultValue":"http://support.supermap.com.cn:8090/iserver/services/map-world/wmts100" + }, + { + "type":"textArea", + "id":"layer", + "title":"layer:", + "defaultValue":"World" + }, + { + "type":"textArea", + "id":"wmtsMatrixSet", + "title":"MatrixSet:", + "defaultValue":"GlobalCRS84Scale_World" + }, + { + "type":"select", + "id":"wmtsFormat", + "title":"Format:", + "defaultValue":"0", + "nameValues":[ + { + "name":"PNG", + "value":"image/png" + } + ] + }, + { + "type":"select", + "id":"resolution", + "title":"Resolution:", + "defaultValue":"0", + "nameValues":[ + { + "name":"GlobalCRS84Scale", + "value":"1.25764139776733,0.628820698883665,0.251528279553466,0.125764139776733,0.0628820698883665,0.0251528279553466,0.0125764139776733,0.00628820698883665,0.00251528279553466,0.00125764139776733,0.000628820698883665,0.000251528279553466,0.000125764139776733,0.0000628820698883665,0.0000251528279553466,0.0000125764139776733,0.00000628820698883665,0.00000251528279553466,0.00000125764139776733,0.000000628820698883665,0.00000025152827955346" + } + ] + }, + { + "type":"select", + "id":"requestEncoding", + "title":"requestEncoding:", + "defaultValue":"0", + "nameValues":[ + { + "name":"KVP", + "value":"KVP" + }, + { + "name":"SOAP", + "value":"SOAP" + }, + { + "name":"REST", + "value":"REST" + } + ] + } + ] + } + ] + }, + { + "type":"fileupload", + "id":"dataUpload", + "title":"上传数据文件:", + "jsCode":"", + "defaultValue":"georss.xml" + }, + { + "type":"disableTextArea", + "id":"longitude", + "title":"经度:", + "jsCode":"$key", + "defaultValue":0, + "key":"centerLon" + }, + { + "type":"disableTextArea", + "id":"latitude", + "title":"纬度:", + "jsCode":"$key", + "defaultValue":0, + "key":"centerLat" + }, + { + "type":"disableTextArea", + "id":"zoomLevel", + "title":"地图级别:", + "jsCode":"$key", + "defaultValue":1, + "key":"zoom" + }, + { + "type":"checkboxList", + "id":"mapControls", + "title":"选择地图控件:", + "jsCode":"$key", + "defaultValue":"1,2,3,4", + "list":[ + { + "title":"缩放控件", + "key":1 + }, + { + "title":"比例尺", + "key":2 + }, + { + "title":"导航控件", + "key":3 + }, + { + "title":"鹰眼", + "key":4 + }, + { + "title":"图层管理器", + "key":5 + } + ] + } + ] + }, + { + "category":"选择功能控件", + "contents":[ + { + "type":"checkbox", + "id":"measureControl", + "title":"量算控件", + "jsCode":"addMeasure($key);", + "defaultValue":1 + }, + { + "type":"checkbox", + "id":"geolocateControl", + "title":"定位控件", + "jsCode":"addGeolocate($key);", + "defaultValue":1 + }, + { + "type":"checkbox", + "id":"drawControl", + "title":"绘制控件", + "jsCode":"addDraw($key);", + "defaultValue":1 + }, + { + "type":"checkbox", + "id":"loadJSON", + "title":"JSON控件", + "jsCode":"addJSON($key);", + "defaultValue":1 + } + ] + }, + { + "category":"REST服务", + "contents":[ + { + "type":"configWindow", + "id":"queryControl", + "title":"查询控件", + "jsCode":"addQueryControl($key,$options);", + "defaultValue":1, + "options":[ + { + "type":"textArea", + "id":"url", + "title":"URL:", + "defaultValue":"http://support.supermap.com.cn:8090/iserver/services/map-world/rest/maps/World" + }, + { + "type":"textArea", + "id":"datasetName", + "title":"数据集名称:", + "defaultValue":"Capitals@World" + }, + { + "type":"textArea", + "id":"queryField", + "title":"查询字段:", + "defaultValue":"CAPITAL" + }, + { + "type":"textArea", + "id":"resultTableFields", + "title":"查询结果所要显示的字段:", + "defaultValue":"", + "info":"用逗号隔开,例如:SMID,NAME,AGE;如果为空,则显示所有字段。" + }, + { + "type":"textArea", + "id":"resultTableColumnTitles", + "title":"查询结果表格中的列标题:", + "defaultValue":"", + "info":"用逗号隔开,例如:ID,名称,年龄;如果为空,则使用字段名称。" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/config/css/style.css b/config/css/style.css new file mode 100644 index 0000000..d18e7c0 --- /dev/null +++ b/config/css/style.css @@ -0,0 +1,28 @@ +body{ + position: absolute; + margin: 0px; + padding: 0px; + height: 100%; + width:100%; + overflow: hidden; +} +body { + font-size: 62.5%; + font-family: "Trebuchet MS", "Arial", "Helvetica", "Verdana", "sans-serif"; +} +#toolbar{ + position: absolute; + width:260px; + height: 100%; + /*border:1px solid #f00;*/ + z-index: 5; + /*background: #0f0;*/ +} +#map{ + position: absolute; + /*width: 100%;*/ + height: 100%; + left:260px; + /*background: #00f;*/ + /*border:1px solid #0f0;*/ +} \ No newline at end of file diff --git a/images/init/home_banner.jpg b/config/img/home_banner.jpg similarity index 100% rename from images/init/home_banner.jpg rename to config/img/home_banner.jpg diff --git a/images/init/home_banner2.png b/config/img/home_banner2.png similarity index 100% rename from images/init/home_banner2.png rename to config/img/home_banner2.png diff --git a/images/init/logo.png b/config/img/logo.png similarity index 100% rename from images/init/logo.png rename to config/img/logo.png diff --git a/config/js/ConfigTool.js b/config/js/ConfigTool.js new file mode 100644 index 0000000..cf3cfb4 --- /dev/null +++ b/config/js/ConfigTool.js @@ -0,0 +1,1110 @@ +/** + * Class: Bev.ConfigTool + * 配置面板。 + */ +Bev.ConfigTool = Bev.Class({ + configObject:null, + div:null, + onload:function(){}, + _mapFrame:null, + _keyupTimeoutId:null, + _eventMap:{}, + _mapLoaded:false, + _body:null, + /** + * Constructor: Bev.ConfigTool + * 实例化 ConfigTool 类。 + */ + initialize: function(options) { + var t = this; + for(var key in options){ + this[key] = options[key]; + } + this._mapFrame = document.getElementById("mapFrame"); + Bev.loader.js("config/js/Select.js",function(){ + t.create(); + t.onload(); + }); + }, + + create:function(){ + var t = this; + if(!this.div){ + this.div = $("
"); + } + this._body = $("
") + .appendTo(this.div) + .css({ + "overflow":"auto", + "position":"absolute", + "height":"100%", + "width":"100%" + }); + var ca = this.configObject; + if(ca){ + var dv = $("
").appendTo(this._body); + var myAccordion = new Bev.Accordion({ + body:dv, + isRoundedCorner:false + }); + var categoryArr = ca.configInfo; + for(var i=0;i"); + var contents = categoryObj.contents; + for(var j=0;j") + .css({ + "padding":"5px", + "text-align":"right" + }) + .prependTo(this._body); + + var btn = $("") + .attr("href","#") + .html("生成页面>>") + .css({ + "text-decoration":"underline", + "color":"#999999", + "cursor":"pointer" + }) + .click(function(){ + t.createPage(); + }) + .appendTo(d1); + } + }, + + createPage:function(){ + var t = this; + var url = "config?m=createPage"; + t.request(url,function(){ + window.location = "index.html"; + }); + }, + + createConfigWindowBtn:function(obj,div1){ + var t = this; + + var div = $("
") + .css({ + "margin":"10px 0px 0px 0px" + }) + .appendTo(div1); + + var checkbox = $("") + .attr({ + "type":"checkbox" + }) + .click(function(obj){ + return function(){ + if($(this).attr("checked")=="checked"){ + obj.defaultValue = 1; + } + else{ + obj.defaultValue = 0; + } + + request(); + } + }(obj)) + .appendTo(div); + + if(obj.defaultValue+"" == "1"){ + checkbox.attr({ + "checked":"checked" + }); + } + + var sp = $("") + .html(obj.title) + .appendTo(div); + + var infoWinBtn = $("") + .bevbutton({ + icons:{ + primary:"glyphicon-plus" + } + }) + .css({ + "height":" 30px", + "margin":"10px 0px 0px 0px" + }) + .click(function(){ + defaultValue1.push(t.cloneObject(curOption)); + createList(defaultValue1,tableDiv); + + obj.defaultValue = defaultValue1; + }) + .appendTo($("
").appendTo(contentBody)); + + tableDiv.appendTo(contentBody); + + var defaultValue = obj.defaultValue; + if(defaultValue&&defaultValue!="null"&&defaultValue!=""){ + defaultValue1 = eval(defaultValue); + + createList(defaultValue1,tableDiv); + } + } + + function createOptionsDom(obj,paramDiv,curOption){ + var options = obj.options; + curOption.type = obj.value; + curOption.typeName = obj.name; + if(options&&options.length){ + for(var i=0;i0){ + var table = $("").appendTo(tableDiv); + for(var i=0;i").appendTo(table); + var css = {"border":"1px solid #333","margin":"0px"}; + $("
").css(css).html(i+1).appendTo(tr); + $("").css(css).html(type).appendTo(tr); + $("").css(css).html(title).appendTo(tr); + + createBtn("glyphicon-minus",function(i){ + return function(){ + defaultValue1.splice(i,1); + createList(defaultValue1,tableDiv); + } + }(i),tr); + + if(i!=defaultValue1.length-1){ + createBtn("glyphicon-chevron-down",function(i){ + return function(){ + var tp = defaultValue1.splice(i,1); + tp = tp[0]; + defaultValue1.splice(i+1,0,tp); + createList(defaultValue1,tableDiv); + } + }(i),tr); + } + + if(i!=0){ + createBtn("glyphicon-chevron-up",function(i){ + return function(){ + var tp = defaultValue1.splice(i,1); + tp = tp[0]; + defaultValue1.splice(i-1,0,tp); + createList(defaultValue1,tableDiv); + } + }(i),tr); + } + } + } + function createBtn(classN,click,tr){ + var minusBtn = $("").appendTo(tr)); + + minusBtn.children("span").css("left","2px"); + } + } + }, + + createSelect:function(obj,onselect){ + var t = this; + //var options = obj.options; + var nameValues = obj.nameValues; + var id = obj.id; + var title = obj.title; + var mySelect; + + mySelect = new Bev.Select({ + nameValues:nameValues, + defaultValue:obj.defaultValue, + title:title, + onSelect:function(id){ + if(onselect){ + return onselect; + } + return function(value){ + var index = parseInt(value); + + var obj = nameValues[index]; + if(obj.options){ + mySelect.infoWinBtn.css({ + "display":"inline" + }); + mySelect.infoWinBtn.dialogParam = { + "obj":obj, + "id":id, + "value":value + }; + t.createDialog(obj,$("body"),id,value); + } + else{ + mySelect.infoWinBtn.css({ + "display":"none" + }); + try{if(Bev.configDialog)Bev.configDialog.destroy();}catch(e){}; + } + var url = "config?id="+id+"&value="+value; + t.request(url,function(){ + t.redrawMapFrame(); + }); + } + }(id) + }); + + mySelect.infoWinBtn = $("