@ -0,0 +1,18 @@
|
||||
# 用于FineReport参数界面的下拉表格控件 |
||||
|
||||
## [插件构建指南](https://github.com/FineDevelop/plugin-build/blob/master/README.md) |
||||
|
||||
可以用于参数面板上的弹出表格控件,可以比下拉框控件展示更详细的数据 |
||||
使用的第三方表格控件easyui的datagrid控件来做表格展示 |
||||
|
||||
## 添加了插件后,参数面板上会多出一个“下拉表格”的控件 |
||||
![s](effect/Snip20150317_11.png) |
||||
## 把控件拖拽添加到参数面板上后,在属性表界面,可以选择要使用的数据集 |
||||
![ss](effect/Snip20150317_12.png) |
||||
## 在参数界面上的效果如图,把控件名设置为c1,并在报表的一个格子中写上公式:=$c1 |
||||
![sss](effect/Snip20150317_13.png) |
||||
## 预览报表并点击下拉按钮看以看到弹出一个表格 |
||||
![ssss](effect/Snip20150317_14.png) |
||||
## 选中需要的一行值后,点击查询按钮,可以看到参数值正确的在报表格子中显示了 |
||||
![sssss](effect/Snip20150317_15.png) |
||||
|
@ -0,0 +1,117 @@
|
||||
<?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_45.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="parameter-combo-grid"/> |
||||
<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> |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<module type="JAVA_MODULE" version="4"> |
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false"> |
||||
<output url="file://$MODULE_DIR$/../../../env/8.0/WebReport/WEB-INF/classes" /> |
||||
<content url="file://$MODULE_DIR$"> |
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||
</content> |
||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" /> |
||||
<orderEntry type="sourceFolder" forTests="false" /> |
||||
<orderEntry type="library" name="lib" level="project" /> |
||||
<orderEntry type="module" module-name="base" /> |
||||
<orderEntry type="module" module-name="base-basic" /> |
||||
<orderEntry type="module" module-name="base-calculate" /> |
||||
<orderEntry type="module" module-name="base-data" /> |
||||
<orderEntry type="module" module-name="base-file" /> |
||||
<orderEntry type="module" module-name="base-performance" /> |
||||
<orderEntry type="module" module-name="base-stable" /> |
||||
<orderEntry type="module" module-name="designer_base" /> |
||||
<orderEntry type="module" module-name="designer_form" /> |
||||
</component> |
||||
</module> |
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.parameter.widget.grid</id> |
||||
<name><![CDATA[表格选择控件]]></name> |
||||
<active>yes</active> |
||||
<version>2.0</version> |
||||
<env-version>8.0</env-version> |
||||
<jartime>2015-08-09</jartime> |
||||
<vendor>路人丁</vendor> |
||||
<description><![CDATA[类似于下拉框但是弹出的选项是一个表格,可以比下拉框展示更加详细的信息]]></description> |
||||
<change-notes><![CDATA[可以在参数界面、表单、填报控件中使用该控件]]></change-notes> |
||||
<extra-core> |
||||
<JavaScriptFileHandler class="com.fr.plugin.widget.grid.JavaScriptFile"/> |
||||
<CssFileHandler class="com.fr.plugin.widget.grid.CssFile"/> |
||||
</extra-core> |
||||
<extra-report/> |
||||
<extra-designer> |
||||
<ParameterWidgetOptionProvider class="com.fr.plugin.widget.grid.GridImpl"/> |
||||
<FormWidgetOptionProvider class="com.fr.plugin.widget.grid.GridImpl"/> |
||||
<CellWidgetOptionProvider class="com.fr.plugin.widget.grid.CellGridImpl"/> |
||||
</extra-designer> |
||||
</plugin> |
@ -0,0 +1,125 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.gui.frpane.TreeSettingPane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.present.dict.DictionaryPane; |
||||
import com.fr.design.widget.DataModify; |
||||
import com.fr.design.widget.ui.AbstractDataModify; |
||||
import com.fr.file.DatasourceManager; |
||||
import com.fr.third.org.apache.poi.hssf.record.formula.functions.Abs; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.Iterator; |
||||
import java.util.Vector; |
||||
|
||||
public class CellGridDefinePane extends AbstractDataModify<ComboGrid> { |
||||
|
||||
private ComboBoxModel model; |
||||
private UINumberField real; |
||||
private UINumberField display; |
||||
|
||||
public CellGridDefinePane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
setLayout(new BorderLayout()); |
||||
model = model(); |
||||
UIComboBox comboBox = new UIComboBox(model); |
||||
comboBox.setRenderer(renderer()); |
||||
comboBox.setPreferredSize(new Dimension(240, 24)); |
||||
|
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
|
||||
double[] rowSize = new double[]{p, p, p}; |
||||
double[] columnSize = new double[]{p, f}; |
||||
|
||||
real = new UINumberField(); |
||||
real.setInteger(true); |
||||
real.setValue(0); |
||||
|
||||
display = new UINumberField(); |
||||
display.setInteger(true); |
||||
display.setValue(0); |
||||
|
||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(new Component[][]{ |
||||
{new UILabel("TableData:"), comboBox}, |
||||
{new UILabel("Value:"), real}, |
||||
{new UILabel("ShowValue:"), display}, |
||||
}, rowSize, columnSize); |
||||
add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
/** |
||||
* 数据源 |
||||
* |
||||
* @return 数据源 |
||||
*/ |
||||
public ComboBoxModel model() { |
||||
Vector<TableData> tableDatas = new Vector<TableData>(); |
||||
TableDataSource tableDataSource = DesignTableDataManager.getEditingTableDataSource(); |
||||
if (tableDataSource != null) { |
||||
Iterator it = tableDataSource.getTableDataNameIterator(); |
||||
while (it.hasNext()) { |
||||
String name = (String) it.next(); |
||||
tableDatas.add(new NameTableData(name)); |
||||
} |
||||
} |
||||
Iterator nameIt = DatasourceManager.getProviderInstance().getTableDataNameIterator(); |
||||
while (nameIt.hasNext()) { |
||||
tableDatas.add(new NameTableData((String) nameIt.next())); |
||||
} |
||||
return new DefaultComboBoxModel(tableDatas); |
||||
} |
||||
|
||||
/** |
||||
* 遍历器 |
||||
* |
||||
* @return 遍历器 |
||||
*/ |
||||
public ListCellRenderer renderer() { |
||||
return new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList jList, Object o, int i, boolean b, boolean b1) { |
||||
if (o instanceof NameTableData) { |
||||
setText(((NameTableData) o).getName()); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ComboGrid ob) { |
||||
model.setSelectedItem(ob.getTableData()); |
||||
real.setValue(ob.getKeyIndex()); |
||||
display.setValue(ob.getValueIndex()); |
||||
} |
||||
|
||||
@Override |
||||
public ComboGrid updateBean() { |
||||
ComboGrid grid = new ComboGrid(); |
||||
grid.setTableData((TableData) model.getSelectedItem()); |
||||
grid.setKeyIndex((int) real.getValue()); |
||||
grid.setValueIndex((int) display.getValue()); |
||||
return grid; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "grid"; |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractCellWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
|
||||
public class CellGridImpl extends AbstractCellWidgetOptionProvider { |
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return ComboGrid.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends BasicBeanPane<? extends Widget>> appearanceForWidget() { |
||||
return CellGridDefinePane.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "/com/fr/plugin/widget/grid/images/table.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "Grid"; |
||||
} |
||||
} |
@ -0,0 +1,156 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.form.ui.DataControl; |
||||
import com.fr.form.ui.WidgetValue; |
||||
import com.fr.form.ui.WriteAbleRepeatEditor; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.web.core.SessionIDInfor; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-16 |
||||
* @since 8.0 |
||||
*/ |
||||
public class ComboGrid extends WriteAbleRepeatEditor implements DataControl { |
||||
|
||||
private TableData tableData; |
||||
private WidgetValue widgetValue; |
||||
private int keyIndex; |
||||
private int valueIndex; |
||||
|
||||
public ComboGrid() { |
||||
|
||||
} |
||||
|
||||
public TableData getTableData() { |
||||
return tableData; |
||||
} |
||||
|
||||
public void setTableData(TableData tableData) { |
||||
this.tableData = tableData; |
||||
} |
||||
|
||||
public int getKeyIndex() { |
||||
return keyIndex; |
||||
} |
||||
|
||||
public void setKeyIndex(int keyIndex) { |
||||
this.keyIndex = keyIndex; |
||||
} |
||||
|
||||
public int getValueIndex() { |
||||
return valueIndex; |
||||
} |
||||
|
||||
public void setValueIndex(int valueIndex) { |
||||
this.valueIndex = valueIndex; |
||||
} |
||||
|
||||
/** |
||||
* 生成下拉框数据的JSONArray。这个方法用于生成控件数据,因为下拉框数据一般不需要在一开始就加载的, |
||||
* 当点击下拉框的时候才加载数据,就要用到这个方法了。 |
||||
* |
||||
* @param sessionIDInfor 本次会话信息 |
||||
* @param c 算子 |
||||
* @param req http请求 |
||||
* @return 返回数据对象 |
||||
* @throws Exception 抛出异常 |
||||
*/ |
||||
public JSONArray createJSONData(SessionIDInfor sessionIDInfor, Calculator c, HttpServletRequest req) throws Exception { |
||||
JSONArray ja = new JSONArray(); |
||||
|
||||
JSONObject columnInfo = new JSONObject(); |
||||
ja.put(columnInfo); |
||||
|
||||
JSONArray columnNames = new JSONArray(); |
||||
columnInfo.put("columnNames", columnNames); |
||||
|
||||
JSONObject valueInfo = new JSONObject(); |
||||
columnInfo.put("valueInfo", valueInfo); |
||||
|
||||
|
||||
DataModel dataModel = tableData.createDataModel(c); |
||||
|
||||
for (int i = 0, col = dataModel.getColumnCount(); i < col; i ++) { |
||||
String colName = dataModel.getColumnName(i); |
||||
columnNames.put(colName); |
||||
} |
||||
valueInfo.put("valueColumnName", columnNames.length() > keyIndex ? columnNames.getString(keyIndex) : columnNames.getString(0)); |
||||
valueInfo.put("textColumnName", columnNames.length() > valueIndex ? columnNames.getString(valueIndex) : columnNames.getString(0)); |
||||
|
||||
|
||||
JSONArray valueArray = new JSONArray(); |
||||
ja.put(valueArray); |
||||
for (int j = 0, row = dataModel.getRowCount(); j < row; j ++) { |
||||
JSONObject jo = new JSONObject(); |
||||
valueArray.put(jo); |
||||
for (int i = 0, col = dataModel.getColumnCount(); i < col; i ++) { |
||||
jo.put(dataModel.getColumnName(i), dataModel.getValueAt(j, i)); |
||||
} |
||||
} |
||||
|
||||
return ja; |
||||
} |
||||
|
||||
|
||||
public String getXType() { |
||||
return "combogrid"; |
||||
} |
||||
|
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
if (reader.isChildNode()) { |
||||
String nodeName = reader.getTagName(); |
||||
if ("ComboGridAttr".equals(nodeName)) { |
||||
tableData = new NameTableData(reader.getAttrAsString("tdname", "")); |
||||
keyIndex = reader.getAttrAsInt("keyIndex", 0); |
||||
valueIndex = reader.getAttrAsInt("valueIndex", 0); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
writer.startTAG("ComboGridAttr"); |
||||
if (tableData != null) { |
||||
writer.attr("tdname", ((NameTableData) tableData).getName()); |
||||
if (keyIndex != 0) { |
||||
writer.attr("keyIndex", keyIndex); |
||||
} |
||||
if (valueIndex != 0) { |
||||
writer.attr("valueindex", valueIndex); |
||||
} |
||||
} |
||||
writer.end(); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public int[] getValueType() { |
||||
return new int[]{TYPE_STRING, TYPE_FORMULA}; |
||||
} |
||||
|
||||
@Override |
||||
public void setWidgetValue(WidgetValue value) { |
||||
widgetValue = value; |
||||
} |
||||
|
||||
@Override |
||||
public WidgetValue getWidgetValue() { |
||||
return widgetValue; |
||||
} |
||||
|
||||
@Override |
||||
public void createValueResult(DataControl widget, Calculator widgetCalculator, JSONObject widgetResult, JSONObject attrSourceCache) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractCssFileHandler; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-16 |
||||
* @since 8.0 |
||||
*/ |
||||
public class CssFile extends AbstractCssFileHandler { |
||||
|
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{ |
||||
"/com/fr/plugin/widget/grid/easyui/easyui.css", |
||||
"/com/fr/plugin/widget/grid/easyui/icon.css", |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.design.fun.ParameterWidgetOptionProvider; |
||||
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||
import com.fr.form.ui.Widget; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-16 |
||||
* @since 8.0 |
||||
*/ |
||||
public class GridImpl extends AbstractFormWidgetOptionProvider implements ParameterWidgetOptionProvider { |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public Class<? extends Widget> classForWidget() { |
||||
return ComboGrid.class; |
||||
} |
||||
|
||||
@Override |
||||
public Class<?> appearanceForWidget() { |
||||
return XComboGrid.class; |
||||
} |
||||
|
||||
@Override |
||||
public String iconPathForWidget() { |
||||
return "/com/fr/plugin/widget/grid/images/table.png"; |
||||
} |
||||
|
||||
@Override |
||||
public String nameForWidget() { |
||||
return "下拉表格"; |
||||
} |
||||
} |
@ -0,0 +1,19 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-16 |
||||
* @since 8.0 |
||||
*/ |
||||
public class JavaScriptFile extends AbstractJavaScriptFileHandler { |
||||
|
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[]{ |
||||
"/com/fr/plugin/widget/grid/easyui/jquery.easyui.min.js", |
||||
"/com/fr/plugin/widget/grid/web/combogrid.js" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,77 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.gui.icombobox.UIComboBoxRenderer; |
||||
import com.fr.design.mainframe.widget.editors.ComboEditor; |
||||
import com.fr.file.DatasourceManager; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.util.Iterator; |
||||
import java.util.Vector; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-17 |
||||
* @since 8.0 |
||||
*/ |
||||
public class TableDataEditor extends ComboEditor { |
||||
|
||||
|
||||
public TableDataEditor() { |
||||
super(); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 获取数据 |
||||
* |
||||
* @return 数据集信息 |
||||
*/ |
||||
public ComboBoxModel model() { |
||||
Vector<TableData> tableDatas = new Vector<TableData>(); |
||||
TableDataSource tableDataSource = DesignTableDataManager.getEditingTableDataSource(); |
||||
if (tableDataSource != null) { |
||||
Iterator it = tableDataSource.getTableDataNameIterator(); |
||||
while (it.hasNext()) { |
||||
String name = (String) it.next(); |
||||
tableDatas.add(new NameTableData(name)); |
||||
} |
||||
} |
||||
Iterator nameIt = DatasourceManager.getProviderInstance().getTableDataNameIterator(); |
||||
while (nameIt.hasNext()) { |
||||
tableDatas.add(new NameTableData((String)nameIt.next())); |
||||
} |
||||
return new DefaultComboBoxModel(tableDatas); |
||||
} |
||||
|
||||
/** |
||||
* 格子遍历器 |
||||
* |
||||
* @return 格子遍历器 |
||||
*/ |
||||
public ListCellRenderer renderer() { |
||||
return new UIComboBoxRenderer() { |
||||
@Override |
||||
public Component getListCellRendererComponent(JList jList, Object o, int i, boolean b, boolean b1) { |
||||
if (o instanceof NameTableData) { |
||||
setText(((NameTableData) o).getName()); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
@Override |
||||
public void setValue(Object value) { |
||||
comboBox.setSelectedItem(value); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValue() { |
||||
return comboBox.getSelectedItem(); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-17 |
||||
* @since 8.0 |
||||
*/ |
||||
public class TableDataRenderer extends EncoderCellRenderer { |
||||
|
||||
public TableDataRenderer() { |
||||
super(new TableDataWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,40 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.design.Exception.ValidationException; |
||||
import com.fr.design.designer.properties.Decoder; |
||||
import com.fr.design.designer.properties.Encoder; |
||||
|
||||
/** |
||||
* 包装下数据字典 |
||||
* @version 6.5.3 |
||||
*/ |
||||
public class TableDataWrapper implements Encoder, Decoder { |
||||
|
||||
public TableDataWrapper() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Object decode(String txt) { |
||||
return txt; |
||||
} |
||||
|
||||
@Override |
||||
public String encode(Object v) { |
||||
if (v == null) { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
if (v instanceof NameTableData) { |
||||
return ((NameTableData) v).getName(); |
||||
} |
||||
|
||||
return v.toString(); |
||||
} |
||||
|
||||
@Override |
||||
public void validate(String txt) throws ValidationException { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,103 @@
|
||||
package com.fr.plugin.widget.grid; |
||||
|
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XLayoutContainer; |
||||
import com.fr.design.designer.creator.XWScaleLayout; |
||||
import com.fr.design.designer.creator.XWriteAbleRepeatEditor; |
||||
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.stable.ArrayUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @date 2015-03-16 |
||||
* @since 8.0 |
||||
*/ |
||||
public class XComboGrid extends XWriteAbleRepeatEditor { |
||||
|
||||
LimpidButton btn; |
||||
|
||||
public XComboGrid(ComboGrid widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
|
||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
|
||||
return (CRPropertyDescriptor[]) ArrayUtils.addAll( |
||||
super.supportedDescriptor(), |
||||
new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName(Inter.getLocText(new String[]{"Widget", "Value"})).setEditorClass(WidgetValueEditor.class), |
||||
new CRPropertyDescriptor("tableData", this.data.getClass()) |
||||
.setI18NName("数据集") |
||||
.setEditorClass(TableDataEditor.class).setRendererClass(TableDataRenderer.class), |
||||
new CRPropertyDescriptor("keyIndex", this.data.getClass()).setI18NName("实际值索引"), |
||||
new CRPropertyDescriptor("valueIndex", this.data.getClass()).setI18NName("显示值索引") |
||||
}); |
||||
} |
||||
|
||||
public ComboGrid toData() { |
||||
return (ComboGrid) this.data; |
||||
} |
||||
|
||||
public String getIconPath() { |
||||
return "/com/fr/plugin/widget/grid/images/table.png"; |
||||
} |
||||
|
||||
@Override |
||||
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; |
||||
} |
||||
|
||||
protected void makeVisible(boolean visible) { |
||||
btn.makeVisible(visible); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前XCreator的一个封装父容器 |
||||
* |
||||
* @param widgetName 当前组件名 |
||||
* @return 封装的父容器 |
||||
* @date 2014-11-25-下午4:47:23 |
||||
*/ |
||||
protected XLayoutContainer getCreatorWrapper(String widgetName) { |
||||
return new XWScaleLayout(); |
||||
} |
||||
|
||||
/** |
||||
* 将当前对象添加到父容器中 |
||||
* |
||||
* @param parentPanel 父容器组件 |
||||
* @date 2014-11-25-下午4:57:55 |
||||
*/ |
||||
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,96 @@
|
||||
.icon-blank{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/blank.gif') no-repeat center center; |
||||
} |
||||
.icon-add{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/edit_add.png') no-repeat center center; |
||||
} |
||||
.icon-edit{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/pencil.png') no-repeat center center; |
||||
} |
||||
.icon-clear{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/clear.png') no-repeat center center; |
||||
} |
||||
.icon-remove{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/edit_remove.png') no-repeat center center; |
||||
} |
||||
.icon-save{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/filesave.png') no-repeat center center; |
||||
} |
||||
.icon-cut{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/cut.png') no-repeat center center; |
||||
} |
||||
.icon-ok{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/ok.png') no-repeat center center; |
||||
} |
||||
.icon-no{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/no.png') no-repeat center center; |
||||
} |
||||
.icon-cancel{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/cancel.png') no-repeat center center; |
||||
} |
||||
.icon-reload{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/reload.png') no-repeat center center; |
||||
} |
||||
.icon-search{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/search.png') no-repeat center center; |
||||
} |
||||
.icon-print{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/print.png') no-repeat center center; |
||||
} |
||||
.icon-help{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/help.png') no-repeat center center; |
||||
} |
||||
.icon-undo{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/undo.png') no-repeat center center; |
||||
} |
||||
.icon-redo{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/redo.png') no-repeat center center; |
||||
} |
||||
.icon-back{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/back.png') no-repeat center center; |
||||
} |
||||
.icon-sum{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/sum.png') no-repeat center center; |
||||
} |
||||
.icon-tip{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/tip.png') no-repeat center center; |
||||
} |
||||
.icon-filter{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/filter.png') no-repeat center center; |
||||
} |
||||
.icon-man{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/man.png') no-repeat center center; |
||||
} |
||||
.icon-lock{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/lock.png') no-repeat center center; |
||||
} |
||||
.icon-more{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/more.png') no-repeat center center; |
||||
} |
||||
|
||||
|
||||
.icon-mini-add{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/mini_add.png') no-repeat center center; |
||||
} |
||||
.icon-mini-edit{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/mini_edit.png') no-repeat center center; |
||||
} |
||||
.icon-mini-refresh{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/mini_refresh.png') no-repeat center center; |
||||
} |
||||
|
||||
.icon-large-picture{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/large_picture.png') no-repeat center center; |
||||
} |
||||
.icon-large-clipart{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/large_clipart.png') no-repeat center center; |
||||
} |
||||
.icon-large-shapes{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/large_shapes.png') no-repeat center center; |
||||
} |
||||
.icon-large-smartart{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/large_smartart.png') no-repeat center center; |
||||
} |
||||
.icon-large-chart{ |
||||
background:url('${servletURL}?op=resource&resource=/com/fr/plugin/widget/grid/easyui/icons/large_chart.png') no-repeat center center; |
||||
} |
After Width: | Height: | Size: 912 B |
After Width: | Height: | Size: 43 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 779 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 625 B |
After Width: | Height: | Size: 898 B |
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 311 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 244 B |
After Width: | Height: | Size: 161 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 110 B |
After Width: | Height: | Size: 922 B |
After Width: | Height: | Size: 883 B |
After Width: | Height: | Size: 713 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 708 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 813 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 743 B |
After Width: | Height: | Size: 707 B |
After Width: | Height: | Size: 184 B |
After Width: | Height: | Size: 43 B |
After Width: | Height: | Size: 173 B |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 220 B |
After Width: | Height: | Size: 626 B |
After Width: | Height: | Size: 319 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 6.0 KiB |
After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 852 B |
After Width: | Height: | Size: 813 B |
After Width: | Height: | Size: 863 B |
After Width: | Height: | Size: 115 B |
After Width: | Height: | Size: 150 B |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 921 B |
After Width: | Height: | Size: 356 B |
@ -0,0 +1,100 @@
|
||||
(function ($) { |
||||
/** |
||||
* @class FR.ComboGrid |
||||
* @extends FR.TriggerEditor |
||||
*/ |
||||
FR.ComboGrid = FR.extend(FR.TriggerEditor, { |
||||
_defaultConfig: function () { |
||||
return $.extend(FR.ComboGrid.superclass._defaultConfig.apply(), { |
||||
showWidth : 500, |
||||
showHeight : 280, |
||||
defaultWidth : 80 |
||||
}); |
||||
}, |
||||
_init: function () { |
||||
FR.ComboGrid.superclass._init.apply(this, arguments); |
||||
}, |
||||
|
||||
onTriggerClick: function () { |
||||
var $t = $('<table style="width:700px;height:250px"/>'); |
||||
var opt = this.options, self = this; |
||||
if (opt.columns) { |
||||
self._refreshGrid($t, opt.columns, opt.data); |
||||
} else { |
||||
$.ajax({ |
||||
url: opt.widgetUrl, |
||||
success: function (res) { |
||||
var data = FR.jsonDecode(res); |
||||
var columnInfo = data[0]; |
||||
var columnName = columnInfo["columnNames"]; |
||||
|
||||
var valueInfo = columnInfo["valueInfo"]; |
||||
opt.valueColumnName = valueInfo["valueColumnName"]; |
||||
opt.textColumnName = valueInfo["textColumnName"]; |
||||
|
||||
var columns = []; |
||||
var columnCount = columnName.length; |
||||
if (columnCount * opt.defaultWidth < opt.showWidth) { |
||||
opt.defaultWidth = opt.showWidth / columnCount; |
||||
} |
||||
for (var i = 0, len = columnCount; i < len; i++) { |
||||
columns.push({ |
||||
field: columnName[i], |
||||
title: columnName[i], |
||||
width: opt.defaultWidth, |
||||
sortable: true |
||||
}); |
||||
} |
||||
|
||||
opt.columns = [columns]; |
||||
|
||||
opt.data = data[1]; |
||||
|
||||
self._refreshGrid($t, opt.columns, opt.data); |
||||
} |
||||
}); |
||||
} |
||||
}, |
||||
_refreshGrid: function ($t, columns, data) { |
||||
var self = this, opt = this.options; |
||||
FR.showDialog({ |
||||
title: "下拉表格", |
||||
width: 500, |
||||
height: 280, |
||||
contentHtml: $t |
||||
}); |
||||
$t.datagrid({ |
||||
singleSelect: true, |
||||
collapsible: true, |
||||
columns: columns, |
||||
data: data, |
||||
onClickRow : function(rowIndex, rowData) { |
||||
self._setTextAndValue(rowData[opt.textColumnName], rowData[opt.valueColumnName]); |
||||
FR.destroyDialog(); |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
|
||||
_setTextAndValue : function(text, value) { |
||||
this.setText(text); |
||||
this.setValue(value); |
||||
}, |
||||
|
||||
getValue : function() { |
||||
return this.options.value; |
||||
}, |
||||
|
||||
setValue : function(value) { |
||||
this.options.value = value; |
||||
}, |
||||
|
||||
setText: function (text) { |
||||
this.editComp.val(text); |
||||
}, |
||||
getText : function() { |
||||
return this.editComp.val(); |
||||
} |
||||
}); |
||||
$.shortcut('combogrid', FR.ComboGrid); |
||||
})(jQuery); |