Browse Source

日期插件源码

master
xiamaofa 8 months ago
parent
commit
1305b1926d
  1. 3
      README.md
  2. 122
      build.gradle
  3. 13
      encrypt.xml
  4. 0
      lib/finekit-10.0.jar
  5. 32
      plugin.xml
  6. 36
      src/main/java/com/eco/plugin/zgtpbxdate/LocaleFinder.java
  7. 51
      src/main/java/com/eco/plugin/zgtpbxdate/PluginMonitor.java
  8. 15
      src/main/java/com/eco/plugin/zgtpbxdate/VSCSSFileHandler.java
  9. 26
      src/main/java/com/eco/plugin/zgtpbxdate/VSJSFileHandler.java
  10. 29
      src/main/java/com/eco/plugin/zgtpbxdate/VSMapService.java
  11. 47
      src/main/java/com/eco/plugin/zgtpbxdate/accessibles/AccessibleFormulaVueEditor.java
  12. 227
      src/main/java/com/eco/plugin/zgtpbxdate/accessibles/BaseAccessibleVueEditor.java
  13. 217
      src/main/java/com/eco/plugin/zgtpbxdate/creator/XVueDateEditor.java
  14. 66
      src/main/java/com/eco/plugin/zgtpbxdate/editors/ConfigurationItemEditor.java
  15. 86
      src/main/java/com/eco/plugin/zgtpbxdate/editors/DateFormatEditor.java
  16. 81
      src/main/java/com/eco/plugin/zgtpbxdate/editors/DateTypeEditor.java
  17. 50
      src/main/java/com/eco/plugin/zgtpbxdate/editors/FirstDayOfWeekEditor.java
  18. 79
      src/main/java/com/eco/plugin/zgtpbxdate/editors/ReturnTypeEditor.java
  19. 24
      src/main/java/com/eco/plugin/zgtpbxdate/editors/ShowDateEditor.java
  20. 157
      src/main/java/com/eco/plugin/zgtpbxdate/editors/ShowDateFormulaEditor.java
  21. 50
      src/main/java/com/eco/plugin/zgtpbxdate/editors/VueDateFormatEditor.java
  22. 50
      src/main/java/com/eco/plugin/zgtpbxdate/editors/VueDateTimeFormatEditor.java
  23. 58
      src/main/java/com/eco/plugin/zgtpbxdate/items/DateFormatItems.java
  24. 35
      src/main/java/com/eco/plugin/zgtpbxdate/items/DateTimeFormatItems.java
  25. 55
      src/main/java/com/eco/plugin/zgtpbxdate/items/FirstDayOfWeekItems.java
  26. 186
      src/main/java/com/eco/plugin/zgtpbxdate/pane/DateFormatPane.java
  27. 220
      src/main/java/com/eco/plugin/zgtpbxdate/pane/ReturnFormatPane.java
  28. 92
      src/main/java/com/eco/plugin/zgtpbxdate/pane/ShowDatePane.java
  29. 160
      src/main/java/com/eco/plugin/zgtpbxdate/pane/VueDateEditorFormDefinePane.java
  30. 135
      src/main/java/com/eco/plugin/zgtpbxdate/pane/VueDateEditorPane.java
  31. 88
      src/main/java/com/eco/plugin/zgtpbxdate/pane/self/DirectWriteEditorDefinePane.java
  32. 136
      src/main/java/com/eco/plugin/zgtpbxdate/pane/self/FieldEditorDefinePane.java
  33. 37
      src/main/java/com/eco/plugin/zgtpbxdate/provider/VSCellWidgetOptionProvider.java
  34. 40
      src/main/java/com/eco/plugin/zgtpbxdate/provider/VueFormOptionProvider.java
  35. 37
      src/main/java/com/eco/plugin/zgtpbxdate/provider/VueParameterWidgetOptionProvider.java
  36. 235
      src/main/java/com/eco/plugin/zgtpbxdate/utils/DateUtilSelf.java
  37. 559
      src/main/java/com/eco/plugin/zgtpbxdate/widget/VueDateEditor.java
  38. 65
      src/main/resources/com/eco/plugin/zgtpbxdate/css/base.css
  39. 25
      src/main/resources/com/eco/plugin/zgtpbxdate/css/custom.css
  40. 1
      src/main/resources/com/eco/plugin/zgtpbxdate/css/datepicker.css
  41. 1
      src/main/resources/com/eco/plugin/zgtpbxdate/css/iconfont.css
  42. 214
      src/main/resources/com/eco/plugin/zgtpbxdate/js/custom.js
  43. 3246
      src/main/resources/com/eco/plugin/zgtpbxdate/js/datepicker.all.js
  44. 26
      src/main/resources/com/eco/plugin/zgtpbxdate/js/datepicker.en.js
  45. 3196
      src/main/resources/com/eco/plugin/zgtpbxdate/js/moment.min.js
  46. 242
      src/main/resources/com/eco/plugin/zgtpbxdate/js/vuedatetime.js
  47. 32
      src/main/resources/com/eco/plugin/zgtpbxdate/locale/lang.properties
  48. 32
      src/main/resources/com/eco/plugin/zgtpbxdate/locale/lang_zh_CN.properties

3
README.md

@ -1,2 +1,3 @@
# shopself-rqcj # JSD-13108
JSD-13108

122
build.gradle

@ -0,0 +1,122 @@
apply plugin: 'java'
ext {
/**
* jar的路径
* 1.jar需要打包到zip中,lib根目录下
* 2.jar仅仅是编译时需要lib下子目录下即可
*/
libPath = "$projectDir/../webroot/WEB-INF/lib"
/**
* class进行加密保护
*/
guard = true
def pluginInfo = getPluginInfo()
pluginPre = "fine-plugin"
pluginName = pluginInfo.id
pluginVersion = pluginInfo.version
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes"
}
group = 'com.fr.plugin'
version = '10.0'
sourceCompatibility = '8'
sourceSets {
main {
java.outputDir = file(outputPath)
output.resourcesDir = file(outputPath)
}
}
ant.importBuild("encrypt.xml")
//ant变量
ant.projectDir = projectDir
ant.references["compile.classpath"] = ant.path {
fileset(dir: libPath, includes: '**/*.jar')
fileset(dir: ".",includes:"**/*.jar" )
}
classes.dependsOn('clean')
task copyFiles(type: Copy,dependsOn: 'classes'){
from outputPath
into "$projectDir/classes"
}
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){
from "$projectDir/classes"
into "$projectDir/transform-classes"
include "**/*.*"
}
jar.dependsOn("preJar")
task makeJar(type: Jar,dependsOn: preJar){
from fileTree(dir: "$projectDir/transform-classes")
baseName pluginPre
appendix pluginName
version pluginVersion
destinationDir = file("$buildDir/libs")
doLast(){
delete file("$projectDir/classes")
delete file("$projectDir/transform-classes")
}
}
task copyFile(type: Copy,dependsOn: ["makeJar"]){
from "$buildDir/libs"
from("$projectDir/lib") {
include "*.jar"
}
from "$projectDir/plugin.xml"
into file("$buildDir/temp/plugin")
}
task zip(type:Zip,dependsOn:["copyFile"]){
from "$buildDir/temp/plugin"
destinationDir file("$buildDir/install")
baseName pluginPre
appendix pluginName
version pluginVersion
}
//build时包含哪些文件,
processResources {
// exclude everything
// *.css没效果
// exclude '**/*.css'
// except this file
// include 'xx.xml'
}
/*读取plugin.xml中的version*/
def getPluginInfo(){
def xmlFile = file("plugin.xml")
if (!xmlFile.exists()) {
return ["id":"none", "version":"1.0.0"]
}
def plugin = new XmlParser().parse(xmlFile)
def version = plugin.version[0].text()
def id = plugin.id[0].text()
return ["id":id,"version":version]
}
repositories {
mavenLocal()
maven {
url = uri('http://mvn.finedevelop.com/repository/maven-public/')
}
}
dependencies {
//使jar
implementation fileTree(dir: 'lib', include: ['**/*.jar'])
implementation fileTree(dir: libPath, include: ['**/*.jar'])
}

13
encrypt.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<target name="compile_encrypt_javas" depends="copyFiles">
<echo message="加密文件"/>
<echo message="${projectDir}"/>
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask">
<classpath refid="compile.classpath"/>
</taskdef>
<pretreatment baseDir="${projectDir}"/>
</target>
<target name="compile_plain_javas" depends="copyFiles">
</target>
</project>

0
lib/finekit-10.0.jar

32
plugin.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>com.eco.plugin.zgtpbxdate</id>
<name><![CDATA[日期控件]]></name>
<active>yes</active>
<version>1.0.1</version>
<env-version>11.0~11.0</env-version>
<jartime>2022-09-28</jartime>
<vendor>wink</vendor>
<description><![CDATA[日期控件]]></description>
<change-notes><![CDATA[
]]></change-notes>
<main-package>com.eco.plugin.zgtpbxdate</main-package>
<prefer-packages>
<prefer-package>com.fanruan.api</prefer-package>
</prefer-packages>
<lifecycle-monitor class="com.eco.plugin.zgtpbxdate.PluginMonitor"/>
<extra-report>
<JavaScriptFileHandler class="com.eco.plugin.zgtpbxdate.VSJSFileHandler"/>
<CssFileHandler class="com.eco.plugin.zgtpbxdate.VSCSSFileHandler"/>
</extra-report>
<extra-core>
<LocaleFinder class="com.eco.plugin.zgtpbxdate.LocaleFinder"/>
</extra-core>
<extra-designer>
<FormWidgetOptionProvider class="com.eco.plugin.zgtpbxdate.provider.VueFormOptionProvider"/>
<ParameterWidgetOptionProvider class="com.eco.plugin.zgtpbxdate.provider.VueParameterWidgetOptionProvider"/>
<CellWidgetOptionProvider class="com.eco.plugin.zgtpbxdate.provider.VSCellWidgetOptionProvider"/>
</extra-designer>
<function-recorder class="com.eco.plugin.zgtpbxdate.LocaleFinder"/>
</plugin>

36
src/main/java/com/eco/plugin/zgtpbxdate/LocaleFinder.java

@ -0,0 +1,36 @@
/*
* Copyright (C), 2018-2020
* Project: starter
* FileName: LocaleFinder
* Author: Louis
* Date: 2020/8/31 22:19
*/
package com.eco.plugin.zgtpbxdate;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
/**
* <Function Description><br>
* <LocaleFinder>
*
* @author wink
* @since 1.0.0
*/
@EnableMetrics
public class LocaleFinder extends AbstractLocaleFinder {
public static final String PLUGIN_ID = "com.eco.plugin.zgtpbxdate";
@Override
@Focus(id = PLUGIN_ID, text = "Plugin-abege", source = Original.PLUGIN)
public String find() {
return "com/eco/plugin/zgtpbxdate/locale/lang";
}
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
}

51
src/main/java/com/eco/plugin/zgtpbxdate/PluginMonitor.java

@ -0,0 +1,51 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: PluginMonitor
* Author: Louis
* Date: 2021/3/30 15:10
*/
package com.eco.plugin.zgtpbxdate;
import com.eco.plugin.zgtpbxdate.pane.VueDateEditorFormDefinePane;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.widget.Appearance;
import com.fr.design.widget.FormWidgetDefinePaneFactoryBase;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
/**
* <Function Description><br>
* <PluginMonitor>
*
* @author wink
* @since 1.0.0
*/
public class PluginMonitor extends AbstractPluginLifecycleMonitor {
public PluginMonitor() {
}
public static void pluginForbid(PluginMarker pluginMarker) {
PluginManager.getController().forbid(pluginMarker, pluginTaskResult -> {
});
// LogKit.error(I18nKit.getLocText("Plugin-abege_Licence_Expired"));
}
@Override
public void beforeStop(PluginContext pluginContext) {
}
@Override
public void afterRun(PluginContext pluginContext) {
if (!pluginContext.isAvailable()) {
pluginForbid(pluginContext.getMarker());
return;
}
// FormWidget定义日期控件外观
FormWidgetDefinePaneFactoryBase.registerDefinePane(VueDateEditor.class, new Appearance(VueDateEditorFormDefinePane.class, "VueDateDefine"));
}
}

15
src/main/java/com/eco/plugin/zgtpbxdate/VSCSSFileHandler.java

@ -0,0 +1,15 @@
package com.eco.plugin.zgtpbxdate;
import com.fr.stable.fun.impl.AbstractCssFileHandler;
public class VSCSSFileHandler extends AbstractCssFileHandler {
@Override
public String[] pathsForFiles() {
return new String[]{
"com/eco/plugin/zgtpbxdate/css/base.css",
"com/eco/plugin/zgtpbxdate/css/datepicker.css",
"com/eco/plugin/zgtpbxdate/css/iconfont.css",
"com/eco/plugin/zgtpbxdate/css/custom.css",
};
}
}

26
src/main/java/com/eco/plugin/zgtpbxdate/VSJSFileHandler.java

@ -0,0 +1,26 @@
package com.eco.plugin.zgtpbxdate;
import com.fr.plugin.context.PluginContexts;
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler;
//@Authorize(callSignKey = PLUGIN_ID)
public class VSJSFileHandler extends AbstractJavaScriptFileHandler {
public VSJSFileHandler() {
}
@Override
public String[] pathsForFiles() {
if (!PluginContexts.currentContext().isAvailable()) {
PluginMonitor.pluginForbid(PluginContexts.currentContext().getMarker());
return new String[]{};
}
return new String[]{
"/com/eco/plugin/zgtpbxdate/js/moment.min.js",
"/com/eco/plugin/zgtpbxdate/js/datepicker.all.js",
"/com/eco/plugin/zgtpbxdate/js/datepicker.en.js",
"/com/eco/plugin/zgtpbxdate/js/custom.js",
"/com/eco/plugin/zgtpbxdate/js/vuedatetime.js",
};
}
}

29
src/main/java/com/eco/plugin/zgtpbxdate/VSMapService.java

@ -0,0 +1,29 @@
package com.eco.plugin.zgtpbxdate;
import com.fr.decision.webservice.v10.plugin.helper.PluginUtils;
import com.fr.json.JSONObject;
import com.fr.plugin.context.PluginMarker;
import com.fr.plugin.manage.PluginManager;
import com.fr.stable.fun.Service;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class VSMapService implements Service {
@Override
public String actionOP() {
return "restartInit";
}
@Override
public void process(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String op, String cmd) throws Exception {
PluginMarker pluginMarker = PluginUtils.createPluginMarker("com.fr.plugin.m.tree_1.0.0");
PluginManager.getController().forbid(pluginMarker, pluginTaskResult -> {
});
PluginManager.getController().enable(pluginMarker, pluginTaskResult -> {
});
WebUtils.printAsJSON(httpServletResponse, new JSONObject());
return;
}
}

47
src/main/java/com/eco/plugin/zgtpbxdate/accessibles/AccessibleFormulaVueEditor.java

@ -0,0 +1,47 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: AccessibleFormulaVueEditor
* Author: Louis
* Date: 2021/11/26 9:09
*/
package com.eco.plugin.zgtpbxdate.accessibles;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.mainframe.widget.wrappers.FormulaWrapper;
import javax.swing.*;
/**
* <Function Description><br>
* <AccessibleFormulaVueEditor>
*
* @author wink
* @since 1.0.0
*/
public class AccessibleFormulaVueEditor extends BaseAccessibleVueEditor {
private UIFormula formulaPane;
public AccessibleFormulaVueEditor() {
super(new FormulaWrapper(), new FormulaWrapper(), true);
}
protected void showEditorPane() {
if (this.formulaPane == null) {
this.formulaPane = FormulaFactory.createFormulaPane();
}
BasicDialog var1 = this.formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() {
public void doOk() {
AccessibleFormulaVueEditor.this.setValue(AccessibleFormulaVueEditor.this.formulaPane.update());
AccessibleFormulaVueEditor.this.fireStateChanged();
}
});
this.formulaPane.populate((BaseFormula) this.getValue());
var1.setVisible(true);
}
}

227
src/main/java/com/eco/plugin/zgtpbxdate/accessibles/BaseAccessibleVueEditor.java

@ -0,0 +1,227 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueAccessibleEditor
* Author: Louis
* Date: 2021/11/25 21:58
*/
package com.eco.plugin.zgtpbxdate.accessibles;
import com.fr.base.BaseUtils;
import com.fr.design.Exception.ValidationException;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.accessibles.AccessibleEditor;
import com.fr.design.mainframe.widget.editors.ITextComponent;
import com.fr.design.mainframe.widget.editors.TextField;
import com.fr.design.utils.gui.GUIPaintUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.ButtonUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
/**
* <Function Description><br>
* <VueAccessibleEditor>
*
* @author wink
* @since 1.0.0
*/
public class BaseAccessibleVueEditor extends BasicPane implements AccessibleEditor {
protected Encoder encoder;
protected ITextComponent txtValue;
private ArrayList<ChangeListener> listeners = new ArrayList();
private boolean showButton;
private Decoder decoder;
private UIButton btPopup;
public BaseAccessibleVueEditor(Encoder var1, Decoder var2, boolean var3) {
this.showButton = var3;
this.encoder = var1;
this.decoder = var2;
this.initComponents();
// this.txtValue.setEditable(var2 != null);
this.txtValue.setEditable(false);
((JComponent) this.txtValue).setOpaque(true);
((JComponent) this.txtValue).setBorder(BorderFactory.createLineBorder(Color.lightGray));
((JComponent) this.txtValue).setBackground(Color.WHITE);
}
public static void showMessage(String var0, Component var1) {
FineJOptionPane.showMessageDialog(var1, var0, "Validation Error", 0);
}
public void requestFocus() {
super.requestFocus();
if (this.decoder != null) {
((JComponent) this.txtValue).requestFocus();
} else if (this.showButton) {
this.btPopup.requestFocus();
}
}
protected ITextComponent createTextField() {
return new TextField() {
public void registerChangeListener(UIObserverListener var1) {
}
public boolean shouldResponseChangeListener() {
return false;
}
};
}
private void initComponents() {
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 1));
this.txtValue = this.createTextField();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.txtValue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent var1) {
BaseAccessibleVueEditor.this.txtValueActionPerformed(var1);
}
});
this.add((JComponent) this.txtValue, "Center");
this.setOpaque(false);
if (this.showButton) {
this.btPopup = new UIButton() {
public ButtonUI getUI() {
return new UIButtonUI() {
protected boolean isPressed(AbstractButton var1) {
return model.isArmed() && model.isPressed();
}
protected void doExtraPainting(UIButton var1, Graphics2D var2, int var3, int var4, String var5) {
if (this.isPressed(var1) && var1.isPressedPainted()) {
GUIPaintUtils.fillPressed(var2, 0, 0, var3, var4, var1.isRoundBorder(), var1.getRectDirection(), var1.isDoneAuthorityEdited(var5), UIConstants.COMBOBOX_BTN_PRESS);
} else if (this.isRollOver(var1)) {
GUIPaintUtils.fillRollOver(var2, 0, 0, var3, var4, var1.isRoundBorder(), var1.getRectDirection(), var1.isDoneAuthorityEdited(var5), var1.isPressedPainted(), UIConstants.COMBOBOX_BTN_ROLLOVER);
} else if (var1.isNormalPainted()) {
GUIPaintUtils.fillNormal(var2, 0, 0, var3, var4, var1.isRoundBorder(), var1.getRectDirection(), var1.isDoneAuthorityEdited(var5), var1.isPressedPainted(), UIConstants.COMBOBOX_BTN_NORMAL);
}
}
};
}
};
this.initPopupButton();
this.btPopup.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent var1) {
BaseAccessibleVueEditor.this.showEditorPane();
}
});
this.add(this.btPopup, "East");
}
}
protected String title4PopupWindow() {
return "Base";
}
protected void showEditorPane() {
}
protected void initPopupButton() {
if (!this.isComboButton()) {
this.btPopup.setIcon(new ImageIcon(UIConstants.ACCESSIBLE_EDITOR_DOT));
this.btPopup.setPreferredSize(new Dimension(20, 20));
} else {
this.btPopup.setRolloverEnabled(true);
this.btPopup.setFocusPainted(false);
this.btPopup.setPreferredSize(new Dimension(15, 19));
this.btPopup.setBorderPainted(false);
this.btPopup.setContentAreaFilled(false);
this.btPopup.setMargin(new Insets(0, 0, 0, 0));
this.btPopup.setIcon(BaseUtils.readIcon("/com/fr/design/images/form/designer/drop_up.png"));
this.btPopup.setPressedIcon(BaseUtils.readIcon("/com/fr/design/images/form/designer/drop_down.png"));
this.btPopup.setRolloverIcon(BaseUtils.readIcon("/com/fr/design/images/form/designer/drop_over.png"));
}
}
protected boolean isComboButton() {
return false;
}
private void txtValueActionPerformed(ActionEvent var1) {
try {
this.validateValue();
this.fireStateChanged();
} catch (ValidationException var3) {
showMessage(var3.getMessage(), this);
this.txtValue.selectAll();
((JComponent) this.txtValue).requestFocus();
}
}
public Component getEditor() {
return this;
}
public Object getValue() {
return this.decoder.decode(this.txtValue.getText());
}
public void setValue(Object var1) {
if (this.encoder != null) {
this.txtValue.setText(this.encoder.encode(var1));
}
this.txtValue.setValue(var1);
}
public void addChangeListener(ChangeListener var1) {
if (!this.listeners.contains(var1)) {
this.listeners.add(var1);
}
}
public void removeChangeListener(ChangeListener var1) {
if (this.listeners.contains(var1)) {
this.listeners.remove(var1);
}
}
protected void fireStateChanged() {
ChangeEvent var1 = new ChangeEvent(this);
Iterator var2 = this.listeners.iterator();
while (var2.hasNext()) {
ChangeListener var3 = (ChangeListener) var2.next();
var3.stateChanged(var1);
}
}
public Encoder getEncoder() {
return this.encoder;
}
public void setEncoder(Encoder var1) {
this.encoder = var1;
}
public void validateValue() throws ValidationException {
if (this.decoder != null) {
this.decoder.validate(this.txtValue.getText());
}
}
}

217
src/main/java/com/eco/plugin/zgtpbxdate/creator/XVueDateEditor.java

@ -0,0 +1,217 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: XVueDateEditor
* Author: Louis
* Date: 2021/11/8 11:46
*/
package com.eco.plugin.zgtpbxdate.creator;
import com.eco.plugin.zgtpbxdate.editors.*;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XDirectWriteEditor;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.concept.data.ValueInitializer;
import com.fr.general.DateUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.awt.*;
import java.beans.IntrospectionException;
import java.util.Date;
/**
* <Function Description><br>
* <XVueDateEditor>
*
* @author wink
* @since 1.0.0
*/
public class XVueDateEditor extends XDirectWriteEditor {
private static final long serialVersionUID = -8713302762570916556L;
public static final String SHOW_DATE = "showDate";
public static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek";
public static final String CONFIGURATION_ITEM = "configurationItem";
public static final String DATE_FORMAT = "dateFormat";
public static final String RETURN_FORMAT = "returnFormat";
public static final String RETURN_TYPE = "returnType";
public static final String DATE_SEPARATOR = "dateSeparator";
private UITextField textField;
private LimpidButton btn;
public XVueDateEditor(VueDateEditor dateEditor, Dimension dimension) {
super(dateEditor, dimension);
}
/**
* 控件的属性列表
*
* @return 此控件所用的属性列表
* @throws IntrospectionException 异常
*/
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
CRPropertyDescriptor widgetValueCRP = new CRPropertyDescriptor("widgetValue", this.data.getClass())
.setI18NName(Toolkit.i18nText("Fine-Design_Form_Widget_Value"))
.setEditorClass(WidgetValueEditor.class)
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
initFieldText();
}
});
// CRPropertyDescriptor formatTextCRP = new CRPropertyDescriptor("formatText", this.data.getClass())
// .setI18NName(Toolkit.i18nText("Fine-Design_Report_Engine_Format"))
// .setEditorClass(formatClass()).setRendererClass(DateCellRenderer.class)
// .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 日期格式
CRPropertyDescriptor dateFormatAttr = new CRPropertyDescriptor(DATE_FORMAT, this.data.getClass())
// .setEditorClass(VueDateFormatEditor.class)
.setEditorClass(DateFormatEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Date_Format"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 显示日期格式
CRPropertyDescriptor showDateCRP = new CRPropertyDescriptor(SHOW_DATE, this.data.getClass())
.setEditorClass(ShowDateEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Design_Form_Show_Date"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 返回格式
CRPropertyDescriptor returnFormatCRP = new CRPropertyDescriptor(RETURN_FORMAT, this.data.getClass())
.setEditorClass(ShowDateEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Format"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 周起始日
CRPropertyDescriptor firstDayOfWeekAttr = new CRPropertyDescriptor(FIRST_DAY_OF_WEEK, this.data.getClass())
.setEditorClass(FirstDayOfWeekEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Design_Form_Week_Start_Date"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 返回类型
CRPropertyDescriptor returnTypeAttr = new CRPropertyDescriptor(RETURN_TYPE, this.data.getClass())
.setEditorClass(ReturnTypeEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Type"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
// 数组拼接符
CRPropertyDescriptor dateSeparatorCRP = new CRPropertyDescriptor(DATE_SEPARATOR, this.data.getClass()).setI18NName(
Toolkit.i18nText("Plugin-abege-Design_Form_Date_Separator")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY,
"Fine-Design_Basic_Advanced");
// 配置项
CRPropertyDescriptor configurationItemCRP = new CRPropertyDescriptor(CONFIGURATION_ITEM, this.data.getClass())
.setEditorClass(ConfigurationItemEditor.class)
.setI18NName(Toolkit.i18nText("Plugin-abege-Design_Form_Configuration_Item"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced");
CRPropertyDescriptor[] crp = new CRPropertyDescriptor[]{widgetValueCRP, dateFormatAttr, showDateCRP, returnFormatCRP,
firstDayOfWeekAttr, returnTypeAttr, dateSeparatorCRP, configurationItemCRP};
return ArrayUtils.addAll(super.supportedDescriptor(), crp);
}
// protected Class formatClass() {
// return DateFormatEditor.class;
// }
private void initFieldText() {
VueDateEditor dateEditor = (VueDateEditor) data;
if (dateEditor.getWidgetValue() != null) {
ValueInitializer widgetValue = dateEditor.getWidgetValue();
//控件值.toString
String valueStr = widgetValue.toString();
//控件值
Object value = widgetValue.getValue();
//格式
String format = dateEditor.getFormatText();
if (value instanceof Date) {
valueStr = DateUtils.getDate2Str(format, (Date) value);
}
//日期控件默认值
if (StringUtils.isEmpty(valueStr)) {
// valueStr = DateUtils.getDate2Str(format, new Date());
// valueStr =
// DateUtilSelf.getNow();
valueStr = "";
dateEditor.setWidgetValue(new WidgetValue(new Date()));
}
textField.setText(valueStr);
}
}
@Override
protected void initXCreatorProperties() {
super.initXCreatorProperties();
initFieldText();
}
@Override
protected JComponent initEditor() {
if (editor == null) {
editor = FRGUIPaneFactory.createBorderLayout_S_Pane();
editor.add(textField = new UITextField(5), BorderLayout.CENTER);
btn = new LimpidButton(StringUtils.EMPTY, this.getIconPath(), toData().isVisible() ? FULL_OPACITY : HALF_OPACITY);
btn.setPreferredSize(new Dimension(21, 21));
editor.add(btn, BorderLayout.EAST);
textField.setOpaque(false);
editor.setBackground(Color.WHITE);
}
return editor;
}
@Override
protected String getIconName() {
return "date_16.png";
}
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;
}
/**
* data属性改变触发其他操作
*/
public void firePropertyChange() {
initFieldText();
}
}

66
src/main/java/com/eco/plugin/zgtpbxdate/editors/ConfigurationItemEditor.java

@ -0,0 +1,66 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ConfigurationItemEditor
* Author: Louis
* Date: 2021/11/18 16:38
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.fr.design.Exception.ValidationException;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
/**
* <Function Description><br>
* <ConfigurationItemEditor>
*
* @author wink
* @since 1.0.0
*/
public class ConfigurationItemEditor extends AbstractPropertyEditor {
private static final int CONTENT_PANE_COLUMNS = 25;
private JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
private UITextArea textField = new UITextArea(5, CONTENT_PANE_COLUMNS);
public ConfigurationItemEditor() {
this.panel.add(this.textField, "Center");
this.textField.setBorder((Border) null);
this.textField.getDocument().addDocumentListener(new DocumentListener() {
public void removeUpdate(DocumentEvent var1) {
ConfigurationItemEditor.this.firePropertyChanged();
}
public void insertUpdate(DocumentEvent var1) {
ConfigurationItemEditor.this.firePropertyChanged();
}
public void changedUpdate(DocumentEvent var1) {
ConfigurationItemEditor.this.firePropertyChanged();
}
});
}
public Object getValue() {
return this.textField.getText();
}
public void setValue(Object var1) {
this.textField.setText((String) var1);
}
public Component getCustomEditor() {
return this.textField;
}
public void validateValue() throws ValidationException {
}
}

86
src/main/java/com/eco/plugin/zgtpbxdate/editors/DateFormatEditor.java

@ -0,0 +1,86 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateFormatEditor
* Author: Louis
* Date: 2021/11/24 16:44
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.eco.plugin.zgtpbxdate.items.DateFormatItems;
import com.eco.plugin.zgtpbxdate.pane.DateFormatPane;
import com.fr.design.Exception.ValidationException;
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* <Function Description><br>
* <DateFormatEditor>
*
* @author wink
* @since 1.0.0
*/
public class DateFormatEditor extends AbstractPropertyEditor {
private final DateFormatPane dateFormatPane;
public DateFormatEditor() {
this.dateFormatPane = new DateFormatPane();
this.initComponents();
}
private void initComponents() {
this.dateFormatPane.addPropertyChangeListener("value", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
DateFormatEditor.this.firePropertyChanged();
}
});
}
@Override
public void validateValue() throws ValidationException {
}
@Override
public Object getValue() {
String value = this.dateFormatPane.update();
return value;
}
@Override
public void setValue(Object value) {
if (StringUtils.equals(String.valueOf(value), DateFormatItems.YEAR)) {
this.dateFormatPane.populate(0, 0);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.MONTH)) {
this.dateFormatPane.populate(0, 1);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATE)) {
this.dateFormatPane.populate(0, 2);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATES)) {
this.dateFormatPane.populate(0, 3);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.WEEK)) {
this.dateFormatPane.populate(0, 4);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATERANGE)) {
this.dateFormatPane.populate(0, 5);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATERANGEWEEK)) {
this.dateFormatPane.populate(0, 6);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATERANGEMONTH)) {
this.dateFormatPane.populate(0, 7);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATETIME)) {
this.dateFormatPane.populate(1, 0);
} else if (StringUtils.equals(String.valueOf(value), DateFormatItems.DATETIMERANGE)) {
this.dateFormatPane.populate(1, 1);
} else {
this.dateFormatPane.populate(0, 2);
}
}
@Override
public Component getCustomEditor() {
return this.dateFormatPane;
}
}

81
src/main/java/com/eco/plugin/zgtpbxdate/editors/DateTypeEditor.java

@ -0,0 +1,81 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateTypeEditor
* Author: Louis
* Date: 2021/11/15 8:53
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.fr.design.Exception.ValidationException;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* <Function Description><br>
* <DateTypeEditor>
*
* @author wink
* @since 1.0.0
*/
public class DateTypeEditor extends AbstractPropertyEditor {
public static final String DATE = "date";
public static final String DATETIME = "datetime";
private static final Map<String, String> ITEMS = new HashMap<String, String>() {
{
put(Toolkit.i18nText("Plugin-abege-Date_Type_Date"), DATE);
put(Toolkit.i18nText("Plugin-abege-Date_Type_DateTime"), DATETIME);
}
};
protected UIButtonGroup<String> buttonGroup;
public DateTypeEditor() {
this.buttonGroup = new UIButtonGroup<>(ITEMS.keySet().toArray(new String[0]));
this.initButtonGroupLookAndFeel();
}
@Override
public void validateValue() throws ValidationException {
}
@Override
public Object getValue() {
if (ComparatorUtils.equals(this.buttonGroup.getSelectedIndex(), 0)) {
return DATE;
} else if (ComparatorUtils.equals(this.buttonGroup.getSelectedIndex(), 1)) {
return DATETIME;
} else {
return DATE;
}
}
@Override
public void setValue(Object value) {
if (StringUtils.equals(String.valueOf(value), DATE)) {
this.buttonGroup.setSelectedIndex(0);
} else if (StringUtils.equals(String.valueOf(value), DATETIME)) {
this.buttonGroup.setSelectedIndex(1);
} else {
this.buttonGroup.setSelectedIndex(0);
}
}
@Override
public Component getCustomEditor() {
return this.buttonGroup;
}
private void initButtonGroupLookAndFeel() {
this.buttonGroup.addActionListener(e -> DateTypeEditor.this.firePropertyChanged());
}
}

50
src/main/java/com/eco/plugin/zgtpbxdate/editors/FirstDayOfWeekEditor.java

@ -0,0 +1,50 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: FirstDayOfWeekEditor
* Author: Louis
* Date: 2021/11/15 8:41
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.eco.plugin.zgtpbxdate.items.FirstDayOfWeekItems;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.mainframe.widget.editors.ComboEditor;
import java.util.Vector;
/**
* <Function Description><br>
* <FirstDayOfWeekEditor>
*
* @author wink
* @since 1.0.0
*/
public class FirstDayOfWeekEditor extends ComboEditor {
public FirstDayOfWeekEditor() {
this((ItemProvider) (new FirstDayOfWeekItems()));
}
public FirstDayOfWeekEditor(ItemProvider itemProvider) {
this(itemProvider.getItems());
}
public FirstDayOfWeekEditor(Item[] items) {
super(items);
}
public FirstDayOfWeekEditor(Vector<Item> items) {
super(items);
}
public Object getValue() {
Item selectedItem = (Item) this.comboBox.getSelectedItem();
return selectedItem.getValue();
}
public void setValue(Object obj) {
Item var2 = new Item("", obj);
this.comboBox.setSelectedItem(var2);
}
}

79
src/main/java/com/eco/plugin/zgtpbxdate/editors/ReturnTypeEditor.java

@ -0,0 +1,79 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ReturnTypeEditor
* Author: Louis
* Date: 2021/11/12 11:16
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.fr.design.Exception.ValidationException;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* <Function Description><br>
* <ReturnTypeEditor>
*
* @author wink
* @since 1.0.0
*/
public class ReturnTypeEditor extends AbstractPropertyEditor {
public static final String STRING = "string";
public static final String DATE = "date";
private static final Map<String, String> ITEMS = new HashMap<String, String>() {
{
put(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Type_String"), STRING);
put(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Type_Date"), DATE);
}
};
protected UIButtonGroup<String> buttonGroup;
public ReturnTypeEditor() {
this.buttonGroup = new UIButtonGroup<>(ITEMS.keySet().toArray(new String[0]));
this.initButtonGroupLookAndFeel();
}
@Override
public void validateValue() throws ValidationException {
}
@Override
public Object getValue() {
if (ComparatorUtils.equals(this.buttonGroup.getSelectedIndex(), 0)) {
return STRING;
} else if (ComparatorUtils.equals(this.buttonGroup.getSelectedIndex(), 1)) {
return DATE;
} else {
return STRING;
}
}
@Override
public void setValue(Object value) {
if (StringUtils.equals(String.valueOf(value), STRING)) {
this.buttonGroup.setSelectedIndex(0);
} else if (StringUtils.equals(String.valueOf(value), DATE)) {
this.buttonGroup.setSelectedIndex(1);
} else {
this.buttonGroup.setSelectedIndex(0);
}
}
@Override
public Component getCustomEditor() {
return this.buttonGroup;
}
private void initButtonGroupLookAndFeel() {
this.buttonGroup.addActionListener(e -> ReturnTypeEditor.this.firePropertyChanged());
}
}

24
src/main/java/com/eco/plugin/zgtpbxdate/editors/ShowDateEditor.java

@ -0,0 +1,24 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ShowDateEditor
* Author: Louis
* Date: 2021/11/25 16:56
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.eco.plugin.zgtpbxdate.accessibles.AccessibleFormulaVueEditor;
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor;
/**
* <Function Description><br>
* <ShowDateEditor>
*
* @author wink
* @since 1.0.0
*/
public class ShowDateEditor extends AccessiblePropertyEditor {
public ShowDateEditor() {
super(new AccessibleFormulaVueEditor());
}
}

157
src/main/java/com/eco/plugin/zgtpbxdate/editors/ShowDateFormulaEditor.java

@ -0,0 +1,157 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ShowDateFormulaEditor
* Author: Louis
* Date: 2021/11/29 12:01
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.editor.Editor;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import javax.swing.event.DocumentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* <Function Description><br>
* <ShowDateFormulaEditor>
*
* @author wink
* @since 1.0.0
*/
public class ShowDateFormulaEditor extends Editor<BaseFormula> {
private BaseFormula formula;
private UITextField currentTextField;
private ShowPaneListener listener;
public ShowDateFormulaEditor() {
this("");
}
public ShowDateFormulaEditor(String var1) {
this(var1, (BaseFormula) null);
}
public ShowDateFormulaEditor(String var1, BaseFormula var2) {
this.formula = BaseFormula.createFormulaBuilder().build();
this.listener = new ShowPaneListener();
if (var2 != null) {
this.formula = var2;
}
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// JPanel var3 = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.currentTextField = new UITextField();
this.currentTextField.setText(this.formula.getContent());
// var3.add(this.currentTextField, "Center");
this.currentTextField.setEditable(false);
this.currentTextField.addMouseListener(this.listener);
// this.add(var3, "Center");
this.add(this.currentTextField, "Center");
this.setName(var1);
}
public void setColumns(int var1) {
this.currentTextField.setColumns(var1);
}
public void selected() {
this.showFormulaPane();
}
public void setEnabled(boolean var1) {
super.setEnabled(var1);
this.currentTextField.setEnabled(var1);
}
protected void showFormulaPane() {
final UIFormula var1 = FormulaFactory.createFormulaPaneWhenReserveFormula();
var1.populate(this.formula);
var1.showLargeWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() {
public void doOk() {
ShowDateFormulaEditor.this.formula = var1.update();
ShowDateFormulaEditor.this.setValue(ShowDateFormulaEditor.this.formula);
ShowDateFormulaEditor.this.fireStateChanged();
}
}).setVisible(true);
}
public BaseFormula getFormula() {
return this.formula;
}
public UITextField getUITextField() {
return this.currentTextField;
}
public BaseFormula getValue() {
return this.formula != null && "=".equals(this.formula.getContent()) ? null : this.formula;
}
public void setValue(BaseFormula var1) {
if (var1 == null) {
var1 = BaseFormula.createFormulaBuilder().build();
}
this.formula = var1;
this.currentTextField.setText(var1.toString());
}
public void addDocumentListener(DocumentListener var1) {
this.currentTextField.getDocument().addDocumentListener(var1);
}
public String getIconName() {
return "type_formula";
}
public boolean accept(Object var1) {
return var1 instanceof BaseFormula;
}
public void reset() {
this.currentTextField.setText("=");
this.formula = BaseFormula.createFormulaBuilder().build();
}
public void clearData() {
this.reset();
}
public void enableEditor(boolean var1) {
this.setEnabled(var1);
this.currentTextField.setEnabled(var1);
if (!var1) {
this.currentTextField.removeMouseListener(this.listener);
} else {
int var2 = this.currentTextField.getMouseListeners().length;
for (int var3 = 0; var3 < var2; ++var3) {
this.currentTextField.removeMouseListener(this.listener);
}
this.currentTextField.addMouseListener(this.listener);
}
}
private class ShowPaneListener extends MouseAdapter {
private ShowPaneListener() {
}
public void mousePressed(MouseEvent var1) {
if (ShowDateFormulaEditor.this.currentTextField.isEnabled()) {
ShowDateFormulaEditor.this.showFormulaPane();
}
}
}
}

50
src/main/java/com/eco/plugin/zgtpbxdate/editors/VueDateFormatEditor.java

@ -0,0 +1,50 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateFormatEditor
* Author: Louis
* Date: 2021/11/15 10:10
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.eco.plugin.zgtpbxdate.items.DateFormatItems;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.mainframe.widget.editors.ComboEditor;
import java.util.Vector;
/**
* <Function Description><br>
* <DateFormatEditor>
*
* @author wink
* @since 1.0.0
*/
public class VueDateFormatEditor extends ComboEditor {
public VueDateFormatEditor() {
this((ItemProvider) (new DateFormatItems()));
}
public VueDateFormatEditor(ItemProvider itemProvider) {
this(itemProvider.getItems());
}
public VueDateFormatEditor(Item[] items) {
super(items);
}
public VueDateFormatEditor(Vector<Item> items) {
super(items);
}
public Object getValue() {
Item selectedItem = (Item) this.comboBox.getSelectedItem();
return selectedItem.getValue();
}
public void setValue(Object obj) {
Item var2 = new Item("", obj);
this.comboBox.setSelectedItem(var2);
}
}

50
src/main/java/com/eco/plugin/zgtpbxdate/editors/VueDateTimeFormatEditor.java

@ -0,0 +1,50 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateTimeFormatEditor
* Author: Louis
* Date: 2021/11/15 10:54
*/
package com.eco.plugin.zgtpbxdate.editors;
import com.eco.plugin.zgtpbxdate.items.DateTimeFormatItems;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.mainframe.widget.editors.ComboEditor;
import java.util.Vector;
/**
* <Function Description><br>
* <DateTimeFormatEditor>
*
* @author wink
* @since 1.0.0
*/
public class VueDateTimeFormatEditor extends ComboEditor {
public VueDateTimeFormatEditor() {
this((ItemProvider) (new DateTimeFormatItems()));
}
public VueDateTimeFormatEditor(ItemProvider itemProvider) {
this(itemProvider.getItems());
}
public VueDateTimeFormatEditor(Item[] items) {
super(items);
}
public VueDateTimeFormatEditor(Vector<Item> items) {
super(items);
}
public Object getValue() {
Item selectedItem = (Item) this.comboBox.getSelectedItem();
return selectedItem.getValue();
}
public void setValue(Object obj) {
Item var2 = new Item("", obj);
this.comboBox.setSelectedItem(var2);
}
}

58
src/main/java/com/eco/plugin/zgtpbxdate/items/DateFormatItems.java

@ -0,0 +1,58 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateFormatItems
* Author: Louis
* Date: 2021/11/15 10:11
*/
package com.eco.plugin.zgtpbxdate.items;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.i18n.Toolkit;
/**
* <Function Description><br>
* <DateFormatItems>
*
* @author wink
* @since 1.0.0
*/
public class DateFormatItems implements ItemProvider {
public static final String DATE = "date";
public static final String YEAR = "year";
public static final String MONTH = "month";
public static final String DATES = "dates";
public static final String WEEK = "week";
public static final String DATERANGE = "daterange";
public static final String DATERANGEWEEK = "daterangeweek";
public static final String DATERANGEMONTH = "daterangemonth";
public static final String DATETIME = "datetime";
public static final String DATETIMERANGE = "datetimerange";
public static Item[] DATE_ITEMS = new Item[]{
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_Year"), YEAR),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_Month"), MONTH),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_Date"), DATE),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_Dates"), DATES),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_Week"), WEEK),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRange"), DATERANGE),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRangeWeek"), DATERANGEWEEK),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRangeMonth"), DATERANGEMONTH),
// new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTime"), "datetime"),
// new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTimeRange"), "datetimerange"),
// new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRange"), "daterange"),
};
public static Item[] TIME_ITEMS = new Item[]{
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTime"), DATETIME),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTimeRange"), DATETIMERANGE),
// new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRange"), "daterange"),
};
public DateFormatItems() {
}
@Override
public Item[] getItems() {
return DATE_ITEMS;
}
}

35
src/main/java/com/eco/plugin/zgtpbxdate/items/DateTimeFormatItems.java

@ -0,0 +1,35 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: DateTimeFormatItems
* Author: Louis
* Date: 2021/11/15 10:55
*/
package com.eco.plugin.zgtpbxdate.items;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.i18n.Toolkit;
/**
* <Function Description><br>
* <DateTimeFormatItems>
*
* @author wink
* @since 1.0.0
*/
public class DateTimeFormatItems implements ItemProvider {
public static Item[] DATETIME_ITEMS = new Item[]{
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTime"), "datetime"),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateTimeRange"), "datetimerange"),
new Item(Toolkit.i18nText("Plugin-abege-Date_Format_DateRange"), "daterange"),
};
public DateTimeFormatItems() {
}
@Override
public Item[] getItems() {
return DATETIME_ITEMS;
}
}

55
src/main/java/com/eco/plugin/zgtpbxdate/items/FirstDayOfWeekItems.java

@ -0,0 +1,55 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: FirstDayOfWeekItems
* Author: Louis
* Date: 2021/11/15 8:42
*/
package com.eco.plugin.zgtpbxdate.items;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.designer.properties.items.ItemProvider;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import javax.swing.*;
/**
* <Function Description><br>
* <FirstDayOfWeekItems>
*
* @author wink
* @since 1.0.0
*/
public class FirstDayOfWeekItems implements ItemProvider {
public static final int SUNDAY = 7;
public static Item[] VALUE_ITEMS = new Item[]{
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Monday"), 1),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Tuesday"), 2),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Wednesday"), 3),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Thursday"), 4),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Friday"), 5),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Saturday"), 6),
new Item(Toolkit.i18nText("Plugin-abege-Week_Start_Date_Sunday"), SUNDAY),
};
public FirstDayOfWeekItems() {
}
@Override
public Item[] getItems() {
return VALUE_ITEMS;
}
public static UIComboBox getUIComboBox() {
return initUIComboBox(VALUE_ITEMS);
}
private static UIComboBox initUIComboBox(Item[] items) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
return new UIComboBox(model);
}
}

186
src/main/java/com/eco/plugin/zgtpbxdate/pane/DateFormatPane.java

@ -0,0 +1,186 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ReturnFormatPane
* Author: Louis
* Date: 2021/11/24 16:47
*/
package com.eco.plugin.zgtpbxdate.pane;
import com.eco.plugin.zgtpbxdate.items.DateFormatItems;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import static com.fr.design.layout.FRGUIPaneFactory.createBorderLayout;
/**
* <Function Description><br>
* <ReturnFormatPane>
*
* @author wink
* @since 1.0.0
*/
public class DateFormatPane extends JPanel {
private CardLayout cardLayout;
private JPanel customPane;
private String[] tabTitles;
private UIComboBox currentFormatComboBox;
private UIComboBox dateFormatComboBox;
private UIComboBox timeFormatComboBox;
private UIButtonGroup<String> formatHeadGroup;
public DateFormatPane() {
this.initComponents();
}
private void initComponents() {
this.setLayout(createBorderLayout());
this.dateFormatComboBox = initUIComboBox(DateFormatItems.DATE_ITEMS);
this.dateFormatComboBox.setSelectedIndex(2);
this.dateFormatComboBox.addActionListener(e -> this.firePropertyChange("dateFormatValue", null, this.update()));
this.timeFormatComboBox = initUIComboBox(DateFormatItems.TIME_ITEMS);
this.timeFormatComboBox.setSelectedIndex(0);
this.timeFormatComboBox.addActionListener(e -> this.firePropertyChange("dateFormatValue", null, this.update()));
this.cardLayout = new CardLayout();
this.customPane = new JPanel(cardLayout);
JPanel dateFormatPane = createFormatPane(dateFormatComboBox);
JPanel timeFormatPane = createFormatPane(timeFormatComboBox);
customPane.add(dateFormatPane, Toolkit.i18nText("Plugin-abege-Date_Type_Date"));
customPane.add(timeFormatPane, Toolkit.i18nText("Plugin-abege-Date_Type_DateTime"));
this.tabTitles = new String[]{Toolkit.i18nText("Plugin-abege-Date_Type_Date"), Toolkit.i18nText("Plugin-abege-Date_Type_DateTime")};
this.formatHeadGroup = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Plugin-abege-Date_Type_Date"), Toolkit.i18nText("Plugin-abege-Date_Type_DateTime")});
this.formatHeadGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int newSelectedIndex = formatHeadGroup.getSelectedIndex();
cardLayout.show(customPane, tabTitles[newSelectedIndex]);
if (newSelectedIndex == 0) {
currentFormatComboBox = dateFormatComboBox;
} else {
currentFormatComboBox = timeFormatComboBox;
}
}
});
this.add(formatHeadGroup, BorderLayout.NORTH);
this.add(customPane, BorderLayout.CENTER);
}
private JPanel createFormatPane(UIComboBox formatComboBox) {
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
jPanel.add(formatComboBox, BorderLayout.CENTER);
return jPanel;
}
private UIComboBox initUIComboBox(Item[] items) {
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (Item item : items) {
model.addElement(item);
}
return new UIComboBox(model);
}
public void populate(String dateFormat) {
if (StringUtils.equals(dateFormat, DateFormatItems.YEAR)) {
this.populate(0, 0);
} else if (StringUtils.equals(dateFormat, DateFormatItems.MONTH)) {
this.populate(0, 1);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATE)) {
this.populate(0, 2);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATES)) {
this.populate(0, 3);
} else if (StringUtils.equals(dateFormat, DateFormatItems.WEEK)) {
this.populate(0, 4);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATERANGE)) {
this.populate(0, 5);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATERANGEWEEK)) {
this.populate(0, 6);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATERANGEMONTH)) {
this.populate(0, 7);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATETIME)) {
this.populate(1, 0);
} else if (StringUtils.equals(dateFormat, DateFormatItems.DATETIMERANGE)) {
this.populate(1, 1);
} else {
this.populate(0, 2);
}
}
public void populate(int formatHead, int formatIndex) {
this.formatHeadGroup.setSelectedIndex(formatHead);
if (ComparatorUtils.equals(formatHead, 0)) {
this.cardLayout.show(this.customPane, this.tabTitles[formatHead]);
this.currentFormatComboBox = this.dateFormatComboBox;
this.dateFormatComboBox.setSelectedIndex(formatIndex);
this.timeFormatComboBox.setSelectedIndex(0);
} else if (ComparatorUtils.equals(formatHead, 1)) {
this.cardLayout.show(this.customPane, this.tabTitles[formatHead]);
this.currentFormatComboBox = this.timeFormatComboBox;
this.dateFormatComboBox.setSelectedIndex(0);
this.timeFormatComboBox.setSelectedIndex(formatIndex);
}
}
public String update() {
if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 0)) {
return DateFormatItems.YEAR;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 1)) {
return DateFormatItems.MONTH;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 2)) {
return DateFormatItems.DATE;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 3)) {
return DateFormatItems.DATES;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 4)) {
return DateFormatItems.WEEK;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 5)) {
return DateFormatItems.DATERANGE;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 6)) {
return DateFormatItems.DATERANGEWEEK;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 7)) {
return DateFormatItems.DATERANGEMONTH;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 1) && ComparatorUtils.equals(this.timeFormatComboBox.getSelectedIndex(), 0)) {
return DateFormatItems.DATETIME;
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 1) && ComparatorUtils.equals(this.timeFormatComboBox.getSelectedIndex(), 1)) {
return DateFormatItems.DATETIMERANGE;
} else {
return DateFormatItems.DATE;
}
}
public void update(VueDateEditor dateEditor) {
if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 0)) {
dateEditor.setDateFormat(DateFormatItems.YEAR);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 1)) {
dateEditor.setDateFormat(DateFormatItems.MONTH);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 2)) {
dateEditor.setDateFormat(DateFormatItems.DATE);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 3)) {
dateEditor.setDateFormat(DateFormatItems.DATES);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 4)) {
dateEditor.setDateFormat(DateFormatItems.WEEK);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 5)) {
dateEditor.setDateFormat(DateFormatItems.DATERANGE);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 6)) {
dateEditor.setDateFormat(DateFormatItems.DATERANGEWEEK);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 0) && ComparatorUtils.equals(this.dateFormatComboBox.getSelectedIndex(), 7)) {
dateEditor.setDateFormat(DateFormatItems.DATERANGEMONTH);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 1) && ComparatorUtils.equals(this.timeFormatComboBox.getSelectedIndex(), 0)) {
dateEditor.setDateFormat(DateFormatItems.DATETIME);
} else if (ComparatorUtils.equals(this.formatHeadGroup.getSelectedIndex(), 1) && ComparatorUtils.equals(this.timeFormatComboBox.getSelectedIndex(), 1)) {
dateEditor.setDateFormat(DateFormatItems.DATETIMERANGE);
} else {
dateEditor.setDateFormat(DateFormatItems.DATE);
}
}
}

220
src/main/java/com/eco/plugin/zgtpbxdate/pane/ReturnFormatPane.java

@ -0,0 +1,220 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ReturnFormatPane
* Author: Louis
* Date: 2021/11/29 15:01
*/
package com.eco.plugin.zgtpbxdate.pane;
import com.eco.plugin.zgtpbxdate.items.DateFormatItems;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.base.BaseFormula;
import com.fr.design.editor.editor.*;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.widget.editors.DataBindingEditor;
import com.fr.design.mainframe.widget.editors.DataTableEditor;
import com.fr.design.mainframe.widget.editors.ServerDataBindingEditor;
import com.fr.design.mainframe.widget.editors.ServerDataTableEditor;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
/**
* <Function Description><br>
* <ReturnFormatPane>
*
* @author wink
* @since 1.0.0
*/
public class ReturnFormatPane extends JPanel {
private UIButtonGroup widgetValueHead;
private Editor[] editor;
private JPanel customPane;
private CardLayout cardLayout;
public ReturnFormatPane() {
this.editor = createWidgetValueEditor(new int[]{1, 3}, true);
this.setLayout(new BorderLayout(0, 4));
this.cardLayout = new CardLayout();
this.customPane = new JPanel(this.cardLayout);
String[] editorNames = new String[this.editor.length];
for (int i = 0; i < this.editor.length; ++i) {
this.customPane.add(this.editor[i], this.editor[i].getName());
editorNames[i] = this.editor[i].getName();
}
this.widgetValueHead = new UIButtonGroup(editorNames);
this.add(this.widgetValueHead, BorderLayout.NORTH);
this.add(this.customPane, BorderLayout.CENTER);
}
public static Editor createWidgetValueEditorByType(int editorType, boolean var1) {
switch (editorType) {
case 0:
return new DoubleEditor();
case 1:
return new TextEditor();
case 2:
return (Editor) (var1 ? new ServerDataBindingEditor() : new DataBindingEditor());
case 3:
return new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
case 4:
return new DateEditor(true, Toolkit.i18nText("Fine-Design_Basic_Date"));
case 5:
return new BooleanEditor(false);
case 6:
return (Editor) (var1 ? new ServerDataTableEditor() : new DataTableEditor());
default:
return null;
}
}
public static Editor[] createWidgetValueEditor(int[] editorTypes, boolean var1) {
Editor[] editors = new Editor[editorTypes.length];
for (int var4 = 0; var4 < editorTypes.length; ++var4) {
editors[var4] = createWidgetValueEditorByType(editorTypes[var4], var1);
}
return editors;
}
public void attributeChange() {
int var1 = this.widgetValueHead.getSelectedIndex();
if (var1 == -1) {
var1 = 0;
this.widgetValueHead.setSelectedIndex(var1);
}
if (ComparatorUtils.equals(this.editor[var1].getName(), Toolkit.i18nText("Fine-Design_Basic_Widget_Field"))) {
this.customPane.setPreferredSize(new Dimension(100, 47));
} else {
this.customPane.setPreferredSize(new Dimension(100, 20));
}
this.cardLayout.show(this.customPane, this.editor[var1].getName());
}
public void update(VueDateEditor dateEditor, boolean isShowDate) {
this.attributeChange();
int selectedIndex = this.widgetValueHead.getSelectedIndex();
Editor editor = this.editor[selectedIndex];
Object value = editor.getValue();
if (isShowDate) {
updateShowDate(dateEditor, value);
} else {
updateReturnFormat(dateEditor, value);
}
}
private void updateShowDate(VueDateEditor dateEditor, Object value) {
if (value == null) {
return;
}
if (value instanceof BaseFormula) {
dateEditor.setShowDate("");
dateEditor.setShowDateFM((BaseFormula) value);
} else if (value instanceof String) {
dateEditor.setShowDate(String.valueOf(value));
dateEditor.setShowDateFM(null);
} else {
dateEditor.setShowDate(String.valueOf(value));
dateEditor.setShowDateFM(null);
}
}
private void updateReturnFormat(VueDateEditor dateEditor, Object value) {
if (value == null) {
return;
}
if (value instanceof BaseFormula) {
dateEditor.setReturnFormat("");
dateEditor.setReturnFormatFM((BaseFormula) value);
} else if (value instanceof String) {
dateEditor.setReturnFormat(String.valueOf(value));
dateEditor.setReturnFormatFM(null);
} else {
dateEditor.setReturnFormat(String.valueOf(value));
dateEditor.setReturnFormatFM(null);
}
}
public void populateShowDate(VueDateEditor dateEditor) {
if (StringUtils.isNotBlank(dateEditor.getShowDate())) {
this.populate(dateEditor.getShowDate());
} else if (dateEditor.getShowDateFM() != null) {
this.populate(dateEditor.getShowDateFM());
}
}
public void populateShowDate(Object dateFormat) {
if (dateFormat == null) {
return;
}
String str;
switch (String.valueOf(dateFormat)) {
case DateFormatItems.YEAR:
str = "yyyy";
break;
case DateFormatItems.MONTH:
str = "yyyy-MM";
break;
case DateFormatItems.DATE:
str = "yyyy-MM-dd";
break;
case DateFormatItems.WEEK:
str = "yyyy-WW";
break;
case DateFormatItems.DATERANGE:
str = "yyyy-MM-dd";
break;
case DateFormatItems.DATERANGEWEEK:
str = "yyyy-WW";
break;
case DateFormatItems.DATERANGEMONTH:
str = "yyyy-MM";
break;
case DateFormatItems.DATES:
str = "yyyy-MM-dd";
break;
case DateFormatItems.DATETIME:
str = "yyyy-MM-dd hh:mm:ss";
break;
case DateFormatItems.DATETIMERANGE:
str = "yyyy-MM-dd hh:mm:ss";
break;
default:
str = "yyyy-MM-dd";
}
this.populate(str);
}
public void populateReturnFormat(VueDateEditor dateEditor) {
if (StringUtils.isNotBlank(dateEditor.getReturnFormat())) {
this.populate(dateEditor.getReturnFormat());
} else if (dateEditor.getReturnFormatFM() != null) {
this.populate(dateEditor.getReturnFormatFM());
}
}
public void populate(Object value) {
for (int i = 0; i < this.editor.length; ++i) {
if (this.editor[i].accept(value)) {
this.setCardValue(i, value);
break;
}
}
this.attributeChange();
}
private void setCardValue(int var1, Object var2) {
this.widgetValueHead.setSelectedIndex(var1);
this.editor[var1].setValue(var2);
for (int i = 0; i < this.editor.length; ++i) {
if (var1 != i) {
this.editor[i].setValue((Object) null);
}
}
}
}

92
src/main/java/com/eco/plugin/zgtpbxdate/pane/ShowDatePane.java

@ -0,0 +1,92 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: ShowDatePane
* Author: Louis
* Date: 2021/11/28 23:22
*/
package com.eco.plugin.zgtpbxdate.pane;
import com.fr.base.BaseFormula;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.*;
import javax.swing.event.DocumentListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* <Function Description><br>
* <ShowDatePane>
*
* @author wink
* @since 1.0.0
*/
public class ShowDatePane extends JPanel {
private final UITextField currentTextField;
private BaseFormula formula;
private ShowPaneListener listener;
public ShowDatePane() {
this.formula = BaseFormula.createFormulaBuilder().build();
this.listener = new ShowPaneListener();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.currentTextField = new UITextField();
this.currentTextField.setText(this.formula.getContent());
this.currentTextField.setEditable(false);
this.currentTextField.addMouseListener(this.listener);
this.add(this.currentTextField, "Center");
this.setName(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
}
protected void showFormulaPane() {
final UIFormula reserveFormula = FormulaFactory.createFormulaPaneWhenReserveFormula();
reserveFormula.populate(this.formula);
reserveFormula.showLargeWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() {
public void doOk() {
ShowDatePane.this.formula = reserveFormula.update();
}
}).setVisible(true);
}
public BaseFormula update() {
return this.formula != null && "=".equals(this.formula.getContent()) ? null : this.formula;
}
public void populate(BaseFormula value) {
if (value == null) {
value = BaseFormula.createFormulaBuilder().build();
}
this.formula = value;
this.currentTextField.setText(value.toString());
}
public BaseFormula getFormula() {
return this.formula;
}
public UITextField getUITextField() {
return this.currentTextField;
}
public void addDocumentListener(DocumentListener var1) {
this.currentTextField.getDocument().addDocumentListener(var1);
}
private class ShowPaneListener extends MouseAdapter {
private ShowPaneListener() {
}
public void mousePressed(MouseEvent var1) {
if (ShowDatePane.this.currentTextField.isEnabled()) {
ShowDatePane.this.showFormulaPane();
}
}
}
}

160
src/main/java/com/eco/plugin/zgtpbxdate/pane/VueDateEditorFormDefinePane.java

@ -0,0 +1,160 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueDateEditorDefinePane
* Author: Louis
* Date: 2021/11/28 12:52
*/
package com.eco.plugin.zgtpbxdate.pane;
import com.eco.plugin.zgtpbxdate.items.FirstDayOfWeekItems;
import com.eco.plugin.zgtpbxdate.pane.self.DirectWriteEditorDefinePane;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.WaterMarkDictPane;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import javax.swing.*;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* <Function Description><br>
* <表单和参数控件设置界面类VueDateEditorDefinePane>
* 在PluginMonitor中通过FormWidgetDefinePaneFactoryBase注册
*
* @author wink
* @since 1.0.0
*/
public class VueDateEditorFormDefinePane extends DirectWriteEditorDefinePane<VueDateEditor> {
private static final int CONTENT_PANE_COLUMNS = 25;
private WaterMarkDictPane waterMarkDictPane;
private FormWidgetValuePane formWidgetValuePane;
private DateFormatPane dateFormatPane;
private ReturnFormatPane showDatePane;
private ReturnFormatPane returnFormatPane;
private UIComboBox firstDayOfWeekComboBox;
private UIButtonGroup<String> returnTypeComboBox;
private UITextField dateSeparatorTextField;
private UITextArea configurationItemTextArea;
public VueDateEditorFormDefinePane(XCreator xCreator) {
super(xCreator);
}
@Override
public String title4PopupWindow() {
return "VueDate";
}
@Override
protected JPanel setFirstContentPane() {
// 水印
this.waterMarkDictPane = new WaterMarkDictPane();
// 控件值
UILabel widgetValueLabel = new UILabel(Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"));
widgetValueLabel.setVerticalAlignment(SwingConstants.TOP);
this.formWidgetValuePane = new FormWidgetValuePane(this.creator.toData(), false);
// 类型/格式
UILabel formatLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Date_Format"));
formatLabel.setVerticalAlignment(SwingConstants.TOP);
this.dateFormatPane = new DateFormatPane();
this.dateFormatPane.addPropertyChangeListener("dateFormatValue", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
VueDateEditorFormDefinePane.this.showDatePane.populateShowDate(evt.getNewValue());
}
});
// 显示日期格式
UILabel showDateLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Show_Date"));
showDateLabel.setVerticalAlignment(SwingConstants.TOP);
this.showDatePane = new ReturnFormatPane();
// 返回格式
UILabel returnFormatLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Format"));
returnFormatLabel.setVerticalAlignment(SwingConstants.TOP);
this.returnFormatPane = new ReturnFormatPane();
// 周起始日
UILabel firstDayOfWeekLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Week_Start_Date"));
firstDayOfWeekLabel.setVerticalAlignment(SwingConstants.TOP);
this.firstDayOfWeekComboBox = FirstDayOfWeekItems.getUIComboBox();
// 返回类型
UILabel returnTypeLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Type"));
returnTypeLabel.setVerticalAlignment(SwingConstants.TOP);
this.returnTypeComboBox = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Basic_Date"), Toolkit.i18nText("Fine-Design_Basic_String")});
// 数组拼接符
UILabel dateSeparatorLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Date_Separator"));
dateSeparatorLabel.setVerticalAlignment(SwingConstants.TOP);
this.dateSeparatorTextField = new UITextField();
// 配置项
UILabel configurationItemLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Configuration_Item"));
configurationItemLabel.setVerticalAlignment(SwingConstants.TOP);
this.configurationItemTextArea = new UITextArea(5, CONTENT_PANE_COLUMNS);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
/*
{new UILabel(Toolkit.i18nText("Fine-Design_Form_Label_Name")), this.labelNameTextField},
{widgetValueLabel, this.formWidgetValuePane},
{formatLabel, this.dateFormatPane},
{showDateLabel, this.showDatePane},
{returnFormatLabel, this.returnFormatPane},
{firstDayOfWeekLabel, this.firstDayOfWeekComboBox},
{returnTypeLabel, this.returnTypeComboBox},
{dateSeparatorLabel, this.dateSeparatorTextField},
{configurationItemLabel, this.configurationItemTextArea},
{new UILabel(Toolkit.i18nText("Fine-Design_Form_WaterMark")), this.waterMarkDictPane},
{new UILabel(Toolkit.i18nText("Fine-Design_Form_Font_Size")), this.fontSizePane} // 字体大小
*/
};
double[] rowSize = new double[]{p, p, p, p, p, p, p, p, p, p, p, p, p};
double[] columnSize = new double[]{p, f};
int[][] rowCount = new int[][]{{1, 1}, {1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel componentsPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1);
JPanel firstContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
firstContentPane.add(componentsPane);
return null;
}
@Override
protected void populateSubDirectWriteEditorBean(VueDateEditor dateEditor) {
this.waterMarkDictPane.populate(dateEditor);
this.formWidgetValuePane.populate(dateEditor);
this.dateFormatPane.populate(dateEditor.getDateFormat());
this.showDatePane.populateShowDate(dateEditor);
this.returnFormatPane.populateReturnFormat(dateEditor);
this.firstDayOfWeekComboBox.setSelectedItem(new Item("", dateEditor.getFirstDayOfWeek()));
this.returnTypeComboBox.setSelectedIndex(dateEditor.getReturnTypeInt());
this.dateSeparatorTextField.setText(dateEditor.getDateSeparator());
this.configurationItemTextArea.setText(dateEditor.getConfigurationItem());
}
@Override
protected VueDateEditor updateSubDirectWriteEditorBean() {
VueDateEditor dateEditor = (VueDateEditor) this.creator.toData();
this.waterMarkDictPane.update(dateEditor);
this.formWidgetValuePane.update(dateEditor);
this.dateFormatPane.update(dateEditor);
this.showDatePane.update(dateEditor, true);
this.returnFormatPane.update(dateEditor, false);
dateEditor.setFirstDayOfWeek(this.firstDayOfWeekComboBox.getSelectedItem());
dateEditor.setReturnType(this.returnTypeComboBox.getSelectedIndex());
dateEditor.setDateSeparator(this.dateSeparatorTextField.getText());
dateEditor.setConfigurationItem(this.configurationItemTextArea.getText());
return dateEditor;
}
}

135
src/main/java/com/eco/plugin/zgtpbxdate/pane/VueDateEditorPane.java

@ -0,0 +1,135 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueDateEditorPane
* Author: Louis
* Date: 2021/11/8 16:38
*/
package com.eco.plugin.zgtpbxdate.pane;
import com.eco.plugin.zgtpbxdate.items.FirstDayOfWeekItems;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.properties.items.Item;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.DirectWriteEditorDefinePane;
import javax.swing.*;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
/**
* <Function Description><br>
* <单元格日期控件设置界面类VueDateEditorPane>
*
* @author wink
* @since 1.0.0
*/
public class VueDateEditorPane extends DirectWriteEditorDefinePane<VueDateEditor> {
private static final int CONTENT_PANE_COLUMNS = 25;
private DateFormatPane dateFormatPane;
private ReturnFormatPane showDatePane;
private ReturnFormatPane returnFormatPane;
private UIComboBox firstDayOfWeekComboBox;
private UIButtonGroup<String> returnTypeComboBox;
private UITextField dateSeparatorTextField;
private UITextArea configurationItemTextArea;
public VueDateEditorPane() {
}
@Override
protected String title4PopupWindow() {
return "VueDate";
}
@Override
protected JPanel setSecondContentPane() {
// 类型/格式
UILabel formatLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Date_Format"));
formatLabel.setVerticalAlignment(SwingConstants.TOP);
this.dateFormatPane = new DateFormatPane();
this.dateFormatPane.addPropertyChangeListener("dateFormatValue", new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
VueDateEditorPane.this.showDatePane.populateShowDate(evt.getNewValue());
}
});
// 显示日期格式
UILabel showDateLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Show_Date"));
showDateLabel.setVerticalAlignment(SwingConstants.TOP);
this.showDatePane = new ReturnFormatPane();
// 返回格式
UILabel returnFormatLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Format"));
returnFormatLabel.setVerticalAlignment(SwingConstants.TOP);
this.returnFormatPane = new ReturnFormatPane();
// 周起始日
UILabel firstDayOfWeekLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Week_Start_Date"));
firstDayOfWeekLabel.setVerticalAlignment(SwingConstants.TOP);
this.firstDayOfWeekComboBox = FirstDayOfWeekItems.getUIComboBox();
// 返回类型
UILabel returnTypeLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Return_Type"));
returnTypeLabel.setVerticalAlignment(SwingConstants.TOP);
this.returnTypeComboBox = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Basic_Date"), Toolkit.i18nText("Fine-Design_Basic_String")});
// 数组拼接符
UILabel dateSeparatorLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Date_Separator"));
dateSeparatorLabel.setVerticalAlignment(SwingConstants.TOP);
this.dateSeparatorTextField = new UITextField();
// 配置项
UILabel configurationItemLabel = new UILabel(Toolkit.i18nText("Plugin-abege-Design_Form_Configuration_Item"));
configurationItemLabel.setVerticalAlignment(SwingConstants.TOP);
this.configurationItemTextArea = new UITextArea(5, CONTENT_PANE_COLUMNS);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{
new Component[]{formatLabel, this.dateFormatPane},
new Component[]{showDateLabel, this.showDatePane},
new Component[]{returnFormatLabel, this.returnFormatPane},
new Component[]{firstDayOfWeekLabel, this.firstDayOfWeekComboBox},
new Component[]{returnTypeLabel, this.returnTypeComboBox},
new Component[]{dateSeparatorLabel, this.dateSeparatorTextField},
new Component[]{dateSeparatorLabel, this.dateSeparatorTextField},
new Component[]{configurationItemLabel, this.configurationItemTextArea},
new Component[]{this.waterMarkDictPane, null}
};
double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1);
return panel;
}
@Override
protected void populateSubDirectWriteEditorBean(VueDateEditor dateEditor) {
this.dateFormatPane.populate(dateEditor.getDateFormat());
this.showDatePane.populateShowDate(dateEditor);
this.returnFormatPane.populateReturnFormat(dateEditor);
this.firstDayOfWeekComboBox.setSelectedItem(new Item("", dateEditor.getFirstDayOfWeek()));
this.returnTypeComboBox.setSelectedIndex(dateEditor.getReturnTypeInt());
this.dateSeparatorTextField.setText(dateEditor.getDateSeparator());
this.configurationItemTextArea.setText(dateEditor.getConfigurationItem());
}
@Override
protected VueDateEditor updateSubDirectWriteEditorBean() {
VueDateEditor dateEditor = new VueDateEditor();
this.dateFormatPane.update(dateEditor);
this.showDatePane.update(dateEditor, true);
this.returnFormatPane.update(dateEditor, false);
dateEditor.setFirstDayOfWeek(this.firstDayOfWeekComboBox.getSelectedItem());
dateEditor.setReturnType(this.returnTypeComboBox.getSelectedIndex());
dateEditor.setDateSeparator(this.dateSeparatorTextField.getText());
dateEditor.setConfigurationItem(this.configurationItemTextArea.getText());
return dateEditor;
}
}

88
src/main/java/com/eco/plugin/zgtpbxdate/pane/self/DirectWriteEditorDefinePane.java

@ -0,0 +1,88 @@
package com.eco.plugin.zgtpbxdate.pane.self;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.DirectWriteEditor;
import javax.swing.*;
import java.awt.*;
public abstract class DirectWriteEditorDefinePane<T extends DirectWriteEditor> extends FieldEditorDefinePane<T> {
public UICheckBox directWriteCheckBox;
protected FormWidgetValuePane formWidgetValuePane;
public DirectWriteEditorDefinePane(XCreator var1) {
super(var1);
}
protected JPanel setFirstContentPane() {
JPanel var1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel var2 = new UILabel(Toolkit.i18nText("Fine-Design_Form_Estate_Widget_Value"));
var2.setVerticalAlignment(1);
this.formWidgetValuePane = new FormWidgetValuePane(this.creator.toData(), false);
Component[] var3 = new Component[]{this.createRepeatCheckBox(), null};
Component[] var4 = this.createDictPane();
Component[] var5 = this.createWaterMarkPane();
double var6 = -1.0D;
double var8 = -2.0D;
Component[][] var10 = new Component[][]{{new UILabel(Toolkit.i18nText("Fine-Design_Form_Label_Name")), this.labelNameTextField}, {var2, this.formWidgetValuePane}, var4, var3, var5, {new UILabel(Toolkit.i18nText("Fine-Design_Form_Font_Size")), this.fontSizePane}};
double[] var11 = new double[]{var8, var8, var8, var8, var8, var8, var8, var8};
double[] var12 = new double[]{var8, var6};
int[][] var13 = new int[][]{{1, 1}, {1, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel var14 = TableLayoutHelper.createGapTableLayoutPane(var10, var11, var12, var13, 25.0D, 10.0D);
var1.add(var14, "North");
JPanel var15 = this.createOtherPane();
if (var15 != null) {
var1.add(var15, "Center");
}
return var1;
}
public UICheckBox createRepeatCheckBox() {
return null;
}
public Component[] createWaterMarkPane() {
return new Component[]{null, null};
}
protected Component[] createDictPane() {
return new Component[]{null, null};
}
public JPanel createOtherPane() {
return null;
}
public JPanel setValidatePane() {
this.directWriteCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Form_Allow_Edit"), false);
this.directWriteCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel var1 = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane();
var1.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
JPanel var2 = GUICoreUtils.createFlowPane(new JComponent[]{this.directWriteCheckBox}, 0, 0);
var1.add(var2);
return var1;
}
protected void populateSubFieldEditorBean(T var1) {
// this.directWriteCheckBox.setSelected(var1.isDirectEdit());
this.populateSubDirectWriteEditorBean(var1);
}
protected abstract void populateSubDirectWriteEditorBean(T var1);
protected T updateSubFieldEditorBean() {
DirectWriteEditor var1 = this.updateSubDirectWriteEditorBean();
// var1.setDirectEdit(this.directWriteCheckBox.isSelected());
return (T) var1;
}
protected abstract T updateSubDirectWriteEditorBean();
}

136
src/main/java/com/eco/plugin/zgtpbxdate/pane/self/FieldEditorDefinePane.java

@ -0,0 +1,136 @@
package com.eco.plugin.zgtpbxdate.pane.self;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.ErrorMsgTextFieldAdapter;
import com.fr.design.beans.UITextFieldAdapter;
import com.fr.design.designer.creator.*;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.fun.TextFieldAdapterProvider;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.ui.designer.AbstractDataModify;
import com.fr.design.widget.ui.designer.component.FontSizeComboPane;
import com.fr.form.ui.FieldEditor;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public abstract class FieldEditorDefinePane<T extends FieldEditor> extends AbstractDataModify<T> {
protected UICheckBox allowBlankCheckBox;
protected ErrorMsgTextFieldAdapter errorMsgTextField;
protected JPanel validatePane;
protected FontSizeComboPane fontSizePane;
protected UITextField labelNameTextField;
public FieldEditorDefinePane(XCreator var1) {
super(var1);
this.initComponents();
}
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.labelNameTextField = new UITextField();
this.allowBlankCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Form_Allow_Null"));
this.allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.fontSizePane = new FontSizeComboPane();
JPanel var1 = this.setFirstContentPane();
if (var1 != null) {
JPanel var2 = FRGUIPaneFactory.createBorderLayout_S_Pane();
var2.add(var1, "Center");
var1.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
UIExpandablePane var3 = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, var2);
this.add(var3, "North");
}
// this.addValidatePane();
}
public void populateBean(T var1) {
this.allowBlankCheckBox.setSelected(var1.isAllowBlank());
// this.errorMsgTextField.setText(var1.getErrorMessage());
this.fontSizePane.setValue(var1.getFontSize());
this.labelNameTextField.setText(var1.getLabelName());
this.populateSubFieldEditorBean(var1);
}
protected abstract void populateSubFieldEditorBean(T var1);
public T updateBean() {
FieldEditor var1 = this.updateSubFieldEditorBean();
var1.setAllowBlank(this.allowBlankCheckBox.isSelected());
// var1.setErrorMessage(this.errorMsgTextField.getText());
var1.setFontSize(this.fontSizePane.getValue());
var1.setLabelName(this.labelNameTextField.getText());
return (T) var1;
}
protected void initErrorMsgPane() {
TextFieldAdapterProvider var1 = (TextFieldAdapterProvider)ExtraDesignClassManager.getInstance().getSingle("TextFieldAdapterProvider");
if (var1 == null) {
this.errorMsgTextField = new UITextFieldAdapter();
} else {
try {
this.errorMsgTextField = var1.createTextFieldAdapter();
} catch (Exception var3) {
FineLoggerFactory.getLogger().error(var3.getMessage(), var3);
this.errorMsgTextField = new UITextFieldAdapter();
}
}
}
protected abstract T updateSubFieldEditorBean();
protected abstract JPanel setFirstContentPane();
public void checkValid() throws Exception {
}
protected void addValidatePane() {
this.initErrorMsgPane();
this.validatePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel var1 = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"));
JPanel var2 = FRGUIPaneFactory.createBorderLayout_S_Pane();
final JPanel var3 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{{var1, this.errorMsgTextField.getErrorMsgTextField()}}, 1, 10.0D, 6.0D);
var3.setBorder(BorderFactory.createEmptyBorder(5, 12, 0, 0));
var2.add(var3, "Center");
this.allowBlankCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent var1) {
boolean var2 = FieldEditorDefinePane.this.allowBlankCheckBox.isSelected();
var3.setVisible(!var2);
}
});
Component[][] var4 = new Component[][]{{this.allowBlankCheckBox}, {var2}};
JPanel var5 = TableLayoutHelper.createGapTableLayoutPane(var4, 1, 5.0D, 0.0D);
var5.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
this.validatePane.add(var5, "North");
JPanel var6 = this.setValidatePane();
if (var6 != null) {
this.validatePane.add(var6, "Center");
}
UIExpandablePane var7 = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Basic_Validate"), 280, 20, this.validatePane);
this.add(var7, "Center");
}
public XLayoutContainer getParent(XCreator var1) {
XLayoutContainer var2 = XCreatorUtils.getParentXLayoutContainer(var1);
if (var1.acceptType(new Class[]{XWFitLayout.class}) || var1.acceptType(new Class[]{XWParameterLayout.class})) {
var2 = null;
}
return var2;
}
public JPanel setValidatePane() {
return null;
}
}

37
src/main/java/com/eco/plugin/zgtpbxdate/provider/VSCellWidgetOptionProvider.java

@ -0,0 +1,37 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VSCellWidgetOptionProvider
* Author: Louis
* Date: 2021/11/5 16:32
*/
package com.eco.plugin.zgtpbxdate.provider;
import com.eco.plugin.zgtpbxdate.pane.VueDateEditorPane;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.impl.AbstractCellWidgetOptionProvider;
import com.fr.form.ui.Widget;
public class VSCellWidgetOptionProvider extends AbstractCellWidgetOptionProvider {
@Override
public Class<? extends Widget> classForWidget() {
return VueDateEditor.class;
}
@Override
public Class<? extends BasicBeanPane<? extends Widget>> appearanceForWidget() {
return VueDateEditorPane.class;
}
@Override
public String iconPathForWidget() {
return "com/fr/design/images/buttonicon/widget/date_16.png";
}
@Override
public String nameForWidget() {
return "自定义日期控件";
}
}

40
src/main/java/com/eco/plugin/zgtpbxdate/provider/VueFormOptionProvider.java

@ -0,0 +1,40 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueFormOptionProvider
* Author: Louis
* Date: 2021/11/8 11:46
*/
package com.eco.plugin.zgtpbxdate.provider;
import com.eco.plugin.zgtpbxdate.creator.XVueDateEditor;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider;
import com.fr.form.ui.Widget;
public class VueFormOptionProvider extends AbstractFormWidgetOptionProvider {
public VueFormOptionProvider() {
}
@Override
public Class<? extends Widget> classForWidget() {
return VueDateEditor.class;
}
@Override
public Class<?> appearanceForWidget() {
return XVueDateEditor.class;
}
@Override
public String iconPathForWidget() {
return "com/fr/design/images/buttonicon/widget/date_16.png";
}
@Override
public String nameForWidget() {
return "自定义日期控件";
}
}

37
src/main/java/com/eco/plugin/zgtpbxdate/provider/VueParameterWidgetOptionProvider.java

@ -0,0 +1,37 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueParameterWidgetOptionProvider
* Author: Louis
* Date: 2021/11/5 16:32
*/
package com.eco.plugin.zgtpbxdate.provider;
import com.eco.plugin.zgtpbxdate.creator.XVueDateEditor;
import com.eco.plugin.zgtpbxdate.widget.VueDateEditor;
import com.fr.design.fun.impl.AbstractParameterWidgetOptionProvider;
import com.fr.form.ui.Widget;
public class VueParameterWidgetOptionProvider extends AbstractParameterWidgetOptionProvider {
@Override
public Class<? extends Widget> classForWidget() {
return VueDateEditor.class;
}
@Override
public Class<?> appearanceForWidget() {
return XVueDateEditor.class;
}
@Override
public String iconPathForWidget() {
return "com/fr/design/images/buttonicon/widget/date_16.png";
}
@Override
public String nameForWidget() {
return "自定义日期控件";
}
}

235
src/main/java/com/eco/plugin/zgtpbxdate/utils/DateUtilSelf.java

@ -0,0 +1,235 @@
package com.eco.plugin.zgtpbxdate.utils;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class DateUtilSelf {
/**
* 获取当前时间 格式 yyyy-MM-dd HH:mm:ss
* @return
*/
public static String getNow() {
return DateToString(new Date(),"yyyy-MM-dd");
}
/**
* 日期转换为日期字符串
* @param date
* @param formatStr
* @return String
*/
public static String DateToString(Date date,String formatStr) {
SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
String dateStr = sdf.format(date).toString();
return dateStr;
}
/**
* 日期字符串转换日期
* @param dateStr
* @param formatStr
* @return Date
*/
public static Date strToDate(String dateStr,String formatStr){
SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
Date date = null;
try {
date = sdf.parse(dateStr);
}
catch(Exception e) {
}
return date;
}
/**
* Date转Timestamp
* @param date
* @return
*/
public static Timestamp dateToTimestamp(Date date) {
Date transDate = DateUtilSelf.strToDate(DateUtilSelf.DateToString(date, "yyyy-MM-dd hh:mm:ss"),"yyyy-MM-dd hh:mm:ss");
Timestamp timestamp = new Timestamp(transDate.getTime());
return timestamp;
}
/**
* Date字符串转Timestamp
* @param dateStr
* @param format
* @return
*/
public static Timestamp strToTimestamp(String dateStr,String format) {
Date date = strToDate(dateStr,format);
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
}
/**
* 获取两个日期字符串之间的天数
* @param startDateStr
* @param endDateStr
* @param formatStr
* @return
*/
public static int getDays(String startDateStr,String endDateStr,String formatStr) {
Date startDate = strToDate(startDateStr,formatStr);
Date endDate = strToDate(endDateStr,formatStr);
long startTime = startDate.getTime();
long endTime = endDate.getTime();
int days = (int) ((endTime - startTime)/(60*60*24*1000));
return days;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param dateStr
* @param count
* @param formatStr
* @return
*/
public static String getAfterDateStr(int type,String dateStr,int count,String formatStr) {
Date startDate = strToDate(dateStr,formatStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
calendar.add(type, count);
String endDateStr = DateToString(calendar.getTime(),formatStr);
return endDateStr;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param date
* @param count
* @param formatStr
* @return
*/
public static String getAfterDateStr(int type,Date date,int count,String formatStr) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(type, count);
String endDateStr = DateToString(calendar.getTime(),formatStr);
return endDateStr;
}
/**
* 获取给定时间之前之后的时间
* @param type
* @param date
* @param count
* @return
*/
public static Date getAfterDateStr(int type,Date date,int count) {
Calendar dateResult = Calendar.getInstance();
dateResult.setTime(date);
dateResult.add(type, count);
return dateResult.getTime();
}
/**
* 时间戳转日期
* @param timestamp
* @return
*/
public static Date timestampToDate(Timestamp timestamp) {
Date date = new Date(timestamp.getTime());
return date;
}
/**
* 时间戳转时间字符串
* @param timestamp
* @param format 日期格式
* @return
*/
public static String timestampToStr(Timestamp timestamp,String format) {
Date date = timestampToDate(timestamp);
String timeStr = DateToString(date, format);
return timeStr;
}
/**
* 获取所给日期length天内每s一天的日期
* @param date 所给日期yyyy-MM-dd
* @param length 长度
* @return
*/
public static List<String> getDateList(String date,int length){
List<String> dateList = new ArrayList<String>();
String format = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//获取length天后的日期
String targetDate = getAfterDateStr(Calendar.DATE,date,length,format);
Date start = null;
Date end = null;
if(length >= 0) {
start = strToDate(date,format);
end = strToDate(targetDate,format);
}else {
start = strToDate(targetDate,format);
end = strToDate(date,format);
}
Calendar calBegin = Calendar.getInstance();
calBegin.setTime(start);
Calendar calEnd = Calendar.getInstance();
calEnd.setTime(end);
while (end.after(calBegin.getTime())) {
calBegin.add(Calendar.DATE, 1);
String dayStr = sdf.format(calBegin.getTime());
dateList.add(dayStr);
}
return dateList;
}
/**
* 比较startDate是否在endDate之前
* @param startDate
* @param endDate
* @param format
* @return 0 两个日期相等 <0 开始日期在结束日期之前 >0 开始日期在结束日期之后
*/
public static int comparisonDate(String startDate,String endDate,String format) {
Date start = strToDate(startDate,format);
Date end = strToDate(endDate,format);
return start.compareTo(end);
}
//获取当前日期年、月、日、时、分、秒
public static int getCount(int type){
Calendar calendar = Calendar.getInstance();
return calendar.get(type);
}
}

559
src/main/java/com/eco/plugin/zgtpbxdate/widget/VueDateEditor.java

@ -0,0 +1,559 @@
/*
* Copyright (C), 2018-2021
* Project: starter
* FileName: VueDateEditorWidget
* Author: Louis
* Date: 2021/11/5 16:32
*/
package com.eco.plugin.zgtpbxdate.widget;
import com.eco.plugin.zgtpbxdate.editors.DateTypeEditor;
import com.eco.plugin.zgtpbxdate.editors.ReturnTypeEditor;
import com.eco.plugin.zgtpbxdate.items.FirstDayOfWeekItems;
import com.fr.base.BaseFormula;
import com.fr.base.ParameterMapNameSpace;
import com.fr.base.Utils;
import com.fr.data.core.FormatField;
import com.fr.design.designer.properties.items.Item;
import com.fr.form.FormUtils;
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.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.UtilEvalError;
import com.fr.stable.core.NodeVisitor;
import com.fr.stable.script.CalculatorProvider;
import com.fr.stable.web.Repository;
import com.fr.stable.web.SessionProvider;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import static com.eco.plugin.zgtpbxdate.creator.XVueDateEditor.*;
/**
* <Function Description><br>
* <VueDateEditor>
*
* @author wink
* @since 1.0.0
*/
public class VueDateEditor extends DirectWriteEditor implements DataControl {
private static final long serialVersionUID = 1406480833692359017L;
public static String oldDateTimeWidgetTag = "com.fr.report.web.ui.DateTimeEditor";
public static String oldDateTimeFormat = "yyyy-MM-dd HH:mm";
public static final String SHOW_DATE_FM = "showDateFM";
public static final String RETURN_FORMAT_FM = "returnFormatFM";
private String startDate;
private String endDate;
private BaseFormula startDateFM;
private BaseFormula endDateFM;
// private String formatText = "yyyy-MM-dd";
// private String formatText = "yyyy-MM-dd hh:mm:ss";
private ValueInitializer widgetValue = new WidgetValue();
// 日期类型和格式
private String dateFormat = DateTypeEditor.DATE;
// 显示日期格式
private String showDate;
private BaseFormula showDateFM;
// 返回格式
private String returnFormat;
private BaseFormula returnFormatFM;
// 周起始日
private int firstDayOfWeek = FirstDayOfWeekItems.SUNDAY;
// 返回类型
private String returnType = ReturnTypeEditor.STRING;
// 数组拼接符
private String dateSeparator = ",";
// 配置项
private String configurationItem = "";
public VueDateEditor() {
}
@Override
public String getXType() {
return "custom_datetime";
}
@Override
public String getFormatText() {
return this.showDate;
}
public void setFormatText(String showDate) {
this.showDate = showDate;
}
@Override
public int[] getValueType() {
return new int[]{TYPE_DATE, TYPE_FORMULA, TYPE_DATABINDING};
}
@Override
public ValueInitializer getWidgetValue() {
return this.widgetValue;
}
@Override
public void setWidgetValue(ValueInitializer valueInitializer) {
this.widgetValue = valueInitializer;
}
@Override
public String[] dependence(CalculatorProvider calculator) {
Set<String> hashSet = new HashSet<>();
if (this.widgetValue != null) {
Collections.addAll(hashSet, this.widgetValue.dependence(calculator));
}
Collections.addAll(hashSet, FormUtils.getDependence(this.getStartDate(), calculator));
Collections.addAll(hashSet, FormUtils.getDependence(this.getEndDate(), calculator));
return hashSet.toArray(new String[0]);
}
public Object getStartDateValue(Calculator calculator) throws Exception {
if (this.startDateFM != null) {
return calculator.eval(this.startDateFM);
} else {
return this.startDate != null ? DateUtils.string2Date(this.startDate, true) : null;
}
}
public Object getEndDateValue(Calculator calculator) throws Exception {
if (this.endDateFM != null) {
return calculator.eval(this.endDateFM);
} else {
return this.endDate != null ? DateUtils.string2Date(this.endDate, true) : null;
}
}
public Object getStartDate() {
if (this.startDateFM != null) {
return this.startDateFM;
} else {
return this.startDate != null ? DateUtils.string2Date(this.startDate, true) : null;
}
}
public void setStartDate(Object startDate) {
if (startDate instanceof BaseFormula) {
this.startDateFM = (BaseFormula) startDate;
this.startDate = null;
} else if (startDate instanceof Date) {
this.startDateFM = null;
this.startDate = DateUtils.getDate2Str("MM/dd/yyyy", (Date) startDate);
} else {
this.startDateFM = null;
this.startDate = null;
}
}
public Object getEndDate() {
if (this.endDateFM != null) {
return this.endDateFM;
} else {
return this.endDate != null ? DateUtils.string2Date(this.endDate, true) : null;
}
}
public void setEndDate(Object endDate) {
if (endDate instanceof BaseFormula) {
this.endDateFM = (BaseFormula) endDate;
this.endDate = null;
} else if (endDate instanceof Date) {
this.endDateFM = null;
this.endDate = DateUtils.getDate2Str("MM/dd/yyyy", (Date) endDate);
} else {
this.endDateFM = null;
this.endDate = null;
}
}
public String getStartText() {
return this.startDate;
}
public void setStartText(String startText) {
this.startDate = startText;
}
public String getEndText() {
return this.endDate;
}
public void setEndText(String endText) {
this.endDate = endText;
}
public BaseFormula getStartDateFM() {
return this.startDateFM;
}
public void setStartDateFM(BaseFormula formula) {
this.startDateFM = formula;
}
public BaseFormula getEndDateFM() {
return this.endDateFM;
}
public void setEndDateFM(BaseFormula formula) {
this.endDateFM = formula;
}
@Override
public void createValueResult(CalculatorProvider calculator, JSONObject widgetResult) {
if (this.widgetValue != null) {
calculator.setAttribute(Widget.NAME, this.getWidgetName().toUpperCase());
Object result = this.getWidgetValue().executeResult(calculator);
if (StringUtils.equals(this.returnType, ReturnTypeEditor.STRING)
&& result instanceof Date && this.showDate != null) {
result = (new SimpleDateFormat(this.showDate)).format((Date) result);
}
widgetResult.put(this.widgetName.toUpperCase(), result == null ? "" : result);
}
}
@Override
public String getDataBindDefaultValue(CalculatorProvider calculator) {
if (this.widgetValue == null) {
this.setWidgetValue(new WidgetValue());
}
Object result = this.getWidgetValue().executeResult(calculator);
if (result == null) {
return null;
} else {
return result instanceof Date && this.showDate != null ? (new SimpleDateFormat(this.showDate)).format((Date) result) : Utils.objectToString(result);
}
}
@Override
public JSONObject createJSONConfig(Repository repository, Calculator calculator, NodeVisitor nodeVisitor) throws JSONException {
JSONObject config = super.createJSONConfig(repository, calculator, nodeVisitor);
config.put("allowBlank", this.allowBlank);
Object value = config.get("value");
if (value == null) {
config.remove("value");
} else if (value instanceof Date) {
config.put("value", (new JSONObject()).put("date_milliseconds", ((Date) value).getTime()));
}
if (StringUtils.isNotEmpty(this.showDate)) {
config.put("format", this.showDate);
if (!ArrayUtils.contains(FormatField.getInstance().getDateFormatArray(), this.showDate)) {
config.put("customFormat", true);
}
}
try {
if (StringUtils.isNotEmpty(this.startDate)) {
config.put("startDate", this.value2Config(this.startDate, calculator));
} else if (this.startDateFM != null) {
config.put("startDate", this.value2Config(calculator.evalValue(this.startDateFM.getContent()), calculator));
}
if (StringUtils.isNotEmpty(this.endDate)) {
config.put("endDate", this.value2Config(this.endDate, calculator));
} else if (this.endDateFM != null) {
config.put("endDate", this.value2Config(calculator.evalValue(this.endDateFM.getContent()), calculator));
}
if (StringUtils.isNotBlank(this.getDateFormat())) {
config.put(DATE_FORMAT, this.getDateFormat());
}
if (StringUtils.isNotBlank(this.getShowDate())) {
config.put(SHOW_DATE, this.getShowDate());
}
if (!CommonUtils.isNull(this.getShowDateFM())) {
config.put(SHOW_DATE, calculator.evalValue(this.getShowDateFM()));
}
if (StringUtils.isNotBlank(this.getReturnFormat())) {
config.put(RETURN_FORMAT, this.getReturnFormat());
}
if (!CommonUtils.isNull(this.getReturnFormatFM())) {
config.put(RETURN_FORMAT, calculator.evalValue(this.getReturnFormatFM()));
}
} catch (UtilEvalError e) {
// LogKit.error(e.getMessage(), e);
}
config.put(FIRST_DAY_OF_WEEK, this.getFirstDayOfWeek());
if (StringUtils.isNotBlank(this.getReturnType())) {
config.put(RETURN_TYPE, this.getReturnType());
}
if (StringUtils.isNotBlank(this.getDateSeparator())) {
config.put(DATE_SEPARATOR, this.getDateSeparator());
}
if (StringUtils.isNotBlank(this.getConfigurationItem())) {
config.put(CONFIGURATION_ITEM, this.getConfigurationItem());
}
String[] dependence = this.dependence(calculator);
if (!ArrayUtils.isEmpty(dependence)) {
config.put("dependence", dependence);
}
return config;
}
@Override
public JSONArray createJSONData(SessionProvider sessionProvider, Calculator calculator, HttpServletRequest request) throws Exception {
JSONArray data = super.createJSONData(sessionProvider, calculator, request);
ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(sessionProvider.getOriginalParameterMap());
DependenceNameSpace dependenceNameSpace = new DependenceNameSpace(WebUtils.getHTTPRequestParameter(request, "dependence"));
calculator.pushNameSpace(parameterMapNameSpace);
calculator.pushNameSpace(dependenceNameSpace);
JSONObject dateJson = JSONObject.create();
dateJson.put("startDate", this.value2Config(this.getStartDateValue(calculator), calculator));
dateJson.put("endDate", this.value2Config(this.getEndDateValue(calculator), calculator));
data.put(dateJson);
calculator.removeNameSpace(parameterMapNameSpace);
calculator.removeNameSpace(dependenceNameSpace);
return data;
}
@Override
public Object value2Config(Object value, CalculatorProvider calculator) {
String config;
if (value instanceof Date) {
config = (new SimpleDateFormat(this.showDate)).format((Date) value);
} else if (value == null) {
config = "";
} else {
String str = Utils.objectToString(value);
try {
Date var5 = DateUtils.string2Date(str, false);
config = (new SimpleDateFormat(this.showDate)).format(var5);
} catch (Exception e) {
config = value.toString();
}
}
return config;
}
@Override
public String[] supportedEvents() {
return new String[]{"afterinit", "afteredit", "stopedit"};
}
@Override
public boolean equals(Object obj) {
return obj instanceof VueDateEditor && super.equals(obj)
&& ComparatorUtils.equals(this.startDate, ((VueDateEditor) obj).startDate)
&& ComparatorUtils.equals(this.endDate, ((VueDateEditor) obj).endDate)
&& StringUtils.equals(this.returnType, ((VueDateEditor) obj).returnType);
}
@Override
public void readXML(XMLableReader reader) {
super.readXML(reader);
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("DateAttr".equals(tagName)) {
String element;
if ((element = reader.getAttrAsString("format", null)) != null) {
this.setFormatText(element);
}
if ((element = reader.getAttrAsString("start", null)) != null) {
this.startDate = element;
} else if ((element = reader.getAttrAsString("startdatefm", null)) != null) {
this.startDateFM = BaseFormula.createFormulaBuilder().build(element);
}
if ((element = reader.getAttrAsString("end", null)) != null) {
this.endDate = element;
} else if ((element = reader.getAttrAsString("enddatefm", null)) != null) {
this.endDateFM = BaseFormula.createFormulaBuilder().build(element);
}
this.setShowDate(reader.getAttrAsString(SHOW_DATE, ""));
this.setShowDateFM(BaseFormula.createFormulaBuilder().build(reader.getAttrAsString(SHOW_DATE_FM, "")));
this.setReturnFormat(reader.getAttrAsString(RETURN_FORMAT, ""));
this.setReturnFormatFM(BaseFormula.createFormulaBuilder().build(reader.getAttrAsString(RETURN_FORMAT_FM, "")));
this.setFirstDayOfWeek(reader.getAttrAsInt(FIRST_DAY_OF_WEEK, FirstDayOfWeekItems.SUNDAY));
this.setReturnType(reader.getAttrAsString(RETURN_TYPE, ReturnTypeEditor.STRING));
this.setDateFormat(reader.getAttrAsString(DATE_FORMAT, DateTypeEditor.DATE));
this.setDateSeparator(reader.getAttrAsString(DATE_SEPARATOR, ""));
this.setConfigurationItem(reader.getAttrAsString(CONFIGURATION_ITEM, ""));
} else if ("widgetValue".equals(tagName)) {
this.widgetValue = new WidgetValue();
reader.readXMLObject(this.widgetValue);
}
}
if (ComparatorUtils.equals(reader.getAttrAsString("class", null), oldDateTimeWidgetTag) && reader.getAttrAsString("format", (String) null) == null) {
this.setFormatText(oldDateTimeFormat);
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG("DateAttr");
if (!ComparatorUtils.equals(this.getFormatText(), this.getDefaultFormatText())) {
writer.attr("format", this.getFormatText());
}
if (StringUtils.isNotEmpty(this.startDate)) {
writer.attr("start", this.startDate);
} else if (this.startDateFM != null) {
writer.attr("startdatefm", this.startDateFM.getContent());
}
if (StringUtils.isNotEmpty(this.endDate)) {
writer.attr("end", this.endDate);
} else if (this.endDateFM != null) {
writer.attr("enddatefm", this.endDateFM.getContent());
}
if (StringUtils.isNotBlank(this.getDateFormat())) {
writer.attr(DATE_FORMAT, this.getDateFormat());
}
if (StringUtils.isNotBlank(this.getShowDate())) {
writer.attr(SHOW_DATE, this.getShowDate());
}
if (this.getShowDateFM() != null && StringUtils.isNotBlank(this.getShowDateFM().getContent())) {
writer.attr(SHOW_DATE_FM, this.getShowDateFM().getContent());
}
if (StringUtils.isNotBlank(this.getReturnFormat())) {
writer.attr(RETURN_FORMAT, this.getReturnFormat());
}
if (this.getReturnFormatFM() != null && StringUtils.isNotBlank(this.getReturnFormatFM().getContent())) {
writer.attr(RETURN_FORMAT_FM, this.getReturnFormatFM().getContent());
}
writer.attr(FIRST_DAY_OF_WEEK, this.getFirstDayOfWeek());
if (StringUtils.isNotBlank(this.getReturnType())) {
writer.attr(RETURN_TYPE, this.getReturnType());
}
if (StringUtils.isNotBlank(this.getDateSeparator())) {
writer.attr(DATE_SEPARATOR, this.getDateSeparator());
}
if (StringUtils.isNotBlank(this.getConfigurationItem())) {
writer.attr(CONFIGURATION_ITEM, this.getConfigurationItem());
}
writer.end();
if (this.widgetValue != null) {
this.widgetValue.writeXML(writer);
}
}
protected String getDefaultFormatText() {
return "yyyy-MM-dd";
}
public String getShowDate() {
return showDate;
}
public void setShowDate(String showDate) {
this.showDate = showDate;
}
public BaseFormula getShowDateFM() {
return showDateFM;
}
public void setShowDateFM(BaseFormula showDateFM) {
this.showDateFM = showDateFM;
}
public int getFirstDayOfWeek() {
return firstDayOfWeek;
}
public void setFirstDayOfWeek(Object firstDayOfWeek) {
Item selectedItem = (Item) firstDayOfWeek;
this.firstDayOfWeek = Integer.parseInt(String.valueOf(selectedItem.getValue()));
}
public void setFirstDayOfWeek(int firstDayOfWeek) {
this.firstDayOfWeek = firstDayOfWeek;
}
public String getConfigurationItem() {
return configurationItem;
}
public void setConfigurationItem(String configurationItem) {
this.configurationItem = configurationItem;
}
public String getDateFormat() {
return dateFormat;
}
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
public String getReturnFormat() {
return returnFormat;
}
public void setReturnFormat(String returnFormat) {
this.returnFormat = returnFormat;
}
public BaseFormula getReturnFormatFM() {
return returnFormatFM;
}
public void setReturnFormatFM(BaseFormula returnFormatFM) {
this.returnFormatFM = returnFormatFM;
}
public int getReturnTypeInt() {
if (StringUtils.equals(this.returnType, ReturnTypeEditor.DATE)) {
return 0;
} else if (StringUtils.equals(this.returnType, ReturnTypeEditor.STRING)) {
return 1;
} else {
return 1;
}
}
public String getReturnType() {
return returnType;
}
public void setReturnType(int returnType) {
if (ComparatorUtils.equals(returnType, 0)) {
this.returnType = ReturnTypeEditor.DATE;
} else if (ComparatorUtils.equals(returnType, 1)) {
this.returnType = ReturnTypeEditor.STRING;
} else {
this.returnType = ReturnTypeEditor.STRING;
}
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getDateSeparator() {
return dateSeparator;
}
public void setDateSeparator(String dateSeparator) {
this.dateSeparator = dateSeparator;
}
}

65
src/main/resources/com/eco/plugin/zgtpbxdate/css/base.css

@ -0,0 +1,65 @@
.wrapper{
max-width: 100%;
width: 800px;
margin: 0 auto;
}
.htmleaf-links{
padding: 20px 0;
text-align: center;
}
.text-center {
text-align: center;
}
.related {
margin-top: 50px;
/* color: #fff; */
/* background: #494A5F; */
text-align: center;
font-size: 1.25em;
padding: 0.5em 0;
overflow: hidden;
}
.related > a {
vertical-align: top;
width: calc(100% - 20px);
max-width: 340px;
display: inline-block;
text-align: center;
margin: 20px 10px;
padding: 25px;
/* font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo; */
}
.related a {
display: inline-block;
text-align: left;
margin: 20px auto;
padding: 10px 20px;
/* opacity: 0.8; */
-webkit-transition: opacity 0.3s;
transition: opacity 0.3s;
-webkit-backface-visibility: hidden;
text-decoration: none;
}
.related a:hover,
.related a:active {
opacity: 1;
}
.related a img {
max-width: 100%;
/* opacity: 0.8; */
border-radius: 4px;
}
.related a:hover img,
.related a:active img {
opacity: 1;
}
.related h3{font-family: "Microsoft YaHei", sans-serif;font-size: 1.2em}
.related a h3 {
font-size: 0.85em;
font-weight: 500;
margin-top: 0.15em;
/* color: #fff; */
}

25
src/main/resources/com/eco/plugin/zgtpbxdate/css/custom.css

@ -0,0 +1,25 @@
.c999 {
color: #999;
font-size: 12px;
}
.c-datepicker-picker__footer{
display: flex;
flex-direction: row;
}
.my-button{
width: auto;
height: 23px;
line-height: 22px;
margin: 10px 6px 10px 6px;
border: 1px solid #409EFF;
color: #409EFF;
background-color: #E2F4F6;
min-width: 20px;
border-radius: 4px;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
padding-left: 5px;
padding-right: 5px;
}

1
src/main/resources/com/eco/plugin/zgtpbxdate/css/datepicker.css

File diff suppressed because one or more lines are too long

1
src/main/resources/com/eco/plugin/zgtpbxdate/css/iconfont.css

@ -0,0 +1 @@
@font-face{font-family:"kxiconfont";src:url("iconfont.eot?t=1534989522363");src:url("iconfont.eot?t=1534989522363#iefix") format("embedded-opentype"),url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAVIAAsAAAAACDAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY8j0g/Y21hcAAAAYAAAABsAAABuLPUtGhnbHlmAAAB7AAAAUwAAAG8Fx4wJ2hlYWQAAAM4AAAALwAAADYSZ6+haGhlYQAAA2gAAAAcAAAAJAfeA4dobXR4AAADhAAAAA4AAAAYGAAAAGxvY2EAAAOUAAAADgAAAA4BYADIbWF4cAAAA6QAAAAfAAAAIAETAEFuYW1lAAADxAAAAUUAAAJtPlT+fXBvc3QAAAUMAAAAOwAAAE2wPds5eJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeST7zZW7438AQw9zA0AAUZgTJAQDk6QxJeJztkdENgCAMRA8BYwwL+IMM4ATOIGv45dxdA9urY3jkNddL048CIAOIyqEkIDwIMN2aBuYRK/OEU/tF3wTIJk36GHTVHRU4Uegm3R65dcavwnp9XbbLOXZnqQ5vuzucaY79kXQH6QUQEheSeJxdjj9Lw1AUxd9JmsSQVKtNG4ekSrXp1kATG0HtEKij+AWEIhgUXJxcHdx0dqj45yOog6OFqoOD4OLQb+BQN3Hz6nuW0uobHvf33jnnHgbGj9STnpnCmI5AxxwsNPfoDDv72EWTLulCSIRO3pZ6bIxNCqWmw0YtLA0GaZpufCzRvY91E4t0PYRzrPn0QB0O6dn0KAxz33nulMiNdJShWspgsPEmHI9Y8enKpKcRMLApdi6jzokn/4F+5+8PqSubTGUaYzzut6vU9ajlIRHXMQ48bJWoRa0SjkQV7rmTO3LMDDbPQu4ah1aAXUdUQVbV1GK5grIXRvyhVrX5T97SVB8LoVdUXU5BNap5EmtTKkXtNikKrQZx46QRJ67juMlwbN7mZ/KvhpE1dUWOFSHuW77qgeO6TvLftXH4ksnlMp+n2kS6wKv+ANtFbjx4nGNgZGBgAOJlq92M4/ltvjJwszCAwPUlppcQ9P99LAzMTkAuBwMTSBQALeQKjwB4nGNgZGBgbvjfwBDDwgACQJKRARWwAQBHDAJveJxjYWBgYMGCAQFoABkAAAAAAAAAFABAAG4AiADeAAB4nGNgZGBgYGMwZWBmAAEmIOYCQgaG/2A+AwAOXgFVAHicZY9NTsMwEIVf+gekEqqoYIfkBWIBKP0Rq25YVGr3XXTfpk6bKokjx63UA3AejsAJOALcgDvwSCebNpbH37x5Y08A3OAHHo7fLfeRPVwyO3INF7gXrlN/EG6QX4SbaONVuEX9TdjHM6bCbXRheYPXuGL2hHdhDx18CNdwjU/hOvUv4Qb5W7iJO/wKt9Dx6sI+5l5XuI1HL/bHVi+cXqnlQcWhySKTOb+CmV7vkoWt0uqca1vEJlODoF9JU51pW91T7NdD5yIVWZOqCas6SYzKrdnq0AUb5/JRrxeJHoQm5Vhj/rbGAo5xBYUlDowxQhhkiMro6DtVZvSvsUPCXntWPc3ndFsU1P9zhQEC9M9cU7qy0nk6T4E9XxtSdXQrbsuelDSRXs1JErJCXta2VELqATZlV44RelzRiT8oZ0j/AAlabsgAAAB4nGNgYoAALgbsgI2RiZGZkYWRlZGNkZ2BJSc1rYQlJ7G4hDUtswhIFmWmZ5SwJufkJ2czMAAApPgJ/AA=") format("woff"),url("iconfont.ttf?t=1534989522363") format("truetype"),url("iconfont.svg?t=1534989522363#iconfont") format("svg")}.kxiconfont{font-family:"kxiconfont" !important;font-size:16px;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-left:before{content:"\e619"}.icon-last:before{content:"\e61e"}.icon-first:before{content:"\e620"}.icon-right:before{content:"\e64d"}.icon-clock:before{content:"\e61f"}

214
src/main/resources/com/eco/plugin/zgtpbxdate/js/custom.js

@ -0,0 +1,214 @@
// 计算某个日期距离今天有多少天
function calculateDays(date) {
const today = new Date(); // 获取今天的日期
const inputDate = new Date(date); // 将传入的日期字符串转换为日期对象
// 将日期转换为时间戳,并计算日期差距的毫秒数
const diff = inputDate.getTime() - today.getTime();
// 将毫秒数转换为天数差距
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
return days + 1;
}
//获取去年第一天到现在一共多少天
function lastYearFToToday(){
var now = new Date();
var lastYear = now.getFullYear() - 1;
var firstDayLastYear = new Date(lastYear, 0, 1);
var diff = Math.floor((now - firstDayLastYear) / (1000 * 60 * 60 * 24));
return diff
}
//获取年初到现在一共多少天
function lastYearLToToday(){
// 获取当前时间的年份
var currentYear = new Date().getFullYear();
// 构造去年最后一天的日期
var lastDayOfLastYear = new Date(currentYear - 1, 11, 31); // 11表示12月,因为月份是从0开始的
// 计算去年最后一天距离现在的天数
var timeDiff = new Date() - lastDayOfLastYear;
var daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
return daysDiff
}
//获取当前时间距离明年第一天还有多少天
function toDayToNextYear(){
// 获取当前日期
var currentDate = new Date();
// 获取明年第一天的日期
var nextYear = currentDate.getFullYear() + 1;
var firstDayOfYear = new Date(nextYear, 0, 1);
// 计算当前时间距离明年第一天的时间差(以天为单位)
var timeDifference = Math.ceil((firstDayOfYear - currentDate) / (1000 * 60 * 60 * 24));
return timeDifference - 1
}
//获取上个季度第一天的具体日期
function getLastQuarterFirstDay() {
var today = new Date(); // 获取当前日期
var year = today.getFullYear(); // 获取当前年份
var month = today.getMonth(); // 获取当前月份
// 计算前一个季度的月份范围
var startMonth, endMonth;
if(month >= 0 && month <= 2) { // 第一季度
startMonth = 9; // 上一年的10月
endMonth = 11; // 上一年的12月
year--; // 年份减1
} else if(month >= 3 && month <= 5) { // 第二季度
startMonth = 0; // 1月
endMonth = 2; // 3月
} else if(month >= 6 && month <= 8) { // 第三季度
startMonth = 3; // 4月
endMonth = 5; // 6月
} else { // 第四季度
startMonth = 6; // 7月
endMonth = 8; // 9月
}
// 创建日期对象
var firstDay = new Date(year, startMonth, 1);
return firstDay.toLocaleDateString();
}
//获取上个季度最后一天距离今天有多少天
function getDaysToLastDayOfPreviousQuarter() {
var today = new Date();
var currentMonth = today.getMonth();
var currentQuarter = Math.floor(currentMonth / 3); // 获取当前季度
var lastQuarterLastMonth = (currentQuarter - 1) * 3 + 2; // 上个季度的最后一个月
var lastQuarterLastDay = new Date(today.getFullYear(), lastQuarterLastMonth + 1, 0).getDate(); // 上个季度的最后一天
var timeDiff = Math.ceil((today - new Date(today.getFullYear(), lastQuarterLastMonth, lastQuarterLastDay)) / (1000 * 60 * 60 * 24));
return timeDiff
}
//js获取本季度最后一天距离今天有多少天
function getDaysToThisDayOfPreviousQuarter() {
const currentDate = new Date();
const currentMonth = currentDate.getMonth() + 1; // 注意月份范围是0-11,所以需要+1
const currentYear = currentDate.getFullYear();
let lastDay;
if (currentMonth >= 1 && currentMonth <= 3) {
// 第一季度
lastDay = new Date(currentYear, 2, 31); // 本季度最后一天为3月的31号
} else if (currentMonth >= 4 && currentMonth <= 6) {
// 第二季度
lastDay = new Date(currentYear, 5, 30); // 本季度最后一天为6月的30号
} else if (currentMonth >= 7 && currentMonth <= 9) {
// 第三季度
lastDay = new Date(currentYear, 8, 30); // 本季度最后一天为9月的30号
} else if (currentMonth >= 10 && currentMonth <= 12) {
// 第四季度
lastDay = new Date(currentYear, 11, 31); // 本季度最后一天为12月的31号
}
const year = lastDay.getFullYear();
const month = lastDay.getMonth() + 1;
const day = lastDay.getDate();
return `${year}/${month}/${day}`;
}
//上月第一天距离今天
function getLastMonthToToday() {
// 获取今天的日期
var today = new Date();
// 获取上个月的年份和月份
var year, month;
if (today.getMonth() === 0) {
year = today.getFullYear() - 1;
month = 12;
} else {
year = today.getFullYear();
month = today.getMonth();
}
// 构建上个月第一天的日期对象
var firstDayOfLastMonth = new Date(year, month - 1, 1);
// 计算上个月第一天距离今天的天数
var daysDiff = Math.ceil((today - firstDayOfLastMonth) / (1000 * 60 * 60 * 24));
return daysDiff
}
function getDaysFromFirstDayOfMonth() {
var today = new Date(); // 获取当前日期
var firstDay = new Date(today.getFullYear(), today.getMonth(), 1); // 获取本月第一天
var timeDiff = today.getTime() - firstDay.getTime(); // 计算时间差
var dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24)); // 将时间差转换为天数
return dayDiff;
}
//获取本月最后一天距离今天有多少天
function getDaysUntilLastDayOfMonth() {
// 获取当前日期
var today = new Date();
var lastDayOfMonth = new Date(today.getFullYear(), today.getMonth()+1, 0);
var diff = lastDayOfMonth.getDate() - today.getDate();
return diff;
}
//修改左边快捷键的样式
function changeUI(index = 0){ //多个日期组件同时存在一个页面时,改变这个值切换要修改哪个日期的快捷键
e = window.event||e;
var obj = e.srcElement || e.target;
if($(obj).is(".c-datepicker-range-separator")){
return ;
}
let pickers = $(".c-datepicker-popper")
let id = "changeUi"+index;
pickers[index].id = id;
$(`#${id} .c-datepicker-picker__sidebar`).children().appendTo(`#${id} .c-datepicker-picker__footer`);
$(`#${id} .c-datepicker-picker__sidebar`).remove()
let old = $(`#${id} .c-datepicker-picker__footer`).children()
for(let i=0;i<old.length;i++){
// old[i].className = 'c-datepicker-picker__shortcut my-button'
let txt = old[i].innerHTML
if(txt && txt.indexOf('清空') == -1) {
old[i].className = 'c-datepicker-picker__shortcut my-button'
}else{
old[i].className = old[i].className + ' c-datepicker-picker__shortcut my-button'
}
if(txt && txt.indexOf('确定') > -1) old[i].remove()
// if(txt && txt.indexOf('清空') > -1) old[i].remove()
}
$("#"+id).css({"display":"block"});
$("body").one("click",function(){
$("#"+id).css({"display":"none"});
})
}
var DATAPICKERAPI = {
// 快捷选项option,参数day是距离今天是天数
rangeShortcutOption1: [{
name: '今天',
day: '0,0',
}, {
name: '昨天',
day: '-1,-1',
}, {
name: '本月',
day: '-'+(getDaysFromFirstDayOfMonth()-1)+','+ getDaysUntilLastDayOfMonth(),
}, {
name: '上月',
day: '-'+ (getLastMonthToToday()-1) +',-' + getDaysFromFirstDayOfMonth(),
}, {
name: '本季度',
day:'-' +(getDaysToLastDayOfPreviousQuarter() -2)+','+ calculateDays( getDaysToThisDayOfPreviousQuarter() ),
}, {
name: '上季度',
day: calculateDays( getLastQuarterFirstDay() ) +', -' + (getDaysToLastDayOfPreviousQuarter()-1),
}, {
name: '当年',
// day: '-'+ (lastYearLToToday()-1) +', '+ toDayToNextYear(),
day: '-'+ (lastYearLToToday()-1) +', 0',
}, {
name: '去年',
day:'-'+lastYearFToToday() + ', -'+lastYearLToToday(),
}],
};

3246
src/main/resources/com/eco/plugin/zgtpbxdate/js/datepicker.all.js

File diff suppressed because it is too large Load Diff

26
src/main/resources/com/eco/plugin/zgtpbxdate/js/datepicker.en.js

@ -0,0 +1,26 @@
/**
* Simplified Chinese translation for bootstrap-datetimepicker
* Yuan Cheung <advanimal@gmail.com>
*/
;(function($){
$.fn.datePicker.dates['en'] = {
days: ["Sun", 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
now: "now",
clear: 'clear',
headerYearLink:'',
units: ['-', ''],
button: ["confirm", "cancel"],
confirm: 'confirm',
cancel: 'cancel',
chooseDay: 'Choose Day',
chooseTime: 'Choose Time',
begin: 'Start Time',
end: 'End Time',
prevYear: 'prevYear',
prevMonth: 'prevMonth',
nextYear: 'nextYear',
nextMonth: 'nextMonth',
zero: '0:00'
};
}(jQuery));

3196
src/main/resources/com/eco/plugin/zgtpbxdate/js/moment.min.js vendored

File diff suppressed because it is too large Load Diff

242
src/main/resources/com/eco/plugin/zgtpbxdate/js/vuedatetime.js

@ -0,0 +1,242 @@
var i = 0;
window.onload=function (){
var timer = setInterval(function(){
var dom = $(".c-datepicker-date-editor");
if(dom.length > 0){
$('.J-datepicker-range-day').datePicker({
hasShortcut: true,
format: 'YYYY-MM-DD',
isRange: true,
shortcutOptions: DATAPICKERAPI.rangeShortcutOption1
});
clearInterval(timer)
}
}, 500)
}
;
;(function ($) {
FR.VueDateTimeEditor = FR.extend(FR.DateTimeEditor, {
_defaultConfig: function () {
return $.extend(FR.VueDateTimeEditor.superclass._defaultConfig.apply(), {
format: "yyyy-MM-dd",
directEdit: true
})
},
uuid: function () {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 12; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
var uuid = 'vue' + s.join("");
return uuid;
},
_init: function () {
try {
FR.VueDateTimeEditor.superclass._init.apply(this, arguments);
this._hideView();
// FR.$defaultImport('/com/fr/plugin/abege/css/index.min.css', 'css');
var dom = this.element;
var id = this.options.location = this.options.location || this.uuid();
$(dom).attr("id", id);
var d = $("#" + id)
if (d[0]) {
this._realInit();
} else {
this._initMe();
}
this.editComp.keydown(function (c) {
a.editComp[0].realValue = null
});
$(this.editComp).keyup(function () {
if ($(this).val() == a.oriText) {
return
}
a.isValidateInput();
a.oriText = $(this).val();
a.fireEvent(FR.Events.AFTEREDIT)
});
} catch (e) {
console.error(e);
}
},
onTriggerClick: function (a) {
if (!this.isEnabled()) {
return
}
if (document.activeElement != this.editComp[0]) {
this.editComp.focus()
}
if (this.isExpanded()) {
if (FR.Browser.isIE8() && this.$view.css("visibility") == "hidden") {
this.$view.css("visibility", "visible")
} else {
this.$view.show()
}
} else {
this.$view.empty();
this._createCalendar()
}
},
reportEdit: function () {
var that = this;
setTimeout(function () {
that.fireEvent(FR.Events.AFTEREDIT);
}, 300)
},
_realInit: function () {
this._showView();
$(this.element).css("overflow", "unset")
var opt = this.options;
var id = opt.location;
opt.index = i;
var width = opt.width;
var eachWidth = width/2.5
var height = opt.height
var dom = $('#' + id);
$(dom).html("<div style='width:"+width+"px;height:"+height+"px;line-height: "+height+"px' class=\"c-datepicker-date-editor J-datepicker-range-day \" onclick=\"changeUI("+i+")\">\n" +
" <input id=\"startTime"+i+"\" style='width:"+eachWidth+"px;color:black' placeholder=\"开始日期\" name=\"\" class=\"c-datepicker-data-input only-date\" value=\"\" readonly>\n" +
" <span class=\"c-datepicker-range-separator only-date\">~</span>\n" +
" <input id=\"endTime"+i+"\" style='width:"+eachWidth+"px;color:black' placeholder=\"结束日期\" name=\"\" class=\"c-datepicker-data-input only-date\" value=\"\" readonly>\n" +
" </div>");
i++;
},
_initMe: function () {
var id = this.options.location;
var that = this;
var intc = setTimeout(function () {
var dom = $("#" + id);
if (dom[0]) {
that._realInit();
} else {
that._initMe();
}
}, 100)
},
setText: function (text) {
this.editComp.val(1111);
},
_hideView: function () {
if (FR.Browser.isIE8()) {
this.element.css("visibility", "hidden");
} else {
this.element.hide();
}
},
_showView: function () {
if (FR.Browser.isIE8()) {
this.element.css("visibility", "show");
} else {
var id = this.options.location;
$("#" + id).show();
}
},
setValue: function (value) {
try {
if (value) {
this.app.$refs.vueDateTime.value = value;
}
} catch (e) {
console.error(e);
}
},
startEditing: function () {
this._showView()
},
stopEditing: function () {
},
getValue: function () {
var opt = this.options;
var id = opt.index;
let startTime = $('#startTime'+id).val();
let endTime = $('#endTime'+id).val();
var tmpDateArr = [];
console.info(startTime);
if(startTime){
tmpDateArr.push(startTime);
}else{
tmpDateArr.push("");
}
if(endTime){
tmpDateArr.push(endTime);
}else{
tmpDateArr.push("");
}
if(!startTime && !endTime){
var tmpDateArr = [];
}
if (this.options.returnType === 'string') {
return tmpDateArr;
} else {
var format = this.options.format;
var result = FR.date2Str(tmpDate, format);
return (result == null) ? "" : result;
}
},
});
$.shortcut("custom_datetime", FR.VueDateTimeEditor);
})(jQuery);
(function ($) {
!(function () {
try {
var provider = BI.Providers.getProvider("report.controller.provider");
} catch (e) {
return;
}
var ImplClass = provider.getImpl();
var Widget = BI.inherit(ImplClass, {
mounted: function () {
this.widget = FR.createWidget(BI.extend({}, this.options, {
type: 'custom_datetime',
renderEl: this.element[0],
}));
Widget.superclass.mounted.apply(this, arguments);
},
isValidate: function () {
return true;
},
focusDown: function () {
return (this.widget && this.widget.focusDown.apply(this.widget, arguments))
},
getValue: function () {
return (this.widget && this.widget.getValue.apply(this.widget, arguments))
},
reset: function () {
return (this.widget && this.widget.reset.apply(this.widget, arguments))
},
preGetValidation: function () {
return {result: this.isValidate.apply(this, arguments)}
},
postGetValidation: function () {
return {result: this.isValidate.apply(this, arguments)}
},
setInteractValue: function () {
this.widget && this.widget.setValue.apply(this.widget, arguments)
},
setControllerValue: function () {
this.widget && this.widget.setValue.apply(this.widget, arguments)
},
resize: function (width, height) {
this.widget && this.widget.doResize({
width: width, height: height
});
}
});
Widget.xtype = "custom_datetime";
BI.shortcut(Widget.xtype, Widget);
provider.set('custom_datetime', Widget.xtype);
})();
})(jQuery);

32
src/main/resources/com/eco/plugin/zgtpbxdate/locale/lang.properties

@ -0,0 +1,32 @@
Plugin-abege=Vue Date Picker Plugin
Plugin-abege_Licence_Expired=Vue Date Picker Plugin Licence Expired
Plugin-abege-Date_Format=Type/Format
Plugin-abege-Date_Format_Year=year
Plugin-abege-Date_Format_Month=month
Plugin-abege-Date_Format_Date=date
Plugin-abege-Date_Format_Dates=dates
Plugin-abege-Date_Format_Week=week
Plugin-abege-Date_Format_DateRange=daterange
Plugin-abege-Date_Format_DateRangeWeek=daterangeweek
Plugin-abege-Date_Format_DateRangeMonth=daterangemonth
Plugin-abege-Date_Format_DateTime=datetime
Plugin-abege-Date_Format_DateTimeRange=datetimerange
Plugin-abege-Design_Form_Date_Type=Type/Format
Plugin-abege-Date_Type_Date=Date
Plugin-abege-Date_Type_DateTime=DateTime
Plugin-abege-Design_Form_Start_Date=Start Date
Plugin-abege-Design_Form_Show_Date=Show Date
Plugin-abege-Design_Form_Return_Format=Return Format
Plugin-abege-Design_Form_Week_Start_Date=Week Start Date
Plugin-abege-Week_Start_Date_Monday=Monday
Plugin-abege-Week_Start_Date_Tuesday=Tuesday
Plugin-abege-Week_Start_Date_Wednesday=Wednesday
Plugin-abege-Week_Start_Date_Thursday=Thursday
Plugin-abege-Week_Start_Date_Friday=Friday
Plugin-abege-Week_Start_Date_Saturday=Saturday
Plugin-abege-Week_Start_Date_Sunday=Sunday
Plugin-abege-Design_Form_Return_Type=Return Type
Plugin-abege-Design_Form_Return_Type_String=String
Plugin-abege-Design_Form_Return_Type_Date=Date
Plugin-abege-Design_Form_Date_Separator=Date Separator
Plugin-abege-Design_Form_Configuration_Item=Configuration Item

32
src/main/resources/com/eco/plugin/zgtpbxdate/locale/lang_zh_CN.properties

@ -0,0 +1,32 @@
Plugin-abege=Vue\u65E5\u671F\u9009\u62E9\u5668\u63D2\u4EF6
Plugin-abege_Licence_Expired=Vue\u65E5\u671F\u9009\u62E9\u5668\u63D2\u4EF6\u8BB8\u53EF\u8FC7\u671F
Plugin-abege-Date_Format=\u7C7B\u578B/\u683C\u5F0F
Plugin-abege-Date_Format_Year=year
Plugin-abege-Date_Format_Month=month
Plugin-abege-Date_Format_Date=date
Plugin-abege-Date_Format_Dates=dates
Plugin-abege-Date_Format_Week=week
Plugin-abege-Date_Format_DateRange=daterange
Plugin-abege-Date_Format_DateRangeWeek=daterangeweek
Plugin-abege-Date_Format_DateRangeMonth=daterangemonth
Plugin-abege-Date_Format_DateTime=datetime
Plugin-abege-Date_Format_DateTimeRange=datetimerange
Plugin-abege-Design_Form_Date_Type=\u7C7B\u578B/\u683C\u5F0F
Plugin-abege-Date_Type_Date=\u65E5\u671F\u578B
Plugin-abege-Date_Type_DateTime=\u65F6\u95F4\u578B
Plugin-abege-Design_Form_Start_Date=\u5F00\u59CB\u65E5\u671F
Plugin-abege-Design_Form_Show_Date=\u663E\u793A\u683C\u5F0F
Plugin-abege-Design_Form_Return_Format=\u8FD4\u56DE\u683C\u5F0F
Plugin-abege-Design_Form_Week_Start_Date=\u5468\u8D77\u59CB\u65E5
Plugin-abege-Week_Start_Date_Monday=\u5468\u4E00
Plugin-abege-Week_Start_Date_Tuesday=\u5468\u4E8C
Plugin-abege-Week_Start_Date_Wednesday=\u5468\u4E09
Plugin-abege-Week_Start_Date_Thursday=\u5468\u56DB
Plugin-abege-Week_Start_Date_Friday=\u5468\u4E94
Plugin-abege-Week_Start_Date_Saturday=\u5468\u516D
Plugin-abege-Week_Start_Date_Sunday=\u5468\u65E5
Plugin-abege-Design_Form_Return_Type=\u8FD4\u56DE\u7C7B\u578B
Plugin-abege-Design_Form_Return_Type_String=\u5B57\u7B26\u4E32
Plugin-abege-Design_Form_Return_Type_Date=\u65E5\u671F
Plugin-abege-Design_Form_Date_Separator=\u6570\u7EC4\u62FC\u63A5\u7B26
Plugin-abege-Design_Form_Configuration_Item=\u914D\u7F6E\u9879
Loading…
Cancel
Save