Browse Source
* commit '12f6eddb2772daa1e2992c5bc76d1a3cefb1ad96': (147 commits) merge code REPORT-47782 数据集-数据连接-数据集界面的数据连接按钮,鼠标悬浮时的提示不对 【问题原因】数据集查询页面以及服务器数据集页面中的按钮正常状态下没有tooltips,但是UILockButton在初始化的时候会传入一个空字符串,导致会有一个小方格显示出来 【改动思路】把初始化传入的空字符串修改为null,setTooltipsText方法中会判断是否为null,如果是null就会把tooltips隐藏 CHART-18309 框架图面板边框颜色 CHART-18270 点样式图片的宽高增加px单位 CHART-18112 富文本组件新建和刷新后选中最后一个元素 调整富文本组件间距 REPORT-46723 填报智能添加单元格组 遗漏一个判断条件的同步修改 update REPORT-48124 内置缓存插件漏掉了其它提交&方法改个名字 REPORT-46723 填报智能添加单元格组 CHART-18103 调整富文本字体选择组件宽度 CHART-18257 支持组合图的富文本新增字段参数 CHART-18255 富文本默认字段最后一个不需要添加换行 REPORT-47516 远程锁定-集群单节点,两个用户先后进入,数据连接的锁定有问题 【问题原因】主要的原因有两个,一是当时测试同学在集群环境上的操作不当导致了用户lock后,在ClientAliveChecker中的check4EditLock方法报错,然后被认定成脏数据清除了;二是此前userIn和userBeat时存入的是LockItem枚举类对象,相当于常量,那么所有用户beat后存入的对象都是同一个,这个是逻辑问题,并且在集群环境上测试的过程中还发现LockItem对象的序列化有些问题,会报错 【改动思路】①将之前存入的ClientID-LockItem键值对修改为存入ClientID-LockedFile键值对,LockedFile是一个继承了HashSet的类,里面有birth和beat的逻辑,天然实现了序列化接口,是模板锁定那边写的一个类,这边就直接拿来用了;②将EditLock和模板锁定的一些逻辑分离了一下,避免过多耦合;③自己测试的时候还发现数据集查询页下的提示弹窗会出现二级弹窗问题,因此在EditLockUtils中添加了个api用于传入父窗口 CHART-18066 调整富文本编辑器尺寸 CHART-18102 JXBrowser资源请求增加文件类型 REPORT-46915 重命名 单元测试 REPORT-47034 FRM新前端&新自适应合入主JAR 使用内部类代替重复的方法 ...final/10.0
superman
4 years ago
165 changed files with 4543 additions and 1588 deletions
@ -0,0 +1,25 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
|
||||
import com.fr.report.LockItem; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
* 定义数据连接的checker |
||||
*/ |
||||
public class ConnectionLockChangeChecker extends EditLockChangeChecker{ |
||||
|
||||
private static class Holder { |
||||
private static final ConnectionLockChangeChecker INSTANCE = new ConnectionLockChangeChecker(); |
||||
} |
||||
|
||||
public static ConnectionLockChangeChecker getInstance() { |
||||
return ConnectionLockChangeChecker.Holder.INSTANCE; |
||||
} |
||||
|
||||
public ConnectionLockChangeChecker() { |
||||
this.lockItem = LockItem.CONNECTION; |
||||
} |
||||
} |
@ -0,0 +1,85 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.ui.util.UIUtil; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.lock.editlock.EditLockOperator; |
||||
import com.fr.report.LockItem; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.concurrent.Executors; |
||||
import java.util.concurrent.ScheduledExecutorService; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/19 |
||||
* 判断当前设计器在远程设计服务器中的锁状态是否发生了改变 |
||||
*/ |
||||
public abstract class EditLockChangeChecker { |
||||
|
||||
private static final int INTERVAL = 30000; |
||||
private ScheduledExecutorService scheduler; |
||||
protected LockItem lockItem; |
||||
private boolean isLocked = false; |
||||
private List<EditLockChangeListener> listeners = new ArrayList<>(); |
||||
|
||||
/** |
||||
* 轮询任务,如果是远程设计状态,每隔30s查询一次相应lockItem的锁状态是否改变 |
||||
*/ |
||||
public void start() { |
||||
this.scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("EditLockChangeChecker")); |
||||
this.scheduler.scheduleAtFixedRate(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
// 判断是否为远程设计环境
|
||||
if (!WorkContext.getCurrent().isLocal()) { |
||||
try { |
||||
EditLockOperator operator = WorkContext.getCurrent().get(EditLockOperator.class); |
||||
boolean locked = operator.isLocked(lockItem); |
||||
if (isLocked() != locked) { |
||||
setLocked(locked); |
||||
fireChange(); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} else if (isLocked()){ |
||||
// 如果不是远程环境,且此前的远程状态下为锁定的话,切换回来后需要将其修改为不锁定
|
||||
setLocked(false); |
||||
fireChange(); |
||||
} |
||||
} |
||||
}, 0, INTERVAL, TimeUnit.MILLISECONDS); |
||||
} |
||||
|
||||
public void stop() { |
||||
this.scheduler.shutdown(); |
||||
} |
||||
|
||||
public void addEditLockChangeListener(EditLockChangeListener listener) { |
||||
this.listeners.add(listener); |
||||
} |
||||
|
||||
private void fireChange() { |
||||
UIUtil.invokeLaterIfNeeded(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
for (EditLockChangeListener listener : EditLockChangeChecker.this.listeners) { |
||||
listener.updateLockedState(new EditLockChangeEvent(isLocked())); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public boolean isLocked() { |
||||
return this.isLocked; |
||||
} |
||||
|
||||
public void setLocked(boolean locked) { |
||||
this.isLocked = locked; |
||||
} |
||||
} |
@ -0,0 +1,25 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
import java.util.EventObject; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public class EditLockChangeEvent extends EventObject { |
||||
|
||||
private boolean isLocked; |
||||
|
||||
/** |
||||
* @param source 锁状态发生了改变,且当前锁状态就是source |
||||
*/ |
||||
public EditLockChangeEvent(boolean source) { |
||||
super(source); |
||||
this.isLocked = source; |
||||
} |
||||
|
||||
public boolean isLocked() { |
||||
return isLocked; |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
import java.util.EventListener; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public interface EditLockChangeListener extends EventListener { |
||||
/** |
||||
* 锁定状态改变后执行的动作 |
||||
* @param event 事件 |
||||
*/ |
||||
void updateLockedState(EditLockChangeEvent event); |
||||
} |
@ -0,0 +1,87 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.base.svg.SVGLoader; |
||||
import com.fr.design.dialog.FineJOptionPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.lock.editlock.EditLockOperator; |
||||
import com.fr.report.LockItem; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JOptionPane; |
||||
import javax.swing.SwingUtilities; |
||||
import java.awt.Component; |
||||
import java.awt.Image; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
* 关于编辑锁定的一些常量和静态方法 |
||||
*/ |
||||
public class EditLockUtils { |
||||
|
||||
/** |
||||
* 数据连接锁定标志 |
||||
*/ |
||||
public static final Icon CONNECTION_LOCKED_ICON = IconUtils.readIcon("/com/fr/design/images/m_web/connection_locked"); |
||||
|
||||
/** |
||||
* 小锁图片 |
||||
*/ |
||||
public static final @Nullable Image LOCKED_IMAGE = SVGLoader.load("/com/fr/design/images/m_web/locked_normal.svg"); |
||||
|
||||
/** |
||||
* 提示弹窗中的提示标志 |
||||
*/ |
||||
public static final Icon TOOLTIPS_ICON = IOUtils.readIcon("/com/fr/design/images/m_web/warningIcon.png"); |
||||
|
||||
/** |
||||
* 数据连接锁定中 |
||||
*/ |
||||
public static final String CONNECTION_LOCKED_TOOLTIPS = Toolkit.i18nText("Fine_Designer_Remote_Design_Data_Connection_Locked"); |
||||
|
||||
/** |
||||
* 服务器数据集锁定中 |
||||
*/ |
||||
public static final String SERVER_TABLEDATA_LOCKED_TOOLTIPS = Toolkit.i18nText("Fine_Designer_Remote_Design_Server_TableData_Locked"); |
||||
|
||||
/** |
||||
* 提示弹窗中的提示信息 |
||||
*/ |
||||
public static final String LOCKED_MESSAGE = Toolkit.i18nText("Fine_Designer_Remote_Design_Locked_Message"); |
||||
|
||||
/** |
||||
* 提示弹窗中的标题 |
||||
*/ |
||||
public static final String TOOLTIPS = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint"); |
||||
|
||||
/** |
||||
* 已经被锁,跳出弹窗提示 |
||||
*/ |
||||
public static void showLockMessage() { |
||||
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), EditLockUtils.LOCKED_MESSAGE, EditLockUtils.TOOLTIPS, JOptionPane.INFORMATION_MESSAGE, EditLockUtils.TOOLTIPS_ICON); |
||||
} |
||||
|
||||
public static void showLockMessage(Component parentComponent) { |
||||
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(parentComponent), EditLockUtils.LOCKED_MESSAGE, EditLockUtils.TOOLTIPS, JOptionPane.INFORMATION_MESSAGE, EditLockUtils.TOOLTIPS_ICON); |
||||
} |
||||
|
||||
public static boolean lock(LockItem lockItem) { |
||||
return WorkContext.getCurrent().get(EditLockOperator.class).lock(lockItem); |
||||
} |
||||
|
||||
public static boolean unlock(LockItem lockItem) { |
||||
return WorkContext.getCurrent().get(EditLockOperator.class).unlock(lockItem); |
||||
} |
||||
|
||||
public static boolean isLocked(LockItem lockItem) { |
||||
EditLockOperator operator = WorkContext.getCurrent().get(EditLockOperator.class); |
||||
// 启动过程中UILockButton初始化的时候会调用这个方法,但是此时workObjectPool中还没有对象,会报npe
|
||||
return operator != null && operator.isLocked(lockItem); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.fr.design.editlock; |
||||
|
||||
import com.fr.report.LockItem; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
* 服务器数据集的checker |
||||
*/ |
||||
public class ServerTableDataLockChangeChecker extends EditLockChangeChecker{ |
||||
private static class Holder { |
||||
private static final ServerTableDataLockChangeChecker INSTANCE = new ServerTableDataLockChangeChecker(); |
||||
} |
||||
|
||||
public static ServerTableDataLockChangeChecker getInstance() { |
||||
return ServerTableDataLockChangeChecker.Holder.INSTANCE; |
||||
} |
||||
|
||||
public ServerTableDataLockChangeChecker() { |
||||
this.lockItem = LockItem.SERVER_TABLE_DATA; |
||||
} |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
/** |
||||
* 设计器生命周期接口 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/26 |
||||
*/ |
||||
public interface DesignerLifecycleMonitor { |
||||
|
||||
String MARK_STRING = "DesignerLifecycleMonitor"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
/** |
||||
* 设计器启动之前 |
||||
*/ |
||||
void beforeStart(); |
||||
|
||||
/** |
||||
* 设计器启动完成 界面出现之后 |
||||
*/ |
||||
void afterStart(); |
||||
|
||||
/** |
||||
* 设计器关闭退出之前 |
||||
*/ |
||||
void beforeStop(); |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
/** |
||||
* 设计器所有端口获取 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/18 |
||||
*/ |
||||
public interface DesignerPortProvider { |
||||
|
||||
String MARK_STRING = "DesignerPortProvider"; |
||||
|
||||
int CURRENT_LEVEL = 1; |
||||
|
||||
|
||||
/** |
||||
* 设计器自身端口 |
||||
* |
||||
* @return |
||||
*/ |
||||
int messagePort(); |
||||
|
||||
/** |
||||
* 内置服务器端口 |
||||
* |
||||
* @return |
||||
*/ |
||||
int embeddedServerPort(); |
||||
|
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.design.gui.frpane; |
||||
|
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.ispinner.chart.UISpinnerWithPercent; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-01-21 |
||||
*/ |
||||
public class UINumberDragPaneWithPercent extends UINumberDragPane { |
||||
|
||||
public UINumberDragPaneWithPercent(double minValue, double maxValue) { |
||||
super(minValue, maxValue); |
||||
} |
||||
|
||||
public UINumberDragPaneWithPercent(double minValue, double maxValue, double dierta) { |
||||
super(minValue, maxValue, dierta); |
||||
} |
||||
|
||||
protected UISpinner createUISpinner(double minValue, double maxValue, double dierta) { |
||||
return new UISpinnerWithPercent(minValue, maxValue, dierta, minValue); |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
package com.fr.design.gui.ibutton; |
||||
|
||||
import com.fr.design.editlock.EditLockChangeEvent; |
||||
import com.fr.design.editlock.EditLockChangeListener; |
||||
import com.fr.design.editlock.EditLockUtils; |
||||
import com.fr.report.LockItem; |
||||
|
||||
import javax.swing.Icon; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public class UILockButton extends UIButton implements EditLockChangeListener { |
||||
|
||||
/** |
||||
* 锁定状态图标 |
||||
*/ |
||||
private Icon lockedIcon; |
||||
/** |
||||
* 正常状态图标 |
||||
*/ |
||||
private Icon normalIcon; |
||||
/** |
||||
* 锁定状态的提示信息 |
||||
*/ |
||||
private String lockedTooltips; |
||||
/** |
||||
* 正常状态的提示信息 |
||||
*/ |
||||
private String normalTooltips; |
||||
|
||||
public UILockButton(Icon lockedIcon, Icon normalIcon, String lockedTooltips, String normalTooltips) { |
||||
super(); |
||||
this.lockedIcon = lockedIcon; |
||||
this.normalIcon = normalIcon; |
||||
this.lockedTooltips = lockedTooltips; |
||||
this.normalTooltips = normalTooltips; |
||||
init(); |
||||
} |
||||
|
||||
private void init() { |
||||
boolean locked = EditLockUtils.isLocked(LockItem.CONNECTION); |
||||
this.setIcon(locked ? lockedIcon : normalIcon); |
||||
this.setToolTipText(locked ? lockedTooltips : normalTooltips); |
||||
} |
||||
|
||||
@Override |
||||
public void updateLockedState(EditLockChangeEvent event) { |
||||
this.setIcon(event.isLocked() ? lockedIcon : normalIcon); |
||||
this.setToolTipText(event.isLocked() ? lockedTooltips : normalTooltips); |
||||
this.repaint(); |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.gui.imenu; |
||||
|
||||
import com.fr.design.editlock.EditLockChangeEvent; |
||||
import com.fr.design.editlock.EditLockChangeListener; |
||||
import com.fr.report.LockItem; |
||||
|
||||
import javax.swing.Action; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public class UILockMenuItem extends UIMenuItem implements EditLockChangeListener { |
||||
|
||||
/** |
||||
* 锁定状态的提示信息 |
||||
*/ |
||||
private String lockedTooltips; |
||||
/** |
||||
* 正常状态的提示信息 |
||||
*/ |
||||
private String normalTooltips; |
||||
|
||||
/** |
||||
* 当前锁定项 |
||||
*/ |
||||
private LockItem lockItem; |
||||
|
||||
public UILockMenuItem(Action action, String lockedTooltips, String normalTooltips, LockItem lockItem) { |
||||
super(action); |
||||
this.lockedTooltips = lockedTooltips; |
||||
this.normalTooltips = normalTooltips; |
||||
this.lockItem = lockItem; |
||||
setUI(new UILockMenuItemUI()); |
||||
} |
||||
|
||||
public LockItem getLockItem() { |
||||
return lockItem; |
||||
} |
||||
|
||||
@Override |
||||
public void updateLockedState(EditLockChangeEvent event) { |
||||
this.setToolTipText(event.isLocked() ? lockedTooltips : normalTooltips); |
||||
this.repaint(); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.design.gui.imenu; |
||||
|
||||
import com.fr.design.editlock.EditLockUtils; |
||||
|
||||
import javax.swing.JMenuItem; |
||||
import java.awt.Graphics; |
||||
import java.awt.Rectangle; |
||||
|
||||
/** |
||||
* @author Yvan |
||||
* @version 10.0 |
||||
* Created by Yvan on 2021/1/20 |
||||
*/ |
||||
public class UILockMenuItemUI extends UIMenuItemUI{ |
||||
|
||||
@Override |
||||
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { |
||||
super.paintText(g, menuItem, textRect, text); |
||||
// 除了绘制text之外,还需要画一下锁定图标
|
||||
UILockMenuItem lockMenuItem = (UILockMenuItem) menuItem; |
||||
if (EditLockUtils.isLocked(lockMenuItem.getLockItem())) { |
||||
int width = menuItem.getWidth(); |
||||
int height = menuItem.getHeight(); |
||||
g.drawImage(EditLockUtils.LOCKED_IMAGE, (int) Math.round(width * 0.9), (int) Math.round(height * 0.1), 16, 16, null); |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.design.gui.ispinner.chart; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-01-21 |
||||
*/ |
||||
public class UISpinnerWithPercent extends UISpinnerWithUnit { |
||||
|
||||
private static final String UNIT = "%"; |
||||
|
||||
public UISpinnerWithPercent(double minValue, double maxValue, double dierta, double defaultValue) { |
||||
super(minValue, maxValue, dierta, defaultValue, UNIT); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
|
||||
package com.fr.design.gui.ispinner.chart; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-01-21 |
||||
*/ |
||||
public class UISpinnerWithPx extends UISpinnerWithUnit { |
||||
|
||||
private static final String UNIT = "px"; |
||||
|
||||
public UISpinnerWithPx(double defaultValue) { |
||||
this(0, Double.MAX_VALUE, 1, defaultValue); |
||||
} |
||||
|
||||
public UISpinnerWithPx(double minValue, double maxValue, double dierta, double defaultValue) { |
||||
super(minValue, maxValue, dierta, defaultValue, UNIT); |
||||
this.getTextField().canFillNegativeNumber(false); |
||||
} |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.fr.design.gui.ispinner.chart; |
||||
|
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.itextfield.UINumberField; |
||||
import com.fr.design.gui.itextfield.UINumberFieldWithUnit; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-01-20 |
||||
*/ |
||||
public class UISpinnerWithUnit extends UISpinner { |
||||
|
||||
private String unit; |
||||
|
||||
public UISpinnerWithUnit(double minValue, double maxValue, double dierta, double defaultValue, String unit) { |
||||
this.unit = unit; |
||||
init(minValue, maxValue, dierta); |
||||
getTextField().setValue(defaultValue); |
||||
} |
||||
|
||||
@Override |
||||
protected UINumberField initNumberField() { |
||||
return new UINumberFieldWithUnit(3, unit); |
||||
} |
||||
} |
@ -0,0 +1,114 @@
|
||||
package com.fr.design.gui.itextfield; |
||||
|
||||
import com.fr.base.Utils; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.Comparator; |
||||
import java.util.LinkedHashSet; |
||||
import java.util.List; |
||||
import java.util.Set; |
||||
import java.awt.Toolkit; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2021-01-20 |
||||
* 这个控件不会限制输入的数字大小,但是同样不允许输入数字之外的字符 |
||||
*/ |
||||
public class UINumberFieldWithUnit extends UINumberField { |
||||
|
||||
private String unit; |
||||
|
||||
private List<String> unitList = new ArrayList<>(); |
||||
|
||||
public UINumberFieldWithUnit(int columns, String unit) { |
||||
super(columns); |
||||
this.unit = unit; |
||||
initUnitList(); |
||||
} |
||||
|
||||
//对单位的字符进行组合
|
||||
private void initUnitList() { |
||||
char[] chars = unit.toCharArray(); |
||||
Set<String> set = new LinkedHashSet<>(); |
||||
initUnitList(chars, 0, StringUtils.EMPTY, set); |
||||
unitList.addAll(set); |
||||
Collections.sort(unitList, Comparator.comparing(String::length)); |
||||
} |
||||
|
||||
private void initUnitList(char[] chars, int index, String str, Set<String> set) { |
||||
if (index == chars.length) { |
||||
return; |
||||
} |
||||
for (int i = index; i < chars.length; i++) { |
||||
String newStr = str + chars[i]; |
||||
set.add(newStr); |
||||
initUnitList(chars, i + 1, newStr, set); |
||||
} |
||||
} |
||||
|
||||
public void setFieldDocument() { |
||||
setDocument(new NumberDocumentNoLimit()); |
||||
} |
||||
|
||||
public void setValue(double value) { |
||||
this.setText(Utils.doubleToString(value) + unit); |
||||
} |
||||
|
||||
public double getValue() throws NumberFormatException { |
||||
try { |
||||
String text = this.getText(); |
||||
if (StringUtils.isEmpty(text)) { |
||||
return 0; |
||||
} |
||||
|
||||
return Double.parseDouble(text.replace(getEndString(text), StringUtils.EMPTY)); |
||||
} catch (NumberFormatException numberFormatException) { |
||||
return UINumberField.ERROR_VALUE; |
||||
} |
||||
} |
||||
|
||||
private String getEndString(String text) { |
||||
int size = unitList.size(); |
||||
for (int i = size - 1; i >= 0; i--) { |
||||
String unit = unitList.get(i); |
||||
if (text.endsWith(unit)) { |
||||
return unit; |
||||
|
||||
} |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
class NumberDocumentNoLimit extends NumberDocument { |
||||
|
||||
public boolean checkString(int offset, String s, String str) { |
||||
return (ComparatorUtils.equals(s, "F") |
||||
|| ComparatorUtils.equals(s, "f") |
||||
|| ComparatorUtils.equals(s, "D") |
||||
|| ComparatorUtils.equals(s, "d") |
||||
|| (ComparatorUtils.equals(s, ".") && getMaxDecimalLength() == 0)); |
||||
|
||||
} |
||||
|
||||
protected boolean isOverMaxOrMinValue(String strIntPart, String strDecPart, String strNew) { |
||||
return super.isOverMaxOrMinValue(strIntPart, strDecPart, strNew.replaceFirst(getEndString(strNew), StringUtils.EMPTY)); |
||||
} |
||||
|
||||
protected boolean checkNumber(String strValue, boolean isMinus) { |
||||
try { |
||||
if (ComparatorUtils.equals(strValue, StringUtils.EMPTY) || ComparatorUtils.equals(strValue, "-")) { |
||||
return false; |
||||
} |
||||
Double.parseDouble(strValue.replaceFirst(getEndString(strValue), StringUtils.EMPTY)); |
||||
} catch (Exception e) { |
||||
Toolkit.getDefaultToolkit().beep(); |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/29 |
||||
*/ |
||||
public class BbsRegisterMark implements LocaleMark<String> { |
||||
|
||||
private final Map<Locale, String> map = new HashMap<>(); |
||||
private static final String BBS_REGISTER_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.register"); |
||||
private static final String BBS_REGISTER_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.register"); |
||||
private static final String BBS_REGISTER_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US"); |
||||
private static final String BBS_REGISTER_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US"); |
||||
private static final String BBS_REGISTER_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.register.en_US"); |
||||
|
||||
public BbsRegisterMark() { |
||||
map.put(Locale.CHINA, BBS_REGISTER_CN); |
||||
map.put(Locale.KOREA, BBS_REGISTER_KR); |
||||
map.put(Locale.JAPAN, BBS_REGISTER_JP); |
||||
map.put(Locale.US, BBS_REGISTER_EN); |
||||
map.put(Locale.TAIWAN, BBS_REGISTER_TW); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? BBS_REGISTER_EN : result; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/29 |
||||
*/ |
||||
public class BbsResetMark implements LocaleMark<String> { |
||||
|
||||
private final Map<Locale, String> map = new HashMap<>(); |
||||
private static final String BBS_RESET_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset"); |
||||
private static final String BBS_RESET_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.reset"); |
||||
private static final String BBS_RESET_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US"); |
||||
private static final String BBS_RESET_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US"); |
||||
private static final String BBS_RESET_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.reset.en_US"); |
||||
|
||||
public BbsResetMark() { |
||||
map.put(Locale.CHINA, BBS_RESET_CN); |
||||
map.put(Locale.KOREA, BBS_RESET_KR); |
||||
map.put(Locale.JAPAN, BBS_RESET_JP); |
||||
map.put(Locale.US, BBS_RESET_EN); |
||||
map.put(Locale.TAIWAN, BBS_RESET_TW); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? BBS_RESET_EN : result; |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/29 |
||||
*/ |
||||
public class BbsSpaceMark implements LocaleMark<String> { |
||||
|
||||
private final Map<Locale, String> map = new HashMap<>(); |
||||
private static final String BBS_SPACE_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.default"); |
||||
private static final String BBS_SPACE_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.default"); |
||||
private static final String BBS_SPACE_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US"); |
||||
private static final String BBS_SPACE_KR = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US"); |
||||
private static final String BBS_SPACE_JP = CloudCenter.getInstance().acquireUrlByKind("bbs.default.en_US"); |
||||
|
||||
public BbsSpaceMark() { |
||||
map.put(Locale.CHINA, BBS_SPACE_CN); |
||||
map.put(Locale.KOREA, BBS_SPACE_KR); |
||||
map.put(Locale.JAPAN, BBS_SPACE_JP); |
||||
map.put(Locale.US, BBS_SPACE_EN); |
||||
map.put(Locale.TAIWAN, BBS_SPACE_TW); |
||||
} |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
String result = map.get(GeneralContext.getLocale()); |
||||
return result == null ? BBS_SPACE_EN : result; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.monitor; |
||||
|
||||
import com.fr.design.fun.DesignerLifecycleMonitor; |
||||
import com.fr.stable.bridge.StableFactory; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/27 |
||||
*/ |
||||
public class DesignerLifecycleMonitorContext { |
||||
|
||||
private static DesignerLifecycleMonitor monitor; |
||||
|
||||
static { |
||||
DesignerLifecycleMonitor designerLifecycleMonitor = StableFactory.getMarkedInstanceObjectFromClass(DesignerLifecycleMonitor.MARK_STRING, DesignerLifecycleMonitor.class); |
||||
if (designerLifecycleMonitor != null) { |
||||
monitor = designerLifecycleMonitor; |
||||
} else { |
||||
monitor = new EmptyDesignerLifecycleMonitor(); |
||||
} |
||||
} |
||||
|
||||
public static DesignerLifecycleMonitor getMonitor() { |
||||
return monitor; |
||||
} |
||||
|
||||
static class EmptyDesignerLifecycleMonitor implements DesignerLifecycleMonitor { |
||||
|
||||
@Override |
||||
public void beforeStart() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void afterStart() { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void beforeStop() { |
||||
|
||||
} |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.port; |
||||
|
||||
import com.fr.design.fun.DesignerPortProvider; |
||||
import com.fr.stable.bridge.StableFactory; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2021/1/27 |
||||
*/ |
||||
public class DesignerPortContext { |
||||
|
||||
private static int messagePort = -1; |
||||
|
||||
private static int embeddedServerPort = -1; |
||||
|
||||
static { |
||||
DesignerPortProvider designerPortProvider = StableFactory.getMarkedInstanceObjectFromClass(DesignerPortProvider.MARK_STRING, DesignerPortProvider.class); |
||||
if (designerPortProvider != null) { |
||||
messagePort = designerPortProvider.messagePort(); |
||||
embeddedServerPort = designerPortProvider.embeddedServerPort(); |
||||
} |
||||
} |
||||
|
||||
public static int getMessagePort() { |
||||
return messagePort; |
||||
} |
||||
|
||||
public static int getEmbeddedServerPort() { |
||||
return embeddedServerPort; |
||||
} |
||||
} |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 959 B |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,135 @@
|
||||
package com.fr.van.chart.box; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataMaxFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataMedianFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataMinFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataNumberFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataOutlierFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataQ1Format; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDataQ3Format; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; |
||||
import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListener; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class VanChartBoxRichTextDetailedFieldListPane extends VanChartFieldListPane { |
||||
|
||||
private VanChartFieldButton richTextNumber; |
||||
private VanChartFieldButton richTextMax; |
||||
private VanChartFieldButton richTextQ3; |
||||
private VanChartFieldButton richTextMedian; |
||||
private VanChartFieldButton richTextQ1; |
||||
private VanChartFieldButton richTextMin; |
||||
private VanChartFieldButton richTextOutlier; |
||||
|
||||
public VanChartBoxRichTextDetailedFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextMax() { |
||||
return richTextMax; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextQ3() { |
||||
return richTextQ3; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextMedian() { |
||||
return richTextMedian; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextQ1() { |
||||
return richTextQ1; |
||||
} |
||||
|
||||
public VanChartFieldButton getRichTextMin() { |
||||
return richTextMin; |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
VanChartFieldListener listener = getFieldListener(); |
||||
|
||||
setCategoryNameButton(new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), new AttrTooltipCategoryFormat(), listener)); |
||||
setSeriesNameButton(new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), new AttrTooltipSeriesFormat(), listener)); |
||||
|
||||
richTextNumber = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Number"), new AttrTooltipDataNumberFormat(), listener); |
||||
richTextMax = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Max_Value"), new AttrTooltipDataMaxFormat(), listener); |
||||
richTextQ3 = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), new AttrTooltipDataQ3Format(), listener); |
||||
richTextMedian = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Median"), new AttrTooltipDataMedianFormat(), listener); |
||||
richTextQ1 = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), new AttrTooltipDataQ1Format(), listener); |
||||
richTextMin = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Min_Value"), new AttrTooltipDataMinFormat(), listener); |
||||
richTextOutlier = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"), new AttrTooltipDataOutlierFormat(), listener); |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(getCategoryNameButton()); |
||||
fieldPane.add(getSeriesNameButton()); |
||||
fieldPane.add(richTextNumber); |
||||
fieldPane.add(richTextMax); |
||||
fieldPane.add(richTextQ3); |
||||
fieldPane.add(richTextMedian); |
||||
fieldPane.add(richTextQ1); |
||||
fieldPane.add(richTextMin); |
||||
fieldPane.add(richTextOutlier); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> fieldButtonList = new ArrayList<>(); |
||||
|
||||
fieldButtonList.add(getCategoryNameButton()); |
||||
fieldButtonList.add(getSeriesNameButton()); |
||||
fieldButtonList.add(richTextNumber); |
||||
fieldButtonList.add(richTextMax); |
||||
fieldButtonList.add(richTextQ3); |
||||
fieldButtonList.add(richTextMedian); |
||||
fieldButtonList.add(richTextQ1); |
||||
fieldButtonList.add(richTextMin); |
||||
fieldButtonList.add(richTextOutlier); |
||||
|
||||
return fieldButtonList; |
||||
} |
||||
|
||||
public void populateDefaultField(AttrTooltipContent tooltipContent) { |
||||
super.populateDefaultField(tooltipContent); |
||||
|
||||
if (tooltipContent instanceof AttrBoxTooltipContent) { |
||||
AttrBoxTooltipContent box = (AttrBoxTooltipContent) tooltipContent; |
||||
|
||||
populateButtonFormat(richTextNumber, box.getRichTextNumber()); |
||||
populateButtonFormat(richTextMax, box.getRichTextMax()); |
||||
populateButtonFormat(richTextQ3, box.getRichTextQ3()); |
||||
populateButtonFormat(richTextMedian, box.getRichTextMedian()); |
||||
populateButtonFormat(richTextQ1, box.getRichTextQ1()); |
||||
populateButtonFormat(richTextMin, box.getRichTextMin()); |
||||
populateButtonFormat(richTextOutlier, box.getRichTextOutlier()); |
||||
} |
||||
} |
||||
|
||||
public void updateDefaultField(AttrTooltipContent tooltipContent) { |
||||
super.updateDefaultField(tooltipContent); |
||||
|
||||
if (tooltipContent instanceof AttrBoxTooltipContent) { |
||||
AttrBoxTooltipContent box = (AttrBoxTooltipContent) tooltipContent; |
||||
|
||||
updateButtonFormat(richTextNumber, box.getRichTextNumber()); |
||||
updateButtonFormat(richTextMax, box.getRichTextMax()); |
||||
updateButtonFormat(richTextQ3, box.getRichTextQ3()); |
||||
updateButtonFormat(richTextMedian, box.getRichTextMedian()); |
||||
updateButtonFormat(richTextQ1, box.getRichTextQ1()); |
||||
updateButtonFormat(richTextMin, box.getRichTextMin()); |
||||
updateButtonFormat(richTextOutlier, box.getRichTextOutlier()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,41 @@
|
||||
package com.fr.van.chart.box; |
||||
|
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class VanChartBoxRichTextResultFieldListPane extends VanChartBoxRichTextDetailedFieldListPane { |
||||
|
||||
public VanChartBoxRichTextResultFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(getCategoryNameButton()); |
||||
fieldPane.add(getSeriesNameButton()); |
||||
fieldPane.add(getRichTextMax()); |
||||
fieldPane.add(getRichTextQ3()); |
||||
fieldPane.add(getRichTextMedian()); |
||||
fieldPane.add(getRichTextQ1()); |
||||
fieldPane.add(getRichTextMin()); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> fieldButtonList = new ArrayList<>(); |
||||
|
||||
fieldButtonList.add(getCategoryNameButton()); |
||||
fieldButtonList.add(getSeriesNameButton()); |
||||
fieldButtonList.add(getRichTextMax()); |
||||
fieldButtonList.add(getRichTextQ3()); |
||||
fieldButtonList.add(getRichTextMedian()); |
||||
fieldButtonList.add(getRichTextQ1()); |
||||
fieldButtonList.add(getRichTextMin()); |
||||
|
||||
return fieldButtonList; |
||||
} |
||||
} |
@ -1,191 +0,0 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.concurrent.NamedThreadFactory; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipRichText; |
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSValue; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; |
||||
|
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
public class VanChartRichEditorPane { |
||||
|
||||
private static final String namespace = "Pool"; |
||||
private static final String variable = "data"; |
||||
private static final String richEditorPath = "/com/fr/design/editor/rich_editor.html"; |
||||
private static final String expression = "dispatch()"; |
||||
|
||||
private static ModernUIPane<RichEditorModel> richEditorPane; |
||||
private static Browser browser; |
||||
|
||||
public static void initRichEditorPane() { |
||||
ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("VanChartRichEditor")); |
||||
|
||||
try { |
||||
singleThreadExecutor.submit(new Runnable() { |
||||
@Override |
||||
public void run() { |
||||
try { |
||||
richEditorPane = initPane(new RichEditorModel()); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
}); |
||||
} finally { |
||||
singleThreadExecutor.shutdown(); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<RichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) { |
||||
RichEditorModel model = getRichEditorModel(richEditor); |
||||
|
||||
if (richEditorPane == null) { |
||||
richEditorPane = initPane(model); |
||||
} else if (browser != null) { |
||||
updatePane(browser, model); |
||||
} |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
public static ModernUIPane<RichEditorModel> initPane(RichEditorModel model) { |
||||
return new ModernUIPane.Builder<RichEditorModel>() |
||||
.prepare(new ScriptContextAdapter() { |
||||
public void onScriptContextCreated(ScriptContextEvent event) { |
||||
browser = event.getBrowser(); |
||||
browser.getCacheStorage().clearCache(); |
||||
|
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); |
||||
browser.executeJavaScript(generateTransformI18nJS()); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); |
||||
|
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); |
||||
ns.asObject().setProperty(variable, model); |
||||
} |
||||
}) |
||||
.withEMB(richEditorPath) |
||||
.namespace(namespace).build(); |
||||
} |
||||
|
||||
public static void updatePane(Browser browser, RichEditorModel model) { |
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); |
||||
ns.asObject().setProperty(variable, model); |
||||
browser.executeJavaScript("window." + namespace + "." + expression); |
||||
} |
||||
|
||||
public static RichEditorModel getRichEditorModel(AttrTooltipRichText richText) { |
||||
Map<String, String> paramsMap = richText.getParams(); |
||||
StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); |
||||
|
||||
if (paramsMap != null) { |
||||
for (Map.Entry<String, String> entry : paramsMap.entrySet()) { |
||||
paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); |
||||
paramsStr.append("-"); |
||||
} |
||||
} |
||||
|
||||
int len = paramsStr.length(); |
||||
|
||||
if (len > 0) { |
||||
paramsStr.deleteCharAt(len - 1); |
||||
} |
||||
|
||||
String content = richText.getContent(); |
||||
String initParams = StringUtils.EMPTY; |
||||
String align = StringUtils.EMPTY; |
||||
|
||||
if (content.contains("data-id") && !content.contains("class")) { |
||||
initParams = richText.getInitParamsContent(); |
||||
|
||||
String left = TextAlign.LEFT.getAlign(); |
||||
String center = TextAlign.CENTER.getAlign(); |
||||
|
||||
align = content.contains(left) ? left : center; |
||||
} |
||||
|
||||
return new RichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); |
||||
} |
||||
|
||||
public static String generateTransformI18nJS() { |
||||
String language = "zh_CN"; |
||||
|
||||
Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); |
||||
|
||||
if (locale != null) { |
||||
language = locale.toString(); |
||||
} |
||||
|
||||
return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; |
||||
} |
||||
|
||||
public static class RichEditorModel { |
||||
private String content = StringUtils.EMPTY; |
||||
private boolean auto = true; |
||||
private String params = StringUtils.EMPTY; |
||||
private String initParams = StringUtils.EMPTY; |
||||
private String align = TextAlign.LEFT.getAlign(); |
||||
|
||||
public RichEditorModel() { |
||||
} |
||||
|
||||
public RichEditorModel(String content, boolean auto, String params, String initParams, String align) { |
||||
this.content = content; |
||||
this.auto = auto; |
||||
this.params = params; |
||||
this.initParams = initParams; |
||||
this.align = align; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public boolean isAuto() { |
||||
return auto; |
||||
} |
||||
|
||||
public void setAuto(boolean auto) { |
||||
this.auto = auto; |
||||
} |
||||
|
||||
public String getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(String params) { |
||||
this.params = params; |
||||
} |
||||
|
||||
public String getInitParams() { |
||||
return initParams; |
||||
} |
||||
|
||||
public void setInitParams(String initParams) { |
||||
this.initParams = initParams; |
||||
} |
||||
|
||||
public String getAlign() { |
||||
return align; |
||||
} |
||||
|
||||
public void setAlign(String align) { |
||||
this.align = align; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,103 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.style.FormatPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; |
||||
import com.fr.plugin.chart.base.format.IntervalTimeFormat; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.Format; |
||||
|
||||
public class VanChartFieldAttrPane extends JPanel { |
||||
|
||||
private FormatPane fieldFormatPane; |
||||
private UIComboBox intervalTimeBox; |
||||
private CalculateComboBox dataFunctionBox; |
||||
|
||||
private JPanel formatPane; |
||||
private JPanel intervalTimePane; |
||||
private JPanel fieldFunctionPane; |
||||
|
||||
public VanChartFieldAttrPane() { |
||||
initComponents(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(formatPane, BorderLayout.NORTH); |
||||
this.add(fieldFunctionPane, BorderLayout.CENTER); |
||||
this.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
double p = TableLayout.PREFERRED; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
fieldFormatPane = new FormatPaneWithOutFont() { |
||||
protected JPanel createContentPane(Component[][] components) { |
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p, p}, new double[]{d, e}); |
||||
} |
||||
}; |
||||
intervalTimeBox = new UIComboBox(IntervalTimeFormat.getFormats()); |
||||
dataFunctionBox = new CalculateComboBox(); |
||||
|
||||
Component[][] intervalTimeComponents = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), intervalTimeBox} |
||||
}; |
||||
Component[][] dataFunctionComponents = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), dataFunctionBox} |
||||
}; |
||||
|
||||
intervalTimePane = TableLayout4VanChartHelper.createGapTableLayoutPane(intervalTimeComponents, new double[]{p, p}, new double[]{d, e}); |
||||
|
||||
formatPane = new JPanel(new BorderLayout()); |
||||
formatPane.add(fieldFormatPane, BorderLayout.NORTH); |
||||
formatPane.add(intervalTimePane, BorderLayout.CENTER); |
||||
|
||||
fieldFunctionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(dataFunctionComponents, new double[]{p, p}, new double[]{d, e}); |
||||
} |
||||
|
||||
public void registerFormatListener(UIObserverListener listener) { |
||||
fieldFormatPane.registerChangeListener(listener); |
||||
intervalTimeBox.registerChangeListener(listener); |
||||
} |
||||
|
||||
public void registerFunctionListener(ActionListener listener) { |
||||
dataFunctionBox.addActionListener(listener); |
||||
} |
||||
|
||||
public void populate(Format format, IntervalTimeFormat intervalTime, AbstractDataFunction dataFunction, boolean showDataFunction, boolean showIntervalTime) { |
||||
fieldFormatPane.populateBean(format); |
||||
intervalTimeBox.setSelectedItem(intervalTime); |
||||
dataFunctionBox.populateBean(dataFunction); |
||||
|
||||
fieldFormatPane.setVisible(!showIntervalTime); |
||||
intervalTimePane.setVisible(showIntervalTime); |
||||
fieldFunctionPane.setVisible(showDataFunction); |
||||
} |
||||
|
||||
public Format updateFormat() { |
||||
return fieldFormatPane.update(); |
||||
} |
||||
|
||||
public IntervalTimeFormat updateIntervalTime() { |
||||
return (IntervalTimeFormat) intervalTimeBox.getSelectedItem(); |
||||
} |
||||
|
||||
public AbstractDataFunction updateDataFunction() { |
||||
return dataFunctionBox.updateBean(); |
||||
} |
||||
} |
@ -0,0 +1,202 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.data.util.function.DataFunction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIButtonUI; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.utils.gui.GUIPaintUtils; |
||||
import com.fr.plugin.chart.base.FirstFunction; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
||||
import com.fr.plugin.chart.base.format.IntervalTimeFormat; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.plaf.ButtonUI; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.text.Format; |
||||
|
||||
public class VanChartFieldButton extends JPanel { |
||||
|
||||
private static final Icon ADD_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"); |
||||
private static final Color HOVER_COLOR = new Color(232, 232, 232); |
||||
|
||||
private static final int W = 200; |
||||
private static final int H = 24; |
||||
|
||||
private final String fieldName; |
||||
private final String fieldId; |
||||
|
||||
private final AttrTooltipFormat tooltipFormat; |
||||
private final boolean showDataFunction; |
||||
private final boolean showIntervalTime; |
||||
|
||||
private UIToggleButton fieldButton; |
||||
private UIButton addButton; |
||||
|
||||
private DataFunction dataFunction = new FirstFunction(); |
||||
|
||||
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, VanChartFieldListener listener) { |
||||
this(fieldName, format, false, false, listener); |
||||
} |
||||
|
||||
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, boolean showDataFunction, VanChartFieldListener listener) { |
||||
this(fieldName, format, showDataFunction, false, listener); |
||||
} |
||||
|
||||
public VanChartFieldButton(String fieldName, AttrTooltipFormat format, boolean showDataFunction, boolean showIntervalTime, VanChartFieldListener listener) { |
||||
this.fieldName = fieldName; |
||||
this.tooltipFormat = format; |
||||
|
||||
this.showDataFunction = showDataFunction; |
||||
this.showIntervalTime = showIntervalTime; |
||||
|
||||
this.fieldId = format == null ? StringUtils.EMPTY : format.getFormatJSONKey(); |
||||
|
||||
initComponents(fieldName, listener); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(getContentPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
public String getFieldName() { |
||||
return fieldName; |
||||
} |
||||
|
||||
public boolean isEnable() { |
||||
return this.tooltipFormat.isEnable(); |
||||
} |
||||
|
||||
public void setEnable(boolean enable) { |
||||
this.tooltipFormat.setEnable(enable); |
||||
} |
||||
|
||||
public Format getFormat() { |
||||
return tooltipFormat.getFormat(); |
||||
} |
||||
|
||||
public void setFormat(Format format) { |
||||
this.tooltipFormat.setFormat(format); |
||||
} |
||||
|
||||
public IntervalTimeFormat getIntervalTimeFormat() { |
||||
if (tooltipFormat instanceof AttrTooltipDurationFormat) { |
||||
return ((AttrTooltipDurationFormat) tooltipFormat).getIntervalTimeFormat(); |
||||
} |
||||
|
||||
return IntervalTimeFormat.DAY; |
||||
} |
||||
|
||||
public void setIntervalTimeFormat(IntervalTimeFormat intervalTime) { |
||||
if (tooltipFormat instanceof AttrTooltipDurationFormat) { |
||||
((AttrTooltipDurationFormat) tooltipFormat).setIntervalTimeFormat(intervalTime); |
||||
} |
||||
} |
||||
|
||||
public DataFunction getDataFunction() { |
||||
return dataFunction; |
||||
} |
||||
|
||||
public void setDataFunction(DataFunction dataFunction) { |
||||
this.dataFunction = dataFunction; |
||||
} |
||||
|
||||
public boolean isShowDataFunction() { |
||||
return showDataFunction; |
||||
} |
||||
|
||||
public boolean isShowIntervalTime() { |
||||
return showIntervalTime; |
||||
} |
||||
|
||||
public String getFormatJs() { |
||||
return this.tooltipFormat.getJs(); |
||||
} |
||||
|
||||
private void initComponents(String fieldName, VanChartFieldListener listener) { |
||||
fieldButton = new UIToggleButton(fieldName) { |
||||
|
||||
protected MouseListener getMouseListener() { |
||||
|
||||
return new MouseAdapter() { |
||||
public void mousePressed(MouseEvent e) { |
||||
setSelected(true); |
||||
|
||||
listener.refreshSelectedPane(fieldName); |
||||
listener.setGlobalName(fieldName); |
||||
listener.populateFieldFormatPane(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public ButtonUI getUI() { |
||||
return new FieldButtonUI(); |
||||
} |
||||
}; |
||||
|
||||
addButton = new UIButton(ADD_ICON) { |
||||
public ButtonUI getUI() { |
||||
return new FieldButtonUI(); |
||||
} |
||||
}; |
||||
|
||||
addButton.addMouseListener(new MouseAdapter() { |
||||
|
||||
public void mousePressed(MouseEvent e) { |
||||
super.mousePressed(e); |
||||
|
||||
listener.addSelectedField(fieldName, fieldId); |
||||
} |
||||
}); |
||||
|
||||
fieldButton.setBorderPaintedOnlyWhenPressed(true); |
||||
addButton.setBorderPaintedOnlyWhenPressed(true); |
||||
} |
||||
|
||||
private JPanel getContentPane() { |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{fieldButton, addButton} |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
|
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {e, d}; |
||||
|
||||
JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 3, 0); |
||||
content.setPreferredSize(new Dimension(W, H)); |
||||
|
||||
return content; |
||||
} |
||||
|
||||
public void setSelectedState(boolean selected) { |
||||
fieldButton.setSelected(selected); |
||||
} |
||||
|
||||
private static class FieldButtonUI extends UIButtonUI { |
||||
|
||||
protected void doExtraPainting(UIButton b, Graphics2D g2d, int w, int h, String selectedRoles) { |
||||
if (isPressed(b) && b.isPressedPainted()) { |
||||
GUIPaintUtils.fillPressed(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles)); |
||||
} else if (isRollOver(b)) { |
||||
GUIPaintUtils.fillRollOver(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted(), HOVER_COLOR); |
||||
} else if (b.isNormalPainted()) { |
||||
GUIPaintUtils.fillNormal(g2d, 0, 0, w, h, b.isRoundBorder(), b.getRectDirection(), b.isDoneAuthorityEdited(selectedRoles), b.isPressedPainted()); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,400 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.data.util.function.AbstractDataFunction; |
||||
import com.fr.data.util.function.DataFunction; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.plugin.chart.base.TableFieldCollection; |
||||
import com.fr.plugin.chart.base.TableFieldDefinition; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFieldFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; |
||||
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; |
||||
import com.fr.plugin.chart.base.format.IntervalTimeFormat; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
import java.awt.GridLayout; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.text.Format; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public class VanChartFieldListPane extends JPanel { |
||||
|
||||
private static final int FIELD_ADD_W = 400; |
||||
private static final int FIELD_ADD_H = 28; |
||||
|
||||
private VanChartFieldButton categoryNameButton; |
||||
private VanChartFieldButton seriesNameButton; |
||||
private VanChartFieldButton valueButton; |
||||
private VanChartFieldButton percentButton; |
||||
|
||||
private VanChartFieldAttrPane fieldAttrPane; |
||||
private ModernUIPane<VanChartRichEditorModel> richEditorPane; |
||||
private List<String> tableFieldNameList; |
||||
private List<VanChartFieldButton> tableFieldButtonList = new ArrayList<>(); |
||||
private TableFieldCollection tableFieldCollection = new TableFieldCollection(); |
||||
|
||||
private VanChartFieldListener fieldListener; |
||||
|
||||
public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
|
||||
List<String> richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); |
||||
|
||||
this.tableFieldNameList = (!supportAddField() || richEditorFieldNames == null) ? new ArrayList<>() : richEditorFieldNames; |
||||
|
||||
this.fieldAttrPane = fieldAttrPane; |
||||
this.richEditorPane = richEditorPane; |
||||
|
||||
initFieldListListener(); |
||||
initDefaultFieldButton(); |
||||
|
||||
registerAttrListener(); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
this.add(createDefaultFieldPane(), BorderLayout.CENTER); |
||||
this.add(createTableFieldPane(), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
public VanChartFieldButton getCategoryNameButton() { |
||||
return categoryNameButton; |
||||
} |
||||
|
||||
public void setCategoryNameButton(VanChartFieldButton categoryNameButton) { |
||||
this.categoryNameButton = categoryNameButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getSeriesNameButton() { |
||||
return seriesNameButton; |
||||
} |
||||
|
||||
public void setSeriesNameButton(VanChartFieldButton seriesNameButton) { |
||||
this.seriesNameButton = seriesNameButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getValueButton() { |
||||
return valueButton; |
||||
} |
||||
|
||||
public void setValueButton(VanChartFieldButton valueButton) { |
||||
this.valueButton = valueButton; |
||||
} |
||||
|
||||
public VanChartFieldButton getPercentButton() { |
||||
return percentButton; |
||||
} |
||||
|
||||
public void setPercentButton(VanChartFieldButton percentButton) { |
||||
this.percentButton = percentButton; |
||||
} |
||||
|
||||
public VanChartFieldListener getFieldListener() { |
||||
return fieldListener; |
||||
} |
||||
|
||||
private JPanel createDefaultFieldPane() { |
||||
JPanel fieldPane = new JPanel(); |
||||
|
||||
fieldPane.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
addDefaultFieldButton(fieldPane); |
||||
|
||||
fieldPane.setPreferredSize(new Dimension(FIELD_ADD_W, getDefaultFieldButtonList().size() * FIELD_ADD_H)); |
||||
fieldPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 0)); |
||||
|
||||
return fieldPane; |
||||
} |
||||
|
||||
protected void initDefaultFieldButton() { |
||||
categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), |
||||
new AttrTooltipCategoryFormat(), false, fieldListener); |
||||
|
||||
seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), |
||||
new AttrTooltipSeriesFormat(), false, fieldListener); |
||||
|
||||
valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), |
||||
new AttrTooltipValueFormat(), false, fieldListener); |
||||
|
||||
percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), |
||||
new AttrTooltipPercentFormat(), false, fieldListener); |
||||
} |
||||
|
||||
protected boolean supportAddField() { |
||||
return true; |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(categoryNameButton); |
||||
fieldPane.add(seriesNameButton); |
||||
fieldPane.add(valueButton); |
||||
fieldPane.add(percentButton); |
||||
} |
||||
|
||||
private JPanel createTableFieldPane() { |
||||
if (tableFieldNameList == null || tableFieldNameList.isEmpty()) { |
||||
return new JPanel(); |
||||
} |
||||
|
||||
JPanel tableField = new JPanel(); |
||||
|
||||
tableField.setLayout(new GridLayout(0, 1, 1, 0)); |
||||
|
||||
for (String name : tableFieldNameList) { |
||||
VanChartFieldButton fieldButton = new VanChartFieldButton(name, new AttrTooltipFieldFormat(name), true, fieldListener); |
||||
|
||||
tableField.add(fieldButton); |
||||
tableFieldButtonList.add(fieldButton); |
||||
} |
||||
|
||||
tableField.setPreferredSize(new Dimension(FIELD_ADD_W, tableFieldNameList.size() * FIELD_ADD_H)); |
||||
|
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap(Toolkit.i18nText("Fine-Design_Report_Table_Field"), tableField); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = new ArrayList<>(); |
||||
|
||||
defaultFieldButtonList.add(categoryNameButton); |
||||
defaultFieldButtonList.add(seriesNameButton); |
||||
defaultFieldButtonList.add(valueButton); |
||||
defaultFieldButtonList.add(percentButton); |
||||
|
||||
return defaultFieldButtonList; |
||||
} |
||||
|
||||
private void initFieldListListener() { |
||||
|
||||
fieldListener = new VanChartFieldListener() { |
||||
|
||||
private String fieldName; |
||||
|
||||
public void setGlobalName(String fieldName) { |
||||
this.fieldName = fieldName; |
||||
} |
||||
|
||||
public String getGlobalName() { |
||||
return this.fieldName; |
||||
} |
||||
|
||||
public VanChartFieldButton getSelectedField() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
for (VanChartFieldButton fieldButton : defaultFieldButtonList) { |
||||
if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { |
||||
return fieldButton; |
||||
} |
||||
} |
||||
|
||||
for (VanChartFieldButton fieldButton : tableFieldButtonList) { |
||||
if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { |
||||
return fieldButton; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public void refreshSelectedPane(String fieldName) { |
||||
if (ComparatorUtils.equals(fieldName, this.fieldName)) { |
||||
return; |
||||
} |
||||
|
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
for (VanChartFieldButton fieldButton : defaultFieldButtonList) { |
||||
fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); |
||||
} |
||||
|
||||
for (VanChartFieldButton fieldButton : tableFieldButtonList) { |
||||
fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); |
||||
} |
||||
} |
||||
|
||||
public void addSelectedField(String fieldName, String fieldId) { |
||||
VanChartRichEditorModel model = richEditorPane.update(); |
||||
model.setAddition(fieldName); |
||||
VanChartRichEditorPane.richEditorAddField(model); |
||||
|
||||
if (tableFieldNameList.contains(fieldName)) { |
||||
int index = tableFieldNameList.indexOf(fieldName); |
||||
|
||||
VanChartFieldButton fieldButton = tableFieldButtonList.get(index); |
||||
Format fieldFormat = fieldButton.getFormat(); |
||||
DataFunction dataFunction = fieldButton.getDataFunction(); |
||||
|
||||
tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
|
||||
public void populateFieldFormatPane() { |
||||
VanChartFieldButton fieldButton = this.getSelectedField(); |
||||
|
||||
if (fieldButton == null) { |
||||
return; |
||||
} |
||||
|
||||
Format format = fieldButton.getFormat(); |
||||
IntervalTimeFormat intervalTime = fieldButton.getIntervalTimeFormat(); |
||||
AbstractDataFunction dataFunction = (AbstractDataFunction) fieldButton.getDataFunction(); |
||||
|
||||
boolean showDataFunction = fieldButton.isShowDataFunction(); |
||||
boolean showIntervalTime = fieldButton.isShowIntervalTime(); |
||||
|
||||
fieldAttrPane.populate(format, intervalTime, dataFunction, showDataFunction, showIntervalTime); |
||||
} |
||||
|
||||
public void updateFieldFormatPane() { |
||||
VanChartFieldButton fieldButton = this.getSelectedField(); |
||||
|
||||
if (fieldButton == null) { |
||||
return; |
||||
} |
||||
|
||||
fieldButton.setFormat(fieldAttrPane.updateFormat()); |
||||
fieldButton.setIntervalTimeFormat(fieldAttrPane.updateIntervalTime()); |
||||
fieldButton.setDataFunction(fieldAttrPane.updateDataFunction()); |
||||
|
||||
if (tableFieldNameList.contains(fieldName)) { |
||||
Format fieldFormat = fieldButton.getFormat(); |
||||
DataFunction dataFunction = fieldButton.getDataFunction(); |
||||
|
||||
tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
private void registerAttrListener() { |
||||
|
||||
fieldAttrPane.registerFunctionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
fieldListener.updateFieldFormatPane(); |
||||
} |
||||
}); |
||||
|
||||
fieldAttrPane.registerFormatListener(new UIObserverListener() { |
||||
public void doChange() { |
||||
fieldListener.updateFieldFormatPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkFieldListSelected() { |
||||
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); |
||||
|
||||
if (defaultFieldButtonList != null && defaultFieldButtonList.size() > 0) { |
||||
String selected = defaultFieldButtonList.get(0).getFieldName(); |
||||
|
||||
fieldListener.refreshSelectedPane(selected); |
||||
fieldListener.setGlobalName(selected); |
||||
fieldListener.populateFieldFormatPane(); |
||||
} |
||||
} |
||||
|
||||
public void populate(AttrTooltipContent tooltipContent) { |
||||
populateDefaultField(tooltipContent); |
||||
populateTableField(tooltipContent); |
||||
|
||||
// 初次打开富文本界面选中第一个
|
||||
checkFieldListSelected(); |
||||
} |
||||
|
||||
public void populateDefaultField(AttrTooltipContent tooltipContent) { |
||||
populateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); |
||||
populateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); |
||||
populateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); |
||||
populateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); |
||||
} |
||||
|
||||
public void populateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { |
||||
if (button == null || format == null) { |
||||
return; |
||||
} |
||||
|
||||
button.setEnable(format.isEnable()); |
||||
button.setFormat(format.getFormat()); |
||||
|
||||
if (button.isShowIntervalTime() && format instanceof AttrTooltipDurationFormat) { |
||||
button.setIntervalTimeFormat(((AttrTooltipDurationFormat) format).getIntervalTimeFormat()); |
||||
} |
||||
} |
||||
|
||||
public void populateTableField(AttrTooltipContent tooltipContent) { |
||||
TableFieldCollection fieldCollection = tooltipContent.getFieldCollection(); |
||||
|
||||
if (fieldCollection == null) { |
||||
return; |
||||
} |
||||
|
||||
Map<String, TableFieldDefinition> fieldDefinitionGroup = fieldCollection.getFieldNameFormulaMap(); |
||||
|
||||
if (fieldDefinitionGroup == null || fieldDefinitionGroup.isEmpty()) { |
||||
return; |
||||
} |
||||
|
||||
this.tableFieldCollection = new TableFieldCollection(); |
||||
|
||||
for (int i = 0, len = tableFieldNameList.size(); i < len; i++) { |
||||
String fieldName = tableFieldNameList.get(i); |
||||
VanChartFieldButton fieldButton = tableFieldButtonList.get(i); |
||||
TableFieldDefinition fieldDefinition = fieldDefinitionGroup.get(fieldName); |
||||
|
||||
if (fieldDefinitionGroup.containsKey(fieldName)) { |
||||
Format fieldFormat = fieldDefinition.getFormat(); |
||||
DataFunction dataFunction = fieldDefinition.getDataFunction(); |
||||
|
||||
fieldButton.setFormat(fieldFormat); |
||||
fieldButton.setDataFunction(dataFunction); |
||||
|
||||
this.tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void update(AttrTooltipContent tooltipContent) { |
||||
updateDefaultField(tooltipContent); |
||||
updateTableField(tooltipContent); |
||||
} |
||||
|
||||
public void updateDefaultField(AttrTooltipContent tooltipContent) { |
||||
updateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); |
||||
updateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); |
||||
updateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); |
||||
updateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); |
||||
} |
||||
|
||||
public void updateTableField(AttrTooltipContent tooltipContent) { |
||||
try { |
||||
tooltipContent.setFieldCollection(this.tableFieldCollection); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public void updateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { |
||||
if (button == null || format == null) { |
||||
return; |
||||
} |
||||
|
||||
format.setEnable(button.isEnable()); |
||||
format.setFormat(button.getFormat()); |
||||
|
||||
if (button.isShowIntervalTime() && format instanceof AttrTooltipDurationFormat) { |
||||
((AttrTooltipDurationFormat) format).setIntervalTimeFormat(button.getIntervalTimeFormat()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,17 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.event.GlobalNameListener; |
||||
|
||||
public interface VanChartFieldListener extends GlobalNameListener { |
||||
|
||||
public VanChartFieldButton getSelectedField(); |
||||
|
||||
public void refreshSelectedPane(String fieldName); |
||||
|
||||
public void addSelectedField(String fieldName, String fieldId); |
||||
|
||||
public void populateFieldFormatPane(); |
||||
|
||||
public void updateFieldFormatPane(); |
||||
|
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
public class VanChartRichEditorModel { |
||||
|
||||
private String content = StringUtils.EMPTY; |
||||
private boolean auto = true; |
||||
private String params = StringUtils.EMPTY; |
||||
private String initParams = StringUtils.EMPTY; |
||||
private String align = TextAlign.LEFT.getAlign(); |
||||
private String addition = StringUtils.EMPTY; |
||||
|
||||
public VanChartRichEditorModel() { |
||||
} |
||||
|
||||
public VanChartRichEditorModel(String content, boolean auto, String params, String initParams, String align) { |
||||
this.content = content; |
||||
this.auto = auto; |
||||
this.params = params; |
||||
this.initParams = initParams; |
||||
this.align = align; |
||||
this.addition = StringUtils.EMPTY; |
||||
} |
||||
|
||||
public String getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(String content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
public boolean isAuto() { |
||||
return auto; |
||||
} |
||||
|
||||
public void setAuto(boolean auto) { |
||||
this.auto = auto; |
||||
} |
||||
|
||||
public String getParams() { |
||||
return params; |
||||
} |
||||
|
||||
public void setParams(String params) { |
||||
this.params = params; |
||||
} |
||||
|
||||
public String getInitParams() { |
||||
return initParams; |
||||
} |
||||
|
||||
public void setInitParams(String initParams) { |
||||
this.initParams = initParams; |
||||
} |
||||
|
||||
public String getAlign() { |
||||
return align; |
||||
} |
||||
|
||||
public void setAlign(String align) { |
||||
this.align = align; |
||||
} |
||||
|
||||
public String getAddition() { |
||||
return addition; |
||||
} |
||||
|
||||
public void setAddition(String addition) { |
||||
this.addition = addition; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,232 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.Plot; |
||||
import com.fr.chart.chartdata.MoreNameCDDefinition; |
||||
import com.fr.chart.chartdata.OneValueCDDefinition; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.impl.EmbeddedTableData; |
||||
import com.fr.design.DesignModelAdapter; |
||||
import com.fr.design.DesignerEnvManager; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.base.AttrTooltipRichText; |
||||
import com.fr.plugin.chart.custom.CustomDefinition; |
||||
import com.fr.plugin.chart.custom.type.CustomPlotType; |
||||
import com.fr.plugin.chart.type.TextAlign; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.PlotFactory; |
||||
import com.teamdev.jxbrowser.chromium.Browser; |
||||
import com.teamdev.jxbrowser.chromium.JSValue; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; |
||||
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; |
||||
|
||||
import java.util.List; |
||||
import java.util.Locale; |
||||
import java.util.Map; |
||||
|
||||
public class VanChartRichEditorPane { |
||||
|
||||
private static final String PARAMS_SPLITTER = "|"; |
||||
|
||||
private static final String NAME_SPACE = "Pool"; |
||||
private static final String VARIABLE = "data"; |
||||
|
||||
private static final String RICH_EDITOR_HTML = "/com/fr/design/editor/rich_editor.html"; |
||||
|
||||
private static final String REFRESH = "refresh()"; |
||||
private static final String ADD_FIELD = "addField()"; |
||||
|
||||
private static ModernUIPane<VanChartRichEditorModel> richEditorPane; |
||||
private static Browser browser; |
||||
private static List<String> fieldNames; |
||||
|
||||
public static List<String> getFieldNames() { |
||||
return fieldNames; |
||||
} |
||||
|
||||
// 更新普通图表中指定plot的数据集字段
|
||||
public static void refreshCommonChartFieldNames(Chart chart) { |
||||
if (chart == null) { |
||||
return; |
||||
} |
||||
|
||||
Plot plot = chart.getPlot(); |
||||
|
||||
if (plot == null) { |
||||
return; |
||||
} |
||||
|
||||
VanChartRichEditorPane.fieldNames = null; |
||||
|
||||
if (!PlotFactory.plotSupportAddTableField(plot)) { |
||||
return; |
||||
} |
||||
|
||||
TopDefinitionProvider definition = chart.getFilterDefinition(); |
||||
VanChartRichEditorPane.refreshFieldNames(definition); |
||||
} |
||||
|
||||
// 更新组合图表中指定plot的数据集字段
|
||||
public static void refreshCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) { |
||||
if (chart == null || plotType == null) { |
||||
return; |
||||
} |
||||
|
||||
VanChartRichEditorPane.fieldNames = null; |
||||
TopDefinitionProvider filterDefinition = chart.getFilterDefinition(); |
||||
|
||||
if (filterDefinition instanceof CustomDefinition) { |
||||
CustomDefinition customDefinition = (CustomDefinition) filterDefinition; |
||||
Map<CustomPlotType, TopDefinitionProvider> definitionProviderMap = customDefinition.getDefinitionProviderMap(); |
||||
VanChartRichEditorPane.refreshFieldNames(definitionProviderMap.get(plotType)); |
||||
} |
||||
} |
||||
|
||||
// 更新富文本数据集字段
|
||||
public static void refreshFieldNames(TopDefinitionProvider definition) { |
||||
if (definition == null) { |
||||
return; |
||||
} |
||||
|
||||
DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); |
||||
TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); |
||||
|
||||
TableData tableData = null; |
||||
|
||||
if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { |
||||
OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; |
||||
tableData = oneValueCDDefinition.getTableData(); |
||||
} |
||||
|
||||
if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { |
||||
MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; |
||||
tableData = moreNameCDDefinition.getTableData(); |
||||
} |
||||
|
||||
if (tableData == null) { |
||||
return; |
||||
} |
||||
|
||||
try { |
||||
EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource, |
||||
tableData, TableData.RESULT_NOT_NEED, false); |
||||
|
||||
List<String> fieldNames = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); |
||||
VanChartRichEditorPane.fieldNames = fieldNames; |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(AttrTooltipRichText richEditor) { |
||||
VanChartRichEditorModel model = getRichEditorModel(richEditor); |
||||
return createRichEditorPane(model); |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> createRichEditorPane(VanChartRichEditorModel model) { |
||||
if (richEditorPane == null) { |
||||
richEditorPane = initPane(model); |
||||
} else { |
||||
richEditorRefresh(model); |
||||
} |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
public static void richEditorRefresh(VanChartRichEditorModel model) { |
||||
if (richEditorPane != null && browser != null) { |
||||
refresh(browser, model); |
||||
} |
||||
} |
||||
|
||||
public static void richEditorAddField(VanChartRichEditorModel model) { |
||||
if (richEditorPane != null && browser != null) { |
||||
addField(browser, model); |
||||
} |
||||
} |
||||
|
||||
public static ModernUIPane<VanChartRichEditorModel> initPane(VanChartRichEditorModel model) { |
||||
return new ModernUIPane.Builder<VanChartRichEditorModel>() |
||||
.prepare(new ScriptContextAdapter() { |
||||
public void onScriptContextCreated(ScriptContextEvent event) { |
||||
browser = event.getBrowser(); |
||||
browser.getCacheStorage().clearCache(); |
||||
|
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); |
||||
browser.executeJavaScript(generateTransformI18nJS()); |
||||
browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); |
||||
|
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); |
||||
ns.asObject().setProperty(VARIABLE, model); |
||||
} |
||||
}) |
||||
.withEMB(RICH_EDITOR_HTML) |
||||
.namespace(NAME_SPACE).build(); |
||||
} |
||||
|
||||
public static void refresh(Browser browser, VanChartRichEditorModel model) { |
||||
stateChange(browser, model, REFRESH); |
||||
} |
||||
|
||||
public static void addField(Browser browser, VanChartRichEditorModel model) { |
||||
stateChange(browser, model, ADD_FIELD); |
||||
} |
||||
|
||||
public static void stateChange(Browser browser, VanChartRichEditorModel model, String trigger) { |
||||
JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); |
||||
ns.asObject().setProperty(VARIABLE, model); |
||||
browser.executeJavaScript("window." + NAME_SPACE + "." + trigger); |
||||
} |
||||
|
||||
public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { |
||||
Map<String, String> paramsMap = richText.getParams(); |
||||
StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); |
||||
|
||||
if (paramsMap != null) { |
||||
for (Map.Entry<String, String> entry : paramsMap.entrySet()) { |
||||
paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); |
||||
paramsStr.append(PARAMS_SPLITTER); |
||||
} |
||||
} |
||||
|
||||
int len = paramsStr.length(); |
||||
|
||||
if (len > 0) { |
||||
paramsStr.deleteCharAt(len - 1); |
||||
} |
||||
|
||||
String content = richText.getContent(); |
||||
String initParams = StringUtils.EMPTY; |
||||
String align = StringUtils.EMPTY; |
||||
|
||||
if (content.contains("data-id") && !content.contains("class")) { |
||||
initParams = richText.getInitParamsContent(); |
||||
|
||||
String left = TextAlign.LEFT.getAlign(); |
||||
String center = TextAlign.CENTER.getAlign(); |
||||
|
||||
align = content.contains(left) ? left : center; |
||||
} |
||||
|
||||
return new VanChartRichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); |
||||
} |
||||
|
||||
public static String generateTransformI18nJS() { |
||||
String language = "zh_CN"; |
||||
|
||||
Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); |
||||
|
||||
if (locale != null) { |
||||
language = locale.toString(); |
||||
} |
||||
|
||||
return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; |
||||
} |
||||
} |
@ -0,0 +1,97 @@
|
||||
package com.fr.van.chart.designer.component.richText; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Dimension; |
||||
|
||||
// 标签提示中的富文本面板,包含字段设置和富文本编辑器
|
||||
public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> { |
||||
|
||||
private static final int FIELD_PANE_W = 470; |
||||
private static final int FIELD_PANE_H = 270; |
||||
|
||||
private static final int RICH_EDITOR_W = 940; |
||||
private static final int RICH_EDITOR_H = 460; |
||||
|
||||
private VanChartFieldListPane fieldListPane; |
||||
private VanChartFieldAttrPane fieldAttrPane; |
||||
|
||||
public VanChartRichTextPane(ModernUIPane<VanChartRichEditorModel> richEditor) { |
||||
fieldAttrPane = new VanChartFieldAttrPane(); |
||||
fieldListPane = createFieldListPane(fieldAttrPane, richEditor); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(createFieldContentPane(), BorderLayout.CENTER); |
||||
this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH); |
||||
} |
||||
|
||||
public VanChartFieldListPane getFieldListPane() { |
||||
return fieldListPane; |
||||
} |
||||
|
||||
private JPanel createFieldContentPane() { |
||||
JPanel fieldPane = new JPanel(); |
||||
fieldPane.setLayout(FRGUIPaneFactory.create2ColumnGridLayout()); |
||||
|
||||
// 新增字段目录
|
||||
JPanel fieldListContent = new JPanel(); |
||||
fieldListContent.setLayout(new BorderLayout()); |
||||
fieldListContent.add(fieldListPane, BorderLayout.NORTH); |
||||
|
||||
JScrollPane fieldListScrollPane = new JScrollPane(fieldListContent); |
||||
fieldListScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldListScrollPane.setHorizontalScrollBar(null); |
||||
fieldListScrollPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Add_Field"))); |
||||
|
||||
// 字段格式和汇总
|
||||
JScrollPane fieldAttrScrollPane = new JScrollPane(fieldAttrPane); |
||||
fieldAttrScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); |
||||
fieldAttrScrollPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Field_Setting"))); |
||||
|
||||
fieldPane.add(fieldListScrollPane); |
||||
fieldPane.add(fieldAttrScrollPane); |
||||
|
||||
return fieldPane; |
||||
} |
||||
|
||||
protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditor) { |
||||
return new VanChartFieldListPane(fieldAttrPane, richEditor); |
||||
} |
||||
|
||||
private JPanel createRichEditorPane(JPanel richEditor) { |
||||
JPanel richEditorPane = new JPanel(); |
||||
|
||||
richEditorPane.setLayout(new BorderLayout()); |
||||
richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); |
||||
richEditorPane.add(richEditor, BorderLayout.CENTER); |
||||
|
||||
return richEditorPane; |
||||
} |
||||
|
||||
protected AttrTooltipContent getInitialTooltipContent() { |
||||
return new AttrTooltipContent(); |
||||
} |
||||
|
||||
public void populateBean(AttrTooltipContent tooltipContent) { |
||||
fieldListPane.populate(tooltipContent); |
||||
} |
||||
|
||||
public AttrTooltipContent updateBean() { |
||||
AttrTooltipContent content = getInitialTooltipContent(); |
||||
fieldListPane.update(content); |
||||
return content; |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
package com.fr.van.chart.designer.component.tooltip; |
||||
|
||||
import com.fr.design.ui.ModernUIPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldButton; |
||||
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; |
||||
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class VanChartFieldListPaneWithOutSeries extends VanChartFieldListPane { |
||||
|
||||
public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) { |
||||
super(fieldAttrPane, richEditorPane); |
||||
} |
||||
|
||||
protected void addDefaultFieldButton(JPanel fieldPane) { |
||||
fieldPane.add(getCategoryNameButton()); |
||||
fieldPane.add(getValueButton()); |
||||
fieldPane.add(getPercentButton()); |
||||
} |
||||
|
||||
protected List<VanChartFieldButton> getDefaultFieldButtonList() { |
||||
List<VanChartFieldButton> fieldButtonList = new ArrayList<>(); |
||||
|
||||
fieldButtonList.add(getCategoryNameButton()); |
||||
fieldButtonList.add(getValueButton()); |
||||
fieldButtonList.add(getPercentButton()); |
||||
|
||||
return fieldButtonList; |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue