Browse Source

Merge pull request #720 in DESIGN/design from ~NEIL/design:10.0 to 10.0

* commit 'c52d2ca8185327d40f995873b7d09afdb0784380': (189 commits)
  ct
  ct
  .
  .
  .
  .
  1
  REPORT-13626 昨天传的没合到final
  REPORT-13074 远程设计向下兼容 1. 将尝试连接和正式连接提示分开。
  REPORT-13431 功能点记录, 需要合并发送 1.发送前去重 2.SEND_DELAY原先定义有误,修正
  REPORT-13074 远程设计向下兼容 1. 忘了注释掉
  REPORT-13074 远程设计向下兼容 1. 修复一下逻辑。 更方便理解
  REPORT-13074 远程设计向下兼容 1. 补充一些注释。
  REPORT-13074 远程设计向下兼容 1. 加入序列化异常 SerilizationException , WorkspaceNoteHitException 2. 加入切换远程连接的检测,以及测试远程连接的提醒。
  MOBILE-18801
  CHART-3575 修改为需要的'分类名'
  CHART-3573 使用新的key来区别开'空值断开'
  CHART-3169 新特性图表 样式系列颜色风格 改为'渐变'
  REPORT-13689 & REPORT-13733 & REPORT-13716 & REPORT-13720
  REPORT-13018 大赛后续开两个接口
  ...
10.0
Kara 6 years ago
parent
commit
ec88aa20f4
  1. 83
      designer-base/src/main/java/com/fr/base/vcs/DesignerMode.java
  2. 170
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  3. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  4. 57
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  5. 2
      designer-base/src/main/java/com/fr/design/actions/ExitAuthorityEditAction.java
  6. 10
      designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java
  7. 20
      designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java
  8. 19
      designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java
  9. 223
      designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java
  10. 66
      designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java
  11. 8
      designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java
  12. 60
      designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java
  13. 38
      designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java
  14. 36
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  15. 8
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JNDIDefPane.java
  16. 7
      designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java
  17. 85
      designer-base/src/main/java/com/fr/design/designer/TargetComponent.java
  18. 5
      designer-base/src/main/java/com/fr/design/designer/properties/PropertyTab.java
  19. 93
      designer-base/src/main/java/com/fr/design/dialog/AbstractTemplateServerSettingPane.java
  20. 83
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  21. 4
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  22. 120
      designer-base/src/main/java/com/fr/design/extra/ucenter/AbstractClient.java
  23. 264
      designer-base/src/main/java/com/fr/design/extra/ucenter/Client.java
  24. 41
      designer-base/src/main/java/com/fr/design/extra/ucenter/XMLHelper.java
  25. 13
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  26. 5
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  27. 63
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  28. 5
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  29. 69
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  30. 327
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  31. 31
      designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProcessor.java
  32. 15
      designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java
  33. 31
      designer-base/src/main/java/com/fr/design/fun/HyperlinkProvider.java
  34. 17
      designer-base/src/main/java/com/fr/design/fun/JavaScriptActionProvider.java
  35. 31
      designer-base/src/main/java/com/fr/design/fun/ParameterExpandablePaneUIProvider.java
  36. 55
      designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java
  37. 44
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProcessor.java
  38. 21
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java
  39. 24
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractHyperlinkProvider.java
  40. 18
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractJavaScriptActionProvider.java
  41. 19
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractParameterExpandablePaneUIProvider.java
  42. 45
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java
  43. 7
      designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java
  44. 16
      designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java
  45. 14
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java
  46. 7
      designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java
  47. 4
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java
  48. 6
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java
  49. 11
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  50. 7
      designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java
  51. 22
      designer-base/src/main/java/com/fr/design/hyperlink/AbstractHyperNorthPane.java
  52. 184
      designer-base/src/main/java/com/fr/design/hyperlink/ReporletHyperNorthPane.java
  53. 450
      designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java
  54. 47
      designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java
  55. 4
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  56. 11
      designer-base/src/main/java/com/fr/design/mainframe/BaseJForm.java
  57. 68
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  58. 54
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  59. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  60. 43
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  61. 6
      designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java
  62. 9
      designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java
  63. 7
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java
  64. 119
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java
  65. 195
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java
  66. 107
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/LinePane.java
  67. 235
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java
  68. 166
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SliderStyleDefinePane.java
  69. 114
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/StyleDefinePaneWithSelectConf.java
  70. 182
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java
  71. 55
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java
  72. 221
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java
  73. 144
      designer-base/src/main/java/com/fr/design/mainframe/widget/MobileTabFontConfPane.java
  74. 50
      designer-base/src/main/java/com/fr/design/mainframe/widget/UITitleSplitLine.java
  75. 10
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AbstractTemplateStylePane.java
  76. 13
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java
  77. 112
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java
  78. 5
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java
  79. 14
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java
  80. 68
      designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java
  81. 17
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java
  82. 11
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  83. 62
      designer-base/src/main/java/com/fr/design/report/WatermarkSettingPane.java
  84. 76
      designer-base/src/main/java/com/fr/design/report/fit/FitType.java
  85. 240
      designer-base/src/main/java/com/fr/design/report/fit/menupane/BrowserFitAttrPane.java
  86. 74
      designer-base/src/main/java/com/fr/design/report/fit/menupane/FitPreviewPane.java
  87. 80
      designer-base/src/main/java/com/fr/design/report/fit/menupane/FitRadioGroup.java
  88. 17
      designer-base/src/main/java/com/fr/design/report/fit/menupane/FontRadioGroup.java
  89. 107
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  90. 56
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java
  91. 85
      designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateBrowserFitAttrPane.java
  92. 55
      designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java
  93. 4
      designer-base/src/main/java/com/fr/design/style/color/ColorCell.java
  94. 3
      designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java
  95. 27
      designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java
  96. 41
      designer-base/src/main/java/com/fr/design/style/color/PickColorButtonFactory.java
  97. 2
      designer-base/src/main/java/com/fr/design/style/color/UsedColorPane.java
  98. 12
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  99. 36
      designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java
  100. 629
      designer-base/src/main/java/com/fr/design/web/CustomIconPane.java
  101. Some files were not shown because too many files have changed in this diff Show More

83
designer-base/src/main/java/com/fr/base/vcs/DesignerMode.java

@ -0,0 +1,83 @@
package com.fr.base.vcs;
import com.fr.design.base.mode.DesignModeContext;
/**
* 兼容
*
* @deprecated user {@link com.fr.design.base.mode.DesignerMode} and {@link DesignModeContext} instead
*/
@Deprecated
public enum DesignerMode {
NORMAL() {
@Override
public void doSwitch() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
}
},
VCS() {
@Override
public void doSwitch() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.VCS);
}
},
AUTHORITY() {
@Override
public void doSwitch() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.AUTHORITY);
}
};
abstract void doSwitch();
/**
* @return 是否时版本控制模式
* @deprecated use {@link DesignModeContext#isVcsMode()} instead
*/
@Deprecated
public static boolean isVcsMode() {
return DesignModeContext.isVcsMode();
}
/**
* 切换设计器模式
*
* @param mode mode
* @deprecated use {@link DesignModeContext#switchTo(com.fr.design.base.mode.DesignerMode)} instead
*/
@Deprecated
public static void setMode(DesignerMode mode) {
mode.doSwitch();
}
/**
* @return 获取当前设计器模式
* @deprecated use {@link DesignModeContext#getMode()} instead
*/
@Deprecated
public static DesignerMode getMode() {
switch (DesignModeContext.getMode()) {
case VCS:
return VCS;
case AUTHORITY:
return AUTHORITY;
case NORMAL:
default:
return NORMAL;
}
}
/**
* 是否为权限编辑
*
* @return 是否为权限编辑
* @deprecated use {@link DesignModeContext#isAuthorityEditing()} instead
*/
@Deprecated
public static boolean isAuthorityEditing() {
return DesignModeContext.isAuthorityEditing();
}
}

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

@ -3,6 +3,8 @@ package com.fr.design;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateProvider; import com.fr.design.mainframe.JTemplateProvider;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
@ -14,68 +16,159 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 当前的设计器模式 * 设计器模式 FormModel or WorkBookModel
* <p>
* 指的是编辑的模板是普通报表还是决策报表
* *
* @author zhou * @author zhou
* @since 2012-7-26上午11:24:54 * @since 2012-7-26上午11:24:54
*/ */
public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplateProvider> { public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplateProvider<T>> {
/**
* 当前的设计模式 FormModel or WorkBookModel
*/
private static DesignModelAdapter<?, ?> currentModelAdapter; private static DesignModelAdapter<?, ?> currentModelAdapter;
/**
* 模板
*/
protected S jTemplate; protected S jTemplate;
/**
* 全部的参数包括全局参数模板参数和数据集参数
*/
private Parameter[] parameters;
/**
* 数据集参数
*/
private Parameter[] tableDataParameters;
/**
* 模板参数
*/
private Parameter[] templateParameters;
public DesignModelAdapter(S jTemplate) { public DesignModelAdapter(S jTemplate) {
this.jTemplate = jTemplate; this.jTemplate = jTemplate;
setCurrentModelAdapter(this); updateCachedParameter();
setCurrentModelAdapter(this);
}
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return currentModelAdapter;
} }
/**
* 获取当前编辑的模板
*
* @return template
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
* @see HistoryTemplateListCache#getCurrentEditingTemplate()
* @deprecated use {@link HistoryTemplateListCache#setCurrentEditingTemplate(JTemplate)} instead
*/
@Deprecated
public S getjTemplate() { public S getjTemplate() {
return jTemplate; return jTemplate;
} }
/**
* 设置当前编辑的模板
* 不要脱离上下文直接调用
*
* @param jTemplate jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
* @deprecated use {@link HistoryTemplateListCache#setCurrentEditingTemplate(JTemplate)} instead
*/
@Deprecated
public void setjTemplate(S jTemplate) { public void setjTemplate(S jTemplate) {
this.jTemplate = jTemplate; this.jTemplate = jTemplate;
} }
public T getBook() { public T getBook() {
return (T) ((JTemplate) jTemplate).getTarget(); return jTemplate.getTarget();
} }
public static void setCurrentModelAdapter(DesignModelAdapter<?, ?> model) {
currentModelAdapter = model;
}
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() {
return currentModelAdapter;
}
/** /**
* 响应目标改变事件. * 响应正在编辑的模板改变事件.
*/ */
public void fireTargetModified() { public void fireTargetModified() {
((JTemplate) this.jTemplate).fireTargetModified(); this.jTemplate.fireTargetModified();
} }
/**
* 获取悬浮元素名称数组
*
* @return String[] 悬浮元素名称数组
*/
public String[] getFloatNames() { public String[] getFloatNames() {
return new String[0]; return new String[0];
} }
/**
* 获取编辑模板的所有参数
* <p>
* 由于在参数面板拖动过程中频繁获取
* 远程设计时数据集参数rpc 调用需要考虑网络等因素,因此会比较缓慢,引起参数面板拖动卡顿,
* 所以缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板的所有参数
*/
public Parameter[] getParameters() { public Parameter[] getParameters() {
return new Parameter[0]; return parameters == null ? new Parameter[0] : parameters;
} }
// 报表参数 /**
* 模板参数报表参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板参数
* @deprecated use {@link DesignModelAdapter#getTemplateParameters()} instead
*/
@Deprecated
public Parameter[] getReportParameters() { public Parameter[] getReportParameters() {
return new Parameter[0]; return getTableDataParameters();
}
/**
* 模板参数报表参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
*
* @return Parameter[] 模板参数
*/
public Parameter[] getTemplateParameters() {
return templateParameters == null ? new Parameter[0] : templateParameters;
} }
/** /**
* 数据源参数 * 数据源参数
* <p>
* 既然全部参数都,那么这个也缓存一下,并且在参数改动时及时缓存
* *
* @return * @return Parameter[] 数据源参数
*/ */
public Parameter[] getTableDataParameters() { public Parameter[] getTableDataParameters() {
return new Parameter[0]; return tableDataParameters == null ? new Parameter[0] : tableDataParameters;
}
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
} }
/** /**
@ -101,17 +194,6 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
return true; return true;
} }
/**
* 重命名TableData后的一些操作
*
* @param oldName 旧名字
* @param newName 新名字.
* @return 返回是否名字一样.
*/
public boolean renameTableData(String oldName, String newName) {
return renameTableData(oldName, newName, true);
}
/** /**
* 重命名tabledata * 重命名tabledata
* *
@ -128,10 +210,23 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
} }
} }
public abstract Widget[] getLinkableWidgets() ; public abstract Widget[] getLinkableWidgets();
public abstract List<WidgetName> getWidgetsName(); public abstract List<WidgetName> getWidgetsName();
/**
* 更新缓存的参数
*/
public void updateCachedParameter() {
// 全部参数
this.parameters = getLatestParameters();
// 数据及参数
this.tableDataParameters = getLatestTableDataParameters();
// 模板参数
this.templateParameters = getLatestTemplateParameters();
}
/** /**
* 环境改变. * 环境改变.
*/ */
@ -146,4 +241,19 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
* 控件配置改变. * 控件配置改变.
*/ */
public abstract void widgetConfigChanged(); public abstract void widgetConfigChanged();
/**
* 获取变更后的模板参数
*/
protected abstract Parameter[] getLatestTemplateParameters();
/**
* 获取变更后的数据集参数
*/
protected abstract Parameter[] getLatestTableDataParameters();
/**
* 获取变更后的全部参数
*/
protected abstract Parameter[] getLatestParameters();
} }

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

@ -112,7 +112,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
private Color paginationLineColor = Color.black; // line color of paper private Color paginationLineColor = Color.black; // line color of paper
private boolean supportCellEditorDef = false; private boolean supportCellEditorDef = false;
private boolean isDragPermited = false; private boolean isDragPermited = false;
private Locale language = Locale.SIMPLIFIED_CHINESE; private Locale language = Locale.getDefault();
//2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容 //2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容
private boolean useOracleSystemSpace = true; private boolean useOracleSystemSpace = true;
private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT; private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT;

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

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException; import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray; import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance { public class EnvChangeEntrance {
@ -90,6 +97,12 @@ public class EnvChangeEntrance {
}); });
return false; return false;
} }
// 如果版本不一致,且确认 不继续 连接,这里返回 false.
if (!versionCheckAndConfirm(selectedEnv)) {
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
@ -138,6 +151,50 @@ public class EnvChangeEntrance {
return true; return true;
} }
/**
* 切换远程环境之前进行版本检测当版本不一致的时候提示
* 当用户确认选择 ok 才继续
*
* @param selectedEnv 选择的环境
* @return 是否一致
* 1. 非远程环境 返回 true
* 2. 远程环境
* 2.1 不匹配
* 2.1.1 当选择 ok 返回 true
* 2.1.2 当选择 no, 返回 false
* 2.2 匹配 返回 true
* @throws Exception 异常
*/
private boolean versionCheckAndConfirm(DesignerWorkspaceInfo selectedEnv) throws Exception {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo info = selectedEnv.getConnection();
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return true;
}
final List<Integer> result = new ArrayList<>(1);
PopTipStrategy.NOW.showTip(new PopTip() {
@Override
public void show() {
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
int choice = JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistency"),
UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1);
result.add(choice);
}
});
// 只有选择 yes , 这里的值才为 0, 返回 true
// 否着返回 false, 将不进行下面的连接操作。
return result.size() != 0 && result.get(0) == 0;
}
return true;
}
/** /**
* 编辑items * 编辑items
* *

2
designer-base/src/main/java/com/fr/design/actions/ExitAuthorityEditAction.java

@ -35,7 +35,7 @@ public class ExitAuthorityEditAction extends TemplateComponentAction {
} }
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMARL); DesignerMode.setMode(DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); WestRegionContainerPane.getInstance().replaceDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus()); DesignerContext.getDesignerFrame().resetToolkitByPlus(tc.getToolBarMenuDockPlus());

10
designer-base/src/main/java/com/fr/design/actions/edit/CopyAction.java

@ -5,10 +5,10 @@ package com.fr.design.actions.edit;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import javax.swing.KeyStroke;
import javax.swing.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -24,14 +24,12 @@ public class CopyAction extends TemplateComponentAction {
this.setMnemonic('C'); this.setMnemonic('C');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER));
this.setEnabled(!DesignModeContext.isBanCopyAndCut());
} }
@Override @Override
public boolean executeActionReturnUndoRecordNeeded() { public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent(); DesignModeContext.doCopy(getEditingComponent());
if (tc != null) {
tc.copy();
}
return false; return false;
} }
} }

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

@ -3,14 +3,13 @@
*/ */
package com.fr.design.actions.edit; package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -21,21 +20,18 @@ public class CutAction extends TemplateComponentAction {
/** /**
* Constructor * Constructor
*/ */
public CutAction(TargetComponent t) { public CutAction(TargetComponent t) {
super(t); super(t);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"));
this.setMnemonic('T'); this.setMnemonic('T');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"));
this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER));
this.setEnabled(!DesignModeContext.isBanCopyAndCut());
} }
@Override @Override
public boolean executeActionReturnUndoRecordNeeded() { public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent editPane = getEditingComponent(); return DesignModeContext.doPaste(getEditingComponent());
if (editPane == null) {
return false;
}
return editPane.cut();
} }
} }

19
designer-base/src/main/java/com/fr/design/actions/edit/PasteAction.java

@ -3,14 +3,13 @@
*/ */
package com.fr.design.actions.edit; package com.fr.design.actions.edit;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -21,9 +20,9 @@ public class PasteAction extends TemplateComponentAction {
/** /**
* Constructor * Constructor
*/ */
public PasteAction(TargetComponent t) { public PasteAction(TargetComponent t) {
super(t); super(t);
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Edit_Paste"));
this.setMnemonic('P'); this.setMnemonic('P');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png"));
@ -32,10 +31,6 @@ public class PasteAction extends TemplateComponentAction {
@Override @Override
public boolean executeActionReturnUndoRecordNeeded() { public boolean executeActionReturnUndoRecordNeeded() {
TargetComponent tc = getEditingComponent(); return DesignModeContext.doPaste(getEditingComponent());
if (tc == null) {
return false;
}
return tc.paste();
} }
} }

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

@ -0,0 +1,223 @@
package com.fr.design.actions.file.export;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.actions.JTemplateAction;
import com.fr.design.gui.iprogressbar.FRProgressBar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.exception.RemoteDesignPermissionDeniedException;
import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.io.exporter.DesignExportType;
import com.fr.io.exporter.ExporterKey;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.third.jodd.io.FileNameUtil;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.exporter.TemplateExportOperator;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.event.ActionEvent;
import java.io.OutputStream;
import java.util.Map;
public abstract class AbstractExportAction<E extends JTemplate<?, ?>> extends JTemplateAction<E> {
private FRProgressBar progressbar;
public AbstractExportAction(E t) {
super(t);
}
/**
* 导出接口名
*
* @return String scopeName
*/
public abstract ExporterKey exportKey();
/**
* 导出类型
*
* @return DesignExportType tyoe
*/
public abstract DesignExportType exportType();
/**
* 目标文件过滤器
*
* @return ChooseFileFilter filter
*/
protected abstract ChooseFileFilter getChooseFileFilter();
/**
* 目标文件扩展名
*
* @return String extensionName
*/
protected abstract String getDefaultExtension();
/**
* 处理参数
*
* @return Map para
*/
protected abstract Map<String, Object> processParameter();
/**
* 执行方法
*/
@Override
public void actionPerformed(ActionEvent e) {
if (!processNotSaved()) {
return;
}
Map<String, Object> para = processParameter();
// 选择输入的文件
FILEChooserPane fileChooserPane = FILEChooserPane.getMultiEnvInstance(true, false);
fileChooserPane.addChooseFILEFilter(this.getChooseFileFilter());
String fileName = getTargetFileName();
fileChooserPane.setFileNameTextField(fileName, "." + this.getDefaultExtension());
int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension());
if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) {
FILE target = fileChooserPane.getSelectedFILE();
try {
target.mkfile();
} catch (Exception exp) {
FineLoggerFactory.getLogger().error("Error In Make New File", exp);
}
FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!");
progressbar = new FRProgressBar(
createExportWork(getSource(), target, para),
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exporting"),
StringUtils.EMPTY,
0,
100);
progressbar.start();
}
}
private FILE getSource() {
return this.getEditingComponent().getEditingFILE();
}
private String getTargetFileName() {
FILE source = getSource();
String fileName = source.getName();
return FileNameUtil.removeExtension(fileName);
}
private boolean processNotSaved() {
//当前编辑的模板
E e = getEditingComponent();
if (!e.isALLSaved() && !DesignerMode.isVcsMode()) {
e.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + e.getEditingFILE() + "\" ?",
ProductConstants.PRODUCT_NAME,
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE
);
if (returnVal == JOptionPane.YES_OPTION) {
e.saveTemplate();
FineLoggerFactory.getLogger().info(
Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", e.getEditingFILE().getName())
);
return true;
} else {
return false;
}
} else {
return true;
}
}
private SwingWorker createExportWork(final FILE source, final FILE target, final Map<String, Object> parameterMap) {
final String path = source.getPath();
final String name = target.getName();
return new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
//bug 10516
Thread.sleep(100);
try (OutputStream outputStream = target.asOutputStream()) {
this.setProgress(10);
dealExporter(outputStream, path, parameterMap);
this.setProgress(80);
outputStream.flush();
outputStream.close();
this.setProgress(100);
FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!");
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Exported_Successfully") + "\n" + name);
} catch (RemoteDesignPermissionDeniedException exp) {
this.setProgress(100);
target.closeTemplate();
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Engine_Remote_Design_Permission_Denied"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
} catch (Exception exp) {
this.setProgress(100);
target.closeTemplate();
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Report_Export_Failed") + "\n" + path,
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
}
return null;
}
@Override
public void done() {
progressbar.close();
}
};
}
private void dealExporter(OutputStream outputStream, String path, final Map<String, Object> para) throws Exception {
// 没有办法处理这个 isLocal 判断,因为一个是修改参数传递结果,一个是返回值做结果
// todo 后续想想办法
if (WorkContext.getCurrent().isLocal()) {
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportKey(), exportType(), outputStream, path, para);
} else {
byte[] contents =
WorkContext.getCurrent().get(TemplateExportOperator.class)
.export(exportKey(), exportType(), null, path, para);
outputStream.write(contents);
}
}
}

66
designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java

@ -0,0 +1,66 @@
package com.fr.design.base.mode;
import com.fr.design.designer.TargetComponent;
import static com.fr.design.base.mode.DesignerMode.AUTHORITY;
public class DesignModeContext {
private static DesignerMode mode = DesignerMode.NORMAL;
public static void switchTo(DesignerMode mode) {
DesignModeContext.mode = mode;
}
public static DesignerMode getMode() {
return mode;
}
/**
* 是否是版本控制模式
*
* @return 是否是版本控制模式
*/
public static boolean isVcsMode() {
return mode == DesignerMode.VCS;
}
/**
* @return 是否是禁止拷贝剪切模式
*/
public static boolean isBanCopyAndCut() {
return mode == DesignerMode.BAN_COPY_AND_CUT;
}
/**
* 是否为权限编辑
*
* @return 是否为权限编辑
*/
public static boolean isAuthorityEditing() {
return mode == AUTHORITY;
}
public static void doCopy(TargetComponent principal) {
if (isBanCopyAndCut() || principal == null) {
return;
}
principal.copy();
}
public static boolean doPaste(TargetComponent principal) {
if (principal == null) {
return false;
}
return principal.paste();
}
public static boolean doCut(TargetComponent principal) {
if (isBanCopyAndCut() || principal == null) {
return false;
}
return principal.cut();
}
}

8
designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java

@ -0,0 +1,8 @@
package com.fr.design.base.mode;
public enum DesignerMode {
NORMAL,
BAN_COPY_AND_CUT,
VCS,
AUTHORITY
}

60
designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java

@ -1,14 +1,8 @@
package com.fr.design.bbs; package com.fr.design.bbs;
import com.fr.config.BBSAttr; import com.fr.base.passport.FinePassportManager;
import com.fr.config.Configuration;
import com.fr.config.MarketConfig;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.util.List;
/** /**
* Created by ibm on 2017/8/21. * Created by ibm on 2017/8/21.
@ -16,62 +10,14 @@ import java.util.List;
public class BBSLoginUtils { public class BBSLoginUtils {
public static void bbsLogin(final String username, final String password) { public static void bbsLogin(final String username, final String password) {
final BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUsername(username);
bbsAttr.setBbsPassword(password);
try { try {
Configurations.update(new Worker() { FinePassportManager.getInstance().login(username, password);
@Override
public void run() {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public static void bbsLogin(List<String> list) {
try {
String uid = list.get(0);
String username = list.get(1);
String password = list.get(2);
final BBSAttr bbsAttr = new BBSAttr();
bbsAttr.setBbsUsername(username);
bbsAttr.setBbsPassword(password);
bbsAttr.setBbsUid(Integer.parseInt(uid));
bbsAttr.setInShowBBsName(username);
Configurations.update(new Worker() {
@Override
public void run() {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{MarketConfig.class};
}
});
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
public static void bbsLogout() { public static void bbsLogout() {
final BBSAttr bbsAttr = new BBSAttr(); FinePassportManager.getInstance().logout();
bbsAttr.setBbsUsername(StringUtils.EMPTY);
bbsAttr.setBbsPassword(StringUtils.EMPTY);
bbsAttr.setBbsUid(0);
bbsAttr.setInShowBBsName(StringUtils.EMPTY);
try {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} }
} }

38
designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java

@ -121,7 +121,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
JoinCondition newJoinCondition = new JoinCondition(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR, liteCondition); JoinCondition newJoinCondition = new JoinCondition(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR, liteCondition);
ExpandMutableTreeNode parentTreeNode = getParentTreeNode(); ExpandMutableTreeNode parentTreeNode = getParentTreeNode();
boolean result = isExistedInParentTreeNode(parentTreeNode, newJoinCondition); boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, false);
if (result) { if (result) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this), JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed")); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed"));
@ -162,7 +162,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
@Override @Override
public void mouseExited(MouseEvent evt) { public void mouseExited(MouseEvent evt) {
GUICoreUtils.setEnabled(conditionCardPane, conditionCardPane.isEnabled()); GUICoreUtils.setEnabled(conditionCardPane, conditionCardPane.isEnabled());
} }
}; };
@ -596,6 +596,8 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR); oldJoinCondition.setJoin(andRadioButton.isSelected() ? DataConstants.AND : DataConstants.OR);
Condition oldLiteCondition = oldJoinCondition.getCondition(); Condition oldLiteCondition = oldJoinCondition.getCondition();
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
// peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回. // peter:如果当前选中的是ListCondition,只要改变Join为AND或者OR,直接返回.
if (oldLiteCondition != null && !(oldLiteCondition instanceof ListCondition)) { if (oldLiteCondition != null && !(oldLiteCondition instanceof ListCondition)) {
// peter:先获得当前的LiteCondition. // peter:先获得当前的LiteCondition.
@ -605,13 +607,18 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
} else { } else {
liteCondition = new FormulaCondition(formulaTextArea.getText()); liteCondition = new FormulaCondition(formulaTextArea.getText());
} }
//修改的时候加入判断条件重复 REPORT-13441
boolean result = isExistedInParentTreeNode(parentTreeNode, liteCondition, true);
if (result) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(LiteConditionPane.this),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_BindColumn_This_Condition_Has_Been_Existed"));
return;
}
oldJoinCondition.setCondition(liteCondition); oldJoinCondition.setCondition(liteCondition);
} }
// peter:需要reload parent // peter:需要reload parent
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) conditionsTree.getModel();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) selectedTreeNode.getParent();
defaultTreeModel.reload(parentTreeNode); defaultTreeModel.reload(parentTreeNode);
parentTreeNode.expandCurrentTreeNode(conditionsTree); parentTreeNode.expandCurrentTreeNode(conditionsTree);
conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(selectedTreeNode)); conditionsTree.setSelectionPath(GUICoreUtils.getTreePath(selectedTreeNode));
@ -745,22 +752,31 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
return parentTreeNode; return parentTreeNode;
} }
private boolean isExistedInParentTreeNode(ExpandMutableTreeNode parentTreeNode, JoinCondition newJoinCondition) { private boolean isExistedInParentTreeNode(ExpandMutableTreeNode parentTreeNode, Condition liteCondition, boolean isModify) {
if (parentTreeNode == null) { if (parentTreeNode == null) {
return false; return false;
} }
JoinCondition parentJoinCondition = (JoinCondition) parentTreeNode.getUserObject(); JoinCondition parentJoinCondition = (JoinCondition) parentTreeNode.getUserObject();
Condition parentLiteCondition = parentJoinCondition.getCondition(); Condition parentLiteCondition = parentJoinCondition.getCondition();
Object oldJoinCondition = null;
//获取当前选中的条件用于修改判断
TreePath selectedTreePath = conditionsTree.getSelectionPath();
if (selectedTreePath != null) {
ExpandMutableTreeNode selectedTreeNode = (ExpandMutableTreeNode) selectedTreePath.getLastPathComponent();
oldJoinCondition = selectedTreeNode.getUserObject();
}
if (parentLiteCondition instanceof ListCondition) { if (parentLiteCondition instanceof ListCondition) {
// peter:在添加UserObject的节点. // peter:在添加UserObject的节点.
for (int i = 0; i < parentTreeNode.getChildCount(); i++) { for (int i = 0; i < parentTreeNode.getChildCount(); i++) {
ExpandMutableTreeNode tempTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAt(i); ExpandMutableTreeNode tempTreeNode = (ExpandMutableTreeNode) parentTreeNode.getChildAt(i);
Object tempObject = tempTreeNode.getUserObject(); Object tempObject = tempTreeNode.getUserObject();
if (tempObject instanceof JoinCondition) { //修改的时候需要排除所选条件,和其他条件比较。增加的时候全盘比较
if (tempObject instanceof JoinCondition && isModify ? (!tempObject.equals(oldJoinCondition)) : true) {
JoinCondition tempJoinCondition = (JoinCondition) tempObject; JoinCondition tempJoinCondition = (JoinCondition) tempObject;
if (ComparatorUtils.equals(tempJoinCondition, newJoinCondition)) { //条件内容一样就视为相同条件,join类型无关
if (ComparatorUtils.equals(tempJoinCondition.getCondition(), liteCondition)) {
return true; return true;
} }
} }
@ -941,7 +957,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
@Override @Override
public Condition updateBean() { public Condition updateBean() {
// Samuel:先按modifybutton // Samuel:先按modifybutton
modify(); //modify(); REPORT-13442 需要点修改按钮才能修改
// peter: 先删除所有的节点 // peter: 先删除所有的节点
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel(); DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.conditionsTree.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot(); ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
@ -963,9 +979,9 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
JoinCondition joinCondition = (JoinCondition) rootTreeNode.getUserObject(); JoinCondition joinCondition = (JoinCondition) rootTreeNode.getUserObject();
Condition newCondition = joinCondition.getCondition(); Condition newCondition = joinCondition.getCondition();
//clone(),防止多个条件分组使用同一个condition对象 //clone(),防止多个条件分组使用同一个condition对象
try{ try {
newCondition = (Condition)joinCondition.getCondition().clone(); newCondition = (Condition) joinCondition.getCondition().clone();
}catch (CloneNotSupportedException e){ } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return newCondition; return newCondition;

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

@ -15,7 +15,9 @@ import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -34,8 +36,9 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private UIButton cancelButton; private UIButton cancelButton;
private JDialog dialog; private JDialog dialog;
private UILabel uiLabel; private UILabel uiLabel;
private String oirginalCharSet = null; // 编码转换.
private String newCharSet = null; private UIComboBox charSetComboBox;
private String originalCharSet = null;
// Database pane // Database pane
public DatabaseConnectionPane() { public DatabaseConnectionPane() {
@ -47,6 +50,8 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
uiLabel = new UILabel(); uiLabel = new UILabel();
okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel")); cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
String[] defaultEncode = new String[] {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto")};
charSetComboBox = new UIComboBox(ArrayUtils.addAll(defaultEncode, EncodeConstants.ENCODING_ARRAY));
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
@ -61,6 +66,14 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
// Center // Center
northPane.add(mainPanel(), BorderLayout.CENTER); northPane.add(mainPanel(), BorderLayout.CENTER);
// ChartSet
JPanel chartSetPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
northPane.add(chartSetPane);
chartSetPane.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced")
));
chartSetPane.add(GUICoreUtils.createNamedPane(charSetComboBox, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Charset") + ":"));
} }
protected abstract JPanel mainPanel(); protected abstract JPanel mainPanel();
@ -69,8 +82,12 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override @Override
public void populateBean(com.fr.data.impl.Connection ob) { public void populateBean(com.fr.data.impl.Connection ob) {
this.oirginalCharSet = ob.getOriginalCharsetName(); this.originalCharSet = ob.getOriginalCharsetName();
this.newCharSet = ob.getNewCharsetName(); if (StringUtils.isBlank(originalCharSet)) {
this.charSetComboBox.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Encode_Auto"));
} else {
this.charSetComboBox.setSelectedItem(ob.getOriginalCharsetName());
}
populateSubDatabaseConnectionBean((E) ob); populateSubDatabaseConnectionBean((E) ob);
} }
@ -81,8 +98,15 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
public com.fr.data.impl.Connection updateBean() { public com.fr.data.impl.Connection updateBean() {
E ob = updateSubDatabaseConnectionBean(); E ob = updateSubDatabaseConnectionBean();
ob.setOriginalCharsetName(this.oirginalCharSet); ob.setOriginalCharsetName(this.originalCharSet);
ob.setNewCharsetName(this.newCharSet); if (this.charSetComboBox.getSelectedIndex() == 0) {
ob.setNewCharsetName(null);
ob.setOriginalCharsetName(null);
} else {
ob.setNewCharsetName(EncodeConstants.ENCODING_GBK);
ob.setOriginalCharsetName(((String) this.charSetComboBox.getSelectedItem()));
}
return ob; return ob;
} }

8
designer-base/src/main/java/com/fr/design/data/datapane/connect/JNDIDefPane.java

@ -125,7 +125,7 @@ public class JNDIDefPane extends JPanel {
} }
// Properties. // Properties.
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable(); Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
Object INITIAL_CONTEXT_FACTORY = contextHashtable.get(Context.INITIAL_CONTEXT_FACTORY); Object INITIAL_CONTEXT_FACTORY = contextHashtable.get(Context.INITIAL_CONTEXT_FACTORY);
this.JNDIFactoryComboBox.setSelectedItem(INITIAL_CONTEXT_FACTORY == null ? "" : INITIAL_CONTEXT_FACTORY); this.JNDIFactoryComboBox.setSelectedItem(INITIAL_CONTEXT_FACTORY == null ? "" : INITIAL_CONTEXT_FACTORY);
@ -148,7 +148,7 @@ public class JNDIDefPane extends JPanel {
populateContextAttributes(contextHashtable, this.APPLET_TF, Context.APPLET); populateContextAttributes(contextHashtable, this.APPLET_TF, Context.APPLET);
} }
private void populateContextAttributes(Hashtable<String, String> properties, UITextField textField, String contextAttr) { private void populateContextAttributes(Map<String, String> properties, UITextField textField, String contextAttr) {
String PROVIDER_URL = properties.get(contextAttr); String PROVIDER_URL = properties.get(contextAttr);
if (PROVIDER_URL != null) { if (PROVIDER_URL != null) {
textField.setText(PROVIDER_URL); textField.setText(PROVIDER_URL);
@ -160,7 +160,7 @@ public class JNDIDefPane extends JPanel {
jndiDatabase.setJNDIName(this.jndiNameTextField.getText()); jndiDatabase.setJNDIName(this.jndiNameTextField.getText());
Hashtable<String, String> contextHashtable = jndiDatabase.getContextHashtable(); Map<String, String> contextHashtable = jndiDatabase.getContextHashtable();
String factoryString = (String)this.JNDIFactoryComboBox.getEditor().getItem(); String factoryString = (String)this.JNDIFactoryComboBox.getEditor().getItem();
if (factoryString != null && factoryString.trim().length() > 0) { if (factoryString != null && factoryString.trim().length() > 0) {
@ -186,7 +186,7 @@ public class JNDIDefPane extends JPanel {
return jndiDatabase; return jndiDatabase;
} }
private void updateContextAttributes(Hashtable<String, String> contextHashtable, UITextField textField, String contextAttr) { private void updateContextAttributes(Map<String, String> contextHashtable, UITextField textField, String contextAttr) {
String tValue = textField.getText(); String tValue = textField.getText();
if (tValue != null && tValue.trim().length() > 0) { if (tValue != null && tValue.trim().length() > 0) {
contextHashtable.put(contextAttr, tValue); contextHashtable.put(contextAttr, tValue);

7
designer-base/src/main/java/com/fr/design/designer/DesignerProxy.java

@ -0,0 +1,7 @@
package com.fr.design.designer;
/**
* 暂时是空接口标记一下模板设计时推出的代理其他 {@link TargetComponent} 的类
*/
public interface DesignerProxy {
}

85
designer-base/src/main/java/com/fr/design/designer/TargetComponent.java

@ -1,14 +1,13 @@
package com.fr.design.designer; package com.fr.design.designer;
import com.fr.design.DesignState;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.mainframe.AuthorityEditPane; import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.JTemplateProvider;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.stable.StringUtils;
import com.fr.third.javax.annotation.Nullable; import com.fr.third.javax.annotation.Nullable;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -17,7 +16,7 @@ import javax.swing.JPanel;
/** /**
* 模板设计界面 * 模板设计界面
*/ */
public abstract class TargetComponent<T> extends JComponent { public abstract class TargetComponent<T> extends JComponent implements JTemplateProvider<T> {
private T target; private T target;
public TargetComponent(T t) { public TargetComponent(T t) {
@ -36,6 +35,7 @@ public abstract class TargetComponent<T> extends JComponent {
public abstract void stopEditing(); public abstract void stopEditing();
@Override
public T getTarget() { public T getTarget() {
return target; return target;
} }
@ -84,6 +84,7 @@ public abstract class TargetComponent<T> extends JComponent {
/** /**
* Fire template modified listeners. * Fire template modified listeners.
*/ */
@Override
public void fireTargetModified() { public void fireTargetModified() {
// Guaranteed to return a non-null array // Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList(); Object[] listeners = listenerList.getListenerList();
@ -115,82 +116,4 @@ public abstract class TargetComponent<T> extends JComponent {
public EditingState createEditingState() { public EditingState createEditingState() {
return EditingState.NULL; return EditingState.NULL;
} }
public static final TargetComponent<String> NULLAVOID = new TargetComponent<String>(StringUtils.EMPTY) {
@Override
public void copy() {
}
@Override
public boolean paste() {
return false;
}
@Override
public int getMenuState() {
return DesignState.WORK_SHEET;
}
@Override
public void cancelFormat() {
return;
}
@Override
public boolean cut() {
return false;
}
@Override
public void stopEditing() {
}
@Override
public AuthorityEditPane createAuthorityEditPane() {
return null;
}
@Override
public ToolBarMenuDockPlus getToolBarMenuDockPlus() {
return null;
}
@Override
public ToolBarDef[] toolbars4Target() {
return new ToolBarDef[0];
}
@Override
public MenuDef[] menus4Target() {
return new MenuDef[0];
}
@Override
public ShortCut[] shortcut4TemplateMenu() {
return new ShortCut[0];
}
@Override
public ShortCut[] shortCuts4Authority() {
return new ShortCut[0];
}
@Override
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
}
@Override
public JPanel getEastUpPane() {
return new JPanel();
}
@Override
public JPanel getEastDownPane() {
return new JPanel();
}
};
} }

5
designer-base/src/main/java/com/fr/design/designer/properties/PropertyTab.java

@ -0,0 +1,5 @@
package com.fr.design.designer.properties;
public enum PropertyTab {
ATTR, MOBILE
}

93
designer-base/src/main/java/com/fr/design/dialog/AbstractTemplateServerSettingPane.java

@ -0,0 +1,93 @@
package com.fr.design.dialog;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 封装了"为该模版单独设置、采用服务器设置"选项功能的设置面板
* Created by plough on 2018/11/7.
*/
public abstract class AbstractTemplateServerSettingPane extends BasicPane {
private static final String[] CHOOSEITEM = new String[] {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_I_Want_To_Set_Single"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings")
};
protected static final int SINGLE_SET = 0;
protected static final int SERVER_SET = 1;
protected UIComboBox chooseComboBox;
protected JPanel buttonPane;
private JPanel contentPane;
protected AbstractTemplateServerSettingPane() {
initComponents();
}
private void initComponents() {
chooseComboBox = new UIComboBox(CHOOSEITEM);
chooseComboBox.addItemListener(itemListener);
UILabel belowSetLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Blow_Set"));
belowSetLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
buttonPane = GUICoreUtils.createFlowPane(new Component[] {
belowSetLabel, chooseComboBox}, FlowLayout.LEFT, 0, 0);
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0));
this.setLayout(new BorderLayout());
this.add(buttonPane, BorderLayout.NORTH);
this.contentPane = getContentPane();
this.add(contentPane, BorderLayout.CENTER);
}
/**
* 包含设置项的主面板
*/
protected abstract JPanel getContentPane();
private ItemListener itemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
if (isUsingServerSettings()) {
populateServerSettings();
setSettingPaneEnabled(false);
} else {
setSettingPaneEnabled(true);
}
}
}
};
private void setSettingPaneEnabled(boolean enabled) {
// GUICoreUtils.setEnabled 会遍历所有 Component。所以要先设置外层,如果是生效的,再设置内层
GUICoreUtils.setEnabled(contentPane, enabled);
if (enabled) {
checkContentPaneEnabled();
}
}
protected boolean isUsingServerSettings() {
return chooseComboBox.getSelectedIndex() == SERVER_SET;
}
/**
* 整个配置面板设置为可用后可能还需要检测面板中部分区域的可用性
*/
protected void checkContentPaneEnabled() {
// do nothing
}
/**
* 读取服务器配置并 populate 到主面板中
*/
protected abstract void populateServerSettings();
}

83
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -1,23 +1,18 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext; import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.PluginLoginExecutor;
import com.fr.design.extra.ucenter.Client;
import com.fr.design.extra.ucenter.XMLHelper;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import javafx.scene.web.WebEngine; import javafx.scene.web.WebEngine;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.Color; import java.awt.Color;
@ -25,8 +20,6 @@ import java.awt.Desktop;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.LinkedList;
import java.util.List;
/** /**
* @author vito * @author vito
@ -150,7 +143,7 @@ public class LoginWebBridge {
try { try {
Thread.sleep(millis); Thread.sleep(millis);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
@ -161,7 +154,7 @@ public class LoginWebBridge {
try { try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.register"))); Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.register")));
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
@ -172,7 +165,7 @@ public class LoginWebBridge {
try { try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset"))); Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset")));
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
@ -202,35 +195,16 @@ public class LoginWebBridge {
if (!testConnection()) { if (!testConnection()) {
return NET_FAILED; return NET_FAILED;
} }
List<String> loginResult = frPassport(userInfo, password); int uid = 0;
String uid = loginResult.get(0);
String username = loginResult.get(1);
if (Integer.parseInt(uid) > 0) {
loginSuccess(username);
}
return uid;
}
private List<String> frPassport(String username, String password) {
LinkedList<String> list = new LinkedList<>();
try { try {
Client uc = new Client(); uid = FinePassportManager.getInstance().login(userInfo, password);
String result = uc.ucUserLogin(username, password);
result = new String(result.getBytes("iso-8859-1"), "gbk");
list = XMLHelper.ucUnserialize(result);
if (list.size() > 0) {
int uid = Integer.parseInt(list.get(0));
if (uid > 0) {
BBSLoginUtils.bbsLogin(list);
}
} else {
list.push(NET_FAILED);
}
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().info(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage(), e);
list.push(UNKNOWN_ERROR); }
if (uid > 0) {
loginSuccess(MarketConfig.getInstance().getBbsUsername());
} }
return list; return String.valueOf(uid);
} }
/** /**
@ -276,39 +250,6 @@ public class LoginWebBridge {
} }
} }
/**
* 获取用户信息
*
* @param userInfo
*/
public void getLoginInfo(String userInfo) {
try {
JSONObject jo = new JSONObject(userInfo);
String status = jo.get("status").toString();
if (ComparatorUtils.equals(status, LOGIN_SUCCESS)) {
String username = jo.get("username").toString();
int uid = Integer.parseInt(jo.get("uid") == null ? StringUtils.EMPTY : jo.get("uid").toString());
closeQQWindow();
loginSuccess(username);
LinkedList<String> list = new LinkedList<>();
list.add(String.valueOf(uid));
list.add(username);
list.add(StringUtils.EMPTY);
BBSLoginUtils.bbsLogin(list);
} else if (ComparatorUtils.equals(status, LOGIN_FAILED)) {
//账号没有QQ授权
closeQQWindow();
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("QQ_binding")));
} catch (Exception ignored) {
// ignored
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) { if (url.indexOf("qqLogin.html") > 0) {

4
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -1,8 +1,8 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor; import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
import com.fr.design.extra.exe.GetPluginCategoriesExecutor; import com.fr.design.extra.exe.GetPluginCategoriesExecutor;
@ -554,7 +554,7 @@ public class PluginWebBridge {
*/ */
public void clearUserInfo() { public void clearUserInfo() {
MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY);
BBSLoginUtils.bbsLogout(); FinePassportManager.getInstance().logout();
uiLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn")); uiLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn"));
} }

120
designer-base/src/main/java/com/fr/design/extra/ucenter/AbstractClient.java

@ -1,120 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.Base64;
import com.fr.base.FRContext;
import com.fr.stable.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
/**
* @author lp
* @date 2016/9/9
*/
public abstract class AbstractClient {
static final String UC_API_MYSQL = "ucApiMysql";
static final String UC_API_POST = "ucApiPost";
protected String urlEncode(String value) {
return URLEncoder.encode(value);
}
protected String md5(String input) {
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
return byte2hex(md.digest(input.getBytes()));
}
protected String md5(long input) {
return md5(String.valueOf(input));
}
protected String base64Decode(String input) {
try {
return new String(Base64.decode(input));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String base64Encode(String input) {
try {
return Base64.encode(input.getBytes("iso-8859-1"));
} catch (Exception e) {
FRContext.getLogger().info(e.getMessage());
return "";
}
}
protected String byte2hex(byte[] b) {
StringBuilder hs = new StringBuilder();
String stmp = "";
for (byte aB : b) {
stmp = (Integer.toHexString(aB & 0XFF));
if (stmp.length() == 1) {
hs.append("0").append(stmp);
} else {
hs.append(stmp);
}
}
return hs.toString();
}
protected String subStr(String input, int begin, int length) {
return input.substring(begin, begin + length);
}
protected String subStr(String input, int begin) {
if (begin > 0) {
return input.substring(begin);
} else {
return input.substring(input.length() + begin);
}
}
protected long microTime() {
return System.currentTimeMillis();
}
protected long time() {
return System.currentTimeMillis() / 1000;
}
protected String sprintf(String format, long input) {
String temp = "0000000000" + input;
return temp.substring(temp.length() - 10);
}
protected String callUserFunc(String function, String model, String action, Map<String, Object> args) {
if (UC_API_MYSQL.equals(function)) {
return this.ucApiMysql(model, action, args);
}
if (UC_API_POST.equals(function)) {
return this.ucApiPost(model, action, args);
}
return StringUtils.EMPTY;
}
public abstract String ucApiPost(String module, String action, Map<String, Object> arg);
public abstract String ucApiMysql(String model, String action, Map args);
protected String urlEncode(String value, String code) {
try {
return URLEncoder.encode(value, code);
} catch (UnsupportedEncodingException e) {
FRContext.getLogger().info(e.getMessage());
}
return "";
}
}

264
designer-base/src/main/java/com/fr/design/extra/ucenter/Client.java

@ -1,264 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.fr.general.CloudCenter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
*
* @author lp
* @date 2016/9/9
*/
public class Client extends AbstractClient {
private static String UC_IP = "";
private static String UC_API = "";
private static String UC_CONNECT = "";
private static String UC_KEY = "Rc85U37411p4zdvcedm8D4t4D3l9Sa42H0kd98Gbd82aA99a61S2Z5LbQ9u430M0";
private static String UC_APPID = "4";
private static String UC_CLIENT_RELEASE = "20090212";
public static String UC_ROOT = "";
private static String UC_API_FUNC = "mysql".equals(UC_CONNECT) ? UC_API_MYSQL : UC_API_POST;
public String ucUserLogin(String username, String password) {
return ucUserLogin(username, password, 0, 0);
}
public String ucUserLogin(String username, String password, int isUid, int checkQues) {
return ucUserLogin(username, password, isUid, checkQues, "", "");
}
/**
* 用户登录
*
* @param username 用户名
* @param password 密码
* @param isUid 是否为uid
* @param checkQues 是否使用安全问题
* @param questionId 安全提问
* @param answer 安全提问答案
* @return array (uid/status, username, password, email)
*/
public String ucUserLogin(String username, String password, int isUid, int checkQues, String questionId, String answer) {
Map<String, Object> args = new HashMap<>(6);
args.put("username", username);
args.put("password", password);
args.put("isUid", isUid);
args.put("checkQues", checkQues);
args.put("questionId", questionId);
args.put("answer", answer);
String res = callUserFunc(UC_API_FUNC, "user", "login", args);
return "mysql".equals(UC_CONNECT) ? res : res;
}
/**
* 拼接发送的post请求
*
* @param module 模块
* @param action 操作模式
* @param arg 参数
* @return 发送的请求加密内容
*/
@Override
public String ucApiPost(String module, String action, Map<String, Object> arg) {
StringBuilder str = new StringBuilder();
String sep = "";
for (String k : arg.keySet()) {
Object v = arg.get(k);
k = urlEncode(k);
if (v.getClass().isAssignableFrom(Map.class)) {
StringBuilder s2 = new StringBuilder();
String sep2 = "";
for (String k2 : ((Map<String, Object>) v).keySet()) {
Object v2 = ((Map<String, Object>) v).get(k2);
k2 = urlEncode(k2);
s2.append(sep2).append("{").append(k).append("}[").append(k2).append("]=").append(urlEncode(String.valueOf(v2)));
sep2 = "&";
}
str.append(sep).append(s2);
} else {
str.append(sep).append(k).append("=").append(urlEncode(String.valueOf(v), "GBK"));
}
sep = "&";
}
String postData = ucApiRequestdata(module, action, str.toString(), "");
UC_API = CloudCenter.getInstance().acquireUrlByKind("bbs.ucapi");
UC_IP = CloudCenter.getInstance().acquireUrlByKind("bbs.ip");
return ucFopen2(UC_API + "/index.php", 500000, postData, "", true, UC_IP, 20, true);
}
@Override
public String ucApiMysql(String model, String action, Map args) {
return "";
}
public String ucApiInput(String data) {
return urlEncode(ucAuthCode(data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY), "GBK");
}
protected String ucApiRequestdata(String module, String action, String arg, String extra) {
String input = ucApiInput(arg);
return "m=" + module + "&a=" + action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + input + "&appid=" + UC_APPID + extra;
}
public String ucAuthCode(String string, String operation, String key) {
return ucAuthCode(string, operation, key, 0);
}
/**
* 内容加密
*
* @param string 原文
* @param operation decode或者encode
* @param key 密钥
* @param expiry 密文有效时限
* @return 加密之后的原文
*/
public String ucAuthCode(String string, String operation, String key, int expiry) {
int ckeyLength = 4;
key = md5(key != null ? key : UC_KEY);
String keya = md5(subStr(key, 0, 16));
String keyb = md5(subStr(key, 16, 16));
String keyc = "DECODE".equals(operation) ? subStr(string, 0, ckeyLength) : subStr(md5(microTime()), -ckeyLength);
String cryptkey = keya + md5(keya + keyc);
int keyLength = cryptkey.length();
string = "DECODE".equals(operation) ? base64Decode(subStr(string, ckeyLength)) : sprintf("%010d", expiry > 0 ? expiry + time() : 0) + subStr(md5(string + keyb), 0, 16) + string;
int stringLength = string.length();
StringBuilder result1 = new StringBuilder();
int[] box = new int[256];
for (int i = 0; i < 256; i++) {
box[i] = i;
}
int[] rndkey = new int[256];
for (int i = 0; i <= 255; i++) {
rndkey[i] = (int) cryptkey.charAt(i % keyLength);
}
int j = 0;
for (int i = 0; i < 256; i++) {
j = (j + box[i] + rndkey[i]) % 256;
int tmp = box[i];
box[i] = box[j];
box[j] = tmp;
}
j = 0;
int a = 0;
for (int i = 0; i < stringLength; i++) {
a = (a + 1) % 256;
j = (j + box[a]) % 256;
int tmp = box[a];
box[a] = box[j];
box[j] = tmp;
result1.append((char) (((int) string.charAt(i)) ^ (box[(box[a] + box[j]) % 256])));
}
if ("DECODE".equals(operation)) {
String result = result1.toString();
try {
result = new String(result.getBytes("iso-8859-1"), "gbk");
} catch (Exception e) {
result = result1.substring(0, result1.length());
}
if ((Integer.parseInt(subStr(result, 0, 10)) == 0 || Long.parseLong(subStr(result, 0, 10)) - time() > 0) && subStr(result, 10, 16).equals(subStr(md5(subStr(result, 26) + keyb), 0, 16))) {
return subStr(result, 26);
} else {
return "";
}
} else {
return keyc + base64Encode(result1.toString()).replaceAll("=", "");
}
}
protected String ucFopen2(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
url += url.indexOf("?") > 0 ? "&" : "?" + "__times__=1";
return ucFopen(url, limit, post, cookie, bysocket, ip, timeout, block);
}
/**
* 本地模网络请求取数据
*
* @param url 打开的url
* @param limit 取返回的数据的长度
* @param post 要发送的 POST 数据如uid=1&password=1234
* @param cookie 要模拟的 COOKIE 数据如uid=123&auth=a2323sd2323
* @param bysocket TRUE/FALSE 是否通过SOCKET打开
* @param ip IP地址
* @param timeout 连接超时时间
* @param block 是否为阻塞模式 defaul valuet:true
* @return 取到的字符串
*/
private String ucFopen(String url, int limit, String post, String cookie, boolean bysocket, String ip, int timeout, boolean block) {
StringBuilder result = new StringBuilder();
URL matches;
String host = "";
String path = "";
int port = 80;
try {
matches = new URL(url);
host = matches.getHost();
path = matches.getPath() != null ? matches.getPath() + (matches.getQuery() != null ? "?" + matches.getQuery() : "") : "/";
if (matches.getPort() > 0) port = matches.getPort();
} catch (Exception e1) {
FRContext.getLogger().info(e1.getMessage());
}
StringBuilder out = new StringBuilder();
if (post != null && post.length() > 0) {
out.append("POST ").append(path).append(" HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("Content-Type: application/x-www-form-urlencoded\r\n");
out.append("User-Agent: \r\n");
out.append("Host: ").append(host).append("\r\n");
out.append("Content-Length: ").append(post.length()).append("\r\n");
out.append("Connection: Close\r\n");
out.append("Cache-Control: no-cache\r\n");
out.append("Cookie: \r\n\r\n");
out.append(post);
} else {
out.append("GET $path HTTP/1.0\r\n");
out.append("Accept: */*\r\n");
out.append("Accept-Language: zh-cn\r\n");
out.append("User-Agent: Java/1.5.0_01\r\n");
out.append("Host: $host\r\n");
out.append("Connection: Close\r\n");
out.append("Cookie: $cookie\r\n\r\n");
}
try {
Socket fp = new Socket(ip != null && ip.length() > 10 ? ip : host, port);
if (!fp.isConnected()) {
return "";
} else {
OutputStream os = fp.getOutputStream();
os.write(out.toString().getBytes());
InputStream ins = fp.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ins, "iso-8859-1"));
while (true) {
String header = reader.readLine();
if (header == null || "".equals(header) || Objects.equals(header, "\r\n") || Objects.equals(header, "\n")) {
break;
}
}
while (true) {
String data = reader.readLine();
if (data == null || "".equals(data)) {
break;
} else {
result.append(data);
}
}
fp.close();
}
} catch (IOException e) {
FRContext.getLogger().info(e.getMessage());
}
return result.toString();
}
}

41
designer-base/src/main/java/com/fr/design/extra/ucenter/XMLHelper.java

@ -1,41 +0,0 @@
package com.fr.design.extra.ucenter;
import com.fr.base.FRContext;
import com.sun.org.apache.xerces.internal.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.IOException;
import java.io.StringReader;
import java.util.LinkedList;
/**
* @author lp
* @date 2016/9/9
*/
public class XMLHelper {
public static LinkedList<String> ucUnserialize(String input) {
LinkedList<String> result = new LinkedList<String>();
DOMParser parser = new DOMParser();
try {
parser.parse(new InputSource(new StringReader(input)));
Document doc = parser.getDocument();
NodeList nl = doc.getChildNodes().item(0).getChildNodes();
int length = nl.getLength();
for (int i = 0; i < length; i++) {
if (nl.item(i).getNodeType() == Document.ELEMENT_NODE) {
result.add(nl.item(i).getTextContent());
}
}
} catch (SAXException e) {
FRContext.getLogger().info(e.getMessage());
} catch (IOException e1) {
FRContext.getLogger().info(e1.getLocalizedMessage());
}
return result;
}
}

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

@ -2,9 +2,11 @@ package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
@ -58,6 +60,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
public void closeSelectedReport(JTemplate<?, ?> selected) { public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane(); DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected); DesignTableDataManager.closeTemplate(selected);
//直接关闭模板的时候退出权限编辑
if (DesignModeContext.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().closeAuthorityEditing();
}
if (contains(selected) == -1) { if (contains(selected) == -1) {
return; return;
} }
@ -99,6 +105,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
return this.editingTemplate; return this.editingTemplate;
} }
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt; this.editingTemplate = jt;
//如果当前历史面板中没有 //如果当前历史面板中没有
@ -178,10 +188,13 @@ public class HistoryTemplateListCache implements CallbackEvent {
/** /**
* 判断是否打开过该模板 * 判断是否打开过该模板
* 由于切换环境不会关闭模板可能存在同名的模板所以该方法不能准确找到所选的模板
* *
* @param filename 文件名 * @param filename 文件名
* @return 文件位置 * @return 文件位置
* @deprecated use HistoryTemplateListCache#contains(com.fr.design.mainframe.JTemplate) instead
*/ */
@Deprecated
public int contains(String filename) { public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) { for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath(); String historyPath = historyList.get(i).getPath();

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

@ -1,6 +1,7 @@
package com.fr.design.file; package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
@ -60,6 +61,10 @@ public class HistoryTemplateListPane implements CallbackEvent {
return instead().getCurrentEditingTemplate(); return instead().getCurrentEditingTemplate();
} }
/**
* @param jt jt
* @see DesignerFrameFileDealerPane#setCurrentEditingTemplate(JTemplate)
*/
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
instead().setCurrentEditingTemplate(jt); instead().setCurrentEditingTemplate(jt);

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

@ -18,7 +18,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.third.javax.annotation.Nonnull; import com.fr.third.javax.annotation.Nonnull;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
@ -206,8 +205,7 @@ public class MutilTempalteTabPane extends JComponent {
openedTemplate.remove(jTemplate); openedTemplate.remove(jTemplate);
closeFormat(jTemplate); closeFormat(jTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate);
// release lock closeAndFreeLock(jTemplate);
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath());
} }
} }
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
@ -221,7 +219,6 @@ public class MutilTempalteTabPane extends JComponent {
if (openedTemplate.size() == 1) { if (openedTemplate.size() == 1) {
closeOther.setEnabled(false); closeOther.setEnabled(false);
} }
return closeOther; return closeOther;
} }
@ -676,9 +673,6 @@ public class MutilTempalteTabPane extends JComponent {
return; return;
} }
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getPath();
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) { if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing(); specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
@ -686,21 +680,29 @@ public class MutilTempalteTabPane extends JComponent {
if (returnVal == JOptionPane.YES_OPTION) { if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate(); specifiedTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} else if (returnVal == JOptionPane.NO_OPTION) { } else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} else { } else {
closeTpl(specifiedTemplate, filename); closeTpl(specifiedTemplate);
} }
} }
private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate, @Nonnull String fileName) { private void closeTpl(@Nonnull JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate); HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock closeAndFreeLock(specifiedTemplate);
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath()); activePrevTemplateAfterClose();
activeTemplate(fileName); }
private void closeAndFreeLock(@Nonnull JTemplate<?, ?> template) {
FILE file = template.getEditingFILE();
// 只有是环境内的文件,才执行释放锁
if (file != null && file.isEnvFile()) {
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
}
} }
/** /**
@ -723,11 +725,9 @@ public class MutilTempalteTabPane extends JComponent {
} }
/** /**
* 关闭掉一个模板之后该激活的Tab * 关闭掉一个模板之后激活新的待显示模板
*
* @param fileName 关闭掉一个模板之后该激活的Tab的文件名绝对路径
*/ */
private void activeTemplate(String fileName) { private void activePrevTemplateAfterClose() {
if (openedTemplate.isEmpty()) { if (openedTemplate.isEmpty()) {
//新建并激活模板 //新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@ -736,23 +736,20 @@ public class MutilTempalteTabPane extends JComponent {
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else { } else {
//如果关闭的模板是当前选中的模板,则重新激活 // 如果关闭的模板是当前选中的模板,则重新激活当前 selectIndex 的模板;
if (closeIconIndex == selectedIndex) { // selectIndex 没有变化,但是对应的模板已经变成了前一张模板
if (closeIconIndex == maxPaintIndex) { if (closeIconIndex == selectedIndex || isCloseCurrent) {
// 如果 closeIconIndex 是最后一个被渲染画出的,那么预览上一个,防止数组越界
if (closeIconIndex >= maxPaintIndex) {
// selectIndex 不会 <0 因为如果关闭的是打开的最后一个模板,那么关闭之后 openedTemplate.isEmpty() = true
selectedIndex--; selectedIndex--;
} }
} else if (isCloseCurrent) { isCloseCurrent = false;
//不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活 }
if (selectedIndex > openedTemplate.size() - 1) { // 如果关闭的模板不是当前选中的模板,那么重新获取一下当前模板的 index,激活该 index
selectedIndex -= 1; else {
if (selectedIndex < 0) { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
selectedIndex = 0; selectedIndex = HistoryTemplateListCache.getInstance().contains(template);
}
isCloseCurrent = false;
}
} else {
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName);
} }
//如果是已后台关闭的模板,则重新打开文件 //如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate(); openedTemplate.get(selectedIndex).activeOldJTemplate();

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

@ -17,6 +17,7 @@ import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -303,8 +304,6 @@ public class TemplateTreePane extends JPanel implements FileOperations {
private boolean deleteNodes(Collection<ExpandMutableTreeNode> nodes) { private boolean deleteNodes(Collection<ExpandMutableTreeNode> nodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean success = true; boolean success = true;
for (ExpandMutableTreeNode treeNode : nodes) { for (ExpandMutableTreeNode treeNode : nodes) {
Object node = treeNode.getUserObject(); Object node = treeNode.getUserObject();
@ -379,7 +378,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
TreePath[] selectedTreePaths = reportletsTree.getSelectionPaths(); TreePath[] selectedTreePaths = reportletsTree.getSelectionPaths();
if (selectedTreePaths == null || selectedTreePaths.length != 1) { if (ArrayUtils.isEmpty(selectedTreePaths)) {
return false; return false;
} }
// 选中的是文件夹 // 选中的是文件夹

69
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -63,19 +63,19 @@ import java.util.Locale;
*/ */
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea;
protected RSyntaxTextArea formulaTextArea; private RSyntaxTextArea formulaTextArea;
protected UITextField keyWordTextField = new UITextField(18); private UITextField keyWordTextField = new UITextField(18);
protected int currentPosition = 0; private int currentPosition = 0;
protected int beginPosition = 0; private int beginPosition = 0;
protected int insertPosition = 0; private int insertPosition = 0;
protected JList tipsList; private JList tipsList;
protected DefaultListModel listModel = new DefaultListModel(); protected DefaultListModel listModel = new DefaultListModel();
protected int ifHasBeenWriten = 0; private int ifHasBeenWriten = 0;
protected DefaultListModel functionTypeListModel = new DefaultListModel(); private DefaultListModel functionTypeListModel = new DefaultListModel();
protected QuickList functionTypeList; private QuickList functionTypeList;
protected DefaultListModel functionNameModel; private DefaultListModel functionNameModel;
protected JList functionNameList; private JList functionNameList;
public FormulaPane() { public FormulaPane() {
initComponents(); initComponents();
@ -184,6 +184,18 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
protected void initComponents() { protected void initComponents() {
this.setLayout(new BorderLayout(4, 4)); this.setLayout(new BorderLayout(4, 4));
initTextPane();
initTipsPane();
initVariableTreeAndDescriptionArea();
}
private void initVariableTreeAndDescriptionArea() {
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
}
private void initTextPane() {
// text // text
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(textPane, BorderLayout.CENTER); this.add(textPane, BorderLayout.CENTER);
@ -199,7 +211,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER); textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER);
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH); textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH);
initTipsPane();
UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid")); UIButton checkValidButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Check_Valid"));
checkValidButton.addActionListener(checkValidActionListener); checkValidButton.addActionListener(checkValidActionListener);
@ -209,8 +220,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST);
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST);
extendCheckBoxPane(checkBoxPane); extendCheckBoxPane(checkBoxPane);
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea();
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH);
} }
@ -218,7 +227,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
protected void configFormulaArea() { private void configFormulaArea() {
formulaTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_FORMULA); formulaTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_FORMULA);
formulaTextArea.setAnimateBracketMatching(true); formulaTextArea.setAnimateBracketMatching(true);
formulaTextArea.setAntiAliasingEnabled(true); formulaTextArea.setAntiAliasingEnabled(true);
@ -313,7 +322,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
} }
protected void fixFunctionNameList() { private void fixFunctionNameList() {
if (tipsList.getSelectedValue() != null) { if (tipsList.getSelectedValue() != null) {
int signOfContinue = 1; int signOfContinue = 1;
int indexOfFunction = 0; int indexOfFunction = 0;
@ -346,7 +355,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
protected int getBeginPosition() { private int getBeginPosition() {
int i = currentPosition; int i = currentPosition;
String textArea = formulaTextArea.getText(); String textArea = formulaTextArea.getText();
for (; i > 0; i--) { for (; i > 0; i--) {
@ -361,7 +370,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return i; return i;
} }
protected void firstStepToFindTips(int theBeginPosition) { private void firstStepToFindTips(int theBeginPosition) {
String textArea = formulaTextArea.getText(); String textArea = formulaTextArea.getText();
if (currentPosition > 0 && theBeginPosition < currentPosition) { if (currentPosition > 0 && theBeginPosition < currentPosition) {
@ -443,7 +452,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
/** /**
* Apply text. * Apply text.
*/ */
public void applyText(String text) { private void applyText(String text) {
if (text == null || text.length() <= 0) { if (text == null || text.length() <= 0) {
return; return;
} }
@ -541,7 +550,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
} }
// check valid // check valid
protected ActionListener checkValidActionListener = new ActionListener() { private ActionListener checkValidActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// Execute Formula default cell element. // Execute Formula default cell element.
@ -579,7 +588,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private JTree variablesTree; private JTree variablesTree;
private UITextArea descriptionTextArea; private UITextArea descriptionTextArea;
public VariableTreeAndDescriptionArea() { VariableTreeAndDescriptionArea() {
this.initComponents(); this.initComponents();
} }
@ -802,13 +811,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private void initComponents() { private void initComponents() {
this.setLayout(new BorderLayout(4, 4)); this.setLayout(new BorderLayout(4, 4));
// Function initVariablesTree();
initFunctionPane();
}
private void initFunctionPane() {
JPanel functionPane = new JPanel(new BorderLayout(4, 4)); JPanel functionPane = new JPanel(new BorderLayout(4, 4));
this.add(functionPane, BorderLayout.WEST); this.add(functionPane, BorderLayout.WEST);
initFunctionTypeList(functionPane); initFunctionTypeList(functionPane);
initFunctionNameList(functionPane); initFunctionNameList(functionPane);
initVariablesTree();
// 选择:
functionTypeList.setSelectedIndex(0); functionTypeList.setSelectedIndex(0);
} }
@ -959,7 +970,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
private Icon icon; private Icon icon;
private String[] subNodes = new String[0]; private String[] subNodes = new String[0];
public TextFolderUserObject(String text, Icon icon, String[] subNodes) { TextFolderUserObject(String text, Icon icon, String[] subNodes) {
this.text = text; this.text = text;
this.icon = icon; this.icon = icon;
this.subNodes = subNodes; this.subNodes = subNodes;
@ -986,11 +997,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
public static class TextUserObject { public static class TextUserObject {
public TextUserObject(String text) { TextUserObject(String text) {
this(text, text); this(text, text);
} }
public TextUserObject(String text, String displayText) { TextUserObject(String text, String displayText) {
this.text = text; this.text = text;
this.displayText = displayText; this.displayText = displayText;
} }
@ -999,7 +1010,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
return this.text; return this.text;
} }
public String getDisplayText() { String getDisplayText() {
return this.displayText; return this.displayText;
} }

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

@ -13,6 +13,8 @@ import com.fr.function.SUM;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
@ -34,13 +36,88 @@ import java.util.zip.ZipFile;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
public abstract class FunctionConstants { public final class FunctionConstants {
public static FunctionGroup PLUGIN = getPluginFunctionGroup();
public static FunctionGroup CUSTOM = getCustomFunctionGroup();
static NameAndFunctionList COMMON = getCommonFunctionList();
static NameAndTypeAndFunctionList[] EMBFUNCTIONS = getEmbededFunctionListArray();
public static FunctionGroup ALL = getAllFunctionGroup();
static {
loadEmbededFunctions();
}
/** /**
* Don't let anyone instantiate this class.
*/
private FunctionConstants() {}
private static void loadEmbededFunctions() {
String pkgName = "com.fr.function";
Class<Function> iface = Function.class;
ClassLoader classloader = iface.getClassLoader();
Enumeration<URL> urlEnumeration = null;
try {
urlEnumeration = classloader.getResources(pkgName.replace('.', '/'));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
return;
}
while (urlEnumeration.hasMoreElements()) {
URL url = urlEnumeration.nextElement();
String classFilePath = url.getFile();
/*
* alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理
* 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理
*/
try {
classFilePath = URLDecoder.decode(classFilePath, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e1) {
FRContext.getLogger().error(e1.getMessage(), e1);
}
FRContext.getLogger().info("ClassFilePath:" + classFilePath);
if (isCustomFormulaPath(classFilePath)) {
continue;
}
for (String fileName : findClassNamesUnderFilePath(classFilePath)) {
try {
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6));
if (StableUtils.classInstanceOf(cls, iface)) {
Function inst;
inst = (Function)cls.newInstance();
for (NameAndTypeAndFunctionList EMBFUNCTION : EMBFUNCTIONS) {
if (EMBFUNCTION.test(inst)) {
break;
}
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ignore) {
} catch (Throwable e) {
// 不要因为个别公式加载失败,而导致整个函数面板无法启动
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
}
}
private static boolean isCustomFormulaPath(String classFilePath) {
return !isJarPath(classFilePath) && isNotDebugMode();
}
private static boolean isNotDebugMode() {
return GeneralUtils.readBuildNO().contains("-");
}
private static boolean isJarPath(String classFilePath) {
return classFilePath.contains("!/");
}
/**
* 将函数分组插件中的函数添加到对应的列表中 * 将函数分组插件中的函数添加到对应的列表中
* @param listModel * @param listModel
*/ */
public static void addFunctionGroupFromPlugins(DefaultListModel listModel){ static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组 //hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){ if(!containers.isEmpty()){
@ -74,107 +151,15 @@ public abstract class FunctionConstants {
} }
}; };
} }
public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Formula_Plugin");
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] fs = ExtraClassManager.getInstance().getFunctionDef();
int count = fs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(fs[i]);
}
return nads;
}
};
public static FunctionGroup CUSTOM = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Custom_Function");
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionConfig funtionManager = FunctionConfig.getInstance();
if (funtionManager != null) {
int functionDefCount = funtionManager.getFunctionDefCount();
FunctionDefNAD[] nads = new FunctionDefNAD[functionDefCount];
for (int i = 0; i < functionDefCount; i++) {
nads[i] = new FunctionDefNAD(funtionManager.getFunctionDef(i));
}
return nads;
}
return new NameAndDescription[0];
}
};
public static NameAndFunctionList COMMON = new NameAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Most_Recently_Used"), new Function[] {
new SUM(), new COUNT(), new AVERAGE(), new CHAR(), new DATE(), new MAX(), new MIN(), new TIME(), new RANGE()
});
public static NameAndTypeAndFunctionList[] EMBFUNCTIONS = new NameAndTypeAndFunctionList[] {
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Math_&_Trig"), Function.MATH),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Text"), Function.TEXT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Date_&_Time"), Function.DATETIME),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Logical"), Function.LOGIC),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Array"), Function.ARRAY),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Report"), Function.REPORT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Other"), Function.OTHER),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_Type_Hierarchy"), Function.HA)
};
public static FunctionGroup ALL = new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_All");
}
@Override
public NameAndDescription[] getDescriptions() {
List<NameAndDescription> all = new ArrayList<NameAndDescription>();
for (int i = 0; i < EMBFUNCTIONS.length; i++) {
all.addAll(Arrays.asList(EMBFUNCTIONS[i].getDescriptions()));
}
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
java.util.Collections.sort(all, NameAndDescriptionComparator);
return all.toArray(new NameAndDescription[all.size()]);
}
};
private static Comparator<NameAndDescription> NameAndDescriptionComparator = new Comparator<NameAndDescription>() {
@Override
public int compare(NameAndDescription o1, NameAndDescription o2) {
return ComparatorUtils.compare(o1.getName(), o2.getName());
}
};
private static String[] findClassNamesUnderFilePath(String filePath) { private static String[] findClassNamesUnderFilePath(String filePath) {
java.util.List<String> classNameList = new ArrayList<String>(); java.util.List<String> classNameList = new ArrayList<String>();
/* /*
* alex:如果是jar包中的class文件 * alex:如果是jar包中的class文件
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function * file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function
*/ */
if (filePath.indexOf("!/") >= 0) { if (isJarPath(filePath)) {
String[] arr = filePath.split("!/"); String[] arr = filePath.split("!/");
String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符 String jarPath = arr[0].substring(6); // alex:substring(6)去掉前面的file:/这六个字符
String classPath = arr[1]; String classPath = arr[1];
@ -197,7 +182,7 @@ public abstract class FunctionConstants {
} }
String entryName = entry.getName(); String entryName = entry.getName();
if (entryName.indexOf(classPath) < 0 || !entryName.endsWith(".class")) { if (!entryName.contains(classPath) || !entryName.endsWith(".class")) {
continue; continue;
} }
@ -208,57 +193,117 @@ public abstract class FunctionConstants {
} }
} else { } else {
File dir = new File(filePath); File dir = new File(filePath);
File[] files = dir.listFiles();
for (File f : dir.listFiles()) { if (files != null) {
String fileName = f.getName(); for (File f : files) {
if (fileName.endsWith(".class")) { String fileName = f.getName();
classNameList.add(fileName); if (fileName.endsWith(".class")) {
classNameList.add(fileName);
}
} }
} }
} }
return classNameList.toArray(new String[classNameList.size()]); return classNameList.toArray(new String[0]);
} }
// alex:读取com.fr.script.function包下面所有的Function类 private static FunctionGroup getPluginFunctionGroup() {
static { return new FunctionGroup() {
String pkgName = "com.fr.function"; @Override
Class<Function> iface = Function.class; public String getGroupName() {
ClassLoader classloader = iface.getClassLoader(); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Formula_Plugin");
URL url = classloader.getResource(pkgName.replace('.', '/')); }
String classFilePath = url.getFile();
@Override
/* public NameAndDescription[] getDescriptions() {
* alex:url.getFile获取的地址中,如果有空格或中文会被URLEncoder.encode处理 FunctionDef[] fs = ExtraClassManager.getInstance().getFunctionDef();
* 会变成%20这种%打头的东西,但是new File的时候%20是无法解析成空格,所以在此需要做URLDecoder.decode处理 int count = fs.length;
*/ FunctionDefNAD[] nads = new FunctionDefNAD[count];
try { for (int i = 0; i < count; i ++) {
classFilePath = URLDecoder.decode(classFilePath, EncodeConstants.ENCODING_UTF_8); nads[i] = new FunctionDefNAD(fs[i]);
} catch (UnsupportedEncodingException e1) { }
FRContext.getLogger().error(e1.getMessage(), e1); return nads;
} }
FRContext.getLogger().info("ClassFilePath:" + classFilePath); };
/* }
* alex:如果是jar包中的class文件
* file:/D:/opt/FineReport6.5/WebReport/WEB-INF/lib/fr-server-6.5.jar!/com/fr/rpt/script/function private static FunctionGroup getCustomFunctionGroup() {
*/ return new FunctionGroup() {
for (String fileName : findClassNamesUnderFilePath(classFilePath)) { @Override
try { public String getGroupName() {
Class<?> cls = Class.forName(pkgName + "." + fileName.substring(0, fileName.length() - 6)); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Custom_Function");
if (StableUtils.classInstanceOf(cls, iface)) { }
Function inst;
inst = (Function)cls.newInstance(); @Override
for (int fi = 0; fi < EMBFUNCTIONS.length; fi++) { public NameAndDescription[] getDescriptions() {
if (EMBFUNCTIONS[fi].test(inst)) { FunctionConfig funtionManager = FunctionConfig.getInstance();
break; if (funtionManager != null) {
} int functionDefCount = funtionManager.getFunctionDefCount();
FunctionDefNAD[] nads = new FunctionDefNAD[functionDefCount];
for (int i = 0; i < functionDefCount; i++) {
nads[i] = new FunctionDefNAD(funtionManager.getFunctionDef(i));
} }
return nads;
} }
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) { return new NameAndDescription[0];
} catch (IllegalAccessException e) {
} }
} };
}
private static NameAndFunctionList getCommonFunctionList() {
return new NameAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Most_Recently_Used"), new Function[] {
new SUM(), new COUNT(), new AVERAGE(), new CHAR(), new DATE(), new MAX(), new MIN(), new TIME(), new RANGE()
});
}
private static NameAndTypeAndFunctionList[] getEmbededFunctionListArray() {
return new NameAndTypeAndFunctionList[] {
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Math_&_Trig"), Function.MATH),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Text"), Function.TEXT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Date_&_Time"), Function.DATETIME),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Logical"), Function.LOGIC),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Array"), Function.ARRAY),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Report"), Function.REPORT),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Other"), Function.OTHER),
new NameAndTypeAndFunctionList(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_Type_Hierarchy"), Function.HA)
};
}
private static FunctionGroup getAllFunctionGroup() {
return new FunctionGroup() {
@Override
public String getGroupName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_All");
}
@Override
public NameAndDescription[] getDescriptions() {
List<NameAndDescription> all = new ArrayList<NameAndDescription>();
for (int i = 0; i < EMBFUNCTIONS.length; i++) {
all.addAll(Arrays.asList(EMBFUNCTIONS[i].getDescriptions()));
}
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
Collections.sort(all, new Comparator<NameAndDescription>() {
@Override
public int compare(NameAndDescription o1, NameAndDescription o2) {
return ComparatorUtils.compare(o1.getName(), o2.getName());
}
});
return all.toArray(new NameAndDescription[0]);
}
};
} }
} }

31
designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProcessor.java

@ -1,31 +0,0 @@
package com.fr.design.fun;
import com.fr.stable.fun.ReportFitAttrProvider;
import com.fr.stable.fun.mark.Immutable;
import java.beans.PropertyDescriptor;
/**
* Created by Slpire on 2016/10/28.
*/
public interface FormElementCaseEditorProcessor extends Immutable {
String MARK_STRING = "PropertyEditor";
int CURRENT_LEVEL = 1;
/**
* 生成属性表
* @param temp 传入当前操作的class
* @param reportFitAttr 传入的自适应属性
* @return 返回属性表
*/
PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr);
/**
* 返回pc自适应属性值
* @param fitAttrProvider 传入的自适应属性
* @return 返回pc自适应属性值
*/
int getFitStateInPC(ReportFitAttrProvider fitAttrProvider);
}

15
designer-base/src/main/java/com/fr/design/fun/FormElementCaseEditorProvider.java

@ -2,7 +2,6 @@ package com.fr.design.fun;
import com.fr.form.FormProvider; import com.fr.form.FormProvider;
import com.fr.form.ui.ElementCaseEditorProvider; import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.stable.fun.ReportFitAttrProvider;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
@ -18,18 +17,4 @@ public interface FormElementCaseEditorProvider extends Mutable {
PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, FormProvider formProvider, ElementCaseEditorProvider editor); PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, FormProvider formProvider, ElementCaseEditorProvider editor);
/**
* 生成属性表
* @param temp 传入当前操作的class
* @param reportFitAttr 传入的自适应属性
* @return 返回属性表
*/
PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr);
/**
* 返回pc自适应属性值
* @param fitAttrProvider 传入的自适应属性
* @return 返回pc自适应属性值
*/
int getFitStateInPC(ReportFitAttrProvider fitAttrProvider);
} }

31
designer-base/src/main/java/com/fr/design/fun/HyperlinkProvider.java

@ -1,21 +1,44 @@
package com.fr.design.fun; package com.fr.design.fun;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.stable.fun.Level; import com.fr.js.Hyperlink;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
/** /**
* Created by zack on 2016/1/20. * Created by zack on 2016/1/20.
*/ */
public interface HyperlinkProvider extends Mutable { public interface HyperlinkProvider<T extends Hyperlink> extends Mutable {
String XML_TAG = "HyperlinkProvider"; String XML_TAG = "HyperlinkProvider";
int CURRENT_LEVEL = 2; int CURRENT_LEVEL = 2;
/** /**
* 创建一个超级连接类型 * 超级链接的描述信息如果是实现类中重载了这个方法就不需要再实现下面的三个方法
* @return NameableCreator * @see HyperlinkProvider#text()
* @see HyperlinkProvider#target()
* @see HyperlinkProvider#appearance()
* 如果并不重载就需要分别实现上面的三个方法不推荐重载这个方法
* @return 描述信息
*/ */
NameableCreator createHyperlinkCreator(); NameableCreator createHyperlinkCreator();
/**
* 超级链接的名字
* @return 名字
*/
String text();
/**
* 超级链接的实现类
* @return 实现类
*/
Class<T> target();
/**
* 超级链接的界面配置类
* @return 配置类
*/
Class<? extends BasicBeanPane<T>> appearance();
} }

17
designer-base/src/main/java/com/fr/design/fun/JavaScriptActionProvider.java

@ -2,11 +2,12 @@ package com.fr.design.fun;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
/** /**
* Created by zack on 2015/8/14. * 控件的事件扩展接口
*/ */
public interface JavaScriptActionProvider extends Mutable{ public interface JavaScriptActionProvider extends Mutable{
@ -14,9 +15,21 @@ public interface JavaScriptActionProvider extends Mutable{
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 1;
/**
* 事件的界面
*/
FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(); FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane();
/**
* 这个界面在哪些类型模板设计的时候会出现
* @see com.fr.design.mainframe.JWorkBook
* @see com.fr.design.mainframe.JForm
*/
boolean accept(JTemplate template);
@Deprecated
FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane); FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane);
boolean isSupportType(); @Deprecated
boolean isSupportType();
} }

31
designer-base/src/main/java/com/fr/design/fun/ParameterExpandablePaneUIProvider.java

@ -0,0 +1,31 @@
package com.fr.design.fun;
import com.fr.design.designer.properties.PropertyTab;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.stable.fun.mark.Mutable;
/**
* created by hades on 18/10/16
* 该接口支持在设计器cpt&frm参数界面的属性和移动端下添加一个UIExpandablePane可展开面板
*/
public interface ParameterExpandablePaneUIProvider extends Mutable {
String XML_TAG = "ParameterExpandablePaneUIProvider";
int CURRENT_LEVEL = 1;
/**
* 创建可展开面板并添加子容器
*
* @return UIExpandablePane
*/
UIExpandablePane createUIExpandablePane();
/**
* 指定添加UIExpandablePane到哪个PropertyTab下例如属性移动端
*
* @return PropertyTab
*/
PropertyTab addToWhichPropertyTab();
}

55
designer-base/src/main/java/com/fr/design/fun/RightSelectionHandlerProvider.java

@ -0,0 +1,55 @@
package com.fr.design.fun;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.mark.Mutable;
import java.util.List;
/**
* 设计器右键菜单接口
*/
public interface RightSelectionHandlerProvider extends Mutable {
int CURRENT_LEVEL = 1;
String XML_TAG = "RightSelectionHandlerProvider";
/**
* 对单元格或者悬浮元素的右键菜单项进行增删改
*
* @param ePane 选择的元素
* @param popupMenu 右键主菜单
*/
void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu);
/**
* 当前实现是否可以作用于当前元素
*
* @param selectableElement 当前选中元素分为CellSelection和FloatSelection(单元格和悬浮元素)
* @return
*/
boolean accept(SelectableElement selectableElement);
/**
* 对表单,参数面板内置的右键选项进行增删改处理
*
* @param actions 默认的action集合 注意:主体代码要求这边的action必须是UndoableAction 的子类而非updateAction
*/
void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions);
/**
* 当前实现是否可以作用于当前元素
*
* @param formDesigner 当前选中元素分为表单编辑器和参数面板(表单组件元素以及各种控件)
* @return
*/
boolean accept(BaseFormDesigner formDesigner);
}

44
designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProcessor.java

@ -1,44 +0,0 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.FormElementCaseEditorProcessor;
import com.fr.stable.fun.ReportFitAttrProvider;
import com.fr.stable.fun.mark.API;
import java.beans.PropertyDescriptor;
/**
* Created by zhouping on 2015/9/10.
*/
@API(level = FormElementCaseEditorProcessor.CURRENT_LEVEL)
public abstract class AbstractFormElementCaseEditorProcessor implements FormElementCaseEditorProcessor {
public int currentAPILevel() {
return CURRENT_LEVEL;
}
public int layerIndex() {
return DEFAULT_LAYER_INDEX;
}
/**
* 生成属性表
* @param temp 传入当前操作的class
* @param reportFitAttr 传入的自适应属性
* @return 返回属性表
*/
@Override
public PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr) {
return new PropertyDescriptor[0];
}
/**
* 返回pc自适应属性值
* @param fitAttrProvider 传入的自适应属性
* @return 返回pc自适应属性值
*/
@Override
public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) {
return 0;
}
}

21
designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java

@ -3,7 +3,6 @@ package com.fr.design.fun.impl;
import com.fr.design.fun.FormElementCaseEditorProvider; import com.fr.design.fun.FormElementCaseEditorProvider;
import com.fr.form.FormProvider; import com.fr.form.FormProvider;
import com.fr.form.ui.ElementCaseEditorProvider; import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.stable.fun.ReportFitAttrProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
import java.beans.PropertyDescriptor; import java.beans.PropertyDescriptor;
@ -28,24 +27,4 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme
return new PropertyDescriptor[0]; return new PropertyDescriptor[0];
} }
/**
* 生成属性表
* @param temp 传入当前操作的class
* @param reportFitAttr 传入的自适应属性
* @return 返回属性表
*/
@Override
public PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportFitAttrProvider reportFitAttr) {
return new PropertyDescriptor[0];
}
/**
* 返回pc自适应属性值
* @param fitAttrProvider 传入的自适应属性
* @return 返回pc自适应属性值
*/
@Override
public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) {
return 0;
}
} }

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

@ -1,6 +1,10 @@
package com.fr.design.fun.impl; package com.fr.design.fun.impl;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.fun.HyperlinkProvider; import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
@ -18,4 +22,24 @@ public abstract class AbstractHyperlinkProvider extends AbstractProvider impleme
public String mark4Provider() { public String mark4Provider() {
return getClass().getName(); return getClass().getName();
} }
@Override
public NameableCreator createHyperlinkCreator() {
return new NameObjectCreator(text(), target(), appearance());
}
@Override
public String text() {
return StringUtils.EMPTY;
}
@Override
public Class target() {
return null;
}
@Override
public Class<? extends BasicBeanPane> appearance() {
return null;
}
} }

18
designer-base/src/main/java/com/fr/design/fun/impl/AbstractJavaScriptActionProvider.java

@ -3,6 +3,8 @@ package com.fr.design.fun.impl;
import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
@ -26,11 +28,17 @@ public abstract class AbstractJavaScriptActionProvider extends AbstractProvider
public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane) { public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane(JavaScriptActionPane pane) {
return getJavaScriptActionPane(); return getJavaScriptActionPane();
} }
/** @Override
* 判断是否是支持的类型cpt,frm默认是 public boolean accept(JTemplate template) {
* @return // 这里只是为了兼容原来的isSupportType方法
*/ boolean result = isSupportType();
if (result) {
return true;
}
return true;
}
@Override @Override
public boolean isSupportType(){ public boolean isSupportType(){
return true; return true;

19
designer-base/src/main/java/com/fr/design/fun/impl/AbstractParameterExpandablePaneUIProvider.java

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

45
designer-base/src/main/java/com/fr/design/fun/impl/AbstractRightSelectionHandlerProvider.java

@ -0,0 +1,45 @@
package com.fr.design.fun.impl;
import com.fr.design.actions.UpdateAction;
import com.fr.design.designer.TargetComponent;
import com.fr.design.fun.RightSelectionHandlerProvider;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.BaseFormDesigner;
import com.fr.design.selection.SelectableElement;
import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API;
import java.util.List;
@API(level = RightSelectionHandlerProvider.CURRENT_LEVEL)
public abstract class AbstractRightSelectionHandlerProvider extends AbstractProvider implements RightSelectionHandlerProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public void dmlUpdateActions(BaseFormDesigner formDesigner, List<UpdateAction> actions) {
}
@Override
public boolean accept(BaseFormDesigner formDesigner) {
return false;
}
@Override
public void dmlMenu(TargetComponent ePane, UIPopupMenu popupMenu) {
}
@Override
public boolean accept(SelectableElement selectableElement) {
return false;
}
}

7
designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java

@ -8,6 +8,7 @@ import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.CardLayout; import java.awt.CardLayout;
@ -71,7 +72,11 @@ class JControlUpdatePane extends JPanel {
cardPane.add(updatePanes[i], String.valueOf(i)); cardPane.add(updatePanes[i], String.valueOf(i));
} }
card.show(cardPane, String.valueOf(i)); card.show(cardPane, String.valueOf(i));
updatePanes[i].populateBean(ob2Populate); try{
updatePanes[i].populateBean(ob2Populate);
}catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
break; break;
} }
} }

16
designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java

@ -667,18 +667,10 @@ public class UIBasicMenuItemUI extends MenuItemUI {
} }
private void installFont(final String prefix, final JComponent menuItem) { private void installFont(final String prefix, final JComponent menuItem) {
Thread thread = new Thread(new Runnable() { if (menuItem == null) {
@Override return;
public void run() { }
if (menuItem == null) { LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
return;
}
LookAndFeel.installColorsAndFont(menuItem, prefix + ".background", prefix + ".foreground", prefix + ".font");
}
});
thread.setName("UIBasicMenuItemUI");
thread.setDaemon(true);
thread.start();
} }
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon,

14
designer-base/src/main/java/com/fr/design/gui/itextfield/UIAutoCompletionField.java

@ -1,11 +1,11 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import com.fr.design.gui.imenu.UIListPopup; import com.fr.design.gui.imenu.UIListPopup;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import javax.swing.*; import javax.swing.JList;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionEvent;
@ -13,10 +13,12 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.text.AbstractDocument; import javax.swing.text.AbstractDocument;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Document; import javax.swing.text.Document;
import java.awt.event.ActionEvent;
import java.awt.Dimension; import java.awt.event.ActionListener;
import java.awt.LayoutManager; import java.awt.event.KeyEvent;
import java.awt.event.*; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList; import java.util.ArrayList;
public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener { public class UIAutoCompletionField extends UITextField implements DocumentListener, MouseListener, ListSelectionListener, ActionListener, KeyListener {

7
designer-base/src/main/java/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java

@ -100,10 +100,9 @@ public class CheckBoxTreeCellRenderer extends NullPanel implements TreeCellRende
Border border = treeCellRendererComponent.getBorder(); Border border = treeCellRendererComponent.getBorder();
setBorder(border); setBorder(border);
treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder()); treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder());
//todo 可能会发生数组越界,需要处理一下
if (getComponentCount() == 2) { remove((Component) this._actualTreeRenderer);
remove(1);
}
add(treeCellRendererComponent); add(treeCellRendererComponent);
} }

4
designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java

@ -69,10 +69,8 @@ public class EnvFileTree extends RefreshableJTree {
if (treeNode.hasFullAuthority()) { if (treeNode.hasFullAuthority()) {
if (lock != null && !node.getUserID().equals(lock)) { if (lock != null && !node.getUserID().equals(lock)) {
name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")"); name = name + Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked", "(", ")");
this.setIcon(FileTreeIcon.getIcon(node));
} else {
this.setIcon(FileTreeIcon.getIcon(node, false));
} }
this.setIcon(FileTreeIcon.getIcon(node));
} else { } else {
this.setIcon(FileTreeIcon.getFolderHalfImageIcon()); this.setIcon(FileTreeIcon.getFolderHalfImageIcon());
} }

6
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeComparator.java

@ -3,13 +3,15 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
/** /**
* FileTreeNode compare... * FileTreeNode compare...
* Directory is in the first. and normal file the in the last. * Directory is in the first. and normal file the in the last.
*/ */
public class FileNodeComparator implements Comparator<FileNode> { public class FileNodeComparator implements Comparator<FileNode>, Serializable {
/** /**
* 正序还是倒序 * 正序还是倒序
*/ */
@ -46,7 +48,7 @@ public class FileNodeComparator implements Comparator<FileNode> {
public FileNodeComparator(boolean reverse, String[] types) { public FileNodeComparator(boolean reverse, String[] types) {
this.isReverse = reverse; this.isReverse = reverse;
this.supportTypes = types; this.supportTypes = Arrays.copyOf(types, types.length);
} }
/** /**

11
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -3,6 +3,7 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.icon.LockIcon; import com.fr.design.icon.LockIcon;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -125,8 +126,16 @@ public class FileTreeIcon {
return FOLDER_HALF_IMAGE_ICON; return FOLDER_HALF_IMAGE_ICON;
} }
/**
* 获取文件节点对应的图标
*
* @param node 文件节点
* @return 文件节点的图标
*/
public static Icon getIcon(FileNode node) { public static Icon getIcon(FileNode node) {
return getIcon(node, node.getLock() != null); // 如果文件节点锁不为空且不是当前用户锁定的该模板,那么模板ICON 提示用户当前文件节点被锁
boolean showLock = node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock());
return getIcon(node, showLock);
} }
public static Icon getIcon(FileNode node, boolean isShowLock) { public static Icon getIcon(FileNode node, boolean isShowLock) {

7
designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java

@ -37,9 +37,12 @@ import java.util.Vector;
* Pane to edit Font. * Pane to edit Font.
*/ */
public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObserver { public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObserver {
public static final Integer[] FONT_SIZES = {
6, 8, 9, 10, 11, 12, 13, 14, 16,
18, 20, 22, 24, 26, 28, 30, 32, 34,
36, 38, 40, 48, 64, 72, 128
};
private static final int MAX_FONT_SIZE = 100; private static final int MAX_FONT_SIZE = 100;
public static Integer[] FONT_SIZES = {new Integer(6), new Integer(8), new Integer(9), new Integer(10), new Integer(11), new Integer(12), new Integer(14), new Integer(16),
new Integer(18), new Integer(20), new Integer(22), new Integer(24), new Integer(26), new Integer(28), new Integer(36), new Integer(48), new Integer(72)};
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
private static final Dimension UNDER_LINE_SIZE = new Dimension(87, 20); private static final Dimension UNDER_LINE_SIZE = new Dimension(87, 20);
private static final Dimension HIDE_SIZE = new Dimension(0, 0); private static final Dimension HIDE_SIZE = new Dimension(0, 0);

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

@ -6,11 +6,14 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.js.Hyperlink; import com.fr.js.Hyperlink;
import javax.swing.*; import javax.swing.DefaultListCellRenderer;
import java.awt.*; import javax.swing.JList;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
@ -21,10 +24,17 @@ public abstract class AbstractHyperNorthPane<T extends Hyperlink> extends BasicB
public static final int DEFAULT_H_VALUE = 400; public static final int DEFAULT_H_VALUE = 400;
public static final int DEFAULT_V_VALUE = 600; public static final int DEFAULT_V_VALUE = 600;
private JPanel headerPane; /**
* 链接打开方式对话框
*/
private UIComboBox targetFrameComboBox; private UIComboBox targetFrameComboBox;
/**
* 对话框高度输入框
*/
private UINumberField heightTextFiled; private UINumberField heightTextFiled;
/**
* 对话框宽度输入框
*/
private UINumberField widthTextFiled; private UINumberField widthTextFiled;
@ -35,7 +45,7 @@ public abstract class AbstractHyperNorthPane<T extends Hyperlink> extends BasicB
protected void initComponents() { protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
headerPane = this.setHeaderPanel(); JPanel headerPane = this.setHeaderPanel();
this.add(headerPane, BorderLayout.NORTH); this.add(headerPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
targetFrameComboBox = new UIComboBox(getTargetFrames()); targetFrameComboBox = new UIComboBox(getTargetFrames());

184
designer-base/src/main/java/com/fr/design/hyperlink/ReporletHyperNorthPane.java

@ -1,184 +0,0 @@
package com.fr.design.hyperlink;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.ReportletPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.ReportletHyperlink;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面.
*
* @author kunsnat
*/
public class ReporletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> {
private UITextField itemNameTextField;
private boolean needRenamePane = false;
private UITextField reportPathTextField;
private UICheckBox showParameterInterface;
private UIButton browserButton;
// richer:参数传递方式
private UIComboBox postComboBox;
public ReporletHyperNorthPane(boolean needRenamePane) {
this.needRenamePane = needRenamePane;
this.inits();
}
public ReporletHyperNorthPane() {
this.inits();
}
/**
* 初始化组件
*/
public void inits() {
super.initComponents();
}
@Override
protected JPanel setHeaderPanel() {
JPanel headerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] columnSize = {p, TableLayout.FILL};
// Reportlet.
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
reportPathTextField = new UITextField(20);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
browserButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReporletHyperNorthPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
Component[][] components;
if (!this.needRenamePane) {
components = new Component[][]{
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane},
};
} else {
itemNameTextField = new UITextField();
components = new Component[][]{
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField},
{new UILabel(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), reportletNamePane},
};
}
JPanel northPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
headerPane.add(northPane, BorderLayout.NORTH);
return headerPane;
}
@Override
protected String title4PopupWindow() {
return "reportlet";
}
@Override
protected void populateSubHyperlinkBean(ReportletHyperlink link) {
if (itemNameTextField != null) {
this.itemNameTextField.setText(link.getItemName());
}
this.reportPathTextField.setText(link.getReportletPath());
this.showParameterInterface.setSelected(link.isShowParameterInterface());
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0);
}
@Override
protected ReportletHyperlink updateSubHyperlinkBean() {
ReportletHyperlink reportletHyperlink = new ReportletHyperlink();
updateSubHyperlinkBean(reportletHyperlink);
return reportletHyperlink;
}
@Override
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) {
if (itemNameTextField != null) {
reportletHyperlink.setItemName(this.itemNameTextField.getText());
}
reportletHyperlink.setReportletPath(this.reportPathTextField.getText());
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected());
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1 ? true : false);
}
public String getReportletName() {
return StringUtils.isBlank(this.reportPathTextField.getText()) ? StringUtils.EMPTY : this.reportPathTextField.getText().substring(1);
}
/**
* 获取按钮焦点
*/
public void requestButtonFocus() {
this.browserButton.requestFocus();
JPopupMenu popup = new JPopupMenu();
FakeTipAction tip = new FakeTipAction();
tip.setEnabled(false);
popup.add(tip);
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton);
}
private class FakeTipAction extends UpdateAction {
public FakeTipAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Select"));
}
public void actionPerformed(ActionEvent e) {
//do nothing
}
}
@Override
protected JPanel setFootPanel() {
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] columnSize = {p, TableLayout.FILL};
showParameterInterface = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display"));
JPanel showParameterPanel = new JPanel();
showParameterPanel.add(new UILabel());
showParameterPanel.add(showParameterInterface);
postComboBox = new UIComboBox(new String[]{"GET", "POST"});
JPanel postPanel = new JPanel();
postPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type")));
postPanel.add(postComboBox);
Component[][] components = {{postPanel},
{showParameterPanel},
{new UILabel(" ")}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
}

450
designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperNorthPane.java

@ -0,0 +1,450 @@
package com.fr.design.hyperlink;
import com.fr.base.BaseFormula;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.ReportletPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.ReportletHyperlink;
import com.fr.js.ReportletHyperlinkDialogAttr;
import com.fr.stable.CommonUtils;
import com.fr.stable.FormulaProvider;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* 热点链接部分 上方 定义特征 样式 报表 等属性的界面.
*
* @author kunsnat
*/
public class ReportletHyperNorthPane extends AbstractHyperNorthPane<ReportletHyperlink> {
/**
* item name text filed
*/
private UITextField itemNameTextField;
/**
* 是否展示item name
*/
private boolean needRenamePane = false;
/**
* 参数路径输入框
*/
private UITextField reportPathTextField;
/**
* 是否展示参数面板勾选框
*/
private UICheckBox showParameterInterface;
/**
* 选择文件按钮
*/
private UIButton browserButton;
/**
* 参数传递方式下拉选择框
*/
private UIComboBox postComboBox;
/**
* 对话框标题输入框
*/
private TinyFormulaPane titleFiled;
/**
* 对话框居中按钮
*/
private UIRadioButton center;
/**
* 对话框位置自定义按钮
*/
private UIRadioButton custom;
/**
* 距左
*/
private UINumberField leftLocation;
/**
* 距上
*/
private UINumberField topLocation;
public ReportletHyperNorthPane(boolean needRenamePane) {
this.needRenamePane = needRenamePane;
}
public ReportletHyperNorthPane() {
}
/**
* 初始化面板
*/
@Override
protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
final List<Component[]> dialogComponents = new ArrayList<>();
final List<Component[]> othersComponents = new ArrayList<>();
initRenamePanel(dialogComponents, othersComponents);
initHeaderPanel(dialogComponents, othersComponents);
initTargetComboBoxPanel(dialogComponents, othersComponents);
initTitlePanel(dialogComponents);
initDialogSizePanel(dialogComponents);
initDialogLocationPanel(dialogComponents);
initFooterPanel(dialogComponents, othersComponents);
initPlaceHolder(othersComponents);
bindListener(dialogComponents, othersComponents);
// 创建内容面板
JPanel content = TableLayoutHelper.createTableLayoutPane(dialogComponents.toArray(new Component[dialogComponents.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW);
this.add(content, BorderLayout.CENTER);
}
/**
* 生成最上方的配置面板
*
* @return JPanel
*/
@Override
protected JPanel setHeaderPanel() {
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ReportletHyperNorthPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
return reportletNamePane;
}
@Override
protected String title4PopupWindow() {
return "reportlet";
}
@Override
protected void populateSubHyperlinkBean(ReportletHyperlink link) {
if (itemNameTextField != null) {
this.itemNameTextField.setText(link.getItemName());
}
this.reportPathTextField.setText(link.getReportletPath());
this.showParameterInterface.setSelected(link.isShowParameterInterface());
this.postComboBox.setSelectedIndex(link.isByPost() ? 1 : 0);
ReportletHyperlinkDialogAttr attr = link.getAttr();
titleFiled.populateBean(StringUtils.EMPTY);
leftLocation.setText(StringUtils.EMPTY);
topLocation.setText(StringUtils.EMPTY);
center.setSelected(true);
if (attr != null) {
Object title = attr.getTitle();
String titleContent;
if (title instanceof FormulaProvider) {
titleContent = ((FormulaProvider) title).getContent();
} else {
titleContent = title == null ? StringUtils.EMPTY : title.toString();
}
titleFiled.populateBean(titleContent);
boolean isCenter = attr.isCenter();
if (!isCenter) {
int left = attr.getLeft(), top = attr.getTop();
leftLocation.setText(Integer.toString(left));
topLocation.setText(Integer.toString(top));
}
center.setSelected(isCenter);
custom.setSelected(!isCenter);
}
}
@Override
protected ReportletHyperlink updateSubHyperlinkBean() {
ReportletHyperlink reportletHyperlink = new ReportletHyperlink();
updateSubHyperlinkBean(reportletHyperlink);
return reportletHyperlink;
}
@Override
protected void updateSubHyperlinkBean(ReportletHyperlink reportletHyperlink) {
if (itemNameTextField != null) {
reportletHyperlink.setItemName(this.itemNameTextField.getText());
}
reportletHyperlink.setReportletPath(this.reportPathTextField.getText());
reportletHyperlink.setShowParameterInterface(this.showParameterInterface.isSelected());
reportletHyperlink.setByPost(postComboBox.getSelectedIndex() == 1);
ReportletHyperlinkDialogAttr attr = new ReportletHyperlinkDialogAttr();
String title = titleFiled.updateBean();
if (CommonUtils.maybeFormula(title)) {
attr.setTitle(BaseFormula.createFormulaBuilder().build(titleFiled.updateBean()));
} else {
attr.setTitle(title);
}
attr.setCenter(center.isSelected());
if (!attr.isCenter()) {
attr.setLeft((int) leftLocation.getValue());
attr.setTop((int) topLocation.getValue());
}
reportletHyperlink.setAttr(attr);
}
public String getReportletName() {
String text = this.reportPathTextField.getText();
return StringUtils.isBlank(text) ? StringUtils.EMPTY : text.substring(1);
}
/**
* 获取按钮焦点
*/
public void requestButtonFocus() {
this.browserButton.requestFocus();
JPopupMenu popup = new JPopupMenu();
FakeTipAction tip = new FakeTipAction();
tip.setEnabled(false);
popup.add(tip);
GUICoreUtils.showPopupCloseMenu(popup, this.browserButton);
}
private class FakeTipAction extends UpdateAction {
public FakeTipAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Select"));
}
@Override
public void actionPerformed(ActionEvent e) {
// do nothing
}
}
/**
* 底部面板参数传递方式
*
* @return JPanel
*/
@Override
protected JPanel setFootPanel() {
JPanel content = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
// 参数传递方式下拉框
postComboBox = new UIComboBox(new String[]{"GET", "POST"});
postComboBox.setPreferredSize(new Dimension(60, 20));
postComboBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
content.add(postComboBox);
showParameterInterface = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Parameter_UI_Display"));
showParameterInterface.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
content.add(showParameterInterface);
return content;
}
private void bindListener(final List<Component[]> dialogComponents, final List<Component[]> othersComponents) {
final UIComboBox targetFrameComboBox = this.getTargetFrameComboBox();
targetFrameComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean show = DIALOG == targetFrameComboBox.getSelectedIndex();
JPanel content;
List<Component[]> cs = show ? dialogComponents : othersComponents;
ReportletHyperNorthPane.this.removeAll();
content = TableLayoutHelper.createTableLayoutPane(cs.toArray(new Component[cs.size()][]), TableLayoutHelper.FILL_LASTCOL_AND_ROW);
ReportletHyperNorthPane.this.add(content, BorderLayout.CENTER);
ReportletHyperNorthPane.this.revalidate();
ReportletHyperNorthPane.this.repaint();
}
});
}
private void initPlaceHolder(List<Component[]> othersComponents) {
JPanel empty1 = new JPanel();
empty1.setPreferredSize(new Dimension(20, 20));
JPanel empty2 = new JPanel();
empty2.setPreferredSize(new Dimension(20, 20));
JPanel empty3 = new JPanel();
empty3.setPreferredSize(new Dimension(20, 23));
othersComponents.add(new Component[]{empty1, new JPanel()});
othersComponents.add(new Component[]{empty2, new JPanel()});
othersComponents.add(new Component[]{empty3, new JPanel()});
}
private void initRenamePanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) {
// 是否有重命名属性
if (this.needRenamePane) {
itemNameTextField = new UITextField();
Component[] renameComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), itemNameTextField};
dialogComponents.add(renameComponents);
othersComponents.add(renameComponents);
}
}
private void initHeaderPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) {
//最上方位置的面板
JPanel headerPane = this.setHeaderPanel();
Component[] headerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet") + ":"), headerPane};
dialogComponents.add(headerComponents);
othersComponents.add(headerComponents);
}
private void initTargetComboBoxPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) {
// 链接打开于
UIComboBox targetFrameComboBox = new UIComboBox(getTargetFrames());
this.setTargetFrameComboBox(targetFrameComboBox);
targetFrameComboBox.setEditable(true);
targetFrameComboBox.setPreferredSize(new Dimension(100, 20));
JPanel targetFramePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
targetFramePanel.add(targetFrameComboBox);
Component[] targetComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Link_Opened_In") + ":"), targetFramePanel};
dialogComponents.add(targetComponents);
othersComponents.add(targetComponents);
}
private void initTitlePanel(List<Component[]> dialogComponents) {
// 对话框标题
titleFiled = new TinyFormulaPane();
titleFiled.getUITextField().setColumns(15);
final JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
titlePanel.add(titleFiled);
Component[] titleComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Title") + ":"), titlePanel};
dialogComponents.add(titleComponents);
}
private void initDialogSizePanel(List<Component[]> dialogComponents) {// 对话框大小
final JPanel sizeJPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
UILabel heightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Height") + ":");
heightLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
sizeJPanel.add(heightLabel);
UINumberField heightTextFiled = new UINumberField();
heightTextFiled.setMinValue(0);
heightTextFiled.setText(String.valueOf(DEFAULT_H_VALUE));
heightTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(heightTextFiled);
this.setHeightTextFiled(heightTextFiled);
UILabel widthLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Designer_Width") + ":");
widthLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
sizeJPanel.add(widthLabel);
UINumberField widthTextFiled = new UINumberField();
widthTextFiled.setMinValue(0);
widthTextFiled.setText(String.valueOf(DEFAULT_V_VALUE));
widthTextFiled.setPreferredSize(new Dimension(40, 20));
sizeJPanel.add(widthTextFiled);
this.setWidthTextFiled(widthTextFiled);
sizeJPanel.setVisible(true);
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Size") + ":"), sizeJPanel});
}
private void initDialogLocationPanel(List<Component[]> dialogComponents) {
// 显示位置
final JPanel locationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
// 居中
center = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Center"));
// 自定义
custom = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Custom"));
custom.setBorder(BorderFactory.createEmptyBorder(4, 20, 4, 5));
ButtonGroup group = new ButtonGroup();
group.setSelected(center.getModel(), true);
group.add(center);
group.add(custom);
locationPanel.add(center);
locationPanel.add(custom);
// 位置 距左
final UILabel leftLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Left"));
leftLabel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 10));
leftLocation = new UINumberField();
leftLocation.setMinValue(0);
leftLocation.setPreferredSize(new Dimension(40, 20));
// 位置 距上
final UILabel topLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Position_Top"));
topLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10));
topLocation = new UINumberField();
topLocation.setMinValue(0);
topLocation.setPreferredSize(new Dimension(40, 20));
locationPanel.add(leftLabel);
locationPanel.add(leftLocation);
locationPanel.add(topLabel);
locationPanel.add(topLocation);
leftLabel.setVisible(false);
leftLocation.setVisible(false);
topLabel.setVisible(false);
topLocation.setVisible(false);
ChangeListener actionListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
boolean visible = custom.isSelected();
leftLabel.setVisible(visible);
leftLocation.setVisible(visible);
topLabel.setVisible(visible);
topLocation.setVisible(visible);
}
};
// 默认居中
center.setSelected(true);
center.addChangeListener(actionListener);
custom.addChangeListener(actionListener);
dialogComponents.add(new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Dialog_Show_Position") + ":"), locationPanel});
}
private void initFooterPanel(List<Component[]> dialogComponents, List<Component[]> othersComponents) {
// 最下方的配置面板
// 参数传递方式
Component[] footerComponents = new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Reportlet_Parameter_Type") + ":"), this.setFootPanel()};
dialogComponents.add(footerComponents);
othersComponents.add(footerComponents);
}
}

47
designer-base/src/main/java/com/fr/design/hyperlink/ReportletHyperlinkPane.java

@ -6,23 +6,30 @@ import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.design.parameter.ParameterReader; import com.fr.design.parameter.ParameterReader;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.ReportletHyperlink; import com.fr.js.ReportletHyperlink;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.JOptionPane;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyperlink> { public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyperlink> {
private ReporletHyperNorthPane northPane; /**
* 超链配置面板
*/
private ReportletHyperNorthPane northPane;
/**
* 是否继承参数勾选框
*/
private UICheckBox extendParametersCheckBox; private UICheckBox extendParametersCheckBox;
public ReportletHyperlinkPane(HashMap hyperLinkEditorMap, boolean needRenamePane) { public ReportletHyperlinkPane(HashMap hyperLinkEditorMap, boolean needRenamePane) {
@ -38,22 +45,29 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyper
protected void initComponents() { protected void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
northPane = new ReporletHyperNorthPane(needRenamePane()); northPane = new ReportletHyperNorthPane(needRenamePane());
this.add(northPane, BorderLayout.NORTH); this.add(northPane, BorderLayout.NORTH);
parameterViewPane = new ReportletParameterViewPane(new UITableEditAction[]{new HyperlinkParametersAction()}, getChartParaType(), getValueEditorPane(), getValueEditorPane()); parameterViewPane = new ReportletParameterViewPane(
new UITableEditAction[]{
new HyperlinkParametersAction()
},
getChartParaType(),
getValueEditorPane(),
getValueEditorPane()
);
this.add(parameterViewPane, BorderLayout.CENTER); this.add(parameterViewPane, BorderLayout.CENTER);
parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter"), null)); parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Parameter"), null));
extendParametersCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters")); extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
this.add(GUICoreUtils.createFlowPane(extendParametersCheckBox, FlowLayout.LEFT), BorderLayout.SOUTH); this.add(GUICoreUtils.createFlowPane(extendParametersCheckBox, FlowLayout.LEFT), BorderLayout.SOUTH);
} }
@Override @Override
public String title4PopupWindow() { public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet"); return Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Reportlet");
} }
@Override @Override
@ -77,6 +91,7 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyper
return reportletHyperlink; return reportletHyperlink;
} }
@Override
public void updateBean(ReportletHyperlink reportletHyperlink) { public void updateBean(ReportletHyperlink reportletHyperlink) {
northPane.updateBean(reportletHyperlink); northPane.updateBean(reportletHyperlink);
// Parameter. // Parameter.
@ -94,16 +109,20 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyper
} }
/**
* 自动添加模板参数的按钮操作
*/
protected class HyperlinkParametersAction extends UITableEditAction { protected class HyperlinkParametersAction extends UITableEditAction {
public HyperlinkParametersAction() { public HyperlinkParametersAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); this.setName(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String tpl = northPane.getReportletName(); String tpl = northPane.getReportletName();
if (StringUtils.isBlank(tpl)) { if (StringUtils.isBlank(tpl)) {
JOptionPane.showMessageDialog(ReportletHyperlinkPane.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Please_Select_Reportlet") + ".", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(ReportletHyperlinkPane.this, Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Please_Select_Reportlet") + ".", Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE);
northPane.requestButtonFocus(); northPane.requestButtonFocus();
return; return;
} }
@ -129,20 +148,22 @@ public class ReportletHyperlinkPane extends AbstractHyperLinkPane<ReportletHyper
} }
public static class ChartNoRename extends ReportletHyperlinkPane { public static class ChartNoRename extends ReportletHyperlinkPane {
@Override
protected int getChartParaType() { protected int getChartParaType() {
return ParameterTableModel.CHART_NORMAL_USE; return ParameterTableModel.CHART_NORMAL_USE;
} }
@Override
protected boolean needRenamePane() { protected boolean needRenamePane() {
return false; return false;
} }
} }
public ReporletHyperNorthPane getNorthPane() { public ReportletHyperNorthPane getNorthPane() {
return northPane; return northPane;
} }
public void setNorthPane(ReporletHyperNorthPane northPane) { public void setNorthPane(ReportletHyperNorthPane northPane) {
this.northPane = northPane; this.northPane = northPane;
} }

4
designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java

@ -7,9 +7,9 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.fun.JavaScriptActionProvider;
import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.form.ui.WebContentUtils; import com.fr.form.ui.WebContentUtils;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -46,7 +46,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG); Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) { if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) { for (JavaScriptActionProvider jsp : javaScriptActionProviders) {
if(jsp.isSupportType()){ if(jsp.accept(DesignerContext.getDesignerFrame().getSelectedJTemplate())){
paneList.add(jsp.getJavaScriptActionPane(this)); paneList.add(jsp.getJavaScriptActionPane(this));
} }
} }

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

@ -1,16 +1,16 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import javax.swing.JComponent;
import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseContainerProvider;
import javax.swing.JComponent;
/** /**
* Author : Shockway * Author : Shockway
* Date: 13-7-15 * Date: 13-7-15
* Time: 上午10:28 * Time: 上午10:28
*/ */
public interface BaseJForm extends JTemplateProvider { public interface BaseJForm<T> extends JTemplateProvider<T> {
String XML_TAG = "JForm"; String XML_TAG = "JForm";
int FORM_TAB = 0; int FORM_TAB = 0;
@ -32,11 +32,6 @@ public interface BaseJForm extends JTemplateProvider {
*/ */
void refreshSelectedWidget(); void refreshSelectedWidget();
/**
* 获取当前的Target
*/
Object getTarget();
/** /**
* 执行撤销 * 执行撤销
* *

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

@ -10,6 +10,7 @@ import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
@ -17,6 +18,7 @@ import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.DesignerOpenedListener;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.NewTemplatePane; import com.fr.design.file.NewTemplatePane;
@ -29,6 +31,7 @@ import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iprogressbar.ProgressDialog;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.loghandler.LogMessageBar;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
@ -37,6 +40,7 @@ import com.fr.design.menu.MenuManager;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEFactory; import com.fr.file.FILEFactory;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
@ -65,6 +69,7 @@ import javax.swing.JLayeredPane;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.border.MatteBorder; import javax.swing.border.MatteBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -74,7 +79,6 @@ import java.awt.Graphics;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
@ -158,9 +162,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
//用于判断设计器是否打开了 //用于判断设计器是否打开了
private boolean designerOpened = false; private boolean designerOpened = false;
private int contentWidth = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()); private int contentWidth = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getWidth());
private int contentHeight = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()); private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight());
private WindowAdapter windowAdapter = new WindowAdapter() { private WindowAdapter windowAdapter = new WindowAdapter() {
@ -222,16 +226,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
DesignerMode.setMode(DesignerMode.NORMARL); closeAuthorityEditing();
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
} }
} }
@ -330,6 +326,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.progressDialog = new ProgressDialog(this); this.progressDialog = new ProgressDialog(this);
} }
public void closeAuthorityEditing(){
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane(
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()));
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane();
DesignerContext.getDesignerFrame().resetToolkitByPlus(
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getToolBarMenuDockPlus());
needToAddAuhtorityPaint();
refreshDottedLine();
fireAuthorityStateToNomal();
}
/** /**
* 注册app. * 注册app.
* *
@ -847,18 +855,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
editingTemplate.stopEditing(); editingTemplate.stopEditing();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE()
+ "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION, + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} else { } else {
if (editingTemplate.saveTemplate()) { if (editingTemplate.saveTemplate()) {
editingTemplate.saveTemplate(); editingTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved",
editingTemplate.getEditingFILE().getName())); editingTemplate.getEditingFILE().getName()));
} }
} }
@ -955,14 +963,29 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
// p:判断一下,如何文件为空或者文件不存在,直接返回. // p:判断一下,如何文件为空或者文件不存在,直接返回.
if (tplFile == null || !tplFile.exists()) { if (tplFile == null || !tplFile.exists()) {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), JOptionPane.showMessageDialog(
ProductConstants.PRODUCT_NAME, JOptionPane.INFORMATION_MESSAGE); this,
Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"),
ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE
);
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
return; return;
} }
try { try {
openFile(tplFile); openFile(tplFile);
} catch (DecryptTemplateException e) {
JOptionPane.showMessageDialog(
this,
Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
if (this.getSelectedJTemplate() == null) {
addAndActivateJTemplate();
}
} catch (Throwable t) { } catch (Throwable t) {
FineLoggerFactory.getLogger().error(t.getMessage(), t); FineLoggerFactory.getLogger().error(t.getMessage(), t);
addAndActivateJTemplate(); addAndActivateJTemplate();
@ -1014,7 +1037,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} else { } else {
activeTemplate(tplFile, jt); activeTemplate(jt);
} }
opened = true; opened = true;
break; break;
@ -1029,13 +1052,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 激活指定的模板 * 激活指定的模板
* *
* @param tplFile 模板文件 * @param jt 当前报表
* @param jt 当前报表
* @date 2014-10-14-下午6:31:23 * @date 2014-10-14-下午6:31:23
*/ */
private void activeTemplate(FILE tplFile, JTemplate jt) { private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(tplFile.getPath()); int index = HistoryTemplateListPane.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);

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

@ -3,12 +3,14 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.*; import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.base.mode.DesignerMode;
import com.fr.design.dialog.BasicPane;
import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener; import com.fr.design.event.TargetModifiedListener;
import com.fr.design.dialog.BasicPane;
import java.awt.BorderLayout;
/** /**
@ -17,16 +19,22 @@ import com.fr.design.dialog.BasicPane;
*/ */
public class DesktopCardPane extends BasicPane implements TargetModifiedListener { public class DesktopCardPane extends BasicPane implements TargetModifiedListener {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JTemplate<?, ?> component; private JTemplate<?, ?> component;
protected DesktopCardPane() { protected DesktopCardPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
} }
protected void showJTemplate(final JTemplate<?, ?> jt) { protected void showJTemplate(final JTemplate<?, ?> jt) {
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); // 判断是否切换设计器状态到禁止拷贝剪切
if(component != null) { if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT);
} else {
DesignModeContext.switchTo(DesignerMode.NORMAL);
}
DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt);
if (component != null) {
remove(component); remove(component);
} }
add(component = jt, BorderLayout.CENTER); add(component = jt, BorderLayout.CENTER);
@ -34,18 +42,18 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
repaint(); repaint();
revalidate(); revalidate();
component.requestGridFocus(); component.requestGridFocus();
} }
protected JTemplate<?, ?> getSelectedJTemplate() { protected JTemplate<?, ?> getSelectedJTemplate() {
return component; return component;
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Desktop"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Desktop");
} }
@Override @Override
public void targetModified(TargetModifiedEvent e) { public void targetModified(TargetModifiedEvent e) {
} }
} }

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

@ -412,6 +412,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
if (propertyItem.isVisible() && propertyItem.isEnabled() && !propertyItem.isPoppedOut()) { if (propertyItem.isVisible() && propertyItem.isEnabled() && !propertyItem.isPoppedOut()) {
propertyCard.show(rightPane, tabName); propertyCard.show(rightPane, tabName);
propertyItem.setTabButtonSelected(); propertyItem.setTabButtonSelected();
//从单元格菜单过来也要关闭弹出窗
hideCurrentPopupPane();
} }
} }

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

@ -5,6 +5,7 @@ import com.fr.base.FRContext;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
@ -17,6 +18,8 @@ import com.fr.design.actions.edit.UndoAction;
import com.fr.design.actions.file.SaveAsTemplateAction; import com.fr.design.actions.file.SaveAsTemplateAction;
import com.fr.design.actions.file.SaveTemplateAction; import com.fr.design.actions.file.SaveTemplateAction;
import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.DesignerProxy;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.InformationWarnPane; import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
@ -29,6 +32,7 @@ import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.templateinfo.TemplateInfoCollector; import com.fr.design.mainframe.templateinfo.TemplateInfoCollector;
import com.fr.design.mainframe.templateinfo.TemplateProcessInfo; import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
@ -53,6 +57,8 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID; import com.fr.stable.core.UUID;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon; import javax.swing.Icon;
@ -69,7 +75,7 @@ import java.util.regex.Pattern;
/** /**
* 报表设计和表单设计的编辑区域(设计器编辑的IO文件) * 报表设计和表单设计的编辑区域(设计器编辑的IO文件)
*/ */
public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, JTemplateProvider { public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>> extends TargetComponent<T> implements ToolBarMenuDockPlus, DesignerProxy {
// TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null
private static final int PREFIX_NUM = 3000; private static final int PREFIX_NUM = 3000;
private FILE editingFILE = null; private FILE editingFILE = null;
@ -104,6 +110,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public JTemplate(T t, FILE file, boolean isNewFile) { public JTemplate(T t, FILE file, boolean isNewFile) {
super(t); super(t);
// 判断是否切换设计器状态到禁止拷贝剪切
if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT);
} else {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
}
this.template = t; this.template = t;
this.previewType = parserPreviewProvider(t.getPreviewType()); this.previewType = parserPreviewProvider(t.getPreviewType());
this.editingFILE = file; this.editingFILE = file;
@ -117,6 +129,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
openTime = System.currentTimeMillis(); openTime = System.currentTimeMillis();
process.append(tic.loadProcess(t)); process.append(tic.loadProcess(t));
} }
} }
// 刷新右侧属性面板 // 刷新右侧属性面板
@ -409,7 +422,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
fireSuperTargetModified(); fireSuperTargetModified();
} }
protected boolean accept(Object o) { public boolean accept(Object o) {
return true; return true;
} }
@ -577,6 +590,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
if (isCancelOperation(chooseResult)) { if (isCancelOperation(chooseResult)) {
return false; return false;
} }
// 源文件
FILE sourceFile = editingFILE;
if (isOkOperation(chooseResult)) { if (isOkOperation(chooseResult)) {
boolean access = false; boolean access = false;
@ -586,13 +601,33 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (!access) { if (!access) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied") + "!",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false; return false;
} }
// 目标文件
editingFILE = fileChooser.getSelectedFILE(); editingFILE = fileChooser.getSelectedFILE();
} }
return saveNewFile(editingFILE, oldName); boolean lockedTarget = WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath());
if (lockedTarget) {
boolean saved = saveNewFile(editingFILE, oldName);
// 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉
if (saved && !ComparatorUtils.equals(editingFILE.getPath(), sourceFile.getPath())) {
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(sourceFile.getPath());
}
return saved;
} else {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Status_Locked"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"),
JOptionPane.WARNING_MESSAGE);
return false;
}
} }
protected boolean saveNewFile(FILE editingFILE, String oldName) { protected boolean saveNewFile(FILE editingFILE, String oldName) {

6
designer-base/src/main/java/com/fr/design/mainframe/JTemplateProvider.java

@ -1,6 +1,8 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
public interface JTemplateProvider { public interface JTemplateProvider<T> {
public void fireTargetModified(); void fireTargetModified();
T getTarget();
} }

9
designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/PatternBackgroundQuickPane.java

@ -30,6 +30,8 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
private int patternIndex = 0; // pattern setIndex. private int patternIndex = 0; // pattern setIndex.
private final static int DEFAULT_DIM_HEIGHT = 210; private final static int DEFAULT_DIM_HEIGHT = 210;
private final static Color DEFAULT_FOREGROUND = Color.lightGray;
private final static Color DEFAULT_BACKGROUND = Color.black;
private ColorSelectBox foregroundColorPane; private ColorSelectBox foregroundColorPane;
private ColorSelectBox backgroundColorPane; private ColorSelectBox backgroundColorPane;
private PatternButton[] patternButtonArray; private PatternButton[] patternButtonArray;
@ -52,7 +54,8 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
} }
foregroundColorPane = new ColorSelectBox(60); foregroundColorPane = new ColorSelectBox(60);
backgroundColorPane = new ColorSelectBox(60); backgroundColorPane = new ColorSelectBox(60);
foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
foregroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
@ -219,7 +222,7 @@ public class PatternBackgroundQuickPane extends BackgroundQuickPane {
@Override @Override
public void reset() { public void reset() {
patternButtonArray[0].setSelected(true); patternButtonArray[0].setSelected(true);
foregroundColorPane.setSelectObject(null); foregroundColorPane.setSelectObject(DEFAULT_FOREGROUND);
backgroundColorPane.setSelectObject(null); backgroundColorPane.setSelectObject(DEFAULT_BACKGROUND);
} }
} }

7
designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java

@ -68,4 +68,11 @@ public class LogMessageBar extends JPanel {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(width, 24); return new Dimension(width, 24);
} }
public void disposeLogDialog() {
if (dlg != null) {
dlg.dispose();
}
THIS = null;
}
} }

119
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleDefinePane.java

@ -0,0 +1,119 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.GraphHelper;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class DefaultMobileStyleDefinePane extends MobileTemplateStyleDefinePane {
public DefaultMobileStyleDefinePane(WCardTagLayout tagLayout) {
super(tagLayout);
}
@Override
public void populateBean(MobileTemplateStyle ob) {
updatePreviewPane();
}
protected void createConfigPane() {
}
@Override
protected void initDefaultConfig() {
}
@Override
public MobileTemplateStyle updateSubStyle() {
return null;
}
@Override
public MobileTemplateStyle updateBean() {
return getDefaultTemplateStyle();
}
public MobileTemplateStyle updateConfig(){
return getDefaultTemplateStyle();
}
@Override
protected MobileTemplateStyle getDefaultTemplateStyle() {
return new DefaultMobileTemplateStyle(new TabFontConfig(getTagLayout().getTitleFont()));
}
@Override
public void populateSubStyle(MobileTemplateStyle ob) {
}
@Override
protected String title4PopupWindow() {
return null;
}
protected MobileTemplatePreviewPane createPreviewPane() {
return new DefaultStylePreviewPane();
}
public class DefaultStylePreviewPane extends MobileTemplatePreviewPane {
public DefaultStylePreviewPane() {
this.setBackground(DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR);
}
public Color getInitialColor() {
return DefaultMobileTemplateStyle.DEFAULT_INITIAL_COLOR;
}
public void repaint() {
super.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
Dimension dimension = this.getSize();
int panelWidth = dimension.width;
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = DefaultMobileStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
g2d.setFont(frFont);
int fontHeight = fm.getHeight();
int ascentHeight = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
if (i == 0) {
g2d.setColor(Color.BLACK);
g2d.setStroke(new BasicStroke(2.0f));
g2d.drawLine(0, panelHeight - 1, eachWidth, panelHeight - 1);
}
g2d.translate(eachWidth, 0);
}
}
}
}

195
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java

@ -0,0 +1,195 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.GraphHelper;
import com.fr.base.Icon;
import com.fr.base.IconManager;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.DownMenuStyle;
import com.fr.general.cardtag.mobile.LineDescription;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
import java.util.ArrayList;
public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
private LinePane splitLinePane;
private TabIconConfigPane initIconConfigPane;
private TabIconConfigPane selectIconConfigPane;
public DownMenuStyleDefinePane(WCardTagLayout tagLayout) {
super(tagLayout);
}
protected void createExtraConfPane(JPanel centerPane) {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0);
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
UITitleSplitLine iconSplitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon"), 520);
iconSplitLine.setPreferredSize(new Dimension(520, 20));
centerPane.add(iconSplitLine);
initIconConfigPane = new TabIconConfigPane(getTagLayout().getWidgetCount());
selectIconConfigPane = new TabIconConfigPane(getTagLayout().getWidgetCount());
UILabel initIconLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Initial_Icon"));
UILabel selectIconLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Icon"));
initIconLabel.setPreferredSize(new Dimension(55, 20));
selectIconLabel.setPreferredSize(new Dimension(55, 20));
JPanel initIconContainPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initIconLabel, initIconConfigPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
JPanel selectIconContainePane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectIconLabel, selectIconConfigPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
initIconContainPane.setPreferredSize(new Dimension(240, 50));
selectIconContainePane.setPreferredSize(new Dimension(240, 50));
panel.add(initIconContainPane);
panel.add(selectIconContainePane);
UITitleSplitLine splitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Spit_Line"), 520);
splitLine.setPreferredSize(new Dimension(520, 20));
splitLinePane = new LinePane();
splitLinePane.addLineChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
centerPane.add(panel);
centerPane.add(splitLine);
centerPane.add(splitLinePane);
}
@Override
protected void initDefaultConfig() {
this.initialColorBox.setSelectObject(DownMenuStyle.DEFAULT_INITIAL_COLOR);
this.fontConfPane.populate(DownMenuStyle.DEFAULT_TAB_FONT.getFont());
this.selectColorBox.setSelectObject(DownMenuStyle.DEFAULT_SELECT_COLOR);
this.selectFontColor.setColor(DownMenuStyle.DEFAULT_SELECT_FONT_COLOR);
this.splitLinePane.populate(DownMenuStyle.DEFAULT_SPLIT_LINE);
}
@Override
protected MobileTemplatePreviewPane createPreviewPane() {
return new DownMenuStylePreviewPane();
}
@Override
public void populateSubStyle(MobileTemplateStyle ob) {
super.populateSubStyle(ob);
DownMenuStyle downMenuStyle = (DownMenuStyle) ob;
splitLinePane.populate(downMenuStyle.getSplitLine());
ArrayList<String> initialIconNames = new ArrayList<String>();
ArrayList<String> selectIconNames = new ArrayList<String>();
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) {
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i);
initialIconNames.add(cardSwitchButton.getInitIconName());
selectIconNames.add(cardSwitchButton.getSelectIconName());
}
initIconConfigPane.populate(initialIconNames);
selectIconConfigPane.populate(selectIconNames);
}
@Override
protected MobileTemplateStyle getDefaultTemplateStyle() {
return new DownMenuStyle();
}
@Override
public MobileTemplateStyle updateStyleWithSelectConf() {
DownMenuStyle downMenuStyle = new DownMenuStyle();
downMenuStyle.setSplitLine(splitLinePane.update());
ArrayList<String> initialIconNames = initIconConfigPane.update();
ArrayList<String> selectIconNames = selectIconConfigPane.update();
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) {
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i);
cardSwitchButton.setInitIconName(initialIconNames.get(i));
cardSwitchButton.setSelectIconName(selectIconNames.get(i));
}
return downMenuStyle;
}
@Override
protected String title4PopupWindow() {
return null;
}
public class DownMenuStylePreviewPane extends MobileTemplatePreviewPane {
private static final int ICON_OFFSET = 16;
private static final int GAP = 6;
private static final String PAINT_ICON = "fund_white";
private static final String ICON_PATH = "/com/fr/web/images/fund_white.png";
private LineDescription splitLine;
public DownMenuStylePreviewPane() {
this.setBackground(Color.decode("#3888EE"));
}
public void repaint() {
super.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
Color selectFontColor = this.getTabFontConfig().getSelectColor();
Dimension dimension = this.getSize();
int panelWidth = dimension.width;
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = DownMenuStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
g2d.setFont(frFont);
int fontHeight = fm.getHeight();
int ascent = fm.getAscent();
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
if(i == 0){
Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight);
g2d.setColor(oldColor);
}
Icon icon = new Icon(PAINT_ICON, ICON_PATH);
g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null);
g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent);
Stroke oldStroke = g2d.getStroke();
if (splitLine.getLineStyle() != 0) {
g2d.setColor(splitLine.getColor());
g2d.setStroke(GraphHelper.getStroke(splitLine.getLineStyle()));
g2d.drawLine(eachWidth, 0, eachWidth, panelHeight);
}
g2d.setStroke(oldStroke);
g2d.translate(eachWidth, 0);
}
}
public void populateConfig(MobileTemplateStyle templateStyle) {
super.populateConfig(templateStyle);
this.splitLine = ((DownMenuStyle) templateStyle).getSplitLine();
}
}
}

107
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/LinePane.java

@ -0,0 +1,107 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.icombobox.LineComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.general.cardtag.mobile.LineDescription;
import com.fr.stable.CoreConstants;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public class LinePane extends JPanel {
private LineComboBox lineStyle;
private NewColorSelectBox lineColor;
private EventListenerList lineChangeListener = new EventListenerList();
public LinePane() {
init();
}
private void init() {
this.setLayout(new VerticalFlowLayout(FlowLayout.CENTER, 0, 10));
this.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
UILabel lineLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style"));
UILabel colorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Colors"));
lineLabel.setPreferredSize(new Dimension(55, 20));
colorLabel.setPreferredSize(new Dimension(55, 20));
lineStyle = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY);
lineStyle.setPreferredSize(new Dimension(152, 20));
lineColor = new NewColorSelectBox(137);
lineStyle.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireLineStateChanged();
}
});
lineColor.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireLineStateChanged();
}
});
this.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{lineLabel, lineStyle}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM));
this.add(TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{colorLabel, lineColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM));
}
public LineDescription update() {
LineDescription lineDescription = new LineDescription();
lineDescription.setColor(lineColor.getSelectObject());
lineDescription.setLineStyle(lineStyle.getSelectedLineStyle());
return lineDescription;
}
public void populate(LineDescription lineDescription) {
lineStyle.setSelectedLineStyle(lineDescription.getLineStyle());
lineColor.setSelectObject(lineDescription.getColor());
}
/**
* 添加监听
*
* @param changeListener 监听列表
*/
public void addLineChangeListener(ChangeListener changeListener) {
lineChangeListener.add(ChangeListener.class, changeListener);
}
/**
* 移除监听
* Removes an old ColorChangeListener.
*
* @param changeListener 监听列表
*/
public void removeLineChangeListener(ChangeListener changeListener) {
lineChangeListener.remove(ChangeListener.class, changeListener);
}
/**
* 颜色状态改变
*/
public void fireLineStateChanged() {
Object[] listeners = lineChangeListener.getListenerList();
ChangeEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
if (e == null) {
e = new ChangeEvent(this);
}
((ChangeListener) listeners[i + 1]).stateChanged(e);
}
}
}
}

235
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java

@ -0,0 +1,235 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.dialog.AttrScrollPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.MobileTabFontConfPane;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane<MobileTemplateStyle> {
private static final String[] TAB_STYLES = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom")};
private UIComboBox custom;
protected NewColorSelectBox initialColorBox;
protected MobileTabFontConfPane fontConfPane;
private JPanel centerPane;
protected MobileTemplatePreviewPane previewPane;
private WCardTagLayout tagLayout;
public MobileTemplatePreviewPane getPreviewPane() {
return previewPane;
}
public MobileTemplateStyleDefinePane(WCardTagLayout tagLayout) {
this.tagLayout = tagLayout;
init();
}
public WCardTagLayout getTagLayout() {
return tagLayout;
}
protected void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
previewPane = createPreviewPane();
previewPane.setPreferredSize(new Dimension(500, 60));
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 9, Color.BLUE));
northPane.setBorder(titledBorder);
northPane.setPreferredSize(new Dimension(500, 83));
northPane.add(previewPane, BorderLayout.CENTER);
this.add(northPane, BorderLayout.NORTH);
createConfigPane();
}
protected void createConfigPane() {
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, 9, Color.BLUE));
configPane.setBorder(titledBorder);
centerPane = createCenterPane();
custom = new UIComboBox(TAB_STYLES);
custom.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean isCustom = custom.getSelectedIndex() == 1;
centerPane.setVisible(isCustom);
updatePreviewPane();
}
});
centerPane.setVisible(false);
custom.setPreferredSize(new Dimension(157, 20));
final JPanel scrollPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
BasicScrollPane basicScrollPane = new AttrScrollPane() {
@Override
protected JPanel createContentPane() {
return scrollPanel;
}
};
configPane.add(basicScrollPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER);
JPanel outPanel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane();
outPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
UILabel tabStyleLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Style"));
tabStyleLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tabStyleLabel, custom}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
jPanel.setPreferredSize(new Dimension(200, 20));
outPanel.add(jPanel);
scrollPanel.add(outPanel, BorderLayout.NORTH);
UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), 520);
backgroundSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(backgroundSplit);
centerPane.add(createBackgroundConfPane());
UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), 520);
fontSplit.setPreferredSize(new Dimension(520, 20));
centerPane.add(fontSplit);
centerPane.add(createFontConfPane());
createExtraConfPane(centerPane);
scrollPanel.add(centerPane, BorderLayout.CENTER);
initDefaultConfig();
}
protected JPanel createCenterPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
return panel;
}
protected JPanel createBackgroundConfPane() {
initialColorBox = new NewColorSelectBox(137);
initialColorBox.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UILabel fillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fill"));
fillLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{fillLabel, initialColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
jPanel.setPreferredSize(new Dimension(240, 20));
initialColorBox.setPreferredSize(new Dimension(157, 20));
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
return jPanel;
}
protected JPanel createFontConfPane() {
fontConfPane = new MobileTabFontConfPane();
fontConfPane.addFontChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UILabel initCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char"));
initCharLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel3 = GUICoreUtils.createBoxFlowInnerContainerPane(5, 0);
jPanel3.add(initCharLabel);
jPanel3.add(fontConfPane);
jPanel3.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
return jPanel3;
}
protected void createExtraConfPane(JPanel centerPane) {
}
protected abstract void initDefaultConfig();
protected abstract MobileTemplatePreviewPane createPreviewPane();
@Override
public void populateBean(MobileTemplateStyle ob) {
centerPane.setVisible(ob.isCustom());
populateSubStyle(ob);
custom.setSelectedItem(!ob.isCustom() ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default") :
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Custom"));
initialColorBox.setSelectObject(ob.getInitialColor());
fontConfPane.populate(ob.getTabFontConfig().getFont());
updatePreviewPane();
}
@Override
public MobileTemplateStyle updateBean() {
//保存之前需要先将cardSwitchBtn的icon设置清空
for (int i = 0; i < getTagLayout().getWidgetCount(); i++) {
CardSwitchButton cardSwitchButton = (CardSwitchButton) getTagLayout().getWidget(i);
cardSwitchButton.setInitIconName(StringUtils.EMPTY);
cardSwitchButton.setSelectIconName(StringUtils.EMPTY);
}
return updateConfig();
}
public MobileTemplateStyle updateConfig(){
if (custom.getSelectedIndex() == 0) {
return getDefaultTemplateStyle();
}
MobileTemplateStyle ob = updateSubStyle();
ob.setCustom(custom.getSelectedIndex() == 1);
ob.setInitialColor(initialColorBox.getSelectObject());
TabFontConfig config = new TabFontConfig();
config.setSelectColor(ob.getTabFontConfig().getSelectColor());
config.setFont(fontConfPane.update());
ob.setTabFontConfig(config);
return ob;
}
protected abstract MobileTemplateStyle getDefaultTemplateStyle();
public void updatePreviewPane() {
previewPane.populateConfig(updateConfig());
previewPane.setBackground(previewPane.getInitialColor());
previewPane.repaint();
}
public abstract void populateSubStyle(MobileTemplateStyle ob);
public abstract MobileTemplateStyle updateSubStyle();
@Override
protected String title4PopupWindow() {
return null;
}
}

166
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SliderStyleDefinePane.java

@ -0,0 +1,166 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.GraphHelper;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.SliderStyle;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
public class SliderStyleDefinePane extends MobileTemplateStyleDefinePane {
private NewColorSelectBox initDotColor;
private NewColorSelectBox selectDotColor;
public SliderStyleDefinePane(WCardTagLayout tagLayout) {
super(tagLayout);
}
@Override
public void populateSubStyle(MobileTemplateStyle ob) {
SliderStyle sliderStyle = (SliderStyle) ob;
initDotColor.setSelectObject(sliderStyle.getInitDotColor());
selectDotColor.setSelectObject(sliderStyle.getSelectDotColor());
}
@Override
protected MobileTemplateStyle getDefaultTemplateStyle() {
return new SliderStyle();
}
@Override
public MobileTemplateStyle updateSubStyle() {
SliderStyle sliderStyle = new SliderStyle();
sliderStyle.setInitDotColor(initDotColor.getSelectObject());
sliderStyle.setSelectDotColor(selectDotColor.getSelectObject());
return sliderStyle;
}
protected void createExtraConfPane(JPanel centerPane) {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
UITitleSplitLine dotIndicator = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Slider_Dot_Indicator"), 520);
dotIndicator.setPreferredSize(new Dimension(520, 20));
centerPane.add(dotIndicator);
initDotColor = new NewColorSelectBox(137);
initDotColor.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
selectDotColor = new NewColorSelectBox(137);
selectDotColor.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UILabel initColor = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill"));
UILabel selectColor = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill"));
initColor.setPreferredSize(new Dimension(55, 20));
selectColor.setPreferredSize(new Dimension(55, 20));
JPanel initDotColorPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initColor, initDotColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
JPanel selectDotColorPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectColor, selectDotColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
initDotColorPane.setPreferredSize(new Dimension(240, 20));
selectDotColorPane.setPreferredSize(new Dimension(240, 20));
panel.add(initDotColorPane);
panel.add(selectDotColorPane);
centerPane.add(panel);
}
@Override
protected void initDefaultConfig() {
this.initialColorBox.setSelectObject(SliderStyle.DEFAULT_INITIAL_COLOR);
this.fontConfPane.populate(SliderStyle.DEFAULT_TAB_FONT.getFont());
initDotColor.setSelectObject(SliderStyle.DEFAULT_INITIAL_DOT_COLOR);
selectDotColor.setSelectObject(SliderStyle.DEFAULT_SELECT_DOT_COLOR);
}
@Override
protected MobileTemplatePreviewPane createPreviewPane() {
return new SliderStylePreviewPane();
}
@Override
protected String title4PopupWindow() {
return null;
}
public class SliderStylePreviewPane extends MobileTemplatePreviewPane {
private static final int CIRCLE_SIZE = 6;
private static final int GAP = 4;
private static final int OFFSET_X = 10;
private Color initDotColor;
private Color selectDotColor;
public SliderStylePreviewPane() {
}
public void repaint() {
super.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
Dimension dimension = this.getSize();
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
g2d.setFont(frFont);
g2d.setColor(frFont.getForeground());
FontMetrics fm = GraphHelper.getFontMetrics(frFont);
int fontHeight = fm.getHeight();
int ascent = fm.getAscent();
g2d.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Slider_Title"), OFFSET_X, (panelHeight - fontHeight - GAP - CIRCLE_SIZE) / 2 + ascent);
WCardTagLayout cardTagLayout = SliderStyleDefinePane.this.getTagLayout();
g2d.translate(OFFSET_X, (panelHeight + fontHeight + GAP - CIRCLE_SIZE) / 2);
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
if (i == 0) {
g2d.setColor(selectDotColor);
g2d.fillOval(0, 0, CIRCLE_SIZE, CIRCLE_SIZE);
g2d.translate(CIRCLE_SIZE + GAP, 0);
continue;
}
g2d.setColor(initDotColor);
g2d.fillOval(0, 0, CIRCLE_SIZE, CIRCLE_SIZE);
g2d.translate(CIRCLE_SIZE + GAP, 0);
}
}
public void populateConfig(MobileTemplateStyle templateStyle) {
super.populateConfig(templateStyle);
this.initDotColor = ((SliderStyle) templateStyle).getInitDotColor();
this.selectDotColor = ((SliderStyle) templateStyle).getSelectDotColor();
}
}
}

114
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/StyleDefinePaneWithSelectConf.java

@ -0,0 +1,114 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.MobileTabFontConfPane;
import com.fr.design.style.color.NewColorSelectBox;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
public abstract class StyleDefinePaneWithSelectConf extends MobileTemplateStyleDefinePane {
protected NewColorSelectBox selectColorBox;
protected UIColorButton selectFontColor;
public StyleDefinePaneWithSelectConf(WCardTagLayout tagLayout) {
super(tagLayout);
}
protected JPanel createBackgroundConfPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
initialColorBox = new NewColorSelectBox(137);
initialColorBox.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
selectColorBox = new NewColorSelectBox(137);
selectColorBox.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UILabel initFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill"));
UILabel selectFillLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill"));
initFillLabel.setPreferredSize(new Dimension(55, 20));
selectFillLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initFillLabel, initialColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
JPanel jPanel3 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectFillLabel, selectColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
jPanel2.setPreferredSize(new Dimension(240, 20));
jPanel3.setPreferredSize(new Dimension(240, 20));
panel.add(jPanel2);
panel.add(jPanel3);
return panel;
}
protected JPanel createFontConfPane() {
JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10);
panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20));
fontConfPane = new MobileTabFontConfPane();
fontConfPane.addFontChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
selectFontColor = new UIColorButton();
selectFontColor.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UILabel initCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char"));
initCharLabel.setPreferredSize(new Dimension(55, 20));
JPanel jPanel3 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{initCharLabel, fontConfPane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
jPanel3.setPreferredSize(new Dimension(500, 20));
UILabel selectCharLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Select_Char"));
selectCharLabel.setPreferredSize(new Dimension(55, 20));
selectFontColor.setPreferredSize(new Dimension(20, 20));
JPanel jPanel4 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectCharLabel, selectFontColor}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
JPanel jPanel5 = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
jPanel5.setPreferredSize(new Dimension(500, 20));
jPanel5.add(jPanel4);
panel.add(jPanel3);
panel.add(jPanel5);
return panel;
}
@Override
public MobileTemplateStyle updateSubStyle() {
MobileTemplateStyle mobileTemplateStyle = updateStyleWithSelectConf();
mobileTemplateStyle.setSelectColor(selectColorBox.getSelectObject());
TabFontConfig config = new TabFontConfig();
config.setFont(mobileTemplateStyle.getTabFontConfig().getFont());
config.setSelectColor(selectFontColor.getColor());
mobileTemplateStyle.setTabFontConfig(config);
return mobileTemplateStyle;
}
protected abstract MobileTemplateStyle updateStyleWithSelectConf();
public void populateSubStyle(MobileTemplateStyle ob) {
selectColorBox.setSelectObject(ob.getSelectColor());
selectFontColor.setColor(ob.getTabFontConfig().getSelectColor());
}
}

182
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java

@ -0,0 +1,182 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.IconManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.utils.DrawRoutines;
import com.fr.design.web.CustomIconPane;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
public class TabIconConfigPane extends JPanel {
private UIButton editIconButton;
private String curIconName;
private IconButton selectIconButton;
private ArrayList<IconButton> iconButtons = new ArrayList<IconButton>();
public TabIconConfigPane(int count) {
initComp(count);
}
public void initComp(int count) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
editIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
editIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
editIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(editIconButton);
editIconButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final CustomIconPane cip = new CustomIconPane(){
protected String createDescriptionText(){
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Custom_Icon_Message");
}
};
BasicDialog editDialog = cip.showWindow(DesignerContext.getDesignerFrame());
editDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
curIconName = cip.update();
setShowIconImage();
TabIconConfigPane.this.repaint();
}
});
editDialog.setVisible(true);
}
});
editIconButton.setEnabled(false);
this.add(panel, BorderLayout.CENTER);
JPanel northPane = new JPanel();
northPane.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
for (int i = 0; i < count; i++) {
IconButton iconButton = new IconButton("");
northPane.add(iconButton);
iconButtons.add(iconButton);
}
this.add(northPane, BorderLayout.NORTH);
}
public void setShowIconImage() {
selectIconButton.setIconName(curIconName);
}
public void populate(ArrayList<String> iconArr) {
for (int i = 0; i < iconButtons.size(); i++) {
iconButtons.get(i).setIconName(iconArr.get(i));
}
}
public ArrayList<String> update() {
ArrayList<String> iconNames = new ArrayList<String>();
for (int i = 0; i < iconButtons.size(); i++) {
iconNames.add(iconButtons.get(i).getIconName());
}
return iconNames;
}
private class IconButton extends JToggleButton implements ActionListener {
private String iconName;
private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 20;
private static final int ICON_X = 2;
private static final int ICON_Y = 2;
public IconButton(String name) {
this.iconName = name;
this.addActionListener(this);
this.setBackground(Color.WHITE);
this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name);
}
@Override
public void updateUI() {
setUI(new BasicButtonUI() {
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
});
}
protected void paintBorder(Graphics g) {
super.paintBorder(g);
if (ComparatorUtils.equals(this, selectIconButton)) {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#419BF9"), 0, 0, 20, 20);
} else {
DrawRoutines.drawRoundedBorder(
g, Color.decode("#D9DADD"), 0, 0, 20, 20);
}
}
public String getIconName() {
return iconName;
}
public void setIconName(String iconName) {
this.iconName = iconName;
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconName);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16
if (iconImage != null) {
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
}
}
@Override
public Dimension getPreferredSize() {
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE);
}
public void actionPerformed(ActionEvent evt) {
selectIconButton = this;
editIconButton.setEnabled(true);
TabIconConfigPane.this.repaint();// repaint
}
@Override
public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener;
}
private void fireChagneListener() {
if (this.changeListener != null) {
ChangeEvent evt = new ChangeEvent(this);
this.changeListener.stateChanged(evt);
}
}
}
}

55
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java

@ -0,0 +1,55 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.design.beans.BasicBeanPane;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.DefaultMobileTemplateStyle;
import com.fr.general.cardtag.mobile.DownMenuStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.SliderStyle;
import com.fr.general.cardtag.mobile.UpMenuStyle;
import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import java.util.HashMap;
import java.util.Map;
public class TemplateStyleDefinePaneFactory {
private static Map<String, StyleDefinePaneUI> defineMap = new HashMap<String, StyleDefinePaneUI>();
static {
defineMap.put(DefaultMobileTemplateStyle.STYLE_NAME, new StyleDefinePaneUI(DefaultMobileStyleDefinePane.class));
defineMap.put(UpMenuStyle.STYLE_NAME, new StyleDefinePaneUI(UpMenuStyleDefinePane.class));
defineMap.put(DownMenuStyle.STYLE_NAME, new StyleDefinePaneUI(DownMenuStyleDefinePane.class));
defineMap.put(SliderStyle.STYLE_NAME, new StyleDefinePaneUI(SliderStyleDefinePane.class));
}
public static BasicBeanPane<MobileTemplateStyle> createDefinePane(String style, WCardTagLayout tagLayout) {
StyleDefinePaneUI styleDefinePaneUI = defineMap.get(style);
if(styleDefinePaneUI == null){
styleDefinePaneUI = defineMap.get(DefaultMobileTemplateStyle.STYLE_NAME);
}
Class<? extends BasicBeanPane<MobileTemplateStyle>> clazz = styleDefinePaneUI.getaClass();
BasicBeanPane<MobileTemplateStyle> quickPane = null;
try {
quickPane = Reflect.on(clazz).create(tagLayout).get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return quickPane;
}
private static class StyleDefinePaneUI {
private Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass;
public StyleDefinePaneUI(Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass) {
this.aClass = aClass;
}
public Class<? extends BasicBeanPane<MobileTemplateStyle>> getaClass() {
return aClass;
}
public void setaClass(Class<? extends BasicBeanPane<MobileTemplateStyle>> aClass) {
this.aClass = aClass;
}
}
}

221
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UpMenuStyleDefinePane.java

@ -0,0 +1,221 @@
package com.fr.design.mainframe.mobile.ui;
import com.fr.base.GraphHelper;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.widget.UITitleSplitLine;
import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.FRFont;
import com.fr.general.cardtag.mobile.LineDescription;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.UpMenuStyle;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Stroke;
public class UpMenuStyleDefinePane extends StyleDefinePaneWithSelectConf {
private UIRadioButton gapFix;
private UIRadioButton titleWidthFix;
private LinePane bottomBorderPane;
private LinePane underLinePane;
public UpMenuStyleDefinePane(WCardTagLayout tagLayout) {
super(tagLayout);
}
protected JPanel createCenterPane() {
JPanel panel = super.createCenterPane();
UILabel displayGap = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Display_Gap"));
displayGap.setPreferredSize(new Dimension(55, 20));
gapFix = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Gap_Fix"));
titleWidthFix = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Title_Width_Fix"));
ButtonGroup buttonGroup = new ButtonGroup();
titleWidthFix.setSelected(true);
buttonGroup.add(gapFix);
gapFix.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
titleWidthFix.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
buttonGroup.add(titleWidthFix);
gapFix.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
titleWidthFix.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
JPanel flowLeft = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
flowLeft.add(gapFix);
flowLeft.add(titleWidthFix);
JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{displayGap, flowLeft}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM);
centerPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 15, 20));
centerPane.setPreferredSize(new Dimension(500, 20));
JPanel outerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
outerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 15, 0));
outerPane.add(centerPane, BorderLayout.CENTER);
panel.add(outerPane);
return panel;
}
protected void createExtraConfPane(JPanel centerPane) {
bottomBorderPane = new LinePane();
underLinePane = new LinePane();
bottomBorderPane.addLineChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
underLinePane.addLineChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
updatePreviewPane();
}
});
UITitleSplitLine titleSplitLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Bottom_Border"), 520);
titleSplitLine.setPreferredSize(new Dimension(520, 20));
centerPane.add(titleSplitLine);
centerPane.add(bottomBorderPane);
UITitleSplitLine titleUnderLine = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Under_Line"), 520);
titleUnderLine.setPreferredSize(new Dimension(520, 20));
centerPane.add(titleUnderLine);
centerPane.add(underLinePane);
}
@Override
protected void initDefaultConfig() {
this.initialColorBox.setSelectObject(UpMenuStyle.DEFAULT_INITIAL_COLOR);
this.fontConfPane.populate(UpMenuStyle.DEFAULT_TAB_FONT.getFont());
this.selectColorBox.setSelectObject(UpMenuStyle.DEFAULT_SELECT_COLOR);
this.selectFontColor.setColor(UpMenuStyle.DEFAULT_SELECT_FONT_COLOR);
this.bottomBorderPane.populate(UpMenuStyle.DEFAULT_BOTTOM_BORDER);
this.underLinePane.populate(UpMenuStyle.DEFAULT_UNDER_LINE);
}
@Override
protected MobileTemplatePreviewPane createPreviewPane() {
return new UpMenuStylePreviewPane();
}
@Override
public void populateSubStyle(MobileTemplateStyle ob) {
super.populateSubStyle(ob);
UpMenuStyle style = (UpMenuStyle) ob;
gapFix.setSelected(style.isGapFix());
titleWidthFix.setSelected(style.isTitleWidthFix());
bottomBorderPane.populate(style.getBottomBorder());
underLinePane.populate(style.getUnderline());
}
@Override
protected MobileTemplateStyle getDefaultTemplateStyle() {
return new UpMenuStyle();
}
@Override
public MobileTemplateStyle updateStyleWithSelectConf() {
UpMenuStyle style = new UpMenuStyle();
style.setGapFix(gapFix.isSelected());
style.setTitleWidthFix(titleWidthFix.isSelected());
style.setBottomBorder(bottomBorderPane.update());
style.setUnderline(underLinePane.update());
return style;
}
@Override
protected String title4PopupWindow() {
return null;
}
public class UpMenuStylePreviewPane extends MobileTemplatePreviewPane {
private LineDescription bottomBorder;
private LineDescription underLine;
private boolean isGapFix;
public UpMenuStylePreviewPane() {
this.setBackground(Color.WHITE);
}
public void repaint() {
super.repaint();
}
@Override
public void paint(Graphics g) {
super.paint(g);
Color selectFontColor = this.getTabFontConfig().getSelectColor();
Dimension dimension = this.getSize();
int panelWidth = dimension.width;
int panelHeight = dimension.height;
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
FRFont frFont = this.getTabFontConfig().getFont();
FontMetrics fm = GraphHelper.getFontMetrics(frFont);
WCardTagLayout cardTagLayout = UpMenuStyleDefinePane.this.getTagLayout();
int eachWidth = panelWidth / cardTagLayout.getWidgetCount();
g2d.setFont(frFont);
int fontHeight = fm.getHeight();
int ascentHeight = fm.getAscent();
if (bottomBorder.getLineStyle() != 0) {
g2d.setColor(bottomBorder.getColor());
g2d.setStroke(GraphHelper.getStroke(bottomBorder.getLineStyle()));
g2d.drawLine(0, panelHeight - 1, panelWidth, panelHeight - 1);
}
for (int i = 0; i < cardTagLayout.getWidgetCount(); i++) {
g2d.setColor(i == 0 ? selectFontColor : frFont.getForeground());
CardSwitchButton cardSwitchButton = cardTagLayout.getSwitchButton(i);
String displayName = calculateDisplayName(cardSwitchButton.getText(), fm, eachWidth);
int width = fm.stringWidth(displayName);
if(i == 0){
Color oldColor = g2d.getColor();
g2d.setColor(this.getSelectColor());
g2d.fillRect(0, 0 ,eachWidth, panelHeight - 2);
g2d.setColor(oldColor);
}
g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight - fontHeight) / 2 + ascentHeight);
Stroke oldStroke = g2d.getStroke();
if (i == 0) {
g2d.setColor(this.underLine.getColor());
g2d.setStroke(GraphHelper.getStroke(underLine.getLineStyle()));
int underLineX = this.isGapFix ? (eachWidth - width) / 2 : 0;
int underLineWidth = this.isGapFix ? width : eachWidth;
g2d.drawLine(underLineX, panelHeight - 2, underLineX + underLineWidth, panelHeight - 2);
}
g2d.setStroke(oldStroke);
g2d.translate(eachWidth, 0);
}
}
public void populateConfig(MobileTemplateStyle templateStyle) {
super.populateConfig(templateStyle);
this.bottomBorder = ((UpMenuStyle) templateStyle).getBottomBorder();
this.underLine = ((UpMenuStyle) templateStyle).getUnderline();
this.isGapFix = ((UpMenuStyle) templateStyle).isGapFix();
}
}
}

144
designer-base/src/main/java/com/fr/design/mainframe/widget/MobileTabFontConfPane.java

@ -0,0 +1,144 @@
package com.fr.design.mainframe.widget;
import com.fr.base.BaseUtils;
import com.fr.base.Utils;
import com.fr.design.gui.ibutton.UIColorButton;
import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.general.FRFont;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Vector;
public class MobileTabFontConfPane extends JPanel {
private static final Icon[] ITALIC_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic_white.png")};
private static final Icon[] BOLD_ICONS = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold_white.png")};
private EventListenerList fontChangeListener = new EventListenerList();
private UIComboBox fontFamily;
private UIComboBox fontSize;
private UIToggleButton bold;
private UIColorButton color;
private UIToggleButton italic;
public MobileTabFontConfPane() {
super();
init();
}
private void init() {
this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
fontFamily = new UIComboBox(Utils.getAvailableFontFamilyNames4Report());
Vector<Integer> integerList = new Vector<Integer>();
for (int i = 1; i < 100; i++) {
integerList.add(i);
}
fontFamily.setPreferredSize(new Dimension(152, 20));
fontSize = new UIComboBox(integerList);
color = new UIColorButton();
bold = new UIToggleButton(BOLD_ICONS, true);
italic = new UIToggleButton(ITALIC_ICONS, true);
fontFamily.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireFontStateChanged();
}
});
fontSize.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireFontStateChanged();
}
});
bold.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
italic.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
color.addColorChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
fireFontStateChanged();
}
});
this.add(fontFamily);
this.add(fontSize);
this.add(color);
this.add(bold);
this.add(italic);
}
public FRFont update() {
String family = (String) fontFamily.getSelectedItem();
int size = (int) fontSize.getSelectedItem();
int style = Font.PLAIN;
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN;
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN;
FRFont frFont = FRFont.getInstance(family, style, size, color.getColor());
return frFont;
}
public void populate(FRFont frFont) {
fontFamily.setSelectedItem(frFont.getFamily());
fontSize.setSelectedItem(frFont.getSize());
color.setColor(frFont.getForeground());
bold.setSelected(frFont.isBold());
italic.setSelected(frFont.isItalic());
}
/**
* 添加监听
*
* @param changeListener 监听列表
*/
public void addFontChangeListener(ChangeListener changeListener) {
fontChangeListener.add(ChangeListener.class, changeListener);
}
/**
* 移除监听
* Removes an old ColorChangeListener.
*
* @param changeListener 监听列表
*/
public void removeFontChangeListener(ChangeListener changeListener) {
fontChangeListener.remove(ChangeListener.class, changeListener);
}
/**
* 颜色状态改变
*/
public void fireFontStateChanged() {
Object[] listeners = fontChangeListener.getListenerList();
ChangeEvent e = null;
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == ChangeListener.class) {
if (e == null) {
e = new ChangeEvent(this);
}
((ChangeListener) listeners[i + 1]).stateChanged(e);
}
}
}
}

50
designer-base/src/main/java/com/fr/design/mainframe/widget/UITitleSplitLine.java

@ -0,0 +1,50 @@
package com.fr.design.mainframe.widget;
import com.fr.design.gui.ilable.UILabel;
import com.fr.general.FRFont;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
public class UITitleSplitLine extends JPanel {
private static final Color LINE_COLOR = Color.decode("#E0E0E1");
private static final Color TITLE_COLOR = Color.decode("#333334");
private static final FRFont TITLE_FONT = FRFont.getInstance("PingFangSC-Regular", 0, 12.0F);
private static final int OFFSETX = 10;
private static final int OFFSET = 3;
private Color color;
private UILabel label;
private int width;
public UITitleSplitLine(String title, int width) {
this(title, LINE_COLOR, width);
}
public UITitleSplitLine(String title, Color color, int width) {
super();
this.color = color;
this.width = width;
this.label = new UILabel(title);
}
public void paint(Graphics g) {
super.paint(g);
Dimension size = label.getPreferredSize();
int labelH = size.height;
g.setColor(color);
g.drawLine(0, labelH / 2, OFFSETX, labelH / 2);
g.drawLine(OFFSETX + size.width + OFFSET * 2, labelH / 2, width, labelH / 2);
g.translate(OFFSETX + OFFSET, 0);
label.setFont(TITLE_FONT);
label.setForeground(TITLE_COLOR);
label.setSize(size.width, size.height);
label.paint(g);
g.translate(-OFFSETX - OFFSET, 0);
}
}

10
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AbstractTemplateStylePane.java

@ -0,0 +1,10 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.dialog.BasicPane;
public abstract class AbstractTemplateStylePane<T> extends BasicPane {
public abstract void populate(T ob);
public abstract T update();
}

13
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleTemplateStyleEditor.java

@ -2,7 +2,6 @@ package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.general.cardtag.TemplateStyle;
import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper; import com.fr.design.mainframe.widget.wrappers.TemplateStyleWrapper;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -15,18 +14,16 @@ public class AccessibleTemplateStyleEditor extends UneditableAccessibleEditor {
private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400); private static final Dimension DEFAULT_DIMENSION = new Dimension(600, 400);
private TemplateStylePane stylePane; private AbstractTemplateStylePane stylePane;
public AccessibleTemplateStyleEditor() { public AccessibleTemplateStyleEditor(AbstractTemplateStylePane stylePane) {
super(new TemplateStyleWrapper()); super(new TemplateStyleWrapper());
this.stylePane = stylePane;
} }
@Override @Override
protected void showEditorPane() { protected void showEditorPane() {
if (stylePane == null) { stylePane.setPreferredSize(DEFAULT_DIMENSION);
stylePane = new TemplateStylePane();
stylePane.setPreferredSize(DEFAULT_DIMENSION);
}
BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this)); BasicDialog dlg = stylePane.showWindow(SwingUtilities.getWindowAncestor(this));
dlg.addDialogActionListener(new DialogActionAdapter() { dlg.addDialogActionListener(new DialogActionAdapter() {
@ -36,7 +33,7 @@ public class AccessibleTemplateStyleEditor extends UneditableAccessibleEditor {
fireStateChanged(); fireStateChanged();
} }
}); });
stylePane.populate((TemplateStyle) getValue()); stylePane.populate(getValue());
dlg.setVisible(true); dlg.setVisible(true);
} }
} }

112
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java

@ -0,0 +1,112 @@
package com.fr.design.mainframe.widget.accessibles;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory;
import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.MobileTemplateStyleType;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.ListCellRenderer;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MobileTemplateStylePane extends AbstractTemplateStylePane<MobileTemplateStyle> {
private static final List<MobileTemplateStyleType> STYLE_LIST = new ArrayList<MobileTemplateStyleType>();
static {
STYLE_LIST.add(MobileTemplateStyleType.DEFAULT_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.UP_MENU_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.DOWN_MENU_STYLE);
STYLE_LIST.add(MobileTemplateStyleType.SLIDER_STYLE);
}
private DefaultListModel listModel;
private JList styleList;
private Map<String, BasicBeanPane<MobileTemplateStyle>> map = new HashMap<>();
private JPanel right;
private CardLayout card;
public MobileTemplateStylePane(WCardTagLayout tagLayout){
init(tagLayout);
}
public void init(WCardTagLayout tagLayout){
this.setLayout(FRGUIPaneFactory.createBorderLayout());
listModel = new DefaultListModel();
card = new CardLayout();
right = FRGUIPaneFactory.createCardLayout_S_Pane();
right.setLayout(card);
for(MobileTemplateStyleType style : STYLE_LIST){
listModel.addElement(style.getDisplayName());
BasicBeanPane<MobileTemplateStyle> styleBasicBeanPane = TemplateStyleDefinePaneFactory.createDefinePane(style.getStyle(), tagLayout);
map.put(style.getDisplayName(), styleBasicBeanPane);
right.add(style.getDisplayName(), styleBasicBeanPane);
}
styleList = new JList(listModel);
styleList.setCellRenderer(render);
JPanel westPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
westPane.add(styleList, BorderLayout.CENTER);
westPane.setPreferredSize(new Dimension(100, 500));
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);
styleList.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String selectedValue = (String)styleList.getSelectedValue();
card.show(right, selectedValue);
}
});
this.add(westPane, BorderLayout.WEST);
this.add(centerPane, BorderLayout.CENTER);
}
public 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 MobileTemplateStyle) {
MobileTemplateStyle l = (MobileTemplateStyle) value;
this.setText(l.toString());
}
return this;
}
};
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Tab_Style_Template");
}
public void populate(MobileTemplateStyle templateStyle) {
for(int i = 0; i< listModel.getSize(); i++){
String style = templateStyle.getStyle();
MobileTemplateStyleType templateStyleType = MobileTemplateStyleType.parse(style);
if((listModel.getElementAt(i)).equals(templateStyleType.getDisplayName())){
styleList.setSelectedIndex(i);
map.get(templateStyle.toString()).populateBean(templateStyle);
card.show(right, templateStyle.toString());
return;
}
}
styleList.setSelectedIndex(0);
}
public MobileTemplateStyle update() {
return map.get(styleList.getSelectedValue()).updateBean();
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java

@ -21,16 +21,17 @@ import javax.swing.ListCellRenderer;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
/** /**
* Created by kerry on 2017/11/23. * Created by kerry on 2017/11/23.
*/ */
public class TemplateStylePane extends BasicPane { public class TemplateStylePane extends AbstractTemplateStylePane<TemplateStyle> {
private DefaultListModel listModel; private DefaultListModel listModel;
private JList styleList; private JList styleList;
private TemplateStylePreviewPane previewPane = new TemplateStylePreviewPane(new DefaultTemplateStyle()); private TemplateStylePreviewPane previewPane = new TemplateStylePreviewPane(new DefaultTemplateStyle(), new Rectangle(0, 50, 540, 400));
public TemplateStylePane(){ public TemplateStylePane(){
init(); init();

14
designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java

@ -1,26 +1,23 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.BaseUtils;
import com.fr.general.cardtag.TemplateStyle; import com.fr.general.cardtag.TemplateStyle;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Rectangle;
/** /**
* Created by kerry on 2017/12/11. * Created by kerry on 2017/12/11.
*/ */
public class TemplateStylePreviewPane extends JPanel { public class TemplateStylePreviewPane extends JPanel {
private static final int WIDTH = 540; private Rectangle rectangle;
private static final int HEIGHT = 400;
private static final int OFFSETY = 50;
private TemplateStyle templateStyle; private TemplateStyle templateStyle;
public TemplateStylePreviewPane(TemplateStyle templateStyle){ public TemplateStylePreviewPane(TemplateStyle templateStyle, Rectangle rectangle){
this.templateStyle = templateStyle; this.templateStyle = templateStyle;
this.rectangle = rectangle;
} }
public void repaint (TemplateStyle templateStyle){ public void repaint (TemplateStyle templateStyle){
@ -32,7 +29,6 @@ public class TemplateStylePreviewPane extends JPanel {
public void paint(Graphics g) { public void paint(Graphics g) {
super.paint(g); super.paint(g);
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();
Image image = BaseUtils.readImage(templateStyle.getPreview()); templateStyle.paintPreview(g2d, rectangle);
g2d.drawImage(image, 0, OFFSETY, WIDTH, HEIGHT, null);
} }
} }

68
designer-base/src/main/java/com/fr/design/mainframe/widget/preview/MobileTemplatePreviewPane.java

@ -0,0 +1,68 @@
package com.fr.design.mainframe.widget.preview;
import com.fr.general.cardtag.mobile.MobileTemplateStyle;
import com.fr.general.cardtag.mobile.TabFontConfig;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.FontMetrics;
public abstract class MobileTemplatePreviewPane extends JPanel {
private Color initialColor;
private Color selectColor;
private TabFontConfig tabFontConfig = new TabFontConfig();
public Color getInitialColor() {
return initialColor;
}
public void setInitialColor(Color initialColor) {
this.initialColor = initialColor;
}
public Color getSelectColor() {
return selectColor;
}
public void setSelectColor(Color selectColor) {
this.selectColor = selectColor;
}
public TabFontConfig getTabFontConfig() {
return tabFontConfig;
}
public void setTabFontConfig(TabFontConfig tabFontConfig) {
this.tabFontConfig = tabFontConfig;
}
public MobileTemplatePreviewPane() {
}
public void populateConfig(MobileTemplateStyle templateStyle) {
this.setInitialColor(templateStyle.getInitialColor());
this.setBackground(templateStyle.getInitialColor());
this.setSelectColor(templateStyle.getSelectColor());
this.setTabFontConfig(templateStyle.getTabFontConfig());
}
protected String calculateDisplayName(String widgetName, FontMetrics fm, int eachWidth) {
StringBuffer buffer = new StringBuffer();
String result;
for (int i = 0; i < widgetName.length(); i++) {
result = buffer.toString();
buffer.append(widgetName.charAt(i));
if (fm.stringWidth(buffer.toString()) > eachWidth) {
return result;
}
}
return buffer.toString();
}
public void repaint() {
super.repaint();
}
}

17
designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/UpdateMainDialog.java

@ -23,7 +23,12 @@ import com.fr.design.onlineupdate.ui.widget.UpdateInfoTableCellRender;
import com.fr.design.onlineupdate.ui.widget.UpdateInfoTableModel; import com.fr.design.onlineupdate.ui.widget.UpdateInfoTableModel;
import com.fr.design.onlineupdate.ui.widget.UpdateInfoTextAreaCellRender; import com.fr.design.onlineupdate.ui.widget.UpdateInfoTextAreaCellRender;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.*; import com.fr.general.ComparatorUtils;
import com.fr.general.DateUtils;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils;
import com.fr.general.SiteCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -337,8 +342,14 @@ public class UpdateMainDialog extends UIDialog {
initUpdateActionPane(); initUpdateActionPane();
add(jarVersionInfoPane, BorderLayout.NORTH); add(jarVersionInfoPane, BorderLayout.NORTH);
add(jarUpdateInfoPane, BorderLayout.CENTER);
add(updateActionPane, BorderLayout.SOUTH); //海外版本不显示更新信息
if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)){
add(jarUpdateInfoPane, BorderLayout.CENTER);
add(updateActionPane, BorderLayout.SOUTH);
}else {
add(updateActionPane, BorderLayout.CENTER);
}
addActionListenerForUpdateBtn(); addActionListenerForUpdateBtn();

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

@ -13,7 +13,6 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.NewColorSelectPane; import com.fr.design.style.color.NewColorSelectPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -30,7 +29,6 @@ import java.awt.event.ItemListener;
* Created by plough on 2018/5/15. * Created by plough on 2018/5/15.
*/ */
public class WatermarkPane extends BasicPane { public class WatermarkPane extends BasicPane {
private static final int MAX_WIDTH = 160; private static final int MAX_WIDTH = 160;
// 水印预览面板 // 水印预览面板
@ -47,7 +45,7 @@ public class WatermarkPane extends BasicPane {
} }
private void initComponents() { private void initComponents() {
this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.setBorder(BorderFactory.createEmptyBorder(4, 4, -5, 4));
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
@ -66,7 +64,7 @@ public class WatermarkPane extends BasicPane {
// 设置 // 设置
JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane.add(rightPane, BorderLayout.EAST); contentPane.add(rightPane, BorderLayout.EAST);
rightPane.add(initRightPane(), BorderLayout.CENTER); rightPane.add(initRightPane(), BorderLayout.NORTH);
} }
public void populate(WatermarkAttr watermark) { public void populate(WatermarkAttr watermark) {
@ -84,6 +82,7 @@ public class WatermarkPane extends BasicPane {
watermark.setText(formulaPane.getUITextField().getText()); watermark.setText(formulaPane.getUITextField().getText());
watermark.setFontSize((int)fontSizeComboBox.getSelectedItem()); watermark.setFontSize((int)fontSizeComboBox.getSelectedItem());
watermark.setColor(colorPane.getColor()); watermark.setColor(colorPane.getColor());
colorPane.updateUsedColor();
return watermark; return watermark;
} }
@ -98,6 +97,7 @@ public class WatermarkPane extends BasicPane {
protected UIScrollPane initRightPane(){ protected UIScrollPane initRightPane(){
formulaPane = new TinyFormulaPane(); formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true);
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));
fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER); fontSizeTypePane.add(fontSizeComboBox, BorderLayout.CENTER);
@ -157,7 +157,8 @@ public class WatermarkPane extends BasicPane {
} }
private void populateColor(Color color) { private void populateColor(Color color) {
colorPane.setColor(color); // 颜色面板的色值只有 rgb,去掉 alpha 通道
colorPane.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
colorPane.addChangeListener(new ChangeListener() { colorPane.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {

62
designer-base/src/main/java/com/fr/design/report/WatermarkSettingPane.java

@ -0,0 +1,62 @@
package com.fr.design.report;
import com.fr.base.iofile.attr.WatermarkAttr;
import com.fr.design.dialog.AbstractTemplateServerSettingPane;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
/**
* Created by plough on 2018/11/7.
*/
public class WatermarkSettingPane extends AbstractTemplateServerSettingPane {
private WatermarkPane watermarkPane;
public WatermarkSettingPane() {
super();
initComponents();
}
private void initComponents() {
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 8, 0, 0));
}
@Override
protected JPanel getContentPane() {
if (watermarkPane == null) {
watermarkPane = new WatermarkPane();
}
return watermarkPane;
}
@Override
protected void populateServerSettings() {
WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromServerConfig();
watermarkPane.populate(watermarkAttr);
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_WaterMark");
}
public void populate(WatermarkAttr watermark) {
if (!watermark.isValid()) {
chooseComboBox.setSelectedIndex(SERVER_SET);
populateServerSettings();
return;
}
chooseComboBox.setSelectedIndex(SINGLE_SET);
watermarkPane.populate(watermark);
}
public WatermarkAttr update() {
WatermarkAttr watermark = watermarkPane.update();
if (isUsingServerSettings()) {
watermark.setValid(false);
}
return watermark;
}
}

76
designer-base/src/main/java/com/fr/design/report/fit/FitType.java

@ -0,0 +1,76 @@
package com.fr.design.report.fit;
import com.fr.design.designer.properties.items.Item;
import com.fr.report.fit.ReportFitAttr;
import com.fr.stable.StringUtils;
/**
* Created by Administrator on 2016/4/13/0013.
*/
public enum FitType {
DEFAULT(0) {
@Override
public String description() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Default");
}
},
// 横向自适应, 纵向根据横向的比例来适配
HORIZONTAL_FIT(1) {
@Override
public String description() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal");
}
},
// 双向自适应, 横纵向都是根据页面宽高来计算
DOUBLE_FIT(2) {
@Override
public String description() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Horizontal_Vertical");
}
},
NOT_FIT(3) {
@Override
public String description() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No");
}
};
private int state;
FitType(int state) {
this.state = state;
}
public static FitType parse(ReportFitAttr attr) {
if (attr == null) {
return DEFAULT;
}
for (FitType attrState : values()) {
if (attrState.state == attr.fitStateInPC()) {
return attrState;
}
}
return DEFAULT;
}
public int getState() {
return this.state;
}
public String description() {
return StringUtils.EMPTY;
}
public Item propertyItem() {
return new Item(this.description(), this.getState());
}
}

240
designer-base/src/main/java/com/fr/design/report/fit/menupane/BrowserFitAttrPane.java

@ -0,0 +1,240 @@
package com.fr.design.report.fit.menupane;
import com.fr.config.Configuration;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.report.fit.FitType;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* Created by Administrator on 2016/5/5/0005.
*/
public class BrowserFitAttrPane extends BasicBeanPane<ReportFitAttr> {
protected FontRadioGroup fontRadioGroup;
protected FitRadioGroup fitRadionGroup;
protected UICheckBox globalCheck;
protected FitPreviewPane fitPreviewPane;
protected ReportFitAttr localFitAttr;
protected UIRadioButton defaultRadio;
protected UIRadioButton horizonRadio;
protected UIRadioButton doubleRadio;
protected UIRadioButton notFitRadio;
protected UIRadioButton fontFitRadio;
protected UIRadioButton fontNotFitRadio;
private UIButton editGlobalOps;
private JPanel borderPane;
private JPanel globalOpsPane;
private JPanel fitOpsPane;
public BrowserFitAttrPane() {
initComponents(ReportFitConfig.getInstance().getFrmFitAttr());
}
protected void initComponents(ReportFitAttr globalFitAttr) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
globalOpsPane = initGlobalOpsPane(globalFitAttr);
this.add(globalOpsPane, BorderLayout.NORTH);
fitOpsPane = initFitOpsPane();
}
protected void initBorderPane(String title) {
borderPane = FRGUIPaneFactory.createTitledBorderPaneCenter(title);
borderPane.add(fitOpsPane, BorderLayout.CENTER);
fitPreviewPane = new FitPreviewPane();
borderPane.add(fitPreviewPane, BorderLayout.SOUTH);
this.add(borderPane, BorderLayout.CENTER);
}
private JPanel initFitOpsPane() {
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p};
double[] columnSize = {p, p, p, p, p};
ActionListener actionListener = getPreviewActionListener();
fontRadioGroup = new FontRadioGroup();
fontFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit"));
fontFitRadio.setSelected(true);
fontNotFitRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-No"));
addRadioToGroup(fontRadioGroup, fontFitRadio, fontNotFitRadio);
fontRadioGroup.addActionListener(actionListener);
fitRadionGroup = new FitRadioGroup();
defaultRadio = new UIRadioButton(FitType.DEFAULT.description());
horizonRadio = new UIRadioButton(FitType.HORIZONTAL_FIT.description());
doubleRadio = new UIRadioButton(FitType.DOUBLE_FIT.description());
notFitRadio = new UIRadioButton(FitType.NOT_FIT.description());
addRadioToGroup(fitRadionGroup, defaultRadio, horizonRadio, doubleRadio, notFitRadio);
fitRadionGroup.addActionListener(actionListener);
JPanel fitOpsPane = TableLayoutHelper.createTableLayoutPane(initFitComponents(), rowSize, columnSize);
fitOpsPane.setBorder(BorderFactory.createEmptyBorder(10, 13, 10, 10));
return fitOpsPane;
}
protected Component[][] initFitComponents() {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), defaultRadio, horizonRadio, doubleRadio, notFitRadio}
};
return components;
}
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) {
for (UIRadioButton radio : radios) {
buttonGroup.add(radio);
}
}
private JPanel initGlobalOpsPane(final ReportFitAttr globalFitAttr) {
final JPanel globalOpsPane = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();
globalCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-UseGlobal"));
globalOpsPane.add(globalCheck);
globalCheck.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
boolean isLocalConfig = !globalCheck.isSelected();
//勾选全局时,采用全局保存的自适应属性更新界面
if (!isLocalConfig) {
ReportFitAttr attr = globalFitAttr;
fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont());
fitRadionGroup.selectIndexButton(attr.fitStateInPC());
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled());
remove(BrowserFitAttrPane.this.borderPane);
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global"));
} else {
ReportFitAttr attr = localFitAttr;
fontRadioGroup.selectFontFit(((ReportFitAttr) attr).isFitFont());
fitRadionGroup.selectIndexButton(attr.fitStateInPC());
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled());
remove(BrowserFitAttrPane.this.borderPane);
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local"));
}
fontRadioGroup.setEnabled(isLocalConfig);
fitRadionGroup.setEnabled(isLocalConfig);
editGlobalOps.setVisible(!isLocalConfig);
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled());
}
});
editGlobalOps = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-EditGlobal"));
editGlobalOps.setVisible(false);
editGlobalOps.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
fontRadioGroup.setEnabled(true);
fitRadionGroup.setEnabled(true);
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fitRadionGroup.isEnabled());
}
public void mouseEntered(MouseEvent e) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
public void mouseExited(MouseEvent e) {
setCursor(Cursor.getDefaultCursor());
}
});
globalOpsPane.add(editGlobalOps);
return globalOpsPane;
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-AttrSet");
}
@Override
public void populateBean(ReportFitAttr attr) {
if (attr == null) {
//如果为空, 就用全局的
attr = ReportFitConfig.getInstance().getFrmFitAttr();
populateGlobalComponents();
} else {
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local"));
}
this.localFitAttr = attr;
fontRadioGroup.selectFontFit((attr).isFitFont());
fitRadionGroup.selectIndexButton(attr.fitStateInPC());
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled());
}
protected void populateGlobalComponents() {
globalCheck.setSelected(true);
fontRadioGroup.setEnabled(false);
fitRadionGroup.setEnabled(false);
editGlobalOps.setVisible(true);
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Global"));
}
//有八种组合, 不过有意义的就是6种, 以此为key去缓存里找对应的预览图片
public String getCurrentFitOptions() {
return fitRadionGroup.getSelectRadioIndex() + "" + fontRadioGroup.getSelectRadioIndex();
}
private ActionListener getPreviewActionListener() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String fitOptions = getCurrentFitOptions();
fitPreviewPane.refreshPreview(fitOptions, fontRadioGroup.isEnabled());
}
};
}
@Override
public ReportFitAttr updateBean() {
ReportFitAttr attr = new ReportFitAttr();
attr.setFitFont(fontRadioGroup.isFontFit());
attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex());
// 直接用全局的
if (globalCheck.isSelected()) {
updateGlobalConfig(attr);
return null;
}
this.localFitAttr = attr;
return attr;
}
private void updateGlobalConfig(final ReportFitAttr attr) {
Configurations.update(new Worker() {
@Override
public void run() {
ReportFitConfig manager = ReportFitConfig.getInstance();
manager.setFrmFitAttr(attr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ReportFitConfig.class};
}
});
}
}

74
designer-base/src/main/java/com/fr/design/report/fit/menupane/FitPreviewPane.java

@ -0,0 +1,74 @@
package com.fr.design.report.fit.menupane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.IOUtils;
import javax.swing.ImageIcon;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Administrator on 2016/5/5/0005.
*/
public class FitPreviewPane extends BasicPane {
private static final String DEFAULT_FONT_TAG = "00";
private static final String DEFAULT_TAG = "01";
private static final String HORIZON_FONT_TAG = "10";
private static final String HORIZON_TAG = "11";
private static final String DOUBLE_FONT_TAG = "20";
private static final String DOUBLE_TAG = "21";
private static final String NOT_FONT_TAG = "30";
private static final String NOT_TAG = "31";
private UILabel imageLabel;
private Map<String, ImageIcon> cachedPreviewImage = new HashMap<String, ImageIcon>();
private Map<String, ImageIcon> globalCachedPreviewImage = new HashMap<String, ImageIcon>();
public FitPreviewPane() {
//初始化缓存图片, 有些无意义的组合.
initCacheImage();
//初始化组件
initComponents();
}
//默认和不自适应时,字体自适应不起效,只有6张图
private void initCacheImage() {
globalCachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png")));
globalCachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DEFAULT_FONT_TAG + ".png")));
globalCachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_FONT_TAG + ".png")));
globalCachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + HORIZON_TAG + ".png")));
globalCachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_FONT_TAG + ".png")));
globalCachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + DOUBLE_TAG + ".png")));
globalCachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png")));
globalCachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/gray/" + NOT_FONT_TAG + ".png")));
cachedPreviewImage.put(DEFAULT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png")));
cachedPreviewImage.put(DEFAULT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DEFAULT_FONT_TAG + ".png")));
cachedPreviewImage.put(HORIZON_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_FONT_TAG + ".png")));
cachedPreviewImage.put(HORIZON_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + HORIZON_TAG + ".png")));
cachedPreviewImage.put(DOUBLE_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_FONT_TAG + ".png")));
cachedPreviewImage.put(DOUBLE_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + DOUBLE_TAG + ".png")));
cachedPreviewImage.put(NOT_FONT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png")));
cachedPreviewImage.put(NOT_TAG, new ImageIcon(IOUtils.readImage("/com/fr/design/images/reportfit/preview/" + NOT_FONT_TAG + ".png")));
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
imageLabel = new UILabel();
imageLabel.setIcon(cachedPreviewImage.get(DEFAULT_TAG));
this.add(imageLabel);
}
public void refreshPreview(String index, boolean isEditedable) {
ImageIcon newImageIcon = isEditedable ? cachedPreviewImage.get(index) : globalCachedPreviewImage.get(index);
imageLabel.setIcon(newImageIcon);
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Preview");
}
}

80
designer-base/src/main/java/com/fr/design/report/fit/menupane/FitRadioGroup.java

@ -0,0 +1,80 @@
package com.fr.design.report.fit.menupane;
import com.fr.design.gui.ibutton.UIRadioButton;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
/**
* 自适应四个按钮选项的group
* <p>
* Created by Administrator on 2016/5/5/0005.
*/
public class FitRadioGroup extends ButtonGroup {
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>();
@Override
public void add(AbstractButton button) {
super.add(button);
UIRadioButton radioButton = (UIRadioButton) button;
radioButtons.add(radioButton);
}
/**
* 设置按钮状态
*/
public boolean isEnabled() {
return radioButtons.get(0).isEnabled();
}
/**
* 设置按钮状态
*/
public void setEnabled(boolean enabled) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.setEnabled(enabled);
}
}
/**
* 获取当前选中的按钮index
*
* @return 按钮index
*/
public int getSelectRadioIndex() {
for (int i = 0, len = radioButtons.size(); i < len; i++) {
if (radioButtons.get(i).isSelected()) {
return i;
}
}
return 0;
}
/**
* 选中指定index的按钮
*/
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
/**
* 给所有的按钮加上监听
*/
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
}

17
designer-base/src/main/java/com/fr/design/report/fit/menupane/FontRadioGroup.java

@ -0,0 +1,17 @@
package com.fr.design.report.fit.menupane;
/**
* 字体的两个选项组成的group
* <p>
* Created by Administrator on 2016/5/5/0005.
*/
public class FontRadioGroup extends FitRadioGroup {
public void selectFontFit(boolean isFontFit) {
selectIndexButton(isFontFit ? 0 : 1);
}
public boolean isFontFit() {
return getSelectRadioIndex() == 0;
}
}

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

@ -0,0 +1,107 @@
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;
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.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() {
return 'T';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Template");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
private static final MenuKeySet REPORT_FIT_ATTR_ELEMENTCASE = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'T';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Elementcase");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
public ReportFitAttrAction(JTemplate jTemplate) {
super(jTemplate);
initMenuStyle();
}
private void initMenuStyle() {
JTemplate jTemplate = getEditingComponent();
if (jTemplate.isJWorkBook()) {
this.setMenuKeySet(REPORT_FIT_ATTR);
} else {
this.setMenuKeySet(REPORT_FIT_ATTR_ELEMENTCASE);
}
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/reportfit/fit.png"));
}
/**
* Action触发事件
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
final JTemplate jwb = getEditingComponent();
if (jwb == null) {
return;
}
final FitProvider wbTpl = (FitProvider) jwb.getTarget();
ReportFitAttr fitAttr = wbTpl.getReportFitAttr();
if (jwb.isJWorkBook()) {
final TemplateFitAttrPane attrPane = new TemplateFitAttrPane();
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
} else {
final ReportFitAttrPane attrPane = new ReportFitAttrPane();
showReportFitDialog(fitAttr, jwb, wbTpl, attrPane);
}
}
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() {
@Override
public void doOk() {
wbTpl.setReportFitAttr(attrPane.updateBean());
jwb.fireTargetModified();
}
});
dialog.setSize(MEDIUM);
dialog.setVisible(true);
}
}

56
designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrPane.java

@ -0,0 +1,56 @@
package com.fr.design.report.fit.menupane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
/**
* Created by Administrator on 2015/7/6 0006.
*/
public class ReportFitAttrPane extends BasicBeanPane<ReportFitAttr> {
private BrowserFitAttrPane attrPane;
public ReportFitAttrPane() {
initComponents();
}
private void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
attrPane = new BrowserFitAttrPane();
this.add(attrPane);
}
/**
* 展示界面
*
* @param fitAttr 自适应属性
*/
public void populateBean(ReportFitAttr fitAttr) {
attrPane.populateBean(fitAttr);
}
/**
* 提交数据
*
* @return 界面上的更新数据
*/
public ReportFitAttr updateBean() {
return attrPane.updateBean();
}
/**
* 标题
*
* @return 标题
*/
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr");
}
}

85
designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateBrowserFitAttrPane.java

@ -0,0 +1,85 @@
package com.fr.design.report.fit.menupane;
import com.fr.config.Configuration;
import com.fr.design.gui.ilable.UILabel;
import com.fr.report.fit.ReportFitAttr;
import com.fr.report.fit.ReportFitConfig;
import com.fr.transaction.Configurations;
import com.fr.transaction.Worker;
import java.awt.Component;
/**
* Created by 夏翔 on 2016/6/24.
*/
public class TemplateBrowserFitAttrPane extends BrowserFitAttrPane {
public TemplateBrowserFitAttrPane() {
initComponents(ReportFitConfig.getInstance().getCptFitAttr());
}
@Override
protected Component[][] initFitComponents() {
Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Font")), fontFitRadio, null, fontNotFitRadio},
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Element")), horizonRadio, doubleRadio, notFitRadio}
};
return components;
}
@Override
public void populateBean(ReportFitAttr attr) {
//模板界面,自适应选项去掉了默认,这边的判断为了兼容之前的设置
if (attr != null && attr.fitStateInPC() == 0) {
attr.setFitStateInPC(3);
}
ReportFitAttr fitAttr = ReportFitConfig.getInstance().getCptFitAttr();
if (attr == null) {
//如果为空, 就用全局的
attr = fitAttr;
populateGlobalComponents();
} else if (fitAttr.fitStateInPC() == 0) {
attr = new ReportFitAttr();
attr.setFitStateInPC(3);
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local"));
} else {
initBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Local"));
}
this.localFitAttr = attr;
fontRadioGroup.selectFontFit((attr).isFitFont());
fitRadionGroup.selectIndexButton(attr.fitStateInPC());
fitPreviewPane.refreshPreview(getCurrentFitOptions(), fitRadionGroup.isEnabled());
}
@Override
public ReportFitAttr updateBean() {
ReportFitAttr attr = new ReportFitAttr();
attr.setFitFont(fontRadioGroup.isFontFit());
attr.setFitStateInPC(fitRadionGroup.getSelectRadioIndex());
// 直接用全局的
if (globalCheck.isSelected()) {
updateGlobalConfig(attr);
return null;
}
this.localFitAttr = attr;
return attr;
}
private void updateGlobalConfig(final ReportFitAttr attr) {
Configurations.update(new Worker() {
@Override
public void run() {
ReportFitConfig manager = ReportFitConfig.getInstance();
manager.setCptFitAttr(attr);
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ReportFitConfig.class};
}
});
}
}

55
designer-base/src/main/java/com/fr/design/report/fit/menupane/TemplateFitAttrPane.java

@ -0,0 +1,55 @@
package com.fr.design.report.fit.menupane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.report.fit.ReportFitAttr;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
/**
* Created by 夏翔 on 2016/6/24.
*/
public class TemplateFitAttrPane extends BasicBeanPane<ReportFitAttr> {
private TemplateBrowserFitAttrPane attrPane;
public TemplateFitAttrPane() {
initComponents();
}
private void initComponents() {
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
attrPane = new TemplateBrowserFitAttrPane();
this.add(attrPane);
}
/**
* 展示界面
*
* @param fitAttr 自适应属性
*/
public void populateBean(ReportFitAttr fitAttr) {
attrPane.populateBean(fitAttr);
}
/**
* 提交数据
*
* @return 界面上的更新数据
*/
public ReportFitAttr updateBean() {
return attrPane.updateBean();
}
/**
* 标题
*
* @return 标题
*/
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Fit-Attr");
}
}

4
designer-base/src/main/java/com/fr/design/style/color/ColorCell.java

@ -89,6 +89,10 @@ public class ColorCell extends JComponent implements ColorSelectable {
* @param 鼠标事件 * @param 鼠标事件
*/ */
public void processMouseEvent(MouseEvent e) { public void processMouseEvent(MouseEvent e) {
if (!isEnabled()) {
return;
}
if (e == null || e.getID() == MouseEvent.MOUSE_RELEASED) { if (e == null || e.getID() == MouseEvent.MOUSE_RELEASED) {
colorSelectable.setColor(this.getColor()); colorSelectable.setColor(this.getColor());
colorSelectable.colorSetted(this); colorSelectable.colorSetted(this);

3
designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java

@ -9,6 +9,7 @@ import java.util.regex.Pattern;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JColorChooser; import javax.swing.JColorChooser;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
@ -706,7 +707,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec
mainPanel.add(hexPanel, BorderLayout.SOUTH); mainPanel.add(hexPanel, BorderLayout.SOUTH);
JPanel rightPane = new JPanel(new BorderLayout()); JPanel rightPane = new JPanel(new BorderLayout());
SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true); JButton pickColorButton = PickColorButtonFactory.getPickColorButton(this, PickColorButtonFactory.IconType.ICON18, true);
JPanel blankArea = new JPanel(); JPanel blankArea = new JPanel();
blankArea.setPreferredSize(new Dimension(100, 175)); blankArea.setPreferredSize(new Dimension(100, 175));
rightPane.add(blankArea, BorderLayout.CENTER); rightPane.add(blankArea, BorderLayout.CENTER);

27
designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java

@ -8,11 +8,16 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import javax.swing.BorderFactory;
import javax.swing.*; import javax.swing.Box;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -31,8 +36,6 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
// color setting action. // color setting action.
private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>(); private ArrayList<ChangeListener> colorChangeListenerList = new ArrayList<ChangeListener>();
// 颜色选择器
private ColorSelectDetailPane pane;
// 是否支持透明 // 是否支持透明
private boolean isSupportTransparent; private boolean isSupportTransparent;
@ -52,10 +55,10 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
/** /**
* Constructor. * Constructor.
*/ */
public NewColorSelectPane(boolean isSupportTransparent) { NewColorSelectPane(boolean isSupportTransparent) {
this.isSupportTransparent = isSupportTransparent; this.isSupportTransparent = isSupportTransparent;
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5)); this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5));
if (isSupportTransparent) { if (isSupportTransparent) {
UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency"));
this.add(transpanrentButton, BorderLayout.NORTH); this.add(transpanrentButton, BorderLayout.NORTH);
@ -94,14 +97,19 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
centerPane.add(Box.createVerticalStrut(1)); centerPane.add(Box.createVerticalStrut(1));
// mod by anchore 16/11/16 // mod by anchore 16/11/16
UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color")); final UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color"));
// 不能使用 ActionListener,否则设计器工具栏中的"更多颜色"按钮会有问题(REPORT-13654)
customButton.addMouseListener(new MouseAdapter() { customButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (!customButton.isEnabled()) {
return;
}
customButtonPressed(); customButtonPressed();
} }
}); });
customButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); customButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel centerPane1 = FRGUIPaneFactory.createBorderLayout_S_Pane();
centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8)); centerPane1.setBorder(BorderFactory.createEmptyBorder(2, 8, 0, 8));
@ -183,7 +191,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable {
} }
protected void customButtonPressed() { protected void customButtonPressed() {
pane = new ColorSelectDetailPane(Color.WHITE); // 颜色选择器
ColorSelectDetailPane pane = new ColorSelectDetailPane(Color.WHITE);
ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this);
} }

41
designer-base/src/main/java/com/fr/design/style/color/PickColorButtonFactory.java

@ -2,28 +2,37 @@ package com.fr.design.style.color;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.SpecialUIButton; import com.fr.design.gui.ibutton.SpecialUIButton;
import com.fr.design.gui.ibutton.UIBasicButtonUI;
import javax.swing.*; import javax.swing.JButton;
import javax.swing.plaf.ButtonUI; import javax.swing.JComponent;
import java.awt.*; import java.awt.Color;
import java.awt.event.*; import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/** /**
* Created by plough on 2016/12/22. * Created by plough on 2016/12/22.
*/ */
public class PickColorButtonFactory { class PickColorButtonFactory {
private static int iconSize; private static int iconSize;
private static final int SIZE_16 = 16; private static final int SIZE_16 = 16;
private static final int SIZE_18 = 18; private static final int SIZE_18 = 18;
private static IconType iconType; private static IconType iconType;
private static Image iconImage; private static Image iconImage;
public static SpecialUIButton getPickColorButton(ColorSelectable colorSelectable, IconType iconType) { /**
return getPickColorButton(colorSelectable, iconType, false); * 生成取色按钮
} * @param colorSelectable 接收取到的颜色值的对象
* @param iconType IconType 枚举可选择 16px 18px 两个尺寸
public static SpecialUIButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final boolean setColorRealTime) { * @param setColorRealTime 是否在取色过程中实时更新颜色值
SpecialUIButton pickColorButton = new SpecialUIButton(new WhiteButtonUI()); * @return SpecialUIButton 屏幕取色按钮
*/
static JButton getPickColorButton(final ColorSelectable colorSelectable, IconType iconType, final boolean setColorRealTime) {
final SpecialUIButton pickColorButton = new SpecialUIButton(new WhiteButtonUI());
PickColorButtonFactory.iconType = iconType; PickColorButtonFactory.iconType = iconType;
if (iconType == IconType.ICON16) { if (iconType == IconType.ICON16) {
@ -37,9 +46,13 @@ public class PickColorButtonFactory {
pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize)); pickColorButton.setPreferredSize(new Dimension(iconSize, iconSize));
pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR)); pickColorButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
// 不能使用 ActionListener,否则设计器工具栏中的取色按钮会有问题(REPORT-13654)
pickColorButton.addMouseListener(new MouseAdapter() { pickColorButton.addMouseListener(new MouseAdapter() {
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (!pickColorButton.isEnabled()) {
return;
}
new ColorPicker(colorSelectable, setColorRealTime); new ColorPicker(colorSelectable, setColorRealTime);
} }
}); });
@ -47,12 +60,14 @@ public class PickColorButtonFactory {
return pickColorButton; return pickColorButton;
} }
// 取色器按钮使用的图标 /**
* 取色按钮可使用的图标尺寸
*/
public enum IconType { public enum IconType {
ICON16, ICON18 ICON16, ICON18
} }
private static class WhiteButtonUI extends ButtonUI { private static class WhiteButtonUI extends UIBasicButtonUI {
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
super.paint(g, c); super.paint(g, c);

2
designer-base/src/main/java/com/fr/design/style/color/UsedColorPane.java

@ -72,7 +72,7 @@ public class UsedColorPane extends BasicPane {
int i = 0; int i = 0;
if (needPickColorButton) { if (needPickColorButton) {
// 取色按钮 // 取色按钮
SpecialUIButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime); JButton pickColorButton = PickColorButtonFactory.getPickColorButton(selectable, PickColorButtonFactory.IconType.ICON16, setColorRealTime);
panel.add(pickColorButton); panel.add(pickColorButton);
i++; i++;
this.reserveCells += 1; this.reserveCells += 1;

12
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -65,12 +65,12 @@ public class DesignUtils {
* @return 启动了返回true * @return 启动了返回true
*/ */
public static boolean isStarted() { public static boolean isStarted() {
try { // try {
new Socket("localhost", port); // new Socket("localhost", port);
return true; // return true;
} catch (Exception exp) { // } catch (Exception exp) {
//
} // }
return false; return false;
} }

36
designer-base/src/main/java/com/fr/design/utils/gui/GUICoreUtils.java

@ -18,6 +18,8 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.EditTextField; import com.fr.design.gui.itextfield.EditTextField;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorCell;
import com.fr.design.style.color.ColorFactory; import com.fr.design.style.color.ColorFactory;
import com.fr.design.style.color.ColorSelectBox; import com.fr.design.style.color.ColorSelectBox;
@ -524,6 +526,18 @@ public abstract class GUICoreUtils{
return leftPane; return leftPane;
} }
/**
* 创建一个靠左流式布局流式内嵌
*
* @return JPanel对象
*/
public static JPanel createBoxFlowInnerContainerPane(int hgap, int vgap) {
JPanel jp = new JPanel();
jp.setLayout(new FlowLayout(FlowLayout.LEFT, hgap, vgap));
return jp;
}
/** /**
* 生成一个以流式布局为布局的面板 * 生成一个以流式布局为布局的面板
* @param comps 面板中的组件以及布局的参数后3位参数可选分别表示对齐方式水平间隙垂直间隙 * @param comps 面板中的组件以及布局的参数后3位参数可选分别表示对齐方式水平间隙垂直间隙
@ -891,4 +905,26 @@ public abstract class GUICoreUtils{
panel.add(dynamicPaneWrapper, BorderLayout.CENTER); panel.add(dynamicPaneWrapper, BorderLayout.CENTER);
return panel; return panel;
} }
/**
* 创建一个单列垂直布局的 TableLayout 面板
* @param comps 组件数组
* @return 布局完成后的面板
*/
public static JPanel createHeaderLayoutPane(Component... comps) {
// TableLayout
double p = TableLayout.PREFERRED;
double[] columnSize = {p};
double[] rowSize = new double[comps.length];
for (int i = 0; i < rowSize.length; i++) {
rowSize[i] = p;
}
Component[][] components = new Component[rowSize.length][columnSize.length];
for (int i = 0; i < rowSize.length; i++) {
components[i][0] = comps[i];
}
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10);
}
} }

629
designer-base/src/main/java/com/fr/design/web/CustomIconPane.java

@ -41,333 +41,337 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/** /**
*
* carl自定义Icon编辑 * carl自定义Icon编辑
*
*/ */
public class CustomIconPane extends BasicPane { public class CustomIconPane extends BasicPane {
private String selectedIconName = null; private String selectedIconName = null;
private ListMap iconButtonMap = null; private ListMap iconButtonMap = null;
private JPanel iconPane = null; private JPanel iconPane = null;
private ButtonGroup bg; private ButtonGroup bg;
private UIScrollPane jsPane; private UIScrollPane jsPane;
// 老一次次去拿真麻烦 // 老一次次去拿真麻烦
private IconManager iconManager = null; private IconManager iconManager = null;
private UIButton removeButton; private UIButton removeButton;
private UIButton editButton; private UIButton editButton;
private static final int THE_WIDTH = 180;
private static final int THE_WIDTH = 180; private static final int HORIZONTAL_COUNT = 6;
private static final int HORIZONTAL_COUNT = 6; private static final int HEIGHT_PER = 29;
private static final int HEIGHT_PER = 29; private static final int GAP = 10;
private static final int GAP = 10;
public CustomIconPane() {
public CustomIconPane() { this.initComponents();
this.initComponents(); }
}
private void initComponents() {
private void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); centerPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon")));
centerPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon"))); JPanel noNamePane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
JPanel noNamePane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); centerPane.add(noNamePane, BorderLayout.CENTER);
centerPane.add(noNamePane, BorderLayout.CENTER);
iconPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
iconPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
// 开始加图标选择按钮
// 开始加图标选择按钮 initIcons();
initIcons();
jsPane = new UIScrollPane(iconPane);
jsPane = new UIScrollPane(iconPane); refreshIconPane(false);
refreshIconPane(false); jsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jsPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
jsPane.setPreferredSize(new Dimension(200, 180));
jsPane.setPreferredSize(new Dimension(200,180)); noNamePane.add(jsPane);
noNamePane.add(jsPane);
DescriptionTextArea des = new DescriptionTextArea(2);
DescriptionTextArea des = new DescriptionTextArea(2); des.setText(createDescriptionText());
des.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1")); centerPane.add(des, BorderLayout.SOUTH);
centerPane.add(des, BorderLayout.SOUTH);
this.add(centerPane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER);
JPanel eastPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
JPanel eastPane = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane(); JPanel buttonPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
JPanel buttonPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(1);
// 增加、删除、编辑按钮
// 增加、删除、编辑按钮 initAddButton(buttonPane);
initAddButton(buttonPane); initRemoveButton(buttonPane);
initRemoveButton(buttonPane); initEditButton(buttonPane);
initEditButton(buttonPane);
eastPane.add(buttonPane);
eastPane.add(buttonPane); this.add(eastPane, BorderLayout.EAST);
this.add(eastPane, BorderLayout.EAST);
}
}
private void initIcons() { protected String createDescriptionText(){
iconButtonMap = new ListMap(); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1");
iconManager = WidgetInfoConfig.getInstance().getIconManager(); }
bg = new ButtonGroup();
Object[] names = iconManager.getIconNames(); private void initIcons() {
Object name = null; iconButtonMap = new ListMap();
for (int i = 0; i < names.length; i++) { iconManager = WidgetInfoConfig.getInstance().getIconManager();
name = names[i]; bg = new ButtonGroup();
if (name == null || !(name instanceof String)) { Object[] names = iconManager.getIconNames();
continue; Object name = null;
} for (int i = 0; i < names.length; i++) {
// carl:默认选第一个 name = names[i];
if (this.selectedIconName == null) { if (name == null || !(name instanceof String)) {
this.selectedIconName = (String)name; continue;
} }
IconButton iconButton = new IconButton((String)name); // carl:默认选第一个
iconButtonMap.put(name, iconButton); if (this.selectedIconName == null) {
iconPane.add(iconButton); this.selectedIconName = (String) name;
bg.add(iconButton); }
} IconButton iconButton = new IconButton((String) name);
} iconButtonMap.put(name, iconButton);
iconPane.add(iconButton);
private void initAddButton(JPanel buttonPane) { bg.add(iconButton);
UIButton addButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add")); }
addButton.setPreferredSize(new Dimension(80, 25)); }
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { private void initAddButton(JPanel buttonPane) {
final EditIconDialog add = new EditIconDialog(); UIButton addButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add"));
add.populate(null); addButton.setPreferredSize(new Dimension(80, 25));
add.showWindow(SwingUtilities.getWindowAncestor(CustomIconPane.this), new DialogActionAdapter() { addButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) {
public void doOk() { final EditIconDialog add = new EditIconDialog();
Icon icon = add.update(); add.populate(null);
if (iconManager.addIcon(icon, false)) { add.showWindow(SwingUtilities.getWindowAncestor(CustomIconPane.this), new DialogActionAdapter() {
IconButton iconButton = null;//初始化 @Override
public void doOk() {
addIcon(icon, iconButton); Icon icon = add.update();
if (iconManager.addIcon(icon, false)) {
}else { IconButton iconButton = null;//初始化
// add failed
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); addIcon(icon, iconButton);
}
} } else {
// add failed
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE);
}
}
}).setVisible(true); }).setVisible(true);
} }
}); });
buttonPane.add(addButton); buttonPane.add(addButton);
} }
private void initRemoveButton(JPanel buttonPane) { private void initRemoveButton(JPanel buttonPane) {
removeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove")); removeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));
removeButton.setPreferredSize(new Dimension(80, 25)); removeButton.setPreferredSize(new Dimension(80, 25));
removeButton.addActionListener(new ActionListener() { removeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (iconManager.isSystemIcon(selectedIconName)) { if (iconManager.isSystemIcon(selectedIconName)) {
return; return;
} }
if (iconManager.removeIcon(selectedIconName)) { if (iconManager.removeIcon(selectedIconName)) {
IconButton iconButton = (IconButton)iconButtonMap.get(selectedIconName); IconButton iconButton = (IconButton) iconButtonMap.get(selectedIconName);
iconPane.remove(iconButton); iconPane.remove(iconButton);
iconButtonMap.remove(selectedIconName); iconButtonMap.remove(selectedIconName);
bg.remove(iconButton); bg.remove(iconButton);
selectedIconName = ((IconButton)iconButtonMap.getByIndex(0)).iconName; selectedIconName = ((IconButton) iconButtonMap.getByIndex(0)).iconName;
refreshIconPane(false); refreshIconPane(false);
CustomIconPane.this.validate(); CustomIconPane.this.validate();
CustomIconPane.this.repaint(); CustomIconPane.this.repaint();
} else { } else {
// remove failed // remove failed
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
} }
} }
}); });
buttonPane.add(removeButton); buttonPane.add(removeButton);
} }
private void initEditButton(JPanel buttonPane) { private void initEditButton(JPanel buttonPane) {
editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
editButton.setPreferredSize(new Dimension(80, 25)); editButton.setPreferredSize(new Dimension(80, 25));
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (iconManager.isSystemIcon(selectedIconName)) { if (iconManager.isSystemIcon(selectedIconName)) {
return; return;
} }
Icon oldIcon = null; Icon oldIcon = null;
try { try {
oldIcon= iconManager.getIcon(selectedIconName); oldIcon = iconManager.getIcon(selectedIconName);
} catch (CloneNotSupportedException e1) { } catch (CloneNotSupportedException e1) {
// do nothing // do nothing
} }
if (oldIcon == null) { if (oldIcon == null) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
"Error", "Error",
"Error", "Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} }
final EditIconDialog edit = new EditIconDialog(); final EditIconDialog edit = new EditIconDialog();
edit.populate(oldIcon); edit.populate(oldIcon);
edit.showWindow(DesignerContext.getDesignerFrame(), new IconDialogActionListener(oldIcon) { edit.showWindow(DesignerContext.getDesignerFrame(), new IconDialogActionListener(oldIcon) {
@Override @Override
public void doOk() { public void doOk() {
iconManager.removeIcon(oldIcon.getName()); iconManager.removeIcon(oldIcon.getName());
Icon icon = edit.update(); Icon icon = edit.update();
if (iconManager.addIcon(icon, false)) { if (iconManager.addIcon(icon, false)) {
IconButton iconButton = (IconButton)iconButtonMap.get(oldIcon.getName()); IconButton iconButton = (IconButton) iconButtonMap.get(oldIcon.getName());
iconPane.remove(iconButton); iconPane.remove(iconButton);
bg.remove(iconButton); bg.remove(iconButton);
addIcon(icon, iconButton); addIcon(icon, iconButton);
} else { } else {
// 失败了再弄回去 // 失败了再弄回去
iconManager.addIcon(oldIcon, true); iconManager.addIcon(oldIcon, true);
// edit failed // edit failed
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message2"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.WARNING_MESSAGE);
} }
} }
}).setVisible(true); }).setVisible(true);
} }
}); });
buttonPane.add(editButton); buttonPane.add(editButton);
} }
private void updateButtonPane() { private void updateButtonPane() {
if (editButton == null || removeButton == null){ if (editButton == null || removeButton == null) {
return; return;
} }
if (iconManager.isSystemIcon(selectedIconName)) { if (iconManager.isSystemIcon(selectedIconName)) {
editButton.setEnabled(false); editButton.setEnabled(false);
removeButton.setEnabled(false); removeButton.setEnabled(false);
} else { } else {
editButton.setEnabled(true); editButton.setEnabled(true);
removeButton.setEnabled(true); removeButton.setEnabled(true);
} }
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon");
} }
/** /**
* 添加按钮 * 添加按钮
* *
* @param icon 图标 * @param icon 图标
* @param iconButton 按钮 * @param iconButton 按钮
*/ */
public void addIcon(Icon icon,IconButton iconButton){ public void addIcon(Icon icon, IconButton iconButton) {
selectedIconName = icon.getName(); selectedIconName = icon.getName();
iconButton = new IconButton(icon.getName()); iconButton = new IconButton(icon.getName());
iconButtonMap.put(icon.getName(), iconButton); iconButtonMap.put(icon.getName(), iconButton);
iconPane.add(iconButton); iconPane.add(iconButton);
bg.add(iconButton); bg.add(iconButton);
refreshIconPane(true); refreshIconPane(true);
CustomIconPane.this.validate(); CustomIconPane.this.validate();
CustomIconPane.this.repaint(); CustomIconPane.this.repaint();
} }
public static class IconDialogActionListener extends DialogActionAdapter { public static class IconDialogActionListener extends DialogActionAdapter {
protected Icon oldIcon; protected Icon oldIcon;
public IconDialogActionListener(Icon oldIcon) { public IconDialogActionListener(Icon oldIcon) {
this.oldIcon = oldIcon; this.oldIcon = oldIcon;
} }
} }
public void populate(String iconName) { public void populate(String iconName) {
if (iconName == null) { if (iconName == null) {
return; return;
} }
this.selectedIconName = iconName; this.selectedIconName = iconName;
updateButtonPane(); updateButtonPane();
this.repaint(); this.repaint();
} }
public String update() { public String update() {
//把图标信息入库 //把图标信息入库
Configurations.update(new WorkerFacade(WidgetInfoConfig.class) { Configurations.update(new WorkerFacade(WidgetInfoConfig.class) {
@Override @Override
public void run() { public void run() {
WidgetInfoConfig.getInstance().setIconManager(IconManager.getIconManager()); WidgetInfoConfig.getInstance().setIconManager(IconManager.getIconManager());
} }
}); });
return selectedIconName;
} return selectedIconName;
}
// 不知道怎么动态布局,就这么傻傻的调一下大小
private void refreshIconPane(boolean down) { // 不知道怎么动态布局,就这么傻傻的调一下大小
iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); private void refreshIconPane(boolean down) {
UIScrollBar jsBar = jsPane.createVerticalScrollBar(); iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP));
try { UIScrollBar jsBar = jsPane.createVerticalScrollBar();
if (down) { try {
// 将滚动条滚到最后 if (down) {
jsBar.setValue(jsBar.getMaximum() - jsBar.getVisibleAmount()); // 将滚动条滚到最后
} else { jsBar.setValue(jsBar.getMaximum() - jsBar.getVisibleAmount());
jsBar.setValue(0); } else {
} jsBar.setValue(0);
} catch (RuntimeException re) { }
} catch (RuntimeException re) {
return; return;
} }
updateButtonPane(); updateButtonPane();
} }
private class IconButton extends JToggleButton implements ActionListener{ private class IconButton extends JToggleButton implements ActionListener {
private String iconName; private String iconName;
private Image iconImage = null; private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 24; private static final int ICON_BUTTON_SIZE = 24;
private static final int ICON_X = 4; private static final int ICON_X = 4;
private static final int ICON_Y = 4; private static final int ICON_Y = 4;
public IconButton(String name) {
this.iconName = name; public IconButton(String name) {
this.addActionListener(this); this.iconName = name;
this.addActionListener(this);
this.setCursor(new Cursor(Cursor.HAND_CURSOR)); this.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.setBorder(null); this.setBorder(null);
this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name); this.iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(name);
this.setToolTipText(iconName); this.setToolTipText(iconName);
} }
@Override @Override
public void updateUI() { public void updateUI() {
setUI(new BasicButtonUI(){ setUI(new BasicButtonUI() {
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
super.paint(g, c); super.paint(g, c);
} }
}); });
} }
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16 // carl:这里缩放显示 16 × 16
if (iconImage != null) { if (iconImage != null) {
g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
} }
if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) { if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) {
g2d.setPaint(Color.RED); g2d.setPaint(Color.RED);
} else { } else {
g2d.setPaint(Color.LIGHT_GRAY); g2d.setPaint(Color.LIGHT_GRAY);
} }
GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, IconManager.DEFAULT_ICONWIDTH + 7, GraphHelper.draw(g2d, new Rectangle2D.Double(0, 0, IconManager.DEFAULT_ICONWIDTH + 7,
IconManager.DEFAULT_ICONHEIGHT + 7), Constants.LINE_THICK); IconManager.DEFAULT_ICONHEIGHT + 7), Constants.LINE_THICK);
} }
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE); return new Dimension(ICON_BUTTON_SIZE, ICON_BUTTON_SIZE);
} }
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
CustomIconPane.this.selectedIconName = iconName; CustomIconPane.this.selectedIconName = iconName;
fireChagneListener(); fireChagneListener();
updateButtonPane(); updateButtonPane();
CustomIconPane.this.repaint();// repaint CustomIconPane.this.repaint();// repaint
} }
@Override @Override
public void addChangeListener(ChangeListener changeListener) { public void addChangeListener(ChangeListener changeListener) {
this.changeListener = changeListener; this.changeListener = changeListener;
} }
@ -377,18 +381,18 @@ public class CustomIconPane extends BasicPane {
this.changeListener.stateChanged(evt); this.changeListener.stateChanged(evt);
} }
} }
} }
private static class EditIconDialog extends BasicPane { private static class EditIconDialog extends BasicPane {
private UITextField nameTextField; private UITextField nameTextField;
private UILabel showImageLabel; private UILabel showImageLabel;
private Image iconImage = null; private Image iconImage = null;
private String oldName = null; private String oldName = null;
protected EditIconDialog() { protected EditIconDialog() {
init(); init();
} }
private void init() { private void init() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -402,16 +406,17 @@ public class CustomIconPane extends BasicPane {
nameTextField = new UITextField(20); nameTextField = new UITextField(20);
browseButton.addActionListener(new ActionListener() { browseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
onBrowseButtonClicked(); onBrowseButtonClicked();
} }
}); });
// 焦点丢失时看看名称是否已经存在 // 焦点丢失时看看名称是否已经存在
nameTextField.addFocusListener(new FocusListener() { nameTextField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// do nothing // do nothing
} }
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) {
return; return;
@ -428,7 +433,7 @@ public class CustomIconPane extends BasicPane {
JPanel imagePane = new JPanel(); JPanel imagePane = new JPanel();
imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0)); imagePane.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 0));
showImageLabel = new UILabel(); showImageLabel = new UILabel();
showImageLabel.setPreferredSize(new Dimension(20,20)); showImageLabel.setPreferredSize(new Dimension(20, 20));
imagePane.add(showImageLabel); imagePane.add(showImageLabel);
imagePane.add(browseButton); imagePane.add(browseButton);
Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}}; Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Name") + ":"), nameTextField}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Icon") + ":"), imagePane}};
@ -448,7 +453,7 @@ public class CustomIconPane extends BasicPane {
// 将图片转化到16 × 16大小 // 将图片转化到16 × 16大小
Image image = BaseUtils.readImage(path); Image image = BaseUtils.readImage(path);
BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH, BufferedImage bufferedImage = CoreGraphHelper.createBufferedImage(IconManager.DEFAULT_ICONWIDTH,
IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB); IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = bufferedImage.createGraphics(); Graphics2D g2d = bufferedImage.createGraphics();
g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); g2d.drawImage(image, 0, 0, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
bufferedImage.flush(); bufferedImage.flush();
@ -461,29 +466,29 @@ IconManager.DEFAULT_ICONHEIGHT, BufferedImage.TYPE_INT_ARGB);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Add_Icon"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Add_Icon");
} }
// 用户自定义的只有name 和 imgae两属性, path不要去管 // 用户自定义的只有name 和 imgae两属性, path不要去管
public void populate(Icon icon) { public void populate(Icon icon) {
if (icon == null) { if (icon == null) {
return; return;
} }
oldName = icon.getName(); oldName = icon.getName();
nameTextField.setText(icon.getName()); nameTextField.setText(icon.getName());
if (icon.getImage() != null) { if (icon.getImage() != null) {
showImageLabel.setIcon(new ImageIcon(icon.getImage())); showImageLabel.setIcon(new ImageIcon(icon.getImage()));
} }
iconImage = icon.getImage(); iconImage = icon.getImage();
} }
public Icon update() { public Icon update() {
// 有一个是空,都返回null,反正不会添加的 // 有一个是空,都返回null,反正不会添加的
if (StringUtils.isBlank(nameTextField.getText()) || iconImage == null) { if (StringUtils.isBlank(nameTextField.getText()) || iconImage == null) {
return null; return null;
} }
return new Icon(nameTextField.getText(), iconImage); return new Icon(nameTextField.getText(), iconImage);
} }
} }
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save