update codegen js
This commit is contained in:
parent
8831529251
commit
5f7c00d4e4
45
pom.xml
45
pom.xml
@ -21,13 +21,15 @@
|
||||
<properties>
|
||||
<maven.compiler.source>1.6</maven.compiler.source>
|
||||
<maven.compiler.target>1.6</maven.compiler.target>
|
||||
<spring.version>4.3.6.RELEASE</spring.version>
|
||||
<spring.version>4.3.7.RELEASE</spring.version>
|
||||
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
|
||||
<slf4j.version>1.7.23</slf4j.version>
|
||||
<log4j.version>2.7</log4j.version>
|
||||
<shiro.version>1.3.2</shiro.version>
|
||||
<aspectj.version>1.8.10</aspectj.version>
|
||||
<main.class>Main</main.class>
|
||||
<maven.tomcat.port>8080</maven.tomcat.port>
|
||||
<maven.tomcat.path>/</maven.tomcat.path>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
@ -364,6 +366,18 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.coderplus.maven.plugins</groupId>
|
||||
<artifactId>copy-rename-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@ -589,13 +603,38 @@
|
||||
<artifactId>tomcat7-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<configuration>
|
||||
<port>8080</port>
|
||||
<path>/</path>
|
||||
<port>${maven.tomcat.port}</port>
|
||||
<path>${maven.tomcat.path}</path>
|
||||
<charset>utf-8</charset>
|
||||
<uriEncoding>utf-8</uriEncoding>
|
||||
<contextReloadable>false</contextReloadable>
|
||||
<systemProperties>
|
||||
<http.port>${maven.tomcat.port}</http.port>
|
||||
<project.basedir>${project.basedir}</project.basedir>
|
||||
</systemProperties>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<addResources>true</addResources>
|
||||
<mainClass>${start-class}</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
<jvmArguments>
|
||||
-Xdebug
|
||||
-Dproject.basedir=${project.basedir}
|
||||
</jvmArguments>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-help-plugin</artifactId>
|
||||
|
@ -30,6 +30,10 @@
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
<artifactId>tigon-webmvc-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.chyxion.tigon</groupId>
|
||||
<artifactId>tigon-service-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-jdbc</artifactId>
|
||||
|
@ -1,6 +1,9 @@
|
||||
package me.chyxion.tigon.codegen.service.support;
|
||||
|
||||
import me.chyxion.tigon.mybatis.Table;
|
||||
import me.chyxion.tigon.service.BaseCrudService;
|
||||
import me.chyxion.tigon.service.BaseService;
|
||||
import me.chyxion.tigon.service.support.BaseCrudServiceSupport;
|
||||
import me.chyxion.tigon.util.WordUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -26,12 +29,6 @@ import me.chyxion.tigon.model.M0;
|
||||
import me.chyxion.tigon.model.M1;
|
||||
import me.chyxion.tigon.model.M2;
|
||||
import me.chyxion.tigon.model.M3;
|
||||
/*
|
||||
import me.chyxion.tigon.webmvc.annotations.Mock;
|
||||
import me.chyxion.tigon.webmvc.controller.BaseController;
|
||||
import me.chyxion.tigon.webmvc.service.BaseService;
|
||||
import me.chyxion.tigon.webmvc.service.support.BaseServiceSupport;
|
||||
*/
|
||||
import me.chyxion.tigon.webmvc.test.ControllerTestTool;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -114,17 +111,18 @@ public class CodeGenServiceSupport implements CodeGenService {
|
||||
String baseModelFullName = null;
|
||||
Collection<String> baseCols = null;
|
||||
if (colNames.containsAll(new M3<String, String>().cols())) {
|
||||
baseModelName = M3.class.getSimpleName();
|
||||
baseModelName = M3.class.getSimpleName() +
|
||||
"<" + idType + ", " + idType + ">";
|
||||
baseModelFullName = M3.class.getName();
|
||||
baseCols = new M3<String, String>().cols();
|
||||
}
|
||||
else if (colNames.containsAll(new M2<String>().cols())) {
|
||||
baseModelName = M2.class.getSimpleName();
|
||||
baseModelName = M2.class.getSimpleName() + "<" + idType + ">";
|
||||
baseModelFullName = M2.class.getName();
|
||||
baseCols = new M2<String>().cols();
|
||||
}
|
||||
else if (colNames.containsAll(new M1<String>().cols())) {
|
||||
baseModelName = M1.class.getSimpleName();
|
||||
baseModelName = M1.class.getSimpleName() + "<" + idType + ">";
|
||||
baseModelFullName = M1.class.getName();
|
||||
baseCols = new M1<String>().cols();
|
||||
}
|
||||
@ -143,8 +141,7 @@ public class CodeGenServiceSupport implements CodeGenService {
|
||||
baseTool.getConfig("super.base.model.full.name");
|
||||
|
||||
fmDataModel.put("baseModelName",
|
||||
baseTool.getConfig("super.base.model.name",
|
||||
baseModelName + "<" + idType + ">"));
|
||||
baseTool.getConfig("super.base.model.name", baseModelName));
|
||||
|
||||
fmDataModel.put("baseModelFullName",
|
||||
"NONE".equalsIgnoreCase(cfgBaseModelFullName) ? null :
|
||||
@ -204,14 +201,15 @@ public class CodeGenServiceSupport implements CodeGenService {
|
||||
// super classes name
|
||||
fmDataModel.put("baseControllerName", BaseController.class.getSimpleName());
|
||||
fmDataModel.put("baseControllerFullName", BaseController.class.getName());
|
||||
// service interface
|
||||
fmDataModel.put("baseServiceName", BaseService.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceFullName", BaseService.class.getName());
|
||||
// server support
|
||||
fmDataModel.put("baseServiceSupportName", BaseServiceSupport.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceSupportFullName", BaseServiceSupport.class.getName());
|
||||
*/
|
||||
|
||||
// service interface
|
||||
fmDataModel.put("baseServiceName", BaseCrudService.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceFullName", BaseService.class.getName());
|
||||
// server support
|
||||
fmDataModel.put("baseServiceSupportName", BaseCrudServiceSupport.class.getSimpleName());
|
||||
fmDataModel.put("baseServiceSupportFullName", BaseCrudServiceSupport.class.getName());
|
||||
|
||||
// model
|
||||
//
|
||||
// mapper
|
||||
|
@ -1,6 +1,5 @@
|
||||
/**
|
||||
* @version 0.0.1
|
||||
* @since 0.0.1
|
||||
* @author Auto Generated <br>
|
||||
* Tech Support <a href="mailto:chyxion@163.com">Shaun Chyxion</a><br>
|
||||
* ${now}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package ${pkg}.services.support;
|
||||
package ${pkg}.service.support;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ${baseServiceSupportFullName};
|
||||
import ${pkg}.mappers.${ModelName}Mapper;
|
||||
import ${pkg}.models.${ModelName};
|
||||
import ${pkg}.services.${ModelName}Service;
|
||||
import ${pkg}.mapper.${ModelName}Mapper;
|
||||
import ${pkg}.model.${ModelName};
|
||||
import ${pkg}.service.${ModelName}Service;
|
||||
|
||||
${objDoc}
|
||||
@Service
|
||||
public class ${ModelName}ServiceSupport
|
||||
extends ${baseServiceSupportName}<${ModelName}, ${ModelName}Mapper>
|
||||
extends ${baseServiceSupportName}<${idType}, ${ModelName}, ${ModelName}Mapper>
|
||||
implements ${ModelName}Service {
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package ${pkg}.services;
|
||||
package ${pkg}.service;
|
||||
|
||||
import ${baseServiceFullName};
|
||||
import ${pkg}.models.${ModelName};
|
||||
import ${pkg}.model.${ModelName};
|
||||
|
||||
${objDoc}
|
||||
public interface ${ModelName}Service extends ${baseServiceName}<${ModelName}> {
|
||||
public interface ${ModelName}Service extends ${baseServiceName}<${idType}, ${ModelName}> {
|
||||
|
||||
}
|
||||
|
@ -7,8 +7,7 @@
|
||||
*/
|
||||
Ext.define ('Tigon.views.CodeGen', {
|
||||
extend: 'Ext.container.Container',
|
||||
alternateClassName: ['SpringExt.views.CodeGen'],
|
||||
title: 'Auto Code',
|
||||
title: 'Tigon Code Gen',
|
||||
layout: 'border',
|
||||
items: [{
|
||||
xtype: 'container',
|
||||
@ -32,8 +31,8 @@ Ext.define ('Tigon.views.CodeGen', {
|
||||
handler: function () {
|
||||
var t = this.up('treepanel');
|
||||
Ext.MessageBox.show({
|
||||
title: 'Are You Sure?',
|
||||
msg: 'Are You Sure To Remove Model(s) Selected Without Drop Tables?',
|
||||
title: 'Are you sure?',
|
||||
msg: 'Are you sure to remove model(s) selected without drop tables?',
|
||||
buttons: Ext.MessageBox.YESNOCANCEL,
|
||||
fn: function(btn) {
|
||||
if (btn != 'cancel') {
|
||||
@ -62,7 +61,7 @@ Ext.define ('Tigon.views.CodeGen', {
|
||||
form.getForm().reset();
|
||||
form.down('grid').getStore().removeAll();
|
||||
// remove demo grid
|
||||
rc.down('container[name=demo_grid]').removeAll();
|
||||
// rc.down('container[name=demo_grid]').removeAll();
|
||||
Message.alert('Remove Success.');
|
||||
});
|
||||
}
|
||||
@ -88,12 +87,12 @@ Ext.define ('Tigon.views.CodeGen', {
|
||||
form.getForm().setValues(rec.getData());
|
||||
form.down('grid').getStore().loadData(rec.get('cols'));
|
||||
// show demo grid
|
||||
var dg = rc.down('container[name=demo_grid]');
|
||||
dg.removeAll();
|
||||
// var dg = rc.down('container[name=demo_grid]');
|
||||
// dg.removeAll();
|
||||
// load view
|
||||
dg.add(Ext.create('App.views.' +
|
||||
(rec.get('module') ? rec.get('module') + '.' : '') +
|
||||
rec.get('model') + '.List'));
|
||||
// dg.add(Ext.create('App.views.' +
|
||||
// (rec.get('module') ? rec.get('module') + '.' : '') +
|
||||
// rec.get('model') + '.List'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,6 +100,13 @@ Ext.define ('Tigon.views.CodeGen', {
|
||||
title: 'Tables',
|
||||
split: true,
|
||||
region: 'center',
|
||||
tbar: [{
|
||||
text: 'Reload',
|
||||
iconCls: 'refresh',
|
||||
handler: function () {
|
||||
this.up('treepanel').getStore().reload();
|
||||
}
|
||||
}],
|
||||
store: Store.tree({
|
||||
url: 'codegen/tables',
|
||||
fields: ['id', 'text', 'module', 'model', 'cols', 'table'],
|
||||
@ -110,328 +116,317 @@ Ext.define ('Tigon.views.CodeGen', {
|
||||
select: function(rm, rec) {
|
||||
if (rec.isLeaf()) {
|
||||
// right container
|
||||
var rc = this.up().next('container');
|
||||
form = rc.down('form');
|
||||
form.getForm().setValues(Ext.merge(rec.getData(), {
|
||||
createTable: false
|
||||
}));
|
||||
var form = this.up().next('form');
|
||||
form.getForm().setValues(Ext.merge(rec.getData(), {
|
||||
createTable: false
|
||||
}));
|
||||
form.down('grid').getStore().loadData(rec.get('cols'));
|
||||
// show demo grid
|
||||
var dg = rc.down('container[name=demo_grid]');
|
||||
dg.removeAll();
|
||||
// var dg = rc.down('container[name=demo_grid]');
|
||||
// dg.removeAll();
|
||||
// load view
|
||||
dg.add(Ext.create('App.views.' +
|
||||
(rec.get('module') ? rec.get('module') + '.' : '') +
|
||||
rec.get('model') + '.List'));
|
||||
// dg.add(Ext.create('App.views.' +
|
||||
// (rec.get('module') ? rec.get('module') + '.' : '') +
|
||||
// rec.get('model') + '.List'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
xtype: 'container',
|
||||
xtype: 'form',
|
||||
region: 'center',
|
||||
layout: 'border',
|
||||
items: [{
|
||||
xtype: 'form',
|
||||
region: 'north',
|
||||
split: true,
|
||||
height: 312,
|
||||
autoScroll: true,
|
||||
bodyPadding: 12,
|
||||
layout: 'vbox',
|
||||
defaults: {
|
||||
width: '96%',
|
||||
labelWidth: 86
|
||||
},
|
||||
tbar: [{
|
||||
text: 'New Model',
|
||||
iconCls: 'add',
|
||||
handler: function(btn) {
|
||||
var form = btn.up('form'),
|
||||
s = form.down('grid').getStore();
|
||||
s.removeAll();
|
||||
s.add({
|
||||
name: 'id',
|
||||
javaType: 'String',
|
||||
col: 'id',
|
||||
sqlType: 'varchar(36)'
|
||||
}, {
|
||||
name: 'dateCreated',
|
||||
javaType: 'Date',
|
||||
col: 'date_created',
|
||||
sqlType: 'datetime'
|
||||
}, {
|
||||
name: 'dateUpdated',
|
||||
javaType: 'Date',
|
||||
col: 'date_updated',
|
||||
sqlType: 'datetime'
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: 'Generate!',
|
||||
iconCls: 'save',
|
||||
handler: function(btn) {
|
||||
var form = btn.up('form');
|
||||
if (form.isValid()) {
|
||||
var s = form.down('grid').getStore();
|
||||
if (s.getCount()) {
|
||||
var params = form.getForm().getValues(),
|
||||
columns = [];
|
||||
s.each(function(rec) {
|
||||
columns.push(rec.getData());
|
||||
split: true,
|
||||
height: 312,
|
||||
autoScroll: true,
|
||||
bodyPadding: 12,
|
||||
layout: 'vbox',
|
||||
defaults: {
|
||||
width: '96%',
|
||||
labelWidth: 86
|
||||
},
|
||||
tbar: [{
|
||||
text: 'New model',
|
||||
iconCls: 'add',
|
||||
handler: function(btn) {
|
||||
var form = btn.up('form'),
|
||||
s = form.down('grid').getStore();
|
||||
s.removeAll();
|
||||
s.add({
|
||||
name: 'id',
|
||||
javaType: 'String',
|
||||
col: 'id',
|
||||
sqlType: 'varchar(36)'
|
||||
}, {
|
||||
name: 'dateCreated',
|
||||
javaType: 'Date',
|
||||
col: 'date_created',
|
||||
sqlType: 'datetime'
|
||||
}, {
|
||||
name: 'dateUpdated',
|
||||
javaType: 'Date',
|
||||
col: 'date_updated',
|
||||
sqlType: 'datetime'
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: 'Generate!',
|
||||
iconCls: 'save',
|
||||
handler: function(btn) {
|
||||
var form = btn.up('form');
|
||||
if (form.isValid()) {
|
||||
var s = form.down('grid').getStore();
|
||||
if (s.getCount()) {
|
||||
var params = form.getForm().getValues(),
|
||||
columns = [];
|
||||
s.each(function(rec) {
|
||||
columns.push(rec.getData());
|
||||
});
|
||||
params.columns = columns;
|
||||
Dialog.confirm(s.collect('isKey').length > 1 ?
|
||||
'Are you sure to submit?' :
|
||||
'No primary key, are you sure to submit?', function() {
|
||||
Ajax.post('codegen', params, function() {
|
||||
form.previousNode('treepanel')
|
||||
.previousNode('treepanel')
|
||||
.getStore()
|
||||
.reload();
|
||||
Message.alert('Generate successfully.');
|
||||
});
|
||||
params.columns = columns;
|
||||
Dialog.confirm(s.collect('isKey').length > 1 ?
|
||||
'Are You Sure To Submit?' :
|
||||
'No Primary Key, Are You Sure To Submit?', function() {
|
||||
Ajax.post('codegen', params, function() {
|
||||
form.up().previousNode('treepanel')
|
||||
.previousNode('treepanel')
|
||||
.getStore()
|
||||
.reload();
|
||||
Message.alert('Generate Success.');
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
Message.warn('No Columns.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
items: [{
|
||||
xtype: 'box',
|
||||
html: [
|
||||
'<span style="color: #333;">Note: </span>',
|
||||
'Welcome.'
|
||||
].join(''),
|
||||
padding: '0 0 12 0',
|
||||
style: {
|
||||
fontSize: '12pt',
|
||||
color: '#00F'
|
||||
},
|
||||
}, {
|
||||
fieldLabel: 'Options',
|
||||
xtype: 'checkboxgroup',
|
||||
defaults: {
|
||||
checked: true,
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
},
|
||||
columns: 3,
|
||||
items: [{
|
||||
boxLabel: 'Gen controller',
|
||||
name: 'genController'
|
||||
}, {
|
||||
boxLabel: 'Gen service',
|
||||
name: 'genService'
|
||||
}, {
|
||||
boxLabel: 'Gen mapper',
|
||||
name: 'genMapper'
|
||||
}, {
|
||||
boxLabel: 'Gen model',
|
||||
name: 'genModel'
|
||||
}, {
|
||||
boxLabel: 'Gen table',
|
||||
name: 'genTable'
|
||||
}, {
|
||||
boxLabel: 'Gen form',
|
||||
checked: false,
|
||||
name: 'genView'
|
||||
}, {
|
||||
boxLabel: 'Create table',
|
||||
checked: false,
|
||||
name: 'createTable'
|
||||
}]
|
||||
}, {
|
||||
xtype: 'fieldcontainer',
|
||||
fieldLabel: 'Columns',
|
||||
items: {
|
||||
xtype: 'grid',
|
||||
minHeight: 128,
|
||||
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
|
||||
clicksToEdit: 1
|
||||
})],
|
||||
store: {
|
||||
store: 'json',
|
||||
fields: ['name', 'javaType', 'col', 'sqlType',
|
||||
{name: 'notNull', type: 'boolean', defaultValue: true},
|
||||
{name: 'isKey', type: 'boolean', defaultValue: false},
|
||||
{name: 'isIndex', type: 'boolean', defaultValue: false}]
|
||||
},
|
||||
columns: [{
|
||||
xtype: 'rownumberer'
|
||||
}, {
|
||||
dataIndex: 'name',
|
||||
text: 'Property name',
|
||||
width: 128,
|
||||
editor: {
|
||||
xtype: 'textfield',
|
||||
allowBlank: false,
|
||||
listeners: {
|
||||
change: function(t, nv, ov) {
|
||||
t.up().up()
|
||||
.getSelectionModel()
|
||||
.getLastSelected()
|
||||
.set('col',
|
||||
nv.split(/(?=[A-Z])(?=[A-Z][a-z])|(?=[^A-Z])(?=[A-Z])|(?=[^a-zA-Z])(?=[a-z])|(?=[A-Za-z])(?=[^A-Za-z])/)
|
||||
.join('_').
|
||||
toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'javaType',
|
||||
text: 'Java Type',
|
||||
flex: 1,
|
||||
editor: {
|
||||
xtype: 'combo',
|
||||
typeAhead: true,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: [
|
||||
['String', 'String'],
|
||||
['int', 'int'],
|
||||
['Integer', 'Integer'],
|
||||
['long', 'long'],
|
||||
['Long', 'Long'],
|
||||
['double', 'double'],
|
||||
['Double', 'Double'],
|
||||
['Date', 'Date'],
|
||||
['boolean', 'boolean'],
|
||||
['Boolean', 'Boolean'],
|
||||
['byte', 'byte'],
|
||||
['Byte', 'Byte'],
|
||||
['byte[]', 'byte[]'],
|
||||
['Byte[]', 'Byte[]']
|
||||
]
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'col',
|
||||
text: 'Column name',
|
||||
width: 128,
|
||||
editor: {
|
||||
xtype: 'textfield'
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'sqlType',
|
||||
text: 'SQL type',
|
||||
flex: 1,
|
||||
editor: {
|
||||
allowBlank: false,
|
||||
xtype: 'combo',
|
||||
typeAhead: true,
|
||||
editable: true,
|
||||
triggerAction: 'all',
|
||||
store: [
|
||||
['date', 'date'],
|
||||
['datetime', 'datetime'],
|
||||
['char(36)', 'char(36)'],
|
||||
['varchar(36)', 'varchar(36)'],
|
||||
['bit', 'bit'],
|
||||
['bigint', 'bigint'],
|
||||
['int', 'int'],
|
||||
['float', 'float']
|
||||
]
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'notNull',
|
||||
text: 'Not Null',
|
||||
width: 76,
|
||||
renderer: function(v) {
|
||||
return v || '';
|
||||
},
|
||||
editor: {
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'isKey',
|
||||
text: 'Primary key',
|
||||
width: 76,
|
||||
renderer: function(v) {
|
||||
return v || '';
|
||||
},
|
||||
editor: {
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
}
|
||||
}],
|
||||
tbar: [{
|
||||
text: 'Add column',
|
||||
iconCls: 'add',
|
||||
handler: function () {
|
||||
var s = this.up('grid').getStore(),
|
||||
name = 0;
|
||||
Ext.each(s.collect('name'), function(col) {
|
||||
var m = col.match(/^name(\d*)$/);
|
||||
if (m) {
|
||||
var num = parseInt(m[1]);
|
||||
if (isNaN(num)) {
|
||||
name = 1;
|
||||
}
|
||||
else if (num + 1 > name) {
|
||||
name = num + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
name = 'name' + (name ? name : '');
|
||||
s.add({
|
||||
name: name,
|
||||
javaType: 'String',
|
||||
col: name,
|
||||
sqlType: 'varchar(36)',
|
||||
notNull: true,
|
||||
isKey: false
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: 'Remove column',
|
||||
iconCls: 'remove',
|
||||
handler: function (btn) {
|
||||
var g = btn.up('grid'),
|
||||
ss = g.getSelectionModel().getSelection();
|
||||
if (ss.length) {
|
||||
Dialog.confirm(
|
||||
'Are you sure to remove the column selected?',
|
||||
function() {
|
||||
g.getStore().remove(ss);
|
||||
});
|
||||
}
|
||||
else {
|
||||
Message.warn('No Columns.');
|
||||
Message.warn('Please Select Column To Remove.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}],
|
||||
items: [{
|
||||
xtype: 'box',
|
||||
html: [
|
||||
'<span style="color: #333;">Note: </span>',
|
||||
'Welcome.'
|
||||
].join(''),
|
||||
padding: '0 0 12 0',
|
||||
style: {
|
||||
fontSize: '12pt',
|
||||
color: '#00F'
|
||||
},
|
||||
}, {
|
||||
fieldLabel: 'Options',
|
||||
xtype: 'checkboxgroup',
|
||||
defaults: {
|
||||
checked: true,
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
},
|
||||
columns: 3,
|
||||
items: [{
|
||||
boxLabel: 'Gen Controller',
|
||||
name: 'genController'
|
||||
}, {
|
||||
boxLabel: 'Gen Service',
|
||||
name: 'genService'
|
||||
}, {
|
||||
boxLabel: 'Gen Mapper',
|
||||
name: 'genMapper'
|
||||
}, {
|
||||
boxLabel: 'Gen Model',
|
||||
name: 'genModel'
|
||||
}, {
|
||||
boxLabel: 'Gen Table',
|
||||
name: 'genTable'
|
||||
}, {
|
||||
boxLabel: 'Gen View',
|
||||
checked: false,
|
||||
name: 'genView'
|
||||
}, {
|
||||
boxLabel: 'Create Table',
|
||||
checked: false,
|
||||
name: 'createTable'
|
||||
}]
|
||||
}, {
|
||||
xtype: 'fieldcontainer',
|
||||
fieldLabel: 'Columns',
|
||||
items: {
|
||||
xtype: 'grid',
|
||||
minHeight: 128,
|
||||
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
|
||||
clicksToEdit: 1
|
||||
})],
|
||||
store: {
|
||||
store: 'json',
|
||||
fields: ['name', 'javaType', 'col', 'sqlType',
|
||||
{name: 'notNull', type: 'boolean', defaultValue: true},
|
||||
{name: 'isKey', type: 'boolean', defaultValue: false},
|
||||
{name: 'isIndex', type: 'boolean', defaultValue: false}]
|
||||
},
|
||||
columns: [{
|
||||
xtype: 'rownumberer'
|
||||
}, {
|
||||
dataIndex: 'name',
|
||||
text: 'Property Name',
|
||||
width: 128,
|
||||
editor: {
|
||||
xtype: 'textfield',
|
||||
allowBlank: false,
|
||||
listeners: {
|
||||
change: function(t, nv, ov) {
|
||||
t.up().up()
|
||||
.getSelectionModel()
|
||||
.getLastSelected()
|
||||
.set('col',
|
||||
nv.split(/(?=[A-Z])(?=[A-Z][a-z])|(?=[^A-Z])(?=[A-Z])|(?=[^a-zA-Z])(?=[a-z])|(?=[A-Za-z])(?=[^A-Za-z])/)
|
||||
.join('_').
|
||||
toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'javaType',
|
||||
text: 'Java Type',
|
||||
flex: 1,
|
||||
editor: {
|
||||
xtype: 'combo',
|
||||
typeAhead: true,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: [
|
||||
['String', 'String'],
|
||||
['int', 'int'],
|
||||
['Integer', 'Integer'],
|
||||
['long', 'long'],
|
||||
['Long', 'Long'],
|
||||
['double', 'double'],
|
||||
['Double', 'Double'],
|
||||
['Date', 'Date'],
|
||||
['boolean', 'boolean'],
|
||||
['Boolean', 'Boolean'],
|
||||
['byte', 'byte'],
|
||||
['Byte', 'Byte'],
|
||||
['byte[]', 'byte[]'],
|
||||
['Byte[]', 'Byte[]']
|
||||
]
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'col',
|
||||
text: 'Column Name',
|
||||
width: 128,
|
||||
editor: {
|
||||
xtype: 'textfield'
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'sqlType',
|
||||
text: 'SQL Type',
|
||||
flex: 1,
|
||||
editor: {
|
||||
allowBlank: false,
|
||||
xtype: 'combo',
|
||||
typeAhead: true,
|
||||
editable: true,
|
||||
triggerAction: 'all',
|
||||
store: [
|
||||
['date', 'date'],
|
||||
['datetime', 'datetime'],
|
||||
['char(36)', 'char(36)'],
|
||||
['varchar(36)', 'varchar(36)'],
|
||||
['bit', 'bit'],
|
||||
['bigint', 'bigint'],
|
||||
['int', 'int'],
|
||||
['float', 'float']
|
||||
]
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'notNull',
|
||||
text: 'Not Null',
|
||||
width: 76,
|
||||
renderer: function(v) {
|
||||
return v || '';
|
||||
},
|
||||
editor: {
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
}
|
||||
}, {
|
||||
dataIndex: 'isKey',
|
||||
text: 'Primary Key',
|
||||
width: 76,
|
||||
renderer: function(v) {
|
||||
return v || '';
|
||||
},
|
||||
editor: {
|
||||
xtype: 'checkbox',
|
||||
inputValue: true
|
||||
}
|
||||
}],
|
||||
tbar: [{
|
||||
text: 'Add Column',
|
||||
iconCls: 'add',
|
||||
handler: function () {
|
||||
var s = this.up('grid').getStore(),
|
||||
name = 0;
|
||||
Ext.each(s.collect('name'), function(col) {
|
||||
var m = col.match(/^name(\d*)$/);
|
||||
if (m) {
|
||||
var num = parseInt(m[1]);
|
||||
if (isNaN(num)) {
|
||||
name = 1;
|
||||
}
|
||||
else if (num + 1 > name) {
|
||||
name = num + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
name = 'name' + (name ? name : '');
|
||||
s.add({
|
||||
name: name,
|
||||
javaType: 'String',
|
||||
col: name,
|
||||
sqlType: 'varchar(36)',
|
||||
notNull: true,
|
||||
isKey: false
|
||||
});
|
||||
}
|
||||
}, {
|
||||
text: 'Remove Column',
|
||||
iconCls: 'remove',
|
||||
handler: function (btn) {
|
||||
var g = btn.up('grid'),
|
||||
ss = g.getSelectionModel().getSelection();
|
||||
if (ss.length) {
|
||||
Dialog.confirm(
|
||||
'Are You Sure To Remove The Column Selected.',
|
||||
function() {
|
||||
g.getStore().remove(ss);
|
||||
});
|
||||
}
|
||||
else {
|
||||
Message.warn('Please Select Column To Remove.');
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'pkg',
|
||||
fieldLabel: 'Base Package',
|
||||
allowBlank: true,
|
||||
emptyText: 'Default Base Package (' + pkg + ').'
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'module',
|
||||
fieldLabel: 'Module',
|
||||
emptyText: 'Subpackage Of Base Package.'
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'model',
|
||||
fieldLabel: 'Model Name',
|
||||
value: 'ModelName',
|
||||
allowBlank: false
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'table',
|
||||
fieldLabel: 'Table Name',
|
||||
allowBlank: false
|
||||
}]
|
||||
}
|
||||
}, {
|
||||
xtype: 'container',
|
||||
region: 'center',
|
||||
name: 'demo_grid',
|
||||
layout: 'fit'
|
||||
xtype: 'textfield',
|
||||
name: 'pkg',
|
||||
fieldLabel: 'Base package',
|
||||
allowBlank: true,
|
||||
emptyText: 'Default base package (' + pkg + ').'
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'module',
|
||||
fieldLabel: 'Module',
|
||||
emptyText: 'Subpackage of base package.'
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'model',
|
||||
fieldLabel: 'Model name',
|
||||
value: 'ModelName',
|
||||
allowBlank: false
|
||||
}, {
|
||||
xtype: 'textfield',
|
||||
name: 'table',
|
||||
fieldLabel: 'Table name',
|
||||
allowBlank: false
|
||||
}]
|
||||
}]
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user