null
if not found.
193 | */
194 | private Image getImage(boolean isSelected) {
195 | String key = isSelected ? CHECKED_IMAGE : UNCHECKED_IMAGE;
196 | return imageRegistry.get(key);
197 | }
198 |
199 | /*
200 | * (non-Javadoc)
201 | *
202 | * @see
203 | * org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang
204 | * .Object, int)
205 | */
206 | public Image getColumnImage(Object element, int columnIndex) {
207 | ColumnModel col = (ColumnModel) element;
208 |
209 | Image result = null;
210 |
211 | switch (columnIndex) {
212 | case 3:
213 | result = getImage("Y".equalsIgnoreCase(col.getIsParamKey()));
214 | break;
215 | case 4:
216 | result = getImage("Y".equalsIgnoreCase(col.getIsList()));
217 | break;
218 | case 5:
219 | result = getImage("Y".equalsIgnoreCase(col.getIsQuery()));
220 | break;
221 | case 6:
222 | result = getImage("Y".equalsIgnoreCase(col.getIsEdit()));
223 | break;
224 | default:
225 | break;
226 | }
227 | return result;
228 | }
229 |
230 | public String getColumnText(Object element, int columnIndex) {
231 | String result = "";
232 | ColumnModel col = (ColumnModel) element;
233 | switch (columnIndex) {
234 | case 0:
235 | result = col.getColumnName();
236 | break;
237 | case 1:
238 | result = col.getJavaName();
239 | break;
240 | case 2:
241 | result = col.getComment() == null ? "" : col.getComment();
242 | break;
243 | case 7:
244 | result = col.getDictKey();
245 | break;
246 | default:
247 | break;
248 | }
249 | return result;
250 | }
251 |
252 | }
253 |
254 | class ColumnCellModifier implements ICellModifier {
255 | PageThree pageThree;
256 | List columnNames;
257 |
258 | public ColumnCellModifier(PageThree pageThree, String[] columnNames) {
259 | this.pageThree = pageThree;
260 | this.columnNames = Arrays.asList(columnNames);
261 | }
262 |
263 | public boolean canModify(Object element, String property) {
264 | return true;
265 | }
266 |
267 | public Object getValue(Object element, String property) {
268 | int columnIndex = columnNames.indexOf(property);
269 |
270 | Object result = null;
271 |
272 | ColumnModel col = (ColumnModel) element;
273 | switch (columnIndex) {
274 | case 0:
275 | result = col.getColumnName();
276 | break;
277 | case 1:
278 | result = col.getJavaName();
279 | break;
280 | case 2:
281 | result = col.getComment();
282 | break;
283 | case 3:
284 | result = new Boolean(!"Y".equals(col.getIsParamKey()));
285 | break;
286 | case 4:
287 | result = new Boolean(!"Y".equals(col.getIsList()));
288 | break;
289 | case 5:
290 | result = new Boolean(!"Y".equals(col.getIsQuery()));
291 | break;
292 | case 6:
293 | result = new Boolean(!"Y".equals(col.getIsEdit()));
294 | break;
295 | case 7:
296 | result = col.getDictKey();
297 | break;
298 | default:
299 | result = "";
300 | }
301 | return result;
302 | }
303 |
304 | public void modify(Object element, String property, Object value) {
305 | int columnIndex = columnNames.indexOf(property);
306 | TableItem item = (TableItem) element;
307 | ColumnModel col = (ColumnModel)item.getData();
308 | switch (columnIndex) {
309 | case 0:
310 | col.setColumnName(StringUtils.trim((String)value));
311 | break;
312 | case 1:
313 | col.setJavaName(StringUtils.trim((String)value));
314 | break;
315 | case 2:
316 | col.setComment(StringUtils.trim((String)value));
317 | break;
318 | case 3:
319 | col.setIsParamKey(((Boolean) value).booleanValue()?"N":"Y");
320 | break;
321 | case 4:
322 | col.setIsList(((Boolean) value).booleanValue()?"N":"Y");
323 | break;
324 | case 5:
325 | col.setIsQuery(((Boolean) value).booleanValue()?"N":"Y");
326 | break;
327 | case 6:
328 | col.setIsEdit(((Boolean) value).booleanValue()?"N":"Y");
329 | break;
330 | case 7:
331 | col.setDictKey(StringUtils.trim((String)value));
332 | break;
333 | default:
334 | //result = "";
335 | }
336 |
337 | this.pageThree.getTableViewer().update(col, null);
338 | }
339 |
340 | }
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/crud/StartCurdWizard.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.crud;
2 |
3 | import java.io.File;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import org.eclipse.jface.wizard.Wizard;
8 |
9 | import com.thinkgem.jeesite.autocode.model.ColumnModel;
10 | import com.thinkgem.jeesite.autocode.model.TableConfigModel;
11 | import com.thinkgem.jeesite.autocode.model.TableModel;
12 | import com.thinkgem.jeesite.autocode.util.FreeMakerUtils;
13 | import com.thinkgem.jeesite.autocode.util.StringUtils;
14 | import com.thinkgem.jeesite.autocode.util.XmlObjectCrud;
15 | import com.thinkgem.jeesite.autocode.util.XmlObjectUtils;
16 |
17 | import freemarker.template.Configuration;
18 |
19 | public class StartCurdWizard extends Wizard {
20 | //所有全局变量防止在这里
21 |
22 | TableModel tableModel = new TableModel();
23 |
24 | public StartCurdWizard() {
25 | setWindowTitle("树状机构生成");
26 | setHelpAvailable(false);
27 | setNeedsProgressMonitor(false);
28 | }
29 |
30 | @Override
31 | public void addPages() {
32 | addPage(new PageOne());
33 | addPage(new PageTwo());
34 | addPage(new PageThree());
35 |
36 | //设置上一次操作的路径
37 | TableConfigModel fileconfig = (TableConfigModel)XmlObjectUtils.objectXmlDecoder(XmlObjectCrud.getLeastTable());
38 | if(fileconfig!=null){
39 | PageTwo pageTwo = (PageTwo)super.getPage("PageTwo");
40 | TableConfigModel pttable = pageTwo.getTableConfig();
41 | pttable.setAuthor(fileconfig.getAuthor());
42 | pttable.setVersion(fileconfig.getVersion());
43 | pttable.setTopPackage(fileconfig.getTopPackage());
44 | pttable.setFilePath(fileconfig.getFilePath());
45 | pttable.setJspLocation(fileconfig.getJspLocation());
46 | pttable.setFunctionNameCn(fileconfig.getFunctionNameCn());
47 | pttable.setFunctionNameEn(fileconfig.getFunctionNameEn());
48 | pttable.setUrlPrefix(fileconfig.getUrlPrefix());
49 | pttable.setPermissionPrefix(fileconfig.getPermissionPrefix());
50 | }
51 | }
52 |
53 | @Override
54 | public boolean performFinish() {
55 | PageTwo pageTwo = (PageTwo)super.getPage("PageTwo");
56 | pageTwo.checkInput();
57 |
58 | TableConfigModel tableconfig = pageTwo.getTableConfig();
59 | PageThree pageThree = (PageThree)super.getPage("PageThree");
60 | XmlObjectUtils.objectXmlEncoder(pageThree.getColumnList(), XmlObjectCrud.getLeastColumns());
61 | XmlObjectUtils.objectXmlEncoder(tableconfig,XmlObjectCrud.getLeastTable());
62 | //设置主键字段
63 | for(ColumnModel column:pageThree.getColumnList()){
64 | if(column.isKey()){
65 | tableconfig.setKey(column);
66 | break;
67 | }
68 | }
69 | Map data = new HashMap();
70 | data.put("columnList", pageThree.getColumnList());
71 | data.put("table", tableconfig);
72 |
73 |
74 | String separator = File.separator;
75 | String basePath = pageTwo.getTableConfig().getFilePath();
76 |
77 | //生成文件
78 | Configuration freemakerCfg = FreeMakerUtils.getFreeMarkerCfg(this.getClass(), "template");
79 | //Configuration freemakerCfg = FreeMakerUtils.getFreeMarkerCfg(XmlObjectCrud.getFtlPath());
80 | FreeMakerUtils.generateFile(freemakerCfg, "entity.ftl", data, "src\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\entity\\", StringUtils.capitalize(tableconfig.getTableJavaName()) +".java", basePath);
81 | FreeMakerUtils.generateFile(freemakerCfg,"hbm.ftl",data,"src\\config\\hibernate\\",StringUtils.capitalize(tableconfig.getTableJavaName())+".hbm.xml",basePath);
82 | FreeMakerUtils.generateFile(freemakerCfg,"struts.ftl",data,"src\\config\\struts\\warehouse\\","tmp.xml",basePath);
83 | FreeMakerUtils.generateFile(freemakerCfg, "action.ftl", data, "src\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\web\\", StringUtils.capitalize(tableconfig.getFunctionNameEn()) +"Action.java", basePath);
84 | FreeMakerUtils.generateFile(freemakerCfg, "service.ftl", data, "src\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\services\\", StringUtils.capitalize(tableconfig.getFunctionNameEn()) +"Service.java", basePath);
85 | FreeMakerUtils.generateFile(freemakerCfg, "serviceImpl.ftl", data, "src\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\services\\impl\\", StringUtils.capitalize(tableconfig.getFunctionNameEn()) +"ServiceImpl.java", basePath);
86 | FreeMakerUtils.generateFile(freemakerCfg, "qry.ftl", data, "src\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\qry\\", StringUtils.capitalize(tableconfig.getFunctionNameEn()) +"Qry.java", basePath);
87 |
88 | FreeMakerUtils.generateFile(freemakerCfg, "list.ftl", data, "WebRoot\\"+StringUtils.replace(tableconfig.getJspLocation(), "/", "\\"), "list.jsp", basePath);
89 | FreeMakerUtils.generateFile(freemakerCfg, "edit.ftl", data, "WebRoot\\"+StringUtils.replace(tableconfig.getJspLocation(), "/", "\\"), "edit.jsp", basePath);
90 | FreeMakerUtils.generateFile(freemakerCfg, "view.ftl", data, "WebRoot\\"+StringUtils.replace(tableconfig.getJspLocation(), "/", "\\"), "view.jsp", basePath);
91 |
92 |
93 | //MessageDialog.openInformation(super.getShell(), "代码生成成功", "代码生成成功,生成代码存放路径:"+tableconfig.getFilePath());
94 | return false;
95 | }
96 |
97 |
98 |
99 | public void setTableModel(String name,String comment){
100 | tableModel.setName(name);
101 | tableModel.setComment(comment);
102 | }
103 |
104 | public TableModel getTableModel() {
105 | return tableModel;
106 | }
107 |
108 | @Override
109 | public boolean canFinish() {
110 | if("PageThree".equals(super.getContainer().getCurrentPage().getName())){
111 | return true;
112 | }else{
113 | return false;
114 | }
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/crud/template/action.ftl:
--------------------------------------------------------------------------------
1 | package ${table.topPackage}.web;
2 |
3 | import java.util.Date;
4 |
5 | import org.apache.commons.lang.StringUtils;
6 |
7 | import com.calf.framework.util.Constants;
8 | import com.calf.framework.util.ObjectUtils;
9 | import com.calf.framework.vo.AdminUserInfo;
10 | import com.calf.framework.vo.Page;
11 | import ${table.topPackage}.entity.${table.tableJavaName?cap_first};
12 | import ${table.topPackage}.qry.${table.functionNameEn?cap_first}Qry;
13 | import ${table.topPackage}.services.${table.functionNameEn?cap_first}Service;
14 | import com.calf.framework.web.BaseAction;
15 | import com.calf.framework.web.util.RequiresPermissions;
16 |
17 |
18 | public class ${table.functionNameEn?cap_first}Action extends BaseAction {
19 |
20 | ${table.functionNameEn?cap_first}Service ${table.functionNameEn}Service;
21 |
22 | ${table.functionNameEn?cap_first}Qry qry;
23 |
24 | Page page;
25 |
26 | ${table.tableJavaName?cap_first} entity;
27 |
28 | /**
29 | * 列表
30 | */
31 | @RequiresPermissions(value = "${table.permissionPrefix}:view",requiresUser=true)
32 | public String list() throws Exception{
33 | AdminUserInfo userInfo = super.getUserInfo();
34 | if(StringUtils.isNotBlank(super.qryHex)){
35 | qry = (${table.functionNameEn?cap_first}Qry)ObjectUtils.getObjectFromHex(qryHex);
36 | }
37 | if(qry==null){
38 | qry = new ${table.functionNameEn?cap_first}Qry();
39 | qry.setOrderCol("createDate");
40 | qry.setOrderType(Constants.DESC);
41 | }
42 |
43 | //设置默认排序号
44 | if(StringUtils.isBlank(qry.getOrderCol())){
45 | qry.setOrderCol("createDate");
46 | qry.setOrderType(Constants.DESC);
47 | }
48 |
49 | qry.setUserInfo(userInfo);
50 | page = ${table.functionNameEn}Service.find${table.functionNameEn?cap_first}Page(qry);
51 | return "list";
52 | }
53 | /**
54 | * 新增
55 | **/
56 | @RequiresPermissions(value = "${table.permissionPrefix}:edit",requiresUser=true)
57 | public String toAdd() throws Exception{
58 | AdminUserInfo userInfo = super.getUserInfo();
59 | entity = new ${table.tableJavaName?cap_first}();
60 | super.event="ADD";
61 | super.title="新增";
62 | return "edit";
63 | }
64 | /**
65 | * 修改
66 | **/
67 | @RequiresPermissions(value = "${table.permissionPrefix}:edit",requiresUser=true)
68 | public String toEdit() throws Exception{
69 | AdminUserInfo userInfo = super.getUserInfo();
70 | entity = ${table.functionNameEn}Service.get(${table.tableJavaName?cap_first}.class,entity.get${table.key.javaName?cap_first}());
71 | super.event="EDIT";
72 | super.title="修改";
73 | return "edit";
74 | }
75 | /**
76 | * 修改动作
77 | **/
78 | @RequiresPermissions(value = "${table.permissionPrefix}:edit",requiresUser=true)
79 | public String edit() throws Exception{
80 | AdminUserInfo userInfo = super.getUserInfo();
81 | if("ADD".equals(super.event)){
82 | //新增操作
83 | entity.set${table.key.javaName?cap_first}(null);
84 | entity.setDataStatus(Constants.YES);
85 | entity.setCreateUser(userInfo.getUserId());
86 | entity.setCreateDate(new Date());
87 | ${table.functionNameEn}Service.save${table.functionNameEn?cap_first}(entity);
88 | super.addAttribute("qry.orderCol", "createDate");
89 | super.addAttribute("qry.orderType", "0");
90 | super.saveMessage("${table.functionNameCn}新增成功");
91 | }else if("EDIT".equals(super.event)){
92 | //修改操作
93 | ${table.tableJavaName?cap_first} db = ${table.functionNameEn}Service.get(${table.tableJavaName?cap_first}.class,entity.get${table.key.javaName?cap_first}());
94 |
95 | <#list columnList as x>
96 | <#if x.isEdit=="Y">
97 | db.set${x.javaName?cap_first}(entity.get${x.javaName?cap_first}());
98 | #if>
99 | #list>
100 |
101 | db.setUpdateUser(userInfo.getUserId());
102 | db.setUpdateDate(new Date());
103 |
104 | ${table.functionNameEn}Service.save${table.functionNameEn?cap_first}(db);
105 | super.saveMessage("${table.functionNameCn}修改保存成功");
106 | super.addAttribute("qryHex", super.qryHex);
107 | }
108 | super.redirectUrl = "${table.urlPrefix}_list.action";
109 | return super.GLOBAL_SUCCESS;
110 | }
111 | /**
112 | * 删除
113 | **/
114 | @RequiresPermissions(value = "${table.permissionPrefix}:edit",requiresUser=true)
115 | public String delete() throws Exception{
116 | AdminUserInfo userInfo = super.getUserInfo();
117 | entity = ${table.functionNameEn}Service.get(${table.tableJavaName?cap_first}.class,entity.get${table.key.javaName?cap_first}());
118 | if(entity.isCanDelete()){
119 | this.${table.functionNameEn}Service.delete${table.functionNameEn?cap_first}(entity);
120 | super.renderJsonSuccess("删除成功!");
121 | }else{
122 | super.renderJsonError("该记录已被删除!");
123 | }
124 | return null;
125 | }
126 |
127 | /**
128 | * 修改
129 | **/
130 | @RequiresPermissions(value = "${table.permissionPrefix}:view",requiresUser=true)
131 | public String toView() throws Exception{
132 | AdminUserInfo userInfo = super.getUserInfo();
133 | entity = ${table.functionNameEn}Service.get(${table.tableJavaName?cap_first}.class,entity.get${table.key.javaName?cap_first}());
134 | super.title="${table.functionNameCn}详细信息";
135 | return "view";
136 | }
137 |
138 | /**
139 | * 判断是否唯一
140 | * @return
141 | */
142 | public String checkUnique()throws Exception{
143 | AdminUserInfo userInfo = super.getUserInfo();
144 | boolean isCorrect = ${table.functionNameEn}Service.isUnique(entity.get${table.key.javaName?cap_first}());
145 | super.rendText(String.valueOf(isCorrect));
146 | return null;
147 | }
148 |
149 | public ${table.functionNameEn?cap_first}Qry getQry(){
150 | return this.qry;
151 | }
152 | public void setQry(${table.functionNameEn?cap_first}Qry qry){
153 | this.qry = qry;
154 | }
155 |
156 | public ${table.functionNameEn?cap_first}Service get${table.functionNameEn?cap_first}Service(){
157 | return this.${table.functionNameEn}Service;
158 | }
159 | public void set${table.functionNameEn?cap_first}Service(${table.functionNameEn?cap_first}Service ${table.functionNameEn}Service){
160 | this.${table.functionNameEn}Service = ${table.functionNameEn}Service;
161 | }
162 | public Page getPage() {
163 | return this.page;
164 | }
165 | public void setPage(Page page) {
166 | this.page = page;
167 | }
168 | public ${table.tableJavaName?cap_first} getEntity(){
169 | return entity;
170 | }
171 | public void setEntity(${table.tableJavaName?cap_first} entity){
172 | this.entity = entity;
173 | }
174 | }
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/crud/template/edit.ftl:
--------------------------------------------------------------------------------
1 | <%@ page language="java" contentType="text/html; charset=utf-8"%>
2 | <%@page import="com.calf.framework.util.CodeNameUtils"%>
3 | <%@ include file="/jsp/include/head.jsp"%>
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | <%@ include file="/jsp/include/basejs.jsp" %>
13 |
22 |
23 |
24 | <#if x.comment??>${x.comment}#if> | 20 |${r"${entity."}${x.javaName}<#if x.javaType=='Double'>Str#if><#if x.javaType=='Date'>Str#if><#if x.dictKey!="">Str#if>${r"}"} | 21 |
26 | |
---|
null
if not found.
193 | */
194 | private Image getImage(boolean isSelected) {
195 | String key = isSelected ? CHECKED_IMAGE : UNCHECKED_IMAGE;
196 | return imageRegistry.get(key);
197 | }
198 |
199 | /*
200 | * (non-Javadoc)
201 | *
202 | * @see
203 | * org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang
204 | * .Object, int)
205 | */
206 | public Image getColumnImage(Object element, int columnIndex) {
207 | ColumnModel col = (ColumnModel) element;
208 |
209 | Image result = null;
210 |
211 | switch (columnIndex) {
212 | case 3:
213 | result = getImage("Y".equalsIgnoreCase(col.getIsParamKey()));
214 | break;
215 | case 4:
216 | result = getImage("Y".equalsIgnoreCase(col.getIsList()));
217 | break;
218 | case 5:
219 | result = getImage("Y".equalsIgnoreCase(col.getIsQuery()));
220 | break;
221 | case 6:
222 | result = getImage("Y".equalsIgnoreCase(col.getIsEdit()));
223 | break;
224 | default:
225 | break;
226 | }
227 | return result;
228 | }
229 |
230 | public String getColumnText(Object element, int columnIndex) {
231 | String result = "";
232 | ColumnModel col = (ColumnModel) element;
233 | switch (columnIndex) {
234 | case 0:
235 | result = col.getColumnName();
236 | break;
237 | case 1:
238 | result = col.getJavaName();
239 | break;
240 | case 2:
241 | result = col.getComment() == null ? "" : col.getComment();
242 | break;
243 | case 7:
244 | result = col.getDictKey();
245 | break;
246 | default:
247 | break;
248 | }
249 | return result;
250 | }
251 |
252 | }
253 |
254 | class ColumnCellModifier implements ICellModifier {
255 | PageThree pageThree;
256 | List columnNames;
257 |
258 | public ColumnCellModifier(PageThree pageThree, String[] columnNames) {
259 | this.pageThree = pageThree;
260 | this.columnNames = Arrays.asList(columnNames);
261 | }
262 |
263 | public boolean canModify(Object element, String property) {
264 | return true;
265 | }
266 |
267 | public Object getValue(Object element, String property) {
268 | int columnIndex = columnNames.indexOf(property);
269 |
270 | Object result = null;
271 |
272 | ColumnModel col = (ColumnModel) element;
273 | switch (columnIndex) {
274 | case 0:
275 | result = col.getColumnName();
276 | break;
277 | case 1:
278 | result = col.getJavaName();
279 | break;
280 | case 2:
281 | result = col.getComment();
282 | break;
283 | case 3:
284 | result = new Boolean(!"Y".equals(col.getIsParamKey()));
285 | break;
286 | case 4:
287 | result = new Boolean(!"Y".equals(col.getIsList()));
288 | break;
289 | case 5:
290 | result = new Boolean(!"Y".equals(col.getIsQuery()));
291 | break;
292 | case 6:
293 | result = new Boolean(!"Y".equals(col.getIsEdit()));
294 | break;
295 | case 7:
296 | result = col.getDictKey();
297 | break;
298 | default:
299 | result = "";
300 | }
301 | return result;
302 | }
303 |
304 | public void modify(Object element, String property, Object value) {
305 | int columnIndex = columnNames.indexOf(property);
306 | TableItem item = (TableItem) element;
307 | ColumnModel col = (ColumnModel)item.getData();
308 | switch (columnIndex) {
309 | case 0:
310 | col.setColumnName(StringUtils.trim((String)value));
311 | break;
312 | case 1:
313 | col.setJavaName(StringUtils.trim((String)value));
314 | break;
315 | case 2:
316 | col.setComment(StringUtils.trim((String)value));
317 | break;
318 | case 3:
319 | col.setIsParamKey(((Boolean) value).booleanValue()?"N":"Y");
320 | break;
321 | case 4:
322 | col.setIsList(((Boolean) value).booleanValue()?"N":"Y");
323 | break;
324 | case 5:
325 | col.setIsQuery(((Boolean) value).booleanValue()?"N":"Y");
326 | break;
327 | case 6:
328 | col.setIsEdit(((Boolean) value).booleanValue()?"N":"Y");
329 | break;
330 | case 7:
331 | col.setDictKey(StringUtils.trim((String)value));
332 | break;
333 | default:
334 | //result = "";
335 | }
336 |
337 | this.pageThree.getTableViewer().update(col, null);
338 | }
339 |
340 | }
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/StartMsWizard.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.ms;
2 |
3 | import java.io.File;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import org.eclipse.jface.dialogs.MessageDialog;
8 | import org.eclipse.jface.wizard.Wizard;
9 |
10 | import com.thinkgem.jeesite.autocode.model.TableConfigModel;
11 | import com.thinkgem.jeesite.autocode.model.TableModel;
12 | import com.thinkgem.jeesite.autocode.util.FreeMakerUtils;
13 | import com.thinkgem.jeesite.autocode.util.StringUtils;
14 | import com.thinkgem.jeesite.autocode.util.XmlObjectCrud;
15 | import com.thinkgem.jeesite.autocode.util.XmlObjectUtils;
16 |
17 | import freemarker.template.Configuration;
18 |
19 | /**
20 | * 主从表代码生成
21 | */
22 | public class StartMsWizard extends Wizard {
23 | //所有全局变量防止在这里
24 |
25 | TableModel tableModel = new TableModel();
26 |
27 | public StartMsWizard() {
28 | setWindowTitle("树状机构生成");
29 | setHelpAvailable(false);
30 | setNeedsProgressMonitor(false);
31 | }
32 |
33 | @Override
34 | public void addPages() {
35 | addPage(new PageOne());
36 | addPage(new PageTwo());
37 | addPage(new PageThree());
38 |
39 | //设置上一次操作的路径
40 | TableConfigModel fileconfig = (TableConfigModel)XmlObjectUtils.objectXmlDecoder(XmlObjectCrud.getLeastTable());
41 | if(fileconfig!=null){
42 | PageTwo pageTwo = (PageTwo)super.getPage("PageTwo");
43 | TableConfigModel pttable = pageTwo.getTableConfig();
44 | pttable.setAuthor(fileconfig.getAuthor());
45 | pttable.setVersion(fileconfig.getVersion());
46 | pttable.setTopPackage(fileconfig.getTopPackage());
47 | pttable.setFilePath(fileconfig.getFilePath());
48 | pttable.setJspLocation(fileconfig.getJspLocation());
49 | pttable.setFunctionNameCn(fileconfig.getFunctionNameCn());
50 | pttable.setFunctionNameEn(fileconfig.getFunctionNameEn());
51 | pttable.setUrlPrefix(fileconfig.getUrlPrefix());
52 | }
53 | }
54 |
55 | @Override
56 | public boolean performFinish() {
57 | PageTwo pageTwo = (PageTwo)super.getPage("PageTwo");
58 | pageTwo.checkInput();
59 |
60 | TableConfigModel tableconfig = pageTwo.getTableConfig();
61 |
62 | PageThree pageThree = (PageThree)super.getPage("PageThree");
63 | XmlObjectUtils.objectXmlEncoder(pageThree.getColumnList(), XmlObjectCrud.getLeastColumns());
64 | XmlObjectUtils.objectXmlEncoder(tableconfig,XmlObjectCrud.getLeastTable());
65 |
66 | Map data = new HashMap();
67 | data.put("columnList", pageThree.getColumnList());
68 | data.put("table", tableconfig);
69 |
70 |
71 | String separator = File.separator;
72 | String basePath = pageTwo.getTableConfig().getFilePath();
73 |
74 | //生成文件
75 | //Configuration freemakerCfg = FreeMakerUtils.getFreeMarkerCfg(this.getClass(), "template");
76 |
77 | Configuration freemakerCfg = FreeMakerUtils.getFreeMarkerCfg(XmlObjectCrud.getFtlPath());
78 | FreeMakerUtils.generateFile(freemakerCfg, "entity.ftl", data, "src\\main\\java\\"+StringUtils.replace(tableconfig.getTopPackage(), ".", "\\") + "\\entity\\", StringUtils.capitalize(tableconfig.getTableJavaName()) +".java", basePath);
79 |
80 | MessageDialog.openInformation(super.getShell(), "代码生成成功", "代码生成成功,生成代码存放路径:"+tableconfig.getFilePath());
81 | return true;
82 | }
83 |
84 |
85 |
86 | public void setTableModel(String name,String comment){
87 | tableModel.setName(name);
88 | tableModel.setComment(comment);
89 | }
90 |
91 | public TableModel getTableModel() {
92 | return tableModel;
93 | }
94 |
95 | @Override
96 | public boolean canFinish() {
97 | if("PageThree".equals(super.getContainer().getCurrentPage().getName())){
98 | return true;
99 | }else{
100 | return false;
101 | }
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/template/controller.ftl:
--------------------------------------------------------------------------------
1 | /**
2 | * There are JeeSite code generation
3 | */
4 | package ${packageName}.${moduleName}.web${subModuleName};
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | import org.apache.shiro.authz.annotation.RequiresPermissions;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Controller;
12 | import org.springframework.ui.Model;
13 | import org.springframework.web.bind.annotation.ModelAttribute;
14 | import org.springframework.web.bind.annotation.RequestMapping;
15 | import org.springframework.web.bind.annotation.RequestParam;
16 | import org.springframework.web.servlet.mvc.support.RedirectAttributes;
17 |
18 | import com.thinkgem.jeesite.common.config.Global;
19 | import com.thinkgem.jeesite.common.persistence.Page;
20 | import com.thinkgem.jeesite.common.web.BaseController;
21 | import com.thinkgem.jeesite.modules.sys.entity.User;
22 | import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
23 | import ${packageName}.${moduleName}.entity${subModuleName}.${ClassName};
24 | import ${packageName}.${moduleName}.service${subModuleName}.${ClassName}Service;
25 |
26 | /**
27 | * ${functionName}Controller
28 | * @author ${classAuthor}
29 | * @version ${classVersion}
30 | */
31 | @Controller
32 | @RequestMapping(value = Global.ADMIN_PATH+"/${urlPrefix}")
33 | public class ${ClassName}Controller extends BaseController {
34 |
35 | @Autowired
36 | private ${ClassName}Service ${className}Service;
37 |
38 | @ModelAttribute
39 | public ${ClassName} get(@RequestParam(required=false) Long id) {
40 | if (id != null){
41 | return ${className}Service.get(id);
42 | }else{
43 | return new ${ClassName}();
44 | }
45 | }
46 |
47 | @RequiresPermissions("${permissionPrefix}:view")
48 | @RequestMapping(value = {"list", ""})
49 | public String list(${ClassName} ${className}, HttpServletRequest request, HttpServletResponse response, Model model) {
50 | User user = UserUtils.getUser();
51 | if (!user.isAdmin()){
52 | ${className}.setUser(user);
53 | }
54 | Page<${ClassName}> page = ${className}Service.find(new Page<${ClassName}>(request, response), ${className});
55 | model.addAttribute("page", page);
56 | return "${viewPrefix}List";
57 | }
58 |
59 | @RequiresPermissions("${permissionPrefix}:view")
60 | @RequestMapping(value = "form")
61 | public String form(${ClassName} ${className}, Model model) {
62 | model.addAttribute("${className}", ${className});
63 | return "${viewPrefix}Form";
64 | }
65 |
66 | @RequiresPermissions("${permissionPrefix}:edit")
67 | @RequestMapping(value = "save")
68 | public String save(${ClassName} ${className}, Model model, RedirectAttributes redirectAttributes) {
69 | if (!beanValidator(model, ${className})){
70 | return form(${className}, model);
71 | }
72 | ${className}Service.save(${className});
73 | addMessage(redirectAttributes, "保存${functionName}'" + ${className}.getName() + "'成功");
74 | return "redirect:"+Global.ADMIN_PATH+"/${viewPrefix}/?repage";
75 | }
76 |
77 | @RequiresPermissions("${permissionPrefix}:edit")
78 | @RequestMapping(value = "delete")
79 | public String delete(Long id, RedirectAttributes redirectAttributes) {
80 | ${className}Service.delete(id);
81 | addMessage(redirectAttributes, "删除${functionName}成功");
82 | return "redirect:"+Global.ADMIN_PATH+"/${viewPrefix}/?repage";
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/template/dao.ftl:
--------------------------------------------------------------------------------
1 | /**
2 | * There are JeeSite code generation
3 | */
4 | package ${packageName}.${moduleName}.dao${subModuleName};
5 |
6 | import org.springframework.data.jpa.repository.Modifying;
7 | import org.springframework.data.jpa.repository.Query;
8 | import org.springframework.data.repository.CrudRepository;
9 | import org.springframework.stereotype.Component;
10 |
11 | import com.thinkgem.jeesite.common.persistence.BaseDao;
12 | import com.thinkgem.jeesite.common.persistence.BaseDaoImpl;
13 | import ${packageName}.${moduleName}.entity${subModuleName}.${ClassName};
14 |
15 | /**
16 | * ${functionName}DAO接口
17 | * @author ${classAuthor}
18 | * @version ${classVersion}
19 | */
20 | public interface ${ClassName}Dao extends ${ClassName}DaoCustom, CrudRepository<${ClassName}, Long> {
21 |
22 | @Modifying
23 | @Query("update ${ClassName} set delFlag='" + ${ClassName}.DEL_FLAG_DELETE + "' where id = ?1")
24 | public int deleteById(Long id);
25 |
26 | }
27 |
28 | /**
29 | * DAO自定义接口
30 | * @author ${classAuthor}
31 | */
32 | interface ${ClassName}DaoCustom extends BaseDao<${ClassName}> {
33 |
34 | }
35 |
36 | /**
37 | * DAO自定义接口实现
38 | * @author ${classAuthor}
39 | */
40 | @Component
41 | class ${ClassName}DaoImpl extends BaseDaoImpl<${ClassName}> implements ${ClassName}DaoCustom {
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/template/entity.ftl:
--------------------------------------------------------------------------------
1 | table属性
2 | ${table}
3 |
4 | table所有列属性
5 | <#list columnList as x>
6 | ${x}
7 | #list>
8 |
9 | /**
10 | * There are JeeSite code generation
11 | */
12 | package ${table.topPackage}.entity.${table.tableJavaName}
13 |
14 | import java.util.Date;
15 |
16 | import javax.persistence.Entity;
17 | import javax.persistence.GeneratedValue;
18 | import javax.persistence.GenerationType;
19 | import javax.persistence.Id;
20 | import javax.persistence.JoinColumn;
21 | import javax.persistence.ManyToOne;
22 | import javax.persistence.Table;
23 | import javax.validation.constraints.NotNull;
24 |
25 | import org.hibernate.annotations.Cache;
26 | import org.hibernate.annotations.CacheConcurrencyStrategy;
27 | import org.hibernate.annotations.NotFound;
28 | import org.hibernate.annotations.NotFoundAction;
29 | import org.hibernate.validator.constraints.Length;
30 |
31 | import com.thinkgem.jeesite.common.persistence.BaseEntity;
32 | import com.thinkgem.jeesite.modules.sys.entity.User;
33 |
34 |
35 | /**
36 | * ${table.tableComment}Entity
37 | * @author ${table.author}
38 | * @version ${table.version}
39 | */
40 | @Entity
41 | @Table(name = "${table.tableName}")
42 | @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
43 | public class ${table.tableJavaName} extends BaseEntity {
44 |
45 | <#list columnList as x>
46 | /**
47 | * <#if x.comment??>${x.comment}#if>
48 | **/
49 | private ${x.javaType} ${x.javaName};
50 | #list>
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/template/service.ftl:
--------------------------------------------------------------------------------
1 | /**
2 | * There are JeeSite code generation
3 | */
4 | package ${packageName}.${moduleName}.service${subModuleName};
5 |
6 | import org.apache.commons.lang3.StringUtils;
7 | import org.hibernate.criterion.DetachedCriteria;
8 | import org.hibernate.criterion.Order;
9 | import org.hibernate.criterion.Restrictions;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.stereotype.Component;
14 | import org.springframework.transaction.annotation.Transactional;
15 |
16 | import com.thinkgem.jeesite.common.persistence.Page;
17 | import com.thinkgem.jeesite.common.service.BaseService;
18 | import ${packageName}.${moduleName}.entity${subModuleName}.${ClassName};
19 | import ${packageName}.${moduleName}.dao${subModuleName}.${ClassName}Dao;
20 |
21 | /**
22 | * ${functionName}Service
23 | * @author ${classAuthor}
24 | * @version ${classVersion}
25 | */
26 | @Component
27 | @Transactional(readOnly = true)
28 | public class ${ClassName}Service extends BaseService {
29 |
30 | @SuppressWarnings("unused")
31 | private static Logger logger = LoggerFactory.getLogger(${ClassName}Service.class);
32 |
33 | @Autowired
34 | private ${ClassName}Dao ${className}Dao;
35 |
36 | public ${ClassName} get(Long id) {
37 | return ${className}Dao.findOne(id);
38 | }
39 |
40 | public Page<${ClassName}> find(Page<${ClassName}> page, ${ClassName} ${className}) {
41 | DetachedCriteria dc = ${className}Dao.createDetachedCriteria();
42 | if (${className}.getUser()!=null && ${className}.getUser().getId()>0){
43 | dc.add(Restrictions.eq("user.id", ${className}.getUser().getId()));
44 | }
45 | if (StringUtils.isNotEmpty(${className}.getName())){
46 | dc.add(Restrictions.like("name", "%"+${className}.getName()+"%"));
47 | }
48 | if (StringUtils.isNotEmpty(${className}.getRemarks())){
49 | dc.add(Restrictions.like("remarks", "%"+${className}.getRemarks()+"%"));
50 | }
51 | dc.add(Restrictions.eq("delFlag", ${ClassName}.DEL_FLAG_NORMAL));
52 | dc.addOrder(Order.desc("id"));
53 | return ${className}Dao.find(page, dc);
54 | }
55 |
56 | @Transactional(readOnly = false)
57 | public void save(${ClassName} ${className}) {
58 | ${className}Dao.save(${className});
59 | }
60 |
61 | @Transactional(readOnly = false)
62 | public void delete(Long id) {
63 | ${className}Dao.deleteById(id);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/ms/template/viewForm.ftl:
--------------------------------------------------------------------------------
1 | <%@ page contentType="text/html;charset=UTF-8" %>
2 | <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
3 |
4 |
5 | 名称 | 备注 | 操作 |
---|---|---|
${"${"+className+".name}"} | 37 |${"${"+className+".remarks}"} | 38 |39 | 修改 40 | 删除 41 | |
<#if x.comment??>${x.comment}#if> | 20 |${r"${entity."}${x.javaName}<#if x.javaType=='Double'>Str#if><#if x.javaType=='Date'>Str#if><#if x.dictKey!="">Str#if>${r"}"} | 21 |
26 | |
---|
Operations on {@link java.lang.CharSequence} that are 21 | * {@code null} safe.
22 | * 23 | * @see java.lang.CharSequence 24 | * @since 3.0 25 | * @version $Id: CharSequenceUtils.java 1199894 2011-11-09 17:53:59Z ggregory $ 26 | */ 27 | public class CharSequenceUtils { 28 | 29 | /** 30 | *{@code CharSequenceUtils} instances should NOT be constructed in 31 | * standard programming.
32 | * 33 | *This constructor is public to permit tools that require a JavaBean 34 | * instance to operate.
35 | */ 36 | public CharSequenceUtils() { 37 | super(); 38 | } 39 | 40 | //----------------------------------------------------------------------- 41 | /** 42 | *Returns a new {@code CharSequence} that is a subsequence of this 43 | * sequence starting with the {@code char} value at the specified index.
44 | * 45 | *This provides the {@code CharSequence} equivalent to {@link String#substring(int)}. 46 | * The length (in {@code char}) of the returned sequence is {@code length() - start}, 47 | * so if {@code start == end} then an empty sequence is returned.
48 | * 49 | * @param cs the specified subsequence, null returns null 50 | * @param start the start index, inclusive, valid 51 | * @return a new subsequence, may be null 52 | * @throws IndexOutOfBoundsException if {@code start} is negative or if 53 | * {@code start} is greater than {@code length()} 54 | */ 55 | public static CharSequence subSequence(CharSequence cs, int start) { 56 | return cs == null ? null : cs.subSequence(start, cs.length()); 57 | } 58 | 59 | //----------------------------------------------------------------------- 60 | /** 61 | *Finds the first index in the {@code CharSequence} that matches the 62 | * specified character.
63 | * 64 | * @param cs the {@code CharSequence} to be processed, not null 65 | * @param searchChar the char to be searched for 66 | * @param start the start index, negative starts at the string start 67 | * @return the index where the search char was found, -1 if not found 68 | */ 69 | static int indexOf(CharSequence cs, int searchChar, int start) { 70 | if (cs instanceof String) { 71 | return ((String) cs).indexOf(searchChar, start); 72 | } else { 73 | int sz = cs.length(); 74 | if (start < 0) { 75 | start = 0; 76 | } 77 | for (int i = start; i < sz; i++) { 78 | if (cs.charAt(i) == searchChar) { 79 | return i; 80 | } 81 | } 82 | return -1; 83 | } 84 | } 85 | 86 | /** 87 | * Used by the indexOf(CharSequence methods) as a green implementation of indexOf. 88 | * 89 | * @param cs the {@code CharSequence} to be processed 90 | * @param searchChar the {@code CharSequence} to be searched for 91 | * @param start the start index 92 | * @return the index where the search sequence was found 93 | */ 94 | static int indexOf(CharSequence cs, CharSequence searchChar, int start) { 95 | return cs.toString().indexOf(searchChar.toString(), start); 96 | // if (cs instanceof String && searchChar instanceof String) { 97 | // // TODO: Do we assume searchChar is usually relatively small; 98 | // // If so then calling toString() on it is better than reverting to 99 | // // the green implementation in the else block 100 | // return ((String) cs).indexOf((String) searchChar, start); 101 | // } else { 102 | // // TODO: Implement rather than convert to String 103 | // return cs.toString().indexOf(searchChar.toString(), start); 104 | // } 105 | } 106 | 107 | /** 108 | *Finds the last index in the {@code CharSequence} that matches the 109 | * specified character.
110 | * 111 | * @param cs the {@code CharSequence} to be processed 112 | * @param searchChar the char to be searched for 113 | * @param start the start index, negative returns -1, beyond length starts at end 114 | * @return the index where the search char was found, -1 if not found 115 | */ 116 | static int lastIndexOf(CharSequence cs, int searchChar, int start) { 117 | if (cs instanceof String) { 118 | return ((String) cs).lastIndexOf(searchChar, start); 119 | } else { 120 | int sz = cs.length(); 121 | if (start < 0) { 122 | return -1; 123 | } 124 | if (start >= sz) { 125 | start = sz - 1; 126 | } 127 | for (int i = start; i >= 0; --i) { 128 | if (cs.charAt(i) == searchChar) { 129 | return i; 130 | } 131 | } 132 | return -1; 133 | } 134 | } 135 | 136 | /** 137 | * Used by the lastIndexOf(CharSequence methods) as a green implementation of lastIndexOf 138 | * 139 | * @param cs the {@code CharSequence} to be processed 140 | * @param searchChar the {@code CharSequence} to be searched for 141 | * @param start the start index 142 | * @return the index where the search sequence was found 143 | */ 144 | static int lastIndexOf(CharSequence cs, CharSequence searchChar, int start) { 145 | return cs.toString().lastIndexOf(searchChar.toString(), start); 146 | // if (cs instanceof String && searchChar instanceof String) { 147 | // // TODO: Do we assume searchChar is usually relatively small; 148 | // // If so then calling toString() on it is better than reverting to 149 | // // the green implementation in the else block 150 | // return ((String) cs).lastIndexOf((String) searchChar, start); 151 | // } else { 152 | // // TODO: Implement rather than convert to String 153 | // return cs.toString().lastIndexOf(searchChar.toString(), start); 154 | // } 155 | } 156 | 157 | /** 158 | * Green implementation of toCharArray. 159 | * 160 | * @param cs the {@code CharSequence} to be processed 161 | * @return the resulting char array 162 | */ 163 | static char[] toCharArray(CharSequence cs) { 164 | if (cs instanceof String) { 165 | return ((String) cs).toCharArray(); 166 | } else { 167 | int sz = cs.length(); 168 | char[] array = new char[cs.length()]; 169 | for (int i = 0; i < sz; i++) { 170 | array[i] = cs.charAt(i); 171 | } 172 | return array; 173 | } 174 | } 175 | 176 | /** 177 | * Green implementation of regionMatches. 178 | * 179 | * @param cs the {@code CharSequence} to be processed 180 | * @param ignoreCase whether or not to be case insensitive 181 | * @param thisStart the index to start on the {@code cs} CharSequence 182 | * @param substring the {@code CharSequence} to be looked for 183 | * @param start the index to start on the {@code substring} CharSequence 184 | * @param length character length of the region 185 | * @return whether the region matched 186 | */ 187 | static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, 188 | CharSequence substring, int start, int length) { 189 | if (cs instanceof String && substring instanceof String) { 190 | return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length); 191 | } else { 192 | // TODO: Implement rather than convert to String 193 | return cs.toString().regionMatches(ignoreCase, thisStart, substring.toString(), start, length); 194 | } 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /src/com/thinkgem/jeesite/autocode/util/DbUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package com.thinkgem.jeesite.autocode.util; 18 | 19 | import java.io.PrintWriter; 20 | import java.sql.Connection; 21 | import java.sql.ResultSet; 22 | import java.sql.SQLException; 23 | import java.sql.Statement; 24 | 25 | /** 26 | * A collection of JDBC helper methods. This class is thread safe. 27 | */ 28 | public final class DbUtils { 29 | 30 | /** 31 | * Default constructor. 32 | * 33 | * Utility classes should not have a public or default constructor, but this 34 | * one preserves retro-compatibility. 35 | * 36 | * @since 1.4 37 | */ 38 | public DbUtils() { 39 | // do nothing 40 | } 41 | 42 | /** 43 | * Close aConnection
, avoid closing if null.
44 | *
45 | * @param conn
46 | * Connection to close.
47 | * @throws SQLException
48 | * if a database access error occurs
49 | */
50 | public static void close(Connection conn) throws SQLException {
51 | if (conn != null) {
52 | conn.close();
53 | }
54 | }
55 |
56 | /**
57 | * Close a ResultSet
, avoid closing if null.
58 | *
59 | * @param rs
60 | * ResultSet to close.
61 | * @throws SQLException
62 | * if a database access error occurs
63 | */
64 | public static void close(ResultSet rs) throws SQLException {
65 | if (rs != null) {
66 | rs.close();
67 | }
68 | }
69 |
70 | /**
71 | * Close a Statement
, avoid closing if null.
72 | *
73 | * @param stmt
74 | * Statement to close.
75 | * @throws SQLException
76 | * if a database access error occurs
77 | */
78 | public static void close(Statement stmt) throws SQLException {
79 | if (stmt != null) {
80 | stmt.close();
81 | }
82 | }
83 |
84 | /**
85 | * Close a Connection
, avoid closing if null and hide any
86 | * SQLExceptions that occur.
87 | *
88 | * @param conn
89 | * Connection to close.
90 | */
91 | public static void closeQuietly(Connection conn) {
92 | try {
93 | close(conn);
94 | } catch (SQLException e) { // NOPMD
95 | // quiet
96 | }
97 | }
98 |
99 | /**
100 | * Close a Connection
, Statement
and
101 | * ResultSet
. Avoid closing if null and hide any SQLExceptions
102 | * that occur.
103 | *
104 | * @param conn
105 | * Connection to close.
106 | * @param stmt
107 | * Statement to close.
108 | * @param rs
109 | * ResultSet to close.
110 | */
111 | public static void closeQuietly(Connection conn, Statement stmt,
112 | ResultSet rs) {
113 |
114 | try {
115 | closeQuietly(rs);
116 | } finally {
117 | try {
118 | closeQuietly(stmt);
119 | } finally {
120 | closeQuietly(conn);
121 | }
122 | }
123 |
124 | }
125 |
126 | /**
127 | * Close a ResultSet
, avoid closing if null and hide any
128 | * SQLExceptions that occur.
129 | *
130 | * @param rs
131 | * ResultSet to close.
132 | */
133 | public static void closeQuietly(ResultSet rs) {
134 | try {
135 | close(rs);
136 | } catch (SQLException e) { // NOPMD
137 | // quiet
138 | }
139 | }
140 |
141 | /**
142 | * Close a Statement
, avoid closing if null and hide any
143 | * SQLExceptions that occur.
144 | *
145 | * @param stmt
146 | * Statement to close.
147 | */
148 | public static void closeQuietly(Statement stmt) {
149 | try {
150 | close(stmt);
151 | } catch (SQLException e) { // NOPMD
152 | // quiet
153 | }
154 | }
155 |
156 | /**
157 | * Commits a Connection
then closes it, avoid closing if null.
158 | *
159 | * @param conn
160 | * Connection to close.
161 | * @throws SQLException
162 | * if a database access error occurs
163 | */
164 | public static void commitAndClose(Connection conn) throws SQLException {
165 | if (conn != null) {
166 | try {
167 | conn.commit();
168 | } finally {
169 | conn.close();
170 | }
171 | }
172 | }
173 |
174 | /**
175 | * Commits a Connection
then closes it, avoid closing if null
176 | * and hide any SQLExceptions that occur.
177 | *
178 | * @param conn
179 | * Connection to close.
180 | */
181 | public static void commitAndCloseQuietly(Connection conn) {
182 | try {
183 | commitAndClose(conn);
184 | } catch (SQLException e) { // NOPMD
185 | // quiet
186 | }
187 | }
188 |
189 | /**
190 | * Loads and registers a database driver class. If this succeeds, it returns
191 | * true, else it returns false.
192 | *
193 | * @param driverClassName
194 | * of driver to load
195 | * @return boolean true
if the driver was found, otherwise
196 | * false
197 | */
198 | public static boolean loadDriver(String driverClassName) {
199 | return loadDriver(DbUtils.class.getClassLoader(), driverClassName);
200 | }
201 |
202 | /**
203 | * Loads and registers a database driver class. If this succeeds, it returns
204 | * true, else it returns false.
205 | *
206 | * @param classLoader
207 | * the class loader used to load the driver class
208 | * @param driverClassName
209 | * of driver to load
210 | * @return boolean true
if the driver was found, otherwise
211 | * false
212 | * @since 1.4
213 | */
214 | public static boolean loadDriver(ClassLoader classLoader,
215 | String driverClassName) {
216 | try {
217 | classLoader.loadClass(driverClassName).newInstance();
218 | return true;
219 |
220 | } catch (IllegalAccessException e) {
221 | // Constructor is private, OK for DriverManager contract
222 | return true;
223 |
224 | } catch (Exception e) {
225 | return false;
226 |
227 | }
228 | }
229 |
230 | /**
231 | * Print the stack trace for a SQLException to STDERR.
232 | *
233 | * @param e
234 | * SQLException to print stack trace of
235 | */
236 | public static void printStackTrace(SQLException e) {
237 | printStackTrace(e, new PrintWriter(System.err));
238 | }
239 |
240 | /**
241 | * Print the stack trace for a SQLException to a specified PrintWriter.
242 | *
243 | * @param e
244 | * SQLException to print stack trace of
245 | * @param pw
246 | * PrintWriter to print to
247 | */
248 | public static void printStackTrace(SQLException e, PrintWriter pw) {
249 |
250 | SQLException next = e;
251 | while (next != null) {
252 | next.printStackTrace(pw);
253 | next = next.getNextException();
254 | if (next != null) {
255 | pw.println("Next SQLException:");
256 | }
257 | }
258 | }
259 |
260 | /**
261 | * Print warnings on a Connection to STDERR.
262 | *
263 | * @param conn
264 | * Connection to print warnings from
265 | */
266 | public static void printWarnings(Connection conn) {
267 | printWarnings(conn, new PrintWriter(System.err));
268 | }
269 |
270 | /**
271 | * Print warnings on a Connection to a specified PrintWriter.
272 | *
273 | * @param conn
274 | * Connection to print warnings from
275 | * @param pw
276 | * PrintWriter to print to
277 | */
278 | public static void printWarnings(Connection conn, PrintWriter pw) {
279 | if (conn != null) {
280 | try {
281 | printStackTrace(conn.getWarnings(), pw);
282 | } catch (SQLException e) {
283 | printStackTrace(e, pw);
284 | }
285 | }
286 | }
287 |
288 | /**
289 | * Rollback any changes made on the given connection.
290 | *
291 | * @param conn
292 | * Connection to rollback. A null value is legal.
293 | * @throws SQLException
294 | * if a database access error occurs
295 | */
296 | public static void rollback(Connection conn) throws SQLException {
297 | if (conn != null) {
298 | conn.rollback();
299 | }
300 | }
301 |
302 | /**
303 | * Performs a rollback on the Connection
then closes it, avoid
304 | * closing if null.
305 | *
306 | * @param conn
307 | * Connection to rollback. A null value is legal.
308 | * @throws SQLException
309 | * if a database access error occurs
310 | * @since DbUtils 1.1
311 | */
312 | public static void rollbackAndClose(Connection conn) throws SQLException {
313 | if (conn != null) {
314 | try {
315 | conn.rollback();
316 | } finally {
317 | conn.close();
318 | }
319 | }
320 | }
321 |
322 | /**
323 | * Performs a rollback on the Connection
then closes it, avoid
324 | * closing if null and hide any SQLExceptions that occur.
325 | *
326 | * @param conn
327 | * Connection to rollback. A null value is legal.
328 | * @since DbUtils 1.1
329 | */
330 | public static void rollbackAndCloseQuietly(Connection conn) {
331 | try {
332 | rollbackAndClose(conn);
333 | } catch (SQLException e) { // NOPMD
334 | // quiet
335 | }
336 | }
337 |
338 | }
339 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/FileUtils.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.io.File;
4 | import java.io.FileOutputStream;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 | import java.net.URL;
9 |
10 | public class FileUtils {
11 | public static void copyURLToFile(URL source, File destination)
12 | throws IOException {
13 | java.io.InputStream input = source.openStream();
14 | try {
15 | FileOutputStream output = openOutputStream(destination);
16 | try {
17 | copy(input, output);
18 | } finally {
19 | closeQuietly(output);
20 | }
21 | } finally {
22 | closeQuietly(input);
23 | }
24 | }
25 |
26 | public static FileOutputStream openOutputStream(File file)
27 | throws IOException {
28 | if (file.exists()) {
29 | if (file.isDirectory())
30 | throw new IOException("File '" + file
31 | + "' exists but is a directory");
32 | if (!file.canWrite())
33 | throw new IOException("File '" + file
34 | + "' cannot be written to");
35 | } else {
36 | File parent = file.getParentFile();
37 | if (parent != null && !parent.exists() && !parent.mkdirs())
38 | throw new IOException("File '" + file
39 | + "' could not be created");
40 | }
41 | return new FileOutputStream(file);
42 | }
43 |
44 | public static int copy(InputStream input, OutputStream output)
45 | throws IOException {
46 | long count = copyLarge(input, output);
47 | if (count > 2147483647L)
48 | return -1;
49 | else
50 | return (int) count;
51 | }
52 |
53 | public static long copyLarge(InputStream input, OutputStream output)
54 | throws IOException {
55 | byte buffer[] = new byte[4096];
56 | long count = 0L;
57 | for (int n = 0; -1 != (n = input.read(buffer));) {
58 | output.write(buffer, 0, n);
59 | count += n;
60 | }
61 |
62 | return count;
63 | }
64 |
65 | public static void closeQuietly(OutputStream output) {
66 | try {
67 | if (output != null)
68 | output.close();
69 | } catch (IOException ioe) {
70 | }
71 | }
72 |
73 | public static void closeQuietly(InputStream input) {
74 | try {
75 | if (input != null)
76 | input.close();
77 | } catch (IOException ioe) {
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/FreeMakerUtils.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.File;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 | import java.io.OutputStreamWriter;
8 | import java.io.Writer;
9 | import java.util.Map;
10 |
11 | import freemarker.template.Configuration;
12 | import freemarker.template.Template;
13 | import freemarker.template.TemplateException;
14 |
15 |
16 | public class FreeMakerUtils {
17 |
18 | public static Configuration getFreeMarkerCfg(String ftlPath) {
19 | Configuration freemarkerCfg = new Configuration();
20 | freemarkerCfg.setBooleanFormat("true,false");
21 | freemarkerCfg.setNumberFormat("#");
22 | freemarkerCfg.setDefaultEncoding("UTF-8");
23 | try {
24 | freemarkerCfg.setDirectoryForTemplateLoading(new File(ftlPath));
25 | } catch (IOException e) {
26 | e.printStackTrace();
27 | }
28 | return freemarkerCfg;
29 | }
30 |
31 | public static Configuration getFreeMarkerCfg(Class cls, String templatePath) {
32 | Configuration freemarkerCfg = new Configuration();
33 | freemarkerCfg.setBooleanFormat("true,false");
34 | freemarkerCfg.setDefaultEncoding("UTF-8");
35 | freemarkerCfg.setClassForTemplateLoading(cls, templatePath);
36 | return freemarkerCfg;
37 | }
38 |
39 | public static boolean generateFile(Configuration cfg,
40 | String templateFileName, Map propMap, String relPath,
41 | String fileName, String rootDir) {
42 | try {
43 | Template t = cfg.getTemplate(templateFileName);
44 |
45 | creatDirs(rootDir, relPath);
46 |
47 | File dir = new File(rootDir + "/" + relPath);
48 | if (!dir.exists()) {
49 | dir.mkdir();
50 | }
51 |
52 | File afile = new File(rootDir + "/" + relPath + "/"
53 | + fileName);
54 |
55 | Writer out = new BufferedWriter(new OutputStreamWriter(
56 | new FileOutputStream(afile), "UTF-8"));
57 |
58 | t.process(propMap, out);
59 | out.close();
60 | } catch (TemplateException e) {
61 | e.printStackTrace();
62 | return false;
63 | } catch (IOException e) {
64 | e.printStackTrace();
65 | return false;
66 | }
67 |
68 | return true;
69 | }
70 |
71 | public static boolean creatDirs(String aParentDir, String aSubDir) {
72 | File aFile = new File(aParentDir);
73 | if (aFile.exists()) {
74 | File aSubFile = new File(aParentDir + "/" + aSubDir);
75 | if (!aSubFile.exists()) {
76 | return aSubFile.mkdirs();
77 | } else {
78 | return true;
79 | }
80 | } else {
81 | return false;
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/GetterSetterUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.thinkgem.jeesite.autocode.util;
5 |
6 | import java.lang.reflect.Field;
7 |
8 | import com.thinkgem.jeesite.autocode.model.ColumnModel;
9 | /**
10 | *
11 | */
12 | public class GetterSetterUtils {
13 |
14 | /**
15 | * @param args
16 | */
17 | public static void main(String[] args) {
18 | // TODO Auto-generated method stub
19 | //Class c = com.routdata.dm.equipment.queryFilter.ChangeQueryFilter.class;
20 | Class c = ColumnModel.class;
21 | Field[] fields = c.getDeclaredFields();
22 | for(int i=0,len=fields.length-1;i<=len;i++){
23 | /*if("java.lang.Double".equals(fields[i].getType().getName())){
24 | System.out.println("public String get"+fields[i].getName().substring(0, 1).toUpperCase()+fields[i].getName().substring(1)+"Str(){");
25 | System.out.println("return FormateUtil.getInstance().formateDouble(this."+fields[i].getName()+");");
26 | System.out.println("}");
27 | }else if("java.util.Date".equals(fields[i].getType().getName())){
28 | System.out.println("public String get"+fields[i].getName().substring(0, 1).toUpperCase()+fields[i].getName().substring(1)+"Str(){");
29 | System.out.println("return DateUtil.getInstance().formateDate(this."+fields[i].getName()+");");
30 | System.out.println("}");
31 | }*/
32 |
33 | System.out.println("str.append(\""+fields[i].getName()+"=\").append("+fields[i].getName()+");");
34 | }
35 |
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/SQLFormatter.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import blanco.commons.sql.format.BlancoSqlFormatter;
4 | import blanco.commons.sql.format.BlancoSqlFormatterException;
5 | import blanco.commons.sql.format.BlancoSqlRule;
6 |
7 | /**
8 | * 格式化SQL语句 代码来源 https://github.com/kyama/SQLFormatter
9 | *
10 | */
11 | public class SQLFormatter {
12 | public static String formatSql(String sql) {
13 | String newsql = new String();
14 | BlancoSqlRule rule = new BlancoSqlRule();
15 | String[] mySqlFuncs = {
16 | // getNumericFunctions
17 | "ABS", "ACOS", "ASIN", "ATAN", "ATAN2", "BIT_COUNT", "CEILING",
18 | "COS", "COT", "DEGREES", "EXP",
19 | "FLOOR",
20 | "LOG",
21 | "LOG10",
22 | "MAX",
23 | "MIN",
24 | "MOD",
25 | "PI",
26 | "POW",
27 | "POWER",
28 | "RADIANS",
29 | "RAND",
30 | "ROUND",
31 | "SIN",
32 | "SQRT",
33 | "TAN",
34 | "TRUNCATE",
35 | // getStringFunctions
36 | "ASCII", "BIN", "BIT_LENGTH", "CHAR", "CHARACTER_LENGTH",
37 | "CHAR_LENGTH", "CONCAT", "CONCAT_WS", "CONV", "ELT",
38 | "EXPORT_SET", "FIELD", "FIND_IN_SET", "HEX,INSERT", "INSTR",
39 | "LCASE", "LEFT", "LENGTH", "LOAD_FILE", "LOCATE", "LOCATE",
40 | "LOWER", "LPAD", "LTRIM", "MAKE_SET", "MATCH", "MID", "OCT",
41 | "OCTET_LENGTH", "ORD", "POSITION", "QUOTE", "REPEAT",
42 | "REPLACE", "REVERSE", "RIGHT", "RPAD", "RTRIM", "SOUNDEX",
43 | "SPACE", "STRCMP", "SUBSTRING",
44 | "SUBSTRING",
45 | "SUBSTRING",
46 | "SUBSTRING",
47 | "SUBSTRING_INDEX",
48 | "TRIM",
49 | "UCASE",
50 | "UPPER",
51 | // getSystemFunctions
52 | "DATABASE", "USER",
53 | "SYSTEM_USER",
54 | "SESSION_USER",
55 | "PASSWORD",
56 | "ENCRYPT",
57 | "LAST_INSERT_ID",
58 | "VERSION",
59 | // getTimeDateFunctions
60 | "DAYOFWEEK", "WEEKDAY", "DAYOFMONTH", "DAYOFYEAR", "MONTH",
61 | "DAYNAME", "MONTHNAME", "QUARTER", "WEEK", "YEAR", "HOUR",
62 | "MINUTE", "SECOND", "PERIOD_ADD", "PERIOD_DIFF", "TO_DAYS",
63 | "FROM_DAYS", "DATE_FORMAT", "TIME_FORMAT", "CURDATE",
64 | "CURRENT_DATE", "CURTIME", "CURRENT_TIME", "NOW", "SYSDATE",
65 | "CURRENT_TIMESTAMP", "UNIX_TIMESTAMP", "FROM_UNIXTIME",
66 | "SEC_TO_TIME", "TIME_TO_SEC" };
67 | rule.setFunctionNames(mySqlFuncs);
68 |
69 | BlancoSqlFormatter formatter = new BlancoSqlFormatter(rule);
70 |
71 | try {
72 | newsql = formatter.format(sql);
73 | } catch (BlancoSqlFormatterException e) {
74 | return sql;
75 | }
76 | return newsql;
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/XmlObjectCrud.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * crud xml
7 | *
8 | */
9 | public class XmlObjectCrud extends XmlObjectUtils {
10 | public static String getLeastColumns(){
11 | String userDir = System.getProperty("user.dir");
12 | String fileName = userDir +"\\crud-columns.xml";
13 | return fileName;
14 | }
15 |
16 | public static String getLeastTable(){
17 | String userDir = System.getProperty("user.dir");
18 | String fileName = userDir +"\\crud-table.xml";
19 | return fileName;
20 | }
21 |
22 | public static String getFtlPath(){
23 | String userDir = System.getProperty("user.dir");
24 | File dir = new File(userDir+"\\jeesite");
25 | if (!dir.exists()) {
26 | dir.mkdir();
27 | }
28 | File cruddir = new File(userDir+"\\jeesite\\crud");
29 | if (!cruddir.exists()) {
30 | cruddir.mkdir();
31 | }
32 | return userDir+"\\jeesite\\crud\\ftl";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/XmlObjectReport.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * crud xml
7 | *
8 | */
9 | public class XmlObjectReport extends XmlObjectUtils {
10 | public static String getLeastColumns(){
11 | String userDir = System.getProperty("user.dir");
12 | String fileName = userDir +"\\report-columns.xml";
13 | return fileName;
14 | }
15 |
16 | public static String getLeastTable(){
17 | String userDir = System.getProperty("user.dir");
18 | String fileName = userDir +"\\report-table.xml";
19 | return fileName;
20 | }
21 |
22 | public static String getFtlPath(){
23 | String userDir = System.getProperty("user.dir");
24 | File dir = new File(userDir+"\\jeesite");
25 | if (!dir.exists()) {
26 | dir.mkdir();
27 | }
28 | File cruddir = new File(userDir+"\\jeesite\\report");
29 | if (!cruddir.exists()) {
30 | cruddir.mkdir();
31 | }
32 | return userDir+"\\jeesite\\report\\ftl";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/XmlObjectTree.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * crud xml
7 | *
8 | */
9 | public class XmlObjectTree extends XmlObjectUtils {
10 | public static String getLeastColumns(){
11 | String userDir = System.getProperty("user.dir");
12 | String fileName = userDir +"\\tree-columns.xml";
13 | return fileName;
14 | }
15 |
16 | public static String getLeastTable(){
17 | String userDir = System.getProperty("user.dir");
18 | String fileName = userDir +"\\tree-table.xml";
19 | return fileName;
20 | }
21 |
22 | public static String getFtlPath(){
23 | String userDir = System.getProperty("user.dir");
24 | File dir = new File(userDir+"\\jeesite");
25 | if (!dir.exists()) {
26 | dir.mkdir();
27 | }
28 | File cruddir = new File(userDir+"\\jeesite\\tree");
29 | if (!cruddir.exists()) {
30 | cruddir.mkdir();
31 | }
32 | return userDir+"\\jeesite\\tree\\ftl";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/thinkgem/jeesite/autocode/util/XmlObjectUtils.java:
--------------------------------------------------------------------------------
1 | package com.thinkgem.jeesite.autocode.util;
2 |
3 | import java.beans.XMLDecoder;
4 | import java.beans.XMLEncoder;
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.FileNotFoundException;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 | import java.net.URL;
11 |
12 | import com.thinkgem.jeesite.autocode.crud.StartCurdWizard;
13 |
14 | public class XmlObjectUtils {
15 | /**
16 | * 把java的可序列化的对象(实现Serializable接口)序列化保存到XML文件里面,如果想一次保存多个可序列化对象请用集合进行封装
17 | * 保存时将会用现在的对象原来的XML文件内容
18 | *
19 | * @param obj
20 | * 要序列化的可序列化的对象
21 | * @param fileName
22 | * 带完全的保存路径的文件名
23 | * @throws FileNotFoundException
24 | * 指定位置的文件不存在
25 | * @throws IOException
26 | * 输出时发生异常
27 | * @throws Exception
28 | * 其他运行时异常
29 | */
30 | public static void objectXmlEncoder(Object obj, String fileName) {
31 | // 创建输出文件
32 | try {
33 | File fo = new File(fileName);
34 | // 文件不存在,就创建该文件
35 | if (!fo.exists()) {
36 | // 先创建文件的目录
37 | String path = fileName.substring(0, fileName.lastIndexOf('.'));
38 | File pFile = new File(path);
39 | pFile.mkdirs();
40 | }
41 | // 创建文件输出流
42 | FileOutputStream fos = new FileOutputStream(fo);
43 | // 创建XML文件对象输出类实例
44 | XMLEncoder encoder = new XMLEncoder(fos);
45 | // 对象序列化输出到XML文件
46 | encoder.writeObject(obj);
47 | encoder.flush();
48 | // 关闭序列化工具
49 | encoder.close();
50 | // 关闭输出流
51 | fos.close();
52 | } catch (FileNotFoundException e1) {
53 | e1.printStackTrace();
54 | } catch (IOException e1) {
55 | e1.printStackTrace();
56 | } catch (Exception e1) {
57 | e1.printStackTrace();
58 | }
59 | }
60 |
61 | /**
62 | * 读取由objSource指定的XML文件中的序列化保存的对象,返回的结果经过了List封装
63 | *
64 | * @param objSource
65 | * 带全部文件路径的文件全名
66 | * @return 由XML文件里面保存的对象构成的List列表(可能是一个或者多个的序列化保存的对象)
67 | * @throws FileNotFoundException
68 | * 指定的对象读取资源不存在
69 | * @throws IOException
70 | * 读取发生错误
71 | * @throws Exception
72 | * 其他运行时异常发生
73 | */
74 | public static Object objectXmlDecoder(String objSource) {
75 | Object obj = null;
76 | try {
77 | File fin = new File(objSource);
78 | if(fin.exists()){
79 | FileInputStream fis = new FileInputStream(fin);
80 | XMLDecoder decoder = new XMLDecoder(fis);
81 | obj = decoder.readObject();
82 | fis.close();
83 | decoder.close();
84 | }
85 | } catch (FileNotFoundException e1) {
86 | e1.printStackTrace();
87 | } catch (IOException e1) {
88 | e1.printStackTrace();
89 | } catch (Exception e1) {
90 | e1.printStackTrace();
91 | }
92 | return obj;
93 | }
94 |
95 | /**
96 | * @return
97 | */
98 | public static String getDataSourceFileName(){
99 | String userDir = System.getProperty("user.dir");
100 | String fileName = userDir +"\\datasource.xml";
101 | return fileName;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/swing2swt.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thinkgem/jeesite_autocode/485b381db107e63aa1341a8a5d2b6489b162e791/swing2swt.jar
--------------------------------------------------------------------------------