Browse Source

Merge pull request #4193 in DESIGN/design from feature/10.0 to bugfix/10.0

* commit 'b2f7af88bbae1e70abde1ad7b9ba21eea22eb13a': (55 commits)
  REPORT-51305 打开/保存模板时切换时 右侧面板可用问题 + 第一次打开时加载动画问题
  REPORT-51315 保存中的模板,标签的图标遗漏加载动效
  REPORT-51304 保存时gif背景为透明时 锯齿太严重 通过代码来绘制
  REPORT-51401 打开模板,设计器上日志顺序不对
  REPORT-51409 打开模板加载失败后,点击重试,文件目录上方的工具栏都变得可操作了
  CHART-19104 鼠标的click事件不能稳定触发,改为change事件
  REPORT-51281 & 	REPORT-51378 & REPORT-51490 导出-字体检测-模板保存相关问题
  REPORT-51309 导出-字体检测-检测按钮提示的文字显示不全
  CHART-18951 悬浮窗图表无法关闭
  CHART-19018 插入悬浮图表后,再插入单元格图表,无法点出图表属性面板
  REPORT-51317 保存失败后,保存中加载动画还在
  CHART-18997design 表单 扩展图表图表块读取失败 不吞抛错rethrow
  REPORT-51292 mongodb插件-feature分支下点击确定后保存失效
  CHART-18997 处理下打开模板出错时情况
  CHART-18997 处理下打开模板出错时情况
  REPORT-51162 端口输入限制失效 & REPORT-51260 redshift的特定url格式无法识别
  KERNEL-7542 优化设计器发现的一些问题
  FineJOptionPane
  conflict
  REPORT-51153 数据连接界面优化-url全部删除后,各配置项不会自动清空
  ...
bugfix/10.0
superman 4 years ago
parent
commit
da2320f5ce
  1. 21
      designer-base/src/main/java/com/fr/base/svg/SVGIcon.java
  2. 16
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  3. 26
      designer-base/src/main/java/com/fr/design/actions/ForbiddenUpdateAction.java
  4. 7
      designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java
  5. 3
      designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java
  6. 3
      designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java
  7. 45
      designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java
  8. 11
      designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java
  9. 4
      designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java
  10. 7
      designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java
  11. 5
      designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java
  12. 12
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  13. 43
      designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java
  14. 6
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  15. 3
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  16. 5
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java
  17. 118
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java
  18. 345
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  19. 413
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  20. 43
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  21. 21
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java
  22. 22
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  23. 47
      designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java
  24. 34
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  25. 38
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  26. 2
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  27. 10
      designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java
  28. 7
      designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java
  29. 64
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java
  30. 18
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java
  31. 56
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java
  32. 18
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java
  33. 17
      designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java
  34. 2
      designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java
  35. 76
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  36. 30
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  37. 75
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  38. 8
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  39. 337
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  40. 57
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java
  41. 93
      designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java
  42. 61
      designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java
  43. 41
      designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java
  44. 162
      designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java
  45. 214
      designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java
  46. 126
      designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java
  47. 37
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  48. 8
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  49. 12
      designer-base/src/main/java/com/fr/design/selection/SelectableElement.java
  50. 49
      designer-base/src/main/java/com/fr/design/worker/WorkerManager.java
  51. 28
      designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java
  52. 154
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  53. 75
      designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java
  54. 37
      designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java
  55. 97
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java
  56. 3
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  57. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/check.png
  58. BIN
      designer-base/src/main/resources/com/fr/design/images/buttonicon/run24.png
  59. 16
      designer-base/src/main/resources/com/fr/design/images/control/addPopup_disabled.svg
  60. 14
      designer-base/src/main/resources/com/fr/design/images/control/addPopup_normal.svg
  61. BIN
      designer-base/src/main/resources/com/fr/design/images/correct.png
  62. BIN
      designer-base/src/main/resources/com/fr/design/images/error.png
  63. BIN
      designer-base/src/main/resources/com/fr/design/images/file/grey_saving_close.gif
  64. BIN
      designer-base/src/main/resources/com/fr/design/images/file/white_saving_close.gif
  65. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Down_16x16.png
  66. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png
  67. BIN
      designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png
  68. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif
  69. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png
  70. BIN
      designer-base/src/main/resources/com/fr/design/images/waiting.png
  71. BIN
      designer-base/src/main/resources/com/fr/design/images/warnings/warning32.png
  72. 12
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java
  73. 2
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java
  74. 163
      designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java
  75. 165
      designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java
  76. 22
      designer-chart/src/main/java/com/fr/van/chart/designer/component/format/TargetValueFormatPaneWithCheckBox.java
  77. 32
      designer-chart/src/main/java/com/fr/van/chart/designer/component/format/VanChartFormatPaneWithCheckBox.java
  78. 64
      designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java
  79. 26
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java
  80. 86
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java
  81. 35
      designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java
  82. 4
      designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java
  83. 8
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  84. 23
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  85. 18
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java
  86. 5
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  87. 9
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  88. 3
      designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java
  89. 31
      designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java
  90. 11
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java
  91. 3
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java
  92. 38
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java
  93. 14
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  94. 11
      designer-realize/src/main/java/com/fr/grid/selection/FloatSelection.java
  95. 7
      designer-realize/src/main/java/com/fr/start/MainDesigner.java
  96. 7
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  97. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java

21
designer-base/src/main/java/com/fr/base/svg/SVGIcon.java

@ -7,6 +7,8 @@ import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* SVG转化而来的Icon
@ -28,6 +30,8 @@ public class SVGIcon implements Icon {
this.image = image;
}
private static Map<String, Icon> iconCache = new ConcurrentHashMap<>();
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
if (HI_DPI_SURPORT) {
@ -58,11 +62,26 @@ public class SVGIcon implements Icon {
* @return
*/
public static Icon readSVGIcon(String url) {
return readSVGIconWithCache(url, true);
}
public static Icon readSVGIconWithCache(String url, boolean cacheRead) {
Icon icon = null;
if (cacheRead) {
icon = iconCache.get(url);
}
if (icon == null) {
if (!url.startsWith(ICON_PREFIX)) {
url = ICON_PREFIX + url;
}
BufferedImage image = (BufferedImage) SVGLoader.load(url);
return image == null ? IOUtils.readIcon(url) : new SVGIcon(image);
icon = image == null ? IOUtils.readIcon(url) : new SVGIcon(image);
//只缓存svg图标
if (image != null){
iconCache.put(url, icon);
}
}
return icon;
}
/**

16
designer-base/src/main/java/com/fr/design/DesignModelAdapter.java

@ -75,6 +75,12 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
setCurrentModelAdapter(this);
}
public DesignModelAdapter(S jTemplate, Parameter[] parameters) {
this.jTemplate = jTemplate;
initParameter(parameters);
setCurrentModelAdapter(this);
}
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
@ -244,6 +250,16 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
&& (widget instanceof DataControl || widget instanceof MultiFileEditor);
}
private void initParameter(Parameter[] parameters) {
// 全部参数
this.parameters = parameters;
// 数据及参数
this.tableDataParameters = getLatestTableDataParameters();
// 模板参数
this.templateParameters = getLatestTemplateParameters();
}
/**
* 更新缓存的参数
*/

26
designer-base/src/main/java/com/fr/design/actions/ForbiddenUpdateAction.java

@ -0,0 +1,26 @@
package com.fr.design.actions;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIForbiddenButton;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/12
*/
public abstract class ForbiddenUpdateAction extends UpdateAction {
@Override
public JComponent createToolBarComponent() {
Object object = this.getValue(UIForbiddenButton.class.getName());
if (!(object instanceof AbstractButton)) {
UIButton button = null;
button = new UIForbiddenButton();
object = initButton(button, UIForbiddenButton.class.getName());
}
return (JComponent) object;
}
}

7
designer-base/src/main/java/com/fr/design/actions/core/ActionFactory.java

@ -7,6 +7,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.selection.QuickEditor;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.Action;
import javax.swing.KeyStroke;
@ -14,7 +15,6 @@ import java.awt.event.KeyEvent;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -242,8 +242,11 @@ public class ActionFactory {
KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keyStroke != null) {
buttonToolTipTextBuf.append(" (");
buttonToolTipTextBuf.append(KeyEvent.getKeyModifiersText(keyStroke.getModifiers()));
String modifiersText = KeyEvent.getKeyModifiersText(keyStroke.getModifiers());
if (!StringUtils.isEmpty(modifiersText)) {
buttonToolTipTextBuf.append(modifiersText);
buttonToolTipTextBuf.append('+');
}
buttonToolTipTextBuf.append(KeyEvent.getKeyText(keyStroke.getKeyCode()));
buttonToolTipTextBuf.append(')');
}

3
designer-base/src/main/java/com/fr/design/actions/edit/RedoAction.java

@ -49,7 +49,8 @@ public class RedoAction extends UpdateAction implements TemplateComponentActionI
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
this.setEnabled(undoComponent != null && undoComponent.canRedo());
boolean enable = undoComponent != null && undoComponent.canRedo() && undoComponent.checkEnable();
this.setEnabled(enable);
} else {
this.setEnabled(false);
}

3
designer-base/src/main/java/com/fr/design/actions/edit/UndoAction.java

@ -49,7 +49,8 @@ public class UndoAction extends UpdateAction implements TemplateComponentActionI
public void update() {
JTemplate<?, ?> undoComponent = getEditingComponent();
if (DesignerEnvManager.getEnvManager().isSupportUndo()) {
this.setEnabled(undoComponent != null && undoComponent.canUndo());
boolean enable = undoComponent != null && undoComponent.canUndo() && undoComponent.checkEnable();
this.setEnabled(enable);
} else {
this.setEnabled(false);
}

45
designer-base/src/main/java/com/fr/design/actions/file/CloseCurrentTemplateAction.java

@ -1 +1,44 @@
package com.fr.design.actions.file; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.menu.KeySetUtils; import java.awt.event.ActionEvent; /** * Author : daisy * Date: 13-8-16 * Time: 下午3:23 */ public class CloseCurrentTemplateAction extends UpdateAction { public CloseCurrentTemplateAction() { this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); this.setAccelerator(getMenuKeySet().getKeyStroke()); } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); } }
package com.fr.design.actions.file;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import java.awt.event.ActionEvent;
/**
* Author : daisy
* Date: 13-8-16
* Time: 下午3:23
*/
public class CloseCurrentTemplateAction extends UpdateAction {
public CloseCurrentTemplateAction() {
this.setMenuKeySet(KeySetUtils.CLOSE_CURRENT_TEMPLATE);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setAccelerator(getMenuKeySet().getKeyStroke());
}
/**
* 动作
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
MutilTempalteTabPane.getInstance().setIsCloseCurrent(true);
MutilTempalteTabPane.getInstance().closeFormat(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
}
@Override
public void update() {
super.update();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.setEnabled(!template.isSaving());
}
}
}

11
designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java

@ -3,6 +3,8 @@ package com.fr.design.actions.file;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.event.ActionEvent;
@ -17,4 +19,13 @@ public class EditEnvAction extends UpdateAction {
public void actionPerformed(ActionEvent e) {
EnvChangeEntrance.getInstance().chooseEnv();
}
@Override
public void update() {
super.update();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.setEnabled(!template.isSaving());
}
}
}

4
designer-base/src/main/java/com/fr/design/actions/file/ExitDesignerAction.java

@ -3,6 +3,7 @@
*/
package com.fr.design.actions.file;
import com.fr.design.mainframe.TemplateSavingChecker;
import java.awt.event.ActionEvent;
import com.fr.design.actions.UpdateAction;
@ -27,6 +28,9 @@ public class ExitDesignerAction extends UpdateAction {
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
if (!TemplateSavingChecker.check()) {
return;
}
DesignerContext.getDesignerFrame().exit();
}
}

7
designer-base/src/main/java/com/fr/design/actions/file/SaveAsTemplateAction.java

@ -31,7 +31,7 @@ public class SaveAsTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
JTemplate<?, ?> jt = this.getEditingComponent();
// kunsnat: 保存前停止编辑状态,保存属性.
jt.stopEditing();
jt.saveAsTemplate();
jt.saveAsDirectly();
this.setEnabled(true);
jt.requestFocus();
@ -40,9 +40,6 @@ public class SaveAsTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
@Override
public void update() {
super.update();
// this.setEnabled(!this.getEditingComponent().isSaved());
// 另存为按钮应该一直可用使用
this.setEnabled(true);
this.setEnabled(this.getEditingComponent().checkEnable());
}
}

5
designer-base/src/main/java/com/fr/design/actions/file/SaveTemplateAction.java

@ -31,14 +31,15 @@ public class SaveTemplateAction extends JTemplateAction<JTemplate<?, ?>> {
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = this.getEditingComponent();
jt.stopEditing();
jt.saveTemplate();
jt.saveDirectly();
jt.requestFocus();
}
@Override
public void update() {
super.update();
this.setEnabled(!this.getEditingComponent().isSaved());
boolean enable = !this.getEditingComponent().isSaved() && this.getEditingComponent().checkEnable();
this.setEnabled(enable);
}
}

12
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -1,10 +1,11 @@
package com.fr.design.actions.file;
import com.fr.base.svg.IconUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
@ -68,5 +69,14 @@ public class SwitchExistEnv extends MenuDef {
EnvChangeEntrance.getInstance().switch2Env(envName);
}
}
@Override
public void update() {
super.update();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.setEnabled(!template.isSaving());
}
}
}
}

43
designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java

@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.GeneralUtils;
@ -67,9 +68,21 @@ public final class WebPreviewUtils {
*
* 如果保存失败,不执行下面的WebPreview
*/
if (!jt.isSaved() && !jt.saveTemplate2Env()) {
if (!jt.isSaved()) {
CallbackSaveWorker worker = jt.save2Env();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
browserTemplate(jt, baseRoute, map, actionType);
}
});
worker.start(jt.getTarget().getTemplateID());
return;
}
browserTemplate(jt, baseRoute, map, actionType);
}
private static void browserTemplate(JTemplate<?, ?> jt, String baseRoute, Map<String, Object> map, String actionType) {
FILE currentTemplate = jt.getEditingFILE();
// carl:是否是保存在运行环境下的模板,不是就不能被预览
if (currentTemplate instanceof FileNodeFILE) {
@ -83,15 +96,18 @@ public final class WebPreviewUtils {
WARNING_MESSAGE
);
if (OK_OPTION == selVal) {
if (!jt.saveAsTemplate()) {
return;
CallbackSaveWorker worker = jt.saveAs();
worker.start(jt.getTarget().getTemplateID());
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt);
}
} else {
return;
});
}
currentTemplate = jt.getEditingFILE();
return;
}
browseUrl(currentTemplate, baseRoute, map, actionType, jt);
browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt);
} else {
// 说明模板没有保存在报表运行环境下面,提示用户
int selVal = showConfirmDialog(
@ -102,11 +118,14 @@ public final class WebPreviewUtils {
WARNING_MESSAGE);
if (OK_OPTION == selVal) {
if (!jt.saveAsTemplate2Env()) {
return;
CallbackSaveWorker worker = jt.saveAs2Env();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
browseUrl(jt.getEditingFILE(), baseRoute, map, actionType, jt);
}
currentTemplate = jt.getEditingFILE();
browseUrl(currentTemplate, baseRoute, map, actionType, jt);
});
worker.start(jt.getTarget().getTemplateID());
}
}
}
@ -150,7 +169,7 @@ public final class WebPreviewUtils {
WARNING_MESSAGE
);
if (OK_OPTION == selVal) {
jt.saveAsTemplate();
jt.saveAsDirectly();
}
}
}

6
designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java

@ -226,4 +226,10 @@ public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JT
}
}
@Override
public void update() {
super.update();
this.setEnabled(this.getEditingComponent().checkEnable());
}
}

3
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -6,6 +6,7 @@ import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.ForbiddenUpdateAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
@ -398,7 +399,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
return prefix + count;
}
protected class PreviewTableDataAction extends UpdateAction {
protected class PreviewTableDataAction extends ForbiddenUpdateAction {
private TableDataTree dataTree;
public PreviewTableDataAction(TableDataTree dataTree) {

5
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java

@ -6,6 +6,7 @@ import com.fr.data.TableDataSource;
import com.fr.data.impl.TableDataSourceDependent;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.ForbiddenUpdateAction;
import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.BasicTableDataTreePane;
@ -243,7 +244,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
dg.setVisible(true);
}
private class EditAction extends UpdateAction {
private class EditAction extends ForbiddenUpdateAction {
public EditAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
this.setMnemonic('E');
@ -260,7 +261,7 @@ public class TableDataTreePane extends BasicTableDataTreePane {
}
}
private class RemoveAction extends UpdateAction {
private class RemoveAction extends ForbiddenUpdateAction {
public RemoveAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));

118
designer-base/src/main/java/com/fr/design/data/datapane/connect/DBCPAttrPane.java

@ -0,0 +1,118 @@
package com.fr.design.data.datapane.connect;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.icombobox.UIComboBox;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
public class DBCPAttrPane extends BasicPane {
public static final int TIME_MULTIPLE = 1000;
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor();
private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor();
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
public DBCPAttrPane() {
JPanel defaultPane = this;
// JPanel northFlowPane
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
DBCP_VALIDATION_QUERY.setColumns(15);
// ContextPane
double f = TableLayout.FILL;
// double p = TableLayout.PREFERRED;
double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f};
double[] columnSize = {f, f};
Component[][] comps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT),
DBCP_TIMEBETWEENEVICTIONRUNSMILLS},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
northFlowPane.add(contextPane);
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
}
public void update(JDBCDatabaseConnection jdbcDatabase) {
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestWhileIdle(this.DBCP_TESTWHILEIDLE.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);
dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue());
dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue());
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr");
}
}

345
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -7,15 +7,20 @@ import com.fr.data.impl.Connection;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.operator.DataOperator;
import com.fr.data.solution.ExceptionSolutionSelector;
import com.fr.data.solution.entity.DriverPage;
import com.fr.data.solution.processor.ClassNotFoundExceptionSolutionProcessor;
import com.fr.data.solution.processor.SolutionProcessor;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
@ -25,19 +30,28 @@ import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.HashMap;
import java.util.Map;
import java.net.URI;
import java.util.concurrent.ExecutionException;
/**
@ -50,60 +64,200 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private UIButton cancelButton;
private JDialog dialog;
private UILabel uiLabel;
private UILabel directUiLabel;
private UILabel detailLabel;
private JPanel midPane;
private JPanel hiddenPanel;
// 编码转换.
private UIComboBox charSetComboBox;
private String originalCharSet = null;
private JPanel mainPanel;
// Database pane
public DatabaseConnectionPane() {
this.initComponents();
}
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[] {Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
ActionListener testConnectionActionListener = new ActionListener() {
private boolean firstCreate = true;
// 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
northPane.add(testPane, BorderLayout.NORTH);
UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"));
testPane.add(testButton);
testButton.addActionListener(testConnectionActionListener);
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
@Override
public void actionPerformed(ActionEvent evt) {
// Center
northPane.add(mainPanel(), BorderLayout.CENTER);
// ChartSet
JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
northPane.add(chartSetPane);
chartSetPane.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
// Try the java connection.
final SwingWorker<Void, Void> connectionThread = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
Connection database = DatabaseConnectionPane.this.updateBean();
// 返回连接结果
DriverPage.updateCache();
DataOperator.getInstance().testConnectionWithException(database);
return null;
}
@Override
protected void done() {
try {
get();
dialog.setSize(new Dimension(380, 125));
okButton.setEnabled(true);
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully"));
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (ExecutionException e) {
dialog.setSize(new Dimension(380, 142));
midPane.setVisible(true);
hiddenPanel.setVisible(false);
okButton.setEnabled(true);
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed"));
SolutionProcessor select = ExceptionSolutionSelector.get().select(e);
if (select instanceof ClassNotFoundExceptionSolutionProcessor) {
JPanel gridJpanel = new JPanel();
gridJpanel.setLayout(new GridLayout(5, 1, 0, 5));
UILabel driverTips = new UILabel();
driverTips.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver"));
gridJpanel.add(driverTips);
UILabel deatail = new UILabel();
String content = Toolkit.i18nText("Fine_Designer_Not_Found") + select.getResultException().getDetailMessage() + Toolkit.i18nText("Fine_Designer_Driver");
deatail.setText(content);
deatail.setToolTipText(content);
gridJpanel.add(deatail);
String solution = select.getResultException().getSolution();
UILabel redirect = new UILabel();
if (solution != null) {
redirect.setText(Toolkit.i18nText("Fine_Designer_Download_Driver"));
redirect.setForeground(Color.BLUE);
redirect.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI(solution));
} catch (Exception clickException) {
FineLoggerFactory.getLogger().warn("can not open browser with {}", solution);
}
}
@Override
public void mouseEntered(MouseEvent e) {
redirect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
redirect.setCursor(Cursor.getDefaultCursor());
}
});
} else {
redirect.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver_No_Solution"));
}
gridJpanel.add(redirect);
hiddenPanel.add(gridJpanel);
gridJpanel.setBackground(Color.WHITE);
} else {
JPanel borderPanel = new JPanel();
borderPanel.setLayout(new BorderLayout());
JTextArea jta = new JTextArea();
JScrollPane jsp = new JScrollPane(jta);
jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jta.append(select.getResultException().getDetailMessage() + "\n");
jta.append(select.getResultException().getSolution());
jta.setCaretPosition(0);
jta.setEditable(false);
jta.getCaret().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
jta.getCaret().setVisible(true);
}
});
borderPanel.add(jsp, BorderLayout.CENTER);
hiddenPanel.add(borderPanel);
}
okButton.setEnabled(true);
}
}
};
midPane.setVisible(false);
hiddenPanel.setVisible(false);
initDialogPane();
connectionThread.execute();
// 老bug,initDialogPane 中的 dialog每次都是new的,所以可以重新添加 listener,但是其他的对象不行,会多次添加listener
if (firstCreate) {
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hiddenPanel.removeAll();
dialog.dispose();
}
});
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
hiddenPanel.removeAll();
dialog.dispose();
connectionThread.cancel(true);
}
});
detailLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (hiddenPanel.isVisible()) {
hiddenPanel.setVisible(false);
dialog.setSize(new Dimension(380, 142));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
} else {
dialog.setSize(new Dimension(380, 270));
hiddenPanel.setVisible(true);
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
}
}
@Override
public void mouseEntered(MouseEvent e) {
detailLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseExited(MouseEvent e) {
detailLabel.setCursor(Cursor.getDefaultCursor());
}
});
firstCreate = false;
}
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
connectionThread.cancel(true);
}
});
dialog.setVisible(true);
hiddenPanel.removeAll();
dialog.dispose();
}
};
protected abstract JPanel mainPanel();
protected abstract boolean isFineBI();
@Override
public void populateBean(com.fr.data.impl.Connection ob) {
populateSubDatabaseConnectionBean((E) ob);
if (mainPanel instanceof JDBCDefPane) {
return;
}
this.originalCharSet = ob.getOriginalCharsetName();
if (StringUtils.isBlank(originalCharSet)) {
this.charSetComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Encode_Auto"));
} else {
this.charSetComboBox.setSelectedItem(ob.getOriginalCharsetName());
}
populateSubDatabaseConnectionBean((E) ob);
}
protected abstract void populateSubDatabaseConnectionBean(E ob);
@ -111,7 +265,9 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override
public com.fr.data.impl.Connection updateBean() {
E ob = updateSubDatabaseConnectionBean();
if (mainPanel instanceof JDBCDefPane) {
return ob;
}
ob.setOriginalCharsetName(this.originalCharSet);
if (this.charSetComboBox.getSelectedIndex() == 0) {
ob.setNewCharsetName(null);
@ -127,83 +283,97 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
protected abstract E updateSubDatabaseConnectionBean();
ActionListener testConnectionActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
// Try the java connection.
final SwingWorker<Boolean, Void> connectionThread = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
Connection database = DatabaseConnectionPane.this.updateBean();
// 返回连接结果
return DataOperator.getInstance().testConnection(database);
}
protected void initComponents() {
message = new UILabel();
uiLabel = new UILabel();
detailLabel = new UILabel();
directUiLabel = new UILabel();
hiddenPanel = new JPanel();
midPane = new JPanel();
midPane.add(directUiLabel);
midPane.add(detailLabel);
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH);
@Override
protected void done() {
try {
boolean connect = get();
okButton.setEnabled(true);
if (connect) {
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully"));
}else{
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed"));
}
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
};
// 按钮.
JPanel testPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
northPane.add(testPane, BorderLayout.NORTH);
UIButton testButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"));
testPane.add(testButton);
testButton.addActionListener(testConnectionActionListener);
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
connectionThread.execute();
initDialogPane();
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
// Center
mainPanel = mainPanel();
northPane.add(mainPanel, BorderLayout.CENTER);
JPanel advancedPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
advancedPanel.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
if (mainPanel instanceof JDBCDefPane) {
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
if (wDialog != null) {
wDialog.setVisible(true);
}
});
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
connectionThread.cancel(true);
}
});
JPanel actionLabelPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
actionLabelPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 4, 20));
actionLabelPanel.add(actionLabel, BorderLayout.WEST);
advancedPanel.add(actionLabelPanel);
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
connectionThread.cancel(true);
} else {
//非jdbc配置布局保持不变
// ChartSet
String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
advancedPanel.add(chartSetPane);
}
northPane.add(advancedPanel);
}
});
dialog.setVisible(true);
dialog.dispose();
private JDialog createJDialog() {
return JDBC.getAdvancedAttrPane() != null ? JDBC.getAdvancedAttrPane().showWindow(SwingUtilities.getWindowAncestor(mainPanel)) : null;
}
};
private void initDialogPane() {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection") + "...");
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(DatabaseConnectionPane.this), Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true);
dialog.setSize(new Dimension(268, 118));
dialog.setSize(new Dimension(380, 125));
okButton.setEnabled(false);
JPanel jp = new JPanel();
JPanel upPane = new JPanel();
JPanel downPane = new JPanel();
uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
midPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
detailLabel.setForeground(Color.BLUE);
hiddenPanel.setLayout(new BorderLayout(2, 0));
hiddenPanel.add(new JPanel(), BorderLayout.WEST);
hiddenPanel.add(new JPanel(), BorderLayout.EAST);
downPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 15, 9));
downPane.add(okButton);
downPane.add(cancelButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane);
jp.add(midPane);
jp.add(hiddenPanel);
jp.add(downPane);
dialog.add(jp);
dialog.setResizable(false);
@ -213,6 +383,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public static class JDBC extends DatabaseConnectionPane<JDBCDatabaseConnection> {
private static JDBCDefPane jdbcDefPane = new JDBCDefPane();
private static DBCPAttrPane dbcpAttrPane = new DBCPAttrPane();
@Override
protected JPanel mainPanel() {
@ -224,14 +395,21 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
return false;
}
protected static BasicPane getAdvancedAttrPane() {
return dbcpAttrPane;
}
@Override
protected void populateSubDatabaseConnectionBean(JDBCDatabaseConnection ob) {
jdbcDefPane.populate(ob);
dbcpAttrPane.populate(jdbcDefPane.getJDBCDatabase());
}
@Override
protected JDBCDatabaseConnection updateSubDatabaseConnectionBean() {
return jdbcDefPane.update();
JDBCDatabaseConnection jdbcDatabaseConnection = jdbcDefPane.update();
dbcpAttrPane.update(jdbcDatabaseConnection);
return jdbcDatabaseConnection;
}
@Override
@ -268,5 +446,4 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
return "JNDI";
}
}
}

413
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -1,9 +1,7 @@
package com.fr.design.data.datapane.connect;
import com.fr.base.GraphHelper;
import com.fr.design.constants.UIConstants;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.pool.DBCPConnectionPoolAttr;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
@ -16,22 +14,24 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.dialog.BasicPane;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.utils.BrowseUtils;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -44,13 +44,19 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name";
public static final int TIME_MULTIPLE = 1000;
private static final String OTHER_DB = "Others";
private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");
private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]");
// 编码转换.
private String originalCharSet = null;
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
static {
@ -59,45 +65,38 @@ public class JDBCDefPane extends JPanel {
new DriverURLName("COM.cloudscape.JDBCDriver", "jdbc:cloudscape:/cloudscape/"),
new DriverURLName("com.internetcds.jdbc.tds.Driver", "jdbc:freetds:sqlserver://localhost/"),
new DriverURLName("com.fr.swift.jdbc.Driver", "jdbc:swift:emb://default")});
jdbcMap.put("Inceptor", new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver", "jdbc:inceptor2://localhost:10000/default"),
new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver", "jdbc:inceptor://localhost:10000/default")});
jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:1521:databaseName")});
jdbcMap.put("DB2", new DriverURLName[]{new DriverURLName("com.ibm.db2.jcc.DB2Driver", "jdbc:db2://localhost:50000/")});
jdbcMap.put("SQL Server", new DriverURLName[]{new DriverURLName("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;" + "databaseName=")});
jdbcMap.put("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/"),
new DriverURLName("org.gjt.mm.mysql.Driver", "jdbc:mysql://localhost/")});
jdbcMap.put("Sybase", new DriverURLName[]{new DriverURLName("com.sybase.jdbc2.jdbc.SybDriver", "jdbc:sybase:Tds:localhost:5000/")});
jdbcMap.put("Inceptor", new DriverURLName[]{new DriverURLName("org.apache.hive.jdbc.HiveDriver", "jdbc:inceptor2://localhost:port/databaseName"),
new DriverURLName("org.apache.hadoop.hive.jdbc.HiveDriver", "jdbc:inceptor://localhost:port/databaseName")});
jdbcMap.put("Oracle", new DriverURLName[]{new DriverURLName("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@localhost:port:databaseName")});
jdbcMap.put("DB2", new DriverURLName[]{new DriverURLName("com.ibm.db2.jcc.DB2Driver", "jdbc:db2://localhost:port/databaseName")});
jdbcMap.put("SQL Server", new DriverURLName[]{new DriverURLName("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:port;databaseName=databaseName")});
jdbcMap.put("MySQL", new DriverURLName[]{new DriverURLName("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:port/databaseName"),
new DriverURLName("org.gjt.mm.mysql.Driver", "jdbc:mysql://localhost:port/databaseName")});
jdbcMap.put("Sybase", new DriverURLName[]{new DriverURLName("com.sybase.jdbc2.jdbc.SybDriver", "jdbc:sybase:Tds:localhost:port/databaseName")});
jdbcMap.put("Derby", new DriverURLName[]{new DriverURLName("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost:port/databaseName")});
jdbcMap.put("Postgre", new DriverURLName[]{new DriverURLName("org.postgresql.Driver", "jdbc:postgresql://localhost:port/databaseName")});
jdbcMap.put("Access", new DriverURLName[]{new DriverURLName("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=")});
jdbcMap.put("Derby", new DriverURLName[]{new DriverURLName("org.apache.derby.jdbc.ClientDriver", "jdbc:derby://localhost:1527/")});
jdbcMap.put("Postgre", new DriverURLName[]{new DriverURLName("org.postgresql.Driver", "jdbc:postgresql://localhost:5432/")});
jdbcMap.put("SQLite", new DriverURLName[]{new DriverURLName("org.sqlite.JDBC", "jdbc:sqlite://${ENV_HOME}/../help/FRDemo.db")});
}
private UIButton dbtypeButton;
private UIComboBox dbtypeComboBox;
private UIComboBox driverComboBox;
private UITextField dbNameTextField;
private UITextField hostTextField;
private UITextField portTextField;
private UITextField urlTextField;
private UITextField userNameTextField;
private JPasswordField passwordTextField;
private UIComboBox charSetComboBox;
private ActionLabel odbcTipsLink;
private JPanel centerPanel;
private Component[][] allComponents;
private Component[][] partComponents;
// 请不要改动dbtype,只应该最后添加
private final String[] dbtype = {"Oracle", "DB2", "SQL Server", "MySQL", "Sybase", "Access", "Derby", "Postgre", "SQLite", "Inceptor", OTHER_DB};
// carl:DBCP的一些属性
private IntegerEditor DBCP_INITIAL_SIZE = new IntegerEditor();
private IntegerEditor DBCP_MAX_ACTIVE = new IntegerEditor();
private IntegerEditor DBCP_MAX_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MIN_IDLE = new IntegerEditor();
private IntegerEditor DBCP_MAX_WAIT = new IntegerEditor();
private UITextField DBCP_VALIDATION_QUERY = new UITextField();
private UIComboBox DBCP_TESTONBORROW = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTONRETURN = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private UIComboBox DBCP_TESTWHILEIDLE = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_No"), Toolkit.i18nText("Fine-Design_Basic_Yes")});
private IntegerEditor DBCP_TIMEBETWEENEVICTIONRUNSMILLS = new IntegerEditor();
private IntegerEditor DBCP_NUMTESTSPEREVICTIONRUN = new IntegerEditor();
private IntegerEditor DBCP_MINEVICTABLEIDLETIMEMILLIS = new IntegerEditor();
private JDBCDatabaseConnection jdbcDatabase;
private boolean needRefresh = true;
@ -119,7 +118,14 @@ public class JDBCDefPane extends JPanel {
driverComboBox = new UIComboBox();
driverComboBox.setEditable(true);
driverComboBox.addActionListener(driverListener);
dbNameTextField = new UITextField(15);
hostTextField = new UITextField(15);
portTextField = new UITextField(15);
portTextField.addInputMethodListener(portInputMethodListener);
portTextField.addKeyListener(portKeyListener);
urlTextField = new UITextField(15);
urlTextField.getDocument().addDocumentListener(updateParaListener);
enableSubDocListener();
userNameTextField = new UITextField(15);
userNameTextField.setName(USER_NAME);
passwordTextField = new UIPasswordFieldWithFixedLength(15);
@ -131,11 +137,10 @@ public class JDBCDefPane extends JPanel {
double f = TableLayout.FILL;
JPanel dbtypePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
dbtypePane.add(new UILabel((Toolkit.i18nText("Fine-Design_Basic_Database") + ":")));
JPanel dbtypeComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] dbtypeComComponents = {{dbtypeComboBox}};
double[] dbtypeRowSize = {p};
double[] dbtypeColumnSize = {p};
dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize);
JPanel dbtypeComPane = TableLayoutHelper.createTableLayoutPane(dbtypeComComponents, dbtypeRowSize, dbtypeColumnSize);
JPanel driverPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
driverPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Driver") + ":"));
@ -162,43 +167,61 @@ public class JDBCDefPane extends JPanel {
driverComboBoxAndTips.add(driverComboBox, BorderLayout.WEST);
driverComboBoxAndTips.add(odbcTipsPane, BorderLayout.CENTER);
JPanel hostPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
hostPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Host") + ":"));
Component[][] hostComComponents = {{hostTextField}};
double[] hostRowSize = {p};
double[] hostColumnSize = {p};
JPanel hostComPane = TableLayoutHelper.createTableLayoutPane(hostComComponents, hostRowSize, hostColumnSize);
JPanel portPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
portPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Port") + ":"));
Component[][] portComComponents = {{portTextField}};
double[] portRowSize = {p};
double[] portColumnSize = {p};
JPanel portComPane = TableLayoutHelper.createTableLayoutPane(portComComponents, portRowSize, portColumnSize);
JPanel dbNamePane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
dbNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_DatabaseName") + ":"));
Component[][] dbNameComComponents = {{dbNameTextField}};
double[] dbNameRowSize = {p};
double[] dbNameColumnSize = {p};
JPanel dbNameComPane = TableLayoutHelper.createTableLayoutPane(dbNameComComponents, dbNameRowSize, dbNameColumnSize);
JPanel urlPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
urlPane.add(new UILabel("URL:"));
JPanel urlComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] urlComComponents = {{urlTextField, dbtypeButton}};
double[] urlRowSize = {p};
double[] urlColumnSize = {f, 21};
urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
JPanel urlComPane = TableLayoutHelper.createCommonTableLayoutPane(urlComComponents, urlRowSize, urlColumnSize, 4);
JPanel userPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
userPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_UserName") + ":"));
JPanel userComPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
Component[][] userComComponents = {{userNameTextField, new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":"), passwordTextField}};
double[] userRowSize = {p};
double[] userColumnSize = {f, p, f};
userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4);
JPanel passwordPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
passwordPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Password") + ":"));
Component[][] components = {{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane}, {userPane, userComPane},};
double[] rowSize = {p, p, p, p};
JPanel userComPane = TableLayoutHelper.createCommonTableLayoutPane(userComComponents, userRowSize, userColumnSize, 4);
String[] defaultEncode = new String[]{Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
JPanel chartSetPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
chartSetPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
Component[][] charSetComComponents = {{charSetComboBox}};
double[] charSetRowSize = {p};
double[] charSetColumnSize = {f};
JPanel charSetComPane = TableLayoutHelper.createTableLayoutPane(charSetComComponents, charSetRowSize, charSetColumnSize);
//这边调整的话注意下面的changePane
allComponents = new Component[][]{{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {hostPane, hostComPane},
{portPane, portComPane}, {dbNamePane, dbNameComPane}, {userPane, userComPane},
{chartSetPane, charSetComPane}, {urlPane, urlComPane}};
partComponents = new Component[][]{{dbtypePane, dbtypeComPane}, {driverPane, driverComboBoxAndTips}, {urlPane, urlComPane},
{userPane, userComPane}, {chartSetPane, charSetComPane}};
double[] rowSize = {p, p, p, p, p, p, p, p};
double[] columnSize = {p, f, 22};
// REPORT-41450 Windows环境的jdk11下dpi为125%时会因为缩放导致显示问题,因此加个水平gap值
JPanel centerPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 6, 6);
centerPanel = TableLayoutHelper.createGapTableLayoutPane(allComponents, rowSize, columnSize, 6, 6);
innerthis.add(centerPanel);
JPanel southPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
innerthis.add(southPanel);
southPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 4, 20));
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
southPanel.add(actionLabel, BorderLayout.EAST);
actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JDialog wDialog = createJDialog();
wDialog.setVisible(true);
}
});
}
public void populate(JDBCDatabaseConnection jdbcDatabase) {
@ -235,26 +258,32 @@ public class JDBCDefPane extends JPanel {
this.urlTextField.setText(jdbcDatabase.getURL());
this.userNameTextField.setText(jdbcDatabase.getUser());
this.passwordTextField.setText(jdbcDatabase.getPassword());
this.originalCharSet = jdbcDatabase.getOriginalCharsetName();
if (StringUtils.isBlank(originalCharSet)) {
this.charSetComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Encode_Auto"));
} else {
this.charSetComboBox.setSelectedItem(jdbcDatabase.getOriginalCharsetName());
}
needRefresh = false;
}
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
this.jdbcDatabase.setDbcpAttr(dbcpAttr);
}
this.DBCP_INITIAL_SIZE.setValue(dbcpAttr.getInitialSize());
this.DBCP_MAX_ACTIVE.setValue(dbcpAttr.getMaxActive());
this.DBCP_MAX_IDLE.setValue(dbcpAttr.getMaxIdle());
this.DBCP_MAX_WAIT.setValue(dbcpAttr.getMaxWait());
this.DBCP_MIN_IDLE.setValue(dbcpAttr.getMinIdle());
this.DBCP_VALIDATION_QUERY.setText(dbcpAttr.getValidationQuery());
this.DBCP_TESTONBORROW.setSelectedIndex(dbcpAttr.isTestOnBorrow() ? 1 : 0);
this.DBCP_TESTONRETURN.setSelectedIndex(dbcpAttr.isTestOnReturn() ? 1 : 0);
this.DBCP_TESTWHILEIDLE.setSelectedIndex(dbcpAttr.isTestWhileIdle() ? 1 : 0);
this.DBCP_MINEVICTABLEIDLETIMEMILLIS.setValue(dbcpAttr.getMinEvictableIdleTimeMillis() / TIME_MULTIPLE);
this.DBCP_NUMTESTSPEREVICTIONRUN.setValue(dbcpAttr.getNumTestsPerEvictionRun());
this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.setValue(dbcpAttr.getTimeBetweenEvictionRunsMillis());
needRefresh = true;
protected JDBCDatabaseConnection getJDBCDatabase() {
return this.jdbcDatabase;
}
private void changePane(Object dbType) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f, 22};
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
if (this.centerPanel.getComponentCount() != partComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(partComponents, new double[]{p, p, p, p, p}, columnSize, centerPanel);
}
} else if (this.centerPanel.getComponentCount() != allComponents.length * 2) {
centerPanel.removeAll();
TableLayoutHelper.addComponent2ResultPane(allComponents, new double[]{p, p, p, p, p, p, p, p}, columnSize, centerPanel);
}
}
public JDBCDatabaseConnection update() {
@ -266,25 +295,14 @@ public class JDBCDefPane extends JPanel {
jdbcDatabase.setURL(this.urlTextField.getText().trim());
jdbcDatabase.setUser(this.userNameTextField.getText().trim());
jdbcDatabase.setPassword(new String(this.passwordTextField.getPassword()).trim());
DBCPConnectionPoolAttr dbcpAttr = jdbcDatabase.getDbcpAttr();
if (dbcpAttr == null) {
dbcpAttr = new DBCPConnectionPoolAttr();
jdbcDatabase.setDbcpAttr(dbcpAttr);
}
dbcpAttr.setInitialSize(this.DBCP_INITIAL_SIZE.getValue().intValue());
dbcpAttr.setMaxActive(this.DBCP_MAX_ACTIVE.getValue().intValue());
dbcpAttr.setMaxIdle(this.DBCP_MAX_IDLE.getValue().intValue());
dbcpAttr.setMaxWait(this.DBCP_MAX_WAIT.getValue().intValue());
dbcpAttr.setMinIdle(this.DBCP_MIN_IDLE.getValue().intValue());
dbcpAttr.setValidationQuery(this.DBCP_VALIDATION_QUERY.getText());
dbcpAttr.setTestOnBorrow(this.DBCP_TESTONBORROW.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestOnReturn(this.DBCP_TESTONRETURN.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setTestWhileIdle(this.DBCP_TESTWHILEIDLE.getSelectedIndex() == 0 ? false : true);
dbcpAttr.setMinEvictableIdleTimeMillis(((Number) this.DBCP_MINEVICTABLEIDLETIMEMILLIS.getValue()).intValue() * TIME_MULTIPLE);
dbcpAttr.setNumTestsPerEvictionRun(((Number) this.DBCP_NUMTESTSPEREVICTIONRUN.getValue()).intValue());
dbcpAttr.setTimeBetweenEvictionRunsMillis(((Number) this.DBCP_TIMEBETWEENEVICTIONRUNSMILLS.getValue()).intValue());
jdbcDatabase.setOriginalCharsetName(this.originalCharSet);
if (this.charSetComboBox.getSelectedIndex() == 0) {
jdbcDatabase.setNewCharsetName(null);
jdbcDatabase.setOriginalCharsetName(null);
} else {
jdbcDatabase.setNewCharsetName(EncodeConstants.ENCODING_GBK);
jdbcDatabase.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
}
return jdbcDatabase;
}
@ -310,6 +328,7 @@ public class JDBCDefPane extends JPanel {
if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem());
}
};
@ -368,49 +387,175 @@ public class JDBCDefPane extends JPanel {
}
};
private JDialog createJDialog() {
return new DBCPAttrPane().showWindow(SwingUtilities.getWindowAncestor(JDBCDefPane.this));
InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) {
event.consume();
}
}
class DBCPAttrPane extends BasicPane {
public DBCPAttrPane() {
JPanel defaultPane = this;
@Override
public void caretPositionChanged(InputMethodEvent event) {
// JPanel northFlowPane
JPanel northFlowPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
defaultPane.add(northFlowPane, BorderLayout.NORTH);
}
};
DBCP_VALIDATION_QUERY.setColumns(15);
// ContextPane
DocumentListener updateParaListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
updatePara();
}
double f = TableLayout.FILL;
// double p = TableLayout.PREFERRED;
double[] rowSize = {f, f, f, f, f, f, f, f, f, f, f, f};
double[] columnSize = {f, f};
Component[][] comps = {
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Initial_Size") + ":", SwingConstants.RIGHT), DBCP_INITIAL_SIZE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Active") + ":", SwingConstants.RIGHT), DBCP_MAX_ACTIVE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Max_Idle") + ":", SwingConstants.RIGHT), DBCP_MAX_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Min_Idle") + ":", SwingConstants.RIGHT), DBCP_MIN_IDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Max_Wait_Time") + ":", SwingConstants.RIGHT), DBCP_MAX_WAIT},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Validation_Query") + ":", SwingConstants.RIGHT), DBCP_VALIDATION_QUERY},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Borrow") + ":", SwingConstants.RIGHT), DBCP_TESTONBORROW},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_On_Return") + ":", SwingConstants.RIGHT), DBCP_TESTONRETURN},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Test_While_Idle") + ":", SwingConstants.RIGHT), DBCP_TESTWHILEIDLE},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Evictionruns_millis") + ":", SwingConstants.RIGHT),
DBCP_TIMEBETWEENEVICTIONRUNSMILLS},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Dbcp_Num_Test_Per_Evction_Run") + ":", SwingConstants.RIGHT), DBCP_NUMTESTSPEREVICTIONRUN},
{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Connection_Pool_Mix_Evictable_Idle_Time_Millis") + ":", SwingConstants.RIGHT),
DBCP_MINEVICTABLEIDLETIMEMILLIS}};
JPanel contextPane = TableLayoutHelper.createGapTableLayoutPane(comps, rowSize, columnSize, 10, 4);
contextPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, UIConstants.LINE_COLOR));
northFlowPane.add(contextPane);
@Override
public void removeUpdate(DocumentEvent e) {
updatePara();
}
@Override
public void changedUpdate(DocumentEvent e) {
updatePara();
}
};
private void updatePara() {
String dbType = dbtypeComboBox.getSelectedItem().toString();
if (ComparatorUtils.equals(dbType, OTHER_DB) || ComparatorUtils.equals(dbType, "Access") || ComparatorUtils.equals(dbType, "SQLite")) {
return;
}
disableSubDocListener();
String url = urlTextField.getText().trim();
Matcher matcher = ORACLE_URL.matcher(url);
if (matcher.find()) {
if (matcher.group(1) != null) {
hostTextField.setText(matcher.group(1));
} else {
hostTextField.setText(StringUtils.EMPTY);
}
if (matcher.group(3) != null) {
portTextField.setText(matcher.group(3));
} else {
portTextField.setText(StringUtils.EMPTY);
}
if (matcher.group(5) != null) {
dbNameTextField.setText(matcher.group(5));
} else {
dbNameTextField.setText(StringUtils.EMPTY);
}
enableSubDocListener();
return;
}
matcher = GENERAL_URL.matcher(url);
if (matcher.find()) {
if (matcher.group(2) != null) {
hostTextField.setText(matcher.group(2));
} else {
hostTextField.setText(StringUtils.EMPTY);
}
if (matcher.group(4) != null) {
portTextField.setText(matcher.group(4));
} else {
portTextField.setText(StringUtils.EMPTY);
}
if (matcher.group(7) != null) {
dbNameTextField.setText(matcher.group(7));
} else {
dbNameTextField.setText(StringUtils.EMPTY);
}
enableSubDocListener();
return;
}
hostTextField.setText(StringUtils.EMPTY);
portTextField.setText(StringUtils.EMPTY);
dbNameTextField.setText(StringUtils.EMPTY);
enableSubDocListener();
}
private void enableSubDocListener() {
this.dbNameTextField.getDocument().addDocumentListener(updateURLListener);
this.hostTextField.getDocument().addDocumentListener(updateURLListener);
}
private void disableSubDocListener() {
this.dbNameTextField.getDocument().removeDocumentListener(updateURLListener);
this.hostTextField.getDocument().removeDocumentListener(updateURLListener);
}
KeyListener portKeyListener = new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
String port = portTextField.getText();
if (isPortValid(port)) {
updateURL();
} else {
portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , ""));
if (!isPortValid(portTextField.getText())) {
portTextField.setText(StringUtils.EMPTY);
updateURL();
}
}
}
};
private boolean isPortValid(String port) {
return PORT.matcher(port).find();
}
private String getCharNeedReplace(char c) {
String charNeedReplace = c + "";
Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace);
if (matcher.find()) {
charNeedReplace = "\\" + charNeedReplace;
}
return charNeedReplace;
}
DocumentListener updateURLListener = new DocumentListener() {
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr");
public void insertUpdate(DocumentEvent e) {
updateURL();
}
@Override
public void removeUpdate(DocumentEvent e) {
updateURL();
}
@Override
public void changedUpdate(DocumentEvent e) {
updateURL();
}
};
private void updateURL() {
String dbType = dbtypeComboBox.getSelectedItem().toString();
if (!ComparatorUtils.equals(dbType, OTHER_DB) && !ComparatorUtils.equals(dbType, "Access") && !ComparatorUtils.equals(dbType, "SQLite")) {
urlTextField.getDocument().removeDocumentListener(updateParaListener);
DriverURLName[] driverURLNames = jdbcMap.get(dbType);
String defaultURL = null;
for (DriverURLName driverURLName : driverURLNames) {
if (ComparatorUtils.equals(driverURLName.getDriver(), driverComboBox.getSelectedItem().toString())) {
defaultURL = driverURLName.getURL();
}
}
if (defaultURL != null) {
String host = hostTextField.getText().trim();
String port = portTextField.getText().trim();
String dbName = dbNameTextField.getText().trim();
defaultURL = defaultURL.replace("localhost", host).replace(":port", ComparatorUtils.equals(port, "") ? "" : ":" + port);
if (defaultURL.startsWith("jdbc:sqlserver")) {
defaultURL = defaultURL.replace("=databaseName", "=" + dbName);
} else {
defaultURL = defaultURL.replace("databaseName", dbName);
}
}
urlTextField.setText(defaultURL);
urlTextField.getDocument().addDocumentListener(updateParaListener);
}
}

43
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -9,6 +9,7 @@ import java.awt.Font;
import java.net.URI;
import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/**
* 用来构建JOptionPane带超链的消息提示
@ -19,9 +20,32 @@ import javax.swing.event.HyperlinkEvent;
*/
public class MessageWithLink extends JEditorPane {
private static final UILabel LABEL = new UILabel();
public MessageWithLink(String message, String linkName, String link) {
super("text/html", "<html><body style=\"" + getStyle() + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>");
addHyperlinkListener(e -> {
this(message, linkName, link, LABEL.getBackground(), LABEL.getFont());
}
public MessageWithLink(String linkName, String link ) {
this(StringUtils.EMPTY, linkName, link);
}
public MessageWithLink(String message, String linkName, String link, Color color) {
this(message, linkName, link, color, LABEL.getFont());
}
public MessageWithLink(String message, String linkName, String link, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>");
initListener(link);
setEditable(false);
setBorder(null);
}
protected void initListener(String link) {
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(URI.create(link));
@ -29,21 +53,12 @@ public class MessageWithLink extends JEditorPane {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
});
setEditable(false);
setBorder(null);
}
public MessageWithLink(String linkName, String link ) {
this(StringUtils.EMPTY, linkName, link);
});
}
private static StringBuilder getStyle() {
// 构建和相同风格样式
UILabel label = new UILabel();
Font font = label.getFont();
Color color = label.getBackground();
private static StringBuilder generateStyle(Color color, Font font) {
// 构建相同风格样式
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");

21
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceLoader.java vendored

@ -0,0 +1,21 @@
package com.fr.design.env;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/11
*/
public class DesignerWorkspaceLoader {
public static void init() {
Workspace workspace = WorkContext.getCurrent();
if (workspace.isLocal()) {
return;
}
workspace.isWarDeploy();
workspace.isCluster();
}
}

22
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -14,6 +14,7 @@ import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
import com.fr.workspace.pool.WorkObjectPool;
import javax.swing.SwingWorker;
/**
* Created by juhaoyu on 2018/6/14.
@ -29,6 +30,10 @@ public class RemoteWorkspace implements Workspace {
private volatile Boolean isRoot = null;
private volatile Boolean cluster;
private volatile Boolean warDeploy;
RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) {
this.client = client;
@ -50,13 +55,16 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean isWarDeploy() {
return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler<Boolean>() {
if (warDeploy == null) {
warDeploy = WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler<Boolean>() {
@Override
public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
return false;
}
}).isWarDeploy();
}
return warDeploy;
}
@Override
public boolean isLocal() {
@ -79,13 +87,16 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean isCluster() {
return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler<Boolean>() {
if (cluster == null) {
cluster = WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler<Boolean>() {
@Override
public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
return false;
}
}).isCluster();
}
return cluster;
}
@Override
public WorkspaceConnection getConnection() {
@ -114,8 +125,13 @@ public class RemoteWorkspace implements Workspace {
@Override
public void close() {
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
client.close();
return null;
}
}.execute();
}
@Override

47
designer-base/src/main/java/com/fr/design/env/WorkspaceChangeLoadingDialog.java vendored

@ -0,0 +1,47 @@
package com.fr.design.env;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.gui.GUICoreUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/10
*/
public class WorkspaceChangeLoadingDialog extends JDialog {
private static final ImageIcon LOADING_ICON = new ImageIcon(WorkspaceChangeLoadingDialog.class.getResource("/com/fr/web/images/loading-local.gif"));
private static WorkspaceChangeLoadingDialog dialog;
public WorkspaceChangeLoadingDialog() {
super(DesignerContext.getDesignerFrame());
setLayout(new BorderLayout());
this.getContentPane().setBackground(Color.WHITE);
this.setResizable(false);
this.setUndecorated(true);
this.setAlwaysOnTop(true);
this.setModal(false);
this.setSize(new Dimension(400, 100));
this.add(new UILabel(LOADING_ICON, UILabel.CENTER), BorderLayout.NORTH);
this.add(new UILabel(Toolkit.i18nText("Fine-Design_Change_Workspace_Tip"), UILabel.CENTER), BorderLayout.CENTER);
GUICoreUtils.centerWindow(this);
}
public static void showDialog() {
dialog = new WorkspaceChangeLoadingDialog();
dialog.setVisible(true);
}
public static void hideDialog() {
dialog.dispose();
}
}

34
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -33,6 +33,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import javax.swing.SwingWorker;
/**
* 历史模板缓存
@ -45,6 +46,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private SwingWorker<Boolean, Void> stashWorker;
public static HistoryTemplateListCache getInstance() {
return Holder.INSTANCE;
@ -64,7 +66,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
//直接关闭模板的时候(当且仅当设计器tab上只剩一个模板)退出权限编辑
if (DesignModeContext.isAuthorityEditing() && historyList.size() <= 1) {
@ -92,7 +93,6 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
@ -340,6 +340,17 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @see HistoryTemplateListCache#load()
*/
public void stash() {
stashWorker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
_stash();
return true;
}
};
stashWorker.execute();
}
private void _stash() {
FineLoggerFactory.getLogger().info("Env Change Template Stashing...");
if (stashFILEMap == null) {
stashFILEMap = new HashMap<Integer, FILE>();
@ -365,6 +376,15 @@ public class HistoryTemplateListCache implements CallbackEvent {
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
}
private boolean checkStash() {
try {
return stashWorker.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
return false;
}
}
/**
* 切换环境前将正在编辑的模板暂存起来后在新环境重新读取一遍
* <p>
@ -373,6 +393,9 @@ public class HistoryTemplateListCache implements CallbackEvent {
* @see HistoryTemplateListCache#stash()
*/
public void load() {
if (!checkStash()) {
return;
}
FineLoggerFactory.getLogger().info("Env Change Template Loading...");
if (stashFILEMap != null && stashFILEMap.size() != 0) {
int size = historyList.size();
@ -490,4 +513,11 @@ public class HistoryTemplateListCache implements CallbackEvent {
return false;
}
public void replaceCurrentEditingTemplate(JTemplate<?, ?> jt) {
int index = contains(this.editingTemplate);
this.editingTemplate = jt;
historyList.set(index, jt);
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt));
}
}

38
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -11,9 +11,12 @@ import com.fr.design.gui.imenu.UIScrollPopUpMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.TemplateSavingChecker;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.design.worker.WorkerManager;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
@ -23,6 +26,7 @@ import com.fr.third.javax.annotation.Nonnull;
import javax.swing.BorderFactory;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
@ -66,6 +70,8 @@ public class MutilTempalteTabPane extends JComponent {
private static Icon CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png");
private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png");
private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png");
private static final Icon WHITE_SAVING_CLOSE_ICON = new ImageIcon(MutilTempalteTabPane.class.getResource("/com/fr/design/images/file/white_saving_close.gif"));
private static final Icon GREY_SAVING_CLOSE_ICON = new ImageIcon(MutilTempalteTabPane.class.getResource("/com/fr/design/images/file/grey_saving_close.gif"));
private static final String ELLIPSIS = "...";
private static final int GAP = 5;
private static final int SMALLGAP = 3;
@ -195,6 +201,9 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) {
return;
}
if (!TemplateSavingChecker.check()) {
return;
}
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false);
//点击关闭其他模板,并且点击确定保存
if (saveSomeTempaltePane.showSavePane()) {
@ -380,8 +389,14 @@ public class MutilTempalteTabPane extends JComponent {
selectedIcon = CLOSE;
}
if (i == selectedIndex) {
if (template.isSaving()) {
selectedIcon = WHITE_SAVING_CLOSE_ICON;
}
startX[i - minPaintIndex] = paintSelectedTab(g2d, icon, templateStartX, name, selectedIcon);
} else {
if (template.isSaving()) {
selectedIcon = GREY_SAVING_CLOSE_ICON;
}
boolean isLeft = i < selectedIndex;
startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i);
}
@ -682,9 +697,15 @@ public class MutilTempalteTabPane extends JComponent {
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate();
CallbackSaveWorker worker = specifiedTemplate.save();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate);
}
});
worker.start(specifiedTemplate.getTarget().getTemplateID());
} else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate);
}
@ -919,8 +940,19 @@ public class MutilTempalteTabPane extends JComponent {
closeIconIndex = getTemplateIndex(evtX);
clodeMode = MOUSE_PRESS_CLOSE;
//关闭close图标所在的模板{
closeFormat(openedTemplate.get(closeIconIndex));
closeSpecifiedTemplate(openedTemplate.get(closeIconIndex));
JTemplate<?, ?> template = openedTemplate.get(closeIconIndex);
if (template.isOpening()) {
WorkerManager.getInstance().cancelWorker(template.getPath());
} else if (template.isSaving()) {
boolean completed = WorkerManager.getInstance().isCompleted(template.getTarget().getTemplateID());
if (!completed) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Close_Template_Tip", template.getEditingFILE().getName()));
return;
}
}
closeFormat(template);
closeSpecifiedTemplate(template);
DesignerContext.getDesignerFrame().getContentFrame().repaint();
isShowList = false;
} else {

2
designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java

@ -195,7 +195,7 @@ public class SaveSomeTemplatePane extends BasicPane {
specifiedTemplate.stopEditing();
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) {
if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
}

10
designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java

@ -30,10 +30,12 @@ import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI;
import com.fr.design.gui.itooltip.UIToolTipBorder;
import com.fr.design.gui.itree.UITreeUI;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource;
@ -171,6 +173,8 @@ public class UILookAndFeel extends MetalLookAndFeel {
table.put("FileChooser.upFolderIcon", loadIcon("ParentDirectoryIcon.png", this));
table.put("OptionPane.errorIcon", loadIcon("Information_Icon_Error_32x32.png", this));
table.put("OptionPane.informationIcon", loadIcon("Information_Icon_OK_32x32.png", this));
table.put("OptionPane.narrow.right", loadIcon("Icon_Narrow_Right_16x16.png", this));
table.put("OptionPane.narrow.down", loadIcon("Icon_Narrow_Down_16x16.png", this));
table.put("OptionPane.warningIcon", loadIcon("WarningIcon.png", this));
table.put("OptionPane.questionIcon", loadIcon("QuestionIcon.png", this));
table.put("ScrollPane.border", new UIScrollPaneBorder());
@ -201,7 +205,7 @@ public class UILookAndFeel extends MetalLookAndFeel {
"com/fr/design/images/lookandfeel/" + fileName, UILookAndFeel.class);
if (url == null) {
FineLoggerFactory.getLogger().error("Icon directory could not be resolved.");
FineLoggerFactory.getLogger().error(fileName + " :Icon directory could not be resolved.");
return null;
}
}

7
designer-base/src/main/java/com/fr/design/gui/chart/BaseChartPropertyPane.java

@ -10,9 +10,6 @@ import com.fr.design.mainframe.DockingView;
* @version 创建时间2013-7-10 上午09:12:11
*/
public abstract class BaseChartPropertyPane extends DockingView {
public abstract void setSureProperty();
/**
* 设置是否支持单元格数据.
*/
@ -22,7 +19,5 @@ public abstract class BaseChartPropertyPane extends DockingView {
public abstract ChartEditPaneProvider getChartEditPane();
public abstract void addChartEditPane(String plotID);
//public abstract void clear();
public abstract void updateChartEditPane(String plotID);
}

64
designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButton.java

@ -0,0 +1,64 @@
package com.fr.design.gui.ibutton;
import com.fr.base.CellBorderStyle;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.plaf.ButtonUI;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/9
*/
public class UIForbiddenButton extends UIButton {
public UIForbiddenButton() {
super();
}
public UIForbiddenButton(String string) {
super(string);
}
public UIForbiddenButton(Icon icon) {
super(icon);
}
public UIForbiddenButton(Action action) {
super(action);
}
public UIForbiddenButton(String text, Icon icon) {
super(text, icon);
}
public UIForbiddenButton(Icon normal, Icon rollOver, Icon pressed) {
super(normal, rollOver, pressed);
}
public UIForbiddenButton(String resource, boolean needSetDisabledIcon) {
super(resource, needSetDisabledIcon);
}
@Override
public CellBorderStyle getBorderStyle() {
return super.getBorderStyle();
}
@Override
public boolean isEnabled() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean enabled = true;
if (template != null) {
enabled = super.isEnabled() && template.checkEnable();
}
return enabled;
}
@Override
public ButtonUI getUI() {
return new UIForbiddenButtonUI();
}
}

18
designer-base/src/main/java/com/fr/design/gui/ibutton/UIForbiddenButtonUI.java

@ -0,0 +1,18 @@
package com.fr.design.gui.ibutton;
import java.awt.Graphics;
import javax.swing.JComponent;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/11
*/
public class UIForbiddenButtonUI extends UIButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
c.setEnabled(c.isEnabled());
}
}

56
designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButton.java

@ -0,0 +1,56 @@
package com.fr.design.gui.ibutton;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.plaf.ButtonUI;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/10
*/
public class UISaveForbiddenButton extends UIButton {
public UISaveForbiddenButton() {
}
public UISaveForbiddenButton(String string) {
super(string);
}
public UISaveForbiddenButton(Icon icon) {
super(icon);
}
public UISaveForbiddenButton(Action action) {
super(action);
}
public UISaveForbiddenButton(String text, Icon icon) {
super(text, icon);
}
public UISaveForbiddenButton(Icon normal, Icon rollOver, Icon pressed) {
super(normal, rollOver, pressed);
}
public UISaveForbiddenButton(String resource, boolean needSetDisabledIcon) {
super(resource, needSetDisabledIcon);
}
@Override
public boolean isEnabled() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean enabled = true;
if (template != null) {
enabled = !template.isSaving();
}
return enabled;
}
@Override
public ButtonUI getUI() {
return new UISaveForbiddenButtonUI();
}
}

18
designer-base/src/main/java/com/fr/design/gui/ibutton/UISaveForbiddenButtonUI.java

@ -0,0 +1,18 @@
package com.fr.design.gui.ibutton;
import java.awt.Graphics;
import javax.swing.JComponent;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/14
*/
public class UISaveForbiddenButtonUI extends UIButtonUI {
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
c.setEnabled(c.isEnabled());
}
}

17
designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java

@ -1,8 +1,11 @@
package com.fr.design.gui.itoolbar;
import javax.swing.*;
import java.awt.*;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.Component;
import java.awt.FlowLayout;
import java.util.ArrayList;
import javax.swing.JToolBar;
public class UIToolbar extends JToolBar {
@ -31,4 +34,14 @@ public class UIToolbar extends JToolBar {
}
}
}
public void refreshUIToolBar() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
for (int i = 0; i < getComponentCount(); i++) {
Component component = getComponents()[i];
component.setEnabled(template.checkEnable());
}
}
}
}

2
designer-base/src/main/java/com/fr/design/layout/TableLayoutHelper.java

@ -233,7 +233,7 @@ public class TableLayoutHelper {
container.repaint();
}
private static void addComponent2ResultPane(Component[][] components, double[] rowSize, double[] columnSize, JPanel resultPane) {
public static void addComponent2ResultPane(Component[][] components, double[] rowSize, double[] columnSize, JPanel resultPane) {
for (int i = 0; i < components.length; i++) {
if (i >= rowSize.length) {

76
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -4,6 +4,7 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
@ -84,13 +85,13 @@ import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Component;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@ -185,6 +186,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
@Override
public void windowClosing(WindowEvent e) {
// 关闭前check
if (!TemplateSavingChecker.check()) {
return;
}
//关闭前当前模板 停止编辑
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing();
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
@ -404,7 +409,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
designerOpenedListenerList.clear();
}
protected DesktopCardPane getCenterTemplateCardPane() {
public DesktopCardPane getCenterTemplateCardPane() {
return centerTemplateCardPane;
}
@ -701,6 +706,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
}
//添加检测按钮
addCheckButton();
//添加分享按钮
addShareButton();
//添加插件中的按钮
@ -724,6 +731,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
}
}
private void addCheckButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) {
return;
}
combineUp.addSeparator(new Dimension(2, 16));
UIButton[] checkButtons = jt.createCheckButton();
for (UIButton checkButton : checkButtons) {
combineUp.add(checkButton);
}
}
private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -797,6 +816,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
layeredPane.repaint();
}
public void refreshUIToolBar() {
if (toolbarComponent instanceof UIToolbar) {
((UIToolbar ) toolbarComponent).refreshUIToolBar();
}
combineUp.refreshUIToolBar();
}
public JComponent getToolbarComponent() {
return this.toolbarComponent;
@ -926,42 +952,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
return this.centerTemplateCardPane.getSelectedJTemplate();
}
/**
* 保存当前编辑的模板
*/
public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) {
return;
}
if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板
if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中
// HistoryTemplateListPane.getInstance().addHistory();
}
} else {
editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
} else {
if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName()));
}
}
}
}
/**
* 添加新建模板, 并激活.
*/
@ -1085,6 +1075,16 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}
} catch (ChartNotFoundException e) {
FineJOptionPane.showMessageDialog(this,
Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}

30
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -181,10 +181,13 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.requestFocus();
jt.revert();
// 打开为空占位模板时不输出
if (!jt.isOpening()) {
FineLoggerFactory.getLogger().info(
"\"" + jt.getEditingFILE().getName() + "\""
+ Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!");
}
}
/**
* 刷新菜单
@ -289,16 +292,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
// 打开和保存中 需要禁用相关操作
boolean enable = isEnable();
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected && enable);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
delFileAction.setEnabled(selected && enable);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
//触发vcsAction变化
vcsAction.fireVcsActionChange();
vcsAction.fireVcsActionChange(enable);
// 其他状态
otherStateChange();
@ -363,7 +368,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
/**
* 版本管理可用状态的监控
*/
private void fireVcsActionChange() {
private void fireVcsActionChange(boolean enable) {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()
|| VcsHelper.getInstance().isUnSelectedTemplate()
|| WorkContext.getCurrent().isCluster()) {
@ -381,14 +386,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
setEnabled(false);
} else {
setEnabled(true);
setEnabled(enable);
}
} else {
setEnabled(false);
}
} else {
//当前环境为本地环境时
setEnabled(pathSupportVcsAction);
setEnabled(pathSupportVcsAction && enable);
}
}
}
@ -915,5 +920,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
private boolean isEnable() {
List<JTemplate<?, ?>> templates = HistoryTemplateListCache.getInstance().getHistoryList();
for (JTemplate<?, ?> template : templates) {
if (template.isSaving() || template.isOpening()) {
FileNode node = TemplateTreePane.getInstance().getFileNode();
if (node != null && ComparatorUtils.equals(template.getEditingFILE().getPath(), node.getEnvPath())) {
return false;
}
}
}
return true;
}
}

75
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -11,6 +11,8 @@ import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import java.awt.BorderLayout;
import java.awt.Component;
import javax.swing.JLayeredPane;
/**
@ -19,11 +21,30 @@ import java.awt.BorderLayout;
*/
public class DesktopCardPane extends BasicPane implements TargetModifiedListener {
private static final int CONTENT_LAYER = 0;
private static final int TRANSPARENT_LAYER = 1;
private static final int LOADING_LAYER = 2;
private static final int FAILED_LAYER = 3;
private static final long serialVersionUID = 1L;
private JTemplate<?, ?> component;
private TransparentPane transparentPane = new TransparentPane();
private OpenLoadingPane loadingPane = new OpenLoadingPane();
private OpenFailedPane failedPane = new OpenFailedPane();
private JLayeredPane layeredPane = new JLayeredPane() {
@Override
public void doLayout() {
for (Component comp : getComponents()) {
comp.setBounds(0, 0, getWidth(), getHeight());
}
}
};
protected DesktopCardPane() {
setLayout(new BorderLayout());
layeredPane.add(transparentPane, TRANSPARENT_LAYER);
layeredPane.add(failedPane, FAILED_LAYER);
add(layeredPane, BorderLayout.CENTER);
}
protected void showJTemplate(final JTemplate<?, ?> jt) {
@ -36,10 +57,12 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt);
if (component != null) {
component.onLostFocus();
remove(component);
layeredPane.remove(component);
}
component = jt;
add(component, BorderLayout.CENTER);
layeredPane.add(component, CONTENT_LAYER);
checkSavingAndOpening(jt);
add(layeredPane, BorderLayout.CENTER);
validate();
repaint();
revalidate();
@ -47,6 +70,54 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
component.onGetFocus();
}
private void checkSavingAndOpening(JTemplate<?, ?> jt) {
if (jt.isSaving()) {
showCover();
} else if (jt.isOpening()) {
showOpenStatus();
} else if (jt.isOpenFailed()) {
showOpenFailedCover();
} else {
hideCover();
}
}
/**
* 让loadingPane懒加载
*/
private void checkLoadingPane() {
if (layeredPane.getComponent(LOADING_LAYER) != loadingPane) {
layeredPane.add(loadingPane, LOADING_LAYER);
component.setVisible(false);
}
}
private void showOpenStatus() {
DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
checkLoadingPane();
layeredPane.moveToFront(loadingPane);
}
public void showOpenFailedCover() {
layeredPane.moveToFront(failedPane);
}
public void showCover() {
transparentPane.start();
layeredPane.moveToFront(transparentPane);
DesignerContext.getDesignerFrame().refreshUIToolBar();
EastRegionContainerPane.getInstance().updateAllPropertyPane();
}
public void hideCover() {
transparentPane.stop();
layeredPane.moveToFront(component);
EastRegionContainerPane.getInstance().updateAllPropertyPane();
}
protected JTemplate<?, ?> getSelectedJTemplate() {
return component;
}

8
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -6,6 +6,7 @@ import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.fun.PropertyItemPaneProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI;
@ -791,8 +792,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 选项不可用
public void setEnabled(boolean isEnabled) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.isEnabled = isEnabled && template.checkEnable();
} else {
this.isEnabled = isEnabled;
button.setEnabled(isEnabled);
}
button.setEnabled(this.isEnabled);
}
public void setIconBaseDir(String iconBaseDir) {

337
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
@ -22,6 +21,7 @@ import com.fr.design.designer.DesignerProxy;
import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateResourceManager;
import com.fr.design.file.TemplateTreePane;
@ -38,6 +38,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.check.CheckButton;
import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.template.info.TimeConsumeTimer;
@ -48,6 +49,8 @@ import com.fr.design.menu.NameSeparator;
import com.fr.design.menu.ShortCut;
import com.fr.design.preview.PagePreview;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.design.worker.save.EmptyCallBackSaveWorker;
import com.fr.design.write.submit.DBManipulationInWidgetEventPane;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.event.EventDispatcher;
@ -76,25 +79,26 @@ import com.fr.stable.core.UUID;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import java.util.concurrent.Callable;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import java.awt.BorderLayout;
/**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy {
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null;
protected FILE editingFILE = null;
// alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存
private boolean saved = true;
private boolean authoritySaved = true;
@ -109,6 +113,9 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType;
protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
private volatile boolean saving = false;
private volatile boolean opening = false;
private volatile boolean openFailed = false;
private PluginEventListener pluginListener;
@ -124,7 +131,15 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this(t, file, false);
}
public JTemplate(T t, FILE file, Parameter[] parameters) {
this(t, file, false, parameters);
}
public JTemplate(T t, FILE file, boolean isNewFile) {
this(t, file, isNewFile, null);
}
public JTemplate(T t, FILE file, boolean isNewFile, Parameter[] parameters) {
super(t);
beforeInit();
// 判断是否切换设计器状态到禁止拷贝剪切
@ -138,7 +153,11 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.editingFILE = file;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder());
if (parameters == null) {
designModel = createDesignModel();
} else {
designModel = createDesignModel(parameters);
}
addCenterPane();
this.undoState = createUndoState();
@ -396,6 +415,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected abstract DesignModelAdapter<T, ?> createDesignModel();
protected DesignModelAdapter<T, ?> createDesignModel(Parameter[] parameters) {
// 空实现 兼容下
return null;
}
/**
* 创建菜单项Preview
*
@ -613,6 +638,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*
* @return 保存模板
*/
@Deprecated
public boolean saveTemplate() {
return this.saveTemplate(true);
}
@ -622,6 +648,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*
* @return 保存成功返回true
*/
@Deprecated
public boolean saveTemplate2Env() {
return this.saveTemplate(false);
}
@ -631,6 +658,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*
* @return 保存成功返回true
*/
@Deprecated
public boolean saveAsTemplate() {
return this.saveAsTemplate(true);
}
@ -640,6 +668,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*
* @return 保存成功返回true
*/
@Deprecated
public boolean saveAsTemplate2Env() {
return this.saveAsTemplate(false);
}
@ -650,6 +679,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* @param isShowLoc 是否本地
* @return 保存成功返回true
*/
@Deprecated
public boolean saveTemplate(boolean isShowLoc) {
FILE editingFILE = this.getEditingFILE();
// carl:editingFILE没有,当然不存了,虽然不会有这种情况
@ -661,17 +691,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (!editingFILE.exists()) {
return saveAsTemplate(isShowLoc);
}
boolean access = false;
try {
access = FRContext.getOrganizationOperator().canAccess(this.getEditingFILE().getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE);
return false;
}
collectInfo();
return this.saveFile();
}
@ -701,6 +720,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* @param fileName 保存文件名
* @return
*/
@Deprecated
public boolean saveAsTemplate(boolean isShowLoc, String fileName) {
String oldName = this.getPath();
// alex:如果是SaveAs的话需要让用户来选择路径了
@ -716,20 +736,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) {
boolean access = false;
try {
access = FRContext.getOrganizationOperator().canAccess(fileChooser.getSelectedFILE().getPath());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (!access) {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
return false;
}
// 目标文件
editingFILE = fileChooser.getSelectedFILE();
}
@ -846,33 +852,61 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree();
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
String[] str = new String[gen.getChildCount()];
ArrayList<String> al = new ArrayList<String>();
List<Integer> reportNum = new ArrayList<>();
for (int j = 0; j < gen.getChildCount(); j++) {
str[j] = gen.getChildAt(j).toString();
if (str[j].contains(prefix) && str[j].contains(".")) {
for (int i = 0; i < PREFIX_NUM; i++) {
if (ComparatorUtils.equals(str[j].split("[.]")[0], (prefix + i))) {
al.add(str[j]);
//返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了)
Integer index = getFileNameIndex(prefix, str[j]);
if (index != null) {
reportNum.add(index);
}
}
}
}
int[] reportNum = new int[al.size()];
for (int i = 0; i < al.size(); i++) {
Pattern pattern = Pattern.compile("[" + prefix + ".]+");
String[] strs = pattern.split(al.get(i).toString());
reportNum[i] = Integer.parseInt(strs[1]);
}
Collections.sort(reportNum);
int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1;
Arrays.sort(reportNum);
int idx = reportNum.length > 0 ? reportNum[reportNum.length - 1] + 1 : 1;
idx = idx + currentIndex;
currentIndex++;
return prefix + idx;
}
/**
* @Description 返回文件名中的index
* @param: prefix 前缀
* @param: fileName 文件名称全名
* @return java.lang.Integer WorkBook11.cpt则返回11如果没有找到index返回null
* @Author Henry.Wang
* @Date 2021/4/9 11:13
**/
private static Integer getFileNameIndex(String prefix, String fileName) {
char[] chars = new char[fileName.length()];
int i = 0;
for (; i < fileName.length(); i++) {
char c = fileName.charAt(i);
//匹配前缀
if (i < prefix.length()) {
if (c != prefix.charAt(i)) {
return null;
}
} else {
if (c == '.') {
break;
} else {
//匹配0~9
if (c < 48 || c > 57) {
return null;
}
chars[i - prefix.length()] = c;
}
}
}
String s = new String(chars).substring(0, i - prefix.length());
if (StringUtils.isBlank(s)) {
return null;
}
return Integer.valueOf(s);
}
// /////////////////////////////toolbarMenuDock//////////////////////////////////
/**
@ -1332,6 +1366,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return uiButtons;
}
public UIButton[] createCheckButton() {
return new UIButton[]{new CheckButton()};
}
/**
* 由于老版本的模板没有模板ID当勾选使用参数模板时候就加一个模板ID attr
*
@ -1355,8 +1393,209 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return getEditingFILE().getName();
}
public String getTemplatePredefinedStyle(){
public String getTemplatePredefinedStyle() {
return StringUtils.EMPTY;
}
private CallbackSaveWorker save(boolean showLoc) {
FILE editingFILE = this.getEditingFILE();
// carl:editingFILE没有,当然不存了,虽然不会有这种情况
if (editingFILE == null) {
return new EmptyCallBackSaveWorker();
}
// 检查一下editingFILE是不是已存在的文件,如果不存在则用saveAs
if (!editingFILE.exists()) {
return saveAs(showLoc);
}
CallbackSaveWorker worker = new CallbackSaveWorker(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
collectInfo();
return JTemplate.this.saveRealFile();
}
}, this);
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
callBackForSave();
}
});
return worker;
}
private void callBackForSave() {
JTemplate.this.saved = true;
JTemplate.this.authoritySaved = true;
DesignerContext.getDesignerFrame().setTitle();
JTemplate.this.fireJTemplateSaved();
}
private boolean saveRealFile() throws Exception {
FILE editingFILE = this.getEditingFILE();
if (editingFILE == null || editingFILE instanceof MemFILE) {
return false;
}
this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE));
this.editingFILE = editingFILE;
return true;
}
private CallbackSaveWorker saveAs(boolean showLoc) {
FILE editingFILE = this.getEditingFILE();
if (editingFILE == null) {
return new EmptyCallBackSaveWorker();
}
String oldName = this.getPath();
// alex:如果是SaveAs的话需要让用户来选择路径了
FILEChooserPane fileChooser = getFILEChooserPane(showLoc);
addChooseFILEFilter(fileChooser);
fileChooser.setFileNameTextField(editingFILE.getName(), this.suffix());
int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix());
if (isCancelOperation(chooseResult)) {
return new EmptyCallBackSaveWorker();
}
// 源文件
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) {
// 目标文件
editingFILE = fileChooser.getSelectedFILE();
}
// 在保存之前,初始化 templateID
if (StringUtils.isEmpty(this.template.getTemplateID())) {
generateTemplateId();
}
FILE finalEditingFILE = editingFILE;
CallbackSaveWorker worker = new CallbackSaveWorker(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return saveAs(finalEditingFILE, sourceFile, oldName);
}
}, this);
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
callBackForSave();
// 当前打开的是正在保存的模板才刷新
if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(),
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) {
refreshToolArea();
}
DesignerFrameFileDealerPane.getInstance().refresh();
}
});
return worker;
}
private boolean saveAs(FILE editingFILE, FILE sourceFile, String oldName) throws Exception {
boolean lockedTarget =
// 目标本地文件
!editingFILE.isEnvFile() ||
// 目标远程文件
WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
if (lockedTarget) {
boolean saved = saveNewRealFile(editingFILE, oldName);
// 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉
if (saved && !ComparatorUtils.equals(editingFILE.getPath(), sourceFile.getPath())) {
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(sourceFile.getPath());
}
return saved;
} else {
return false;
}
}
private boolean saveNewRealFile(FILE editingFILE, String oldName) throws Exception {
consumeTimer.setEnabled(true);
consumeTimer.start();
this.editingFILE = editingFILE;
boolean result = this.saveToNewRealFile(oldName);
if (result) {
collectInfo(this.template.getTemplateID());
}
return result;
}
private boolean saveToNewRealFile(String oldName) throws Exception {
boolean result = false;
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
result = result || provider.saveToNewFile(this.editingFILE.getPath(), this);
}
if (!result) {
result = this.saveRealFile();
// 更换最近打开
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath());
}
return result;
}
@Override
public CallbackSaveWorker save() {
return save(true);
}
@Override
public CallbackSaveWorker saveAs() {
return saveAs(true);
}
@Override
public void saveDirectly() {
CallbackSaveWorker worker = save();
worker.start(this.template.getTemplateID());
}
@Override
public void saveAsDirectly() {
CallbackSaveWorker worker = saveAs();
worker.start(this.template.getTemplateID());
}
@Override
public CallbackSaveWorker save2Env() {
return save(false);
}
@Override
public CallbackSaveWorker saveAs2Env() {
return saveAs(false);
}
public boolean isSaving() {
return saving;
}
public void setSaving(boolean saving) {
this.saving = saving;
}
public boolean isOpening() {
return opening;
}
public void setOpening(boolean opening) {
this.opening = opening;
}
public boolean isOpenFailed() {
return openFailed;
}
public void setOpenFailed(boolean openFailed) {
this.openFailed = openFailed;
}
public boolean checkEnable() {
return !isSaving() && !isOpening() && !isOpenFailed();
}
}

57
designer-base/src/main/java/com/fr/design/mainframe/JTemplateSave.java

@ -0,0 +1,57 @@
package com.fr.design.mainframe;
import com.fr.design.worker.save.CallbackSaveWorker;
/**
* 模板保存接口
*
* @author hades
* @version 10.0
* Created by hades on 2021/4/9
*/
public interface JTemplateSave {
/**
* 保存后需要根据是否成功做外部回调可选保存位置
*
* @return
*/
CallbackSaveWorker save();
/**
* 另存为后需要根据是否成功做外部回调可选保存位置
*
* @return
*/
CallbackSaveWorker saveAs();
/**
* 保存到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
*
* @return
*/
CallbackSaveWorker save2Env();
/**
* 另存为到当前工作目录(reportlets)后需要根据是否成功做外部回调
*
* @return
*/
CallbackSaveWorker saveAs2Env();
/**D
* 直接保存
*/
void saveDirectly();
/**
* 直接另存为
*/
void saveAsDirectly();
}

93
designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java

@ -0,0 +1,93 @@
package com.fr.design.mainframe;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import javax.swing.JPanel;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/20
*/
public class OpenFailedPane extends JPanel {
private UILabel label;
private MessageWithLink link;
public OpenFailedPane() {
this.setLayout(new LayoutManager() {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int labelWidth = label.getPreferredSize().width;
int labelHeight = label.getPreferredSize().height;
int labelX = (width - labelWidth) / 2;
int labelY = (height - labelHeight) / 2;
int linkWidth = link.getPreferredSize().width;
int linkHeight = link.getPreferredSize().height;
int linkX = (width - linkWidth) / 2;
int linkY = (height - labelHeight) / 2 + labelHeight;
label.setBounds(labelX, labelY, labelWidth, labelHeight);
link.setBounds(linkX, linkY, linkWidth, linkHeight);
}
});
this.setBackground(Color.WHITE);
label = new UILabel(IOUtils.readIcon("/com/fr/design/images/mainframe/open_failed.png"), UILabel.CENTER);
link = new MessageWithLink(Toolkit.i18nText("Fine-Design_Open_Failed_Tip"), Toolkit.i18nText("Fine-Design_Open_Failed_Retry"), StringUtils.EMPTY, Color.WHITE) {
@Override
protected void initListener(String link) {
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
// 重试
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
template.whenClose();
template = JTemplateFactory.createJTemplate(template.getEditingFILE());
HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(template);
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
}
}
});
}
};
link.setBackground(Color.WHITE);
this.add(label);
this.add(link);
}
}

61
designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java

@ -0,0 +1,61 @@
package com.fr.design.mainframe;
import com.fr.design.gui.ilable.UILabel;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/9
*/
public class OpenLoadingPane extends JPanel {
private static final ImageIcon LOADING_ICON = new ImageIcon(OpenLoadingPane.class.getResource("/com/fr/design/images/mainframe/loading.gif"));
private UILabel loadingLabel;
public OpenLoadingPane() {
setLayout(new LayoutManager() {
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int loadingLabelWidth = loadingLabel.getPreferredSize().width;
int loadingLabelHeight = loadingLabel.getPreferredSize().height;
int loadingLabelX = (width - loadingLabelWidth) / 2;
int loadingLabelY = (height - loadingLabelHeight) / 2;
loadingLabel.setBounds(loadingLabelX, loadingLabelY, loadingLabelWidth, loadingLabelHeight);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
});
setBackground(Color.WHITE);
loadingLabel = new UILabel(LOADING_ICON);
add(loadingLabel);
}
}

41
designer-base/src/main/java/com/fr/design/mainframe/TemplateSavingChecker.java

@ -0,0 +1,41 @@
package com.fr.design.mainframe;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StableUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/12
*/
public class TemplateSavingChecker {
public static boolean check() {
List<String> list = getSavingTemplate();
if (!list.isEmpty()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Close_Template_Tip", StableUtils.join(list, "、")),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
return false;
}
return true;
}
private static List<String> getSavingTemplate() {
List<String> result = new ArrayList<>();
for (JTemplate<?, ?> template : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (template.isSaving()) {
result.add(template.getEditingFILE().getName());
}
}
return result;
}
}

162
designer-base/src/main/java/com/fr/design/mainframe/TransparentPane.java

@ -0,0 +1,162 @@
package com.fr.design.mainframe;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Composite;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.Timer;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/12
*/
public class TransparentPane extends JComponent implements ActionListener {
private UILabel label;
private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
private volatile boolean mIsRunning;
private volatile boolean mIsFadingOut;
private Timer mTimer;
private int mAngle;
private int mFadeCount;
private int mFadeLimit = 15;
private int lines = 12;
private int maxAngle = 360;
private int angleAdd = 30;
private double prec = 0.56;
public TransparentPane() {
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// do nothing
}
});
setLayout(getCoverLayout());
setBackground(null);
setOpaque(false);
label = new UILabel(Toolkit.i18nText("Fine-Design_Saving_Template_Tip"));
add(label);
}
protected LayoutManager getCoverLayout() {
return new LayoutManager() {
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int labelWidth = label.getPreferredSize().width;
int labelHeight = label.getPreferredSize().height;
int labelX = (width - labelWidth) / 2;
int labelY = (int) ((height - labelHeight) * prec);
label.setBounds(labelX, labelY, labelWidth, labelHeight);
}
@Override
public void addLayoutComponent(String name, Component comp) {
}
};
}
@Override
public void paint(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
super.paint(g);
if (!mIsRunning) {
return;
}
Graphics2D g2 = (Graphics2D) g.create();
float fade = (float) mFadeCount / (float) mFadeLimit;
Composite urComposite = g2.getComposite();
g2.setComposite(composite);
g2.fillRect(0, 0, w, h);
g2.setComposite(urComposite);
int s = Math.min(w, h) / 50;
int cx = w / 2;
int cy = h / 2;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setStroke(new BasicStroke(s / 4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2.setPaint(Color.BLACK);
g2.rotate(Math.PI * mAngle / 180, cx, cy);
for (int i = 0; i < lines; i++) {
float scale = (11.0f - (float) i) / 11.0f;
g2.drawLine(cx + s, cy, cx + s * 2, cy);
g2.rotate(-Math.PI / 6, cx, cy);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, scale * fade));
}
g2.dispose();
}
@Override
public void actionPerformed(ActionEvent e) {
if (mIsRunning) {
repaint();
mAngle += angleAdd;
if (mAngle >= maxAngle) {
mAngle = 0;
}
if (mIsFadingOut) {
if (--mFadeCount == 0) {
mIsRunning = false;
mTimer.stop();
}
} else if (mFadeCount < mFadeLimit) {
mFadeCount++;
}
}
}
public void start() {
if (mIsRunning) {
return;
}
mIsRunning = true;
mIsFadingOut = false;
mFadeCount = 0;
int fps = 24;
int tick = 1000 / fps;
mTimer = new Timer(tick, this);
mTimer.start();
}
public void stop() {
mIsRunning = false;
mIsFadingOut = true;
}
}

214
designer-base/src/main/java/com/fr/design/mainframe/check/CheckButton.java

@ -0,0 +1,214 @@
package com.fr.design.mainframe.check;
import com.fr.base.BaseUtils;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.check.TemplateChecker;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import static com.fr.design.dialog.FineJOptionPane.showConfirmDialog;
import static javax.swing.JOptionPane.OK_CANCEL_OPTION;
import static javax.swing.JOptionPane.OK_OPTION;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class CheckButton extends UIButton {
private UILabel message;
private UIButton okButton;
private JDialog dialog;
private UILabel uiLabel;
public CheckButton() {
this.setIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/check.png"));
this.setToolTipText(Toolkit.i18nText("Fine_Designer_Check_Font"));
this.set4ToolbarButton();
this.addActionListener(checkListener);
}
private ActionListener checkListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Try check
final SwingWorker<Set<String>, Void> checkThread = new SwingWorker<Set<String>, Void>() {
@Override
protected Set<String> doInBackground() throws Exception {
// 返回校验结果
return check(DesignerContext.getDesignerFrame().getSelectedJTemplate());
}
@Override
protected void done() {
try {
Set<String> set = get();
if (set == null) {
return;
}
if (set.isEmpty()) {
okButton.setEnabled(true);
uiLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/correct.png"));
message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Success") + "</html>");
} else {
if (dialog != null) {
dialog.dispose();
}
StringBuilder textBuilder = new StringBuilder();
textBuilder.append(Toolkit.i18nText("Fine_Designer_Check_Font_Missing_Font")).append("\n");
for (String font : set) {
textBuilder.append(font).append("\n");
}
String areaText = textBuilder.toString();
CheckFontInfoDialog dialog = new CheckFontInfoDialog(DesignerContext.getDesignerFrame(), areaText);
dialog.setVisible(true);
}
} catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
};
JTemplate<?, ?> jtemplate = DesignerContext.getDesignerFrame().getSelectedJTemplate();
if (jtemplate == null || jtemplate.getEditingFILE() == null) {
return;
}
FILE currentTemplate = jtemplate.getEditingFILE();
if (currentTemplate instanceof FileNodeFILE) {
// 判断下模板是否存在 不存在先提示
if (!currentTemplate.exists()) {
int selVal = showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
Toolkit.i18nText("Fine_Designer_Check_Font"),
OK_CANCEL_OPTION,
WARNING_MESSAGE
);
if (OK_OPTION == selVal) {
CallbackSaveWorker worker = jtemplate.saveAs();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
startCheck(checkThread);
}
});
worker.start(jtemplate.getTarget().getTemplateID());
}
} else {
if (!jtemplate.isSaved()) {
CallbackSaveWorker worker = jtemplate.save();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
startCheck(checkThread);
}
});
worker.start(jtemplate.getTarget().getTemplateID());
} else {
startCheck(checkThread);
}
}
} else {
//模板不在报表环境下,提示保存
int selVal = FineJOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"),
Toolkit.i18nText("Fine_Designer_Check_Font"),
OK_CANCEL_OPTION,
WARNING_MESSAGE);
if (OK_OPTION == selVal) {
CallbackSaveWorker worker = jtemplate.saveAs2Env();
worker.addSuccessCallback(new Runnable() {
@Override
public void run() {
startCheck(checkThread);
}
});
worker.start(jtemplate.getTarget().getTemplateID());
}
}
}
private void startCheck(SwingWorker<Set<String>, Void> checkThread) {
initDialogPane();
dialog.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
checkThread.cancel(true);
}
});
checkThread.execute();
dialog.setVisible(true);
dialog.dispose();
}
};
private Set<String> check(JTemplate jtemplate) {
String path = jtemplate.getEditingFILE().getEnvFullName();
Set<String> fontSet = WorkContext.getCurrent().get(TemplateChecker.class, new ExceptionHandler<Void>() {
@Override
public Void callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) {
uiLabel.setIcon(BaseUtils.readIcon("com/fr/design/images/error.png"));
message.setText("<html>" + Toolkit.i18nText("Fine_Designer_Check_Font_Upgrade") + "</html>");
okButton.setEnabled(true);
return null;
}
}).checkFont(path);
return fontSet;
}
private void initDialogPane() {
message = new UILabel();
message.setText(Toolkit.i18nText("Fine-Designer_Check_Font_Checking") + "...");
uiLabel = new UILabel();
okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
okButton.setEnabled(false);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
dialog = new JDialog();
dialog.setTitle(Toolkit.i18nText("Fine_Designer_Check_Font"));
dialog.setModal(true);
dialog.setSize(new Dimension(268, 118));
JPanel jp = new JPanel();
JPanel upPane = new JPanel();
JPanel downPane = new JPanel();
uiLabel = new UILabel(BaseUtils.readIcon("com/fr/design/images/waiting.png"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
upPane.add(uiLabel);
upPane.add(message);
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
downPane.add(okButton);
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(upPane);
jp.add(downPane);
dialog.add(jp);
dialog.setResizable(false);
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(this));
}
}

126
designer-base/src/main/java/com/fr/design/mainframe/check/CheckFontInfoDialog.java

@ -0,0 +1,126 @@
package com.fr.design.mainframe.check;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Locale;
/**
* 字体缺失检测的具体结果对话框
*
*/
public class CheckFontInfoDialog extends JDialog implements ActionListener {
private JPanel topPanel;
private JPanel upInTopPanel;
private JPanel downInTopPanel;
private JPanel hiddenPanel;
private JPanel bottomPanel;
private UILabel imageLabel;
private UILabel directUiLabel;
private UILabel detailLabel;
public CheckFontInfoDialog(Frame parent, String areaText) {
super(parent,true);
//提示信息
JPanel imagePanel = new JPanel();
imageLabel = new UILabel(IOUtils.readIcon("com/fr/design/images/warnings/warning32.png"));
imagePanel.add(imageLabel);
JPanel messagePanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
MessageWithLink linkMessage = new MessageWithLink(Toolkit.i18nText("Fine_Designer_Check_Font_Message"),
Toolkit.i18nText("Fine_Designer_Check_Font_Install_Font"),
CloudCenter.getInstance().acquireUrlByKind("help.install.font", "https://help.fanruan.com/finereport/doc-view-3999.html"));
linkMessage.setPreferredSize(new Dimension(380, 31));
messagePanel.add(linkMessage);
// 查看详情按钮
directUiLabel = new UILabel();
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
detailLabel = new UILabel();
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
upInTopPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
upInTopPanel.add(imageLabel, BorderLayout.WEST);
upInTopPanel.add(messagePanel, BorderLayout.CENTER);
downInTopPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
downInTopPanel.add(directUiLabel, BorderLayout.WEST);
downInTopPanel.add(detailLabel, BorderLayout.CENTER);
topPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true);
topPanel.add(upInTopPanel, BorderLayout.NORTH);
topPanel.add(downInTopPanel, BorderLayout.SOUTH);
//中间的详情展示(可隐藏)
hiddenPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
hiddenPanel.setBorder(BorderFactory.createEmptyBorder(0,12,0,12));
JScrollPane scrollPane = new JScrollPane();
JTextArea checkArea = new JTextArea(areaText);
scrollPane.setViewportView(checkArea);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
checkArea.setEnabled(false);
hiddenPanel.add(scrollPane);
hiddenPanel.setVisible(false);
downInTopPanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (hiddenPanel.isVisible()) {
hiddenPanel.setVisible(false);
CheckFontInfoDialog.this.setSize(new Dimension(380, 185));
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.right"));
} else {
CheckFontInfoDialog.this.setSize(new Dimension(380, 280));
hiddenPanel.setVisible(true);
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail"));
directUiLabel.setIcon(UIManager.getIcon("OptionPane.narrow.down"));
}
}
});
//底部的按钮面板
UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK"));
okButton.addActionListener(this);
bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
bottomPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
bottomPanel.add(okButton, BorderLayout.EAST);
this.setTitle(Toolkit.i18nText("Fine_Designer_Check_Font"));
this.setResizable(false);
this.add(topPanel, BorderLayout.NORTH);
this.add(hiddenPanel, BorderLayout.CENTER);
this.add(bottomPanel, BorderLayout.SOUTH);
this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US)? 400:380, 185));
GUICoreUtils.centerWindow(this);
}
@Override
public void actionPerformed(ActionEvent e) {
this.dispose();
}
}

37
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -1,12 +1,17 @@
package com.fr.design.menu;
import com.fr.base.svg.IconUtils;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.*;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import java.util.HashSet;
import java.util.Set;
import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
@ -25,6 +30,17 @@ public class MenuDef extends ShortCut {
private static final int MENU_DEFAULTWDITH = 156;
private static final int BLANK_WIDTH = 30;
private static final Set<String> FORBIDDEN_SET = new HashSet<>();
{
FORBIDDEN_SET.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Template"));
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Report_M_Insert"));
FORBIDDEN_SET.add(Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
FORBIDDEN_SET.add(KeySetUtils.CELL.getMenuKeySetName());
FORBIDDEN_SET.add(KeySetUtils.INSERT_FLOAT.getMenuKeySetName());
}
protected String name;
//右侧属性表弹出框重绘
protected Boolean isEastAttr = false;
@ -390,6 +406,21 @@ public class MenuDef extends ShortCut {
toolBar.add(this.createUIButton());
}
private boolean checkEnable(JComponent component) {
if (FORBIDDEN_SET.contains(component.getName())) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean flag = true;
if (template != null) {
flag = template.checkEnable();
}
component.setEnabled(flag);
if (!flag) {
return false;
}
}
return true;
}
protected MenuListener createMenuListener() {
return menuDefListener;
@ -411,7 +442,9 @@ public class MenuDef extends ShortCut {
if (!(source instanceof JMenu)) {
return;
}
if (!checkEnable(createJMenu())) {
return;
}
MenuDef.this.updateMenu();
}
};
@ -421,7 +454,7 @@ public class MenuDef extends ShortCut {
public void mouseReleased(MouseEvent evt) {
Object source = evt.getSource();
UIButton button = (UIButton) source;
if (!button.isEnabled()) {
if (!checkEnable(button)) {
return;
}
if (isEastAttr) {

8
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -243,14 +243,6 @@ public class DesignModuleFactory {
return bp;
}
public static void clearChartPropertyPane() {
if (instance.chartPropertyPaneClass != null) {
StableUtils.clearInstance(instance.chartPropertyPaneClass);
}
}
public static void registerButtonDetailPaneClass(Class clazz) {
instance.buttonDetailPaneClass = clazz;
}

12
designer-base/src/main/java/com/fr/design/selection/SelectableElement.java

@ -15,6 +15,16 @@ public interface SelectableElement {
* @return
*/
@SuppressWarnings("rawtypes")
public QuickEditor getQuickEditor(TargetComponent tc);
QuickEditor getQuickEditor(TargetComponent tc);
/**
* @Description 有些实现类中getQuickEditor会在获取editor后再填充面板这个方法只会获取editor不会填充面板
* @param: tc
* @return com.fr.design.selection.QuickEditor
* @Author Henry.Wang
* @Date 2021/4/2 15:02
**/
default QuickEditor getQuickEditorWithoutPopulate(TargetComponent tc){
return null;
}
}

49
designer-base/src/main/java/com/fr/design/worker/WorkerManager.java

@ -0,0 +1,49 @@
package com.fr.design.worker;
import java.util.HashMap;
import java.util.Map;
import javax.swing.SwingWorker;
import org.jetbrains.annotations.Nullable;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/2
*/
public class WorkerManager {
private static final WorkerManager INSTANCE = new WorkerManager();
private Map<String, SwingWorker> workerMap = new HashMap<>();
public static WorkerManager getInstance() {
return INSTANCE;
}
@Nullable
public SwingWorker getWorker(String taskName) {
return workerMap.get(taskName);
}
public boolean isCompleted(String taskName) {
SwingWorker worker = getWorker(taskName);
return worker == null || worker.isDone();
}
public void registerWorker(String taskName, SwingWorker worker) {
workerMap.put(taskName, worker);
}
public void removeWorker(String taskName) {
workerMap.remove(taskName);
}
public void cancelWorker(String taskName) {
SwingWorker worker = getWorker(taskName);
if (worker != null && !worker.isDone()) {
worker.cancel(true);
removeWorker(taskName);
}
}
}

28
designer-base/src/main/java/com/fr/design/worker/open/OpenResult.java

@ -0,0 +1,28 @@
package com.fr.design.worker.open;
import com.fr.base.io.BaseBook;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/13
*/
public class OpenResult<T extends BaseBook, R> {
private final T baseBook;
private final R ref;
public OpenResult(T baseBook, R r) {
this.baseBook = baseBook;
this.ref = r;
}
public T getBaseBook() {
return baseBook;
}
public R getRef() {
return ref;
}
}

154
designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java

@ -0,0 +1,154 @@
package com.fr.design.worker.open;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.WorkerManager;
import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* 模板打开的worker
*
* @author hades
* @version 10.0
* Created by hades on 2021/4/9
*/
public class OpenWorker<T> extends SwingWorker<T, Void> {
private static final int TIME_OUT = 400;
private final Callable<T> callable;
private final JTemplate<?, ?> template;
private Callable<JTemplate<?, ?>> templateCallable;
private boolean slowly = false;
private String taskName;
private T result;
public OpenWorker(Callable<T> callable, JTemplate<?, ?> template) {
this.callable = callable;
this.template = template;
}
@Override
protected T doInBackground() throws Exception {
return this.callable.call();
}
@Override
protected void done() {
try {
result = get();
} catch (CancellationException ignored) {
return;
} catch (Throwable t) {
processFailed();
Throwable cause = t.getCause();
if (cause instanceof DecryptTemplateException) {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
}
if (cause instanceof ChartNotFoundException) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
FineLoggerFactory.getLogger().error(t.getMessage(), t);
return;
}
// 后续动作
processResult();
}
private void processResult() {
this.template.setOpening(false);
if (slowly && templateCallable != null) {
try {
JTemplate<?, ?> book = templateCallable.call();
FILE tplFile = book.getEditingFILE();
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
// 当前tab页是正在打开的模板
if (ComparatorUtils.equals(currentTemplate.getEditingFILE(), tplFile)) {
currentTemplate.whenClose();
DesignerContext.getDesignerFrame().addAndActivateJTemplate(book);
HistoryTemplateListCache.getInstance().replaceCurrentEditingTemplate(book);
} else {
// 当前tab页是其他模板
for (int i = 0, len = HistoryTemplateListCache.getInstance().getHistoryCount(); i < len; i++) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getTemplate(i);
if (ComparatorUtils.equals(template.getEditingFILE(), book.getEditingFILE())) {
template.whenClose();
HistoryTemplateListCache.getInstance().getHistoryList().set(i, book);
break;
}
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName);
}
private void processFailed() {
this.template.setOpenFailed(true);
this.template.setOpening(false);
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover();
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName);
}
public void addCallBack(Callable<JTemplate<?, ?>> templateCallable) {
this.templateCallable = templateCallable;
}
public void start(String taskName) {
this.taskName = taskName;
this.template.setOpening(true);
this.execute();
WorkerManager.getInstance().registerWorker(taskName, this);
}
public T getResult() {
if (result != null) {
return result;
}
try {
return this.get(TIME_OUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
slowly = true;
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
WorkerManager.getInstance().removeWorker(taskName);
}
return null;
}
}

75
designer-base/src/main/java/com/fr/design/worker/save/CallbackSaveWorker.java

@ -0,0 +1,75 @@
package com.fr.design.worker.save;
import com.fr.common.util.Collections;
import com.fr.design.mainframe.JTemplate;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
/**
* 保存之后需要做些外部回调
*
* @author hades
* @version 10.0
* Created by hades on 2021/4/8
*/
public class CallbackSaveWorker extends SaveWorker {
private List<Runnable> successRunnableList;
private List<Runnable> failRunnableList;
public CallbackSaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) {
super(callable, template);
}
@Override
protected void done() {
super.done();
if (success) {
fireRunnable(successRunnableList);
} else {
fireRunnable(failRunnableList);
}
successRunnableList = null;
failRunnableList = null;
}
private void fireRunnable(List<Runnable> list) {
if (Collections.isEmpty(list)) {
return;
}
for (Runnable runnable : list) {
runnable.run();
}
}
private void addCallback(List<Runnable> runnableList, Runnable runnable) {
if (runnableList == null) {
runnableList = new LinkedList<>();
}
if (runnable != null) {
runnableList.add(runnable);
}
}
public void addSuccessCallback(Runnable successRunnable) {
if (successRunnableList == null) {
successRunnableList = new LinkedList<>();
}
if (successRunnable != null) {
successRunnableList.add(successRunnable);
}
}
public void addFailCallback(Runnable failRunnable) {
if (failRunnableList == null) {
failRunnableList = new LinkedList<>();
}
if (failRunnable != null) {
failRunnableList.add(failRunnable);
}
}
}

37
designer-base/src/main/java/com/fr/design/worker/save/EmptyCallBackSaveWorker.java

@ -0,0 +1,37 @@
package com.fr.design.worker.save;
import com.fr.design.mainframe.JTemplate;
import java.util.concurrent.Callable;
/**
* 空实现
*
* @author hades
* @version 10.0
* Created by hades on 2021/4/9
*/
public class EmptyCallBackSaveWorker extends CallbackSaveWorker {
public EmptyCallBackSaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) {
super(callable, template);
}
public EmptyCallBackSaveWorker() {
this(null, null);
}
@Override
protected Boolean doInBackground() throws Exception {
return false;
}
@Override
protected void done() {
// do nothing
}
@Override
public void start(String taskName) {
// do nothing
}
}

97
designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java

@ -0,0 +1,97 @@
package com.fr.design.worker.save;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.WorkerManager;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
/**
* 模板保存的worker
*
* @author hades
* @version 10.0
* Created by hades on 2021/4/1
*/
public class SaveWorker extends SwingWorker<Boolean, Void> {
private static final int TIME_OUT = 400;
private final Callable<Boolean> callable;
private String taskName;
private final JTemplate<?, ?> template;
protected boolean success;
private boolean slowly;
public SaveWorker(Callable<Boolean> callable, JTemplate<?, ?> template) {
this.callable = callable;
this.template = template;
}
@Override
protected Boolean doInBackground() throws Exception {
return callable.call();
}
@Override
protected void done() {
try {
success = get();
} catch (Exception e) {
processResult();
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.ERROR_MESSAGE);
return;
}
processResult();
}
private void processResult() {
this.template.setSaving(false);
// 恢复界面
if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) {
DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().hideCover();
}
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName);
}
public void start(String taskName) {
this.taskName = taskName;
this.template.setSaving(true);
this.execute();
// worker纳入管理
WorkerManager.getInstance().registerWorker(taskName, this);
try {
this.get(TIME_OUT, TimeUnit.MILLISECONDS);
} catch (TimeoutException timeoutException) {
slowly = true;
// 开始禁用
EastRegionContainerPane.getInstance().updateAllPropertyPane();
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover();
DesignerFrameFileDealerPane.getInstance().stateChange();
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
WorkerManager.getInstance().removeWorker(taskName);
}
}
}

3
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -913,9 +913,8 @@ public class FILEChooserPane extends BasicPane {
private boolean access(FILE selectedFile) {
boolean access = false;
boolean access = true;
try {
access = FRContext.getOrganizationOperator().canAccess(selectedFile.getPath());
if (selectedFile.isEnvFile() && selectedFile instanceof FileNodeFILE) {
FileNodeFILE fileNodeFILE = ((FileNodeFILE) selectedFile);
access = access && fileNodeFILE.hasFullAuth() && NodeAuthProcessor.getInstance().checkFileNodeAuth(new FileNode(fileNodeFILE.getPath(), fileNodeFILE.isDirectory()));

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/check.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

BIN
designer-base/src/main/resources/com/fr/design/images/buttonicon/run24.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 B

After

Width:  |  Height:  |  Size: 736 B

16
designer-base/src/main/resources/com/fr/design/images/control/addPopup_disabled.svg

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="16px" viewBox="0 0 24 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>编组</title>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.3">
<g id="工具栏/导入数据集" transform="translate(-8.000000, -6.000000)">
<g id="编组" transform="translate(8.000000, 6.000000)">
<g fill="#333334" id="Combined-Shape">
<path d="M8,2 C8.38659932,2 8.7,2.32097101 8.7,2.69703907 L8.7,7.3 L13.3029609,7.3 C13.6558446,7.3 13.9474813,7.56107882 13.9936369,7.90444795 L14,8 C14,8.38659932 13.679029,8.7 13.3029609,8.7 L8.7,8.699 L8.7,13.3029609 C8.7,13.6558446 8.43892118,13.9474813 8.09555205,13.9936369 L8,14 C7.61340068,14 7.3,13.679029 7.3,13.3029609 L7.3,8.699 L2.69703907,8.7 C2.34415536,8.7 2.05251868,8.43892118 2.00636315,8.09555205 L2,8 C2,7.61340068 2.32097101,7.3 2.69703907,7.3 L7.3,7.3 L7.3,2.69703907 C7.3,2.34415536 7.56107882,2.05251868 7.90444795,2.00636315 L8,2 Z"></path>
</g>
<g transform="translate(16.000000, 4.000000)" fill="#8F8F92" id="Rectangle-6">
<path d="M2,0.997030139 C2,0.446385598 2.31387329,0.313873291 2.70591205,0.705912054 L6,4 L2.70591205,7.29408795 C2.31604759,7.68395241 2,7.54696369 2,7.00296986 L2,0.997030139 Z" transform="translate(4.000000, 4.000000) rotate(90.000000) translate(-4.000000, -4.000000) "></path>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

14
designer-base/src/main/resources/com/fr/design/images/control/addPopup_normal.svg

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="16px" viewBox="0 0 24 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>编组备份</title>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="编组备份">
<g id="Combined-Shape" fill="#333334">
<path d="M8,2 C8.38659932,2 8.7,2.32097101 8.7,2.69703907 L8.7,7.3 L13.3029609,7.3 C13.6558446,7.3 13.9474813,7.56107882 13.9936369,7.90444795 L14,8 C14,8.38659932 13.679029,8.7 13.3029609,8.7 L8.7,8.699 L8.7,13.3029609 C8.7,13.6558446 8.43892118,13.9474813 8.09555205,13.9936369 L8,14 C7.61340068,14 7.3,13.679029 7.3,13.3029609 L7.3,8.699 L2.69703907,8.7 C2.34415536,8.7 2.05251868,8.43892118 2.00636315,8.09555205 L2,8 C2,7.61340068 2.32097101,7.3 2.69703907,7.3 L7.3,7.3 L7.3,2.69703907 C7.3,2.34415536 7.56107882,2.05251868 7.90444795,2.00636315 L8,2 Z"></path>
</g>
<g id="Rectangle-6" transform="translate(16.000000, 4.000000)" fill="#8F8F92">
<path d="M2,0.997030139 C2,0.446385598 2.31387329,0.313873291 2.70591205,0.705912054 L6,4 L2.70591205,7.29408795 C2.31604759,7.68395241 2,7.54696369 2,7.00296986 L2,0.997030139 Z" transform="translate(4.000000, 4.000000) rotate(90.000000) translate(-4.000000, -4.000000) "></path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/correct.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 B

BIN
designer-base/src/main/resources/com/fr/design/images/error.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

BIN
designer-base/src/main/resources/com/fr/design/images/file/grey_saving_close.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/file/white_saving_close.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Down_16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Icon_Narrow_Right_16x16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 B

BIN
designer-base/src/main/resources/com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 752 B

After

Width:  |  Height:  |  Size: 760 B

BIN
designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/waiting.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

BIN
designer-base/src/main/resources/com/fr/design/images/warnings/warning32.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

12
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java

@ -23,6 +23,9 @@ import org.apache.batik.swing.svg.SVGFileFilter;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
@ -30,9 +33,6 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/**
* 自定义地图界面.
@ -117,7 +117,11 @@ refreshAreaNameBox();
int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame());
if (returnVal != JFileChooser.CANCEL_OPTION) {
File selectedFile = svgFileChooser.getSelectedFile();
lastSelectPath = selectedFile.getAbsolutePath();
try {
lastSelectPath = selectedFile.getCanonicalPath();
} catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
if (selectedFile != null && selectedFile.isFile()) {
imageShowPane.setSvgMap(selectedFile.getPath());
imageShowPane.repaint();

2
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java

@ -11,7 +11,6 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.ChartHyperEditPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory;
@ -122,7 +121,6 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane<ChartHyperPopli
hyperEditPane.updateHyperLink(chartHyperlink);
chartHyperlink.setChartCollection(chartComponent.update());
DesignModuleFactory.getChartPropertyPane().getChartEditPane().fire();// 响应整个图表保存事件等.
if (itemNameTextField != null) {
chartHyperlink.setItemName(this.itemNameTextField.getText());
}

163
designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java

@ -3,48 +3,165 @@
*/
package com.fr.design.mainframe;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.*;
import java.awt.*;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.charttypes.ChartTypeManager;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.UITitlePanel;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.utils.gui.GUICoreUtils;
public class ChartPropertyPane extends MiddleChartPropertyPane{
import javax.swing.BorderFactory;
import javax.swing.Icon;
import java.awt.BorderLayout;
import java.awt.Component;
public class ChartPropertyPane extends BaseChartPropertyPane {
/**
* 创建图表属性表实例.
*/
private synchronized static ChartPropertyPane getInstance() {
//todo
//创建新图表时,创建属性表配置面板
singleton = new ChartPropertyPane();
return singleton;
return new ChartPropertyPane();
}
private static ChartPropertyPane singleton;
protected TargetComponentContainer container = new TargetComponentContainer();
protected ChartEditPane chartEditPane;
private ChartPropertyPane() {
initComponent();
}
protected void initComponent() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
}
@Override
protected void createNameLabel() {
nameLabel = new UILabel() {
public void updateChartEditPane(String plotID) {
chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID);
chartEditPane.setContainer(container);
resetChartEditPane();
}
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 18);
public ChartEditPaneProvider getChartEditPane() {
return chartEditPane;
}
};
nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0));
nameLabel.setHorizontalAlignment(SwingConstants.CENTER);
protected void resetChartEditPane() {
removeChartEditPane();
addChartEditPane(this.chartEditPane);
validate();
repaint();
revalidate();
}
@Override
protected void createMainPane() {
/**
* @Description 去除BorderLayout.CENTER位置的元素
* @return void
* @Author Henry.Wang
* @Date 2021/4/9 13:54
**/
private void removeChartEditPane() {
BorderLayout layout = (BorderLayout) this.getLayout();
Component component = layout.getLayoutComponent(BorderLayout.CENTER);
if (component != null)
this.remove(component);
}
/**
* @Description 把chartEditPane加到BorderLayout.CENTER中
* @param: chartEditPane
* @return void
* @Author Henry.Wang
* @Date 2021/4/9 13:55
**/
private void addChartEditPane(ChartEditPane chartEditPane) {
this.add(chartEditPane, BorderLayout.CENTER);
}
@Override
protected JComponent createNorthComponent() {
return nameLabel;
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param ePane 面板
*/
public void populateChartPropertyPane(ChartCollection collection, TargetComponent<?> ePane) {
String chartID = collection.getSelectedChartProvider(ChartProvider.class).getID();
updateChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID());
setSupportCellData(true);
this.container.setEPane(ePane);
if (ChartTypeManager.getInstance().chartExit(chartID)) {
chartEditPane.populate(collection);
} else {
GUICoreUtils.setEnabled(chartEditPane, false);
}
}
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param ePane 面板
*/
public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent<?> ePane) {
if (collection instanceof ChartCollection) {
populateChartPropertyPane((ChartCollection) collection, ePane);
}
}
public synchronized static void clear() {
singleton = null;
/**
* 返回View的标题.
*/
public String getViewTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell_Element_Property_Table");
}
/**
* 返回View的Icon地址.
*/
public Icon getViewIcon() {
return BaseUtils.readIcon("/com/fr/design/images/m_report/qb.png");
}
/**
* 预定义定位
* @return 定位
*/
public Location preferredLocation() {
return Location.WEST_BELOW;
}
/**
* 创建标题Panel
* @return 标题panel
*/
public UITitlePanel createTitlePanel() {
return new UITitlePanel(this);
}
/**
* 刷新Dockview
*/
public void refreshDockingView() {
// TODO Auto-generated method stub
}
/**
* 设置是否支持单元格数据.
*/
public void setSupportCellData(boolean supportCellData) {
if (chartEditPane != null) {
chartEditPane.setSupportCellData(supportCellData);
}
}
}

165
designer-chart/src/main/java/com/fr/design/mainframe/MiddleChartPropertyPane.java

@ -1,165 +0,0 @@
/*
* Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved.
*/
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.chart.BaseChartCollection;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.ChartEditPaneProvider;
import com.fr.design.gui.frpane.UITitlePanel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itabpane.TitleChangeListener;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.stable.StableUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import java.awt.BorderLayout;
public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{
protected TargetComponentContainer container = new TargetComponentContainer();
protected UILabel nameLabel;
protected ChartEditPane chartEditPane;
public MiddleChartPropertyPane() {
initComponenet();
}
protected void initComponenet() {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
createNameLabel();
//去掉上方名字,先注释掉
// this.add(createNorthComponent(), BorderLayout.NORTH);
chartEditPane = StableUtils.construct(ChartEditPane.class);
chartEditPane.setSupportCellData(true);
}
public void addChartEditPane(String plotID){
chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID);
chartEditPane.setSupportCellData(true);
this.createMainPane();
setSureProperty();
}
protected abstract void createNameLabel();
protected abstract JComponent createNorthComponent();
protected abstract void createMainPane();
@Override
public ChartEditPaneProvider getChartEditPane() {
return chartEditPane;
}
public void setSureProperty() {
chartEditPane.setContainer(container);
chartEditPane.addTitleChangeListener(titleListener);
String tabname = chartEditPane.getSelectedTabName();
nameLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : ""));
resetChartEditPane();
}
protected void resetChartEditPane() {
remove(chartEditPane);
add(chartEditPane, BorderLayout.CENTER);
validate();
repaint();
revalidate();
}
protected TitleChangeListener titleListener = new TitleChangeListener() {
@Override
public void fireTitleChange(String addName) {
nameLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Property_Table") + '-' + addName);
}
};
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param ePane 面板
*/
public void populateChartPropertyPane(ChartCollection collection, TargetComponent<?> ePane) {
addChartEditPane(collection.getSelectedChartProvider(ChartProvider.class).getID());
setSupportCellData(true);
this.container.setEPane(ePane);
chartEditPane.populate(collection);
}
/**
* 感觉ChartCollection加载图表属性界面.
* @param collection 收集图表
* @param ePane 面板
*/
public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent<?> ePane) {
if (collection instanceof ChartCollection) {
populateChartPropertyPane((ChartCollection)collection, ePane);
}
}
// public void clear() {
// this.container.setEPane(null);
// chartEditPane.clear();
// getParent().remove(this);
// }
/**
* 返回View的标题.
*/
public String getViewTitle() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Cell_Element_Property_Table");
}
/**
* 返回View的Icon地址.
*/
public Icon getViewIcon() {
return BaseUtils.readIcon("/com/fr/design/images/m_report/qb.png");
}
/**
* 预定义定位
* @return 定位
*/
public Location preferredLocation() {
return Location.WEST_BELOW;
}
/**
* 创建标题Panel
* @return 标题panel
*/
public UITitlePanel createTitlePanel() {
return new UITitlePanel(this);
}
/**
* 刷新Dockview
*/
public void refreshDockingView() {
// TODO Auto-generated method stub
}
/**
* 设置是否支持单元格数据.
*/
public void setSupportCellData(boolean supportCellData) {
if(chartEditPane != null) {
chartEditPane.setSupportCellData(supportCellData);
}
}
}

22
designer-chart/src/main/java/com/fr/van/chart/designer/component/format/TargetValueFormatPaneWithCheckBox.java

@ -0,0 +1,22 @@
package com.fr.van.chart.designer.component.format;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-04-06
*/
public class TargetValueFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox {
public TargetValueFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) {
super(parent, showOnPane);
}
@Override
protected String getCheckBoxText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Target_Value");
}
}

32
designer-chart/src/main/java/com/fr/van/chart/designer/component/format/VanChartFormatPaneWithCheckBox.java

@ -12,13 +12,12 @@ import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.stable.Constants;
import javax.swing.JPanel;
import java.text.Format;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.text.Format;
import java.util.Map;
/**
* Created by Mitisky on 16/2/23.
@ -54,32 +53,7 @@ public abstract class VanChartFormatPaneWithCheckBox extends JPanel{
this.add(formatButton, BorderLayout.EAST);
initFormatListener();
isSelectedBox.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
isDirty = true;
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
isSelectedBox.addChangeListener((e)-> isDirty = true);
}
protected abstract String getCheckBoxText();

64
designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java

@ -1,6 +1,11 @@
package com.fr.van.chart.designer.component.label;
import com.fr.design.i18n.Toolkit;
import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.gauge.attr.GaugeValueTooltipContent;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.format.TargetValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
@ -11,9 +16,11 @@ import java.awt.Component;
*/
public class LabelContentPaneWithCateValue extends GaugeLabelContentPane {
private TargetValueFormatPaneWithCheckBox targetValueFormatPane;
private static final long serialVersionUID = -8286902939543416431L;
public LabelContentPaneWithCateValue(VanChartStylePane parent, JPanel showOnPane){
public LabelContentPaneWithCateValue(VanChartStylePane parent, JPanel showOnPane) {
super(parent, showOnPane);
}
@ -21,14 +28,59 @@ public class LabelContentPaneWithCateValue extends GaugeLabelContentPane {
return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, panel);
}
protected double[] getRowSize(double p){
return new double[]{p,p};
@Override
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) {
super.initFormatPane(parent, showOnPane);
setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane) {
@Override
protected String getCheckBoxText() {
return Toolkit.i18nText("Fine-Design_Chart_Value_Pointer");
}
});
this.targetValueFormatPane = new TargetValueFormatPaneWithCheckBox(parent, showOnPane);
}
protected double[] getRowSize(double p) {
return new double[]{p, p, p};
}
protected Component[][] getPaneComponents(){
protected Component[][] getPaneComponents() {
return new Component[][]{
new Component[]{getCategoryNameFormatPane(),null},
new Component[]{getValueFormatPane(),null},
new Component[]{getCategoryNameFormatPane(), null},
new Component[]{getValueFormatPane(), null},
new Component[]{targetValueFormatPane, null},
};
}
@Override
protected void populateFormatPane(AttrTooltipContent attrTooltipContent) {
super.populateFormatPane(attrTooltipContent);
if (attrTooltipContent instanceof GaugeValueTooltipContent) {
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) attrTooltipContent;
targetValueFormatPane.populate(gaugeValueTooltipContent.getTargetValueFormat());
}
}
@Override
protected void updateFormatPane(AttrTooltipContent attrTooltipContent) {
super.updateFormatPane(attrTooltipContent);
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) attrTooltipContent;
targetValueFormatPane.update(gaugeValueTooltipContent.getTargetValueFormat());
}
@Override
public void setDirty(boolean isDirty) {
super.setDirty(isDirty);
targetValueFormatPane.setDirty(isDirty);
}
@Override
public boolean isDirty() {
return super.isDirty() || targetValueFormatPane.isDirty();
}
protected AttrTooltipContent createAttrTooltip() {
return new GaugeValueTooltipContent();
}
}

26
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java

@ -1,9 +1,7 @@
package com.fr.van.chart.designer.component.tooltip;
import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox;
import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.JPanel;
@ -25,21 +23,27 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) {
super.initFormatPane(parent, showOnPane);
setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane));
setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane) {
@Override
protected String getCheckBoxText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Change_Value");
}
});
setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane));
}
protected double[] getRowSize(double p){
return new double[]{p,p,p,p,p};
protected double[] getRowSize(double p) {
return new double[]{p, p, p, p, p, p};
}
protected Component[][] getPaneComponents(){
protected Component[][] getPaneComponents() {
return new Component[][]{
new Component[]{getCategoryNameFormatPane(),null},
new Component[]{getValueFormatPane(),null},
new Component[]{getChangedValueFormatPane(),null},
new Component[]{getPercentFormatPane(),null},
new Component[]{getChangedPercentFormatPane(),null},
new Component[]{getCategoryNameFormatPane(), null},
new Component[]{getValueFormatPane(), null},
new Component[]{getTargetValueFormatPane(), null},
new Component[]{getChangedValueFormatPane(), null},
new Component[]{getPercentFormatPane(), null},
new Component[]{getChangedPercentFormatPane(), null},
};
}
}

86
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java

@ -6,8 +6,12 @@ import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipTargetValueFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
import com.fr.plugin.chart.gauge.attr.GaugeValueTooltipContent;
import com.fr.van.chart.designer.component.VanChartTooltipContentPane;
import com.fr.van.chart.designer.component.format.TargetValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox;
import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane;
import com.fr.van.chart.designer.component.richText.VanChartFieldListPane;
import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel;
@ -24,19 +28,38 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane
private static final long serialVersionUID = -1973565663365672717L;
public TooltipContentPaneWithOutSeries(VanChartStylePane parent, JPanel showOnPane){
private TargetValueFormatPaneWithCheckBox targetValueFormatPane;
public TooltipContentPaneWithOutSeries(VanChartStylePane parent, JPanel showOnPane) {
super(parent, showOnPane);
}
protected double[] getRowSize(double p){
return new double[]{p,p,p};
public TargetValueFormatPaneWithCheckBox getTargetValueFormatPane() {
return targetValueFormatPane;
}
@Override
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) {
super.initFormatPane(parent, showOnPane);
setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane) {
@Override
protected String getCheckBoxText() {
return Toolkit.i18nText("Fine-Design_Chart_Value_Pointer");
}
});
this.targetValueFormatPane = new TargetValueFormatPaneWithCheckBox(parent, showOnPane);
}
protected double[] getRowSize(double p) {
return new double[]{p, p, p, p};
}
protected Component[][] getPaneComponents(){
protected Component[][] getPaneComponents() {
return new Component[][]{
new Component[]{getCategoryNameFormatPane(),null},
new Component[]{getValueFormatPane(),null},
new Component[]{getPercentFormatPane(),null},
new Component[]{getCategoryNameFormatPane(), null},
new Component[]{getValueFormatPane(), null},
new Component[]{targetValueFormatPane, null},
new Component[]{getPercentFormatPane(), null}
};
}
@ -57,7 +80,8 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane
protected String[] getRichTextFieldNames() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"),
Toolkit.i18nText("Fine-Design_Chart_Use_Value"),
Toolkit.i18nText("Fine-Design_Chart_Value_Pointer"),
Toolkit.i18nText("Fine-Design_Chart_Target_Value"),
Toolkit.i18nText("Fine-Design_Chart_Use_Percent")
};
}
@ -66,7 +90,53 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane
return new AttrTooltipFormat[]{
new AttrTooltipCategoryFormat(),
new AttrTooltipValueFormat(),
new AttrTooltipTargetValueFormat(),
new AttrTooltipPercentFormat()
};
}
@Override
protected void populateFormatPane(AttrTooltipContent attrTooltipContent) {
super.populateFormatPane(attrTooltipContent);
if (attrTooltipContent instanceof GaugeValueTooltipContent) {
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) attrTooltipContent;
targetValueFormatPane.populate(gaugeValueTooltipContent.getTargetValueFormat());
}
}
@Override
protected void updateFormatPane(AttrTooltipContent attrTooltipContent) {
super.updateFormatPane(attrTooltipContent);
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) attrTooltipContent;
targetValueFormatPane.update(gaugeValueTooltipContent.getTargetValueFormat());
}
protected void updateTooltipFormat(AttrTooltipContent target, AttrTooltipContent source) {
super.updateTooltipFormat(target, source);
if (target instanceof GaugeValueTooltipContent && source instanceof GaugeValueTooltipContent) {
GaugeValueTooltipContent targetGauge = (GaugeValueTooltipContent) target;
GaugeValueTooltipContent sourceGauge = (GaugeValueTooltipContent) source;
targetGauge.setRichTextTargetValueFormat(sourceGauge.getRichTextTargetValueFormat());
}
}
@Override
public void setDirty(boolean isDirty) {
super.setDirty(isDirty);
targetValueFormatPane.setDirty(isDirty);
}
@Override
public boolean isDirty() {
return super.isDirty() || targetValueFormatPane.isDirty();
}
protected AttrTooltipContent createAttrTooltip() {
GaugeValueTooltipContent gaugeValueTooltipContent = new GaugeValueTooltipContent();
gaugeValueTooltipContent.setCustom(false);
gaugeValueTooltipContent.getTargetValueFormat().setEnable(true);
gaugeValueTooltipContent.getRichTextTargetValueFormat().setEnable(true);
return gaugeValueTooltipContent;
}
}

35
designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/VanChartFieldListPaneWithOutSeries.java

@ -1,9 +1,15 @@
package com.fr.van.chart.designer.component.tooltip;
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.AttrTooltipTargetValueFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
import com.fr.plugin.chart.gauge.attr.GaugeValueTooltipContent;
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;
@ -12,13 +18,26 @@ import java.util.List;
public class VanChartFieldListPaneWithOutSeries extends VanChartFieldListPane {
private VanChartFieldButton targetValueButton;
public VanChartFieldListPaneWithOutSeries(VanChartFieldAttrPane fieldAttrPane, ModernUIPane<VanChartRichEditorModel> richEditorPane) {
super(fieldAttrPane, richEditorPane);
}
protected void initDefaultFieldButton() {
super.initDefaultFieldButton();
VanChartFieldListener listener = getFieldListener();
setValueButton(new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Value_Pointer"),
new AttrTooltipValueFormat(), false, listener));
targetValueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Target_Value"),
new AttrTooltipTargetValueFormat(), false, listener);
}
protected void addDefaultFieldButton(JPanel fieldPane) {
fieldPane.add(getCategoryNameButton());
fieldPane.add(getValueButton());
fieldPane.add(targetValueButton);
fieldPane.add(getPercentButton());
}
@ -27,8 +46,24 @@ public class VanChartFieldListPaneWithOutSeries extends VanChartFieldListPane {
fieldButtonList.add(getCategoryNameButton());
fieldButtonList.add(getValueButton());
fieldButtonList.add(targetValueButton);
fieldButtonList.add(getPercentButton());
return fieldButtonList;
}
public void populateDefaultField(AttrTooltipContent tooltipContent) {
super.populateDefaultField(tooltipContent);
if (tooltipContent instanceof GaugeValueTooltipContent) {
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) tooltipContent;
populateButtonFormat(targetValueButton, gaugeValueTooltipContent.getRichTextTargetValueFormat());
}
}
public void updateDefaultField(AttrTooltipContent tooltipContent) {
super.updateDefaultField(tooltipContent);
GaugeValueTooltipContent gaugeValueTooltipContent = (GaugeValueTooltipContent) tooltipContent;
updateButtonFormat(targetValueButton, gaugeValueTooltipContent.getRichTextTargetValueFormat());
}
}

4
designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java

@ -27,6 +27,10 @@ public class FormModelAdapter extends DesignModelAdapter<Form, BaseJForm<Form>>
super(jForm);
}
public FormModelAdapter(BaseJForm<Form> jTemplate, Parameter[] parameters) {
super(jTemplate, parameters);
}
/**
* 环境改变.
*/

8
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -127,6 +127,9 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
super(new Form(new WBorderLayout("form")), "Form");
}
public JForm(Form form, FILE file, Parameter[] parameters) {
super(form, file, parameters);
}
public JForm(Form form, FILE file) {
super(form, file);
@ -679,6 +682,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
return new FormModelAdapter(this);
}
@Override
protected FormModelAdapter createDesignModel(Parameter[] parameters) {
return new FormModelAdapter(this, parameters);
}
@Override
public JPanel[] toolbarPanes4Form() {
return this.index == FORM_TAB ?

23
designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java

@ -1,12 +1,13 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.gui.ibutton.UIForbiddenButtonUI;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
@ -20,6 +21,7 @@ import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.io.Serializable;
import javax.swing.plaf.ButtonUI;
/*
*august: 控件按钮
@ -73,6 +75,10 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
@Override
public void mouseDragged(MouseEvent e) {
if (!isEnabled()) {
return;
}
if (DesignerMode.isAuthorityEditing()) {
return;
}
@ -164,4 +170,19 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public ButtonUI getUI() {
return new UIForbiddenButtonUI();
}
@Override
public boolean isEnabled() {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean enable = true;
if (template != null) {
enable = super.isEnabled() && template.checkEnable();
}
return enable;
}
}

18
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java

@ -14,6 +14,8 @@ import com.fr.design.widget.FRWidgetFactory;
import com.fr.form.main.Form;
import com.fr.form.ui.FormWidgetHelper;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout;
import com.fr.form.ui.container.WLayout;
import com.fr.form.ui.container.WSortLayout;
import com.fr.form.ui.widget.CRBoundsWidget;
@ -123,9 +125,7 @@ public class MobileComponentFrozenPane extends BasicPane {
}
private List<String> frozenWidgets() {
Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
WLayout container = form.getContainer();
WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1);
WSortLayout wSortLayout = getBodyWSortLayout();
List<String> list = wSortLayout.getNonContainerWidgetList();
List<String> widgets = new ArrayList<>();
for (String value : list) {
@ -137,6 +137,18 @@ public class MobileComponentFrozenPane extends BasicPane {
return widgets;
}
private WSortLayout getBodyWSortLayout() {
Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
WLayout container = form.getContainer();
WFitLayout wFitLayout = (WFitLayout) container.getWidget(container.getWidgetCount() - 1);
WSortLayout wSortLayout = wFitLayout;
if (wFitLayout.getBodyLayoutType() == WBodyLayoutType.ABSOLUTE) {
CRBoundsWidget boundsWidget = (CRBoundsWidget) wFitLayout.getWidget(0);
wSortLayout = (WSortLayout) boundsWidget.getWidget();
}
return wSortLayout;
}
@Override
protected String title4PopupWindow() {
return "ComponentFrozenPane";

5
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -271,6 +271,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
@Override
public void mouseClicked(MouseEvent e) {
//如果没有格式刷,点击时就是想使用格式刷
if (!formatBrush.isEnabled()) {
return;
}
if (e.getClickCount() == 1) {
if (!formatBrush.isSelected()) {
DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE);
@ -529,7 +532,7 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
|| DesignModeContext.isAuthorityEditing()) {
try {
//旧选中内容编辑器释放模板对象
QuickEditor editor = this.getCurrentEditor();
QuickEditor editor = this.selection.getQuickEditorWithoutPopulate(this);
if (editor != null) {
editor.release();
}

9
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -145,6 +145,10 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
super(workBook, fileName);
populateReportParameterAttr();
}
public JWorkBook(WorkBook workBook, FILE file, Parameter[] parameters) {
super(workBook, file, parameters);
populateReportParameterAttr();
}
public JWorkBook(WorkBook workBook, FILE file) {
super(workBook, file);
@ -871,6 +875,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return new WorkBookModelAdapter(this);
}
@Override
protected WorkBookModelAdapter createDesignModel(Parameter[] parameters) {
return new WorkBookModelAdapter(this, parameters);
}
/**
* 表单的工具栏
*

3
designer-realize/src/main/java/com/fr/design/mainframe/WorkBookModelAdapter.java

@ -36,6 +36,9 @@ public class WorkBookModelAdapter extends DesignModelAdapter<WorkBook, JWorkBook
super(jworkbook);
}
public WorkBookModelAdapter(JWorkBook jTemplate, Parameter[] parameters) {
super(jTemplate, parameters);
}
/**
* 重命名TableData后的一些操作

31
designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java

@ -1,10 +1,16 @@
package com.fr.design.mainframe.app;
import com.fr.base.Parameter;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.worker.open.OpenResult;
import com.fr.design.worker.open.OpenWorker;
import com.fr.file.FILE;
import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook;
import com.fr.report.worksheet.WorkSheet;
import java.util.concurrent.Callable;
/**
* Created by juhaoyu on 2018/6/27.
@ -20,8 +26,29 @@ abstract class AbstractWorkBookApp implements App<WorkBook> {
@Override
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) {
return new JWorkBook(asIOFile(tplFile), tplFile);
JWorkBook emptyTemplate = new JWorkBook(new WorkBook(new WorkSheet()), tplFile);
OpenWorker<OpenResult<WorkBook, Parameter[]>> worker = new OpenWorker<>(
new Callable<OpenResult<WorkBook, Parameter[]>>() {
@Override
public OpenResult<WorkBook, Parameter[]> call() {
WorkBook workBook = asIOFile(tplFile);
return new OpenResult<>(workBook, workBook.getParameters());
}
}, emptyTemplate);
worker.addCallBack(new Callable<JTemplate<?, ?>>() {
@Override
public JTemplate<?, ?> call() throws Exception {
OpenResult<WorkBook, Parameter[]> result = worker.getResult();
return new JWorkBook(result.getBaseBook(), tplFile, result.getRef());
}
});
worker.start(tplFile.getPath());
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", tplFile.getName()) + "...");
OpenResult<WorkBook, Parameter[]> result = worker.getResult();
if (result != null) {
return new JWorkBook(result.getBaseBook(), tplFile);
}
return emptyTemplate;
}
@Override

11
designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java

@ -3,6 +3,7 @@ package com.fr.design.mainframe.app;
import com.fr.base.BaseUtils;
import com.fr.base.Style;
import com.fr.base.TempNameStyle;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.config.ServerPreferenceConfig;
@ -12,6 +13,7 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.DecryptTemplateException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
@ -56,13 +58,11 @@ class CptApp extends AbstractWorkBookApp {
}
WorkBook tpl = new WorkBook();
// richer:打开报表通知
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", file.getName()) + "...");
TempNameStyle namestyle = TempNameStyle.getInstance();
namestyle.clear();
try {
tpl.readStream(file.asInputStream());
} catch (DecryptTemplateException e) {
} catch (DecryptTemplateException | ChartNotFoundException e) {
throw e;
} catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);
@ -85,8 +85,13 @@ class CptApp extends AbstractWorkBookApp {
al.add((String) it.next());
}
if (!al.isEmpty()) {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
showConfirmDialog(al);
}
});
}
}
private static void showConfirmDialog(final ArrayList<String> namelist) {

3
designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.app;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.extension.FileExtension;
import com.fr.base.frpx.exception.FRPackageRunTimeException;
import com.fr.base.frpx.exception.InvalidWorkBookException;
@ -37,7 +38,7 @@ class CptxApp extends AbstractWorkBookApp {
long time = System.currentTimeMillis();
tpl = new WorkBookX(inputStream);
FineLoggerFactory.getLogger().error("cost: " + (System.currentTimeMillis() - time) + " ms");
} catch (DecryptTemplateException e) {
} catch (DecryptTemplateException | ChartNotFoundException e) {
throw e;
} catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);

38
designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

@ -1,22 +1,29 @@
package com.fr.design.mainframe.app;
import com.fr.base.Parameter;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.AbstractAppProvider;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DecodeDialog;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.open.OpenResult;
import com.fr.design.worker.open.OpenWorker;
import com.fr.exception.DecryptTemplateException;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.exception.TplLockedException;
import com.fr.file.FILE;
import com.fr.form.main.Form;
import com.fr.form.ui.container.WBorderLayout;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.bridge.StableFactory;
import java.util.HashMap;
import java.util.concurrent.Callable;
/**
* Created by juhaoyu on 2018/6/27.
@ -36,9 +43,32 @@ class FormApp extends AbstractAppProvider {
HashMap<String, Class> classType = new HashMap<String, Class>();
classType.put(Constants.ARG_0, Form.class);
classType.put(Constants.ARG_1, FILE.class);
classType.put(Constants.ARG_2, Parameter[].class);
JForm emptyForm = new JForm(new Form(new WBorderLayout("form")), tplFile);
OpenWorker<OpenResult<Form, Parameter[]>> worker = new OpenWorker<>(
new Callable<OpenResult<Form, Parameter[]>>() {
@Override
public OpenResult<Form, Parameter[]> call() throws Exception {
Form form = asIOFile(tplFile);
return new OpenResult<>(form, form.getParameters());
}
}, emptyForm);
worker.addCallBack(new Callable<JTemplate<?, ?>>() {
@Override
public JTemplate<?, ?> call() throws Exception {
OpenResult<Form, Parameter[]> result = worker.getResult();
return (JTemplate<Form, ?>) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG,
new Object[]{asIOFile(tplFile), tplFile}, classType, BaseJForm.class);
new Object[]{result.getBaseBook(), tplFile, result.getRef()}, classType, BaseJForm.class);
}
});
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Report_Template_Opening_And_Waiting", tplFile.getName()) + "...");
worker.start(tplFile.getPath());
OpenResult<Form, Parameter[]> result = worker.getResult();
if (result != null) {
return (JTemplate<Form, ?>) StableFactory.getMarkedInstanceObjectFromClass(BaseJForm.XML_TAG,
new Object[]{result.getBaseBook(), tplFile, new Parameter[0]}, classType, BaseJForm.class);
}
return emptyForm;
}
@Override
@ -54,11 +84,9 @@ class FormApp extends AbstractAppProvider {
// peter:打开新报表.
Form tpl = new Form();
// richer:打开报表通知
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("file.getName()", file.getName()) + "...");
try {
tpl.readStream(file.asInputStream());
} catch (DecryptTemplateException e) {
} catch (DecryptTemplateException | ChartNotFoundException e) {
throw e;
} catch (RemoteDesignPermissionDeniedException exp) {
FineLoggerFactory.getLogger().error(Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + file, exp);

14
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -733,6 +733,16 @@ public class CellSelection extends Selection {
@Override
public QuickEditor getQuickEditor(TargetComponent tc) {
QuickEditor editor = getQuickEditorWithoutPopulate(tc);
if (editor == null) {
return null;
}
editor.populate(tc);
return editor;
}
@Override
public QuickEditor getQuickEditorWithoutPopulate(TargetComponent tc) {
ElementCasePane ePane = (ElementCasePane) tc;
TemplateElementCase tplEC = ePane.getEditingElementCase();
TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row);
@ -744,10 +754,6 @@ public class CellSelection extends Selection {
value = value == null ? StringUtils.EMPTY : value;
//之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子
QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
if (editor == null) {
return null;
}
editor.populate(tc);
return editor;
}

11
designer-realize/src/main/java/com/fr/grid/selection/FloatSelection.java

@ -236,6 +236,15 @@ public class FloatSelection extends Selection {
@Override
public QuickEditor getQuickEditor(TargetComponent tc) {
QuickEditor editor = getQuickEditorWithoutPopulate(tc);
if (editor == null)
return null;
editor.populate(tc);
return editor;
}
@Override
public QuickEditor getQuickEditorWithoutPopulate(TargetComponent tc) {
ElementCasePane ePane = (ElementCasePane) tc;
FloatElement selectedFloat = ePane.getEditingElementCase().getFloatElement(selectedFloatName);
Object value = null;
@ -246,10 +255,10 @@ public class FloatSelection extends Selection {
value = value == null ? "" : value;
value = value instanceof Number ? value.toString() : value;
QuickEditor editor = ActionFactory.getFloatEditor(value.getClass());
editor.populate(tc);
return editor;
}
@Override
public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().removeAll();

7
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -17,6 +17,7 @@ import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIPreviewButton;
import com.fr.design.gui.ibutton.UISaveForbiddenButton;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.gui.itoolbar.UILargeToolbar;
@ -232,7 +233,7 @@ public class MainDesigner extends BaseDesigner {
public void actionPerformed(ActionEvent e) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jt.stopEditing();
jt.saveTemplate();
jt.saveDirectly();
jt.requestFocus();
}
});
@ -270,12 +271,12 @@ public class MainDesigner extends BaseDesigner {
}
private void createRunButton(UILargeToolbar largeToolbar) {
run = new UIPreviewButton(new UIButton(UIConstants.PAGE_BIG_ICON) {
run = new UIPreviewButton(new UISaveForbiddenButton(UIConstants.PAGE_BIG_ICON) {
@Override
public Dimension getPreferredSize() {
return new Dimension(34, 34);
}
}, new UIButton(UIConstants.PREVIEW_DOWN) {
}, new UISaveForbiddenButton(UIConstants.PREVIEW_DOWN) {
@Override
public Dimension getPreferredSize() {
return new Dimension(34, 10);

7
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -27,6 +27,7 @@ import com.fr.design.actions.insert.flot.ImageFloatAction;
import com.fr.design.actions.insert.flot.TextBoxFloatAction;
import com.fr.design.bridge.DesignToolbarProvider;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.env.DesignerWorkspaceLoader;
import com.fr.design.form.parameter.FormParaDesigner;
import com.fr.design.fun.ElementUIProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
@ -145,6 +146,7 @@ public class DesignerActivator extends Activator {
designerModuleStart();
loadLogAppender();
DesignerSocketIO.update();
DesignerWorkspaceLoader.init();
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
@ -160,6 +162,9 @@ public class DesignerActivator extends Activator {
@Override
public void afterAllStart() {
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE);
//生成BasicChartQuickEditor对象,需要用到ChartDesignerActivator的注册信息(DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);)
//所以不能在registerCellEditor函数中进行注册
ActionFactory.registerCellEditor(ChartCollection.class, new BasicChartQuickEditor());
}
private void loadLogAppender() {
@ -344,8 +349,6 @@ public class DesignerActivator extends Activator {
ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor());
ActionFactory.registerCellEditor(BufferedImage.class, new CellImageQuickEditor());
ActionFactory.registerCellEditor(CellImagePainter.class, new CellImageQuickEditor());
//todo 图表编辑器populate没能实现刷新面板显示
ActionFactory.registerCellEditorClass(ChartCollection.class, BasicChartQuickEditor.class);
Set<ElementUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING);
for (ElementUIProvider provider : providers) {

3
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java

@ -2,6 +2,7 @@ package com.fr.start.module;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.PluginClassRefreshManager;
import com.fr.design.env.WorkspaceChangeLoadingDialog;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.event.Event;
import com.fr.event.Listener;
@ -51,6 +52,7 @@ public class DesignerWorkspaceActivator extends Activator {
@Override
public void on(Event event, Workspace workspace) {
WorkspaceChangeLoadingDialog.showDialog();
PluginClassRefreshManager.getInstance().removePluginListener();
HistoryTemplateListCache.getInstance().stash();
}
@ -64,6 +66,7 @@ public class DesignerWorkspaceActivator extends Activator {
HistoryTemplateListCache.getInstance().load();
PluginClassRefreshManager.getInstance().addPluginListener();
WorkspaceChangeLoadingDialog.hideDialog();
}
});
}

Loading…
Cancel
Save