Browse Source

Merging in latest from upstream (DESIGN/design:refs/heads/feature/10.0)

* commit '0ed25a33c32c27edc7b776a20a43459f6e21f26c': (29 commits)
  MOBILE-21673 & MOBILE-21669 修复一处颜色选择框读取值时方法使用错误
  日历、下拉框等全被Scale包住了,设置成真实的组件
  MOBILE-21673 & MOBILE-21669 移动端控件插件化接口设计器支持
  update
  无 jira 任务, 单元测试
  无jira sonar修复
  REPORT-19897 英文版设计器显示问题
  REPORT-19873 设计器英文 表单自适应被遮挡
  补充单元测试
  REPORT-19857 英文版alphafine显示问题 1. 把判断国际化的过程和 点击配置页面才能更新 的逻辑解耦。放到启动的时候做。 2. 配置不依赖于 searchOnline 而是判断中英文。
  不ignored异常
  加读写锁
  初始化时从插件里捞一把
  通过监听插件生命周期实现
  插件天生可拔插,这里不能用static,应每次调用时获取
  REPORT-19733 未装数据集插件的设计器远程设计时 编辑服务器数据集  点击确定会覆盖所有服务器中的插件数据集
  update
  REPORT-19636 填报属性里,智能添加单元格组时,鼠标连续选中一片单元格,如果拖动稍微快了一点,选择会出现丢失
  不要重复close
  close的一些细节
  ...
research/11.0
vito 5 years ago
parent
commit
cdbd818e40
  1. 13
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 22
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  3. 11
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  4. 5
      designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java
  5. 6
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java
  6. 21
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  7. 163
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  8. 2
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  9. 16
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  10. 68
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  11. 21
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  12. 6
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  13. 5
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  14. 15
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  15. 10
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  16. 24
      designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java
  17. 20
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java
  18. 77
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java
  19. 25
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java
  20. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  21. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/CodeTemplateManager.java
  22. 39
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java
  23. 30
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java
  24. 22
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java
  25. 115
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  26. 136
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java
  27. 36
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java
  28. 26
      designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java
  29. 10
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  30. 25
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  31. 15
      designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java
  32. 31
      designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java
  33. 38
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  34. 17
      designer-base/src/main/java/com/fr/env/LocalEnvPane.java
  35. BIN
      designer-base/src/main/resources/com/fr/design/images/dialog/watermark/watermark_background_en.png
  36. BIN
      designer-base/src/main/resources/com/fr/design/images/reportcolumns/col_en.png
  37. BIN
      designer-base/src/main/resources/com/fr/design/images/reportcolumns/row_en.png
  38. 51
      designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java
  39. 3
      designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java
  40. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  41. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  42. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  43. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java
  44. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java
  45. 36
      designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileStylePropertyUI.java
  46. 7
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java
  47. 29
      designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java
  48. 85
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java
  49. 9
      designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java
  50. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  51. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java
  52. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  53. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java
  54. 20
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java
  55. 24
      designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java
  56. 29
      designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java
  57. 20
      designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java
  58. 81
      designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java
  59. 4
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  60. 50
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java
  61. 66
      designer-realize/src/test/java/com/fr/design/widget/WidgetDefinePaneFactoryTest.java

13
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -315,8 +315,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
private void createEnvFile(File envFile) {
FileWriter fileWriter = null;
try {
FileWriter fileWriter = new FileWriter(envFile);
fileWriter = new FileWriter(envFile);
File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml");
File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName());
if (oldEnvFile.exists()) {
@ -332,9 +333,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
}
fileWriter.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if (null != fileWriter) {
try {
fileWriter.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
}

22
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -6,18 +6,14 @@ package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.CellWidgetOptionProvider;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.fun.*;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.core.WidgetOptionFactory;
import com.fr.design.menu.ShortCut;
import com.fr.design.widget.Appearance;
import com.fr.design.widget.mobile.WidgetMobilePane;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.plugin.AbstractExtraClassManager;
import com.fr.plugin.injectable.PluginModule;
@ -207,6 +203,20 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return map;
}
public MobileWidgetStyleProvider[] getMobileStyleOfWidget(String xType) {
Set<MobileWidgetStyleProvider> set = getArray(MobileWidgetStyleProvider.XML_TAG);
if (set.isEmpty()) {
return new MobileWidgetStyleProvider[0];
}
List<MobileWidgetStyleProvider> providers = new ArrayList<>();
for (MobileWidgetStyleProvider provider: set) {
if(ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) {
providers.add(provider);
}
}
return providers.toArray(new MobileWidgetStyleProvider[providers.size()]);
}
@Override
protected boolean demountSpecific(PluginSingleInjection injection) {

11
designer-base/src/main/java/com/fr/design/RestartHelper.java

@ -154,12 +154,12 @@ public class RestartHelper {
deleteWhenDebug();
return;
}
RandomAccessFile randomAccessFile = null;
try {
try {
File restartLockFile = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), "restart.lock"));
StableUtils.makesureFileExist(restartLockFile);
RandomAccessFile randomAccessFile = new RandomAccessFile(restartLockFile,"rw");
randomAccessFile = new RandomAccessFile(restartLockFile,"rw");
FileChannel restartLockFC = randomAccessFile.getChannel();
FileLock restartLock = restartLockFC.tryLock();
if(restartLock == null) {
@ -176,6 +176,13 @@ public class RestartHelper {
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (null != randomAccessFile) {
randomAccessFile.close();
}
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
DesignerContext.getDesignerFrame().exit();
}
}

5
designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java

@ -7,6 +7,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent;
import com.fr.general.IOUtils;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
@ -25,13 +26,13 @@ public class CutAction extends TemplateComponentAction {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"));
this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
this.setEnabled(!DesignModeContext.isBanCopyAndCut());
}
@Override
public boolean executeActionReturnUndoRecordNeeded() {
return DesignModeContext.doPaste(getEditingComponent());
return DesignModeContext.doCut(getEditingComponent());
}
}

6
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java

@ -1,6 +1,5 @@
package com.fr.design.actions.help.alphafine;
import com.fr.base.FRContext;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
@ -11,7 +10,7 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.IOUtils;
import javax.swing.*;
import javax.swing.KeyStroke;
import java.awt.event.ActionEvent;
/**
@ -51,9 +50,6 @@ public class AlphaFineAction extends UpdateAction {
final AlphaFineConfigPane alphaFineConfigPane = new AlphaFineConfigPane();
final AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (!FRContext.isChineseEnv()) {
manager.setSearchOnLine(false);
}
alphaFineConfigPane.populate(manager);
DialogActionListener dialogActionListener = new DialogActionAdapter() {
public void doOk() {

21
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -189,23 +189,34 @@ public class AlphaFineConfigPane extends BasicPane {
}
public void populate(AlphaFineConfigManager alphaFineConfigManager) {
this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
boolean enabled4Locale = FRContext.isChineseEnv();
this.searchOnlineCheckbox.setEnabled(enabled4Locale);
this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containDocumentCheckbox.setEnabled(enabled4Locale);
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setEnabled(enabled4Locale);
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setEnabled(enabled4Locale);
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine());
this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.needIntelligentCustomerService.setEnabled(enabled4Locale);
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
}

163
designer-base/src/main/java/com/fr/design/constants/UIConstants.java

@ -3,13 +3,19 @@
*/
package com.fr.design.constants;
import com.fr.base.BaseUtils;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.Stroke;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
/**
@ -17,19 +23,19 @@ import java.awt.image.BufferedImage;
*/
public interface UIConstants {
public static final Icon CPT_ICON = BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png");
public static final Icon BLACK_ICON = BaseUtils.readIcon("/com/fr/base/images/cell/blank.gif");
public static final Icon CPT_ICON = IOUtils.readIcon("/com/fr/base/images/oem/cpt.png");
public static final Icon BLACK_ICON = IOUtils.readIcon("/com/fr/base/images/cell/blank.gif");
public static final Image APPFIT_V0 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V0.png");
public static final Image APPFIT_V1 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V1.png");
public static final Image APPFIT_V2 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V2.png");
public static final Image APPFIT_V3 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V3.png");
public static final Image APPFIT_V4 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/V4.png");
public static final Image APPFIT_H0 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H0.png");
public static final Image APPFIT_H1 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H1.png");
public static final Image APPFIT_H2 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H2.png");
public static final Image APPFIT_H3 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png");
public static final Image APPFIT_H4 = BaseUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png");
public static final Image APPFIT_V0 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V0.png");
public static final Image APPFIT_V1 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V1.png");
public static final Image APPFIT_V2 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V2.png");
public static final Image APPFIT_V3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V3.png");
public static final Image APPFIT_V4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/V4.png");
public static final Image APPFIT_H0 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H0.png");
public static final Image APPFIT_H1 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H1.png");
public static final Image APPFIT_H2 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H2.png");
public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png");
public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png");
public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0);
public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0);
@ -45,15 +51,15 @@ public interface UIConstants {
* Cell default cursor.
*/
public static final Cursor CELL_DEFAULT_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"),
IOUtils.readImage("/com/fr/base/images/cell/cursor/cell_default.png"),
new Point(16, 16), "CellDefaultCursor");
public static final Cursor DRAW_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"),
IOUtils.readImage("/com/fr/base/images/cell/cursor/cursor_draw.png"),
new Point(16, 16), "DrawCursor");
public static final Cursor FORMAT_BRUSH_CURSOR = Toolkit.getDefaultToolkit().createCustomCursor(
BaseUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"),
IOUtils.readImage("/com/fr/base/images/cell/cursor/brush_cursor0.png"),
new Point(16, 16), "formatBrushCursor");
/**
@ -140,63 +146,64 @@ public interface UIConstants {
public static final BufferedImage DRAG_BAR = BaseUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_LIGHT = BaseUtils.readImage("com/fr/design/images/control/bar-light.png");
public static final BufferedImage ARROW_NORTH = BaseUtils.readImage("com/fr/design/images/control/up_arrow.png");
public static final BufferedImage ARROW_SOUTH = BaseUtils.readImage("com/fr/design/images/control/down_arrow.png");
public static final BufferedImage ARROW_EAST = BaseUtils.readImage("com/fr/design/images/control/east_arrow.png");
public static final BufferedImage ARROW_WEST = BaseUtils.readImage("com/fr/design/images/control/west_arrow.png");
public static final BufferedImage DRAG_BAR_RIGHT = BaseUtils.readImage("com/fr/design/images/control/barm.png");
public static final BufferedImage DRAG_BAR_LEFT = BaseUtils.readImage("com/fr/design/images/control/barl.png");
public static final BufferedImage DRAG_UP_NORMAL = BaseUtils.readImage("com/fr/design/images/control/upnor.png");
public static final BufferedImage DRAG_UP_PRESS = BaseUtils.readImage("com/fr/design/images/control/uppre.png");
public static final BufferedImage DRAG_DOWN_NORMAL = BaseUtils.readImage("com/fr/design/images/control/downnor.png");
public static final BufferedImage DRAG_DOWN_PRESS = BaseUtils.readImage("com/fr/design/images/control/downpre.png");
public static final BufferedImage DRAG_RIGHT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/rightnor.png");
public static final BufferedImage DRAG_RIGHT_PRESS = BaseUtils.readImage("com/fr/design/images/control/rightpre.png");
public static final BufferedImage DRAG_LEFT_NORMAL = BaseUtils.readImage("com/fr/design/images/control/leftnor.png");
public static final BufferedImage DRAG_LEFT_PRESS = BaseUtils.readImage("com/fr/design/images/control/leftpre.png");
public static final BufferedImage DRAG_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png");
public static final BufferedImage DRAG_LINE = BaseUtils.readImage("com/fr/design/images/control/dot-line.png");
public static final BufferedImage ACCESSIBLE_EDITOR_DOT = BaseUtils.readImage("com/fr/design/images/control/dot.png");
public static final BufferedImage DRAG_DOT_VERTICAL = BaseUtils.readImage("com/fr/design/images/control/dotv.png");
public static final BufferedImage POP_BUTTON_DOWN = BaseUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png");
public static final BufferedImage POP_BUTTON_UP = BaseUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png");
public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/downSelected.png");
public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = BaseUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png");
public static final BufferedImage WATERMARK_BACKGROUND = BaseUtils.readImage("/com/fr/design/images/dialog/watermark/watermark_background.png");
public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png");
public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png");
public static final BufferedImage ARROW_SOUTH = IOUtils.readImage("com/fr/design/images/control/down_arrow.png");
public static final BufferedImage ARROW_EAST = IOUtils.readImage("com/fr/design/images/control/east_arrow.png");
public static final BufferedImage ARROW_WEST = IOUtils.readImage("com/fr/design/images/control/west_arrow.png");
public static final BufferedImage DRAG_BAR_RIGHT = IOUtils.readImage("com/fr/design/images/control/barm.png");
public static final BufferedImage DRAG_BAR_LEFT = IOUtils.readImage("com/fr/design/images/control/barl.png");
public static final BufferedImage DRAG_UP_NORMAL = IOUtils.readImage("com/fr/design/images/control/upnor.png");
public static final BufferedImage DRAG_UP_PRESS = IOUtils.readImage("com/fr/design/images/control/uppre.png");
public static final BufferedImage DRAG_DOWN_NORMAL = IOUtils.readImage("com/fr/design/images/control/downnor.png");
public static final BufferedImage DRAG_DOWN_PRESS = IOUtils.readImage("com/fr/design/images/control/downpre.png");
public static final BufferedImage DRAG_RIGHT_NORMAL = IOUtils.readImage("com/fr/design/images/control/rightnor.png");
public static final BufferedImage DRAG_RIGHT_PRESS = IOUtils.readImage("com/fr/design/images/control/rightpre.png");
public static final BufferedImage DRAG_LEFT_NORMAL = IOUtils.readImage("com/fr/design/images/control/leftnor.png");
public static final BufferedImage DRAG_LEFT_PRESS = IOUtils.readImage("com/fr/design/images/control/leftpre.png");
public static final BufferedImage DRAG_DOT = IOUtils.readImage("com/fr/design/images/control/dot.png");
public static final BufferedImage DRAG_LINE = IOUtils.readImage("com/fr/design/images/control/dot-line.png");
public static final BufferedImage ACCESSIBLE_EDITOR_DOT = IOUtils.readImage("com/fr/design/images/control/dot.png");
public static final BufferedImage DRAG_DOT_VERTICAL = IOUtils.readImage("com/fr/design/images/control/dotv.png");
public static final BufferedImage POP_BUTTON_DOWN = IOUtils.readImage("com/fr/design/images/buttonicon/popdownarrow.png");
public static final BufferedImage POP_BUTTON_UP = IOUtils.readImage("com/fr/design/images/buttonicon/popuparrow.png");
public static final BufferedImage DRAG_DOWN_SELECTED_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/downSelected.png");
public static final BufferedImage DRAG_LEFT_NORMAL_SMALL = IOUtils.readImage("com/fr/design/images/buttonicon/leftNormal.png");
public static final BufferedImage WATERMARK_BACKGROUND = IOUtils.readImage("/com/fr/design/images/dialog/watermark/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_WaterMark_Background_Icon_File_Name"));
public static final int MODEL_NORMAL = 0;
public static final int MODEL_PRESS = 1;
public static final Icon ARROW_DOWN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png");
public static final Icon ARROW_UP_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png");
public static final Icon YES_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/yes.png");
public static final Icon CHOOSEN_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/select_item.png");
public static final Icon PRE_WIDGET_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png");
public static final Icon EDIT_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editn.png");
public static final Icon EDIT_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/editp.png");
public static final Icon HIDE_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hiden.png");
public static final Icon HIDE_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/hidep.png");
public static final Icon VIEW_NORMAL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewn.png");
public static final Icon VIEW_PRESSED_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/viewp.png");
public static final Icon RUN_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/run24.png");
public static final Icon RUN_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/runs.png");
public static final Icon PAGE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png");
public static final Icon WRITE_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png");
public static final Icon ANA_BIG_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anab24.png");
public static final Icon PAGE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/pages.png");
public static final Icon WRITE_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/writes.png");
public static final Icon ANA_SMALL_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/anas.png");
public static final Icon REFRESH_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/refresh.png");
public static final Icon FONT_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png");
public static final Icon HISTORY_ICON = BaseUtils.readIcon("com/fr/design/images/buttonicon/history.png");
public static final Icon DELETE_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/close.png");
public static final Icon EDIT_ICON = BaseUtils.readIcon("com/fr/design/images/m_file/edit.png");
public static final Icon SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/search.png");
public static final Icon BLACK_SEARCH_ICON = BaseUtils.readIcon("/com/fr/design/images/data/black_search.png");
public static final Icon CLEAR_ICON = BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png");
public static final Icon LIST_EDIT_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit.png");
public static final Icon LIST_EDIT_WHITE_ICON = BaseUtils.readIcon("/com/fr/design/images/control/edit_white.png");
public static final Icon ARROW_DOWN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowdown.png");
public static final Icon ARROW_UP_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/arrowup.png");
public static final Icon YES_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/yes.png");
public static final Icon CHOOSEN_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/select_item.png");
public static final Icon PRE_WIDGET_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/prewidget.png");
public static final Icon EDIT_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/editn.png");
public static final Icon EDIT_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/editp.png");
public static final Icon HIDE_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/hiden.png");
public static final Icon HIDE_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/hidep.png");
public static final Icon VIEW_NORMAL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/viewn.png");
public static final Icon VIEW_PRESSED_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/viewp.png");
public static final Icon RUN_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/run24.png");
public static final Icon RUN_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/runs.png");
public static final Icon PAGE_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png");
public static final Icon WRITE_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/writeb24.png");
public static final Icon ANA_BIG_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anab24.png");
public static final Icon PAGE_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/pages.png");
public static final Icon WRITE_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/writes.png");
public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png");
public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png");
public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png");
public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png");
public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png");
public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png");
public static final Icon SEARCH_ICON = IOUtils.readIcon("/com/fr/design/images/data/search.png");
public static final Icon BLACK_SEARCH_ICON = IOUtils.readIcon("/com/fr/design/images/data/black_search.png");
public static final Icon CLEAR_ICON = IOUtils.readIcon("/com/fr/design/images/data/source/delete.png");
public static final Icon LIST_EDIT_ICON = IOUtils.readIcon("/com/fr/design/images/control/edit.png");
public static final Icon LIST_EDIT_WHITE_ICON = IOUtils.readIcon("/com/fr/design/images/control/edit_white.png");
public static final Color PRESSED_DARK_GRAY = new Color(127, 127, 127);
public static final Color GRDIENT_DARK_GRAY = new Color(45, 45, 45);
public static final Color BARNOMAL = new Color(232, 232, 233);
@ -205,10 +212,10 @@ public interface UIConstants {
public static final int BUTTON_GROUP_ARC = 0;
public static final int LARGEARC = 6;
public static final Stroke BS = new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 2f, new float[]{3, 1}, 0);
public static final Icon PREVIEW_DOWN = BaseUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png");
public static final Icon CLOSE_OF_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close.png");
public static final Icon CLOSE_OVER_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_over.png");
public static final Icon CLOSE_PRESS_AUTHORITY = BaseUtils.readIcon("/com/fr/design/images/m_report/close_press.png");
public static final Icon PREVIEW_DOWN = IOUtils.readIcon("com/fr/design/images/buttonicon/prevew_down_icon.png");
public static final Icon CLOSE_OF_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close.png");
public static final Icon CLOSE_OVER_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_over.png");
public static final Icon CLOSE_PRESS_AUTHORITY = IOUtils.readIcon("/com/fr/design/images/m_report/close_press.png");
public static final int CLOSE_AUTHORITY_HEIGHT_AND_WIDTH = 24;

2
designer-base/src/main/java/com/fr/design/dialog/BasicPane.java

@ -129,7 +129,7 @@ public abstract class BasicPane extends JPanel {
* @param dimension 自定义尺寸
* @return 对话框
*/
protected BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) {
public BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) {
BasicDialog dg;
if (window instanceof Frame) {
dg = new DIALOG((Frame) window);

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

@ -206,5 +206,21 @@ public class PluginOperateUtils {
return pluginInfo.toString();
}
public static String getSwitchedInfo(PluginTaskResult result) {
StringBuilder pluginInfo = new StringBuilder();
List<PluginTaskResult> pluginTaskResults = result.asList();
for (PluginTaskResult pluginTaskResult : pluginTaskResults) {
PluginTask pluginTask = pluginTaskResult.getCurrentTask();
if (pluginTask == null) {
continue;
}
PluginMarker pluginMarker = pluginTask.getToMarker();
PluginContext pluginContext = PluginManager.getContext(pluginMarker);
if (pluginContext != null && pluginContext.getSelfState() == 1) {
pluginInfo.append("\n").append(pluginContext.getSwitchedReason());
}
}
return pluginInfo.toString();
}
}

68
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -6,6 +6,7 @@ import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginVerifyException;
import com.fr.plugin.basic.version.Version;
import com.fr.plugin.basic.version.VersionIntervalFactory;
import com.fr.plugin.context.PluginContext;
@ -18,6 +19,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -82,29 +84,53 @@ public class PluginUtils {
return jsonArray.toString();
}
public static void downloadShopScripts(String id, Process<Double> p) throws Exception {
HttpClient httpClient = new HttpClient(getDownloadPath(id));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
int totalSize = httpClient.getContentLength();
InputStream reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE);
StableUtils.makesureFileExist(new File(temp));
FileOutputStream writer = new FileOutputStream(temp);
byte[] buffer = new byte[PluginConstants.BYTES_NUM];
int bytesRead = 0;
int totalBytesRead = 0;
public static boolean downloadShopScripts(String id, Process<Double> p) {
InputStream reader = null;
FileOutputStream writer = null;
try {
HttpClient httpClient = new HttpClient(getDownloadPath(id));
if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) {
int totalSize = httpClient.getContentLength();
reader = httpClient.getResponseStream();
String temp = StableUtils.pathJoin(PluginConstants.DOWNLOAD_PATH, PluginConstants.TEMP_FILE);
StableUtils.makesureFileExist(new File(temp));
writer = new FileOutputStream(temp);
byte[] buffer = new byte[PluginConstants.BYTES_NUM];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) > 0) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[PluginConstants.BYTES_NUM];
totalBytesRead += bytesRead;
p.process(totalBytesRead / (double) totalSize);
while ((bytesRead = reader.read(buffer)) > 0) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[PluginConstants.BYTES_NUM];
totalBytesRead += bytesRead;
p.process(totalBytesRead / (double) totalSize);
}
} else {
throw new com.fr.plugin.PluginVerifyException(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
}
reader.close();
writer.flush();
writer.close();
} else {
throw new com.fr.plugin.PluginVerifyException(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error"));
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
} finally {
closeStream(reader, writer);
}
return true;
}
private static void closeStream(InputStream reader, FileOutputStream writer){
try {
if (null != reader) {
reader.close();
}
if (null != writer) {
writer.flush();
writer.close();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}

21
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -259,21 +259,12 @@ public class WebViewDlgHelper {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
try {
PluginUtils.downloadShopScripts(scriptsId, new Process<Double>() {
@Override
public void process(Double integer) {
// 这个注释毫无意义,就是为了通过SonarQube
}
});
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
return true;
return PluginUtils.downloadShopScripts(scriptsId, new Process<Double>() {
@Override
public void process(Double integer) {
// 这个注释毫无意义,就是为了通过SonarQube
}
});
}
@Override

6
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java

@ -36,10 +36,12 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
@Override
public void done(PluginTaskResult result) {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
String switchedInfo = PluginOperateUtils.getSwitchedInfo(result);
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success"));
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
} else if (result.errorCode() == PluginErrorCode.NeedDealWithPluginDependency) {
int rv = JOptionPane.showOptionDialog(
null,

5
designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java

@ -35,9 +35,10 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback {
protected void allDone(PluginTaskResult result) {
String pluginInfo = PluginOperateUtils.getSuccessInfo(result);
if (result.isSuccess()) {
String switchedInfo = PluginOperateUtils.getSwitchedInfo(result);
jsCallback.execute("success");
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success"));
JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success"));
FineLoggerFactory.getLogger().info(pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
JOptionPane.showMessageDialog(null, pluginInfo + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo);
} else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){
int rv = JOptionPane.showOptionDialog(
null,

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

@ -41,17 +41,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache instacne;
public static HistoryTemplateListCache getInstance() {
if (instacne == null) {
synchronized (HistoryTemplateListCache.class) {
if (instacne == null) {
instacne = new HistoryTemplateListCache();
}
}
}
return instacne;
return Holder.INSTANCE;
}
private static class Holder {
private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache();
}
private HistoryTemplateListCache() {

10
designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java

@ -174,7 +174,7 @@ public final class FunctionConstants {
jarPath = StringUtils.perfectStart(jarPath, "/");
}
ZipFile zip;
ZipFile zip = null;
try {
zip = new ZipFile(jarPath);
Enumeration entries = zip.entries();
@ -193,6 +193,14 @@ public final class FunctionConstants {
}
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if(null != zip){
try {
zip.close();
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
} else {
File dir = new File(filePath);

24
designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java

@ -0,0 +1,24 @@
package com.fr.design.fun;
import com.fr.design.mainframe.mobile.ui.MobileStyleCustomDefinePane;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.stable.fun.mark.Mutable;
/**
* 移动端组件样式扩展接口
*/
public interface MobileWidgetStyleProvider extends Mutable {
String XML_TAG = "MobileWidgetStyleProvider";
int CURRENT_LEVEL = 1;
Class<? extends MobileStyle> classForMobileStyle();
Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance();
String xTypeForWidget();
String displayName();
}

20
designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java

@ -0,0 +1,20 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL)
public abstract class AbstractMobileWidgetStyleProvider extends AbstractProvider implements MobileWidgetStyleProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
}

77
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

@ -0,0 +1,77 @@
package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.mainframe.App;
import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.observer.PluginEvent;
import com.fr.plugin.observer.PluginEventListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Created by alex sung on 2019/7/23.
*/
public class FileNodeConstants {
private static List<String> supportFileType;
private static ReadWriteLock rwl = new ReentrantReadWriteLock();
private FileNodeConstants() {
}
static {
initSupportedTypes();
GeneralContext.listenPluginRunningChanged(new PluginEventListener() {
@Override
public void on(PluginEvent pluginEvent) {
initSupportedTypes();
}
}, new PluginFilter() {
@Override
public boolean accept(PluginContext pluginContext) {
return pluginContext.contain(PluginModule.ExtraDesign);
}
});
}
private static void addAppExtensions(String[] extensions) {
for (int i = 0, size = extensions.length; i < size; i++) {
if (!supportFileType.contains(extensions[i])) {
supportFileType.add(extensions[i]);
}
}
}
private static void initSupportedTypes() {
try {
rwl.writeLock().lock();
supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
//通过插件扩展的
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING);
for (App app : apps) {
addAppExtensions(app.defaultExtensions());
}
} finally {
rwl.writeLock().unlock();
}
}
public static String[] getSupportFileTypes() {
try {
rwl.readLock().lock();
return supportFileType.toArray(new String[0]);
} finally {
rwl.readLock().unlock();
}
}
}

25
designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java

@ -1,10 +1,11 @@
package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.project.ProjectConstants;
import org.jetbrains.annotations.Nullable;
import javax.swing.Icon;
import javax.swing.JTree;
@ -29,7 +30,8 @@ import java.util.Stack;
* File Tree.
*/
public class JFileTree extends AbstractFileTree {
protected FileFilter fileFilter;
private FileFilter fileFilter;
public JFileTree() {
this(null);
@ -68,11 +70,11 @@ public class JFileTree extends AbstractFileTree {
DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) defaultTreeModel.getRoot();
rootTreeNode.removeAllChildren();
for (int k = 0; k < rootFiles.length; k++) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RootFile(rootFiles[k]));
for (File rootFile : rootFiles) {
DefaultMutableTreeNode node = new DefaultMutableTreeNode(new RootFile(rootFile));
rootTreeNode.add(node);
if (rootFiles[k].isDirectory()) {
if (rootFile.isDirectory()) {
node.add(new DefaultMutableTreeNode(Boolean.TRUE));
}
}
@ -93,6 +95,7 @@ public class JFileTree extends AbstractFileTree {
this.fileFilter = fileFilter;
}
@Nullable
public File getSelectedFile() {
TreePath selectedTreePath = this.getSelectionPath();
if (selectedTreePath == null) {
@ -140,7 +143,7 @@ public class JFileTree extends AbstractFileTree {
File rootFile = rootLocalFile.getFile();
// 是父子关系,开始找孩子.
if (AbstractFileTree.isParentFile(rootFile, currentFile)) {
Stack nameStack = new Stack(); // 将所有的名字加入Stack.
Stack<String> nameStack = new Stack<>(); // 将所有的名字加入Stack.
while (true) {
if (ComparatorUtils.equals(rootFile, currentFile)) {
break;
@ -153,7 +156,7 @@ public class JFileTree extends AbstractFileTree {
}
DefaultMutableTreeNode curChildTreeNode = rootChildTreeNode;
while (!nameStack.isEmpty()) {
String name = (String) nameStack.pop();
String name = nameStack.pop();
this.expandTreeNode(curChildTreeNode);
for (int j = 0; j < curChildTreeNode.getChildCount(); j++) {
DefaultMutableTreeNode tmpChildTreeNode =
@ -198,9 +201,8 @@ public class JFileTree extends AbstractFileTree {
if (files == null) {
return new FileDirectoryNode[0];
}
List fileNodeList = new ArrayList();
for (int k = 0; k < files.length; k++) {
File tmpFile = files[k];
List<FileDirectoryNode> fileNodeList = new ArrayList<>();
for (File tmpFile : files) {
// 文件属性为隐藏的话 不放入列表
if (tmpFile.isHidden()) {
continue;
@ -256,7 +258,7 @@ public class JFileTree extends AbstractFileTree {
// 得到本地tree图标
Icon tmpIcon = view.getSystemIcon(currentFile);
if (currentFile.isDirectory() && fBuf.length() > 0) {
tmpIcon = BaseUtils.readIcon("/com/fr/design/images/gui/folder.png");
tmpIcon = IOUtils.readIcon("/com/fr/design/images/gui/folder.png");
}
this.setIcon(tmpIcon);
this.setName(null);
@ -299,6 +301,7 @@ public class JFileTree extends AbstractFileTree {
*/
@Override
public int compare(FileDirectoryNode v1, FileDirectoryNode v2) {
//noinspection Duplicates
if (v1.isDirectory()) {
if (v2.isDirectory()) {
return v1.getName().toLowerCase().compareTo(v2.getName().toLowerCase());

2
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -228,7 +228,7 @@ public class TemplateFileTree extends EnvFileTree {
if (fileNodes == null) {
fileNodes = new FileNode[0];
}
Arrays.sort(fileNodes, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes()));
Arrays.sort(fileNodes, new FileNodeComparator(FileNodeConstants.getSupportFileTypes()));
return fileNodes;
}

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/CodeTemplateManager.java

@ -276,8 +276,9 @@ public class CodeTemplateManager {
temp.addAll(templates);
for (int i=0; i<newCount; i++) {
XMLDecoder d = null;
try {
XMLDecoder d = new XMLDecoder(new BufferedInputStream(
d = new XMLDecoder(new BufferedInputStream(
new FileInputStream(files[i])));
Object obj = d.readObject();
if (!(obj instanceof CodeTemplate)) {
@ -285,12 +286,15 @@ public class CodeTemplateManager {
files[i].getAbsolutePath());
}
temp.add((CodeTemplate)obj);
d.close();
} catch (/*IO, NoSuchElement*/Exception e) {
// NoSuchElementException can be thrown when reading
// an XML file not in the format expected by XMLDecoder.
// (e.g. CodeTemplates in an old format).
e.printStackTrace();
} finally {
if(null != d){
d.close();
}
}
}
templates = temp;

39
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import javax.swing.*;
public class DefaultMobileStyleCustomDefinePane extends MobileStyleCustomDefinePane {
public DefaultMobileStyleCustomDefinePane(Widget widget) {
super(widget);
}
@Override
protected JPanel createPreviewPane() {
return null;
}
@Override
public void populateBean(MobileStyle ob) {
}
@Override
public MobileStyle updateBean() {
return null;
}
@Override
protected String title4PopupWindow() {
return null;
}
@Override
protected void init() {
}
}

30
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java

@ -0,0 +1,30 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.fun.impl.AbstractMobileWidgetStyleProvider;
import com.fr.form.ui.mobile.DefaultMobileStyle;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.locale.InterProviderFactory;
public class DefaultMobileWidgetStyleProvider extends AbstractMobileWidgetStyleProvider {
@Override
public Class<? extends MobileStyle> classForMobileStyle() {
return DefaultMobileStyle.class;
}
@Override
public Class<? extends MobileStyleCustomDefinePane> classForWidgetAppearance() {
return DefaultMobileStyleCustomDefinePane.class;
}
@Override
public String xTypeForWidget() {
return null;
}
@Override
public String displayName() {
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT");
}
}

22
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java

@ -0,0 +1,22 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import javax.swing.*;
public abstract class MobileStyleCustomDefinePane extends BasicBeanPane<MobileStyle> {
protected Widget widget;
public MobileStyleCustomDefinePane(Widget widget) {
this.widget = widget;
init();
}
protected abstract JPanel createPreviewPane();
protected abstract void init();
}

115
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -0,0 +1,115 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.Widget;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.general.FRFont;
import com.fr.invoke.Reflect;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private Widget widget;
private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz;
private NewColorSelectBox colorSelectBox;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) {
this.widget = widget;
this.customBeanPane = Reflect.on(customBeanPaneClass).create(widget).get();
this.mobileStyleClazz = mobileStyleClazz;
init();
}
@Override
public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob);
colorSelectBox.setSelectObject(ob.getBackground());
}
@Override
public MobileStyle updateBean() {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean();
mobileStyle.setBackground(colorSelectBox.getSelectObject());
return mobileStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
private void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
createGeneralPane();
createCustomPane();
}
private void createGeneralPane() {
createPreviewPane();
createBackgroundPane();
}
private void createPreviewPane() {
JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane();
if(mobileStylePreviewPane != null) {
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"), null);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, new Color(0x2f8ef100)));
previewPane.setBorder(titledBorder);
previewPane.setPreferredSize(new Dimension(500, 83));
previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER);
this.add(previewPane, BorderLayout.NORTH);
}
}
private void createBackgroundPane() {
JPanel backgroundPane = new JPanel();
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
backgroundPane.setPreferredSize(new Dimension(500, 65));
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"), null);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
backgroundPane.setBorder(titledBorder);
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT);
colorSelectLabel.setPreferredSize(new Dimension(65, 20));
colorSelectBox = new NewColorSelectBox(152);
colorSelectBox.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
backgroundPane.add(colorSelectLabel);
backgroundPane.add(colorSelectBox);
this.add(backgroundPane, BorderLayout.NORTH);
}
private void createCustomPane() {
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
configPane.setBorder(titledBorder);
configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER);
}
}

136
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java

@ -0,0 +1,136 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.MobileWidgetStyleProvider;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.mobile.MobileStyle;
import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;
public class MobileStylePane extends BasicPane {
private Widget widget;
private DefaultListModel<String> listModel;
private JPanel right;
private CardLayout card;
private JList styleList;
private Map<String, BasicBeanPane<MobileStyle>> map = new HashMap<>();
public MobileStylePane(Widget widget) {
if(widget instanceof WScaleLayout) {
this.widget = ((CRBoundsWidget)((WScaleLayout) widget).getBoundsWidget()).getWidget();
} else {
this.widget = widget;
}
init();
}
@Override
protected String title4PopupWindow() {
return null;
}
public void populate(MobileStyle mobileStyle) {
if(mobileStyle != null) {
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders();
for(int i = 0; i < styleProviders.length; i ++) {
if(mobileStyle.getClass() == styleProviders[i].classForMobileStyle()) {
String displayName = styleProviders[i].displayName();
styleList.setSelectedIndex(i);
map.get(displayName).populateBean(mobileStyle);
card.show(right, displayName);
return;
}
}
}
styleList.setSelectedIndex(0);
}
public MobileStyle update() {
return map.get(styleList.getSelectedValue()).updateBean();
}
private void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
listModel = new DefaultListModel<>();
card = new CardLayout();
right = FRGUIPaneFactory.createCardLayout_S_Pane();
right.setLayout(card);
MobileWidgetStyleProvider[] styleProviders = getMobileWidgetStyleProviders();
for(MobileWidgetStyleProvider styleProvider: styleProviders) {
this.addProvider2View(styleProvider);
}
this.addWestList();
this.addCenterConfig();
}
private void addWestList() {
styleList = new JList<>(listModel);
styleList.setCellRenderer(render);
styleList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String selectedValue = (String)styleList.getSelectedValue();
card.show(right, selectedValue);
}
});
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
westPane.add(styleList, BorderLayout.CENTER);
westPane.setPreferredSize(new Dimension(100, 500));
this.add(westPane, BorderLayout.WEST);
}
private void addCenterConfig() {
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
JPanel attrConfPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane.setPreferredSize(new Dimension(500, 500));
attrConfPane.add(right, BorderLayout.CENTER);
centerPane.add(attrConfPane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER);
}
private void addProvider2View(MobileWidgetStyleProvider styleProvider) {
String displayName = styleProvider.displayName();
Class<? extends MobileStyleCustomDefinePane> appearanceClazz = styleProvider.classForWidgetAppearance();
Class<? extends MobileStyle> mobileStyleClazz = styleProvider.classForMobileStyle();
listModel.addElement(displayName);
try {
BasicBeanPane<MobileStyle> mobileStyleBasicBeanPane = new MobileStyleDefinePane(widget, appearanceClazz, mobileStyleClazz);
right.add(displayName, mobileStyleBasicBeanPane);
map.put(displayName, mobileStyleBasicBeanPane);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private static ListCellRenderer render = new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof MobileStyle) {
MobileStyle l = (MobileStyle) value;
this.setText(l.toString());
}
return this;
}
};
private MobileWidgetStyleProvider[] getMobileWidgetStyleProviders() {
DefaultMobileWidgetStyleProvider defaultMobileWidgetStyleProvider = new DefaultMobileWidgetStyleProvider();
MobileWidgetStyleProvider[] styleProviders = ExtraDesignClassManager.getInstance().getMobileStyleOfWidget(widget.getXType());
styleProviders = ArrayUtils.insert(0, styleProviders, defaultMobileWidgetStyleProvider);
return styleProviders;
}
}

36
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java

@ -0,0 +1,36 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.mobile.ui.MobileStylePane;
import com.fr.design.mainframe.widget.wrappers.MobileStyleWrapper;
import com.fr.form.ui.mobile.MobileStyle;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
public class AccessibleMobileStyleEditor extends UneditableAccessibleEditor {
private MobileStylePane stylePane;
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400);
public AccessibleMobileStyleEditor(MobileStylePane stylePane) {
super(new MobileStyleWrapper());
this.stylePane = stylePane;
}
@Override
protected void showEditorPane() {
stylePane.setPreferredSize(DEFAULT_DIMENSION);
BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
setValue(stylePane.update());
fireStateChanged();
}
});
stylePane.populate((MobileStyle) getValue());
dlg.setVisible(true);
}
}

26
designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java

@ -0,0 +1,26 @@
package com.fr.design.mainframe.widget.wrappers;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.locale.InterProviderFactory;
public class MobileStyleWrapper implements Encoder, Decoder {
@Override
public Object decode(String txt) {
return null;
}
@Override
public void validate(String txt) throws ValidationException {
}
@Override
public String encode(Object v) {
if (v == null) {
return InterProviderFactory.getProvider().getLocText("Fine-Engine_Report_DEFAULT");
}
return v.toString();
}
}

10
designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java

@ -1,6 +1,5 @@
package com.fr.design.report.fit.menupane;
import com.fr.base.BaseUtils;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.DialogActionAdapter;
@ -8,18 +7,17 @@ import com.fr.design.dialog.UIDialog;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.general.IOUtils;
import com.fr.report.fit.FitProvider;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.KeyStroke;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
/**
* Created by Administrator on 2015/7/6 0006.
*/
public class ReportFitAttrAction extends JTemplateAction {
private static final Dimension MEDIUM = new Dimension(430, 400);
private static final MenuKeySet REPORT_FIT_ATTR = new MenuKeySet() {
@Override
public char getMnemonic() {
@ -67,7 +65,7 @@ public class ReportFitAttrAction extends JTemplateAction {
}
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/reportfit/fit.png"));
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/reportfit/fit.png"));
}
/**
@ -75,6 +73,7 @@ public class ReportFitAttrAction extends JTemplateAction {
*
* @param e 事件
*/
@Override
public void actionPerformed(ActionEvent e) {
final JTemplate jwb = getEditingComponent();
if (jwb == null) {
@ -93,14 +92,13 @@ public class ReportFitAttrAction extends JTemplateAction {
private void showReportFitDialog(ReportFitAttr fitAttr, final JTemplate jwb, final FitProvider wbTpl, final BasicBeanPane<ReportFitAttr> attrPane) {
attrPane.populateBean(fitAttr);
UIDialog dialog = attrPane.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
UIDialog dialog = attrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
wbTpl.setReportFitAttr(attrPane.updateBean());
jwb.fireTargetModified();
}
});
dialog.setSize(MEDIUM);
dialog.setVisible(true);
}

25
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -80,22 +80,21 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
URLConnection connection = url.openConnection();
int total = connection.getContentLength();
item.setTotalLength(total);
InputStream reader = connection.getInputStream();
File tempFile = new File(StableUtils.pathJoin(saveDir, item.getName()));
StableUtils.makesureFileExist(tempFile);
FileOutputStream writer = new FileOutputStream(tempFile);
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[UpdateConstants.BYTE];
totalBytesRead += bytesRead;
item.setDownloadLength(totalBytesRead);
publish(item);
try ( InputStream reader = connection.getInputStream();
FileOutputStream writer = new FileOutputStream(tempFile)) {
byte[] buffer = new byte[UpdateConstants.BYTE];
int bytesRead = 0;
int totalBytesRead = 0;
while ((bytesRead = reader.read(buffer)) != -1) {
writer.write(buffer, 0, bytesRead);
buffer = new byte[UpdateConstants.BYTE];
totalBytesRead += bytesRead;
item.setDownloadLength(totalBytesRead);
publish(item);
}
}
reader.close();
writer.close();
}
/**

15
designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java

@ -82,15 +82,12 @@ public class DirectoryOperationFactory {
}
private static void copy(String path1, String path2) throws IOException {
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1)));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)));
byte[] date = new byte[in.available()];
in.read(date);
out.write(date);
in.close();
out.close();
try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1)));
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) {
byte[] date = new byte[in.available()];
in.read(date);
out.write(date);
}
}
/**

31
designer-base/src/main/java/com/fr/design/update/ui/dialog/EncodingDetect.java

@ -1,5 +1,6 @@
package com.fr.design.update.ui.dialog;
import com.fr.log.FineLoggerFactory;
import java.io.File;
import java.io.FileInputStream;
@ -11,12 +12,12 @@ import java.io.FileInputStream;
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* EncodingDetect.java<br>
* 自动获取文件的编码
* @author Mata
* @since Create on 2018-08-23
* @version 1.0
* @version 1.0
*/
public class EncodingDetect {
/**
@ -25,11 +26,11 @@ public class EncodingDetect {
* @return 文件的编码
*/
public static String getJavaEncode(File file){
BytesEncodingDetect s = new BytesEncodingDetect();
BytesEncodingDetect s = new BytesEncodingDetect();
String fileCode = BytesEncodingDetect.javaname[s.detectEncoding(file)];
return fileCode;
}
}
@ -75,17 +76,13 @@ class BytesEncodingDetect extends Encoding {
* type. The encoding type with the highest probability is returned.
*/
public int detectEncoding(File testfile) {
FileInputStream chinesefile;
byte[] rawtext;
rawtext = new byte[(int) testfile.length()];
try {
chinesefile = new FileInputStream(testfile);
chinesefile.read(rawtext);
chinesefile.close();
} catch (Exception e) {
System.err.println("Error: " + e);
}
return detectEncoding(rawtext);
byte[] rawtext = new byte[(int) testfile.length()];
try (FileInputStream chinesefile = new FileInputStream(testfile)) {
chinesefile.read(rawtext);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return detectEncoding(rawtext);
}
/**
@ -647,7 +644,7 @@ class BytesEncodingDetect extends Encoding {
* (byte)0xDF) == rawtext[i]) { // Two bytes if (i+1 < rawtextlen && (rawtext[i+1] & (byte)0xBF) == rawtext[i+1]) {
* goodbytes += 2; i++; } } else if ((rawtext[i] & (byte)0xEF) == rawtext[i]) { // Three bytes if (i+2 < rawtextlen &&
* (rawtext[i+1] & (byte)0xBF) == rawtext[i+1] && (rawtext[i+2] & (byte)0xBF) == rawtext[i+2]) { goodbytes += 3; i+=2; } } }
*
*
* score = (int)(100 * ((float)goodbytes/(float)rawtext.length)); // An all ASCII file is also a good UTF8 file, but I'd
* rather it // get identified as ASCII. Can delete following 3 lines otherwise if (goodbytes == asciibytes) { score = 0; } //
* If not above 90, reduce to zero to prevent coincidental matches if (score > 90) { return score; } else { return 0; }
@ -4551,5 +4548,5 @@ class BytesEncodingDetect extends Encoding {
nicename[ASCII] = "ASCII";
nicename[OTHER] = "OTHER";
}
}

38
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -468,30 +468,28 @@ public class UpdateMainDialog extends UIDialog {
return;
}
if (cacheFile.exists()) {
InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader);
String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) {
String[] updateInfo = readStr.split("\\t");
if (updateInfo.length == 2) {
updateTimeStr = updateInfo[0];
Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr);
//形如 Build#release-2018.07.31.03.03.52.80
String currentNO = GeneralUtils.readBuildNO();
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1));
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) {
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) {
continue;
try (InputStreamReader streamReader = new InputStreamReader(new FileInputStream(cacheFile), "UTF-8");
BufferedReader br = new BufferedReader(streamReader)) {
String readStr, updateTimeStr;
while ((readStr = br.readLine()) != null) {
String[] updateInfo = readStr.split("\\t");
if (updateInfo.length == 2) {
updateTimeStr = updateInfo[0];
Date updateTime = CHANGELOG_FORMAT.parse(updateTimeStr);
//形如 Build#release-2018.07.31.03.03.52.80
String currentNO = GeneralUtils.readBuildNO();
Date curJarDate = UPDATE_INFO_TABLE_FORMAT.parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1));
if (!ComparatorUtils.equals(keyword, StringUtils.EMPTY)) {
if (!containsKeyword(UPDATE_INFO_TABLE_FORMAT.format(updateTime), keyword) && !containsKeyword(updateInfo[1], keyword)) {
continue;
}
}
if (isValidLogInfo(updateInfo[1])) {
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)});
}
}
if (isValidLogInfo(updateInfo[1])) {
updateInfoList.add(new Object[]{UPDATE_INFO_TABLE_FORMAT.format(updateTime), updateInfo[1], updateTime.after(curJarDate)});
}
}
}
br.close();
streamReader.close();
}
}

17
designer-base/src/main/java/com/fr/env/LocalEnvPane.java vendored

@ -6,9 +6,9 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.JFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.file.filter.OnlyShowDirectoryFileFilter;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
@ -33,8 +33,9 @@ public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(northPane, BorderLayout.NORTH);
northPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Location") + ":"), BorderLayout.WEST);
northPane.add(pathTextField = new UITextField(), BorderLayout.CENTER);
northPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Location") + ":"), BorderLayout.WEST);
pathTextField = new UITextField();
northPane.add(pathTextField, BorderLayout.CENTER);
// 删除选择文件按钮 添加JFileTree
@ -54,19 +55,23 @@ public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
@Override
public void valueChanged(TreeSelectionEvent e) {
pathTextField.setText(localEnvTree.getSelectedFile().getPath());
File selectFile = localEnvTree.getSelectedFile();
if (selectFile == null) {
return;
}
pathTextField.setText(selectFile.getPath());
}
});
UITextArea description = new UITextArea();
centerPane.add(description, BorderLayout.SOUTH);
description.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Env_Des1"));
description.setText(Toolkit.i18nText("Fine-Design_Basic_Env_Des1"));
description.setEditable(false);
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Location");
return Toolkit.i18nText("Fine-Design_Basic_Location");
}
@Override

BIN
designer-base/src/main/resources/com/fr/design/images/dialog/watermark/watermark_background_en.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

51
designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java

@ -0,0 +1,51 @@
package com.fr.design.gui.itree.filetree;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.mainframe.AbstractAppProvider;
import com.fr.design.mainframe.App;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashSet;
import java.util.Set;
/**
* Created by alex sung on 2019/7/25.
*/
public class FileNodeConstantsTest {
@Test
public void supportFileTypesTest(){
ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class);
Set<Mutable> apps = new HashSet<Mutable>(){{add(new MockCptxApp());}};
EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes();
EasyMock.replay(extra);
Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size());
App app = (App) extra.getArray(App.MARK_STRING).iterator().next();
Assert.assertEquals("cptx", app.defaultExtensions()[0]);
}
private class MockCptxApp extends AbstractAppProvider{
@Override
public String[] defaultExtensions() {
return new String[] {FileExtension.CPTX.getExtension()};
}
@Override
public JTemplate openTemplate(FILE tplFile) {
return null;
}
@Override
public BaseBook asIOFile(FILE tplFile) {
return null;
}
}
}

3
designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java

@ -20,7 +20,6 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.JTemplate;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient;
import com.fr.geojson.helper.GEOJSONHelper;
import com.fr.plugin.chart.base.GisLayer;
import com.fr.plugin.chart.base.ViewCenter;
import com.fr.plugin.chart.map.VanChartMapPlot;
@ -576,7 +575,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver {
mapDataTree.changeRootNode(this.getRootNode());
if(samePlotChange) {
String nodePath = GEOJSONHelper.getDefaultJSONURL();
String nodePath = ChartGEOJSONHelper.getDefaultJSONURL();
mapPlot.setGeoUrl(nodePath);
mapDataTree.setSelectNodePath(nodePath);
selectTreePath = mapDataTree.getSelectionPath();

5
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -339,4 +339,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
public boolean isSupportShared() {
return true;
}
@Override
public boolean supportMobileStyle() {
return false;
}
}

9
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -3,7 +3,6 @@
*/
package com.fr.design.designer.creator;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.UpdateAction;
@ -591,6 +590,14 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
return;
}
/**
* 是否支持定义移动端样式默认true
* @return 是否支持定义移动端样式
*/
public boolean supportMobileStyle() {
return true;
}
/**
* 获取当前组件自定义的属性表tab
*

5
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -121,6 +121,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
return ArrayUtils.add(extraTableEditor, reportFitEditor);
}
@Override
public boolean supportMobileStyle() {
return false;
}
private CRPropertyDescriptor getReportFitEditor() {
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner();
FitProvider wbTpl = designer.getTarget();

5
designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java

@ -572,4 +572,9 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
return false;
}
@Override
public boolean supportMobileStyle() {
return false;
}
}

5
designer-form/src/main/java/com/fr/design/designer/creator/XWScaleLayout.java

@ -179,4 +179,9 @@ public class XWScaleLayout extends DedicateLayoutContainer {
}
return super.getWidgetPropertyUIProviders();
}
@Override
public boolean supportMobileStyle() {
return true;
}
}

36
designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileStylePropertyUI.java

@ -0,0 +1,36 @@
package com.fr.design.designer.properties.mobile;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWScaleLayout;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.widget.ui.designer.mobile.MobileWidgetStyleDefinePane;
public class MobileStylePropertyUI extends AbstractWidgetPropertyUIProvider {
private XCreator xCreator;
public MobileStylePropertyUI(XCreator xCreator) {
if(xCreator instanceof XWScaleLayout) {
this.xCreator = xCreator.getEditingChildCreator();
} else {
this.xCreator = xCreator;
}
}
@Override
public AbstractPropertyTable createWidgetAttrTable() {
return null;
}
@Override
public BasicPane createWidgetAttrPane() {
return new MobileWidgetStyleDefinePane(xCreator);
}
@Override
public String tableTitle() {
return null;
}
}

7
designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

@ -7,6 +7,7 @@ import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.*;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.mobile.MobileStylePropertyUI;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icontainer.UIScrollPane;
@ -172,8 +173,12 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() {
FormSelection selection = designer.getSelectionModel().getSelection();
WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null;
if (selection != null && selection.getSelectedCreator() != null) {
XCreator xCreator = selection.getSelectedCreator();
if (selection != null && xCreator != null) {
embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders();
if(!designer.getDesignerMode().isFormParameterEditor() && xCreator.supportMobileStyle()) {
embeddedPropertyUIProviders = ArrayUtils.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator));
}
}
Set<WidgetPropertyUIProvider> set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG);
return ArrayUtils.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()]));

29
designer-form/src/main/java/com/fr/design/widget/ui/designer/ButtonGroupDictPane.java

@ -1,16 +1,20 @@
package com.fr.design.widget.ui.designer;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.form.ui.ButtonGroup;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.SpinnerNumberModel;
import java.awt.Component;
public class ButtonGroupDictPane extends JPanel {
@ -26,16 +30,23 @@ public class ButtonGroupDictPane extends JPanel {
*
*/
public void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
adaptiveCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Adaptive"), true);
adaptiveCheckbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.columnLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":");
UILabel dictLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary"));
this.columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width);
columnSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{adaptiveCheckbox, columnLabel, columnSpinner}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7);
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}};
Component[][] components = {
new Component[] {adaptiveCheckbox, null},
new Component[] {columnLabel, columnSpinner},
};
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
this.add(jPanel);
}

85
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileWidgetStyleDefinePane.java

@ -0,0 +1,85 @@
package com.fr.design.widget.ui.designer.mobile;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.widget.accessibles.AccessibleMobileStyleEditor;
import com.fr.design.mainframe.mobile.ui.MobileStylePane;
import com.fr.form.ui.mobile.MobileStyle;
import javax.swing.*;
import java.awt.*;
public class MobileWidgetStyleDefinePane extends MobileWidgetDefinePane {
private XCreator xCreator;
private AccessibleMobileStyleEditor mobileStyleEditor;
private AttributeChangeListener changeListener;
public MobileWidgetStyleDefinePane(XCreator xCreator) {
this.xCreator = xCreator;
}
@Override
public void setPreferredSize(Dimension dimension) {
super.setPreferredSize(dimension);
}
@Override
public void initPropertyGroups(Object source) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template"));
mobileStyleEditor = new AccessibleMobileStyleEditor(new MobileStylePane(this.xCreator.toData()));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{new Component[]{label, mobileStyleEditor}},
TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_LARGE
);
JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane();
holder.add(jPanel, BorderLayout.NORTH);
this.add(holder, BorderLayout.NORTH);
}
@Override
public void populate(FormDesigner designer) {
mobileStyleEditor.setValue(xCreator.toData().getMobileStyle());
this.bindListeners2Widgets();
this.addAttributeChangeListener(changeListener);
}
@Override
public void update() {
xCreator.toData().setMobileStyle((MobileStyle) mobileStyleEditor.getValue());
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified();
}
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 30);
}
@Override
public Dimension getMaximumSize() {
return new Dimension(400, 200);
}
private void bindListeners2Widgets() {
reInitAllListeners();
this.changeListener = new AttributeChangeListener() {
@Override
public void attributeChange() {
update();
}
};
}
private void reInitAllListeners() {
initListener(this);
}
}

9
designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java

@ -24,6 +24,7 @@ import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -34,6 +35,7 @@ import java.awt.event.ActionListener;
public class BiasTextPainterCellEditor extends AbstractCellEditor {
private BiasTextPainterPane biasTextPainterPane = null;
private static final double MULTIPLE = 1.5;
/**
* Constructor.
@ -84,8 +86,10 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor {
Window parentWindow = SwingUtilities.getWindowAncestor(grid);
this.biasTextPainterPane = new BiasTextPainterPane();
Dimension dimension = this.biasTextPainterPane.getPreferredSize();
Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * MULTIPLE));
this.biasTextPainterPane.populate(biasTextPainter);
return this.biasTextPainterPane.showSmallWindow(parentWindow, new DialogActionAdapter() {
return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() {
@Override
public void doOk() {
@ -96,7 +100,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor {
public void doCancel() {
BiasTextPainterCellEditor.this.fireEditingCanceled();
}
});
}, wrapDimension);
}
public static class BiasTextPainterPane extends BasicPane {
@ -142,7 +146,6 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor {
group.add(choice2);
choicePane.add(choice1);
// choicePane.add(new UILabel(" "));
choicePane.add(choice2);
centerPane.add(choicePane, BorderLayout.SOUTH);

20
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -15,6 +15,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.SimilarSearchManager;
import com.fr.general.GeneralContext;
import com.fr.general.ProcessCanceledException;
import com.fr.general.http.HttpToolbox;
import com.fr.json.JSON;
@ -33,6 +34,25 @@ public class AlphaFineHelper {
public static final NoResultModel NO_CONNECTION_MODEL = new NoResultModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Connection_Failed"));
private static AlphaFineDialog alphaFineDialog;
private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com";
private AlphaFineHelper() {
}
/**
* 根据国际化调整配置
*/
public static void switchConfig4Locale() {
AlphaFineConfigManager manager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager();
if (!GeneralContext.isChineseEnv()) {
manager.setSearchOnLine(false);
manager.setContainDocument(false);
manager.setContainPlugin(false);
manager.setContainRecommend(false);
manager.setNeedIntelligentCustomerService(false);
}
}
/**
* 弹出alphafine搜索面板

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

@ -27,21 +27,20 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27.
*/
public class PluginSearchManager implements AlphaFineSearchProvider {
private static volatile PluginSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList;
private PluginSearchManager() {
}
public static PluginSearchManager getInstance() {
if (instance == null) {
synchronized (PluginSearchManager.class) {
if (instance == null) {
instance = new PluginSearchManager();
}
}
}
return instance;
return Holder.INSTANCE;
}
private static class Holder {
private static final PluginSearchManager INSTANCE = new PluginSearchManager();
}
private static boolean isCompatibleCurrentEnv(String envVersion) {
@ -105,7 +104,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
lessModelList.add(new MoreModel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")));
return lessModelList;
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if(noConnectList != null){
return noConnectList;
}

20
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -25,22 +25,22 @@ import java.util.List;
* Created by XiaXiang on 2017/3/31.
*/
public class RecommendSearchManager implements AlphaFineSearchProvider {
private static volatile RecommendSearchManager instance;
private SearchResult modelList = new SearchResult();
private SearchResult recommendModelList = new SearchResult();
private SearchResult complementAdviceModelList;
private SearchResult moreModelList = new SearchResult();
private RecommendSearchManager() {
}
public static RecommendSearchManager getInstance() {
if (instance == null) {
synchronized (RecentSearchManager.class) {
if (instance == null) {
instance = new RecommendSearchManager();
}
}
}
return instance;
return Holder.INSTANCE;
}
private static class Holder {
private static final RecommendSearchManager INSTANCE = new RecommendSearchManager();
}
@Override
@ -51,7 +51,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) {
return noConnectList;
}

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java

@ -13,18 +13,18 @@ import java.util.regex.Pattern;
* Created by alex.sung on 2018/8/3.
*/
public class SegmentationManager {
private static volatile SegmentationManager segmentationManager = null;
private static final int MAX_CHINESE_CHARACTERS_NUM = 4;
private SegmentationManager() {
}
public static SegmentationManager getInstance() {
if (segmentationManager == null) {
synchronized (SegmentationManager.class) {
if (segmentationManager == null) {
segmentationManager = new SegmentationManager();
}
}
}
return segmentationManager;
return Holder.INSTANCE;
}
private static class Holder {
private static final SegmentationManager INSTANCE = new SegmentationManager();
}
/**

20
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java

@ -18,19 +18,19 @@ import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
* Created by alex.sung on 2018/8/3.
*/
public class SimilarSearchManager implements AlphaFineSearchProvider {
private static volatile SimilarSearchManager instance;
private SearchResult lessModelList;
private SearchResult moreModelList = new SearchResult();
private SimilarSearchManager() {
}
public static SimilarSearchManager getInstance() {
if (instance == null) {
synchronized (SimilarSearchManager.class) {
if (instance == null) {
instance = new SimilarSearchManager();
}
}
}
return instance;
return Holder.INSTANCE;
}
private static class Holder {
private static final SimilarSearchManager INSTANCE = new SimilarSearchManager();
}
@Override
@ -40,7 +40,7 @@ public class SimilarSearchManager implements AlphaFineSearchProvider {
if (ArrayUtils.isEmpty(searchText)) {
return new SearchResult();
}
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(instance);
SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE);
if (noConnectList != null) {
return noConnectList;
}

24
designer-realize/src/main/java/com/fr/design/report/ReportColumnsPane.java

@ -1,6 +1,5 @@
package com.fr.design.report;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.border.UITitledBorder;
@ -15,14 +14,27 @@ import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.report.stable.WorkSheetAttr;
import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ColumnRow;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -87,6 +99,7 @@ public class ReportColumnsPane extends BasicPane{
};
onOffButtonGroup = new UIButtonGroup(textArray) {
@Override
protected void initButton(UIToggleButton labelButton) {
labelButton.setSize(new Dimension(60,20));
labelButton.setPreferredSize(new Dimension(60, 20));
@ -190,7 +203,7 @@ public class ReportColumnsPane extends BasicPane{
JPanel sampleLablePane = new JPanel(new GridLayout(1,2));
sampleLablePane.setPreferredSize(new Dimension(524, 130));
JPanel rPane = new JPanel();
UILabel rLabel = new UILabel(BaseUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Row_Icon_File_Name")));
UILabel rLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Row_Icon_File_Name")));
rLabel.setBorder(BorderFactory.createEmptyBorder(5,45,0,49));
rPane.add(rLabel);
rowButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportColumns_Columns_Horizontally"));
@ -198,7 +211,7 @@ public class ReportColumnsPane extends BasicPane{
rPane.add(rowButton);
sampleLablePane.add(rPane);
JPanel cPane = new JPanel();
UILabel cLabel = new UILabel(BaseUtils.readIcon("/com/fr/design/images/reportcolumns/col.png"));
UILabel cLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/reportcolumns/" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Col_Icon_File_Name")));
cLabel.setBorder(BorderFactory.createEmptyBorder(5,49,0,49));
cPane.add(cLabel);
colButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportColumns_Columns_Vertically"));
@ -552,6 +565,7 @@ public class ReportColumnsPane extends BasicPane{
/**
* 判断输入是否合法
*/
@Override
public void checkValid() throws Exception {
String repeatText = repeatColDataTextField.getText().trim();
if(StringUtils.isEmpty(repeatText)){

29
designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java

@ -48,6 +48,7 @@ import com.fr.report.web.button.write.AppendRowButton;
import com.fr.report.web.button.write.DeleteRowButton;
import com.fr.stable.bridge.BridgeMark;
import com.fr.stable.bridge.StableFactory;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
@ -60,7 +61,9 @@ import java.util.Map;
* Time : 上午11:17
*/
public class WidgetDefinePaneFactory {
private static Map<Class<? extends Widget>, Appearance> defineMap = new HashMap<Class<? extends Widget>, Appearance>();
private static Map<Class<? extends Widget>, Appearance> pluginDefineMap = ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap();
static {
defineMap.put(NumberEditor.class, new Appearance(NumberEditorDefinePane.class, WidgetConstants.NUMBER + ""));
@ -91,24 +94,32 @@ public class WidgetDefinePaneFactory {
defineMap.put(AppendRowButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + ""));
defineMap.put(DeleteRowButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + ""));
defineMap.put(TreeNodeToggleButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + ""));
defineMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap());
}
private WidgetDefinePaneFactory() {
}
@Nullable
public static RN createWidgetDefinePane(Widget widget, Operator operator) {
Appearance dn = defineMap.get(widget.getClass());
DataModify<Widget> definePane = null;
try {
definePane = (DataModify) dn.getDefineClass().newInstance();
definePane.populateBean(widget);
operator.did(definePane.dataUI(), dn.getDisplayName());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
// 再走一遍插件。
if (dn == null) {
dn = pluginDefineMap.get(widget.getClass());
}
return new RN(definePane, dn.getDisplayName());
if (dn != null) {
DataModify<Widget> definePane = null;
try {
definePane = (DataModify) dn.getDefineClass().newInstance();
definePane.populateBean(widget);
operator.did(definePane.dataUI(), dn.getDisplayName());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return new RN(definePane, dn.getDisplayName());
}
return null;
}
public static class RN {

20
designer-realize/src/main/java/com/fr/design/widget/ui/ButtonGroupDictPane.java

@ -18,6 +18,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.accessibles.AccessibleDictionaryEditor;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.form.ui.ButtonGroup;
@ -42,23 +43,28 @@ public class ButtonGroupDictPane extends JPanel {
adaptiveCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Adaptive"), true);
adaptiveCheckbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
adaptiveCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
columnSpinner.setVisible(!adaptiveCheckbox.isSelected());
columnLabel.setVisible(!adaptiveCheckbox.isSelected());
}
});
this.columnLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":");
UILabel dictLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary"));
this.columnLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Button_Group_Display_Columns") + ":", dictLabel.getPreferredSize().width);
columnSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, Integer.MAX_VALUE, 1));
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double rowSize[] = {p, p};
double columnSize[] = {p, p, f};
Component[][] n_components = {
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_DS_Dictionary")), dictPane, null},
{adaptiveCheckbox, columnLabel, columnSpinner}
double[] rowSize = {p, p, p};
double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}};
Component[][] components = {
new Component[] {dictLabel, dictPane},
new Component[] {adaptiveCheckbox, null},
new Component[] {columnLabel, columnSpinner}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(n_components, rowSize, columnSize, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
this.add(panel);

81
designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

@ -32,11 +32,20 @@ import com.fr.stable.ColumnRowGroup;
import com.fr.stable.StringUtils;
import com.fr.write.DMLConfigJob;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.List;
public class SmartInsertDBManipulationPane extends DBManipulationPane {
private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1);
@ -115,6 +124,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
*
* @param evt 事件对象
*/
@Override
public void actionPerformed(ActionEvent evt) {
BasicPane bPane = new BasicPane() {
@Override
@ -131,6 +141,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
double f = TableLayout.FILL;
bPane.add(TableLayoutHelper.createTableLayoutPane(coms, new double[]{p, p}, new double[]{p, f}), BorderLayout.NORTH);
BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this), new DialogActionAdapter() {
@Override
public void doOk() {
int row_offset = ((Number) rowSpinner.getValue()).intValue();
int column_offset = ((Number) columnSpinner.getValue()).intValue();
@ -177,6 +188,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
*
* @param evt 事件s
*/
@Override
public void actionPerformed(ActionEvent evt) {
showCellWindow(false);
}
@ -192,6 +204,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
*
* @param e 事件s
*/
@Override
public void actionPerformed(ActionEvent e) {
showCellWindow(true);
}
@ -268,6 +281,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel();
int cnt = model.getRowCount();
@ -294,6 +308,10 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
// 单元格组要记录下之前的选中情况
private CellSelection oriCellSelection = null;
private List<String> newAdd = new ArrayList<String>();
private List<String> oldAdd = new ArrayList<String>();
public SmartJTablePane4DB(KeyColumnTableModel model, ElementCasePane actionReportPane) {
this(model, actionReportPane, false);
}
@ -347,6 +365,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
SmartInsertDBManipulationPane.this.checkValid();
}
@ -402,19 +421,21 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
// 要考虑多选的情况 要结合之前的看看 可能是增加 也可能需要减少
ColumnRowGroup add = new ColumnRowGroup();
int removeCount = 0;
if (oriCellSelection != null && isSameStartPoint(cellselection, oriCellSelection)) {
removeCount = dealDragSelection(add, cellselection);
dealDragSelection(add, cellselection, newValue);
} else if (cellselection.getSelectedType() == CellSelection.CHOOSE_ROW || cellselection.getSelectedType() == CellSelection.CHOOSE_COLUMN) {
dealSelectColRow(add, cellselection);
} else {
add.addColumnRow(ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()));
ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow());
String allColumnRow = columnRow.toString();
if (!allColumnRow.contains(columnRow.toString())) {
add.addColumnRow(columnRow);
}
}
if (add.getSize() > 0) {
newValue.addAll(add);
} else if (removeCount > 0) {
newValue.splice(newValue.getSize() - removeCount, removeCount);
}
kcv.cv.obj = newValue;
@ -424,6 +445,32 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
oriCellSelection = cellselection;
}
private void dealDragSelection(ColumnRowGroup add, CellSelection cellselection, ColumnRowGroup newValue) {
int c = cellselection.getColumn();
int cs = cellselection.getColumnSpan();
int r = cellselection.getRow();
int rs = cellselection.getRowSpan();
String allColumnRow = newValue.toString();
newAdd.clear();
for (int i = 0; i < cs; i++) {
for (int j = 0; j < rs; j++) {
ColumnRow columnRow = ColumnRow.valueOf(c + i, r + j);
if (!allColumnRow.contains(columnRow.toString())) {
add.addColumnRow(columnRow);
}
newAdd.add(columnRow.toString());
}
}
int oldSize = oldAdd.size();
int newSize = newAdd.size();
if (oldSize > newSize && oldAdd.containsAll(newAdd)) {
int diff = oldSize - newSize;
newValue.splice(newValue.getSize() - diff, diff);
}
oldAdd.clear();
oldAdd.addAll(newAdd);
}
private ColumnRowGroup getColumnRowGroupValue(Object oriValue) {
ColumnRowGroup newValue = new ColumnRowGroup();
if (oriValue instanceof ColumnRowGroup) {
@ -438,26 +485,6 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
return cs1.getColumn() == cs2.getColumn() && cs1.getRow() == cs2.getRow();
}
private int dealDragSelection(ColumnRowGroup add, CellSelection cellselection) {
int removeCount = 0;
if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() + 1) {
for (int i = 0; i < cellselection.getColumnSpan(); i++) {
add.addColumnRow(ColumnRow.valueOf(
cellselection.getColumn() + i, cellselection.getRow() + cellselection.getRowSpan() - 1));
}
} else if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() - 1) {
removeCount = cellselection.getColumnSpan();
} else if (cellselection.getColumnSpan() == oriCellSelection.getColumnSpan() + 1) {
for (int i = 0; i < cellselection.getRowSpan(); i++) {
add.addColumnRow(ColumnRow.valueOf(
cellselection.getColumn() + cellselection.getColumnSpan() - 1, cellselection.getRow() + i));
}
} else if (cellselection.getColumnSpan() == oriCellSelection.getColumnSpan() - 1) {
removeCount = cellselection.getRowSpan();
}
return removeCount;
}
private void dealSelectColRow(ColumnRowGroup add, CellSelection se) {
int c = se.getColumn(), cs = se.getColumnSpan(),
r = se.getRow(), rs = se.getRowSpan();

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

@ -43,6 +43,7 @@ import com.fr.design.mainframe.InformationCollector;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.bbs.BBSGuestPane;
import com.fr.design.mainframe.bbs.UserInfoPane;
import com.fr.design.mainframe.form.FormECCompositeProvider;
@ -125,8 +126,9 @@ public class DesignerActivator extends Activator {
DesignerSocketIO.update();
UserInfoPane.getInstance().updateBBSUserInfo();
storePassport();
AlphaFineHelper.switchConfig4Locale();
}
private void loadLogAppender() {
logHandler = new LogHandler<DesignerLogAppender>() {
final DesignerLogAppender logAppender = new DesignerLogAppender();

50
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/AlphaFineHelperTest.java

@ -0,0 +1,50 @@
package com.fr.design.mainframe.alphafine;
import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.general.GeneralContext;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
@RunWith(PowerMockRunner.class)
public class AlphaFineHelperTest {
@Test
@PrepareForTest({GeneralContext.class, DesignerEnvManager.class})
@SuppressStaticInitializationFor("com.fr.design.mainframe.alphafine.AlphaFineHelper")
public void testSwitchConfig4Locale() throws Exception {
PowerMock.mockStatic(GeneralContext.class);
EasyMock.expect(GeneralContext.isChineseEnv()).andReturn(true).times(1).andReturn(false).times(1);
AlphaFineConfigManager mockConfig = EasyMock.partialMockBuilder(AlphaFineConfigManager.class).createMock();
Whitebox.setInternalState(mockConfig,"searchOnLine", true);
EasyMock.replay(mockConfig);
DesignerEnvManager manager = EasyMock.mock(DesignerEnvManager.class);
EasyMock.expect(manager.getAlphaFineConfigManager()).andReturn(mockConfig).anyTimes();
EasyMock.replay(manager);
PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
PowerMock.replayAll();
AlphaFineHelper.switchConfig4Locale();
AlphaFineConfigManager config = manager.getAlphaFineConfigManager();
Assert.assertEquals(true, config.isSearchOnLine());
AlphaFineHelper.switchConfig4Locale();
Assert.assertEquals(false, config.isSearchOnLine());
}
}

66
designer-realize/src/test/java/com/fr/design/widget/WidgetDefinePaneFactoryTest.java

@ -0,0 +1,66 @@
package com.fr.design.widget;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.widget.ui.ButtonDefinePane;
import com.fr.form.ui.Button;
import com.fr.form.ui.Widget;
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.Map;
@RunWith(PowerMockRunner.class)
@PowerMockIgnore("javax.swing.*")
public class WidgetDefinePaneFactoryTest {
@Test
@PrepareForTest({ExtraDesignClassManager.class, WidgetDefinePaneFactory.class})
public void testCreateWidgetDefinePane() throws Exception {
Map<Class<? extends Widget>, Appearance> map = new HashMap<>();
ExtraDesignClassManager mockDesignManager = EasyMock.mock(ExtraDesignClassManager.class);
EasyMock.expect(mockDesignManager.getCellWidgetOptionsMap()).andReturn(map).anyTimes();
EasyMock.replay(mockDesignManager);
PowerMock.mockStatic(ExtraDesignClassManager.class);
EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(mockDesignManager).anyTimes();
PowerMock.replayAll(ExtraDesignClassManager.class);
Button mockWidget = EasyMock.mock(Button.class);
EasyMock.replay(mockWidget);
ButtonDefinePane mockPane = EasyMock.mock(ButtonDefinePane.class);
mockPane.populateBean(EasyMock.anyObject(Button.class));
EasyMock.expectLastCall();
EasyMock.replay(mockPane);
Operator mockOperator = EasyMock.mock(Operator.class);
mockOperator.did(EasyMock.anyObject(DataCreatorUI.class), EasyMock.anyString());
EasyMock.replay(mockOperator);
WidgetDefinePaneFactory.RN rn1 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator);
Assert.assertNull(rn1);
Appearance appearance = new Appearance(ButtonDefinePane.class, "test");
map.put(mockWidget.getClass(), appearance);
WidgetDefinePaneFactory.RN rn2 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator);
Assert.assertNotNull(rn2);
map.clear();
WidgetDefinePaneFactory.RN rn3 = WidgetDefinePaneFactory.createWidgetDefinePane(mockWidget, mockOperator);
Assert.assertNull(rn3);
}
}
Loading…
Cancel
Save