@ -0,0 +1,5 @@
|
||||
set JAVA_HOME=D:\FineReport\develop\java\jdk1.6u35 |
||||
|
||||
set ANT_OPTS=-Xmx512M -Xss100m |
||||
|
||||
D:\FineReport\develop\release\build\ant\bin\ant -f build.xml jar |
@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project basedir="." default="jar" name="plugin"> |
||||
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home"/> |
||||
|
||||
<property name="libs" value="${basedir}/lib"/> |
||||
<property name="publicLibs" value=""/> |
||||
<property name="destLoc" value="."/> |
||||
<property name="classes" value="classes"/> |
||||
|
||||
<xmlproperty file="${basedir}/plugin.xml"/> |
||||
<property name="current-version" value="${plugin.version}"/> |
||||
|
||||
<!-- 插件版本--> |
||||
<property name="plugin-version" value="${current-version}"/> |
||||
<!-- 插件名字--> |
||||
<property name="plugin-name" value="ztree"/> |
||||
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||
|
||||
<target name="prepare"> |
||||
<delete dir="${classes}"/> |
||||
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||
<xmlproperty file="${basedir}/plugin.xml"/> |
||||
<delete dir="${destLoc}/${plugin.name}"/> |
||||
</target> |
||||
<path id="compile.classpath"> |
||||
<fileset dir="${libs}"> |
||||
<include name="**/*.jar"/> |
||||
</fileset> |
||||
<fileset dir="${publicLibs}"> |
||||
<include name="**/*.jar"/> |
||||
</fileset> |
||||
</path> |
||||
<patternset id="resources4Jar"> |
||||
<exclude name="**/.settings/**"/> |
||||
<exclude name=".classpath"/> |
||||
<exclude name=".project"/> |
||||
|
||||
<exclude name="**/*.java"/> |
||||
<exclude name="**/*.db"/> |
||||
<exclude name="**/*.g"/> |
||||
<exclude name="**/package.html"/> |
||||
</patternset> |
||||
<target name="copy_resources"> |
||||
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/> |
||||
<delete dir="tmp"/> |
||||
<copy todir="tmp"> |
||||
<fileset dir="${resources_from}\src"> |
||||
<patternset refid="resources4Jar"/> |
||||
</fileset> |
||||
</copy> |
||||
<copy todir="${classes}"> |
||||
<fileset dir="tmp"/> |
||||
</copy> |
||||
<delete dir="tmp"/> |
||||
</target> |
||||
<target name="compile_javas"> |
||||
<echo message="编译${compile_files}下的Java文件"/> |
||||
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}" |
||||
target="${target_jdk_version}" |
||||
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}" |
||||
executable="${compile_jdk_version}/bin/javac"> |
||||
<src path="${basedir}/src"/> |
||||
<exclude name="**/.svn/**"/> |
||||
<compilerarg line="-encoding UTF8 "/> |
||||
<classpath refid="compile.classpath"/> |
||||
</javac> |
||||
</target> |
||||
|
||||
<target name="jar_classes"> |
||||
<echo message="打Jar包:${jar_name}"/> |
||||
<delete file="${basedir}/${jar_name}"/> |
||||
<jar jarfile="${basedir}/${jar_name}"> |
||||
<fileset dir="${classes}"> |
||||
</fileset> |
||||
</jar> |
||||
</target> |
||||
|
||||
<target name="super_jar" depends="prepare"> |
||||
<antcall target="copy_resources"> |
||||
<param name="resources_from" value="${basedir}"/> |
||||
</antcall> |
||||
<antcall target="compile_javas"> |
||||
<param name="source_jdk_version" value="1.6"/> |
||||
<param name="target_jdk_version" value="1.6"/> |
||||
<param name="compile_jdk_version" value="${jdk.home}"/> |
||||
<param name="compile_files" value="${basedir}/src"/> |
||||
</antcall> |
||||
<echo message="compile plugin success!"/> |
||||
|
||||
<antcall target="jar_classes"> |
||||
<param name="jar_name" value="${plugin-jar}"/> |
||||
</antcall> |
||||
<delete dir="${classes}"/> |
||||
|
||||
</target> |
||||
<target name="jar" depends="super_jar"> |
||||
<antcall target="zip"/> |
||||
</target> |
||||
|
||||
<target name="zip"> |
||||
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||
<echo message="----------zip files----------"/> |
||||
<mkdir dir="${plugin-folder}"/> |
||||
<copy todir="${plugin-folder}"> |
||||
<fileset dir="."> |
||||
<include name="${plugin-jar}"/> |
||||
<include name="plugin.xml"/> |
||||
</fileset> |
||||
</copy> |
||||
<zip destfile="${basedir}/${plugin-folder}.zip" basedir="."> |
||||
<include name="${plugin-folder}/*.jar"/> |
||||
<include name="${plugin-folder}/plugin.xml"/> |
||||
</zip> |
||||
<xmlproperty file="${basedir}/plugin.xml"/> |
||||
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/> |
||||
</target> |
||||
</project> |
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.widget.ztree</id> |
||||
<name><![CDATA[急速下拉树控件]]></name> |
||||
<active>yes</active> |
||||
<version>6.0</version> |
||||
<env-version>8.0</env-version> |
||||
<jartime>2016-01-20</jartime> |
||||
<vendor>洪七公</vendor> |
||||
<price>1000</price> |
||||
<description><![CDATA[ztree实现的下拉树控件,仅支持在参数界面和表单中使用]]></description> |
||||
<change-notes><![CDATA[ |
||||
<p>[2015-12-02]完善反馈信息</p> |
||||
<p>[2015-12-09]修复点击滚动条会导致下拉菜单消失的问题</p> |
||||
<p>[2015-12-09]修复插件在tomcat服务器下无法使用的问题</p> |
||||
<p>[2015-12-10]级联选择的时候,会自动加载所有的子孙节点</p> |
||||
<p>[2015-12-10]修复级联选择的时候,没有选择父亲节点只是也会加载孙子节点的问题</p> |
||||
<p>[2015-12-10]增加级联选项,可以选择不级联,级联到子节点,级联到所有节点</p> |
||||
<p>[2015-12-11]增加弹出层高度设置属性;弹出层宽度跟随控件宽度</p> |
||||
<p>[2016-01-15]修正弹出层会被图表遮住无法选择的问题</p> |
||||
]]></change-notes> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugin.widget.ztree.ZTreeLocaleFinder"/> |
||||
<CssFileHandler class="com.fr.plugin.widget.ztree.CssFileLoader"/> |
||||
</extra-core> |
||||
<extra-report> |
||||
<JavaScriptFileHandler class="com.fr.plugin.widget.ztree.JavaScriptFileLoader"/> |
||||
</extra-report> |
||||
<extra-platform/> |
||||
<extra-designer> |
||||
<ParameterWidgetOptionProvider class="com.fr.plugin.widget.ztree.core.ZTreeMarkInForm"/> |
||||
<FormWidgetOptionProvider class="com.fr.plugin.widget.ztree.core.ZTreeMarkInForm"/> |
||||
</extra-designer> |
||||
</plugin> |
@ -0,0 +1,32 @@
|
||||
# 基于ZTree的下拉树组件 |
||||
|
||||
## 控件的特性如下 |
||||
1. 单选时,选中的节点作为控件值 |
||||
2. 多选时,选中的节点组成的数组作为控件值 |
||||
3. 独选时,同一个节点下只有一个值能被选中 |
||||
|
||||
三种类型的截图如下 |
||||
|
||||
 |
||||
|
||||
## 控件数据设置方式 |
||||
**注意:**该控件仅支持手动添加层级的方式作为树的数据 |
||||
|
||||
1. 树的数据设置支持所有的数据字典类型 |
||||
2. 下一层中使用参数@1,@2,@3等参数表示该节点上层节点的值 |
||||
3. 若是要在数据查询中使用层级参数,可以在where条件中写为:where xxx = '${@1}'这种形式 |
||||
|
||||
## 使用方式(示例模板见reportlets目录下的ztree.cpt) |
||||
1. 安装插件(安装了插件才能打开ztree.cpt,否则打开会报错,如果要查看使用数据查询的实例,查看ztree4db.cpt,所使用的数据结构在tree.sql中) |
||||
2. 打开报表参数界面,可以看到多了一个"ZTree的下拉树"控件 |
||||
 |
||||
3. 将控件拖到参数界面上,选中该控件可以看到该控件的各种属性,如果需要多选树,把模式属性更改为"多选"即可 |
||||
 |
||||
4. 点击"数据"项,可以看到点击数据设置的地方 |
||||
 |
||||
5. 点击上图圆圈的地方,会弹出树控件的数据设置界面,默认会添加一个层级,选择适合的数据字典类型 |
||||
 |
||||
6. 需要添加多层级的时候,点击工具栏上的"添加"图标,如下图示例,添加了4层的树 |
||||
 |
||||
7. 预览该报表就可以看到下拉树的效果了 |
||||
 |
@ -0,0 +1,35 @@
|
||||
/* |
||||
Navicat Premium Data Transfer |
||||
|
||||
Source Server : mac |
||||
Source Server Type : MySQL |
||||
Source Server Version : 50617 |
||||
Source Host : localhost |
||||
Source Database : develop |
||||
|
||||
Target Server Type : MySQL |
||||
Target Server Version : 50617 |
||||
File Encoding : utf-8 |
||||
|
||||
Date: 12/02/2015 14:09:32 PM |
||||
*/ |
||||
|
||||
SET NAMES utf8; |
||||
SET FOREIGN_KEY_CHECKS = 0; |
||||
|
||||
-- ---------------------------- |
||||
-- Table structure for `tree` |
||||
-- ---------------------------- |
||||
DROP TABLE IF EXISTS `tree`; |
||||
CREATE TABLE `tree` ( |
||||
`code` varchar(255) DEFAULT NULL |
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
||||
|
||||
-- ---------------------------- |
||||
-- Records of `tree` |
||||
-- ---------------------------- |
||||
BEGIN; |
||||
INSERT INTO `tree` VALUES ('01'), ('0101'), ('010101'), ('010102'), ('0102'), ('010201'), ('010202'), ('010203'); |
||||
COMMIT; |
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1; |
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<WorkBook xmlVersion="20141222" releaseVersion="8.0.0"> |
||||
<Report class="com.fr.report.worksheet.WorkSheet" name="sheet1"> |
||||
<ReportPageAttr> |
||||
<HR/> |
||||
<FR/> |
||||
<HC/> |
||||
<FC/> |
||||
</ReportPageAttr> |
||||
<ColumnPrivilegeControl/> |
||||
<RowPrivilegeControl/> |
||||
<RowHeight defaultValue="723900"> |
||||
<![CDATA[723900,723900,723900,723900,1143000,723900,723900,723900,723900,723900,723900]]></RowHeight> |
||||
<ColumnWidth defaultValue="2743200"> |
||||
<![CDATA[2743200,2743200,1496290,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200]]></ColumnWidth> |
||||
<CellElementList> |
||||
<C c="0" r="0"> |
||||
<O t="Formula" class="Formula"> |
||||
<Attributes> |
||||
<![CDATA[=$q]]></Attributes> |
||||
</O> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="2"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
</CellElementList> |
||||
<ReportAttrSet> |
||||
<ReportSettings headerHeight="0" footerHeight="0"> |
||||
<PaperSetting/> |
||||
</ReportSettings> |
||||
</ReportAttrSet> |
||||
<PrivilegeControl/> |
||||
</Report> |
||||
<ReportParameterAttr> |
||||
<Attributes showWindow="true" delayPlaying="true" windowPosition="1" align="0"/> |
||||
<PWTitle> |
||||
<![CDATA[参数]]></PWTitle> |
||||
<ParameterUI class="com.fr.form.main.parameter.FormParameterUI"> |
||||
<Layout class="com.fr.form.ui.container.WParameterLayout"> |
||||
<WidgetName name="para"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Margin top="1" left="1" bottom="1" right="1"/> |
||||
<Border> |
||||
<border style="0" color="-723724" type="0" borderStyle="0"/> |
||||
<WidgetTitle> |
||||
<O> |
||||
<![CDATA[新建标题]]></O> |
||||
<FRFont name="SimSun" style="0" size="72"/> |
||||
<Position pos="0"/> |
||||
</WidgetTitle> |
||||
<Alpha alpha="1.0"/> |
||||
</Border> |
||||
<Background name="ColorBackground" color="-1118482"/> |
||||
<LCAttr vgap="0" hgap="0" compInterval="0"/> |
||||
<Widget class="com.fr.form.ui.container.WAbsoluteLayout$BoundsWidget"> |
||||
<InnerWidget class="com.fr.plugin.widget.ztree.core.ZTree"> |
||||
<WidgetName name="q"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.FormulaDictionary"> |
||||
<FormulaDict> |
||||
<![CDATA[=range(1, 6)]]></FormulaDict> |
||||
</Dictionary> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.FormulaDictionary"> |
||||
<FormulaDict> |
||||
<![CDATA[=range(-1, @1)]]></FormulaDict> |
||||
</Dictionary> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.FormulaDictionary"> |
||||
<FormulaDict> |
||||
<![CDATA[=range(-2, @1)]]></FormulaDict> |
||||
</Dictionary> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.FormulaDictionary"> |
||||
<FormulaDict> |
||||
<![CDATA[=range(@3, @2)]]></FormulaDict> |
||||
</Dictionary> |
||||
</ZTreeNode> |
||||
</ZTreeNode> |
||||
</ZTreeNode> |
||||
</ZTreeNode> |
||||
<ZTreeAttr class="com.fr.plugin.widget.ztree.core.ZTreeAttr"> |
||||
<Attr/> |
||||
</ZTreeAttr> |
||||
</InnerWidget> |
||||
<BoundsAttr x="288" y="31" width="198" height="21"/> |
||||
</Widget> |
||||
<Widget class="com.fr.form.ui.container.WAbsoluteLayout$BoundsWidget"> |
||||
<InnerWidget class="com.fr.form.parameter.FormSubmitButton"> |
||||
<WidgetName name="formSubmit0"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[查询]]></Text> |
||||
<Hotkeys> |
||||
<![CDATA[enter]]></Hotkeys> |
||||
</InnerWidget> |
||||
<BoundsAttr x="507" y="31" width="80" height="21"/> |
||||
</Widget> |
||||
<Sorted sorted="false"/> |
||||
<Display display="true"/> |
||||
<DelayDisplayContent delay="true"/> |
||||
<Position position="0"/> |
||||
<Design_Width design_width="960"/> |
||||
<MobileWidgetList> |
||||
<Widget widgetName="q"/> |
||||
</MobileWidgetList> |
||||
<WidgetNameTagMap/> |
||||
</Layout> |
||||
<DesignAttr width="960" height="80"/> |
||||
</ParameterUI> |
||||
</ReportParameterAttr> |
||||
<StyleList/> |
||||
<DesignerVersion DesignerVersion="IAA"/> |
||||
<PreviewType PreviewType="0"/> |
||||
</WorkBook> |
@ -0,0 +1,265 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<WorkBook xmlVersion="20141222" releaseVersion="8.0.0"> |
||||
<TableDataMap> |
||||
<TableData name="node1" class="com.fr.data.impl.DBTableData"> |
||||
<Parameters/> |
||||
<Attributes maxMemRowCount="-1"/> |
||||
<Connection class="com.fr.data.impl.NameDatabaseConnection"> |
||||
<DatabaseName> |
||||
<![CDATA[local]]></DatabaseName> |
||||
</Connection> |
||||
<Query> |
||||
<![CDATA[select code from tree where LENGTH(code) = 2]]></Query> |
||||
</TableData> |
||||
<TableData name="node2" class="com.fr.data.impl.DBTableData"> |
||||
<Parameters/> |
||||
<Attributes maxMemRowCount="-1"/> |
||||
<Connection class="com.fr.data.impl.NameDatabaseConnection"> |
||||
<DatabaseName> |
||||
<![CDATA[local]]></DatabaseName> |
||||
</Connection> |
||||
<Query> |
||||
<![CDATA[select code from tree where LENGTH(code) = 4 and left(code, 2) = '${@1}']]></Query> |
||||
</TableData> |
||||
<TableData name="node3" class="com.fr.data.impl.DBTableData"> |
||||
<Parameters/> |
||||
<Attributes maxMemRowCount="-1"/> |
||||
<Connection class="com.fr.data.impl.NameDatabaseConnection"> |
||||
<DatabaseName> |
||||
<![CDATA[local]]></DatabaseName> |
||||
</Connection> |
||||
<Query> |
||||
<![CDATA[select code from tree where LENGTH(code) = 6 and left(code, 4) = '${@2}']]></Query> |
||||
</TableData> |
||||
</TableDataMap> |
||||
<ReportWebAttr> |
||||
<ServerPrinter/> |
||||
<WebPageContent> |
||||
<ToolBars> |
||||
<ToolBarManager> |
||||
<Location> |
||||
<Embed position="1"/> |
||||
</Location> |
||||
<ToolBar> |
||||
<Widget class="com.fr.report.web.button.page.First"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('ReportServerP-First')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[first]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.page.Previous"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('ReportServerP-Previous')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[previous]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.page.PageNavi"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.page.Next"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('ReportServerP-Next')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[next]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.page.Last"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('ReportServerP-Last')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[last]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.FlashPrint"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('Utils-Print[Client]A')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[flashprint]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.Print"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('Print')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[print]]></IconName> |
||||
<PrintButtons/> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.Export"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('Export')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[export]]></IconName> |
||||
<Buttons pdf="true" excelP="true" excelO="true" excelS="true" word="true" image="true" html="true"/> |
||||
</Widget> |
||||
<Widget class="com.fr.report.web.button.Email"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[${i18n('Email')}]]></Text> |
||||
<IconName> |
||||
<![CDATA[email]]></IconName> |
||||
</Widget> |
||||
<Widget class="com.fr.plugin.export.excel.StreamExcelExtensionButton"> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[Excel流式导出]]></Text> |
||||
<IconName> |
||||
<![CDATA[excel]]></IconName> |
||||
</Widget> |
||||
</ToolBar> |
||||
</ToolBarManager> |
||||
</ToolBars> |
||||
<WebPage isPage="false" isShowAsImage="false" isAutoScale="false" isTDHeavy="false"/> |
||||
</WebPageContent> |
||||
</ReportWebAttr> |
||||
<Report class="com.fr.report.worksheet.WorkSheet" name="sheet1"> |
||||
<ReportPageAttr> |
||||
<HR/> |
||||
<FR/> |
||||
<HC/> |
||||
<FC/> |
||||
</ReportPageAttr> |
||||
<ColumnPrivilegeControl/> |
||||
<RowPrivilegeControl/> |
||||
<RowHeight defaultValue="723900"> |
||||
<![CDATA[723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900]]></RowHeight> |
||||
<ColumnWidth defaultValue="2743200"> |
||||
<![CDATA[2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200]]></ColumnWidth> |
||||
<CellElementList> |
||||
<C c="0" r="0"> |
||||
<O t="Formula" class="Formula"> |
||||
<Attributes> |
||||
<![CDATA[=$st]]></Attributes> |
||||
</O> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
</CellElementList> |
||||
<ReportAttrSet> |
||||
<ReportSettings headerHeight="0" footerHeight="0"> |
||||
<PaperSetting/> |
||||
</ReportSettings> |
||||
</ReportAttrSet> |
||||
<PrivilegeControl/> |
||||
</Report> |
||||
<ReportParameterAttr> |
||||
<Attributes showWindow="true" delayPlaying="true" windowPosition="1" align="0"/> |
||||
<PWTitle> |
||||
<![CDATA[参数]]></PWTitle> |
||||
<ParameterUI class="com.fr.form.main.parameter.FormParameterUI"> |
||||
<Layout class="com.fr.form.ui.container.WParameterLayout"> |
||||
<WidgetName name="para"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Margin top="1" left="1" bottom="1" right="1"/> |
||||
<Border> |
||||
<border style="0" color="-723724" type="0" borderStyle="0"/> |
||||
<WidgetTitle> |
||||
<O> |
||||
<![CDATA[新建标题]]></O> |
||||
<FRFont name="SimSun" style="0" size="72"/> |
||||
<Position pos="0"/> |
||||
</WidgetTitle> |
||||
<Alpha alpha="1.0"/> |
||||
</Border> |
||||
<Background name="ColorBackground" color="-1118482"/> |
||||
<LCAttr vgap="0" hgap="0" compInterval="0"/> |
||||
<Widget class="com.fr.form.ui.container.WAbsoluteLayout$BoundsWidget"> |
||||
<InnerWidget class="com.fr.plugin.widget.ztree.core.ZTree"> |
||||
<WidgetName name="st"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.TableDataDictionary"> |
||||
<FormulaDictAttr kiName="code" viName="code"/> |
||||
<TableDataDictAttr> |
||||
<TableData class="com.fr.data.impl.NameTableData"> |
||||
<Name> |
||||
<![CDATA[node1]]></Name> |
||||
</TableData> |
||||
</TableDataDictAttr> |
||||
</Dictionary> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.TableDataDictionary"> |
||||
<FormulaDictAttr kiName="code" viName="code"/> |
||||
<TableDataDictAttr> |
||||
<TableData class="com.fr.data.impl.NameTableData"> |
||||
<Name> |
||||
<![CDATA[node2]]></Name> |
||||
</TableData> |
||||
</TableDataDictAttr> |
||||
</Dictionary> |
||||
<ZTreeNode class="com.fr.plugin.widget.ztree.core.ZTreeNode"> |
||||
<Dictionary class="com.fr.data.impl.TableDataDictionary"> |
||||
<FormulaDictAttr kiName="code" viName="code"/> |
||||
<TableDataDictAttr> |
||||
<TableData class="com.fr.data.impl.NameTableData"> |
||||
<Name> |
||||
<![CDATA[node3]]></Name> |
||||
</TableData> |
||||
</TableDataDictAttr> |
||||
</Dictionary> |
||||
</ZTreeNode> |
||||
</ZTreeNode> |
||||
</ZTreeNode> |
||||
<ZTreeAttr class="com.fr.plugin.widget.ztree.core.ZTreeAttr"> |
||||
<Attr/> |
||||
</ZTreeAttr> |
||||
</InnerWidget> |
||||
<BoundsAttr x="194" y="22" width="167" height="21"/> |
||||
</Widget> |
||||
<Widget class="com.fr.form.ui.container.WAbsoluteLayout$BoundsWidget"> |
||||
<InnerWidget class="com.fr.form.parameter.FormSubmitButton"> |
||||
<WidgetName name="formSubmit0"/> |
||||
<WidgetAttr> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[查询]]></Text> |
||||
<Hotkeys> |
||||
<![CDATA[enter]]></Hotkeys> |
||||
</InnerWidget> |
||||
<BoundsAttr x="376" y="23" width="80" height="21"/> |
||||
</Widget> |
||||
<Sorted sorted="false"/> |
||||
<Display display="true"/> |
||||
<DelayDisplayContent delay="true"/> |
||||
<Position position="0"/> |
||||
<Design_Width design_width="960"/> |
||||
<MobileWidgetList> |
||||
<Widget widgetName="zTree0"/> |
||||
</MobileWidgetList> |
||||
<WidgetNameTagMap/> |
||||
</Layout> |
||||
<DesignAttr width="960" height="80"/> |
||||
</ParameterUI> |
||||
</ReportParameterAttr> |
||||
<StyleList/> |
||||
<DesignerVersion DesignerVersion="IAA"/> |
||||
<PreviewType PreviewType="0"/> |
||||
</WorkBook> |
After Width: | Height: | Size: 73 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.widget.ztree; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractCssFileHandler; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class CssFileLoader extends AbstractCssFileHandler { |
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{ |
||||
"/com/fr/plugin/widget/ztree/web/widget.ztree.css" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.widget.ztree; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class JavaScriptFileLoader extends AbstractJavaScriptFileHandler { |
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{ |
||||
"/com/fr/plugin/widget/ztree/web/widget.ztree.js" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.plugin.widget.ztree; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTreeLocaleFinder extends AbstractLocaleFinder { |
||||
|
||||
@Override |
||||
public String find() { |
||||
return "com/fr/plugin/widget/ztree/locale/ztree"; |
||||
} |
||||
} |
@ -0,0 +1,166 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.form.ui.CustomWriteAbleRepeatEditor; |
||||
import com.fr.form.ui.DataControl; |
||||
import com.fr.form.ui.WidgetValue; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.xml.GeneralXMLTools; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.ExtraClassManager; |
||||
import com.fr.plugin.PluginLicense; |
||||
import com.fr.plugin.PluginLicenseManager; |
||||
import com.fr.plugin.widget.ztree.tools.ZTreeConstants; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.core.NodeVisitor; |
||||
import com.fr.stable.fun.FunctionProcessor; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.web.core.SessionIDInfor; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTree extends CustomWriteAbleRepeatEditor implements DataControl { |
||||
|
||||
private WidgetValue widgetValue; |
||||
|
||||
private ZTreeNode treeNode; |
||||
|
||||
private ZTreeAttr treeAttr = new ZTreeAttr(); |
||||
|
||||
|
||||
/** |
||||
* 控件初始值的可能类型 |
||||
* |
||||
* @return 多种类型组成的数组 |
||||
*/ |
||||
@Override |
||||
public int[] getValueType() { |
||||
return new int[]{TYPE_STRING, TYPE_DATABINDING, TYPE_FORMULA}; |
||||
} |
||||
|
||||
@Override |
||||
public String[] supportedEvents() { |
||||
return new String[]{AFTEREDIT}; |
||||
} |
||||
|
||||
@Override |
||||
public void setWidgetValue(WidgetValue value) { |
||||
widgetValue = value; |
||||
} |
||||
|
||||
@Override |
||||
public WidgetValue getWidgetValue() { |
||||
return widgetValue; |
||||
} |
||||
|
||||
public ZTreeNode getTreeNode() { |
||||
return treeNode; |
||||
} |
||||
|
||||
public void setTreeNode(ZTreeNode treeNode) { |
||||
this.treeNode = treeNode; |
||||
} |
||||
|
||||
public void setSelectStyle(ZTreeStyle style) { |
||||
treeAttr.setCheckStyle(style); |
||||
} |
||||
|
||||
public ZTreeStyle getSelectStyle() { |
||||
return treeAttr.getCheckStyle(); |
||||
} |
||||
|
||||
public ZTreeCascade getCascade() { |
||||
return treeAttr.getCascade(); |
||||
} |
||||
|
||||
public void setCascade(ZTreeCascade cascade) { |
||||
treeAttr.setCascade(cascade); |
||||
} |
||||
|
||||
public int getPopupHeight() { |
||||
return treeAttr.getPopupHeight(); |
||||
} |
||||
|
||||
public void setPopupHeight(int popupHeight) { |
||||
treeAttr.setPopupHeight(popupHeight); |
||||
} |
||||
|
||||
@Override |
||||
public void createValueResult(DataControl widget, Calculator widgetCalculator, JSONObject widgetResult, JSONObject attrSourceCache) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String getXType() { |
||||
return "ztree"; |
||||
} |
||||
|
||||
@Override |
||||
public JSONObject createJSONConfig(Repository repo, Calculator c, NodeVisitor toFindChart) throws JSONException { |
||||
JSONObject conf = super.createJSONConfig(repo, c, toFindChart); |
||||
if (treeAttr != null) { |
||||
treeAttr.mixConfig(conf); |
||||
} |
||||
FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); |
||||
if (processor != null) { |
||||
processor.recordFunction(ZTreeFunctionProcessor.getInstance()); |
||||
} |
||||
return conf; |
||||
} |
||||
|
||||
@Override |
||||
public JSONArray createJSONData(SessionIDInfor sessionIDInfor, Calculator c, HttpServletRequest req) throws Exception { |
||||
if (treeNode == null) { |
||||
return new JSONArray(); |
||||
} |
||||
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(ZTreeConstants.PLUGIN_ID); |
||||
if (pluginLicense != null && pluginLicense.isAvailable()) { |
||||
String pv = WebUtils.getHTTPRequestParameter(req, "pv"); |
||||
int level = WebUtils.getHTTPRequestIntParameter(req, "level", ZTreeNode.ROOT_LEVEL); |
||||
String text = WebUtils.getHTTPRequestParameter(req, "text"); |
||||
String value = WebUtils.getHTTPRequestParameter(req, "value"); |
||||
boolean checked = WebUtils.getHTTPRequestBoolParameter(req, "checked"); |
||||
ZTreeNode node = treeNode.findNode(level); |
||||
if (node != null) { |
||||
return node.toJSONArray(c, level, text, value, pv, checked && treeAttr.getCascade().isCascade()); |
||||
} else { |
||||
return new JSONArray(); |
||||
} |
||||
} else { |
||||
JSONArray errorMsg = new JSONArray(); |
||||
errorMsg.put(new JSONObject().put("text", Inter.getLocText("Plugin-ZTree_License_Expired")).put("value", Inter.getLocText("Plugin-ZTree_License_Expired"))); |
||||
return errorMsg; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (ZTreeNode.XML_TAG.equals(tagName)) { |
||||
treeNode = (ZTreeNode) GeneralXMLTools.readXMLable(reader); |
||||
} else if (ZTreeAttr.XML_TAG.equals(tagName)) { |
||||
treeAttr = (ZTreeAttr) GeneralXMLTools.readXMLable(reader); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
if (treeNode != null) { |
||||
GeneralXMLTools.writeXMLable(writer, treeNode, ZTreeNode.XML_TAG); |
||||
} |
||||
if (treeAttr != null) { |
||||
GeneralXMLTools.writeXMLable(writer, treeAttr, ZTreeAttr.XML_TAG); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,95 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeAttr implements XMLable { |
||||
|
||||
public static final String XML_TAG = "ZTreeAttr"; |
||||
private static final int DEFAULT_POPUP_HEIGHT = 240; |
||||
|
||||
|
||||
private ZTreeStyle style = ZTreeStyle.NONE; |
||||
|
||||
private ZTreeCascade cascade = ZTreeCascade.DESCENDANT; |
||||
|
||||
private int popupHeight = DEFAULT_POPUP_HEIGHT; |
||||
|
||||
|
||||
|
||||
public ZTreeAttr() { |
||||
|
||||
} |
||||
|
||||
public ZTreeStyle getCheckStyle() { |
||||
return style; |
||||
} |
||||
|
||||
public void setCheckStyle(ZTreeStyle checkStyle) { |
||||
this.style = checkStyle; |
||||
} |
||||
|
||||
public ZTreeCascade getCascade() { |
||||
return cascade; |
||||
} |
||||
|
||||
public void setCascade(ZTreeCascade cascade) { |
||||
this.cascade = cascade; |
||||
} |
||||
|
||||
public int getPopupHeight() { |
||||
return popupHeight; |
||||
} |
||||
|
||||
public void setPopupHeight(int popupHeight) { |
||||
this.popupHeight = popupHeight; |
||||
} |
||||
|
||||
public void mixConfig(JSONObject jo) throws JSONException { |
||||
JSONObject settings = new JSONObject(); |
||||
settings.put("data", new JSONObject().put("key", new JSONObject().put("name", "text"))); |
||||
settings.put("check", new JSONObject().put("enable", style!= ZTreeStyle.NONE).put("chkStyle", style.toText())); |
||||
jo.put("setting", settings); |
||||
jo.put("cascade", cascade.toText()); |
||||
jo.put("directEdit", false); |
||||
jo.put("popupHeight", popupHeight); |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (tagName.equals("Attr")) { |
||||
style = ZTreeStyle.parser(reader.getAttrAsString("style", "")); |
||||
cascade = ZTreeCascade.parser(reader.getAttrAsString("cascade", "")); |
||||
popupHeight = reader.getAttrAsInt("popupHeight", DEFAULT_POPUP_HEIGHT); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG("Attr"); |
||||
if (style != ZTreeStyle.NONE) { |
||||
writer.attr("style", style.toText()); |
||||
} |
||||
writer.attr("cascade", cascade.toText()); |
||||
writer.attr("popupHeight", popupHeight); |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
ZTreeAttr cloned = (ZTreeAttr) super.clone(); |
||||
cloned.style = style; |
||||
cloned.cascade = cascade; |
||||
cloned.popupHeight = popupHeight; |
||||
return super.clone(); |
||||
} |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by richie on 15/12/10. |
||||
*/ |
||||
public enum ZTreeCascade { |
||||
|
||||
NONE("none", "Plugin-ZTree_Cascade_None"), |
||||
CHILD("child", "Plugin-ZTree_Cascade_Child"), |
||||
DESCENDANT("descendant", "Plugin-ZTree_Cascade_Descendant"); |
||||
|
||||
private String type; |
||||
private String localeKey; |
||||
|
||||
ZTreeCascade(String type, String localeKey) { |
||||
this.type = type; |
||||
this.localeKey = localeKey; |
||||
} |
||||
|
||||
public String toLocaleText() { |
||||
return Inter.getLocText(localeKey); |
||||
} |
||||
|
||||
public String toLocaleKey() { |
||||
return localeKey; |
||||
} |
||||
|
||||
public String toText() { |
||||
return type; |
||||
} |
||||
|
||||
public boolean isCascade() { |
||||
return this != NONE; |
||||
} |
||||
|
||||
|
||||
public static ZTreeCascade parser(String type) { |
||||
for (ZTreeCascade style : values()) { |
||||
if (ComparatorUtils.equals(type, style.type)) { |
||||
return style; |
||||
} |
||||
} |
||||
return DESCENDANT; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.plugin.widget.ztree.tools.ZTreeConstants; |
||||
import com.fr.stable.fun.FunctionHelper; |
||||
import com.fr.stable.fun.impl.AbstractFunctionProcessor; |
||||
|
||||
/** |
||||
* Created by richie on 15/12/2. |
||||
*/ |
||||
public class ZTreeFunctionProcessor extends AbstractFunctionProcessor { |
||||
|
||||
private static ZTreeFunctionProcessor instance = new ZTreeFunctionProcessor(); |
||||
|
||||
public static ZTreeFunctionProcessor getInstance() { |
||||
return instance; |
||||
} |
||||
|
||||
public int getId() { |
||||
return FunctionHelper.generateFunctionID(ZTreeConstants.PLUGIN_ID); |
||||
} |
||||
|
||||
@Override |
||||
public String getLocaleKey() { |
||||
return "Plugin-ZTree_Widget_Name"; |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.CellWidgetOptionProvider; |
||||
import com.fr.design.fun.impl.AbstractCellWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.ui.XZTree; |
||||
import com.fr.plugin.widget.ztree.ui.ZTreeDefinePane; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTreeMarkInCell extends AbstractCellWidgetOptionProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return ZTree.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<? extends Widget>> appearanceForWidget() { |
||||
return ZTreeDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "/com/fr/plugin/widget/ztree/images/drop_down_tree.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return Inter.getLocText("Plugin-ZTree_Widget_Name"); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.design.fun.ParameterWidgetOptionProvider; |
||||
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.ui.XZTree; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTreeMarkInForm extends AbstractFormWidgetOptionProvider implements ParameterWidgetOptionProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return ZTree.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
return XZTree.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "/com/fr/plugin/widget/ztree/images/drop_down_tree.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return Inter.getLocText("Plugin-ZTree_Widget_Name"); |
||||
} |
||||
} |
@ -0,0 +1,141 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.data.Dictionary; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.xml.GeneralXMLTools; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.widget.ztree.tools.ZTreeHelper; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.script.TreeLayerNameSpace; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.script.NameSpace; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.web.core.SessionIDInfor; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Iterator; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTreeNode implements XMLable { |
||||
public static final int ROOT_LEVEL = -1; |
||||
public static final String XML_TAG = "ZTreeNode"; |
||||
|
||||
private Dictionary dictionary; |
||||
|
||||
private ZTreeNode child; |
||||
|
||||
public ZTreeNode() { |
||||
|
||||
} |
||||
|
||||
public ZTreeNode(Dictionary dictionary) { |
||||
this.dictionary = dictionary; |
||||
} |
||||
|
||||
public Dictionary getDictionary() { |
||||
return dictionary; |
||||
} |
||||
|
||||
public ZTreeNode getChild() { |
||||
return child; |
||||
} |
||||
|
||||
public void setChild(ZTreeNode child) { |
||||
this.child = child; |
||||
} |
||||
|
||||
public ZTreeNode findNode(int level) { |
||||
return findNode(level, ROOT_LEVEL); |
||||
} |
||||
|
||||
public ZTreeNode findNode(int level, int current) { |
||||
if (current < level) { |
||||
current++; |
||||
if (child == null) { |
||||
return null; |
||||
} else { |
||||
return child.findNode(level, current); |
||||
} |
||||
} else { |
||||
return this; |
||||
} |
||||
} |
||||
|
||||
public int getLevelCount() { |
||||
int count = 1; |
||||
ZTreeNode node = getChild(); |
||||
while (node != null) { |
||||
count++; |
||||
node = node.getChild(); |
||||
} |
||||
return count; |
||||
} |
||||
|
||||
|
||||
public JSONArray toJSONArray(Calculator c, int level, String text, String value, String pv, boolean checked) throws JSONException { |
||||
|
||||
Map<String, Object> layerMap = new HashMap<String, Object>(); |
||||
if (pv != null) { |
||||
String[] parentValues = pv.split("\\$\\$"); |
||||
for (int i = 0, len = parentValues.length; i < len; i ++) { |
||||
layerMap.put(GeneralUtils.objectToString(i + 1), parentValues[i]); |
||||
} |
||||
} |
||||
layerMap.put(GeneralUtils.objectToString(level + 1), value); |
||||
NameSpace ns = new TreeLayerNameSpace(layerMap); |
||||
c.pushNameSpace(ns); |
||||
|
||||
JSONArray data = new JSONArray(); |
||||
Iterator entryIt = dictionary.entrys(c); |
||||
|
||||
while (entryIt.hasNext()) { |
||||
Dictionary.MV mv = (Dictionary.MV) entryIt.next(); |
||||
JSONObject jo = new JSONObject(); |
||||
jo.put("text", mv.getView()); |
||||
jo.put("value", mv.getModel()); |
||||
jo.put("pv", ZTreeHelper.join(new String[]{pv, value}, "$$")); |
||||
jo.put("isParent", getChild() != null); |
||||
jo.put("checked", checked); |
||||
data.put(jo); |
||||
} |
||||
c.removeNameSpace(ns); |
||||
return data; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (tagName.equals(Dictionary.XML_TAG)) { |
||||
dictionary = (Dictionary) GeneralXMLTools.readXMLable(reader); |
||||
} else if (tagName.equals(ZTreeNode.XML_TAG)) { |
||||
child = (ZTreeNode) GeneralXMLTools.readXMLable(reader); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
if (dictionary != null) { |
||||
GeneralXMLTools.writeXMLable(writer, dictionary, Dictionary.XML_TAG); |
||||
} |
||||
if (child != null) { |
||||
GeneralXMLTools.writeXMLable(writer, child, ZTreeNode.XML_TAG); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
ZTreeNode cloned = (ZTreeNode) super.clone(); |
||||
cloned.dictionary = (Dictionary) dictionary.clone(); |
||||
cloned.child = (ZTreeNode) child.clone(); |
||||
return cloned; |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.fr.plugin.widget.ztree.core; |
||||
|
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public enum ZTreeStyle { |
||||
|
||||
NONE("none", "Plugin-ZTree_Style_None"), |
||||
CHECK("checkbox", "Plugin-ZTree_Style_Checkbox"), |
||||
RADIO("radio", "Plugin-ZTree_Style_Radio"); |
||||
|
||||
private String type; |
||||
private String localeKey; |
||||
|
||||
ZTreeStyle(String type, String localeKey) { |
||||
this.type = type; |
||||
this.localeKey = localeKey; |
||||
} |
||||
|
||||
public String toLocaleText() { |
||||
return Inter.getLocText(localeKey); |
||||
} |
||||
|
||||
public String toLocaleKey() { |
||||
return localeKey; |
||||
} |
||||
|
||||
public String toText() { |
||||
return type; |
||||
} |
||||
|
||||
public static ZTreeStyle parser(String type) { |
||||
for (ZTreeStyle style : values()) { |
||||
if (ComparatorUtils.equals(type, style.type)) { |
||||
return style; |
||||
} |
||||
} |
||||
return NONE; |
||||
} |
||||
} |
After Width: | Height: | Size: 204 B |
After Width: | Height: | Size: 256 B |
After Width: | Height: | Size: 302 B |
@ -0,0 +1,97 @@
|
||||
/*------------------------------------- |
||||
zTree Style |
||||
|
||||
version: 3.5.19 |
||||
author: Hunter.z |
||||
email: hunter.z@263.net |
||||
website: http://code.google.com/p/jquerytree/ |
||||
|
||||
-------------------------------------*/ |
||||
|
||||
.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif} |
||||
.ztree {margin:0; padding:5px; color:#333} |
||||
.ztree li{padding:0; margin:0; list-style:none; line-height:14px; text-align:left; white-space:nowrap; outline:0} |
||||
.ztree li ul{ margin:0; padding:0 0 0 18px} |
||||
.ztree li ul.line{ background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/line_conn.gif') 0 0 repeat-y;} |
||||
|
||||
.ztree li a {padding:1px 3px 0 0; margin:0; cursor:pointer; height:17px; color:#333; background-color: transparent; |
||||
text-decoration:none; vertical-align:top; display: inline-block} |
||||
.ztree li a:hover {text-decoration:underline} |
||||
.ztree li a.curSelectedNode {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;} |
||||
.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;} |
||||
.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#316AC5; color:white; height:16px; border:1px #316AC5 solid; |
||||
opacity:0.8; filter:alpha(opacity=80)} |
||||
.ztree li a.tmpTargetNode_prev {} |
||||
.ztree li a.tmpTargetNode_next {} |
||||
.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0; |
||||
font-size:12px; border:1px #7EC4CC solid; *border:0px} |
||||
.ztree li span {line-height:16px; margin-right:2px} |
||||
.ztree li span.button {line-height:0; margin:0; width:16px; height:16px; display: inline-block; vertical-align:middle; |
||||
border:0 none; cursor: pointer;outline:none; |
||||
background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; |
||||
background-image:url("${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/zTreeStandard.png"); *background-image:url("${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/zTreeStandard.gif")} |
||||
|
||||
.ztree li span.button.chk {width:13px; height:13px; margin:0 3px 0 0; cursor: auto} |
||||
.ztree li span.button.chk.checkbox_false_full {background-position:0 0} |
||||
.ztree li span.button.chk.checkbox_false_full_focus {background-position:0 -14px} |
||||
.ztree li span.button.chk.checkbox_false_part {background-position:0 -28px} |
||||
.ztree li span.button.chk.checkbox_false_part_focus {background-position:0 -42px} |
||||
.ztree li span.button.chk.checkbox_false_disable {background-position:0 -56px} |
||||
.ztree li span.button.chk.checkbox_true_full {background-position:-14px 0} |
||||
.ztree li span.button.chk.checkbox_true_full_focus {background-position:-14px -14px} |
||||
.ztree li span.button.chk.checkbox_true_part {background-position:-14px -28px} |
||||
.ztree li span.button.chk.checkbox_true_part_focus {background-position:-14px -42px} |
||||
.ztree li span.button.chk.checkbox_true_disable {background-position:-14px -56px} |
||||
.ztree li span.button.chk.radio_false_full {background-position:-28px 0} |
||||
.ztree li span.button.chk.radio_false_full_focus {background-position:-28px -14px} |
||||
.ztree li span.button.chk.radio_false_part {background-position:-28px -28px} |
||||
.ztree li span.button.chk.radio_false_part_focus {background-position:-28px -42px} |
||||
.ztree li span.button.chk.radio_false_disable {background-position:-28px -56px} |
||||
.ztree li span.button.chk.radio_true_full {background-position:-42px 0} |
||||
.ztree li span.button.chk.radio_true_full_focus {background-position:-42px -14px} |
||||
.ztree li span.button.chk.radio_true_part {background-position:-42px -28px} |
||||
.ztree li span.button.chk.radio_true_part_focus {background-position:-42px -42px} |
||||
.ztree li span.button.chk.radio_true_disable {background-position:-42px -56px} |
||||
|
||||
.ztree li span.button.switch {width:18px; height:18px} |
||||
.ztree li span.button.root_open{background-position:-92px -54px} |
||||
.ztree li span.button.root_close{background-position:-74px -54px} |
||||
.ztree li span.button.roots_open{background-position:-92px 0} |
||||
.ztree li span.button.roots_close{background-position:-74px 0} |
||||
.ztree li span.button.center_open{background-position:-92px -18px} |
||||
.ztree li span.button.center_close{background-position:-74px -18px} |
||||
.ztree li span.button.bottom_open{background-position:-92px -36px} |
||||
.ztree li span.button.bottom_close{background-position:-74px -36px} |
||||
.ztree li span.button.noline_open{background-position:-92px -72px} |
||||
.ztree li span.button.noline_close{background-position:-74px -72px} |
||||
.ztree li span.button.root_docu{ background:none;} |
||||
.ztree li span.button.roots_docu{background-position:-56px 0} |
||||
.ztree li span.button.center_docu{background-position:-56px -18px} |
||||
.ztree li span.button.bottom_docu{background-position:-56px -36px} |
||||
.ztree li span.button.noline_docu{ background:none;} |
||||
|
||||
.ztree li span.button.ico_open{margin-right:2px; background-position:-110px -16px; vertical-align:top; *vertical-align:middle} |
||||
.ztree li span.button.ico_close{margin-right:2px; background-position:-110px 0; vertical-align:top; *vertical-align:middle} |
||||
.ztree li span.button.ico_docu{margin-right:2px; background-position:-110px -32px; vertical-align:top; *vertical-align:middle} |
||||
.ztree li span.button.edit {margin-right:2px; background-position:-110px -48px; vertical-align:top; *vertical-align:middle} |
||||
.ztree li span.button.remove {margin-right:2px; background-position:-110px -64px; vertical-align:top; *vertical-align:middle} |
||||
|
||||
.ztree li span.button.ico_loading{margin-right:2px; background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/loading.gif') no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle} |
||||
|
||||
ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)} |
||||
|
||||
span.tmpzTreeMove_arrow {width:16px; height:16px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute; |
||||
background-color:transparent; background-repeat:no-repeat; background-attachment: scroll; |
||||
background-position:-110px -80px; background-image:url("${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/zTreeStandard.png"); *background-image:url("${servletURL}?op=resource&resource=/com/fr/plugin/widget/ztree/lib/img/zTreeStandard.gif")} |
||||
|
||||
ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)} |
||||
.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute} |
||||
|
||||
/* level style*/ |
||||
/*.ztree li span.button.level0 { |
||||
display:none; |
||||
} |
||||
.ztree li ul.level0 { |
||||
padding:0; |
||||
background:none; |
||||
}*/ |
After Width: | Height: | Size: 601 B |
After Width: | Height: | Size: 580 B |
After Width: | Height: | Size: 570 B |
After Width: | Height: | Size: 762 B |
After Width: | Height: | Size: 399 B |
After Width: | Height: | Size: 710 B |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 529 B |
After Width: | Height: | Size: 467 B |
After Width: | Height: | Size: 45 B |
After Width: | Height: | Size: 381 B |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 11 KiB |
@ -0,0 +1,628 @@
|
||||
/* |
||||
* JQuery zTree excheck v3.5.19.2 |
||||
* http://zTree.me/
|
||||
* |
||||
* Copyright (c) 2010 Hunter.z |
||||
* |
||||
* Licensed same as jquery - MIT License |
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* |
||||
* email: hunter.z@263.net |
||||
* Date: 2015-11-15 |
||||
*/ |
||||
(function($){ |
||||
//default consts of excheck
|
||||
var _consts = { |
||||
event: { |
||||
CHECK: "ztree_check" |
||||
}, |
||||
id: { |
||||
CHECK: "_check" |
||||
}, |
||||
checkbox: { |
||||
STYLE: "checkbox", |
||||
DEFAULT: "chk", |
||||
DISABLED: "disable", |
||||
FALSE: "false", |
||||
TRUE: "true", |
||||
FULL: "full", |
||||
PART: "part", |
||||
FOCUS: "focus" |
||||
}, |
||||
radio: { |
||||
STYLE: "radio", |
||||
TYPE_ALL: "all", |
||||
TYPE_LEVEL: "level" |
||||
} |
||||
}, |
||||
//default setting of excheck
|
||||
_setting = { |
||||
check: { |
||||
enable: false, |
||||
autoCheckTrigger: false, |
||||
chkStyle: _consts.checkbox.STYLE, |
||||
nocheckInherit: false, |
||||
chkDisabledInherit: false, |
||||
radioType: _consts.radio.TYPE_LEVEL, |
||||
chkboxType: { |
||||
"Y": "ps", |
||||
"N": "ps" |
||||
} |
||||
}, |
||||
data: { |
||||
key: { |
||||
checked: "checked" |
||||
} |
||||
}, |
||||
callback: { |
||||
beforeCheck:null, |
||||
onCheck:null |
||||
} |
||||
}, |
||||
//default root of excheck
|
||||
_initRoot = function (setting) { |
||||
var r = data.getRoot(setting); |
||||
r.radioCheckedList = []; |
||||
}, |
||||
//default cache of excheck
|
||||
_initCache = function(treeId) {}, |
||||
//default bind event of excheck
|
||||
_bindEvent = function(setting) { |
||||
var o = setting.treeObj, |
||||
c = consts.event; |
||||
o.bind(c.CHECK, function (event, srcEvent, treeId, node) { |
||||
event.srcEvent = srcEvent; |
||||
tools.apply(setting.callback.onCheck, [event, treeId, node]); |
||||
}); |
||||
}, |
||||
_unbindEvent = function(setting) { |
||||
var o = setting.treeObj, |
||||
c = consts.event; |
||||
o.unbind(c.CHECK); |
||||
}, |
||||
//default event proxy of excheck
|
||||
_eventProxy = function(e) { |
||||
var target = e.target, |
||||
setting = data.getSetting(e.data.treeId), |
||||
tId = "", node = null, |
||||
nodeEventType = "", treeEventType = "", |
||||
nodeEventCallback = null, treeEventCallback = null; |
||||
|
||||
if (tools.eqs(e.type, "mouseover")) { |
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
||||
tId = tools.getNodeMainDom(target).id; |
||||
nodeEventType = "mouseoverCheck"; |
||||
} |
||||
} else if (tools.eqs(e.type, "mouseout")) { |
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
||||
tId = tools.getNodeMainDom(target).id; |
||||
nodeEventType = "mouseoutCheck"; |
||||
} |
||||
} else if (tools.eqs(e.type, "click")) { |
||||
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
||||
tId = tools.getNodeMainDom(target).id; |
||||
nodeEventType = "checkNode"; |
||||
} |
||||
} |
||||
if (tId.length>0) { |
||||
node = data.getNodeCache(setting, tId); |
||||
switch (nodeEventType) { |
||||
case "checkNode" : |
||||
nodeEventCallback = _handler.onCheckNode; |
||||
break; |
||||
case "mouseoverCheck" : |
||||
nodeEventCallback = _handler.onMouseoverCheck; |
||||
break; |
||||
case "mouseoutCheck" : |
||||
nodeEventCallback = _handler.onMouseoutCheck; |
||||
break; |
||||
} |
||||
} |
||||
var proxyResult = { |
||||
stop: nodeEventType === "checkNode", |
||||
node: node, |
||||
nodeEventType: nodeEventType, |
||||
nodeEventCallback: nodeEventCallback, |
||||
treeEventType: treeEventType, |
||||
treeEventCallback: treeEventCallback |
||||
}; |
||||
return proxyResult |
||||
}, |
||||
//default init node of excheck
|
||||
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { |
||||
if (!n) return; |
||||
var checkedKey = setting.data.key.checked; |
||||
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); |
||||
n[checkedKey] = !!n[checkedKey]; |
||||
n.checkedOld = n[checkedKey]; |
||||
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); |
||||
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); |
||||
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); |
||||
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); |
||||
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); |
||||
n.halfCheck = !!n.halfCheck; |
||||
n.check_Child_State = -1; |
||||
n.check_Focus = false; |
||||
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; |
||||
|
||||
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) { |
||||
var r = data.getRoot(setting); |
||||
r.radioCheckedList.push(n); |
||||
} |
||||
}, |
||||
//add dom for check
|
||||
_beforeA = function(setting, node, html) { |
||||
var checkedKey = setting.data.key.checked; |
||||
if (setting.check.enable) { |
||||
data.makeChkFlag(setting, node); |
||||
html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true?" style='display:none;'":""),"></span>"); |
||||
} |
||||
}, |
||||
//update zTreeObj, add method of check
|
||||
_zTreeTools = function(setting, zTreeTools) { |
||||
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { |
||||
var checkedKey = this.setting.data.key.checked; |
||||
if (node.chkDisabled === true) return; |
||||
if (checked !== true && checked !== false) { |
||||
checked = !node[checkedKey]; |
||||
} |
||||
callbackFlag = !!callbackFlag; |
||||
|
||||
if (node[checkedKey] === checked && !checkTypeFlag) { |
||||
return; |
||||
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) { |
||||
return; |
||||
} |
||||
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) { |
||||
node[checkedKey] = checked; |
||||
var checkObj = $$(node, consts.id.CHECK, this.setting); |
||||
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); |
||||
view.setChkClass(this.setting, checkObj, node); |
||||
view.repairParentChkClassWithSelf(this.setting, node); |
||||
if (callbackFlag) { |
||||
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
zTreeTools.checkAllNodes = function(checked) { |
||||
view.repairAllChk(this.setting, !!checked); |
||||
} |
||||
|
||||
zTreeTools.getCheckedNodes = function(checked) { |
||||
var childKey = this.setting.data.key.children; |
||||
checked = (checked !== false); |
||||
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked); |
||||
} |
||||
|
||||
zTreeTools.getChangeCheckedNodes = function() { |
||||
var childKey = this.setting.data.key.children; |
||||
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]); |
||||
} |
||||
|
||||
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { |
||||
disabled = !!disabled; |
||||
inheritParent = !!inheritParent; |
||||
inheritChildren = !!inheritChildren; |
||||
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); |
||||
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); |
||||
} |
||||
|
||||
var _updateNode = zTreeTools.updateNode; |
||||
zTreeTools.updateNode = function(node, checkTypeFlag) { |
||||
if (_updateNode) _updateNode.apply(zTreeTools, arguments); |
||||
if (!node || !this.setting.check.enable) return; |
||||
var nObj = $$(node, this.setting); |
||||
if (nObj.get(0) && tools.uCanDo(this.setting)) { |
||||
var checkObj = $$(node, consts.id.CHECK, this.setting); |
||||
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node); |
||||
view.setChkClass(this.setting, checkObj, node); |
||||
view.repairParentChkClassWithSelf(this.setting, node); |
||||
} |
||||
} |
||||
}, |
||||
//method of operate data
|
||||
_data = { |
||||
getRadioCheckedList: function(setting) { |
||||
var checkedList = data.getRoot(setting).radioCheckedList; |
||||
for (var i=0, j=checkedList.length; i<j; i++) { |
||||
if(!data.getNodeCache(setting, checkedList[i].tId)) { |
||||
checkedList.splice(i, 1); |
||||
i--; j--; |
||||
} |
||||
} |
||||
return checkedList; |
||||
}, |
||||
getCheckStatus: function(setting, node) { |
||||
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null; |
||||
var checkedKey = setting.data.key.checked, |
||||
r = { |
||||
checked: node[checkedKey], |
||||
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0))) |
||||
}; |
||||
return r; |
||||
}, |
||||
getTreeCheckedNodes: function(setting, nodes, checked, results) { |
||||
if (!nodes) return []; |
||||
var childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked, |
||||
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL); |
||||
results = !results ? [] : results; |
||||
for (var i = 0, l = nodes.length; i < l; i++) { |
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { |
||||
results.push(nodes[i]); |
||||
if(onlyOne) { |
||||
break; |
||||
} |
||||
} |
||||
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); |
||||
if(onlyOne && results.length > 0) { |
||||
break; |
||||
} |
||||
} |
||||
return results; |
||||
}, |
||||
getTreeChangeCheckedNodes: function(setting, nodes, results) { |
||||
if (!nodes) return []; |
||||
var childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked; |
||||
results = !results ? [] : results; |
||||
for (var i = 0, l = nodes.length; i < l; i++) { |
||||
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) { |
||||
results.push(nodes[i]); |
||||
} |
||||
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results); |
||||
} |
||||
return results; |
||||
}, |
||||
makeChkFlag: function(setting, node) { |
||||
if (!node) return; |
||||
var childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked, |
||||
chkFlag = -1; |
||||
if (node[childKey]) { |
||||
for (var i = 0, l = node[childKey].length; i < l; i++) { |
||||
var cNode = node[childKey][i]; |
||||
var tmp = -1; |
||||
if (setting.check.chkStyle == consts.radio.STYLE) { |
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) { |
||||
tmp = cNode.check_Child_State; |
||||
} else if (cNode.halfCheck === true) { |
||||
tmp = 2; |
||||
} else if (cNode[checkedKey]) { |
||||
tmp = 2; |
||||
} else { |
||||
tmp = cNode.check_Child_State > 0 ? 2:0; |
||||
} |
||||
if (tmp == 2) { |
||||
chkFlag = 2; break; |
||||
} else if (tmp == 0){ |
||||
chkFlag = 0; |
||||
} |
||||
} else if (setting.check.chkStyle == consts.checkbox.STYLE) { |
||||
if (cNode.nocheck === true || cNode.chkDisabled === true) { |
||||
tmp = cNode.check_Child_State; |
||||
} else if (cNode.halfCheck === true) { |
||||
tmp = 1; |
||||
} else if (cNode[checkedKey] ) { |
||||
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; |
||||
} else { |
||||
tmp = (cNode.check_Child_State > 0) ? 1 : 0; |
||||
} |
||||
if (tmp === 1) { |
||||
chkFlag = 1; break; |
||||
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { |
||||
chkFlag = 1; break; |
||||
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) { |
||||
chkFlag = 1; break; |
||||
} else if (tmp > -1) { |
||||
chkFlag = tmp; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
node.check_Child_State = chkFlag; |
||||
} |
||||
}, |
||||
//method of event proxy
|
||||
_event = { |
||||
|
||||
}, |
||||
//method of event handler
|
||||
_handler = { |
||||
onCheckNode: function (event, node) { |
||||
if (node.chkDisabled === true) return false; |
||||
var setting = data.getSetting(event.data.treeId), |
||||
checkedKey = setting.data.key.checked; |
||||
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true; |
||||
node[checkedKey] = !node[checkedKey]; |
||||
view.checkNodeRelation(setting, node); |
||||
var checkObj = $$(node, consts.id.CHECK, setting); |
||||
view.setChkClass(setting, checkObj, node); |
||||
view.repairParentChkClassWithSelf(setting, node); |
||||
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); |
||||
return true; |
||||
}, |
||||
onMouseoverCheck: function(event, node) { |
||||
if (node.chkDisabled === true) return false; |
||||
var setting = data.getSetting(event.data.treeId), |
||||
checkObj = $$(node, consts.id.CHECK, setting); |
||||
node.check_Focus = true; |
||||
view.setChkClass(setting, checkObj, node); |
||||
return true; |
||||
}, |
||||
onMouseoutCheck: function(event, node) { |
||||
if (node.chkDisabled === true) return false; |
||||
var setting = data.getSetting(event.data.treeId), |
||||
checkObj = $$(node, consts.id.CHECK, setting); |
||||
node.check_Focus = false; |
||||
view.setChkClass(setting, checkObj, node); |
||||
return true; |
||||
} |
||||
}, |
||||
//method of tools for zTree
|
||||
_tools = { |
||||
|
||||
}, |
||||
//method of operate ztree dom
|
||||
_view = { |
||||
checkNodeRelation: function(setting, node) { |
||||
var pNode, i, l, |
||||
childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked, |
||||
r = consts.radio; |
||||
if (setting.check.chkStyle == r.STYLE) { |
||||
var checkedList = data.getRadioCheckedList(setting); |
||||
if (node[checkedKey]) { |
||||
if (setting.check.radioType == r.TYPE_ALL) { |
||||
for (i = checkedList.length-1; i >= 0; i--) { |
||||
pNode = checkedList[i]; |
||||
if (pNode[checkedKey] && pNode != node) { |
||||
pNode[checkedKey] = false; |
||||
checkedList.splice(i, 1); |
||||
|
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); |
||||
if (pNode.parentTId != node.parentTId) { |
||||
view.repairParentChkClassWithSelf(setting, pNode); |
||||
} |
||||
} |
||||
} |
||||
checkedList.push(node); |
||||
} else { |
||||
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting); |
||||
for (i = 0, l = parentNode[childKey].length; i < l; i++) { |
||||
pNode = parentNode[childKey][i]; |
||||
if (pNode[checkedKey] && pNode != node) { |
||||
pNode[checkedKey] = false; |
||||
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode); |
||||
} |
||||
} |
||||
} |
||||
} else if (setting.check.radioType == r.TYPE_ALL) { |
||||
for (i = 0, l = checkedList.length; i < l; i++) { |
||||
if (node == checkedList[i]) { |
||||
checkedList.splice(i, 1); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} else { |
||||
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { |
||||
view.setSonNodeCheckBox(setting, node, true); |
||||
} |
||||
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { |
||||
view.setSonNodeCheckBox(setting, node, false); |
||||
} |
||||
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { |
||||
view.setParentNodeCheckBox(setting, node, true); |
||||
} |
||||
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) { |
||||
view.setParentNodeCheckBox(setting, node, false); |
||||
} |
||||
} |
||||
}, |
||||
makeChkClass: function(setting, node) { |
||||
var checkedKey = setting.data.key.checked, |
||||
c = consts.checkbox, r = consts.radio, |
||||
fullStyle = ""; |
||||
if (node.chkDisabled === true) { |
||||
fullStyle = c.DISABLED; |
||||
} else if (node.halfCheck) { |
||||
fullStyle = c.PART; |
||||
} else if (setting.check.chkStyle == r.STYLE) { |
||||
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; |
||||
} else { |
||||
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART); |
||||
} |
||||
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; |
||||
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; |
||||
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; |
||||
}, |
||||
repairAllChk: function(setting, checked) { |
||||
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { |
||||
var checkedKey = setting.data.key.checked, |
||||
childKey = setting.data.key.children, |
||||
root = data.getRoot(setting); |
||||
for (var i = 0, l = root[childKey].length; i<l ; i++) { |
||||
var node = root[childKey][i]; |
||||
if (node.nocheck !== true && node.chkDisabled !== true) { |
||||
node[checkedKey] = checked; |
||||
} |
||||
view.setSonNodeCheckBox(setting, node, checked); |
||||
} |
||||
} |
||||
}, |
||||
repairChkClass: function(setting, node) { |
||||
if (!node) return; |
||||
data.makeChkFlag(setting, node); |
||||
if (node.nocheck !== true) { |
||||
var checkObj = $$(node, consts.id.CHECK, setting); |
||||
view.setChkClass(setting, checkObj, node); |
||||
} |
||||
}, |
||||
repairParentChkClass: function(setting, node) { |
||||
if (!node || !node.parentTId) return; |
||||
var pNode = node.getParentNode(); |
||||
view.repairChkClass(setting, pNode); |
||||
view.repairParentChkClass(setting, pNode); |
||||
}, |
||||
repairParentChkClassWithSelf: function(setting, node) { |
||||
if (!node) return; |
||||
var childKey = setting.data.key.children; |
||||
if (node[childKey] && node[childKey].length > 0) { |
||||
view.repairParentChkClass(setting, node[childKey][0]); |
||||
} else { |
||||
view.repairParentChkClass(setting, node); |
||||
} |
||||
}, |
||||
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { |
||||
if (!node) return; |
||||
var childKey = setting.data.key.children; |
||||
if (node.chkDisabled != chkDisabled) { |
||||
node.chkDisabled = chkDisabled; |
||||
} |
||||
view.repairChkClass(setting, node); |
||||
if (node[childKey] && inherit) { |
||||
for (var i = 0, l = node[childKey].length; i < l; i++) { |
||||
var sNode = node[childKey][i]; |
||||
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit); |
||||
} |
||||
} |
||||
}, |
||||
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { |
||||
if (!node) return; |
||||
if (node.chkDisabled != chkDisabled && inherit) { |
||||
node.chkDisabled = chkDisabled; |
||||
} |
||||
view.repairChkClass(setting, node); |
||||
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); |
||||
}, |
||||
setChkClass: function(setting, obj, node) { |
||||
if (!obj) return; |
||||
if (node.nocheck === true) { |
||||
obj.hide(); |
||||
} else { |
||||
obj.show(); |
||||
} |
||||
obj.attr('class', view.makeChkClass(setting, node)); |
||||
}, |
||||
setParentNodeCheckBox: function(setting, node, value, srcNode) { |
||||
var childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked, |
||||
checkObj = $$(node, consts.id.CHECK, setting); |
||||
if (!srcNode) srcNode = node; |
||||
data.makeChkFlag(setting, node); |
||||
if (node.nocheck !== true && node.chkDisabled !== true) { |
||||
node[checkedKey] = value; |
||||
view.setChkClass(setting, checkObj, node); |
||||
if (setting.check.autoCheckTrigger && node != srcNode) { |
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); |
||||
} |
||||
} |
||||
if (node.parentTId) { |
||||
var pSign = true; |
||||
if (!value) { |
||||
var pNodes = node.getParentNode()[childKey]; |
||||
for (var i = 0, l = pNodes.length; i < l; i++) { |
||||
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey]) |
||||
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) { |
||||
pSign = false; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
if (pSign) { |
||||
view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode); |
||||
} |
||||
} |
||||
}, |
||||
setSonNodeCheckBox: function(setting, node, value, srcNode) { |
||||
if (!node) return; |
||||
var childKey = setting.data.key.children, |
||||
checkedKey = setting.data.key.checked, |
||||
checkObj = $$(node, consts.id.CHECK, setting); |
||||
if (!srcNode) srcNode = node; |
||||
|
||||
var hasDisable = false; |
||||
if (node[childKey]) { |
||||
for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) { |
||||
var sNode = node[childKey][i]; |
||||
view.setSonNodeCheckBox(setting, sNode, value, srcNode); |
||||
if (sNode.chkDisabled === true) hasDisable = true; |
||||
} |
||||
} |
||||
|
||||
if (node != data.getRoot(setting) && node.chkDisabled !== true) { |
||||
if (hasDisable && node.nocheck !== true) { |
||||
data.makeChkFlag(setting, node); |
||||
} |
||||
if (node.nocheck !== true && node.chkDisabled !== true) { |
||||
node[checkedKey] = value; |
||||
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1; |
||||
} else { |
||||
node.check_Child_State = -1; |
||||
} |
||||
view.setChkClass(setting, checkObj, node); |
||||
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) { |
||||
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}, |
||||
|
||||
_z = { |
||||
tools: _tools, |
||||
view: _view, |
||||
event: _event, |
||||
data: _data |
||||
}; |
||||
$.extend(true, $.fn.zTree.consts, _consts); |
||||
$.extend(true, $.fn.zTree._z, _z); |
||||
|
||||
var zt = $.fn.zTree, |
||||
tools = zt._z.tools, |
||||
consts = zt.consts, |
||||
view = zt._z.view, |
||||
data = zt._z.data, |
||||
event = zt._z.event, |
||||
$$ = tools.$; |
||||
|
||||
data.exSetting(_setting); |
||||
data.addInitBind(_bindEvent); |
||||
data.addInitUnBind(_unbindEvent); |
||||
data.addInitCache(_initCache); |
||||
data.addInitNode(_initNode); |
||||
data.addInitProxy(_eventProxy, true); |
||||
data.addInitRoot(_initRoot); |
||||
data.addBeforeA(_beforeA); |
||||
data.addZTreeTools(_zTreeTools); |
||||
|
||||
var _createNodes = view.createNodes; |
||||
view.createNodes = function(setting, level, nodes, parentNode, index) { |
||||
if (_createNodes) _createNodes.apply(view, arguments); |
||||
if (!nodes) return; |
||||
view.repairParentChkClassWithSelf(setting, parentNode); |
||||
} |
||||
var _removeNode = view.removeNode; |
||||
view.removeNode = function(setting, node) { |
||||
var parentNode = node.getParentNode(); |
||||
if (_removeNode) _removeNode.apply(view, arguments); |
||||
if (!node || !parentNode) return; |
||||
view.repairChkClass(setting, parentNode); |
||||
view.repairParentChkClass(setting, parentNode); |
||||
} |
||||
|
||||
var _appendNodes = view.appendNodes; |
||||
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) { |
||||
var html = ""; |
||||
if (_appendNodes) { |
||||
html = _appendNodes.apply(view, arguments); |
||||
} |
||||
if (parentNode) { |
||||
data.makeChkFlag(setting, parentNode); |
||||
} |
||||
return html; |
||||
} |
||||
})(jQuery); |
@ -0,0 +1,367 @@
|
||||
/* |
||||
* JQuery zTree exHideNodes v3.5.19.2 |
||||
* http://zTree.me/
|
||||
* |
||||
* Copyright (c) 2010 Hunter.z |
||||
* |
||||
* Licensed same as jquery - MIT License |
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* |
||||
* email: hunter.z@263.net |
||||
* Date: 2015-11-15 |
||||
*/ |
||||
(function($){ |
||||
//default init node of exLib
|
||||
var _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { |
||||
if (typeof n.isHidden == "string") n.isHidden = tools.eqs(n.isHidden, "true"); |
||||
n.isHidden = !!n.isHidden; |
||||
data.initHideForExCheck(setting, n); |
||||
}, |
||||
//add dom for check
|
||||
_beforeA = function(setting, node, html) {}, |
||||
//update zTreeObj, add method of exLib
|
||||
_zTreeTools = function(setting, zTreeTools) { |
||||
zTreeTools.showNodes = function(nodes, options) { |
||||
view.showNodes(setting, nodes, options); |
||||
} |
||||
zTreeTools.showNode = function(node, options) { |
||||
if (!node) { |
||||
return; |
||||
} |
||||
view.showNodes(setting, [node], options); |
||||
} |
||||
zTreeTools.hideNodes = function(nodes, options) { |
||||
view.hideNodes(setting, nodes, options); |
||||
} |
||||
zTreeTools.hideNode = function(node, options) { |
||||
if (!node) { |
||||
return; |
||||
} |
||||
view.hideNodes(setting, [node], options); |
||||
} |
||||
|
||||
var _checkNode = zTreeTools.checkNode; |
||||
if (_checkNode) { |
||||
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { |
||||
if (!!node && !!node.isHidden) { |
||||
return; |
||||
} |
||||
_checkNode.apply(zTreeTools, arguments); |
||||
} |
||||
} |
||||
}, |
||||
//method of operate data
|
||||
_data = { |
||||
initHideForExCheck: function(setting, n) { |
||||
if (n.isHidden && setting.check && setting.check.enable) { |
||||
if(typeof n._nocheck == "undefined") { |
||||
n._nocheck = !!n.nocheck |
||||
n.nocheck = true; |
||||
} |
||||
n.check_Child_State = -1; |
||||
if (view.repairParentChkClassWithSelf) { |
||||
view.repairParentChkClassWithSelf(setting, n); |
||||
} |
||||
} |
||||
}, |
||||
initShowForExCheck: function(setting, n) { |
||||
if (!n.isHidden && setting.check && setting.check.enable) { |
||||
if(typeof n._nocheck != "undefined") { |
||||
n.nocheck = n._nocheck; |
||||
delete n._nocheck; |
||||
} |
||||
if (view.setChkClass) { |
||||
var checkObj = $$(n, consts.id.CHECK, setting); |
||||
view.setChkClass(setting, checkObj, n); |
||||
} |
||||
if (view.repairParentChkClassWithSelf) { |
||||
view.repairParentChkClassWithSelf(setting, n); |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
//method of operate ztree dom
|
||||
_view = { |
||||
clearOldFirstNode: function(setting, node) { |
||||
var n = node.getNextNode(); |
||||
while(!!n){ |
||||
if (n.isFirstNode) { |
||||
n.isFirstNode = false; |
||||
view.setNodeLineIcos(setting, n); |
||||
break; |
||||
} |
||||
if (n.isLastNode) { |
||||
break; |
||||
} |
||||
n = n.getNextNode(); |
||||
} |
||||
}, |
||||
clearOldLastNode: function(setting, node, openFlag) { |
||||
var n = node.getPreNode(); |
||||
while(!!n){ |
||||
if (n.isLastNode) { |
||||
n.isLastNode = false; |
||||
if (openFlag) { |
||||
view.setNodeLineIcos(setting, n); |
||||
} |
||||
break; |
||||
} |
||||
if (n.isFirstNode) { |
||||
break; |
||||
} |
||||
n = n.getPreNode(); |
||||
} |
||||
}, |
||||
makeDOMNodeMainBefore: function(html, setting, node) { |
||||
html.push("<li ", (node.isHidden ? "style='display:none;' " : ""), "id='", node.tId, "' class='", consts.className.LEVEL, node.level,"' tabindex='0' hidefocus='true' treenode>"); |
||||
}, |
||||
showNode: function(setting, node, options) { |
||||
node.isHidden = false; |
||||
data.initShowForExCheck(setting, node); |
||||
$$(node, setting).show(); |
||||
}, |
||||
showNodes: function(setting, nodes, options) { |
||||
if (!nodes || nodes.length == 0) { |
||||
return; |
||||
} |
||||
var pList = {}, i, j; |
||||
for (i=0, j=nodes.length; i<j; i++) { |
||||
var n = nodes[i]; |
||||
if (!pList[n.parentTId]) { |
||||
var pn = n.getParentNode(); |
||||
pList[n.parentTId] = (pn === null) ? data.getRoot(setting) : n.getParentNode(); |
||||
} |
||||
view.showNode(setting, n, options); |
||||
} |
||||
for (var tId in pList) { |
||||
var children = pList[tId][setting.data.key.children]; |
||||
view.setFirstNodeForShow(setting, children); |
||||
view.setLastNodeForShow(setting, children); |
||||
} |
||||
}, |
||||
hideNode: function(setting, node, options) { |
||||
node.isHidden = true; |
||||
node.isFirstNode = false; |
||||
node.isLastNode = false; |
||||
data.initHideForExCheck(setting, node); |
||||
view.cancelPreSelectedNode(setting, node); |
||||
$$(node, setting).hide(); |
||||
}, |
||||
hideNodes: function(setting, nodes, options) { |
||||
if (!nodes || nodes.length == 0) { |
||||
return; |
||||
} |
||||
var pList = {}, i, j; |
||||
for (i=0, j=nodes.length; i<j; i++) { |
||||
var n = nodes[i]; |
||||
if ((n.isFirstNode || n.isLastNode) && !pList[n.parentTId]) { |
||||
var pn = n.getParentNode(); |
||||
pList[n.parentTId] = (pn === null) ? data.getRoot(setting) : n.getParentNode(); |
||||
} |
||||
view.hideNode(setting, n, options); |
||||
} |
||||
for (var tId in pList) { |
||||
var children = pList[tId][setting.data.key.children]; |
||||
view.setFirstNodeForHide(setting, children); |
||||
view.setLastNodeForHide(setting, children); |
||||
} |
||||
}, |
||||
setFirstNode: function(setting, parentNode) { |
||||
var childKey = setting.data.key.children, childLength = parentNode[childKey].length; |
||||
if (childLength > 0 && !parentNode[childKey][0].isHidden) { |
||||
parentNode[childKey][0].isFirstNode = true; |
||||
} else if (childLength > 0) { |
||||
view.setFirstNodeForHide(setting, parentNode[childKey]); |
||||
} |
||||
}, |
||||
setLastNode: function(setting, parentNode) { |
||||
var childKey = setting.data.key.children, childLength = parentNode[childKey].length; |
||||
if (childLength > 0 && !parentNode[childKey][0].isHidden) { |
||||
parentNode[childKey][childLength - 1].isLastNode = true; |
||||
} else if (childLength > 0) { |
||||
view.setLastNodeForHide(setting, parentNode[childKey]); |
||||
} |
||||
}, |
||||
setFirstNodeForHide: function(setting, nodes) { |
||||
var n,i,j; |
||||
for (i=0, j=nodes.length; i<j; i++) { |
||||
n = nodes[i]; |
||||
if (n.isFirstNode) { |
||||
break; |
||||
} |
||||
if (!n.isHidden && !n.isFirstNode) { |
||||
n.isFirstNode = true; |
||||
view.setNodeLineIcos(setting, n); |
||||
break; |
||||
} else { |
||||
n = null; |
||||
} |
||||
} |
||||
return n; |
||||
}, |
||||
setFirstNodeForShow: function(setting, nodes) { |
||||
var n,i,j, first, old; |
||||
for(i=0, j=nodes.length; i<j; i++) { |
||||
n = nodes[i]; |
||||
if (!first && !n.isHidden && n.isFirstNode) { |
||||
first = n; |
||||
break; |
||||
} else if (!first && !n.isHidden && !n.isFirstNode) { |
||||
n.isFirstNode = true; |
||||
first = n; |
||||
view.setNodeLineIcos(setting, n); |
||||
} else if (first && n.isFirstNode) { |
||||
n.isFirstNode = false; |
||||
old = n; |
||||
view.setNodeLineIcos(setting, n); |
||||
break; |
||||
} else { |
||||
n = null; |
||||
} |
||||
} |
||||
return {"new":first, "old":old}; |
||||
}, |
||||
setLastNodeForHide: function(setting, nodes) { |
||||
var n,i; |
||||
for (i=nodes.length-1; i>=0; i--) { |
||||
n = nodes[i]; |
||||
if (n.isLastNode) { |
||||
break; |
||||
} |
||||
if (!n.isHidden && !n.isLastNode) { |
||||
n.isLastNode = true; |
||||
view.setNodeLineIcos(setting, n); |
||||
break; |
||||
} else { |
||||
n = null; |
||||
} |
||||
} |
||||
return n; |
||||
}, |
||||
setLastNodeForShow: function(setting, nodes) { |
||||
var n,i,j, last, old; |
||||
for (i=nodes.length-1; i>=0; i--) { |
||||
n = nodes[i]; |
||||
if (!last && !n.isHidden && n.isLastNode) { |
||||
last = n; |
||||
break; |
||||
} else if (!last && !n.isHidden && !n.isLastNode) { |
||||
n.isLastNode = true; |
||||
last = n; |
||||
view.setNodeLineIcos(setting, n); |
||||
} else if (last && n.isLastNode) { |
||||
n.isLastNode = false; |
||||
old = n; |
||||
view.setNodeLineIcos(setting, n); |
||||
break; |
||||
} else { |
||||
n = null; |
||||
} |
||||
} |
||||
return {"new":last, "old":old}; |
||||
} |
||||
}, |
||||
|
||||
_z = { |
||||
view: _view, |
||||
data: _data |
||||
}; |
||||
$.extend(true, $.fn.zTree._z, _z); |
||||
|
||||
var zt = $.fn.zTree, |
||||
tools = zt._z.tools, |
||||
consts = zt.consts, |
||||
view = zt._z.view, |
||||
data = zt._z.data, |
||||
event = zt._z.event, |
||||
$$ = tools.$; |
||||
|
||||
data.addInitNode(_initNode); |
||||
data.addBeforeA(_beforeA); |
||||
data.addZTreeTools(_zTreeTools); |
||||
|
||||
// Override method in core
|
||||
var _dInitNode = data.initNode; |
||||
data.initNode = function(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag) { |
||||
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting), |
||||
children = tmpPNode[setting.data.key.children]; |
||||
data.tmpHideFirstNode = view.setFirstNodeForHide(setting, children); |
||||
data.tmpHideLastNode = view.setLastNodeForHide(setting, children); |
||||
if (openFlag) { |
||||
view.setNodeLineIcos(setting, data.tmpHideFirstNode); |
||||
view.setNodeLineIcos(setting, data.tmpHideLastNode); |
||||
} |
||||
isFirstNode = (data.tmpHideFirstNode === node); |
||||
isLastNode = (data.tmpHideLastNode === node); |
||||
if (_dInitNode) _dInitNode.apply(data, arguments); |
||||
if (openFlag && isLastNode) { |
||||
view.clearOldLastNode(setting, node, openFlag); |
||||
} |
||||
}; |
||||
|
||||
var _makeChkFlag = data.makeChkFlag; |
||||
if (!!_makeChkFlag) { |
||||
data.makeChkFlag = function(setting, node) { |
||||
if (!!node && !!node.isHidden) { |
||||
return; |
||||
} |
||||
_makeChkFlag.apply(data, arguments); |
||||
} |
||||
} |
||||
|
||||
var _getTreeCheckedNodes = data.getTreeCheckedNodes; |
||||
if (!!_getTreeCheckedNodes) { |
||||
data.getTreeCheckedNodes = function(setting, nodes, checked, results) { |
||||
if (!!nodes && nodes.length > 0) { |
||||
var p = nodes[0].getParentNode(); |
||||
if (!!p && !!p.isHidden) { |
||||
return []; |
||||
} |
||||
} |
||||
return _getTreeCheckedNodes.apply(data, arguments); |
||||
} |
||||
} |
||||
|
||||
var _getTreeChangeCheckedNodes = data.getTreeChangeCheckedNodes; |
||||
if (!!_getTreeChangeCheckedNodes) { |
||||
data.getTreeChangeCheckedNodes = function(setting, nodes, results) { |
||||
if (!!nodes && nodes.length > 0) { |
||||
var p = nodes[0].getParentNode(); |
||||
if (!!p && !!p.isHidden) { |
||||
return []; |
||||
} |
||||
} |
||||
return _getTreeChangeCheckedNodes.apply(data, arguments); |
||||
} |
||||
} |
||||
|
||||
var _expandCollapseSonNode = view.expandCollapseSonNode; |
||||
if (!!_expandCollapseSonNode) { |
||||
view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) { |
||||
if (!!node && !!node.isHidden) { |
||||
return; |
||||
} |
||||
_expandCollapseSonNode.apply(view, arguments); |
||||
} |
||||
} |
||||
|
||||
var _setSonNodeCheckBox = view.setSonNodeCheckBox; |
||||
if (!!_setSonNodeCheckBox) { |
||||
view.setSonNodeCheckBox = function(setting, node, value, srcNode) { |
||||
if (!!node && !!node.isHidden) { |
||||
return; |
||||
} |
||||
_setSonNodeCheckBox.apply(view, arguments); |
||||
} |
||||
} |
||||
|
||||
var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf; |
||||
if (!!_repairParentChkClassWithSelf) { |
||||
view.repairParentChkClassWithSelf = function(setting, node) { |
||||
if (!!node && !!node.isHidden) { |
||||
return; |
||||
} |
||||
_repairParentChkClassWithSelf.apply(view, arguments); |
||||
} |
||||
} |
||||
})(jQuery); |
@ -0,0 +1,17 @@
|
||||
Plugin-ZTree_Widget_Value=Value |
||||
Plugin-ZTree_Widget_Data=Data |
||||
Plugin-ZTree_Widget_Name=ZTree |
||||
Plugin-ZTree_Add_Node=Add Node |
||||
Plugin-ZTree_Remove_Node=Remove Node |
||||
Plugin-ZTree_Layer=Layer |
||||
Plugin-ZTree_Select=Selected {R1} Items |
||||
Plugin-ZTree_Mode=Mode |
||||
Plugin-ZTree_Style_None=None |
||||
Plugin-ZTree_Style_Checkbox=Checkbox |
||||
Plugin-ZTree_Style_Radio=Radio |
||||
Plugin-ZTree_Cascade=Cascade |
||||
Plugin-ZTree_Cascade_None=No cascade |
||||
Plugin-ZTree_Cascade_Child=Cascade to child |
||||
Plugin-ZTree_Cascade_Descendant=Cascade to descendant |
||||
Plugin-ZTree_Widget_Popup_Height=Popup height |
||||
Plugin-ZTree_License_Expired=Expired |
@ -0,0 +1,17 @@
|
||||
Plugin-ZTree_Widget_Value=\u63A7\u4EF6\u503C |
||||
Plugin-ZTree_Widget_Data=\u6570\u636E |
||||
Plugin-ZTree_Widget_Name=ZTree\u4E0B\u62C9\u6811 |
||||
Plugin-ZTree_Add_Node=\u6DFB\u52A0\u5C42\u7EA7 |
||||
Plugin-ZTree_Remove_Node=\u79FB\u9664\u5C42\u7EA7 |
||||
Plugin-ZTree_Layer=\u5C42\u7EA7 |
||||
Plugin-ZTree_Select=\u5171\u6709{R1}\u9879\u88AB\u9009\u4E2D |
||||
Plugin-ZTree_Mode=\u6A21\u5F0F |
||||
Plugin-ZTree_Style_None=\u5355\u9009 |
||||
Plugin-ZTree_Style_Checkbox=\u591A\u9009 |
||||
Plugin-ZTree_Style_Radio=\u72EC\u9009 |
||||
Plugin-ZTree_Cascade=\u81EA\u52A8\u7EA7\u8054\u9009\u62E9 |
||||
Plugin-ZTree_Cascade_None=\u65E0\u7EA7\u8054 |
||||
Plugin-ZTree_Cascade_Child=\u7EA7\u8054\u5230\u5B50\u8282\u70B9 |
||||
Plugin-ZTree_Cascade_Descendant=\u7EA7\u8054\u5230\u5B59\u5B50\u8282\u70B9 |
||||
Plugin-ZTree_Widget_Popup_Height=\u5F39\u51FA\u5C42\u9AD8\u5EA6 |
||||
Plugin-ZTree_License_Expired=\u6CE8\u518C\u65F6\u95F4\u5DF2\u8FC7,\u6570\u636E\u9519\u8BEF |
@ -0,0 +1,9 @@
|
||||
package com.fr.plugin.widget.ztree.tools; |
||||
|
||||
/** |
||||
* Created by richie on 16/1/22. |
||||
*/ |
||||
public class ZTreeConstants { |
||||
|
||||
public static final String PLUGIN_ID = "com.fr.plugin.widget.ztree"; |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.plugin.widget.ztree.tools; |
||||
|
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeHelper { |
||||
|
||||
public static String join(String[] arr, String delimiter) { |
||||
if (ArrayUtils.isEmpty(arr)) { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
StringBuilder sb = new StringBuilder(); |
||||
for (int i = 0, len = ArrayUtils.getLength(arr); i < len ; i++) { |
||||
String segment = arr[i]; |
||||
if (StringUtils.isNotEmpty(segment)) { |
||||
sb.append(segment); |
||||
if (i != len - 1) { |
||||
sb.append(delimiter); |
||||
} |
||||
} |
||||
} |
||||
return sb.toString(); |
||||
} |
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.fr.plugin.widget.ztree.ui; |
||||
|
||||
import com.fr.design.designer.creator.*; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.core.ZTree; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeCascadeEditor; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeModelEditor; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeStyleEditor; |
||||
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeCascadeRenderer; |
||||
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeModelRenderer; |
||||
import com.fr.plugin.widget.ztree.ui.renderer.ZTreeStyleRenderer; |
||||
import com.fr.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class XZTree extends XFieldEditor { |
||||
|
||||
private LimpidButton btn; |
||||
|
||||
public XZTree(ZTree widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
|
||||
@Override |
||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
CRPropertyDescriptor[] crp = new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("widgetValue", this.toData().getClass()).setI18NName( |
||||
Inter.getLocText("Plugin-ZTree_Widget_Value")).setEditorClass(WidgetValueEditor.class), |
||||
new CRPropertyDescriptor("treeNode", this.toData().getClass()).setI18NName( |
||||
Inter.getLocText("Plugin-ZTree_Widget_Data")).setEditorClass(ZTreeModelEditor.class).setRendererClass( |
||||
ZTreeModelRenderer.class), |
||||
new CRPropertyDescriptor("popupHeight", this.data.getClass()) |
||||
.setI18NName(Inter.getLocText("Plugin-ZTree_Widget_Popup_Height")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), |
||||
new CRPropertyDescriptor("selectStyle", this.toData().getClass()) |
||||
.setI18NName(Inter.getLocText("Plugin-ZTree_Mode")) |
||||
.setEditorClass(ZTreeStyleEditor.class) |
||||
.setRendererClass(ZTreeStyleRenderer.class) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), |
||||
new CRPropertyDescriptor("cascade", this.data.getClass()) |
||||
.setI18NName(Inter.getLocText("Plugin-ZTree_Cascade")) |
||||
.setEditorClass(ZTreeCascadeEditor.class) |
||||
.setRendererClass(ZTreeCascadeRenderer.class) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") |
||||
}; |
||||
return (CRPropertyDescriptor[])ArrayUtils.addAll(super.supportedDescriptor(), crp); |
||||
} |
||||
|
||||
protected JComponent initEditor() { |
||||
if (editor == null) { |
||||
editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
UITextField textField = new UITextField(5); |
||||
textField.setOpaque(false); |
||||
editor.add(textField, BorderLayout.CENTER); |
||||
btn = new LimpidButton("", this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY); |
||||
btn.setPreferredSize(new Dimension(21, 21)); |
||||
btn.setOpaque(true); |
||||
editor.add(btn, BorderLayout.EAST); |
||||
editor.setBackground(Color.WHITE); |
||||
} |
||||
return editor; |
||||
} |
||||
|
||||
@Override |
||||
public ZTree toData() { |
||||
return (ZTree)data; |
||||
} |
||||
|
||||
protected void makeVisible(boolean visible) { |
||||
btn.makeVisible(visible); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 控件的预定义大小 |
||||
* @return 控件的预定义大小 |
||||
*/ |
||||
@Override |
||||
public Dimension initEditorSize() { |
||||
return SMALL_PREFERRED_SIZE; |
||||
} |
||||
|
||||
@Override |
||||
public String getIconPath() { |
||||
return "/com/fr/plugin/widget/ztree/images/drop_down_tree.png"; |
||||
} |
||||
|
||||
/** |
||||
* 获取当前XCreator的一个封装父容器 |
||||
* |
||||
* @param widgetName 当前组件名 |
||||
* |
||||
* @return 封装的父容器 |
||||
* |
||||
* |
||||
* @date 2014-11-25-下午4:47:23 |
||||
* |
||||
*/ |
||||
@Override |
||||
protected XLayoutContainer getCreatorWrapper(String widgetName){ |
||||
return new XWScaleLayout(); |
||||
} |
||||
|
||||
/** |
||||
* 将当前对象添加到父容器中 |
||||
* |
||||
* @param parentPanel 父容器组件 |
||||
* |
||||
* |
||||
* @date 2014-11-25-下午4:57:55 |
||||
* |
||||
*/ |
||||
@Override |
||||
protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ |
||||
this.setSize(width, minHeight); |
||||
parentPanel.add(this); |
||||
} |
||||
|
||||
/** |
||||
* 此控件在自适应布局要保持原样高度 |
||||
* |
||||
* @return 是则返回true |
||||
*/ |
||||
@Override |
||||
public boolean shouldScaleCreator() { |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.plugin.widget.ztree.ui; |
||||
|
||||
import com.fr.design.widget.ui.AbstractDataModify; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.core.ZTree; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
public class ZTreeDefinePane extends AbstractDataModify<ZTree> { |
||||
@Override |
||||
public void populateBean(ZTree ob) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public ZTree updateBean() { |
||||
return new ZTree(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("Plugin-ZTree_Widget_Name"); |
||||
} |
||||
} |
@ -0,0 +1,175 @@
|
||||
package com.fr.plugin.widget.ztree.ui.control; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ilist.UIList; |
||||
import com.fr.design.gui.itoolbar.UIToolbar; |
||||
import com.fr.design.menu.ToolBarDef; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeNode; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.ListSelectionEvent; |
||||
import javax.swing.event.ListSelectionListener; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeControlPane extends BasicPane { |
||||
private static final Dimension N_D = new Dimension(200, 24); |
||||
private static final String LAYER_NAME = Inter.getLocText("Plugin-ZTree_Layer"); |
||||
|
||||
private ZTreeNodePane treeNodePane; |
||||
private DefaultListModel listModel; |
||||
private UIList list; |
||||
private boolean isPopulating = false; |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "ZTree数据配置"; |
||||
} |
||||
|
||||
public ZTreeControlPane() { |
||||
setLayout(new BorderLayout()); |
||||
|
||||
ToolBarDef toolbarDef = new ToolBarDef(); |
||||
toolbarDef.addShortCut(new AddNodeAction()); |
||||
toolbarDef.addShortCut(new RemoveNodeAction()); |
||||
UIToolbar toolbar = ToolBarDef.createJToolBar(); |
||||
toolbarDef.updateToolBar(toolbar); |
||||
toolbar.setPreferredSize(N_D); |
||||
|
||||
listModel = new DefaultListModel(); |
||||
list = new UIList(listModel); |
||||
list.setCellRenderer(listCellRenderer); |
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
||||
list.addListSelectionListener(new ListSelectionListener() { |
||||
@Override |
||||
public void valueChanged(ListSelectionEvent e) { |
||||
if (!e.getValueIsAdjusting() && !isPopulating) { |
||||
JList list = (JList)e.getSource(); |
||||
int selected = list.getSelectedIndex(); |
||||
int previous = selected == e.getFirstIndex() ? e.getLastIndex() : e.getFirstIndex(); |
||||
ZTreeNode treeNode = treeNodePane.updateBean(); |
||||
listModel.set(previous, treeNode); |
||||
treeNode = (ZTreeNode) listModel.get(selected); |
||||
treeNodePane.populateBean(treeNode); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
|
||||
JPanel westPane = GUICoreUtils.createBorderLayoutPane( |
||||
toolbar, BorderLayout.NORTH, |
||||
list, BorderLayout.CENTER |
||||
); |
||||
westPane.setPreferredSize(N_D); |
||||
add(westPane, BorderLayout.WEST); |
||||
|
||||
treeNodePane = new ZTreeNodePane(); |
||||
JLabel label = new JLabel(); |
||||
label.setPreferredSize(N_D); |
||||
add(GUICoreUtils.createBorderLayoutPane( |
||||
label, BorderLayout.NORTH, |
||||
treeNodePane, BorderLayout.CENTER |
||||
), BorderLayout.CENTER); |
||||
} |
||||
|
||||
public ZTreeNode update() { |
||||
updateSelectedIndex(); |
||||
int size = listModel.getSize(); |
||||
if (size == 0) { |
||||
return new ZTreeNode(); |
||||
} else { |
||||
ZTreeNode treeNode = (ZTreeNode) listModel.get(0); |
||||
ZTreeNode parent = treeNode; |
||||
for (int i = 1; i < size ; i ++) { |
||||
ZTreeNode child = (ZTreeNode) listModel.get(i); |
||||
parent.setChild(child); |
||||
parent = child; |
||||
} |
||||
return treeNode; |
||||
} |
||||
} |
||||
|
||||
private void updateSelectedIndex() { |
||||
ZTreeNode treeNode = treeNodePane.updateBean(); |
||||
int index = list.getSelectedIndex(); |
||||
listModel.set(index, treeNode); |
||||
} |
||||
|
||||
public void populate(ZTreeNode treeNode) { |
||||
isPopulating = true; |
||||
listModel.clear(); |
||||
if (treeNode == null) { |
||||
addTreeNode(new ZTreeNode()); |
||||
} else { |
||||
addTreeNode(treeNode); |
||||
} |
||||
selectFirst(); |
||||
isPopulating = false; |
||||
} |
||||
|
||||
private void addTreeNode(ZTreeNode treeNode) { |
||||
listModel.addElement(treeNode); |
||||
if (treeNode.getChild() != null) { |
||||
addTreeNode(treeNode.getChild()); |
||||
} |
||||
} |
||||
|
||||
private void removeSelected() { |
||||
int select = list.getSelectedIndex(); |
||||
listModel.remove(select); |
||||
} |
||||
|
||||
private void selectFirst() { |
||||
list.setSelectedIndex(0); |
||||
treeNodePane.populateBean((ZTreeNode) listModel.get(0)); |
||||
} |
||||
|
||||
private class AddNodeAction extends UpdateAction { |
||||
|
||||
public AddNodeAction() { |
||||
this.setName(Inter.getLocText("Plugin-ZTree_Add_Node")); |
||||
this.setMnemonic('A'); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/plugin/widget/ztree/images/add.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
int size = listModel.getSize(); |
||||
addTreeNode(new ZTreeNode()); |
||||
list.setSelectedIndex(size); |
||||
} |
||||
} |
||||
|
||||
private class RemoveNodeAction extends UpdateAction { |
||||
|
||||
public RemoveNodeAction() { |
||||
this.setName(Inter.getLocText("Plugin-ZTree_Remove_Node")); |
||||
this.setMnemonic('R'); |
||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/plugin/widget/ztree/images/remove.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
removeSelected(); |
||||
} |
||||
} |
||||
|
||||
private ListCellRenderer listCellRenderer = new DefaultListCellRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
if (value instanceof ZTreeNode) { |
||||
this.setText(LAYER_NAME + (index + 1)); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.fr.plugin.widget.ztree.ui.control; |
||||
|
||||
import com.fr.data.Dictionary; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.present.dict.DictionaryPane; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeNode; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeNodePane extends BasicBeanPane<ZTreeNode> { |
||||
|
||||
private DictionaryPane dataRadioPane; |
||||
|
||||
public ZTreeNodePane(){ |
||||
this.initComponents(); |
||||
} |
||||
|
||||
private void initComponents(){ |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
dataRadioPane = new DictionaryPane(); |
||||
this.add(dataRadioPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "ZTree"; |
||||
} |
||||
|
||||
public void populateBean(ZTreeNode treeNodeAttr){ |
||||
Dictionary dict = treeNodeAttr.getDictionary(); |
||||
dataRadioPane.populateBean(dict); |
||||
} |
||||
|
||||
public ZTreeNode updateBean(){ |
||||
|
||||
Dictionary mvList = this.dataRadioPane.updateBean(); |
||||
|
||||
return new ZTreeNode(mvList); |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeNode; |
||||
import com.fr.plugin.widget.ztree.ui.control.ZTreeControlPane; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class AccessibleZTreeModelEditor extends UneditableAccessibleEditor { |
||||
|
||||
private ZTreeControlPane controlPane; |
||||
|
||||
|
||||
public AccessibleZTreeModelEditor() { |
||||
super(new ZTreeModelWrapper()); |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
if (controlPane == null) { |
||||
controlPane = new ZTreeControlPane(); |
||||
} |
||||
BasicDialog dlg = controlPane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||
controlPane.populate(getValue()); |
||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
ZTreeNode zTreeNode = controlPane.update(); |
||||
setValue(zTreeNode); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
dlg.setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
public ZTreeNode getValue() { |
||||
return (ZTreeNode) super.getValue(); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.mainframe.widget.editors.ItemCellEditor; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeCascade; |
||||
|
||||
/** |
||||
* Created by richie on 15/12/10. |
||||
*/ |
||||
|
||||
public class ZTreeCascadeEditor extends ItemCellEditor { |
||||
|
||||
public ZTreeCascadeEditor() { |
||||
super(createItems()); |
||||
} |
||||
|
||||
private static Item[] createItems() { |
||||
ZTreeCascade[] cascades = ZTreeCascade.values(); |
||||
int len = cascades.length; |
||||
Item[] items = new Item[len]; |
||||
for (int i = 0; i < len; i ++) { |
||||
ZTreeCascade style = cascades[i]; |
||||
items[i] = new Item(Inter.getLocText(style.toLocaleKey()), style); |
||||
} |
||||
return items; |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeCascade; |
||||
|
||||
/** |
||||
* Created by richie on 15/12/10. |
||||
*/ |
||||
public class ZTreeCascadeWrapper implements Encoder<ZTreeCascade>, Decoder<ZTreeCascade> { |
||||
@Override |
||||
public ZTreeCascade decode(String txt) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public String encode(ZTreeCascade v) { |
||||
return v.toLocaleText(); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeModelEditor extends AccessiblePropertyEditor { |
||||
|
||||
public ZTreeModelEditor() { |
||||
super(new AccessibleZTreeModelEditor()); |
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeNode; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeModelWrapper implements Encoder<ZTreeNode>, Decoder<ZTreeNode> { |
||||
|
||||
@Override |
||||
public String encode(ZTreeNode v) { |
||||
if (v == null) { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
return "共有" + v.getLevelCount() + "层数据"; |
||||
} |
||||
|
||||
@Override |
||||
public ZTreeNode decode(String txt) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.mainframe.widget.editors.ItemCellEditor; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeStyle; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeStyleEditor extends ItemCellEditor { |
||||
|
||||
public ZTreeStyleEditor() { |
||||
super(createItems()); |
||||
} |
||||
|
||||
private static Item[] createItems() { |
||||
ZTreeStyle[] styles = ZTreeStyle.values(); |
||||
int len = styles.length; |
||||
Item[] items = new Item[len]; |
||||
for (int i = 0; i < len; i ++) { |
||||
ZTreeStyle style = styles[i]; |
||||
items[i] = new Item(Inter.getLocText(style.toLocaleKey()), style); |
||||
} |
||||
return items; |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.plugin.widget.ztree.ui.editor; |
||||
|
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
import com.fr.plugin.widget.ztree.core.ZTreeStyle; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeStyleWrapper implements Encoder<ZTreeStyle>, Decoder<ZTreeStyle> { |
||||
|
||||
@Override |
||||
public String encode(ZTreeStyle v) { |
||||
return v.toLocaleText(); |
||||
} |
||||
|
||||
@Override |
||||
public ZTreeStyle decode(String txt) { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.widget.ztree.ui.renderer; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeCascadeWrapper; |
||||
|
||||
/** |
||||
* Created by richie on 15/12/10. |
||||
*/ |
||||
public class ZTreeCascadeRenderer extends EncoderCellRenderer { |
||||
|
||||
public ZTreeCascadeRenderer() { |
||||
|
||||
super(new ZTreeCascadeWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package com.fr.plugin.widget.ztree.ui.renderer; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeModelWrapper; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeModelRenderer extends EncoderCellRenderer { |
||||
public ZTreeModelRenderer() { |
||||
super(new ZTreeModelWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.widget.ztree.ui.renderer; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
import com.fr.plugin.widget.ztree.ui.editor.ZTreeStyleWrapper; |
||||
|
||||
/** |
||||
* Created by richie on 15/11/18. |
||||
*/ |
||||
public class ZTreeStyleRenderer extends EncoderCellRenderer { |
||||
|
||||
public ZTreeStyleRenderer() { |
||||
|
||||
super(new ZTreeStyleWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,12 @@
|
||||
.ztree-loading { |
||||
font-size: 12px; |
||||
background-color: #f6f6f6; |
||||
width: 100%; |
||||
height: 100%; |
||||
text-align: center; |
||||
} |
||||
.ztree-view { |
||||
background: white none repeat scroll 0 0; |
||||
overflow: auto; |
||||
border: 1px solid #98C0F4; |
||||
} |
@ -0,0 +1,187 @@
|
||||
/** |
||||
* Created by richie on 15/11/17. |
||||
*/ |
||||
; |
||||
(function ($) { |
||||
/** |
||||
* 基于ZTree实现的下拉树 |
||||
* @class FR.ZTree |
||||
* @extends FR.TriggerEditor |
||||
*/ |
||||
FR.ZTree = FR.extend(FR.TriggerEditor, { |
||||
_defaultConfig: function () { |
||||
return $.extend(FR.ZTree.superclass._defaultConfig.apply(), { |
||||
popupWidth: 200, |
||||
popupHeight: 240, |
||||
defaultWidth: 80 |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
FR.ZTree.superclass._init.apply(this, arguments); |
||||
/** |
||||
* 动态的引入js和css代码 |
||||
*/ |
||||
FR.$defaultImport('/com/fr/plugin/widget/ztree/lib/js/jquery.ztree.all-3.5.js', 'js'); |
||||
FR.$defaultImport('/com/fr/plugin/widget/ztree/lib/css/zTreeStyle.css', 'css'); |
||||
}, |
||||
onTriggerClick: function () { |
||||
if (this.isExpanded()) { |
||||
this.collapse(); |
||||
} else { |
||||
var opts = this.options; |
||||
if (!this.$view) { |
||||
this.$view = $('<div class="ztree-view">').appendTo('body').css({ |
||||
width: opts.width, |
||||
height: 20, |
||||
position: 'absolute', |
||||
zIndex : 999999 |
||||
}); |
||||
var $loading = $('<div class="ztree-loading">').text(FR.i18nText('Loading')) |
||||
.css({ |
||||
lineHeight: '20px' |
||||
}); |
||||
$loading.appendTo(this.$view); |
||||
this.expand(); |
||||
this.modifyPosition(); |
||||
this.loadData(); |
||||
} else { |
||||
this.expand(); |
||||
} |
||||
} |
||||
}, |
||||
|
||||
loadData: function () { |
||||
var opts = this.options, self = this; |
||||
FR.ajax({ |
||||
url: opts.widgetUrl, |
||||
data: { |
||||
widgetName: opts.widgetName, |
||||
level: -1 |
||||
}, |
||||
complete: function (res) { |
||||
var data = FR.jsonDecode(res.responseText); |
||||
self._initTreeWithNodes(data); |
||||
} |
||||
}); |
||||
|
||||
}, |
||||
|
||||
_initTreeWithNodes: function (nodes) { |
||||
var opts = this.options, self = this; |
||||
var setting = { |
||||
view: { |
||||
selectedMulti: false |
||||
}, |
||||
async: { |
||||
enable: true, |
||||
url: opts.widgetUrl, |
||||
autoParam: ['text', 'value', 'level', 'pv', 'checked'], |
||||
type: 'post' |
||||
}, |
||||
callback: { |
||||
onAsyncSuccess: function (event, treeId, treeNode, msg) { |
||||
if (setting.check.enable) { |
||||
if (treeNode.checked && opts.cascade === 'descendant') { |
||||
var nodes = treeNode.children; |
||||
for (var i = 0, len = nodes.length; i < len; i++) { |
||||
var child = nodes[i]; |
||||
self.treeObj.expandNode(child, true, false, false); |
||||
} |
||||
} |
||||
self._didSelect(); |
||||
} |
||||
}, |
||||
onCheck: function (event, treeId, treeNode) { |
||||
if (opts.cascade !== 'none') { |
||||
self.treeObj.expandNode(treeNode, true, false, false); |
||||
} |
||||
self._didSelect(); |
||||
}, |
||||
onClick: function (event, treeId, treeNode, clickFlag) { |
||||
if (!setting.check.enable) { |
||||
self.setText(treeNode.text); |
||||
self.setValue(treeNode.value); |
||||
self.collapse(); |
||||
self.fireEvent(FR.Events.AFTEREDIT); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
$.extend(true, setting, opts.setting); |
||||
this.$view.empty(); |
||||
this.$view.css({ |
||||
width: Math.max(opts.popupWidth, opts.width), |
||||
height: opts.popupHeight |
||||
}); |
||||
this.$tree = $('<div class="ztree">').appendTo(this.$view); |
||||
this.treeObj = $.fn.zTree.init(this.$tree, setting, nodes); |
||||
}, |
||||
|
||||
_didSelect: function () { |
||||
var self = this; |
||||
var selected = self.treeObj.getCheckedNodes(true); |
||||
var len = selected.length; |
||||
self.setText(FR.i18nText('Plugin-ZTree_Select', len)); |
||||
var result = []; |
||||
for (var i = 0; i < len; i++) { |
||||
result.push(selected[i].value); |
||||
} |
||||
self.options.value = result; |
||||
self.fireEvent(FR.Events.AFTEREDIT); |
||||
}, |
||||
|
||||
modifyPosition: function () { |
||||
var opts = this.options; |
||||
var p = this.element.offset(); |
||||
this.$view.css({ |
||||
top: p.top + opts.height, |
||||
left: p.left |
||||
}); |
||||
}, |
||||
|
||||
|
||||
isExpanded: function () { |
||||
return this.$view && this.$view.is(":visible"); |
||||
}, |
||||
|
||||
expand: function () { |
||||
this.$view.show(); |
||||
$(document).bind('mousedown', this, this.collapseIf); |
||||
}, |
||||
collapseIf: function (e) { |
||||
var $target = $(e.target); |
||||
var off = $target.offset(); |
||||
var self = e.data; |
||||
if ($target[0] == self.$view[0]) { |
||||
return; |
||||
} |
||||
var opts = self.options; |
||||
var vf = self.$view.offset(); |
||||
// richie:加20的目的是保证有滚动条的时候也会判断在内部
|
||||
if (off.left > vf.left && off.left < vf.left + Math.max(opts.width, opts.popupWidth) + 20 |
||||
&& off.top > vf.top && off.top < vf.top + opts.popupHeight) { |
||||
|
||||
} else { |
||||
self.collapse(); |
||||
} |
||||
}, |
||||
|
||||
collapse: function () { |
||||
if (!this.isExpanded()) { |
||||
return; |
||||
} |
||||
this.$view.hide(); |
||||
$(document).unbind('mousedown', this.collapseIf); |
||||
}, |
||||
setText: function (text) { |
||||
this.editComp.val(text); |
||||
}, |
||||
setValue: function (value) { |
||||
this.options.value = value; |
||||
}, |
||||
getValue: function () { |
||||
return this.options.value; |
||||
} |
||||
}); |
||||
$.shortcut('ztree', FR.ZTree); |
||||
})(jQuery); |