felix xia
5 years ago
25 changed files with 631 additions and 552 deletions
@ -1,13 +0,0 @@ |
|||||||
### 该问题是怎么引起的? |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 重现步骤 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 报错信息 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,15 +0,0 @@ |
|||||||
### 该Pull Request关联的Issue |
|
||||||
|
|
||||||
|
|
||||||
### 修改描述 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 测试用例 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 修复效果的截屏 |
|
||||||
|
|
||||||
|
|
||||||
|
|
After Width: | Height: | Size: 5.4 KiB |
@ -0,0 +1,15 @@ |
|||||||
|
数字滚动控件使用手册 |
||||||
|
|
||||||
|
数字滚动控件,用于决策报表中以滚动的方式显示数据源中的数字。 |
||||||
|
|
||||||
|
一、设置数据源 |
||||||
|
数据源有两种:1、通过公式生成随机数;2、从数据集读取数据。数据可以是整数,小数。 |
||||||
|
|
||||||
|
二、属性设置 |
||||||
|
1、持续时间:设置数据滚动动画的持续时间。 |
||||||
|
2、前/后缀:设置显示在数字前/后的字符。 |
||||||
|
3、文字大小:调整数字的大小。 |
||||||
|
3、文字颜色。 |
||||||
|
4、背景颜色。 |
||||||
|
5、分组:勾选分组后,10000显示为10,000 |
||||||
|
6、小数位数:设置小数点后显示的位数。 |
@ -1,18 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<module type="JAVA_MODULE" version="4"> |
|
||||||
<component name="NewModuleRootManager"> |
|
||||||
<output url="file://$MODULE_DIR$/../project/out/production/plugin-widget-digitroll" /> |
|
||||||
<output-test url="file://$MODULE_DIR$/../project/out/test/plugin-widget-digitroll" /> |
|
||||||
<exclude-output /> |
|
||||||
<content url="file://$MODULE_DIR$"> |
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
|
||||||
</content> |
|
||||||
<orderEntry type="inheritedJdk" /> |
|
||||||
<orderEntry type="sourceFolder" forTests="false" /> |
|
||||||
<orderEntry type="library" name="lib" level="project" /> |
|
||||||
<orderEntry type="module" module-name="designer" /> |
|
||||||
<orderEntry type="module" module-name="designer_base" /> |
|
||||||
<orderEntry type="module" module-name="designer_chart" /> |
|
||||||
<orderEntry type="module" module-name="designer_form" /> |
|
||||||
</component> |
|
||||||
</module> |
|
@ -0,0 +1,52 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module type="JAVA_MODULE" version="4"> |
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6"> |
||||||
|
<output url="file://$MODULE_DIR$/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.widget.digitroll.v10-1.0/classes" /> |
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/webroot/WEB-INF/classes" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="inheritedJdk" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.third:fine-third:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.activator:fine-activator:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.core:fine-core:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.17" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.webui:fine-webui:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.datasource:fine-datasource:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.decision:fine-decision:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.decision:fine-decision-report:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.schedule:fine-schedule:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.schedule:fine-schedule-report:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.intelligence:fine-swift:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fineio:fineio:2.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.third.server:servlet-api:3.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.intelligence:fine-accumulator:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.report:fine-report-engine:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.fr.report:fine-report-designer:10.0-RELEASE-SNAPSHOT" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.socket:socket.io-client:0.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: io.socket:engine.io-client:0.7.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp-ws:3.0.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okhttp3:okhttp:3.0.1" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: com.squareup.okio:okio:1.6.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.json:json:20090211" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.6.9" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.swingexplorer:swexpl:2.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.swingexplorer:swag:1.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-catalina:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-servlet-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jsp-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-el-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-juli:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jni:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-coyote:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-util:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-util-scan:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-jaspic-api:8.5.32" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.44" level="project" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,14 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<parent> |
||||||
|
<groupId>com.fr.plugin</groupId> |
||||||
|
<artifactId>starter</artifactId> |
||||||
|
<version>10.0</version> |
||||||
|
</parent> |
||||||
|
<packaging>jar</packaging> |
||||||
|
<artifactId>plugin-widget-digitroll10</artifactId> |
||||||
|
</project> |
@ -0,0 +1,319 @@ |
|||||||
|
package com.fr.plugin.widget.digitroll; |
||||||
|
|
||||||
|
import com.fr.base.Formula; |
||||||
|
import com.fr.base.ParameterMapNameSpace; |
||||||
|
import com.fr.form.data.DataBinding; |
||||||
|
import com.fr.form.ui.DataControl; |
||||||
|
import com.fr.form.ui.DirectWriteEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.WidgetValue; |
||||||
|
import com.fr.form.ui.concept.data.ValueInitializer; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
import com.fr.stable.CodeUtils; |
||||||
|
import com.fr.stable.core.NodeVisitor; |
||||||
|
import com.fr.stable.script.CalculatorProvider; |
||||||
|
import com.fr.stable.web.Repository; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
import com.fr.web.core.TemplateSessionIDInfo; |
||||||
|
import com.fr.web.utils.WebUtils; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
|
||||||
|
public class DigitRollWidget extends DirectWriteEditor implements DataControl { |
||||||
|
|
||||||
|
public static final String XTYPE = "digitroll"; |
||||||
|
public static final String DURATION = "duration"; |
||||||
|
public static final String FONT_SIZE = "fontSize"; |
||||||
|
public static final String FONT_COLOR = "fontColor"; |
||||||
|
public static final String BACKGROUND_COLOR = "backgroundColor"; |
||||||
|
public static final String PREFIX = "prefix"; |
||||||
|
public static final String SUFFIX = "suffix"; |
||||||
|
public static final String GROUP = "group"; |
||||||
|
public static final String DECIMAL_PALACES = "decimalPlaces"; |
||||||
|
public static final String DECIMAL = "decimal"; |
||||||
|
|
||||||
|
private ValueInitializer widgetValue; |
||||||
|
private int duration; |
||||||
|
private int fontSize; |
||||||
|
private Object fontColor; |
||||||
|
private Object backgroundColor; |
||||||
|
private String prefix; |
||||||
|
private String suffix; |
||||||
|
private boolean group; |
||||||
|
private int decimalPlaces; |
||||||
|
|
||||||
|
public DigitRollWidget() { |
||||||
|
widgetValue = new WidgetValue(); |
||||||
|
duration = 0; |
||||||
|
fontSize = 70; |
||||||
|
fontColor = new Color(204, 204, 204); |
||||||
|
backgroundColor = new Color(51, 51, 51); |
||||||
|
prefix = ""; |
||||||
|
suffix = ""; |
||||||
|
setGroup(true); |
||||||
|
setDecimalPlaces(0); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean isGroup() { |
||||||
|
return group; |
||||||
|
} |
||||||
|
|
||||||
|
public void setGroup(boolean group) { |
||||||
|
this.group = group; |
||||||
|
} |
||||||
|
|
||||||
|
public int getDecimalPlaces() { |
||||||
|
return decimalPlaces; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDecimalPlaces(int decimalPlaces) { |
||||||
|
this.decimalPlaces = decimalPlaces; |
||||||
|
} |
||||||
|
|
||||||
|
public int getDuration() { |
||||||
|
return this.duration; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDuration(int duration) { |
||||||
|
this.duration = duration; |
||||||
|
} |
||||||
|
|
||||||
|
public ValueInitializer getWidgetValue() { |
||||||
|
return this.widgetValue; |
||||||
|
} |
||||||
|
|
||||||
|
public void setWidgetValue(ValueInitializer widgetValue) { |
||||||
|
this.widgetValue = widgetValue; |
||||||
|
} |
||||||
|
|
||||||
|
public int getFontSize() { |
||||||
|
return fontSize; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFontSize(int fontSize) { |
||||||
|
this.fontSize = fontSize; |
||||||
|
} |
||||||
|
|
||||||
|
public Object getFontColor() { |
||||||
|
return fontColor; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFontColor(Object fontColor) { |
||||||
|
this.fontColor = fontColor; |
||||||
|
} |
||||||
|
|
||||||
|
public Object getBackgroundColor() { |
||||||
|
return backgroundColor; |
||||||
|
} |
||||||
|
|
||||||
|
public void setBackgroundColor(Object backgroundColor) { |
||||||
|
this.backgroundColor = backgroundColor; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPrefix() { |
||||||
|
return prefix; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPrefix(String prefix) { |
||||||
|
this.prefix = prefix; |
||||||
|
} |
||||||
|
|
||||||
|
public String getSuffix() { |
||||||
|
return suffix; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSuffix(String suffix) { |
||||||
|
this.suffix = suffix; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getXType() {//控件类型,参考其他的案例,返回的是文本框
|
||||||
|
return XTYPE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int[] getValueType() { |
||||||
|
return new int[]{TYPE_FORMULA, TYPE_DATABINDING}; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] dependence(CalculatorProvider calculatorProvider) { |
||||||
|
return super.dependence(calculatorProvider); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDataBindDefaultValue(CalculatorProvider calculatorProvider) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 读取插件的值 |
||||||
|
*/ |
||||||
|
private int dataSetCursor = 0; |
||||||
|
|
||||||
|
private double getWidgetValue(Calculator calculator) throws Exception { |
||||||
|
double value = 0; |
||||||
|
if (this.widgetValue.getValue() == null) { |
||||||
|
value = 0; |
||||||
|
} else if (this.widgetValue.getValue() instanceof Formula) { |
||||||
|
Object v = calculator.eval((Formula) this.widgetValue.getValue()); |
||||||
|
value = Util.valueChangeToDouble(v); |
||||||
|
} else if (this.widgetValue.getValue() instanceof DataBinding) { |
||||||
|
calculator.setAttribute(Widget.NAME, this.getWidgetName().toUpperCase()); |
||||||
|
calculator.setAttribute(ValueInitializer.RETURN_ARRAY, true); |
||||||
|
calculator.setAttribute(ValueInitializer.VALUE_REPEAT, true); |
||||||
|
Object r = getWidgetValue().executeResult(calculator); |
||||||
|
if (r instanceof Object[]) { |
||||||
|
Object[] ra = (Object[]) r; |
||||||
|
dataSetCursor %= ra.length; |
||||||
|
Object val = ra[dataSetCursor++]; |
||||||
|
return Util.valueChangeToDouble(val); |
||||||
|
} else { |
||||||
|
return (Util.valueChangeToDouble(r)); |
||||||
|
} |
||||||
|
} |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void createValueResult(CalculatorProvider calculatorProvider, JSONObject jsonObject) { |
||||||
|
Object result = null; |
||||||
|
try { |
||||||
|
if (widgetValue.getValue() instanceof Formula) { |
||||||
|
result = calculatorProvider.eval((Formula) widgetValue.getValue()); |
||||||
|
} else if (widgetValue.getValue() instanceof DataBinding) { |
||||||
|
calculatorProvider.setAttribute(Widget.NAME, this.getWidgetName().toUpperCase()); |
||||||
|
calculatorProvider.setAttribute(ValueInitializer.RETURN_ARRAY, true); |
||||||
|
calculatorProvider.setAttribute(ValueInitializer.VALUE_REPEAT, true); |
||||||
|
result = getWidgetValue().executeResult(calculatorProvider); |
||||||
|
} |
||||||
|
jsonObject.put(this.widgetName.toUpperCase(), result == null ? 0 : result); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getFormatText() { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject createJSONConfig(Repository repository, |
||||||
|
Calculator calculator, |
||||||
|
NodeVisitor visitor) throws JSONException { |
||||||
|
JSONObject jsonConfig = super.createJSONConfig(repository, calculator, visitor); |
||||||
|
Object value = jsonConfig.get("value"); |
||||||
|
if (value != null) { |
||||||
|
Double v = 0d; |
||||||
|
try { |
||||||
|
JSONArray jsonArray = (JSONArray) value; |
||||||
|
v = jsonArray.getDouble(0); |
||||||
|
} catch (Exception e) { |
||||||
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||||
|
} |
||||||
|
jsonConfig.put("value", v); |
||||||
|
} |
||||||
|
|
||||||
|
jsonConfig.put(DURATION, this.value2Config(this.duration, calculator)); |
||||||
|
jsonConfig.put(PREFIX, getPrefix()); |
||||||
|
jsonConfig.put(SUFFIX, getSuffix()); |
||||||
|
jsonConfig.put(FONT_COLOR, Util.colorValueToHexString(((Color) getFontColor()).getRGB())); |
||||||
|
jsonConfig.put(BACKGROUND_COLOR, Util.colorValueToHexString(((Color) getBackgroundColor()).getRGB())); |
||||||
|
jsonConfig.put(FONT_SIZE, getFontSize()); |
||||||
|
jsonConfig.put(GROUP, isGroup()); |
||||||
|
//jsonConfig.put(DECIMAL, (getDecimalPlaces() <= 0 ? false : true));
|
||||||
|
jsonConfig.put(DECIMAL_PALACES, getDecimalPlaces()); |
||||||
|
|
||||||
|
String[] dependence = this.dependence(calculator); |
||||||
|
if (!ArrayUtils.isEmpty(dependence)) { |
||||||
|
jsonConfig.put("dependence", dependence); |
||||||
|
} |
||||||
|
return jsonConfig; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONArray createJSONData(TemplateSessionIDInfo sessionIDInfor, |
||||||
|
Calculator calculator, HttpServletRequest request) throws Exception { |
||||||
|
JSONArray jsonArray; |
||||||
|
jsonArray = super.createJSONData(sessionIDInfor, calculator, request); |
||||||
|
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(sessionIDInfor.getParameterMap4Execute()); |
||||||
|
DependenceNameSpace dependenceNameSpace = new DependenceNameSpace(CodeUtils.cjkDecode(WebUtils.getHTTPRequestParameter(request, "dependence"))); |
||||||
|
calculator.pushNameSpace(parameterMapNameSpace); |
||||||
|
calculator.pushNameSpace(dependenceNameSpace); |
||||||
|
JSONObject jsonObject = new JSONObject(); |
||||||
|
jsonObject.put("value", this.getWidgetValue(calculator)); |
||||||
|
jsonArray.put(jsonObject); |
||||||
|
calculator.removeNameSpace(parameterMapNameSpace); |
||||||
|
calculator.removeNameSpace(dependenceNameSpace); |
||||||
|
return jsonArray; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] supportedEvents() { |
||||||
|
return new String[0]; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
super.readXML(reader); |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tagName = reader.getTagName(); |
||||||
|
if (tagName.equals("DigitRollAttr")) { |
||||||
|
String s = null; |
||||||
|
if ((s = reader.getAttrAsString(DURATION, null)) != null) { |
||||||
|
this.setDuration(Integer.parseInt(s)); |
||||||
|
} |
||||||
|
if ((s = reader.getAttrAsString(FONT_SIZE, null)) != null) { |
||||||
|
setFontSize(Integer.parseInt(s)); |
||||||
|
} |
||||||
|
|
||||||
|
int color; |
||||||
|
if ((color = reader.getAttrAsInt(FONT_COLOR, -1)) != -1) { |
||||||
|
setFontColor(new Color(color)); |
||||||
|
} |
||||||
|
if ((color = reader.getAttrAsInt(BACKGROUND_COLOR, -1)) != -1) { |
||||||
|
setBackgroundColor(new Color(color)); |
||||||
|
} |
||||||
|
setPrefix(reader.getAttrAsString(PREFIX, "")); |
||||||
|
setSuffix(reader.getAttrAsString(SUFFIX, "")); |
||||||
|
setDecimalPlaces(reader.getAttrAsInt(DECIMAL_PALACES, 0)); |
||||||
|
setGroup(reader.getAttrAsBoolean(GROUP, true)); |
||||||
|
|
||||||
|
} else if ("widgetValue".equals(tagName)) { |
||||||
|
this.widgetValue = new WidgetValue(); |
||||||
|
reader.readXMLObject(this.widgetValue); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
super.writeXML(writer); |
||||||
|
writer.startTAG("DigitRollAttr"); |
||||||
|
if (this.duration != 0) { |
||||||
|
writer.attr(DURATION, this.getDuration()); |
||||||
|
} |
||||||
|
|
||||||
|
writer.attr(FONT_SIZE, getFontSize()); |
||||||
|
writer.attr(FONT_COLOR, ((Color) getFontColor()).getRGB()); |
||||||
|
writer.attr(BACKGROUND_COLOR, ((Color) getBackgroundColor()).getRGB()); |
||||||
|
writer.attr(PREFIX, getPrefix()); |
||||||
|
writer.attr(SUFFIX, getSuffix()); |
||||||
|
writer.attr(GROUP, isGroup()); |
||||||
|
writer.attr(DECIMAL_PALACES, getDecimalPlaces()); |
||||||
|
writer.end(); |
||||||
|
|
||||||
|
if (this.widgetValue != null) { |
||||||
|
this.widgetValue.writeXML(writer); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,15 +1,30 @@ |
|||||||
package com.fr.plugin.widget.digitroll; |
package com.fr.plugin.widget.digitroll; |
||||||
|
|
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.plugin.PluginLicense; |
||||||
|
import com.fr.plugin.PluginLicenseManager; |
||||||
import com.fr.stable.fun.Authorize; |
import com.fr.stable.fun.Authorize; |
||||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
@Authorize( |
@Authorize( |
||||||
callSignKey = Constants.PLUGIN_ID |
callSignKey = Constants.PLUGIN_ID |
||||||
) |
) |
||||||
public class JavaScriptFileLoader extends AbstractJavaScriptFileHandler { |
public class JavaScriptFileLoader extends AbstractJavaScriptFileHandler { |
||||||
|
private PluginLicense license = PluginLicenseManager.getInstance().getPluginLicenseByID(Constants.PLUGIN_ID); |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String[] pathsForFiles() { |
public String[] pathsForFiles() { |
||||||
|
if (license.isAvailable()) { |
||||||
return new String[]{ |
return new String[]{ |
||||||
"/com/fr/plugin/widget/digitroll/web/widget.digitRoll.js"}; |
"/com/fr/plugin/widget/digitroll/web/widget.digitRoll.js"}; |
||||||
|
} else { |
||||||
|
JOptionPane.showMessageDialog(null |
||||||
|
, Inter.getLocText("Plugin-DigitRoll_License_Expired") |
||||||
|
, Inter.getLocText("Plugin-DigitRoll_License_Title") |
||||||
|
, JOptionPane.PLAIN_MESSAGE); |
||||||
|
return null; |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,321 +0,0 @@ |
|||||||
package com.fr.plugin.widget.digitroll; |
|
||||||
|
|
||||||
import com.fr.base.FRContext; |
|
||||||
import com.fr.base.Formula; |
|
||||||
import com.fr.base.ParameterMapNameSpace; |
|
||||||
import com.fr.form.data.DataBinding; |
|
||||||
import com.fr.form.ui.DataControl; |
|
||||||
import com.fr.form.ui.DirectWriteEditor; |
|
||||||
import com.fr.form.ui.WidgetValue; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.general.ModuleContext; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONException; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.plugin.PluginLicense; |
|
||||||
import com.fr.plugin.PluginLicenseManager; |
|
||||||
import com.fr.script.Calculator; |
|
||||||
import com.fr.stable.ArrayUtils; |
|
||||||
import com.fr.stable.CodeUtils; |
|
||||||
import com.fr.stable.core.NodeVisitor; |
|
||||||
import com.fr.stable.script.CalculatorProvider; |
|
||||||
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; |
|
||||||
import java.awt.*; |
|
||||||
|
|
||||||
|
|
||||||
public class Widget extends DirectWriteEditor implements DataControl { |
|
||||||
public static final int TYPE_YEAR_NONE = 8; |
|
||||||
public static final String ALIGN = "align"; |
|
||||||
public static final String DURATION = "duration"; |
|
||||||
public static final String FONT_SIZE = "fontSize"; |
|
||||||
public static final String FONT_COLOR = "fontColor"; |
|
||||||
public static final String BACKGROUND_COLOR = "backgroundColor"; |
|
||||||
public static final String PREFIX = "prefix"; |
|
||||||
public static final String SUFFIX = "suffix"; |
|
||||||
public static final String CSS = "css"; |
|
||||||
|
|
||||||
private WidgetValue widgetValue = new WidgetValue(); |
|
||||||
private String align = new String(); |
|
||||||
private int duration = 0; |
|
||||||
private int fontSize = 70; |
|
||||||
private Object fontColor = new Color(204, 204, 204); |
|
||||||
private Object backgroundColor = new Color(51, 51, 51); |
|
||||||
private String prefix; |
|
||||||
private String suffix; |
|
||||||
|
|
||||||
public Widget() { |
|
||||||
} |
|
||||||
|
|
||||||
public String getAlign() { |
|
||||||
return this.align; |
|
||||||
} |
|
||||||
|
|
||||||
public void setAlign(String align) { |
|
||||||
this.align = align; |
|
||||||
} |
|
||||||
|
|
||||||
public int getDuration() { |
|
||||||
return this.duration; |
|
||||||
} |
|
||||||
|
|
||||||
public void setDuration(int duration) { |
|
||||||
this.duration = duration; |
|
||||||
} |
|
||||||
|
|
||||||
public WidgetValue getWidgetValue() { |
|
||||||
return this.widgetValue; |
|
||||||
} |
|
||||||
|
|
||||||
public void setWidgetValue(WidgetValue widgetValue) { |
|
||||||
this.widgetValue = widgetValue; |
|
||||||
} |
|
||||||
|
|
||||||
public int getFontSize() { |
|
||||||
return fontSize; |
|
||||||
} |
|
||||||
|
|
||||||
public void setFontSize(int fontSize) { |
|
||||||
this.fontSize = fontSize; |
|
||||||
} |
|
||||||
|
|
||||||
public Object getFontColor() { |
|
||||||
return fontColor; |
|
||||||
} |
|
||||||
|
|
||||||
public void setFontColor(Object fontColor) { |
|
||||||
this.fontColor = fontColor; |
|
||||||
} |
|
||||||
|
|
||||||
public Object getBackgroundColor() { |
|
||||||
return backgroundColor; |
|
||||||
} |
|
||||||
|
|
||||||
public void setBackgroundColor(Object backgroundColor) { |
|
||||||
this.backgroundColor = backgroundColor; |
|
||||||
} |
|
||||||
|
|
||||||
public String getPrefix() { |
|
||||||
return prefix; |
|
||||||
} |
|
||||||
|
|
||||||
public void setPrefix(String prefix) { |
|
||||||
this.prefix = prefix; |
|
||||||
} |
|
||||||
|
|
||||||
public String getSuffix() { |
|
||||||
return suffix; |
|
||||||
} |
|
||||||
|
|
||||||
public void setSuffix(String suffix) { |
|
||||||
this.suffix = suffix; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getXType() {//控件类型,参考其他的案例,返回的是文本框
|
|
||||||
return "digitroll"; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
// 数据源类型:空置,公式,字段
|
|
||||||
public int[] getValueType() { |
|
||||||
return new int[]{TYPE_YEAR_NONE, TYPE_FORMULA, TYPE_DATABINDING}; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String[] dependence(CalculatorProvider calculatorProvider) { |
|
||||||
return super.dependence(calculatorProvider); |
|
||||||
} |
|
||||||
|
|
||||||
private int getWidgetValueFM(Calculator calculator) throws Exception { |
|
||||||
int value = 0; |
|
||||||
if (this.widgetValue.getValue() == null) { |
|
||||||
value = 0; |
|
||||||
} else if (this.widgetValue.getValue() instanceof Formula) { |
|
||||||
Object v = calculator.eval((Formula) this.widgetValue.getValue()); |
|
||||||
value = Util.valueChangeToInt(v); |
|
||||||
} else if (this.widgetValue.getValue() instanceof DataBinding) { |
|
||||||
value = this.getWidgetValueByBinding(calculator); |
|
||||||
} |
|
||||||
|
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
private int getWidgetValueByBinding(Calculator calculator) { |
|
||||||
int value = 0; |
|
||||||
WidgetValue.WidgetValueInfo valueInfo = new WidgetValue.WidgetValueInfo(this.getWidgetName()); |
|
||||||
Object result = this.getWidgetValue().createAttrResult(valueInfo, calculator, new JSONObject()); |
|
||||||
value = Util.valueChangeToInt(result); |
|
||||||
return value; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void createValueResult(DataControl dataControl, Calculator calculator, |
|
||||||
JSONObject jsonObject, JSONObject jsonObject1) { |
|
||||||
if (this.getWidgetValue() != null) { |
|
||||||
WidgetValue.WidgetValueInfo valueInfo = new WidgetValue.WidgetValueInfo(this.getWidgetName()); |
|
||||||
Object result = this.getWidgetValue().createAttrResult(valueInfo, calculator, jsonObject1); |
|
||||||
|
|
||||||
try { |
|
||||||
jsonObject.put(this.widgetName.toUpperCase(), result == null ? "" : result); |
|
||||||
} catch (JSONException e) { |
|
||||||
FRContext.getLogger().error(e.getMessage(), e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getFormatText() { |
|
||||||
return ""; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONObject createJSONConfig(Repository repository, |
|
||||||
Calculator calculator, |
|
||||||
NodeVisitor visitor) throws JSONException { |
|
||||||
// 许可证
|
|
||||||
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(Constants.PLUGIN_ID); |
|
||||||
if (pluginLicense.isAvailable()) { |
|
||||||
JSONObject jsonConfig = super.createJSONConfig(repository, calculator, visitor); |
|
||||||
try { |
|
||||||
Object value = jsonConfig.get("value"); |
|
||||||
int v = Util.valueChangeToInt(value); |
|
||||||
if (value == null) { |
|
||||||
jsonConfig.remove("value"); |
|
||||||
} else if (value instanceof String) { |
|
||||||
jsonConfig.put("value", (new JSONObject()).put("digitroll", v)); |
|
||||||
} else { |
|
||||||
jsonConfig.put("value", v); |
|
||||||
} |
|
||||||
} catch (Exception e) { |
|
||||||
e.printStackTrace(); |
|
||||||
} |
|
||||||
|
|
||||||
if (this.align != null) { |
|
||||||
jsonConfig.put(ALIGN, this.value2Config(this.align, calculator)); |
|
||||||
} |
|
||||||
|
|
||||||
jsonConfig.put(DURATION, this.value2Config(this.duration, calculator)); |
|
||||||
jsonConfig.put(PREFIX, getPrefix()); |
|
||||||
jsonConfig.put(SUFFIX, getSuffix()); |
|
||||||
jsonConfig.put(CSS, buildCss()); |
|
||||||
|
|
||||||
String[] dependence = this.dependence(calculator); |
|
||||||
if (!ArrayUtils.isEmpty(dependence)) { |
|
||||||
jsonConfig.put("dependence", dependence); |
|
||||||
} |
|
||||||
return jsonConfig; |
|
||||||
} else { |
|
||||||
return licenseErr(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private String buildCss() { |
|
||||||
StringBuilder css = new StringBuilder(); |
|
||||||
String fontClr = Util.colorValueToHexString(((Color) getFontColor()).getRGB()); |
|
||||||
String bgClr = Util.colorValueToHexString(((Color) getBackgroundColor()).getRGB()); |
|
||||||
css.append("color:" + fontClr + ';'); |
|
||||||
css.append("font-size:" + getFontSize() + ';'); |
|
||||||
css.append("background:" + bgClr + ";"); |
|
||||||
css.append("position:absolute;"); |
|
||||||
css.append("left:0px;"); |
|
||||||
css.append("top:0px;"); |
|
||||||
return css.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public JSONArray createJSONData(SessionIDInfor sessionIDInfor, |
|
||||||
Calculator calculator, HttpServletRequest request) throws Exception { |
|
||||||
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(Constants.PLUGIN_ID); |
|
||||||
JSONArray errorMsg; |
|
||||||
if (pluginLicense.isAvailable()) { |
|
||||||
errorMsg = super.createJSONData(sessionIDInfor, calculator, request); |
|
||||||
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(sessionIDInfor.getParameterMap4Execute()); |
|
||||||
DependenceNameSpace dependenceNameSpace = new DependenceNameSpace(CodeUtils.cjkDecode(WebUtils.getHTTPRequestParameter(request, "dependence"))); |
|
||||||
calculator.pushNameSpace(parameterMapNameSpace); |
|
||||||
calculator.pushNameSpace(dependenceNameSpace); |
|
||||||
JSONObject jsonObject = new JSONObject(); |
|
||||||
jsonObject.put("value", this.getWidgetValueFM(calculator)); |
|
||||||
errorMsg.put(jsonObject); |
|
||||||
calculator.removeNameSpace(parameterMapNameSpace); |
|
||||||
calculator.removeNameSpace(dependenceNameSpace); |
|
||||||
return errorMsg; |
|
||||||
} else { |
|
||||||
errorMsg = new JSONArray(); |
|
||||||
errorMsg.put(licenseErr()); |
|
||||||
return errorMsg; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private JSONObject licenseErr() throws JSONException { |
|
||||||
return (new JSONObject()).put("text", Inter.getLocText("Plugin-Flip_License_Expired")) |
|
||||||
.put("value", Inter.getLocText("Plugin-Flip_License_Expired")); |
|
||||||
} |
|
||||||
|
|
||||||
private boolean isDesign() { |
|
||||||
return ModuleContext.isModuleStarted("com.fr.design.module.DesignerModule"); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String[] supportedEvents() { |
|
||||||
return new String[0]; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void readXML(XMLableReader reader) { |
|
||||||
super.readXML(reader); |
|
||||||
if (reader.isChildNode()) { |
|
||||||
String tagName = reader.getTagName(); |
|
||||||
if (tagName.equals("DigitRollAttr")) { |
|
||||||
String s = null; |
|
||||||
if ((s = reader.getAttrAsString(ALIGN, null)) != null) { |
|
||||||
this.setAlign(s); |
|
||||||
} |
|
||||||
if ((s = reader.getAttrAsString(DURATION, null)) != null) { |
|
||||||
this.setDuration(Integer.parseInt(s)); |
|
||||||
} |
|
||||||
if ((s = reader.getAttrAsString(FONT_SIZE, null)) != null) { |
|
||||||
setFontSize(Integer.parseInt(s)); |
|
||||||
} |
|
||||||
|
|
||||||
int color; |
|
||||||
if ((color = reader.getAttrAsInt(FONT_COLOR, -1)) != -1) { |
|
||||||
setFontColor(new Color(color)); |
|
||||||
} |
|
||||||
if ((color = reader.getAttrAsInt(BACKGROUND_COLOR, -1)) != -1) { |
|
||||||
setBackgroundColor(new Color(color)); |
|
||||||
} |
|
||||||
} else if ("widgetValue".equals(tagName)) { |
|
||||||
this.widgetValue = new WidgetValue(); |
|
||||||
reader.readXMLObject(this.widgetValue); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public void writeXML(XMLPrintWriter writer) { |
|
||||||
super.writeXML(writer); |
|
||||||
writer.startTAG("DigitRollAttr"); |
|
||||||
if (this.align != null) { |
|
||||||
writer.attr(ALIGN, this.getAlign().toString()); |
|
||||||
} |
|
||||||
|
|
||||||
if (this.duration != 0) { |
|
||||||
writer.attr(DURATION, this.getDuration()); |
|
||||||
} |
|
||||||
|
|
||||||
writer.attr(FONT_SIZE, getFontSize()); |
|
||||||
writer.attr(FONT_COLOR, ((Color) getFontColor()).getRGB()); |
|
||||||
writer.attr(BACKGROUND_COLOR, ((Color) getBackgroundColor()).getRGB()); |
|
||||||
writer.end(); |
|
||||||
|
|
||||||
if (this.widgetValue != null) { |
|
||||||
this.widgetValue.writeXML(writer); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,84 +0,0 @@ |
|||||||
package com.fr.plugin.widget.digitroll; |
|
||||||
|
|
||||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
|
||||||
import com.fr.design.designer.creator.XWidgetCreator; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.gui.itextfield.UITextField; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.mainframe.widget.editors.ColorEditor; |
|
||||||
import com.fr.form.ui.Widget; |
|
||||||
import com.fr.general.IOUtils; |
|
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.plugin.widget.digitroll.editor.DigitRollAlign; |
|
||||||
import com.fr.plugin.widget.digitroll.editor.DigitRollDataSourceEditor; |
|
||||||
import com.fr.stable.ArrayUtils; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.awt.*; |
|
||||||
import java.beans.IntrospectionException; |
|
||||||
|
|
||||||
public class WidgetUI extends XWidgetCreator { |
|
||||||
private UITextField textField; |
|
||||||
|
|
||||||
public WidgetUI(Widget widget, Dimension dimension) { |
|
||||||
super(widget, dimension); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
protected JComponent initEditor() { |
|
||||||
//界面,就是在拖动到主面板上的时候,添加了一个LABLE控件,然后显示图标,并居中对齐
|
|
||||||
if (this.editor == null) { |
|
||||||
this.editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
UILabel label = new UILabel(); |
|
||||||
label.setIcon(IOUtils.readIcon("/com/fr/plugin/widget/digitroll/images/digitroll_display.png")); |
|
||||||
label.setHorizontalAlignment(0); |
|
||||||
label.setVerticalAlignment(0); |
|
||||||
this.editor.add(label, "Center"); |
|
||||||
this.textField = new UITextField(5); |
|
||||||
this.textField.setOpaque(false); |
|
||||||
this.editor.add(this.textField, "South"); |
|
||||||
this.editor.setBackground(Color.WHITE); |
|
||||||
} |
|
||||||
|
|
||||||
return this.editor; |
|
||||||
} |
|
||||||
|
|
||||||
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
||||||
return ArrayUtils.addAll(super.supportedDescriptor() |
|
||||||
, new CRPropertyDescriptor[]{ |
|
||||||
(new CRPropertyDescriptor("widgetValue", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_DataSource")) |
|
||||||
.setEditorClass(DigitRollDataSourceEditor.class) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("align", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_AlignType")) |
|
||||||
.setEditorClass(DigitRollAlign.class) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("duration", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Duration")) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("prefix", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Prefix")) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("suffix", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Suffix")) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("fontSize", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_FontSize")) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("fontColor", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_ColorFont")) |
|
||||||
.setEditorClass(ColorEditor.class) |
|
||||||
.putKeyValue("category", "Advanced"), |
|
||||||
(new CRPropertyDescriptor("backgroundColor", this.data.getClass())) |
|
||||||
.setI18NName(Inter.getLocText("Plugin-DigitRoll_ColorBackground")) |
|
||||||
.setEditorClass(ColorEditor.class) |
|
||||||
.putKeyValue("category", "Advanced") |
|
||||||
} |
|
||||||
); |
|
||||||
} |
|
||||||
|
|
||||||
public String getIconPath() { |
|
||||||
return "com/fr/plugin/widget/digitroll/images/digitroll_icon.png"; |
|
||||||
} |
|
||||||
} |
|
@ -1,28 +0,0 @@ |
|||||||
package com.fr.plugin.widget.digitroll.editor; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.widget.editors.ComboEditor; |
|
||||||
import com.fr.general.Inter; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.util.Vector; |
|
||||||
|
|
||||||
public class DigitRollAlign extends ComboEditor { |
|
||||||
public DigitRollAlign() { |
|
||||||
} |
|
||||||
|
|
||||||
public ComboBoxModel model() { |
|
||||||
Vector<String> vector = new Vector(); |
|
||||||
vector.add(Inter.getLocText("Plugin-DigitRoll_AlignLeft")); |
|
||||||
vector.add(Inter.getLocText("Plugin-DigitRoll_AlignCenter")); |
|
||||||
vector.add(Inter.getLocText("Plugin-DigitRoll_AlignRight")); |
|
||||||
return new DefaultComboBoxModel(vector); |
|
||||||
} |
|
||||||
|
|
||||||
/*public void setValue(Object o) { |
|
||||||
this.comboBox.setSelectedItem(o); |
|
||||||
}*/ |
|
||||||
|
|
||||||
/*public Object getValue() { |
|
||||||
return this.comboBox.getSelectedItem(); |
|
||||||
}*/ |
|
||||||
} |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 744 B After Width: | Height: | Size: 3.2 KiB |
@ -1,14 +1,17 @@ |
|||||||
Plugin-DigitRoll_Widget=DigitRoll |
Plugin-DigitRoll_Widget=DigitRoll |
||||||
|
Plugin-DigitRoll_Advanced=Advanced |
||||||
Plugin-DigitRoll_License_Expired=Expired |
Plugin-DigitRoll_License_Expired=Expired |
||||||
|
Plugin-DigitRoll_License_Title=License |
||||||
Plugin-DigitRoll_DataSource=DataSource |
Plugin-DigitRoll_DataSource=DataSource |
||||||
Plugin-DigitRoll_AlignType=AlignType |
|
||||||
Plugin-DigitRoll_Duration=Duration |
Plugin-DigitRoll_Duration=Duration |
||||||
Plugin-DigitRoll_Prefix=Prefix |
Plugin-DigitRoll_Prefix=Prefix |
||||||
Plugin-DigitRoll_Suffix=Suffix |
Plugin-DigitRoll_Suffix=Suffix |
||||||
Plugin-DigitRoll_None=NoneValue |
Plugin-DigitRoll_Formula=Formula |
||||||
Plugin-DigitRoll_AlignLeft=Left |
Plugin-DigitRoll_AlignLeft=Left |
||||||
Plugin-DigitRoll_AlignCenter=Center |
Plugin-DigitRoll_AlignCenter=Center |
||||||
Plugin-DigitRoll_AlignRight=Right |
Plugin-DigitRoll_AlignRight=Right |
||||||
Plugin-DigitRoll_FontSize = FontSize |
Plugin-DigitRoll_FontSize = FontSize |
||||||
Plugin-DigitRoll_ColorFont=FontColor |
Plugin-DigitRoll_ColorFont=FontColor |
||||||
Plugin-DigitRoll_ColorBackground=BackgroundColor |
Plugin-DigitRoll_ColorBackground=BackgroundColor |
||||||
|
Plugin-DigitRoll_Group=Use Grouping |
||||||
|
Plugin-DigitRoll_DecimalPlaces=Decimal Places |
@ -1,14 +1,17 @@ |
|||||||
Plugin-DigitRoll_Widget=\u6EDA\u52A8\u6570\u5B57 |
Plugin-DigitRoll_Widget=\u6EDA\u52A8\u6570\u5B57 |
||||||
|
Plugin-DigitRoll_Advanced=\u9AD8\u7EA7 |
||||||
Plugin-DigitRoll_License_Expired=\u8BB8\u53EF\u8BC1\u5DF2\u8FC7\u671F |
Plugin-DigitRoll_License_Expired=\u8BB8\u53EF\u8BC1\u5DF2\u8FC7\u671F |
||||||
|
Plugin-DigitRoll_License_Title=\u8BB8\u53EF\u8BC1 |
||||||
Plugin-DigitRoll_DataSource=\u6570\u636E\u6E90 |
Plugin-DigitRoll_DataSource=\u6570\u636E\u6E90 |
||||||
Plugin-DigitRoll_AlignType=\u5BF9\u9F50\u65B9\u5F0F |
|
||||||
Plugin-DigitRoll_Duration=\u6301\u7EED\u65F6\u95F4\uFF08\u79D2\uFF09 |
Plugin-DigitRoll_Duration=\u6301\u7EED\u65F6\u95F4\uFF08\u79D2\uFF09 |
||||||
Plugin-DigitRoll_Prefix=\u524D\u7F00 |
Plugin-DigitRoll_Prefix=\u524D\u7F00 |
||||||
Plugin-DigitRoll_Suffix=\u540E\u7F00 |
Plugin-DigitRoll_Suffix=\u540E\u7F00 |
||||||
Plugin-DigitRoll_None=\u7A7A\u503C |
Plugin-DigitRoll_Formula=\u516C\u5F0F |
||||||
Plugin-DigitRoll_AlignLeft=\u5DE6\u5BF9\u9F50 |
Plugin-DigitRoll_AlignLeft=\u5DE6\u5BF9\u9F50 |
||||||
Plugin-DigitRoll_AlignCenter=\u5C45\u4E2D\u5BF9\u9F50 |
Plugin-DigitRoll_AlignCenter=\u5C45\u4E2D\u5BF9\u9F50 |
||||||
Plugin-DigitRoll_AlignRight=\u53F3\u5BF9\u9F50 |
Plugin-DigitRoll_AlignRight=\u53F3\u5BF9\u9F50 |
||||||
Plugin-DigitRoll_FontSize = \u6587\u5B57\u5927\u5C0F |
Plugin-DigitRoll_FontSize = \u6587\u5B57\u5927\u5C0F |
||||||
Plugin-DigitRoll_ColorFont=\u6587\u5B57\u989C\u8272 |
Plugin-DigitRoll_ColorFont=\u6587\u5B57\u989C\u8272 |
||||||
Plugin-DigitRoll_ColorBackground=\u80CC\u666F\u989C\u8272 |
Plugin-DigitRoll_ColorBackground=\u80CC\u666F\u989C\u8272 |
||||||
|
Plugin-DigitRoll_Group=\u5206\u7EC4 |
||||||
|
Plugin-DigitRoll_DecimalPlaces=\u5C0F\u6570\u4F4D\u6570 |
@ -0,0 +1,21 @@ |
|||||||
|
package com.fr.plugin.widget.digitroll.ui; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.editors.ComboEditor; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.util.Vector; |
||||||
|
|
||||||
|
public class DecimalPlacesEditor extends ComboEditor { |
||||||
|
|
||||||
|
public DecimalPlacesEditor() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public ComboBoxModel model() { |
||||||
|
Vector<Integer> vector = new Vector<Integer>(); |
||||||
|
for (int i = 0; i < 11; i++) { |
||||||
|
vector.add(i); |
||||||
|
} |
||||||
|
return new DefaultComboBoxModel(vector); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,88 @@ |
|||||||
|
package com.fr.plugin.widget.digitroll.ui; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||||
|
import com.fr.design.designer.creator.XWidgetCreator; |
||||||
|
import com.fr.design.editor.editor.SpinnerIntegerEditor; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.widget.editors.BooleanEditor; |
||||||
|
import com.fr.design.mainframe.widget.editors.ColorEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.IOUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.beans.IntrospectionException; |
||||||
|
|
||||||
|
import static com.fr.plugin.widget.digitroll.DigitRollWidget.*; |
||||||
|
|
||||||
|
public class DigitRollWidgetUI extends XWidgetCreator { |
||||||
|
private UITextField textField; |
||||||
|
|
||||||
|
public DigitRollWidgetUI(Widget widget, Dimension dimension) { |
||||||
|
super(widget, dimension); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JComponent initEditor() { |
||||||
|
if (this.editor == null) { |
||||||
|
this.editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
UILabel label = new UILabel(); |
||||||
|
label.setIcon(IOUtils.readIcon("/com/fr/plugin/widget/digitroll/images/digitroll_display.png")); |
||||||
|
label.setHorizontalAlignment(0); |
||||||
|
label.setVerticalAlignment(0); |
||||||
|
this.editor.add(label, "Center"); |
||||||
|
this.textField = new UITextField(5); |
||||||
|
this.textField.setOpaque(false); |
||||||
|
this.editor.add(this.textField, "South"); |
||||||
|
this.editor.setBackground(Color.WHITE); |
||||||
|
} |
||||||
|
|
||||||
|
return this.editor; |
||||||
|
} |
||||||
|
|
||||||
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||||
|
String advanced = Inter.getLocText("Plugin-DigitRoll_Advanced"); |
||||||
|
return ArrayUtils.addAll(super.supportedDescriptor(), |
||||||
|
(new CRPropertyDescriptor("widgetValue", this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_DataSource")) |
||||||
|
.setEditorClass(DigitRollDataSourceEditor.class) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(DURATION, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Duration")) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(PREFIX, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Prefix")) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(SUFFIX, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Suffix")) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(FONT_SIZE, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_FontSize")) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(FONT_COLOR, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_ColorFont")) |
||||||
|
.setEditorClass(ColorEditor.class) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(BACKGROUND_COLOR, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_ColorBackground")) |
||||||
|
.setEditorClass(ColorEditor.class) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(GROUP, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_Group")) |
||||||
|
.setEditorClass(BooleanEditor.class) |
||||||
|
.putKeyValue("category", advanced), |
||||||
|
(new CRPropertyDescriptor(DECIMAL_PALACES, this.data.getClass())) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-DigitRoll_DecimalPlaces")) |
||||||
|
.setEditorClass(DecimalPlacesEditor.class) |
||||||
|
.putKeyValue("category", advanced) |
||||||
|
); |
||||||
|
} |
||||||
|
|
||||||
|
public String getIconPath() { |
||||||
|
return "com/fr/plugin/widget/digitroll/images/digitroll_icon.png"; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue