上传代码

This commit is contained in:
zhangdongxu
2017-12-19 14:55:52 +08:00
commit 13acafd43d
4777 changed files with 898870 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
/**
* 硕正TreeList Properties Background
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Background")
public class Background {
/**
* 背景颜色
*/
@XStreamAsAttribute
private String bgColor = "#FDFDFD";
public Background() {
}
public Background(SupBackground supBackground) {
this();
ObjectUtils.annotationToObject(supBackground, this);
}
public Background(String bgColor) {
this();
this.bgColor = bgColor;
}
public String getBgColor() {
return bgColor;
}
public void setBgColor(String bgColor) {
this.bgColor = bgColor;
}
}

View File

@@ -0,0 +1,542 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;
/**
* 硕正TreeList Cols Col
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Col")
@XStreamConverter(value = ToAttributedValueConverter.class, strings = {"text"})
public class Col {
///////////////////////////////////// 主要 //////////////////////////////////////
/**
* 列名 串, 相当于字段名
*/
@XStreamAsAttribute
private String name;
/**
* 内容是否允许重复 true/false
*/
@XStreamAsAttribute
private String isUnique = "false";
/**
* 是否允许为空 true/false
*/
@XStreamAsAttribute
private String nullAble = "true";
/**
* 默认值 串, 用于新插入行操作时的初始, 支持以 "=" 开头的表达式,例如 defaultValue="=now( )", 表示将日期型默认值设为当天 (无)
* 注: 仅对新插入的行有效
*/
@XStreamAsAttribute
private String defaultValue;
/**
* 数据类型 有 string / int / double / bool / date / datetime 这几种
*/
@XStreamAsAttribute
private String dataType;
/**
* 小数位数 -1至8, 仅用于 double 型。 -1表示小数位数不确定, 可以在0位和8位之间可以任意输入, 默认: 2
*/
@XStreamAsAttribute
private String decimal;
/**
* 是否超链接列 true/false false
*/
@XStreamAsAttribute
private String isHyperlink;
/**
* 是否隐藏, true - 隐藏;
* false - 显示;
* absHide 或 absTrue - 绝对隐藏,不会被鼠标右键菜单选择;
* absShow 或 absFalse - 绝对显示,不会被鼠标右键菜单选择;
*/
@XStreamAsAttribute
private String isHide;
/**
* 点击列标题是否执行排序 true/false ,默认true
* 注: 如果<Properties>中的sortAble设为false, 则本sortAble无效(false)
*/
@XStreamAsAttribute
private String sortAble;
/**
* 是否允许列的拖动操作 ,默认true
* 注: 如果<Properties>中的moveAble设为false, 则本moveAble无效(false)
*/
@XStreamAsAttribute
private String moveAble;
/**
* 是否允许被粘贴 ,默认supcan.xml
* true - 允许;
* false - 不允许;
* supcan.xml - 通常是允许,但是当列不可编辑时(包括隐藏时)将以supcan.xml中的 <pasteAbleWhenUnEditAble> 的设定为准;
*/
@XStreamAsAttribute
private String pasteAble;
/**
* 指向另一列的列名,显示的内容存放在该列中,是另类 key-value对 的简易字典解决方案
*/
@XStreamAsAttribute
private String textId;
///////////////////////////////////// 外观 //////////////////////////////////////
/**
* 是否以千位符分隔显示 true/false 默认true
* 注: 仅用于 datatype 为 int 或 double 时
*/
@XStreamAsAttribute
private String isThousandSeparat;
/**
* 列宽 整数 - 绝对宽度 (单位:像素数);
* 百分比 - 窗口宽度的百分比, 如20%;
* 为小于1的分数 - 比例因子,用于分配剩余的宽度, 如0.2;
* fitHeader 或 header - 自动伸展到能使表头标题能够完整显示;
*/
@XStreamAsAttribute
private String width;
/**
* 列的最小宽度 像素数 10
*/
@XStreamAsAttribute
private String minWidth;
/**
* 水平对齐 left / center / right
*/
@XStreamAsAttribute
private String align;
/**
* 垂直对齐 top / vcenter(或middle) / bottom vcenter
*/
@XStreamAsAttribute
private String vAlign;
/**
* 列标题文字的对齐 left / center / right center
*/
@XStreamAsAttribute
private String alignHeader;
/**
* 采用的字体 数字,指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性 -1
*/
@XStreamAsAttribute
private String fontIndex;
/**
* 列标题采用的字体 数字,指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性 -1
*/
@XStreamAsAttribute
private String headerFontIndex;
/**
* 列标题文字颜色 颜色串 #000000
*/
@XStreamAsAttribute
private String headerTextColor;
/**
* 列标题旁边的小图标 可以是图标的URL, 也可以是如下格式的串:
*   url=[?];pos=[?]
* pos用于指定图标的位置, 是水平(left/right)、 垂直(top/middle/bottom)方向的组合. 举例如下:
*   url=../ac.png;pos=right,bottom
* 建议采用png或ico这类透明的图片
*/
@XStreamAsAttribute
private String headerIcon;
/**
* 鼠标点击上述小图标时弹出的提示文字 文字串, 如果不定义这个串鼠标点击小图标时将触发Clicked事件
*/
@XStreamAsAttribute
private String headerIconTip;
/**
* 用于显示的格式掩码表达式 表达式的内容包括显示内容、 背景色、 文字色、 左图、 右图. 请详见Treelist帮助文档的"3.几个重要的属性"
* formatDate(data,'YYYY-MM-DD')
* =if(data=='1','关闭',if(data=='2','已完成',if(data=='3','未接收','进行中')))
*/
@XStreamAsAttribute
private String displayMask;
/**
* 位于多层表头的层位置 数字从0开始
*/
@XStreamAsAttribute
private String atLayer;
/**
* 位于多层表头的层位置 数字从0开始
*/
@XStreamAsAttribute
private String extentRows;
/**
* 下拉列(droplis, droptreelist)单元格的文字显示方式 0 - 仅显示文字部分;
* 1 - 仅显示键值(即key)部分;
* 2 - 键值+" - "+文字;
*/
@XStreamAsAttribute
private String dropDisplayType;
/**
* 虚拟列的数据分隔符 串,比如"/", 如果设了这个串,在加载数据后,程序将按这个分隔符自动对各行数据进行处理,使其看上去呈现多列的效果。此外, 各个段中纵向、横向如果有连续相同的数据,将自动呈现纵、横的合并效果 (无)
* 注1: 仅改变显示效果,并不改变数据;
* 注2: VColSep列有诸多限制例如只能用于string型、不能作为树的排序列等等;
*/
@XStreamAsAttribute
private String VColSep;
/**
* VColSepStyle 虚拟列的合并方式 row - 只允许跨行的垂直合并;
* col - 只允许跨列的横向合并;
* row,col - 跨行、跨列自动合并;
*/
@XStreamAsAttribute
private String VColSepStyle;
/**
* 合计表达式
*/
@XStreamAsAttribute
private String totalExpress;
/**
* 小计表达式
*/
@XStreamAsAttribute
private String subTotalExpress;
/**
* 列的显示名称
*/
private String text;
/**
* 归属组ID
*/
@XStreamOmitField
private String groupId;
/**
* 字段排序,注解定义时有效
*/
@XStreamOmitField
private int sort;
public Col() {
}
public Col(String name) {
this.name = name;
}
public Col(String name, String text) {
this(name);
this.text = text;
}
public Col(SupCol supCol){
ObjectUtils.annotationToObject(supCol, this);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIsUnique() {
return isUnique;
}
public void setIsUnique(String isUnique) {
this.isUnique = isUnique;
}
public String getNullAble() {
return nullAble;
}
public void setNullAble(String nullAble) {
this.nullAble = nullAble;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getDecimal() {
return decimal;
}
public void setDecimal(String decimal) {
this.decimal = decimal;
}
public String getIsHyperlink() {
return isHyperlink;
}
public void setIsHyperlink(String isHyperlink) {
this.isHyperlink = isHyperlink;
}
public String getIsHide() {
return isHide;
}
public void setIsHide(String isHide) {
this.isHide = isHide;
}
public String getSortAble() {
return sortAble;
}
public void setSortAble(String sortAble) {
this.sortAble = sortAble;
}
public String getMoveAble() {
return moveAble;
}
public void setMoveAble(String moveAble) {
this.moveAble = moveAble;
}
public String getPasteAble() {
return pasteAble;
}
public void setPasteAble(String pasteAble) {
this.pasteAble = pasteAble;
}
public String getTextId() {
return textId;
}
public void setTextId(String textId) {
this.textId = textId;
}
public String getIsThousandSeparat() {
return isThousandSeparat;
}
public void setIsThousandSeparat(String isThousandSeparat) {
this.isThousandSeparat = isThousandSeparat;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getMinWidth() {
return minWidth;
}
public void setMinWidth(String minWidth) {
this.minWidth = minWidth;
}
public String getAlign() {
return align;
}
public void setAlign(String align) {
this.align = align;
}
public String getvAlign() {
return vAlign;
}
public void setvAlign(String vAlign) {
this.vAlign = vAlign;
}
public String getAlignHeader() {
return alignHeader;
}
public void setAlignHeader(String alignHeader) {
this.alignHeader = alignHeader;
}
public String getFontIndex() {
return fontIndex;
}
public void setFontIndex(String fontIndex) {
this.fontIndex = fontIndex;
}
public String getHeaderFontIndex() {
return headerFontIndex;
}
public void setHeaderFontIndex(String headerFontIndex) {
this.headerFontIndex = headerFontIndex;
}
public String getHeaderTextColor() {
return headerTextColor;
}
public void setHeaderTextColor(String headerTextColor) {
this.headerTextColor = headerTextColor;
}
public String getHeaderIcon() {
return headerIcon;
}
public void setHeaderIcon(String headerIcon) {
this.headerIcon = headerIcon;
}
public String getHeaderIconTip() {
return headerIconTip;
}
public void setHeaderIconTip(String headerIconTip) {
this.headerIconTip = headerIconTip;
}
public String getDisplayMask() {
return displayMask;
}
public void setDisplayMask(String displayMask) {
this.displayMask = displayMask;
}
public String getAtLayer() {
return atLayer;
}
public void setAtLayer(String atLayer) {
this.atLayer = atLayer;
}
public String getExtentRows() {
return extentRows;
}
public void setExtentRows(String extentRows) {
this.extentRows = extentRows;
}
public String getDropDisplayType() {
return dropDisplayType;
}
public void setDropDisplayType(String dropDisplayType) {
this.dropDisplayType = dropDisplayType;
}
public String getVColSep() {
return VColSep;
}
public void setVColSep(String vColSep) {
VColSep = vColSep;
}
public String getVColSepStyle() {
return VColSepStyle;
}
public void setVColSepStyle(String vColSepStyle) {
VColSepStyle = vColSepStyle;
}
public String getTotalExpress() {
return totalExpress;
}
public void setTotalExpress(String totalExpress) {
this.totalExpress = totalExpress;
}
public String getSubTotalExpress() {
return subTotalExpress;
}
public void setSubTotalExpress(String subTotalExpress) {
this.subTotalExpress = subTotalExpress;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.util.List;
import com.google.common.collect.Lists;
import com.nis.web.security.IdGen;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* 硕正Common
* @author WangZhen
* @version 2013-11-04
*/
public class Common {
/**
* 属性对象
*/
@XStreamAlias("Properties")
protected Properties properties;
/**
* 字体对象
*/
@XStreamAlias("Fonts")
protected List<Font> fonts;
public Common() {
properties = new Properties(IdGen.uuid());
fonts = Lists.newArrayList(
new Font("宋体", "134", "-12"),
new Font("宋体", "134", "-13", "700"));
}
public Common(Properties properties) {
this();
this.properties = properties;
}
public Properties getProperties() {
return properties;
}
public void setProperties(Properties properties) {
this.properties = properties;
}
public List<Font> getFonts() {
return fonts;
}
public void setFonts(List<Font> fonts) {
this.fonts = fonts;
}
}

View File

@@ -0,0 +1,66 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;
/**
* 硕正TreeList Properties Express
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Express")
@XStreamConverter(value = ToAttributedValueConverter.class, strings = {"text"})
public class Express {
/**
* 是否自动按列的引用关系优化计算顺序 默认值true
*/
@XStreamAsAttribute
private String isOpt;
/**
* 文本
*/
private String text;
public Express() {
}
public Express(SupExpress supExpress) {
this();
ObjectUtils.annotationToObject(supExpress, this);
}
public Express(String text) {
this.text = text;
}
public Express(String name, String text) {
this(name);
this.text = text;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getIsOpt() {
return isOpt;
}
public void setIsOpt(String isOpt) {
this.isOpt = isOpt;
}
}

View File

@@ -0,0 +1,143 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
/**
* 硕正TreeList Properties
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Font")
public class Font {
/**
* 字体名称 微软雅黑 宋体
*/
@XStreamAsAttribute
private String faceName;
/**
* 字符集 134
*/
@XStreamAsAttribute
private String charSet;
/**
* Height(或size)是字体的尺寸单位是字体的逻辑单位通常采用小于0的数字
* 如果大于0则高度不包含文字的内部行距(internal-leading)。
* 常用的尺寸是-8, -9, -10, -11, -12, -14, -16, -18, -20, -22, -24, -26, -28, -36, -48, -72;
*/
@XStreamAsAttribute
private String height;
/**
* 字体加粗 weight=400/700 对应 非粗体/粗体;
*/
@XStreamAsAttribute
private String weight;
/**
* 字体宽度
*/
@XStreamAsAttribute
private String width;
/**
* 字体斜体
*/
@XStreamAsAttribute
private String italic;
/**
* 字体下划线
*/
@XStreamAsAttribute
private String underline;
public Font() {
}
public Font(SupFont supFont) {
this();
ObjectUtils.annotationToObject(supFont, this);
}
public Font(String faceName) {
this();
this.faceName = faceName;
}
public Font(String faceName, String charSet, String height) {
this(faceName);
this.charSet = charSet;
this.height = height;
}
public Font(String faceName, String charSet, String height, String weight) {
this(faceName, charSet, height);
this.weight = weight;
}
public String getFaceName() {
return faceName;
}
public void setFaceName(String faceName) {
this.faceName = faceName;
}
public String getCharSet() {
return charSet;
}
public void setCharSet(String charSet) {
this.charSet = charSet;
}
public String getHeight() {
return height;
}
public void setHeight(String height) {
this.height = height;
}
public String getWeight() {
return weight;
}
public void setWeight(String weight) {
this.weight = weight;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getItalic() {
return italic;
}
public void setItalic(String italic) {
this.italic = italic;
}
public String getUnderline() {
return underline;
}
public void setUnderline(String underline) {
this.underline = underline;
}
}

View File

@@ -0,0 +1,25 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* 硕正FreeForm
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("FreeForm")
public class FreeForm extends Common {
public FreeForm() {
super();
}
public FreeForm(Properties properties) {
this();
this.properties = properties;
}
}

View File

@@ -0,0 +1,157 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.util.List;
import com.google.common.collect.Lists;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
/**
* 硕正TreeList Cols Group
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Group")
public class Group {
/**
* 分组的id仅用于加载采用该id代替列名的XML/JSON数据
*/
@XStreamAsAttribute
private String id;
/**
* 显示的文字 串
*/
@XStreamAsAttribute
private String name;
/**
* 采用的字体, 前面定义的<Font>的序号 数字 指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性
*/
@XStreamAsAttribute
private String headerFontIndex;
/**
* 文字颜色 颜色串 #000000
*/
@XStreamAsAttribute
private String textColor;
/**
* 文字对齐 left/center/right center
*/
@XStreamAsAttribute
private String align;
/**
* 分组下的列集合
*/
@XStreamAlias("Cols")
@XStreamImplicit
private List<Object> cols;
/**
* 父级组ID注解定义时有效
*/
@XStreamOmitField
private String parentId;
/**
* 字段排序,注解定义时有效
*/
@XStreamOmitField
private int sort;
public Group() {
}
public Group(String name) {
this();
this.name = name;
}
public Group(String name, List<Object> cols) {
this(name);
this.cols = cols;
}
public Group(SupGroup supGroup){
ObjectUtils.annotationToObject(supGroup, this);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Object> getCols() {
if (cols == null){
cols = Lists.newArrayList();
}
return cols;
}
public void setCols(List<Object> cols) {
this.cols = cols;
}
public String getHeaderFontIndex() {
return headerFontIndex;
}
public void setHeaderFontIndex(String headerFontIndex) {
this.headerFontIndex = headerFontIndex;
}
public String getTextColor() {
return textColor;
}
public void setTextColor(String textColor) {
this.textColor = textColor;
}
public String getAlign() {
return align;
}
public void setAlign(String align) {
this.align = align;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public int getSort() {
return sort;
}
public void setSort(int sort) {
this.sort = sort;
}
}

View File

@@ -0,0 +1,385 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.util.List;
import com.google.common.collect.Lists;
import com.nis.util.ObjectUtils;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
/**
* 硕正TreeList Properties
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("Properties")
public class Properties {
/**
* Treelist的ID 串
*/
@XStreamAsAttribute
private String id;
/**
* 主键 串, 下面<col>的列名,复合主键须以逗号分隔
*/
@XStreamAsAttribute
private String key;
/**
* 是否以树展现 true/false
*/
@XStreamAsAttribute
private String isTree = "false";
/**
* 是否显示左标尺 true/false
* editAble=true时isShowRuler的默认值是true否则是false;
*/
@XStreamAsAttribute
private String isShowRuler = "false";
/**
* 合计行是否固定在底部、始终显示 true/false
*/
@XStreamAsAttribute
private String isFixTotalRow = "false";
/**
* 合计行的背景色 颜色串
*/
@XStreamAsAttribute
private String totalBgColor = "#FFFFCC";
/**
* 小计行的背景色 颜色串
*/
@XStreamAsAttribute
private String subTotalBgColor = "#FFFFCC";
/**
* 是否允许增删改操作 true/false
* editAble=true时isShowRuler的默认值是true否则是false;
*/
@XStreamAsAttribute
private String editAble = "false";
/**
* 是否允许用户增行操作 true/false
* 注1: 仅在editAble=true时生效; 注2: 不影响增删改的API;
*/
@XStreamAsAttribute
private String addRowAble = "true";
/**
* 分屏方式
* true - 始终显示分隔条;
* false - 始终不显示分隔条;
* auto - 自动(超宽时会在左侧浮现分隔条);
*/
@XStreamAsAttribute
private String separateBarStyle = "false";
/**
* 点击列标题是否执行排序 true/false
*/
@XStreamAsAttribute
private String sortAble = "true";
/**
* 是否允许多层表头 true/false
*/
@XStreamAsAttribute
private String multiLayerAble = "false";
/**
* 执行 Load() 函数时的淡入淡出效果 0 - 255, 数值越小效果越明显, 而 0 表示关闭此效果
*/
@XStreamAsAttribute
private String fadeInStep = "0";
/**
* 顶部标题条的背景色 颜色串,可以是以逗号分隔的多个颜色(渐变)
*/
@XStreamAsAttribute
private String headerBgColor = "#FDFDFD,#F0F1EF";
/**
* 顶部标题条的高度 像素数
*/
@XStreamAsAttribute
private String headerHeight = "28";
/**
* 左标尺的背景色,颜色串,可以是以逗号分隔的多个颜色(渐变)
*/
@XStreamAsAttribute
private String leftColor = "#F0F1EF,#FDFDFD";
/**
* 行高像素数
*/
@XStreamAsAttribute
private String rowHeight = "28";
/**
* 当前行的颜色,允许多个颜色渐变
* 颜色串, 支持ARGB格式例如: "#10C0D0E0", 其中 "10" 是 alpha(透明度), "C0D0E0" 是 RGB, 此外, 还支持包含如下边框属性:
*    borderWidth - 边框线宽
*   borderColor - 边框线色
*   borderRound - 边框线的圆角直径
* 示例: "#12FFFFFF,#22EEFFEE; borderWidth=1; borderColor=red; borderRound=8"
*/
@XStreamAsAttribute
private String curSelBgColor = "#F5F5F5,#EDEDED"; // #F5F5F5 #FFE88D
/**
* 整行的背景色、文字色表达式 表达式, 如:
* displayMask = "bgColor=if(price=0, red, transparent); textColor=if(price>2,#000022, blue)"
*/
@XStreamAsAttribute
private String displayMask;
/**
* 指定标题栏默认字体 <Fonts>中的字体顺序号
*/
@XStreamAsAttribute
private String headerFontIndex;
/**
* 设置背景
*/
@XStreamAlias("Background")
private Background packground = new Background();
/**
* 计算列表达式
*/
@XStreamAlias("Expresses")
private List<Express> expresses;
/**
* 打印简易配置 标题
*/
@XStreamAsAttribute
private String title;
public Properties() {
}
public Properties(SupProperties supProperties) {
this();
ObjectUtils.annotationToObject(supProperties, this);
if (supProperties.packground() != null){
this.packground = new Background(supProperties.packground());
}
if (supProperties.expresses() != null){
for (SupExpress supExpress : supProperties.expresses()){
if (this.expresses == null){
this.expresses = Lists.newArrayList();
}
this.expresses.add(new Express(supExpress));
}
}
}
public Properties(String id) {
this();
this.id = id;
}
public Properties(String id, String key) {
this(id);
this.key = key;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getIsTree() {
return isTree;
}
public void setIsTree(String isTree) {
this.isTree = isTree;
}
public String getIsShowRuler() {
return isShowRuler;
}
public void setIsShowRuler(String isShowRuler) {
this.isShowRuler = isShowRuler;
}
public String getIsFixTotalRow() {
return isFixTotalRow;
}
public void setIsFixTotalRow(String isFixTotalRow) {
this.isFixTotalRow = isFixTotalRow;
}
public String getTotalBgColor() {
return totalBgColor;
}
public void setTotalBgColor(String totalBgColor) {
this.totalBgColor = totalBgColor;
}
public String getSubTotalBgColor() {
return subTotalBgColor;
}
public void setSubTotalBgColor(String subTotalBgColor) {
this.subTotalBgColor = subTotalBgColor;
}
public String getEditAble() {
return editAble;
}
public void setEditAble(String editAble) {
this.editAble = editAble;
}
public String getSeparateBarStyle() {
return separateBarStyle;
}
public void setSeparateBarStyle(String separateBarStyle) {
this.separateBarStyle = separateBarStyle;
}
public String getSortAble() {
return sortAble;
}
public void setSortAble(String sortAble) {
this.sortAble = sortAble;
}
public String getMultiLayerAble() {
return multiLayerAble;
}
public void setMultiLayerAble(String multiLayerAble) {
this.multiLayerAble = multiLayerAble;
}
public String getFadeInStep() {
return fadeInStep;
}
public void setFadeInStep(String fadeInStep) {
this.fadeInStep = fadeInStep;
}
public String getHeaderBgColor() {
return headerBgColor;
}
public void setHeaderBgColor(String headerBgColor) {
this.headerBgColor = headerBgColor;
}
public String getHeaderHeight() {
return headerHeight;
}
public void setHeaderHeight(String headerHeight) {
this.headerHeight = headerHeight;
}
public String getLeftColor() {
return leftColor;
}
public void setLeftColor(String leftColor) {
this.leftColor = leftColor;
}
public String getRowHeight() {
return rowHeight;
}
public void setRowHeight(String rowHeight) {
this.rowHeight = rowHeight;
}
public String getCurSelBgColor() {
return curSelBgColor;
}
public void setCurSelBgColor(String curSelBgColor) {
this.curSelBgColor = curSelBgColor;
}
public String getHeaderFontIndex() {
return headerFontIndex;
}
public void setHeaderFontIndex(String headerFontIndex) {
this.headerFontIndex = headerFontIndex;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Background getPackground() {
return packground;
}
public void setPackground(Background packground) {
this.packground = packground;
}
public List<Express> getExpresses() {
return expresses;
}
public void setExpresses(List<Express> expresses) {
this.expresses = expresses;
}
public String getDisplayMask() {
return displayMask;
}
public void setDisplayMask(String displayMask) {
this.displayMask = displayMask;
}
public String getAddRowAble() {
return addRowAble;
}
public void setAddRowAble(String addRowAble) {
this.addRowAble = addRowAble;
}
}

View File

@@ -0,0 +1,28 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Background注解
* @author WangZhen
* @version 2013-11-12
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupBackground {
/**
* 背景颜色
* @return
*/
String bgColor() default "";
}

View File

@@ -0,0 +1,223 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Col注解
* @author WangZhen
* @version 2013-11-12
* @see 在get方法上添加注解应用实例
*
* @SupCol(text="归属公司", sort = 10)
*/
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupCol {
///////////////////////////////////// 主要 //////////////////////////////////////
/**
* 列名(默认当前字段名)
*/
String name() default "";
/**
* 内容是否允许重复 true/false
*/
String isUnique() default "";
/**
* 是否允许为空 true/false
*/
String nullAble() default "";
/**
* 默认值 串, 用于新插入行操作时的初始, 支持以 "=" 开头的表达式,例如 defaultValue="=now( )", 表示将日期型默认值设为当天 (无)
* 注: 仅对新插入的行有效
*/
String defaultValue() default "";
/**
* 数据类型 有 string / int / double / bool / date / datetime 这几种
*/
String dataType() default "";
/**
* 小数位数 -1至8, 仅用于 double 型。 -1表示小数位数不确定, 可以在0位和8位之间可以任意输入, 默认: 2
*/
String decimal() default "";
/**
* 是否超链接列 true/false false
*/
String isHyperlink() default "";
/**
* 是否隐藏, true - 隐藏() default "";
* false - 显示() default "";
* absHide 或 absTrue - 绝对隐藏,不会被鼠标右键菜单选择() default "";
* absShow 或 absFalse - 绝对显示,不会被鼠标右键菜单选择() default "";
*/
String isHide() default "";
/**
* 点击列标题是否执行排序 true/false ,默认true
* 注: 如果<Properties>中的sortAble设为false, 则本sortAble无效(false)
*/
String sortAble() default "";
/**
* 是否允许列的拖动操作 ,默认true
* 注: 如果<Properties>中的moveAble设为false, 则本moveAble无效(false)
*/
String moveAble() default "";
/**
* 是否允许被粘贴 ,默认supcan.xml
* true - 允许() default "";
* false - 不允许() default "";
* supcan.xml - 通常是允许,但是当列不可编辑时(包括隐藏时)将以supcan.xml中的 <pasteAbleWhenUnEditAble> 的设定为准() default "";
*/
String pasteAble() default "";
/**
* 指向另一列的列名,显示的内容存放在该列中,是另类 key-value对 的简易字典解决方案
*/
String textId() default "";
///////////////////////////////////// 外观 //////////////////////////////////////
/**
* 是否以千位符分隔显示 true/false 默认true
* 注: 仅用于 datatype 为 int 或 double 时
*/
String isThousandSeparat() default "";
/**
* 列宽 整数 - 绝对宽度 (单位:像素数)() default "";
* 百分比 - 窗口宽度的百分比, 如20%() default "";
* 为小于1的分数 - 比例因子,用于分配剩余的宽度, 如0.2() default "";
* fitHeader 或 header - 自动伸展到能使表头标题能够完整显示() default "";
*/
String width() default "";
/**
* 列的最小宽度 像素数 10
*/
String minWidth() default "";
/**
* 水平对齐 left / center / right
*/
String align() default "";
/**
* 垂直对齐 top / vcenter(或middle) / bottom vcenter
*/
String vAlign() default "";
/**
* 列标题文字的对齐 left / center / right center
*/
String alignHeader() default "";
/**
* 采用的字体 数字,指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性 -1
*/
String fontIndex() default "";
/**
* 列标题采用的字体 数字,指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性 -1
*/
String headerFontIndex() default "";
/**
* 列标题文字颜色 颜色串 #000000
*/
String headerTextColor() default "";
/**
* 列标题旁边的小图标 可以是图标的URL, 也可以是如下格式的串:
*   url=[?]() default "";pos=[?]
* pos用于指定图标的位置, 是水平(left/right)、 垂直(top/middle/bottom)方向的组合. 举例如下:
*   url=../ac.png() default "";pos=right,bottom
* 建议采用png或ico这类透明的图片
*/
String headerIcon() default "";
/**
* 鼠标点击上述小图标时弹出的提示文字 文字串, 如果不定义这个串鼠标点击小图标时将触发Clicked事件
*/
String headerIconTip() default "";
/**
* 用于显示的格式掩码表达式 表达式的内容包括显示内容、 背景色、 文字色、 左图、 右图. 请详见Treelist帮助文档的"3.几个重要的属性"
* formatDate(data,'YYYY-MM-DD')
* =if(data=='1','关闭',if(data=='2','已完成',if(data=='3','未接收','进行中')))
*/
String displayMask() default "";
/**
* 位于多层表头的层位置 数字从0开始
*/
String atLayer() default "";
/**
* 位于多层表头的层位置 数字从0开始
*/
String extentRows() default "";
/**
* 下拉列(droplis, droptreelist)单元格的文字显示方式 0 - 仅显示文字部分() default "";
* 1 - 仅显示键值(即key)部分() default "";
* 2 - 键值+" - "+文字() default "";
*/
String dropDisplayType() default "";
/**
* 虚拟列的数据分隔符 串,比如"/", 如果设了这个串,在加载数据后,程序将按这个分隔符自动对各行数据进行处理,使其看上去呈现多列的效果。此外, 各个段中纵向、横向如果有连续相同的数据,将自动呈现纵、横的合并效果 (无)
* 注1: 仅改变显示效果,并不改变数据() default "";
* 注2: VColSep列有诸多限制例如只能用于string型、不能作为树的排序列等等() default "";
*/
String VColSep() default "";
/**
* VColSepStyle 虚拟列的合并方式 row - 只允许跨行的垂直合并() default "";
* col - 只允许跨列的横向合并() default "";
* row,col - 跨行、跨列自动合并() default "";
*/
String VColSepStyle() default "";
/**
* 合计表达式
*/
String totalExpress() default "";
/**
* 小计表达式
*/
String subTotalExpress() default "";
/**
* 列的显示名称
*/
String text() default "";
/**
* 归属组ID
*/
String groupId() default "";
/**
* 排序(升序)
*/
int sort() default 0;
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Express注解
* @author WangZhen
* @version 2013-11-12
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupExpress {
/**
* 是否自动按列的引用关系优化计算顺序 默认值true
*/
String isOpt() default "";
/**
* 文本
*/
String text() default "";
}

View File

@@ -0,0 +1,59 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Font注解
* @author WangZhen
* @version 2013-11-12
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupFont {
/**
* 字体名称 微软雅黑 宋体
*/
String faceName() default "";
/**
* 字符集 134
*/
String charSet() default "";
/**
* Height(或size)是字体的尺寸单位是字体的逻辑单位通常采用小于0的数字
* 如果大于0则高度不包含文字的内部行距(internal-leading)。
* 常用的尺寸是-8, -9, -10, -11, -12, -14, -16, -18, -20, -22, -24, -26, -28, -36, -48, -72() ;
*/
String height() default "";
/**
* 字体加粗 weight=400/700 对应 非粗体/粗体;
*/
String weight() default "";
/**
* 字体宽度
*/
String width() default "";
/**
* 字体斜体
*/
String italic() default "";
/**
* 字体下划线
*/
String underline() default "";
}

View File

@@ -0,0 +1,56 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Group注解
* @author WangZhen
* @version 2013-11-12
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupGroup {
/**
* 分组的id仅用于加载采用该id代替列名的XML/JSON数据
*/
String id();
/**
* 显示的文字 串
*/
String name() default "";
/**
* 采用的字体, 前面定义的<Font>的序号 数字 指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性
*/
String headerFontIndex() default "";
/**
* 文字颜色 颜色串 #000000
*/
String textColor() default "";
/**
* 文字对齐 left/center/right center
*/
String align() default "";
/**
* 父级组ID
*/
String parentId() default "";
/**
* 排序(升序)
*/
int sort() default 0;
}

View File

@@ -0,0 +1,149 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正Properties注解
* @author WangZhen
* @version 2013-11-12
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupProperties {
/**
* Treelist的ID 串
*/
String id() default "";
/**
* 主键 串, 下面<col>的列名,复合主键须以逗号分隔
*/
String key() default "";
/**
* 是否以树展现 true/false
*/
String isTree() default "";
/**
* 是否显示左标尺 true/false
* editAble=true时isShowRuler的默认值是true否则是false;
*/
String isShowRuler() default "";
/**
* 合计行是否固定在底部、始终显示 true/false
*/
String isFixTotalRow() default "";
/**
* 合计行的背景色 颜色串
*/
String totalBgColor() default "";
/**
* 小计行的背景色 颜色串
*/
String subTotalBgColor() default "";
/**
* 是否允许增删改操作 true/false
* editAble=true时isShowRuler的默认值是true否则是false;
*/
String editAble() default "";
/**
* 是否允许用户增行操作 true/false
* 注1: 仅在editAble=true时生效; 注2: 不影响增删改的API;
*/
String addRowAble() default "";
/**
* 分屏方式
* true - 始终显示分隔条;
* false - 始终不显示分隔条;
* auto - 自动(超宽时会在左侧浮现分隔条);
*/
String separateBarStyle() default "";
/**
* 点击列标题是否执行排序 true/false
*/
String sortAble() default "";
/**
* 是否允许多层表头 true/false
*/
String multiLayerAble() default "";
/**
* 执行 Load() 函数时的淡入淡出效果 0 - 255, 数值越小效果越明显, 而 0 表示关闭此效果
*/
String fadeInStep() default "";
/**
* 顶部标题条的背景色 颜色串,可以是以逗号分隔的多个颜色(渐变)
*/
String headerBgColor() default "";
/**
* 顶部标题条的高度 像素数
*/
String headerHeight() default "";
/**
* 左标尺的背景色,颜色串,可以是以逗号分隔的多个颜色(渐变)
*/
String leftColor() default "";
/**
* 行高像素数
*/
String rowHeight() default "";
/**
* 当前行的颜色,允许多个颜色渐变
* 颜色串, 支持ARGB格式例如: "#10C0D0E0", 其中 "10" 是 alpha(透明度), "C0D0E0" 是 RGB, 此外, 还支持包含如下边框属性:
*    borderWidth - 边框线宽
*   borderColor - 边框线色
*   borderRound - 边框线的圆角直径
* 示例: "#12FFFFFF,#22EEFFEE; borderWidth=1; borderColor=red; borderRound=8"
*/
String curSelBgColor() default ""; // #F5F5F5 #FFE88D
/**
* 整行的背景色、文字色表达式 表达式, 如:
* displayMask = "bgColor=if(price=0, red, transparent); textColor=if(price>2,#000022, blue)"
*/
String displayMask() default "";
/**
* 指定标题栏默认字体 <Fonts>中的字体顺序号 指向在<Fonts>中定义的字体的顺序号, 从0开始计数, 等级高于<Properties>中的同名属性
*/
String headerFontIndex() default "";
/**
* 设置背景
*/
SupBackground packground() default @SupBackground;
/**
* 计算列表达式
*/
SupExpress[] expresses() default {};
/**
* 打印简易配置 标题
*/
String title() default "";
}

View File

@@ -0,0 +1,55 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 硕正TreeList注解
* @author WangZhen
* @version 2013-11-12
* @see 在类上添加注解,应用实例:
@SupTreeList(
properties=@SupProperties(headerFontIndex="2", curSelBgColor="#ccddcc",
displayMask="backColor=if(name='管理员', '#ff0000', transparent)",
expresses={
@SupExpress(text="total=round(price*num, 2)"),
@SupExpress(text="price=round(total/num, 4)")
}),
fonts={
@SupFont(faceName="宋体", weight="400"),
@SupFont(faceName="楷体", weight="700", height="-12"),
@SupFont(faceName="楷体", weight="400", height="-12")},
groups={
@SupGroup(id="date", name="日期", headerFontIndex="1", sort=50),
@SupGroup(id="date2", name="日期2", headerFontIndex="2", sort=60, parentId="date"),
@SupGroup(id="date3", name="日期3", headerFontIndex="2", sort=70, parentId="date")
})
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface SupTreeList {
/**
* 属性对象
*/
SupProperties properties() default @SupProperties;
/**
* 字体对象
*/
SupFont[] fonts() default {};
/**
* 列表头组
*/
SupGroup[] groups() default {};
}

View File

@@ -0,0 +1,213 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nis.util.CacheUtils;
import com.nis.util.Configurations;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseController;
import com.nis.web.service.SpringContextHolder;
/**
* 硕正Controller
* @author ThinkGem
* @version 2013-11-13
*/
@Controller
@RequestMapping(value = "${adminPath}/supcan")
public class SupcanController extends BaseController {
private static final String SUPCAN_CACHE = "supcanCache";
/**
* 获取硕正树列表描述根据注解获取XML
* @return
*/
@RequestMapping(value = "treeList/{typeAlias}.xml")
@ResponseBody
public TreeList treeList(@PathVariable("typeAlias") String typeAlias) {
// 如果使用Cache并且在Cache里存在则直接返回。
boolean useCache = Configurations.getBooleanProperty("supcan.useCache", false);
if (useCache){
Object object = CacheUtils.get(SUPCAN_CACHE, typeAlias);
if (object != null){
return (TreeList)object;
}
}
// 实体类型
Class<?> clazz;
try{
// 根据别名获取MyBaits注册类型。
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
clazz = sqlSessionFactory.getConfiguration().getTypeAliasRegistry().resolveAlias(typeAlias);
}catch (Exception e) {
// 取不到类型,返回空。
return null;
}
// 获取硕正注解配置
SupTreeList supTreeList = clazz.getAnnotation(SupTreeList.class);
// 没有硕正注解配置,则返回空
if (supTreeList == null){
return null;
}
// 实例化硕正树列表对象
TreeList treeList = new TreeList(supTreeList);
// 获取表头分组
Map<String, Group> groupMap = Maps.newHashMap();
if (supTreeList !=null && supTreeList.groups() != null){
for (SupGroup supGroup : supTreeList.groups()){
groupMap.put(supGroup.id(), new Group(supGroup));
}
}
// 获取表头列
List<Object> cols = treeList.getCols();
for (Method m : clazz.getMethods()){
SupCol supCol = m.getAnnotation(SupCol.class);
if (supCol != null){
// 转为为Col对象
Col col = new Col(supCol);
if (StringUtils.isBlank(col.getName())){
col.setName(StringUtils.uncapitalize(StringUtils.substring(m.getName(), 3)));
}
// 无分组
if (StringUtils.isBlank(supCol.groupId())){
cols.add(col);
}
// 有分组
else{
Group group = groupMap.get(supCol.groupId());
if (group != null){
group.getCols().add(col);
}
}
}
}
// 创建字段排序类
Comparator<Object> comparator = new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
int sort1 = 0, sort2 = 0;
if (o1 instanceof Group){
sort1 = ((Group)o1).getSort();
}else if (o1 instanceof Col){
sort1 = ((Col)o1).getSort();
}
if (o2 instanceof Group){
sort2 = ((Group)o2).getSort();
}else if (o2 instanceof Col){
sort2 = ((Col)o2).getSort();
}
return new Integer(sort1).compareTo(new Integer(sort2));
}
};
// 将列表转换为树结构并排序
listToTree(cols, groupMap, null, comparator);
// 整体排序
Collections.sort(cols, comparator);
// 如果使用Cache则保存到Cache
if (useCache){
CacheUtils.put(SUPCAN_CACHE, typeAlias, treeList);
}
return treeList;
}
/**
* 将分组转换为树结构
* @param list
* @param groupMap
* @param parentId
*/
private void listToTree(List<Object> colList, Map<String, Group> groupMap, String parentId, Comparator<Object> comparator){
for (Map.Entry<String, Group> e : groupMap.entrySet()){
Group g = e.getValue();
if (StringUtils.equals(parentId, g.getParentId())){
colList.add(g);
// 判断是否有子节点,有的话则加进去
for (Map.Entry<String, Group> ec : groupMap.entrySet()){
Group gc = ec.getValue();
if (g.getId() != null && g.getId().equals(gc.getParentId())){
List<Object> childrenList = Lists.newArrayList();
listToTree(childrenList, groupMap, gc.getParentId(), comparator);
g.getCols().addAll(childrenList);
break;
}
}
// 排序
Collections.sort(g.getCols(), comparator);
}
}
}
/**
* 获取硕正树列表描述注册对象方法获取XML 测试实例
* @return
*/
@RequestMapping(value = "treeList/test/test.xml")
@ResponseBody
public TreeList treeListTest() {
// 创建树列表描述对象
TreeList treeList = new TreeList();
// 设置树列表,表头
List<Object> cols = treeList.getCols();
cols.add(new Col("id", "编号"));
cols.add(new Col("office", "归属部门"));
cols.add(new Col("loginName", "登录名"));
cols.add(new Col("name", "名称"));
cols.add(new Col("remarks", "备注"));
// 设置树列表,多层表头
// 分组1
Group group = new Group("时间");
List<Object> groupCol = group.getCols();
groupCol.add(new Col("createDate", "创建时间"));
groupCol.add(new Col("updateDate", "更新时间"));
// 分组2
Group group2 = new Group("时间2");
List<Object> group2Col = group2.getCols();
group2Col.add(new Col("createDate2", "创建时间2"));
group2Col.add(new Col("updateDate2", "更新时间2"));
// 将分组2添加到分组1的表头
groupCol.add(group2);
// 将分组1添加到主表头
cols.add(group);
// 返回TreeList描述对象
return treeList;
}
}

View File

@@ -0,0 +1,62 @@
/**
* Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
*/
package com.nis.supcan;
import java.util.List;
import com.google.common.collect.Lists;
import com.thoughtworks.xstream.annotations.XStreamAlias;
/**
* 硕正TreeList
* @author WangZhen
* @version 2013-11-04
*/
@XStreamAlias("TreeList")
public class TreeList extends Common {
/**
* 列集合
*/
@XStreamAlias("Cols")
private List<Object> cols;
public TreeList() {
super();
}
public TreeList(Properties properties) {
this();
this.properties = properties;
}
public TreeList(SupTreeList supTreeList) {
this();
if (supTreeList != null){
if (supTreeList.properties() != null){
this.properties = new Properties(supTreeList.properties());
}
if (supTreeList.fonts() != null){
for (SupFont supFont : supTreeList.fonts()){
if (this.fonts == null){
this.fonts = Lists.newArrayList();
}
this.fonts.add(new Font(supFont));
}
}
}
}
public List<Object> getCols() {
if (cols == null){
cols = Lists.newArrayList();
}
return cols;
}
public void setCols(List<Object> cols) {
this.cols = cols;
}
}