Browse Source

Merge pull request #1065 in DESIGN/design from feature/10.0 to refactor/19.4.3

* commit '5108f6b3538990fa7427f62fc5813aa27beaae52': (103 commits)
  REPORT-20318 sonar问题修复-zack
  无JIRA任务 标记开放类
  无JIRA任务 sonar问题修复
  无JIRA任务 标记开放类
  无JIRA任务 标记开放类
  REPORT-20329 sonar问题修复
  MOBILE-21673 & MOBILE-21669 把移动端组件默认背景改为Backgroud类型,同时tilteBorder颜色改为视觉要求颜色
  REPORT-19466 【匹配移动端】组件级控制选中等
  sonar问题修复,无jira任务
  REPORT-20322 sonar问题修复,无jira任务
  REPORT-21203 去掉多余的实现接口
  REPORT-21203 【水印密度】水印密度框输入特殊符号--,输入小数应该不让允许
  无jira任务,sonar问题修复
  报表REPORT-20320 sonar问题修复
  REPORT-20328 sonar
  REPORT-20323 sonar问题修复
  无jira任务,sonar问题修复
  无jira任务 sonar问题修复
  REPORT-19466 【匹配移动端】组件级控制选中等
  REPORT-20320 sonar问题修复
  ...
research/11.0
zheng 5 years ago
parent
commit
d7333bb439
  1. 19
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 11
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 24
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  4. 11
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  5. 5
      designer-base/src/main/java/com/fr/design/actions/edit/CutAction.java
  6. 6
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineAction.java
  7. 79
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  8. 21
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  9. 26
      designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java
  10. 6
      designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java
  11. 3
      designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java
  12. 2
      designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java
  13. 39
      designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java
  14. 163
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  15. 8
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  16. 58
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java
  17. 193
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java
  18. 6
      designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java
  19. 19
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  20. 3
      designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java
  21. 7
      designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java
  22. 8
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  23. 2
      designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java
  24. 48
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  25. 2
      designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java
  26. 16
      designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java
  27. 16
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  28. 36
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  29. 20
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  30. 6
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  31. 5
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java
  32. 15
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  33. 10
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  34. 1
      designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java
  35. 8
      designer-base/src/main/java/com/fr/design/formula/VariableResolverAdapter.java
  36. 24
      designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java
  37. 20
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java
  38. 3
      designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java
  39. 3
      designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java
  40. 4
      designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
  41. 2
      designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java
  42. 4
      designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java
  43. 10
      designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java
  44. 1
      designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java
  45. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  46. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  47. 1
      designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java
  48. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java
  49. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java
  50. 4
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  51. 2
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java
  52. 1
      designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java
  53. 1
      designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java
  54. 12
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java
  55. 51
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  56. 27
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  57. 5
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  58. 6
      designer-base/src/main/java/com/fr/design/gui/ilable/MultilineLabel.java
  59. 4
      designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java
  60. 14
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java
  61. 31
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  62. 31
      designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java
  63. 2
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java
  64. 3
      designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  65. 77
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java
  66. 25
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/JFileTree.java
  67. 2
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  68. 1
      designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java
  69. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/CodeTemplateManager.java
  70. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java
  71. 404
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java
  72. 369
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java
  73. 229
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
  74. 38
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
  75. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java
  76. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java
  77. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java
  78. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java
  79. 10
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java
  80. 6
      designer-base/src/main/java/com/fr/design/icon/LockIcon.java
  81. 1
      designer-base/src/main/java/com/fr/design/icon/WarningIcon.java
  82. 12
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  83. 6
      designer-base/src/main/java/com/fr/design/layout/TableLayout.java
  84. 18
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  85. 39
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileStyleCustomDefinePane.java
  86. 30
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DefaultMobileWidgetStyleProvider.java
  87. 22
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleCustomDefinePane.java
  88. 122
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  89. 136
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStylePane.java
  90. 22
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TabIconConfigPane.java
  91. 123
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java
  92. 18
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java
  93. 8
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  94. 7
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java
  95. 36
      designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleMobileStyleEditor.java
  96. 26
      designer-base/src/main/java/com/fr/design/mainframe/widget/wrappers/MobileStyleWrapper.java
  97. 21
      designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java
  98. 4
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  99. 70
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  100. 10
      designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -149,7 +149,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/** /**
* alphafine * alphafine
*/ */
private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance();
private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance();
@ -263,6 +263,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
Thread.sleep(5000); Thread.sleep(5000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("Map Save Error"); FineLoggerFactory.getLogger().error("Map Save Error");
Thread.currentThread().interrupt();
} }
} }
} }
@ -315,8 +316,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
private void createEnvFile(File envFile) { private void createEnvFile(File envFile) {
FileWriter fileWriter = null;
try { try {
FileWriter fileWriter = new FileWriter(envFile); fileWriter = new FileWriter(envFile);
File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml"); File oldEnvFile = new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "6-1" + "Env.xml");
File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName()); File envFile80 = new File(getEnvHome(VERSION_80) + File.separator + getEnvFile().getName());
if (oldEnvFile.exists()) { if (oldEnvFile.exists()) {
@ -332,11 +334,19 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
Utils.copyCharTo(stringReader, fileWriter); Utils.copyCharTo(stringReader, fileWriter);
stringReader.close(); stringReader.close();
} }
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if (null != fileWriter) {
try {
fileWriter.close(); fileWriter.close();
} catch (IOException e) { } catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
}
}
private static String getEnvHome(String version) { private static String getEnvHome(String version) {
String userHome = System.getProperty("user.home"); String userHome = System.getProperty("user.home");
@ -649,9 +659,6 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
*/ */
public void saveXMLFile() { public void saveXMLFile() {
File xmlFile = this.getDesignerEnvFile(); File xmlFile = this.getDesignerEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录. if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile()); StableUtils.mkdirs(xmlFile.getParentFile());
} }
@ -1514,7 +1521,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
} }
private void readAlphaFineAttr(XMLableReader reader) { private void readAlphaFineAttr(XMLableReader reader) {
reader.readXMLObject(this.alphaFineConfigManager = new AlphaFineConfigManager()); reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance());
} }
private void readHttpsParas(XMLableReader reader) { private void readHttpsParas(XMLableReader reader) {

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

@ -102,11 +102,7 @@ public class EnvChangeEntrance {
return false; return false;
} }
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
@ -119,6 +115,11 @@ public class EnvChangeEntrance {
} }
} }
}); });
//REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
} catch (WorkspaceAuthException | RegistEditionException e) { } catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");

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

@ -5,19 +5,16 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.fun.*;
import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.fun.ParameterWidgetOptionProvider;
import com.fr.design.fun.ServerTableDataDefineProvider;
import com.fr.design.fun.TableDataDefineProvider;
import com.fr.design.fun.ToolbarItemProvider;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.core.WidgetOptionFactory; import com.fr.design.gui.core.WidgetOptionFactory;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.widget.Appearance; import com.fr.design.widget.Appearance;
import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.design.widget.mobile.WidgetMobilePane;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.plugin.AbstractExtraClassManager; import com.fr.plugin.AbstractExtraClassManager;
import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.injectable.PluginModule;
@ -38,6 +35,7 @@ import java.util.Set;
* @since : 8.0 * @since : 8.0
* 用于设计器扩展的管理类 * 用于设计器扩展的管理类
*/ */
@Open
public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider { public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider {
private static ExtraDesignClassManager classManager = new ExtraDesignClassManager(); private static ExtraDesignClassManager classManager = new ExtraDesignClassManager();
@ -207,6 +205,20 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement
return map; return map;
} }
public MobileWidgetStyleProvider[] getMobileStyleOfWidget(String xType) {
Set<MobileWidgetStyleProvider> set = getArray(MobileWidgetStyleProvider.XML_TAG);
if (set.isEmpty()) {
return new MobileWidgetStyleProvider[0];
}
List<MobileWidgetStyleProvider> providers = new ArrayList<>();
for (MobileWidgetStyleProvider provider: set) {
if(ComparatorUtils.equalsIgnoreCase(provider.xTypeForWidget(), xType)) {
providers.add(provider);
}
}
return providers.toArray(new MobileWidgetStyleProvider[providers.size()]);
}
@Override @Override
protected boolean demountSpecific(PluginSingleInjection injection) { protected boolean demountSpecific(PluginSingleInjection injection) {

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

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

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

@ -7,6 +7,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.actions.TemplateComponentAction; import com.fr.design.actions.TemplateComponentAction;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
import com.fr.general.IOUtils;
import javax.swing.KeyStroke; import javax.swing.KeyStroke;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -25,13 +26,13 @@ public class CutAction extends TemplateComponentAction {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut")); this.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(IOUtils.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()); this.setEnabled(!DesignModeContext.isBanCopyAndCut());
} }
@Override @Override
public boolean executeActionReturnUndoRecordNeeded() { public boolean executeActionReturnUndoRecordNeeded() {
return DesignModeContext.doPaste(getEditingComponent()); return DesignModeContext.doCut(getEditingComponent());
} }
} }

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

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

79
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -1,19 +1,29 @@
package com.fr.design.actions.help.alphafine; package com.fr.design.actions.help.alphafine;
import com.fr.general.ComparatorUtils;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import org.jetbrains.annotations.NotNull;
import javax.swing.*; import javax.swing.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/** /**
* Created by XiaXiang on 2017/4/5. * AlphaFine配置类
*
* @author XiaXiang
* @date 2017/4/5
*/ */
public class AlphaFineConfigManager implements XMLable { public class AlphaFineConfigManager implements XMLable {
private static final long serialVersionUID = -8170289826729582122L;
private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager();
/** /**
* 是否开启alphafine * 是否开启alphafine
@ -71,11 +81,18 @@ public class AlphaFineConfigManager implements XMLable {
* 是否提醒 * 是否提醒
*/ */
private boolean needRemind = true; private boolean needRemind = true;
private Map<String, String> actionSearchTextCache = new HashMap<>(8);
private String cacheBuildNO;
/** /**
* 直接操作菜单次数 * 直接操作菜单次数
*/ */
private int operateCount; private int operateCount;
private AlphaFineConfigManager() {
}
public static AlphaFineConfigManager getInstance() { public static AlphaFineConfigManager getInstance() {
return alphaFineConfigManager; return alphaFineConfigManager;
} }
@ -87,8 +104,7 @@ public class AlphaFineConfigManager implements XMLable {
@Override @Override
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
AlphaFineConfigManager manager = (AlphaFineConfigManager) super.clone(); return super.clone();
return manager;
} }
@Override @Override
@ -107,10 +123,34 @@ public class AlphaFineConfigManager implements XMLable {
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts())); this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true)); this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0)); this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
} else if (reader.isChildNode()) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
readActionSearchTextCacheXML(reader);
}
}
}
/**
* 读出搜索缓存
*/
private void readActionSearchTextCacheXML(XMLableReader reader) {
reader.readXMLObject(new XMLReadable() {
@Override
public void readXML(XMLableReader reader) {
if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) {
setCacheBuildNO(reader.getAttrAsString("buildNO", ""));
} else if (ComparatorUtils.equals(reader.getTagName(), "item")) {
String tmpVal = reader.getElementValue();
if (tmpVal != null) {
actionSearchTextCache.put(reader.getAttrAsString("key", ""), tmpVal);
} else {
actionSearchTextCache.put(reader.getAttrAsString("key", ""), StringUtils.EMPTY);
} }
} }
}
});
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
@ -128,6 +168,18 @@ public class AlphaFineConfigManager implements XMLable {
.attr("operateCount", this.getOperateCount()) .attr("operateCount", this.getOperateCount())
.attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox()) .attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()); .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService());
writeActionSearchTextCacheXML(writer);
writer.end();
}
/**
* 写入搜索缓存
*/
private void writeActionSearchTextCacheXML(XMLPrintWriter writer) {
writer.startTAG("ActionSearchTextCache").attr("buildNO", cacheBuildNO);
for (Map.Entry<String, String> item : actionSearchTextCache.entrySet()) {
writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue()).end();
}
writer.end(); writer.end();
} }
@ -262,4 +314,25 @@ public class AlphaFineConfigManager implements XMLable {
public void setOperateCount(int operateCount) { public void setOperateCount(int operateCount) {
this.operateCount = operateCount; this.operateCount = operateCount;
} }
@NotNull
public Map<String, String> getActionSearchTextCache() {
return Collections.unmodifiableMap(actionSearchTextCache);
}
public void setActionSearchTextCache(@NotNull String key, @NotNull String value) {
this.actionSearchTextCache.put(key, value);
}
@NotNull
public String getCacheBuildNO() {
if (cacheBuildNO == null) {
return StringUtils.EMPTY;
}
return cacheBuildNO;
}
public void setCacheBuildNO(@NotNull String cacheBuildNO) {
this.cacheBuildNO = cacheBuildNO;
}
} }

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

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

26
designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java

@ -1,24 +1,27 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
/** @Open
* Update Pane
*/
public abstract class BasicBeanPane<T> extends BasicPane { public abstract class BasicBeanPane<T> extends BasicPane {
/** /**
* Populate. * 展示数据
* @param ob 待展示的对象
*/ */
public abstract void populateBean(T ob); public abstract void populateBean(T ob);
/** /**
* Update. * 保存数据
* @return 待保存的对象
*/ */
public abstract T updateBean(); public abstract T updateBean();
/**
* 保存数据
* @param ob 待保存的对象
*/
public void updateBean(T ob) { public void updateBean(T ob) {
} }
@ -29,13 +32,4 @@ public abstract class BasicBeanPane<T> extends BasicPane {
public void populateAuthority() { public void populateAuthority() {
} }
/**
* 仅用来处理图表设计器的地图面板
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
}
} }

6
designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java

@ -1,11 +1,9 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** @Open
* @author zhou
* @since 2012-5-30下午12:12:42
*/
public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> { public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> {
/** /**
* 是否是指定类型 * 是否是指定类型

3
designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java

@ -1,10 +1,13 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
/** /**
* @author richie * @author richie
* @date 2015-03-26 * @date 2015-03-26
* @since 8.0 * @since 8.0
*/ */
@Open
public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> { public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> {
protected HighLightConditionAction hightLighAttrUpdateAction = null; protected HighLightConditionAction hightLighAttrUpdateAction = null;
private ConditionAttributesPane conditionAttributesPane; private ConditionAttributesPane conditionAttributesPane;

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

@ -1,6 +1,7 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
@ -17,6 +18,7 @@ import java.awt.Dimension;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@Open
public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> { public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
private static final int MIN_HEIGHT = 60; private static final int MIN_HEIGHT = 60;
protected CellHighlightAddMenuDef menuDef; protected CellHighlightAddMenuDef menuDef;

39
designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java

@ -0,0 +1,39 @@
package com.fr.design.constants;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Null;
/**
* 设计器启动事件类型
*
* @author vito
* @date 2019-06-18
*/
public enum DesignerLaunchStatus implements Event<Null> {
/**
* 初始化环境完成
*/
WORKSPACE_INIT_COMPLETE,
/**
* 设计器模块启动完成
*/
DESIGNER_INIT_COMPLETE,
/**
* 启动完成
*/
OPEN_LAST_FILE_COMPLETE;
private static DesignerLaunchStatus status;
public static DesignerLaunchStatus getStatus() {
return status;
}
public static void setStatus(DesignerLaunchStatus state) {
status = state;
EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus());
}
}

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

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

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

@ -46,6 +46,7 @@ import java.awt.event.KeyEvent;
import java.util.EventObject; import java.util.EventObject;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* Coder: zack * Coder: zack
@ -70,6 +71,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
* *
* @return 返回位置 * @return 返回位置
*/ */
@Override
public Location preferredLocation() { public Location preferredLocation() {
return Location.WEST_ABOVE; return Location.WEST_ABOVE;
} }
@ -97,6 +99,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
/** /**
* 响应数据集改变 * 响应数据集改变
*/ */
@Override
public void fireDSChanged() { public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>()); fireDSChanged(new HashMap<String, String>());
} }
@ -107,6 +110,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
* *
* @param map 数据集变化Map * @param map 数据集变化Map
*/ */
@Override
public void fireDSChanged(Map<String, String> map) { public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map); DesignTableDataManager.fireDSChanged(map);
} }
@ -151,6 +155,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
public abstract TableDataTree getDataTree(); public abstract TableDataTree getDataTree();
@Override
public abstract void refreshDockingView(); public abstract void refreshDockingView();
protected void checkButtonEnabled(UpdateAction editAction, UpdateAction previewTableDataAction, UpdateAction removeAction, TableDataSourceOP op, TableDataTree dataTree) { protected void checkButtonEnabled(UpdateAction editAction, UpdateAction previewTableDataAction, UpdateAction removeAction, TableDataSourceOP op, TableDataTree dataTree) {
@ -320,6 +325,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
this.setSmallIcon(this.getTDIcon()); this.setSmallIcon(this.getTDIcon());
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
dgEdit(getTableDataInstance().creatTableDataPane(), createDsName(getNamePrefix()), false); dgEdit(getTableDataInstance().creatTableDataPane(), createDsName(getNamePrefix()), false);
} }
@ -400,7 +406,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
data = selectedNO.getObject(); data = selectedNO.getObject();
} }
try { try {
if (((TableDataWrapper) data).getTableData() instanceof StoreProcedure) { if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof StoreProcedure) {
((StoreProcedure) (((TableDataWrapper) data).getTableData())).resetDataModelList(); ((StoreProcedure) (((TableDataWrapper) data).getTableData())).resetDataModelList();
if (data instanceof StoreProcedureDataWrapper) { if (data instanceof StoreProcedureDataWrapper) {
StoreProcedureDataWrapper oldSdw = ((StoreProcedureDataWrapper) data); StoreProcedureDataWrapper oldSdw = ((StoreProcedureDataWrapper) data);

58
designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java

@ -56,14 +56,18 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
return DesignTableDataManager.getEditingDataSet(tc.getBook()); return DesignTableDataManager.getEditingDataSet(tc.getBook());
} }
List<Map<String, TableDataWrapper>> empty = new ArrayList<Map<String, TableDataWrapper>>(); List<Map<String, TableDataWrapper>> empty = new ArrayList<Map<String, TableDataWrapper>>();
empty.add(Collections.<String, TableDataWrapper>emptyMap());//数据集 //数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());//服务器数据集 empty.add(Collections.<String, TableDataWrapper>emptyMap());
empty.add(Collections.<String, TableDataWrapper>emptyMap());//存储过程 //服务器数据集
empty.add(Collections.<String, TableDataWrapper>emptyMap());
//存储过程
empty.add(Collections.<String, TableDataWrapper>emptyMap());
return empty; return empty;
} }
/** /**
* ButtonEnabled intercept * ButtonEnabled intercept
*
* @return interceptbuttonEnabled * @return interceptbuttonEnabled
*/ */
@Override @Override
@ -73,8 +77,10 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
/** /**
* 移除名字是name的TableData * 移除名字是name的TableData
*
* @param name tabledata name * @param name tabledata name
*/ */
@Override
public void removeAction(String name) { public void removeAction(String name) {
if (tc != null) { if (tc != null) {
TableDataSource tds = tc.getBook(); TableDataSource tds = tc.getBook();
@ -85,7 +91,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
} }
protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, TableDataWrapper> map) { protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, TableDataWrapper> map) {
List<ExpandMutableTreeNode> dataList = new ArrayList<ExpandMutableTreeNode>(); List<ExpandMutableTreeNode> dataList = new ArrayList<>();
Iterator<Entry<String, TableDataWrapper>> entryIt = map.entrySet().iterator(); Iterator<Entry<String, TableDataWrapper>> entryIt = map.entrySet().iterator();
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
Entry<String, TableDataWrapper> entry = entryIt.next(); Entry<String, TableDataWrapper> entry = entryIt.next();
@ -96,7 +102,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
dataList.add(newChildTreeNode); dataList.add(newChildTreeNode);
newChildTreeNode.add(new ExpandMutableTreeNode()); newChildTreeNode.add(new ExpandMutableTreeNode());
} }
return dataList.toArray(new ExpandMutableTreeNode[dataList.size()]); return dataList.toArray(new ExpandMutableTreeNode[0]);
} }
private ExpandMutableTreeNode initTemplateDataNode(Map<String, TableDataWrapper> templateDataMap) { private ExpandMutableTreeNode initTemplateDataNode(Map<String, TableDataWrapper> templateDataMap) {
@ -124,22 +130,20 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
*/ */
@Override @Override
public ExpandMutableTreeNode[] load() { public ExpandMutableTreeNode[] load() {
Map<String, TableDataWrapper> templateDataMap = null; Map<String, TableDataWrapper> templateDataMap;
Map<String, TableDataWrapper> serverDataMap = null; Map<String, TableDataWrapper> serverDataMap;
Map<String, TableDataWrapper> storeProcedureMap = null; Map<String, TableDataWrapper> storeProcedureMap;
if (this != null) {
templateDataMap = this.init().get(0); templateDataMap = this.init().get(0);
serverDataMap = this.init().get(1); serverDataMap = this.init().get(1);
storeProcedureMap = this.init().get(2); storeProcedureMap = this.init().get(2);
} else {
templateDataMap = Collections.emptyMap(); //所有的数据集
serverDataMap = Collections.emptyMap(); List<ExpandMutableTreeNode> list = new ArrayList<>();
storeProcedureMap = Collections.emptyMap(); //模板数据集
} List<ExpandMutableTreeNode> templist = new ArrayList<>();
List<ExpandMutableTreeNode> list = new ArrayList<ExpandMutableTreeNode>(); //所有的数据集 //服务器数据集
List<ExpandMutableTreeNode> templist = new ArrayList<ExpandMutableTreeNode>(); //模板数据集 List<ExpandMutableTreeNode> serverlist = new ArrayList<>();
List<ExpandMutableTreeNode> serverlist = new ArrayList<ExpandMutableTreeNode>(); //服务器数据集
list.add(initTemplateDataNode(templateDataMap)); list.add(initTemplateDataNode(templateDataMap));
addNodeToList(templateDataMap, templist); addNodeToList(templateDataMap, templist);
@ -160,11 +164,11 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
} }
switch (dataMode) { switch (dataMode) {
case TEMPLATE_TABLE_DATA: case TEMPLATE_TABLE_DATA:
return templist.toArray(new ExpandMutableTreeNode[templist.size()]); return templist.toArray(new ExpandMutableTreeNode[0]);
case SERVER_TABLE_DATA: case SERVER_TABLE_DATA:
return serverlist.toArray(new ExpandMutableTreeNode[serverlist.size()]); return serverlist.toArray(new ExpandMutableTreeNode[0]);
default: default:
return list.toArray(new ExpandMutableTreeNode[list.size()]); return list.toArray(new ExpandMutableTreeNode[0]);
} }
} }
@ -182,7 +186,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
} }
protected void setStoreProcedureTree(TableData tableData, ExpandMutableTreeNode tmpNode) { protected void setStoreProcedureTree(TableData tableData, ExpandMutableTreeNode tmpNode) {
ArrayList<String> nodeName = new ArrayList<String>(); ArrayList<String> nodeName = new ArrayList<>();
StoreProcedure storeProcedure = (StoreProcedure) tableData; StoreProcedure storeProcedure = (StoreProcedure) tableData;
String name = ((NameObject) tmpNode.getUserObject()).getName(); String name = ((NameObject) tmpNode.getUserObject()).getName();
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters()); StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
@ -208,13 +212,13 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
} }
if (!resultNames.isEmpty()) { if (!resultNames.isEmpty()) {
for (int i = 0; i < resultNames.size(); i++) { for (String resultName : resultNames) {
if (!nodeName.contains(resultNames.get(i))) { if (!nodeName.contains(resultName)) {
nodeName.add(resultNames.get(i)); nodeName.add(resultName);
hasChild = true; hasChild = true;
String parameterName = name + "_" + resultNames.get(i); String parameterName = name + "_" + resultName;
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false); TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultNames.get(i), newTwd)); ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultName, newTwd));
newChildNode.add(new ExpandMutableTreeNode()); newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode); tmpNode.add(newChildNode);
} }
@ -230,7 +234,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
public void setDataMode(int i) { public void setDataMode(int i) {
this.dataMode = i; dataMode = i;
} }
public int getDataMode() { public int getDataMode() {

193
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java

@ -76,6 +76,7 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class FileTableDataPane extends AbstractTableDataPane<FileTableData> { public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private static final int TEXT = 0; private static final int TEXT = 0;
@ -126,12 +127,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private static final int GAP = 23; private static final int GAP = 23;
public FileTableDataPane(){ public FileTableDataPane() {
this(SETPANELWIDTH,WIDTH,HEIGHT,GAP); this(SETPANELWIDTH, WIDTH, HEIGHT, GAP);
} }
public FileTableDataPane(int setPanelWidth,int width,int height,int gap) { public FileTableDataPane(int setPanelWidth, int width, int height, int gap) {
this.setLayout(new BorderLayout(gap,0)); this.setLayout(new BorderLayout(gap, 0));
JPanel northPanel = new JPanel(new BorderLayout()); JPanel northPanel = new JPanel(new BorderLayout());
JPanel type = new JPanel(); JPanel type = new JPanel();
type.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_File_Type") + ":")); type.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_File_Type") + ":"));
@ -163,16 +164,16 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
southPanel.add(setPanel, BorderLayout.CENTER); southPanel.add(setPanel, BorderLayout.CENTER);
setPanel.setPreferredSize(new Dimension(setPanelWidth, 460)); setPanel.setPreferredSize(new Dimension(setPanelWidth, 460));
setPanel.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"))); setPanel.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")));
JPanel controlPane = textSetPanel(width,height); JPanel controlPane = textSetPanel(width, height);
setPanel.add(controlPane, BorderLayout.NORTH); setPanel.add(controlPane, BorderLayout.NORTH);
fileTypeComboBox.addActionListener(getFileTypeListener(setPanel,width,height)); fileTypeComboBox.addActionListener(getFileTypeListener(setPanel, width, height));
this.add(northPanel, BorderLayout.NORTH); this.add(northPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER); this.add(centerPanel, BorderLayout.CENTER);
this.add(southPanel, BorderLayout.EAST); this.add(southPanel, BorderLayout.EAST);
} }
private void addToCenterPanel(JPanel centerPanel){ private void addToCenterPanel(JPanel centerPanel) {
localFileRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Local_File") + ":", true); localFileRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Local_File") + ":", true);
urlFileRadioButton = new UIRadioButton("URL:", false); urlFileRadioButton = new UIRadioButton("URL:", false);
ButtonGroup bg = new ButtonGroup(); ButtonGroup bg = new ButtonGroup();
@ -217,8 +218,9 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
private ActionListener testConnectionListener = new ActionListener() { private ActionListener testConnectionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
String uri = ParameterHelper.analyze4Templatee( urlText.getText(), params); String uri = ParameterHelper.analyze4Templatee(urlText.getText(), params);
if (!checkURL(uri)) { if (!checkURL(uri)) {
JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(FileTableDataPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_JS_warning")); JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(FileTableDataPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add_JS_warning"));
return; return;
@ -245,10 +247,11 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
}; };
private void previewPanel(JPanel jPanel){ private void previewPanel(JPanel jPanel) {
JPanel previewPanel = new JPanel(new BorderLayout()); JPanel previewPanel = new JPanel(new BorderLayout());
UIButton preview = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview")); UIButton preview = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"));
preview.addActionListener(new ActionListener() { preview.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
preview(); preview();
} }
@ -257,48 +260,47 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
jPanel.add(previewPanel, BorderLayout.SOUTH); jPanel.add(previewPanel, BorderLayout.SOUTH);
} }
private JPanel xmlSetPanel(int width,int height) { private JPanel xmlSetPanel(int width, int height) {
// xml设置pane // xml设置pane
JPanel controlPane = new JPanel(); JPanel controlPane = new JPanel();
JPanel northPane = new JPanel(new BorderLayout(8,8)); JPanel northPane = new JPanel(new BorderLayout(8, 8));
JPanel northTopPane = new JPanel(new BorderLayout(8,8)); JPanel northTopPane = new JPanel(new BorderLayout(8, 8));
JPanel southPane = new JPanel(new BorderLayout(8,8)); JPanel southPane = new JPanel(new BorderLayout(8, 8));
JPanel southTopPane = new JPanel(new BorderLayout(8,8)); JPanel southTopPane = new JPanel(new BorderLayout(8, 8));
JPanel westPane = new JPanel(new BorderLayout()); controlPane.setLayout(new BorderLayout(8, 8));
controlPane.setLayout(new BorderLayout(8,8));
controlPane.setPreferredSize(new Dimension(width, height)); controlPane.setPreferredSize(new Dimension(width, height));
JPanel comboboxPanel = new JPanel(new BorderLayout(8,8)); JPanel comboboxPanel = new JPanel(new BorderLayout(8, 8));
encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":"); encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":");
encodingComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY); encodingComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY);
encodingComboBox.setSelectedIndex(4); encodingComboBox.setSelectedIndex(4);
encodingComboBox.setPreferredSize(new Dimension(90, 20)); encodingComboBox.setPreferredSize(new Dimension(90, 20));
JPanel treeContainerPane = new JPanel(); JPanel treeContainerPane = new JPanel();
treeContainerPane.setLayout(new BorderLayout(8,8)); treeContainerPane.setLayout(new BorderLayout(8, 8));
nodeTreePane = new XMLNodeTreePane(); nodeTreePane = new XMLNodeTreePane();
treeContainerPane.add(nodeTreePane,BorderLayout.CENTER); treeContainerPane.add(nodeTreePane, BorderLayout.CENTER);
comboboxPanel.add(encodeLabel, BorderLayout.WEST); comboboxPanel.add(encodeLabel, BorderLayout.WEST);
comboboxPanel.add(encodingComboBox, BorderLayout.CENTER); comboboxPanel.add(encodingComboBox, BorderLayout.CENTER);
northPane.add(comboboxPanel,BorderLayout.EAST); northPane.add(comboboxPanel, BorderLayout.EAST);
northTopPane.add(northPane,BorderLayout.WEST); northTopPane.add(northPane, BorderLayout.WEST);
southTopPane.add(southPane,BorderLayout.WEST); southTopPane.add(southPane, BorderLayout.WEST);
southTopPane.add(treeContainerPane,BorderLayout.CENTER); southTopPane.add(treeContainerPane, BorderLayout.CENTER);
controlPane.add(northTopPane, BorderLayout.NORTH); controlPane.add(northTopPane, BorderLayout.NORTH);
controlPane.add(southTopPane,BorderLayout.CENTER); controlPane.add(southTopPane, BorderLayout.CENTER);
previewPanel(controlPane); previewPanel(controlPane);
return controlPane; return controlPane;
} }
private JPanel excelSetPanel(int width,int height) { private JPanel excelSetPanel(int width, int height) {
// excel设置pane // excel设置pane
int checkBoxWidth = width - EIGHT; int checkBoxWidth = width - EIGHT;
JPanel controlPane = new JPanel(); JPanel controlPane = new JPanel();
JPanel northPane = new JPanel(new BorderLayout(8,8)); JPanel northPane = new JPanel(new BorderLayout(8, 8));
controlPane.setLayout(new BorderLayout()); controlPane.setLayout(new BorderLayout());
controlPane.setPreferredSize(new Dimension(width,height)); controlPane.setPreferredSize(new Dimension(width, height));
needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), false); needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), false);
needColumnNameCheckBox.setPreferredSize(new Dimension(checkBoxWidth, 20)); needColumnNameCheckBox.setPreferredSize(new Dimension(checkBoxWidth, 20));
northPane.add(needColumnNameCheckBox, BorderLayout.EAST); northPane.add(needColumnNameCheckBox, BorderLayout.EAST);
@ -321,6 +323,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
* *
* @throws Exception * @throws Exception
*/ */
@Override
public void checkValid() throws Exception { public void checkValid() throws Exception {
if (urlFileRadioButton.isSelected()) { if (urlFileRadioButton.isSelected()) {
String url = urlText.getText().trim(); String url = urlText.getText().trim();
@ -331,7 +334,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
private boolean checkURL(String uri){ private boolean checkURL(String uri) {
try { try {
new URL(uri); new URL(uri);
return true; return true;
@ -341,23 +344,23 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
// return (uri.matches("https*://.+|\\$\\{.+\\}.*")); // return (uri.matches("https*://.+|\\$\\{.+\\}.*"));
} }
private JPanel textSetPanel(int width,int height) { private JPanel textSetPanel(int width, int height) {
// text设置pane // text设置pane
JPanel controlPane = new JPanel(); JPanel controlPane = new JPanel();
controlPane.setLayout(new BorderLayout()); controlPane.setLayout(new BorderLayout());
controlPane.setPreferredSize(new Dimension(width,height)); controlPane.setPreferredSize(new Dimension(width, height));
JPanel northPane = new JPanel(new BorderLayout(8,8)); JPanel northPane = new JPanel(new BorderLayout(8, 8));
addToNorthPane(northPane); addToNorthPane(northPane);
controlPane.add(northPane,BorderLayout.WEST); controlPane.add(northPane, BorderLayout.WEST);
previewPanel(controlPane); previewPanel(controlPane);
return controlPane; return controlPane;
} }
private void addToNorthPane(JPanel northPane){ private void addToNorthPane(JPanel northPane) {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double columnSize[] = {f, p, p}; double[] columnSize = {f, p, p};
double rowSize[] = {B, B, B, B, B, B, B}; double[] rowSize = {B, B, B, B, B, B, B};
needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), true); needColumnNameCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FirstRow_IS_Column_Name"), true);
dismenberLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dismenber") + ":"); dismenberLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dismenber") + ":");
tableDismemberRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Table_Dismember"), false); tableDismemberRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Table_Dismember"), false);
@ -390,18 +393,19 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":"); encodeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Encoding_Type") + ":");
charsetComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY); charsetComboBox = new UIComboBox(EncodeConstants.ALL_ENCODING_ARRAY);
Component[][] comps = { Component[][] comps = {
{encodeLabel,charsetComboBox,null}, {encodeLabel, charsetComboBox, null},
{needColumnNameCheckBox,null,null}, {needColumnNameCheckBox, null, null},
{dismenberLabel,tableDismemberRadioButton,null}, {dismenberLabel, tableDismemberRadioButton, null},
{null,spaceDismenberRadioButton,null}, {null, spaceDismenberRadioButton, null},
{null,commaDismenberRadioButton,null}, {null, commaDismenberRadioButton, null},
{null,otherDismenberRadioButton,otherDismenberTextField}, {null, otherDismenberRadioButton, otherDismenberTextField},
{ignoreOneMoreDelimiterCheckBox,null,null} {ignoreOneMoreDelimiterCheckBox, null, null}
}; };
northPane.add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize),BorderLayout.EAST); northPane.add(TableLayoutHelper.createTableLayoutPane(comps, rowSize, columnSize), BorderLayout.EAST);
} }
private ActionListener radioActionListener = new ActionListener() { private ActionListener radioActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (localFileRadioButton.isSelected()) { if (localFileRadioButton.isSelected()) {
localRadioSelectAction(); localRadioSelectAction();
@ -456,8 +460,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private String[] getFileSuffix() { private String[] getFileSuffix() {
List<String> suffixList = new ArrayList<String>(); List<String> suffixList = new ArrayList<String>();
String suffix = fileTypeComboBox.getSelectedItem().toString().toLowerCase(); String suffix = Objects.requireNonNull(fileTypeComboBox.getSelectedItem()).toString().toLowerCase();
if (suffix.equalsIgnoreCase("excel")) { if ("excel".equalsIgnoreCase(suffix)) {
suffixList.add("xls"); suffixList.add("xls");
suffixList.add("xlsx"); suffixList.add("xlsx");
} else { } else {
@ -467,8 +471,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
private String getFileSuffixToString() { private String getFileSuffixToString() {
String suffixToString = fileTypeComboBox.getSelectedItem().toString().toLowerCase(); String suffixToString = Objects.requireNonNull(fileTypeComboBox.getSelectedItem()).toString().toLowerCase();
if (suffixToString.equalsIgnoreCase("excel")) { if ("excel".equalsIgnoreCase(suffixToString)) {
suffixToString = "xls"; suffixToString = "xls";
} }
return suffixToString; return suffixToString;
@ -476,16 +480,17 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private ActionListener getFileTypeListener(final JPanel setPanel, final int width, final int height) { private ActionListener getFileTypeListener(final JPanel setPanel, final int width, final int height) {
ActionListener fileTypeListener = new ActionListener() { ActionListener fileTypeListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
setPanel.removeAll(); setPanel.removeAll();
localText.setText(""); localText.setText("");
urlText.setText(""); urlText.setText("");
if (fileTypeComboBox.getSelectedIndex() == XML) { if (fileTypeComboBox.getSelectedIndex() == XML) {
setPanel.add(xmlSetPanel(width,height), BorderLayout.NORTH); setPanel.add(xmlSetPanel(width, height), BorderLayout.NORTH);
} else if (fileTypeComboBox.getSelectedIndex() == EXCEL) { } else if (fileTypeComboBox.getSelectedIndex() == EXCEL) {
setPanel.add(excelSetPanel(width,height), BorderLayout.NORTH); setPanel.add(excelSetPanel(width, height), BorderLayout.NORTH);
} else { } else {
setPanel.add(textSetPanel(width,height), BorderLayout.NORTH); setPanel.add(textSetPanel(width, height), BorderLayout.NORTH);
} }
String tipContent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Type_Parameter") + "reportlets/excel/FineReport${abc}." + getFileSuffixToString() + "<br>" String tipContent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Type_Parameter") + "reportlets/excel/FineReport${abc}." + getFileSuffixToString() + "<br>"
+ "http://192.168.100.120:8080/XXServer/Report/excel${abc}.jsp<br>" + "&nbsp</body> </html> "; + "http://192.168.100.120:8080/XXServer/Report/excel${abc}.jsp<br>" + "&nbsp</body> </html> ";
@ -503,6 +508,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String[] paramTexts = new String[1]; String[] paramTexts = new String[1];
paramTexts[0] = getFilePathFromUrlOrLocal(); paramTexts[0] = getFilePathFromUrlOrLocal();
@ -545,25 +551,25 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
setTextField(xtd); setTextField(xtd);
editorPane.populate(xtd.getParams()); editorPane.populate(xtd.getParams());
encodingComboBox.setSelectedItem(xtd.getCharSet()); encodingComboBox.setSelectedItem(xtd.getCharSet());
if (!ComparatorUtils.equals(xtd,new XMLTableData())) { if (!ComparatorUtils.equals(xtd, new XMLTableData())) {
xmlNodeTree.initData(); xmlNodeTree.initData();
String[] path = xtd.getXPath(); String[] path = xtd.getXPath();
String[] paths; String[] paths;
if (path != null && path.length > 0) { if (path != null && path.length > 0) {
DefaultTreeModel treeModel = (DefaultTreeModel)xmlNodeTree.getModel(); DefaultTreeModel treeModel = (DefaultTreeModel) xmlNodeTree.getModel();
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
if (treeModel != null) { if (treeModel != null) {
if(!ComparatorUtils.equals(treeModel.getRoot().toString(),"")){ if (!ComparatorUtils.equals(treeModel.getRoot().toString(), "")) {
paths = new String[path.length - 1]; paths = new String[path.length - 1];
for(int i = 1;i< path.length;i++){ for (int i = 1; i < path.length; i++) {
paths[i -1] = path[i]; paths[i - 1] = path[i];
} }
}else{ } else {
paths = path; paths = path;
root.setUserObject(ROOTTAG); root.setUserObject(ROOTTAG);
} }
if (treeModel.getRoot() instanceof ExpandMutableTreeNode) { if (treeModel.getRoot() instanceof ExpandMutableTreeNode) {
selectNode((ExpandMutableTreeNode)treeModel.getRoot(), 0, paths); selectNode((ExpandMutableTreeNode) treeModel.getRoot(), 0, paths);
if (selectedNode != null) { if (selectedNode != null) {
TreePath treepath = new TreePath(treeModel.getPathToRoot(selectedNode)); TreePath treepath = new TreePath(treeModel.getPathToRoot(selectedNode));
xmlNodeTree.setSelectionPath(treepath); xmlNodeTree.setSelectionPath(treepath);
@ -571,7 +577,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
} }
//防止某种操作导致添加的tag作为root出现。 //防止某种操作导致添加的tag作为root出现。
if(ComparatorUtils.equals(root.toString(),ROOTTAG)){ if (ComparatorUtils.equals(root.toString(), ROOTTAG)) {
root.setUserObject(StringUtils.EMPTY); root.setUserObject(StringUtils.EMPTY);
} }
} }
@ -638,7 +644,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
ttd.setDelimiter(this.showDelimiter()); ttd.setDelimiter(this.showDelimiter());
ttd.setIgnoreOneMoreDelimiter(ignoreOneMoreDelimiterCheckBox.isSelected()); ttd.setIgnoreOneMoreDelimiter(ignoreOneMoreDelimiterCheckBox.isSelected());
ttd.setNeedColumnName(needColumnNameCheckBox.isSelected()); ttd.setNeedColumnName(needColumnNameCheckBox.isSelected());
ttd.setCharset((String)charsetComboBox.getSelectedItem()); ttd.setCharset((String) charsetComboBox.getSelectedItem());
fileTableData = ttd; fileTableData = ttd;
return ttd; return ttd;
} }
@ -667,12 +673,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
xmlColumnsList.clear(); xmlColumnsList.clear();
ExpandMutableTreeNode treeNode; ExpandMutableTreeNode treeNode;
boolean flag = true; boolean flag = true;
for(int i = 0;i < selectedNode.getChildCount();i++){ for (int i = 0; i < selectedNode.getChildCount(); i++) {
treeNode = (ExpandMutableTreeNode) selectedNode.getChildAt(i); treeNode = (ExpandMutableTreeNode) selectedNode.getChildAt(i);
if(treeNode.isLeaf()){ if (treeNode.isLeaf()) {
xmlColumnsList.add(treeNode.toString()); xmlColumnsList.add(treeNode.toString());
}else{ } else {
if(flag){ if (flag) {
flag = false; flag = false;
finalSelectedNode = treeNode; finalSelectedNode = treeNode;
leafNode(treeNode); leafNode(treeNode);
@ -692,34 +698,34 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
//wikky:构建树时为了美观把添加的根节点值赋为空显示,现在还得该回去使得预览时能够顺利取到数据。 //wikky:构建树时为了美观把添加的根节点值赋为空显示,现在还得该回去使得预览时能够顺利取到数据。
private String[] getPaths(){ private String[] getPaths() {
TreePath treePath = GUICoreUtils.getTreePath(finalSelectedNode); TreePath treePath = GUICoreUtils.getTreePath(finalSelectedNode);
String path = StringUtils.EMPTY; String path = StringUtils.EMPTY;
if (treePath != null) { if (treePath != null) {
Object[] paths = treePath.getPath(); Object[] paths = treePath.getPath();
for (int i = 0; i < paths.length; i++) { for (int i = 0; i < paths.length; i++) {
path+="/" + paths[i]; path += "/" + paths[i];
} }
} }
if (path.startsWith("/")) { if (path.startsWith("/")) {
path = path.substring(1); path = path.substring(1);
} }
String[] paths = path.split("/"); String[] paths = path.split("/");
if(ComparatorUtils.equals(paths[0],StringUtils.EMPTY)){ if (ComparatorUtils.equals(paths[0], StringUtils.EMPTY)) {
paths[0] = ROOTTAG; paths[0] = ROOTTAG;
} }
return paths; return paths;
} }
private void leafNode(ExpandMutableTreeNode treeNode){ private void leafNode(ExpandMutableTreeNode treeNode) {
boolean flag = true; boolean flag = true;
ExpandMutableTreeNode firstNode; ExpandMutableTreeNode firstNode;
for(int i = 0;i < treeNode.getChildCount();i++){ for (int i = 0; i < treeNode.getChildCount(); i++) {
firstNode = (ExpandMutableTreeNode) treeNode.getChildAt(i); firstNode = (ExpandMutableTreeNode) treeNode.getChildAt(i);
if(firstNode.isLeaf()){ if (firstNode.isLeaf()) {
xmlColumnsList.add(firstNode.toString()); xmlColumnsList.add(firstNode.toString());
}else{ } else {
if(flag){ if (flag) {
flag = false; flag = false;
finalSelectedNode = treeNode; finalSelectedNode = treeNode;
leafNode(firstNode); leafNode(firstNode);
@ -729,16 +735,16 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
private void selectNode(ExpandMutableTreeNode node, int layer, String[] paths) { private void selectNode(ExpandMutableTreeNode node, int layer, String[] paths) {
if (selectedNode != null || node == null){ if (selectedNode != null || node == null) {
return; return;
} }
if (layer < paths.length && paths[layer] != null && ComparatorUtils.equals(paths[layer],node.getUserObject())) { if (layer < paths.length && paths[layer] != null && ComparatorUtils.equals(paths[layer], node.getUserObject())) {
if (layer == paths.length -1) { if (layer == paths.length - 1) {
selectedNode = node; selectedNode = node;
return; return;
} }
for (int i = 0; i < node.getChildCount(); i++) { for (int i = 0; i < node.getChildCount(); i++) {
selectNode((ExpandMutableTreeNode)node.getChildAt(i), layer + 1, paths); selectNode((ExpandMutableTreeNode) node.getChildAt(i), layer + 1, paths);
} }
} }
} }
@ -800,8 +806,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
toolbarDef.addShortCut(refreshAction); toolbarDef.addShortCut(refreshAction);
UIToolbar toolBar = ToolBarDef.createJToolBar(); UIToolbar toolBar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
toolbarPanel.add(keyPointLaber,BorderLayout.WEST); toolbarPanel.add(keyPointLaber, BorderLayout.WEST);
toolbarPanel.add(toolBar,BorderLayout.EAST); toolbarPanel.add(toolBar, BorderLayout.EAST);
this.add(toolbarPanel, BorderLayout.NORTH); this.add(toolbarPanel, BorderLayout.NORTH);
} }
@ -817,6 +823,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
xmlNodeTree.waitRefresh(); xmlNodeTree.waitRefresh();
xmlNodeTree.refreshData(); xmlNodeTree.refreshData();
@ -845,8 +852,9 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
private MouseListener treeMouseListener = new MouseAdapter() { private MouseListener treeMouseListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (XMLNodeTree.this.getModel() != treeModel){ if (XMLNodeTree.this.getModel() != treeModel) {
return; return;
} }
int selRow = XMLNodeTree.this.getRowForLocation(e.getX(), e.getY()); int selRow = XMLNodeTree.this.getRowForLocation(e.getX(), e.getY());
@ -858,12 +866,12 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
return;//没有选中某个树节点,就直接返回啦 return;//没有选中某个树节点,就直接返回啦
} }
Object selObject = selPath.getLastPathComponent(); Object selObject = selPath.getLastPathComponent();
if (selObject instanceof ExpandMutableTreeNode ) { if (selObject instanceof ExpandMutableTreeNode) {
ExpandMutableTreeNode expandMutableTreeNode = (ExpandMutableTreeNode) selObject; ExpandMutableTreeNode expandMutableTreeNode = (ExpandMutableTreeNode) selObject;
if (!expandMutableTreeNode.isLeaf()) { if (!expandMutableTreeNode.isLeaf()) {
selectedNode = expandMutableTreeNode; selectedNode = expandMutableTreeNode;
} else { } else {
selectedNode = (ExpandMutableTreeNode)expandMutableTreeNode.getParent(); selectedNode = (ExpandMutableTreeNode) expandMutableTreeNode.getParent();
} }
} }
} }
@ -906,7 +914,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
DataSource dataSource = null; DataSource dataSource = null;
if (localFileRadioButton.isSelected()) { if (localFileRadioButton.isSelected()) {
String localTextString = StringUtils.trimToNull(localText.getText()); String localTextString = StringUtils.trimToNull(localText.getText());
if(StringUtils.isEmpty(localTextString)){ if (StringUtils.isEmpty(localTextString)) {
FineLoggerFactory.getLogger().info("The file path is empty."); FineLoggerFactory.getLogger().info("The file path is empty.");
loadedTreeModel(); loadedTreeModel();
return; return;
@ -914,7 +922,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
dataSource = new FileDataSource(localTextString, params); dataSource = new FileDataSource(localTextString, params);
} else { } else {
String urlTextString = StringUtils.trimToNull(urlText.getText()); String urlTextString = StringUtils.trimToNull(urlText.getText());
if (StringUtils.isEmpty(urlTextString)){ if (StringUtils.isEmpty(urlTextString)) {
FineLoggerFactory.getLogger().info("The url path is empty."); FineLoggerFactory.getLogger().info("The url path is empty.");
loadedTreeModel(); loadedTreeModel();
return; return;
@ -922,7 +930,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
dataSource = new URLDataSource(urlTextString, params); dataSource = new URLDataSource(urlTextString, params);
} }
try { try {
InputStream in,input; InputStream in, input;
if ((in = dataSource.getSourceStream(params)) != null) { if ((in = dataSource.getSourceStream(params)) != null) {
String xmlString = Utils.inputStream2String(in, (String) encodingComboBox.getSelectedItem()); String xmlString = Utils.inputStream2String(in, (String) encodingComboBox.getSelectedItem());
String stringXml = addTag(xmlString); String stringXml = addTag(xmlString);
@ -941,16 +949,20 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
loadedTreeModel(); loadedTreeModel();
} }
if(treeModel.getChildCount(treeModel.getRoot()) == 1){ if (treeModel == null) {
treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(),0)); FineLoggerFactory.getLogger().info("The file is wrong or bad, can not create the XMLReader.");
}else{ return;
}
if (treeModel.getChildCount(treeModel.getRoot()) == 1) {
treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0));
} else {
ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
root.setUserObject(StringUtils.EMPTY); root.setUserObject(StringUtils.EMPTY);
} }
this.setModel(treeModel); this.setModel(treeModel);
} }
private void loadedTreeModel(){ private void loadedTreeModel() {
ExpandMutableTreeNode rootTreeNode = new ExpandMutableTreeNode(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loaded_Tree_Model")); ExpandMutableTreeNode rootTreeNode = new ExpandMutableTreeNode(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loaded_Tree_Model"));
rootTreeNode.setExpanded(false); rootTreeNode.setExpanded(false);
rootTreeNode.setAllowsChildren(false); rootTreeNode.setAllowsChildren(false);
@ -958,14 +970,14 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
XMLNodeTree.this.setModel(loadedTreeModel); XMLNodeTree.this.setModel(loadedTreeModel);
} }
private String addTag(String string){ private String addTag(String string) {
String stringWithTag; String stringWithTag;
int beginIndex = 0; int beginIndex = 0;
int firstIndex = string.indexOf(">"); int firstIndex = string.indexOf(">");
int endIndex = string.length(); int endIndex = string.length();
String firstPart = string.substring(beginIndex,firstIndex + 1); String firstPart = string.substring(beginIndex, firstIndex + 1);
String secondPart = STARTTAG; String secondPart = STARTTAG;
String thirdPart = string.substring(firstIndex + 1,endIndex); String thirdPart = string.substring(firstIndex + 1, endIndex);
String lastPart = ENDTAG; String lastPart = ENDTAG;
stringWithTag = firstPart + secondPart + thirdPart + lastPart; stringWithTag = firstPart + secondPart + thirdPart + lastPart;
return stringWithTag; return stringWithTag;
@ -986,6 +998,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
this.layer = layer; this.layer = layer;
} }
@Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
String nodeName; String nodeName;
if (this.layer < 0) { if (this.layer < 0) {

6
designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java

@ -1,10 +1,10 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import java.awt.*; import java.awt.*;
/* @Open
* @author _denny
*/
public abstract class BasicDialog extends UIDialog { public abstract class BasicDialog extends UIDialog {
public static final Dimension SMALL = new Dimension(340, 180); public static final Dimension SMALL = new Dimension(340, 180);
public static final Dimension MEDIUM = new Dimension(600, 400); public static final Dimension MEDIUM = new Dimension(600, 400);

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

@ -1,24 +1,17 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dialog; @Open
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Window;
/*
* _denny: 这里的BasicPane通常会有populate & update方法
* 记得populate 一定要在对应的dialog setVisible之前populate
*/
public abstract class BasicPane extends JPanel { public abstract class BasicPane extends JPanel {
/** /**
@ -129,7 +122,7 @@ public abstract class BasicPane extends JPanel {
* @param dimension 自定义尺寸 * @param dimension 自定义尺寸
* @return 对话框 * @return 对话框
*/ */
protected BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) { public BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) {
BasicDialog dg; BasicDialog dg;
if (window instanceof Frame) { if (window instanceof Frame) {
dg = new DIALOG((Frame) window); dg = new DIALOG((Frame) window);

3
designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java

@ -1,5 +1,8 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public abstract class DialogActionAdapter implements DialogActionListener { public abstract class DialogActionAdapter implements DialogActionListener {
@Override @Override
public void doOk() {} public void doOk() {}

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

@ -1,8 +1,11 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public interface DialogActionListener { public interface DialogActionListener {
public void doOk(); void doOk();
public void doCancel(); void doCancel();
} }

8
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -25,13 +25,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created with IntelliJ IDEA.
* User: 小灰灰
* Date: 13-7-16
* Time: 下午2:17
* To change this template use File | Settings | File Templates.
*/
public abstract class UIDialog extends JDialog { public abstract class UIDialog extends JDialog {
public static final String OK_BUTTON = "basic_ok"; public static final String OK_BUTTON = "basic_ok";
public static final String CANCEL_BUTTON = "basic_cancel"; public static final String CANCEL_BUTTON = "basic_cancel";

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

@ -9,5 +9,5 @@ public interface DesignerOpenedListener extends EventListener {
/** /**
* Invoked when the target of the listener has changed the rpt content. * Invoked when the target of the listener has changed the rpt content.
*/ */
public void designerOpened(); void designerOpened();
} }

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

@ -1,6 +1,7 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.passport.FinePassportManager; import com.fr.base.passport.FinePassportManager;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
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;
@ -8,47 +9,30 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
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;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/** /**
* @author vito * @author vito
*/ */
public class LoginWebBridge { public class LoginWebBridge {
//默认查询消息时间, 30s
private static final long CHECK_MESSAGE_TIME = 30 * 1000L;
//数据查询正常的标志 ok
private static final String SUCCESS_MESSAGE_STATUS = "ok";
//数据通讯失败
private static final String FAILED_MESSAGE_STATUS = "error";
//最低消息的条数 //最低消息的条数
private static final int MIN_MESSAGE_COUNT = 0; private static final int MIN_MESSAGE_COUNT = 0;
//登录成功
private static final String LOGININ = "0";
//用户名不存在
private static final String USERNAME_NOT_EXSIT = "-1";
//密码错误
private static final String PASSWORD_ERROR = "-2";
//未知错误
private static final String UNKNOWN_ERROR = "-3";
//网络连接失败 //网络连接失败
private static final String NET_FAILED = "-4"; private static final String NET_FAILED = "-4";
//用户名,密码为空 //用户名,密码为空
private static final String LOGIN_INFO_EMPTY = "-5"; private static final String LOGIN_INFO_EMPTY = "-5";
private static final int TIME_OUT = 10000;
private static final String LOGIN_SUCCESS = "ok";
private static final String LOGIN_FAILED = "failed";
private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242); private static final Color LOGIN_BACKGROUND = new Color(184, 220, 242);
private static LoginWebBridge helper; private static LoginWebBridge helper;
//消息条数 //消息条数
@ -131,22 +115,6 @@ public class LoginWebBridge {
return client.isServerAlive(); return client.isServerAlive();
} }
private String encode(String str) {
try {
return URLEncoder.encode(str, EncodeConstants.ENCODING_UTF_8);
} catch (UnsupportedEncodingException e) {
return str;
}
}
private void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/** /**
* 注册页面 * 注册页面
*/ */
@ -178,7 +146,9 @@ public class LoginWebBridge {
*/ */
public void defaultLogin(String username, String password, final JSObject callback) { public void defaultLogin(String username, String password, final JSObject callback) {
Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password)); Task<Void> task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password));
new Thread(task).start(); ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("bbsDefaultLogin"));
es.submit(task);
es.shutdown();
} }
/** /**
@ -250,10 +220,6 @@ public class LoginWebBridge {
} }
} }
public void openUrlAtLocalWebBrowser(WebEngine eng, String url) { public void openUrlAtLocalWebBrowser(WebEngine eng, String url) {
if (url.indexOf("qqLogin.html") > 0) {
return;
}
} }
} }

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

@ -15,6 +15,7 @@ import com.fr.plugin.manage.control.PluginTaskCallback;
import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.manage.control.PluginTaskResult;
import com.fr.plugin.view.PluginView; import com.fr.plugin.view.PluginView;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -142,6 +143,7 @@ public class PluginControlPane extends BasicPane {
} }
} }
@Nullable
public PluginView getSelectedPlugin() { public PluginView getSelectedPlugin() {
return (PluginView) pluginList.getSelectedValue(); return (PluginView) pluginList.getSelectedValue();
} }

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

@ -28,8 +28,6 @@ import java.util.List;
* @since 8.0 * @since 8.0
*/ */
public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> { public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<PluginView>, Void> {
private static final int LISTNUM1 = 1;
private static final int LISTNUM100 = 100;
private UILabel errorMsgLabel; private UILabel errorMsgLabel;
private UITabbedPane tabbedPane; private UITabbedPane tabbedPane;
private PluginControlPane controlPane; private PluginControlPane controlPane;
@ -45,6 +43,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
* *
* @return 创建的页面对象 * @return 创建的页面对象
*/ */
@Override
public JPanel createSuccessPane() { public JPanel createSuccessPane() {
return new PluginStatusCheckCompletePane() { return new PluginStatusCheckCompletePane() {
@ -130,8 +129,8 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
* *
* @return 插件 * @return 插件
*/ */
@Override
public List<PluginView> loadData() throws Exception { public List<PluginView> loadData() throws Exception {
//Thread.sleep(3000);
return PluginsReaderFromStore.readPlugins(); return PluginsReaderFromStore.readPlugins();
} }
@ -140,6 +139,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
* *
* @param plugins 插件 * @param plugins 插件
*/ */
@Override
public void loadOnSuccess(List<PluginView> plugins) { public void loadOnSuccess(List<PluginView> plugins) {
controlPane.loadPlugins(plugins); controlPane.loadPlugins(plugins);
tabbedPane.setTitleAt(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_All_Plugins") + "(" + plugins.size() + ")"); tabbedPane.setTitleAt(2, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_All_Plugins") + "(" + plugins.size() + ")");
@ -150,10 +150,12 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
* *
* @param e 异常消息 * @param e 异常消息
*/ */
@Override
public void loadOnFailed(Exception e) { public void loadOnFailed(Exception e) {
errorMsgLabel.setText(e.getCause().getMessage()); errorMsgLabel.setText(e.getCause().getMessage());
} }
@Override
protected void installFromDiskFile() { protected void installFromDiskFile() {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
@ -196,10 +198,11 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
} }
if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) { if (StringUtils.isNotEmpty(MarketConfig.getInstance().getBbsUsername())) {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
String id = null; if (plugin == null) {
if (plugin != null) { FineLoggerFactory.getLogger().error("selected plugin is null");
id = plugin.getID(); return;
} }
String id = plugin.getID();
try { try {
PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion()); PluginMarker pluginMarker = PluginMarker.create(id, plugin.getVersion());
@ -219,6 +222,7 @@ public class PluginFromStorePane extends PluginAbstractLoadingViewPane<List<Plug
* *
* @return 标题字符串 * @return 标题字符串
*/ */
@Override
public String textForLoadingLabel() { public String textForLoadingLabel() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Load_Plugins_From_Server"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Load_Plugins_From_Server");
} }

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

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

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

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

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

@ -5,17 +5,15 @@ import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.CloudCenter;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.general.CloudCenter;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginStoreConstants; import com.fr.plugin.PluginStoreConstants;
import com.fr.plugin.PluginVerifyException;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -259,21 +257,12 @@ public class WebViewDlgHelper {
new SwingWorker<Boolean, Void>() { new SwingWorker<Boolean, Void>() {
@Override @Override
protected Boolean doInBackground() throws Exception { protected Boolean doInBackground() throws Exception {
try { return PluginUtils.downloadShopScripts(scriptsId, new Process<Double>() {
PluginUtils.downloadShopScripts(scriptsId, new Process<Double>() {
@Override @Override
public void process(Double integer) { public void process(Double integer) {
// 这个注释毫无意义,就是为了通过SonarQube // 这个注释毫无意义,就是为了通过SonarQube
} }
}); });
} catch (PluginVerifyException e) {
JOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE);
return false;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
return true;
} }
@Override @Override
@ -289,7 +278,10 @@ public class WebViewDlgHelper {
PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等 PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等
JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE);
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

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

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

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

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

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

@ -41,17 +41,12 @@ public class HistoryTemplateListCache implements CallbackEvent {
private List<JTemplate<?, ?>> historyList; private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate; private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache instacne;
public static HistoryTemplateListCache getInstance() { public static HistoryTemplateListCache getInstance() {
if (instacne == null) { return Holder.INSTANCE;
synchronized (HistoryTemplateListCache.class) {
if (instacne == null) {
instacne = new HistoryTemplateListCache();
}
}
} }
return instacne;
private static class Holder {
private static final HistoryTemplateListCache INSTANCE = new HistoryTemplateListCache();
} }
private HistoryTemplateListCache() { private HistoryTemplateListCache() {
@ -263,9 +258,9 @@ public class HistoryTemplateListCache implements CallbackEvent {
JTemplate<?, ?> template = iterator.next(); JTemplate<?, ?> template = iterator.next();
String tPath = template.getPath(); String tPath = template.getPath();
if (isDir ? tPath.startsWith(path) : tPath.equals(path)) { if (isDir ? tPath.startsWith(path) : tPath.equals(path)) {
int size = getHistoryCount();
iterator.remove(); iterator.remove();
int index = iterator.nextIndex(); int index = iterator.nextIndex();
int size = getHistoryCount();
if (size == index + 1 && index > 0) { if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个 //如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1); MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);

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

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

1
designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java

@ -194,6 +194,7 @@ public class JavaEditorPane extends BasicPane {
JOptionPane.showMessageDialog(null, message); JOptionPane.showMessageDialog(null, message);
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1); FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
Thread.currentThread().interrupt();
} catch (ExecutionException e1) { } catch (ExecutionException e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1); FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
} }

8
designer-base/src/main/java/com/fr/design/formula/VariableResolverAdapter.java

@ -23,6 +23,7 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* *
* @return 内置参数 * @return 内置参数
*/ */
@Override
public String[] resolveCurReportVariables() { public String[] resolveCurReportVariables() {
String[] variables = new String[]{ String[] variables = new String[]{
ScriptConstants.SUMMARY_TAG + "page_number", ScriptConstants.SUMMARY_TAG + "page_number",
@ -39,7 +40,7 @@ public abstract class VariableResolverAdapter implements VariableResolver {
}; };
Set<BuiltInParametersProvider> set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG); Set<BuiltInParametersProvider> set = ExtraClassManager.getInstance().getArray(BuiltInParametersProvider.XML_TAG);
for (BuiltInParametersProvider provider : set) { for (BuiltInParametersProvider provider : set) {
return (String[]) ArrayUtils.addAll(variables, new String[]{ ArrayUtils.addAll(variables, new String[]{
ScriptConstants.DETAIL_TAG + provider.getParametersName() ScriptConstants.DETAIL_TAG + provider.getParametersName()
}); });
} }
@ -65,6 +66,8 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* *
* @return 所有参数 * @return 所有参数
*/ */
@Override
@SuppressWarnings("squid:S2259")
public String[] resolveTableDataParameterVariables() { public String[] resolveTableDataParameterVariables() {
Parameter[] parameters = getCurrentModeParameters(TABLE_DATA_PARA); Parameter[] parameters = getCurrentModeParameters(TABLE_DATA_PARA);
String[] parameterNames = new String[parameters.length]; String[] parameterNames = new String[parameters.length];
@ -79,6 +82,8 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* *
* @return 所有参数 * @return 所有参数
*/ */
@Override
@SuppressWarnings("squid:S2259")
public String[] resolveReportParameterVariables() { public String[] resolveReportParameterVariables() {
Parameter[] parameters = getCurrentModeParameters(REPORT_DATA_PARA); Parameter[] parameters = getCurrentModeParameters(REPORT_DATA_PARA);
String[] parameterNames = new String[parameters.length]; String[] parameterNames = new String[parameters.length];
@ -93,6 +98,7 @@ public abstract class VariableResolverAdapter implements VariableResolver {
* *
* @return 所有参数 * @return 所有参数
*/ */
@Override
public String[] resolveGlobalParameterVariables() { public String[] resolveGlobalParameterVariables() {
// 加上全局的参数 // 加上全局的参数
Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters(); Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters();

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

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

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

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

3
designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java

@ -76,7 +76,6 @@ public class UIDefaultTheme extends DefaultMetalTheme {
table.put("Table.background", ThemeUtils.TEXT_BG_COLOR); table.put("Table.background", ThemeUtils.TEXT_BG_COLOR);
table.put("Table.selectionForeground", ThemeUtils.NORMAL_FOREGROUND); table.put("Table.selectionForeground", ThemeUtils.NORMAL_FOREGROUND);
table.put("Table.selectionBackground", new ColorUIResource(200, 221, 233)); table.put("Table.selectionBackground", new ColorUIResource(200, 221, 233));
table.put("Table.gridColor", new ColorUIResource(200, 221, 233));
table.put("TableHeader.background", new ColorUIResource(229, 229, 229)); table.put("TableHeader.background", new ColorUIResource(229, 229, 229));
table.put("ProgressBar.foreground", ThemeUtils.PROCESS_COLOR); table.put("ProgressBar.foreground", ThemeUtils.PROCESS_COLOR);
table.put("ProgressBar.background", ThemeUtils.TEXT_BG_COLOR); table.put("ProgressBar.background", ThemeUtils.TEXT_BG_COLOR);
@ -85,7 +84,6 @@ public class UIDefaultTheme extends DefaultMetalTheme {
table.put("ProgressBar.selectionForeground", ThemeUtils.NORMAL_FOREGROUND); table.put("ProgressBar.selectionForeground", ThemeUtils.NORMAL_FOREGROUND);
table.put("ProgressBar.selectionBackground", ThemeUtils.NORMAL_FOREGROUND); table.put("ProgressBar.selectionBackground", ThemeUtils.NORMAL_FOREGROUND);
table.put("PopupMenu.background", ThemeUtils.NORMAL_BG); table.put("PopupMenu.background", ThemeUtils.NORMAL_BG);
table.put("TabbedPane.background", ThemeUtils.TEXT_BG_COLOR);
table.put("TabbedPane.background", ThemeUtils.NORMAL_BG); table.put("TabbedPane.background", ThemeUtils.NORMAL_BG);
table.put("TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 0)); table.put("TabbedPane.tabAreaInsets", new InsetsUIResource(4, 2, 0, 0));
table.put("TabbedPane.tabInsets", new InsetsUIResource(1, 6, 4, 6)); table.put("TabbedPane.tabInsets", new InsetsUIResource(1, 6, 4, 6));
@ -108,7 +106,6 @@ public class UIDefaultTheme extends DefaultMetalTheme {
table.put("ComboBox.foreground", ThemeUtils.NORMAL_FOREGROUND); table.put("ComboBox.foreground", ThemeUtils.NORMAL_FOREGROUND);
table.put("ComboBox.background", ThemeUtils.TEXT_BG_COLOR); table.put("ComboBox.background", ThemeUtils.TEXT_BG_COLOR);
table.put("ComboBox.disabledBackground", ThemeUtils.TEXT_DISABLED_BG_COLOR); table.put("ComboBox.disabledBackground", ThemeUtils.TEXT_DISABLED_BG_COLOR);
table.put("EditorPane.background", ThemeUtils.TEXT_BG_COLOR);
table.put("EditorPane.foreground", ThemeUtils.NORMAL_FOREGROUND); table.put("EditorPane.foreground", ThemeUtils.NORMAL_FOREGROUND);
table.put("PasswordField.background", ThemeUtils.TEXT_BG_COLOR); table.put("PasswordField.background", ThemeUtils.TEXT_BG_COLOR);
table.put("PasswordField.foreground", ThemeUtils.NORMAL_FOREGROUND); table.put("PasswordField.foreground", ThemeUtils.NORMAL_FOREGROUND);

3
designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java

@ -195,6 +195,9 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase
// provider. We do not do function/method completions while editing // provider. We do not do function/method completions while editing
// strings or comments. // strings or comments.
CompletionProvider provider = getProviderFor(tc); CompletionProvider provider = getProviderFor(tc);
if (provider == null) {
return null;
}
return provider==defaultProvider ? return provider==defaultProvider ?
provider.getParameterizedCompletions(tc) : null; provider.getParameterizedCompletions(tc) : null;
} }

4
designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java

@ -517,6 +517,10 @@ class ParameterizedCompletionContext {
} }
} }
if (currentNext == null) {
return;
}
// No params after caret - go to first one // No params after caret - go to first one
if (currentNext.getStartOffset() + 1 <= dot) { if (currentNext.getStartOffset() + 1 <= dot) {
int nextIndex = getFirstHighlight(highlights); int nextIndex = getFirstHighlight(highlights);

2
designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java

@ -146,6 +146,8 @@ public class ColumnRowPane extends JPanel implements UIObserver {
if (cftf != null) { if (cftf != null) {
cftf.setColumns(3); // specify more width than we need cftf.setColumns(3); // specify more width than we need
cftf.setHorizontalAlignment(UITextField.LEFT); cftf.setHorizontalAlignment(UITextField.LEFT);
}else {
throw new IllegalArgumentException("Spinner'Editor can not be null!");
} }
((AbstractDocument) cftf.getDocument()).setDocumentFilter(new DocumentFilter() { ((AbstractDocument) cftf.getDocument()).setDocumentFilter(new DocumentFilter() {

4
designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java

@ -1,8 +1,8 @@
package com.fr.design.gui.controlpane; package com.fr.design.gui.controlpane;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.stable.AssistUtils;
/** /**
* Created by plough on 2017/8/1. * Created by plough on 2017/8/1.
@ -48,7 +48,7 @@ public abstract class ObjectUIControlPane extends UIListControlPane {
if (constructor != null) { if (constructor != null) {
return constructor; return constructor;
} else { } else {
if (cls.getName() == Object.class.getName()) { if (AssistUtils.equals(cls.getName(),Object.class.getName())) {
return null; return null;
} }
return getConstructor(clazz, cls.getSuperclass()); return getConstructor(clazz, cls.getSuperclass());

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

@ -157,7 +157,7 @@ public class UIDatePicker extends UIComboBox implements Serializable {
/** /**
* 设置当前选择的日期 * 设置当前选择的日期
*/ */
public void setSelectedDate(Date date) throws ParseException { public synchronized void setSelectedDate(Date date) throws ParseException {
if (date == null) { if (date == null) {
this.setSelectedItem(null); this.setSelectedItem(null);
} else { } else {
@ -165,6 +165,7 @@ public class UIDatePicker extends UIComboBox implements Serializable {
} }
} }
@Override
public void setSelectedItem(Object anObject) { public void setSelectedItem(Object anObject) {
model.setSelectedItem(anObject); model.setSelectedItem(anObject);
super.setSelectedItem(anObject); super.setSelectedItem(anObject);
@ -192,12 +193,14 @@ public class UIDatePicker extends UIComboBox implements Serializable {
setBorder(BorderFactory.createEmptyBorder()); setBorder(BorderFactory.createEmptyBorder());
} }
@Override
public void hide() { public void hide() {
if (isWillHide) { if (isWillHide) {
super.hide(); super.hide();
} }
} }
@Override
public void show() { public void show() {
if (isWillHide || UIDatePicker.this.isEnabled() == false) { if (isWillHide || UIDatePicker.this.isEnabled() == false) {
return; return;
@ -211,6 +214,7 @@ public class UIDatePicker extends UIComboBox implements Serializable {
/** /**
* 显示弹出面板 * 显示弹出面板
*/ */
@Override
protected void firePropertyChange(String propertyName, protected void firePropertyChange(String propertyName,
Object oldValue, Object oldValue,
Object newValue) { Object newValue) {
@ -250,12 +254,14 @@ public class UIDatePicker extends UIComboBox implements Serializable {
} }
} }
@Override
protected ComboBoxUI getUIComboBoxUI() { protected ComboBoxUI getUIComboBoxUI() {
return new UIComboBoxUI() { return new UIComboBoxUI() {
@Override
protected ComboPopup createPopup() { protected ComboPopup createPopup() {
return new DatePopup(comboBox); return new DatePopup(comboBox);
} }
@Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (UIDatePicker.this.isPopupVisible()) { if (UIDatePicker.this.isPopupVisible()) {
isWillHide = true; isWillHide = true;

1
designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java

@ -35,6 +35,7 @@ public class LoadingPaneDemo extends JPanel {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
container.add(new UIButton(i + "adfadwdadawdwad")); container.add(new UIButton(i + "adfadwdadawdwad"));
} }

3
designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java

@ -4,6 +4,7 @@ import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignModuleFactory;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.Filter; import com.fr.stable.Filter;
import org.jetbrains.annotations.NotNull;
/** /**
* 基础的超级链接类型, 不包括图表相关超链. * 基础的超级链接类型, 不包括图表相关超链.
@ -18,6 +19,8 @@ public class BaseHyperlinkGroup implements HyperlinkGroupType {
* *
* @return NameableCreator[] * @return NameableCreator[]
*/ */
@NotNull
@Override
public NameableCreator[] getHyperlinkCreators() { public NameableCreator[] getHyperlinkCreators() {
return DesignModuleFactory.getCreators4Hyperlink(); return DesignModuleFactory.getCreators4Hyperlink();
} }

2
designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java

@ -3,6 +3,7 @@ package com.fr.design.gui.frpane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.stable.Filter; import com.fr.stable.Filter;
import org.jetbrains.annotations.NotNull;
/** /**
* 超级链接 支持的类型 种类. * 超级链接 支持的类型 种类.
@ -17,6 +18,7 @@ public interface HyperlinkGroupType {
* *
* @return NameableCreator[] * @return NameableCreator[]
*/ */
@NotNull
NameableCreator[] getHyperlinkCreators(); NameableCreator[] getHyperlinkCreators();

1
designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java

@ -24,6 +24,7 @@ public class LoadingBasicPaneTest {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
container.add(new UIButton(i + "adfadwdadawdwad")); container.add(new UIButton(i + "adfadwdadawdwad"));
} }

3
designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java

@ -14,6 +14,7 @@ import javax.swing.event.ChangeListener;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.style.NumberDragBar; import com.fr.design.gui.style.NumberDragBar;
import com.fr.stable.AssistUtils;
/** /**
* 拖拽的滑条和对应滑条值的数字 * 拖拽的滑条和对应滑条值的数字
@ -65,7 +66,7 @@ public class UINumberSlidePane extends BasicBeanPane<Double> {
public void checkValue(double value) { public void checkValue(double value) {
value = Math.max(value, minValue); value = Math.max(value, minValue);
value = Math.min(value, maxValue); value = Math.min(value, maxValue);
if (this.value == value) { if (AssistUtils.equals(this.value, value)) {
return; return;
} }
double diff = Math.abs(value - this.value); double diff = Math.abs(value - this.value);

3
designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java

@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner;
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.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
@ -81,7 +82,7 @@ public abstract class UnitInputPane extends BasicPane {
floatValue = de.floatValue(); floatValue = de.floatValue();
} }
//选中多列, 并且列宽不完全一致的话, 就不显示值了. //选中多列, 并且列宽不完全一致的话, 就不显示值了.
temp.setText(floatValue == 0 ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue)));
// denny:默认应该为选中,方便用户修改 // denny:默认应该为选中,方便用户修改
temp.selectAll(); temp.selectAll();

4
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java

@ -125,8 +125,7 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
private class UICheckBoxUI extends MetalCheckBoxUI { private class UICheckBoxUI extends MetalCheckBoxUI {
@Override @Override
public void paint(Graphics g, JComponent c) { public synchronized void paint(Graphics g, JComponent c) {
synchronized (this) {
AbstractButton b = (AbstractButton) c; AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel(); ButtonModel model = b.getModel();
Dimension size = c.getSize(); Dimension size = c.getSize();
@ -179,7 +178,6 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
// Draw the Text // Draw the Text
drawLine(text, g, b, c, textRect, fm); drawLine(text, g, b, c, textRect, fm);
} }
}
private void drawLine(String text, Graphics g, AbstractButton b, JComponent c, Rectangle textRect, FontMetrics fm) { private void drawLine(String text, Graphics g, AbstractButton b, JComponent c, Rectangle textRect, FontMetrics fm) {
if (text != null) { if (text != null) {

2
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java

@ -64,7 +64,7 @@ public class UICheckBoxUI extends MetalCheckBoxUI {
} }
} }
static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f / 1.0f}, 1.0f); static BasicStroke focusStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[]{1.0f}, 1.0f);
protected void paintFocus(Graphics g, Rectangle t, Dimension arg2) { protected void paintFocus(Graphics g, Rectangle t, Dimension arg2) {
if (!ThemeUtils.BUTTON_FOCUS) { if (!ThemeUtils.BUTTON_FOCUS) {

1
designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java

@ -84,6 +84,7 @@ public abstract class LazyComboBox extends UIComboBox implements PopupMenuListen
LazyComboBox.this.loadList(get()); LazyComboBox.this.loadList(get());
} catch (InterruptedException | ExecutionException exception) { } catch (InterruptedException | ExecutionException exception) {
FineLoggerFactory.getLogger().debug(exception.getMessage()); FineLoggerFactory.getLogger().debug(exception.getMessage());
Thread.currentThread().interrupt();
} }
LazyComboBox.this.showPopup(); LazyComboBox.this.showPopup();
} }

1
designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java

@ -40,6 +40,7 @@ public class LazyComboBoxTest {
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
return m; return m;
} }

12
designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java

@ -127,10 +127,6 @@ public class UIComboBoxButton extends JButton {
boolean savedOpaque = false; boolean savedOpaque = false;
paintRender(g, c, mustResetOpaque, savedOpaque, leftToRight, width, insets, iconWidth, left, top, height); paintRender(g, c, mustResetOpaque, savedOpaque, leftToRight, width, insets, iconWidth, left, top, height);
if (mustResetOpaque) {
JComponent jc = (JComponent) c;
jc.setOpaque(savedOpaque);
}
} }
private void paintRender(Graphics g, Component c, boolean mustResetOpaque, boolean savedOpaque, boolean leftToRight, private void paintRender(Graphics g, Component c, boolean mustResetOpaque, boolean savedOpaque, boolean leftToRight,
@ -152,14 +148,6 @@ public class UIComboBoxButton extends JButton {
} else { } else {
rendererPane.paintComponent(g, c, this, left + iconWidth, top, cWidth, height, shouldValidate); rendererPane.paintComponent(g, c, this, left + iconWidth, top, cWidth, height, shouldValidate);
} }
if (paintFocus && ThemeUtils.COMBO_FOCUS) {
g.setColor(Color.black);
Graphics2D g2d = (Graphics2D) g;
Rectangle r = new Rectangle(left, top, 2, 2);
TexturePaint tp = new TexturePaint(focusImg, r);
g2d.setPaint(tp);
g2d.draw(new Rectangle(left, top, cWidth, height));
}
} }
} }

51
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -7,12 +7,25 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.icon.IconPathConstants; import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.IOUtils;
import javax.swing.*;
import java.awt.*; import javax.swing.JCheckBox;
import java.awt.event.*; import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
public class UICheckListPopup extends UIPopupMenu { public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>(); private List<ActionListener> listeners = new ArrayList<ActionListener>();
@ -66,10 +79,10 @@ public class UICheckListPopup extends UIPopupMenu {
} }
addSelectListener(); addSelectListener();
jScrollPane.setPreferredSize(new Dimension(200, checkBoxList.size() * CHECKBOX_HEIGHT + 10)); jScrollPane.setPreferredSize(new Dimension(130, checkBoxList.size() * CHECKBOX_HEIGHT + 10));
//超过1页的数量时显示滚动条 //超过1页的数量时显示滚动条
if (checkBoxList.size() > maxDisplayNumber) { if (checkBoxList.size() > maxDisplayNumber) {
jScrollPane.setPreferredSize(new Dimension(200, maxDisplayNumber * CHECKBOX_HEIGHT)); jScrollPane.setPreferredSize(new Dimension(130, maxDisplayNumber * CHECKBOX_HEIGHT));
} }
checkboxPane.repaint(); checkboxPane.repaint();
jScrollPane.repaint(); jScrollPane.repaint();
@ -77,11 +90,11 @@ public class UICheckListPopup extends UIPopupMenu {
private void addOneCheckValue(Object checkValue) { private void addOneCheckValue(Object checkValue) {
JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
checkPane.setPreferredSize(new Dimension(185, CHECKBOX_HEIGHT)); checkPane.setPreferredSize(new Dimension(120, CHECKBOX_HEIGHT));
final JCheckBox temp = createCheckbox(); final JCheckBox temp = createCheckbox();
final UILabel label = new UILabel(checkValue.toString()); final UILabel label = new UILabel(checkValue.toString());
label.setBackground(Color.WHITE); label.setBackground(Color.WHITE);
label.setPreferredSize(new Dimension(156, 20)); label.setPreferredSize(new Dimension(80, 20));
checkPane.setBackground(Color.WHITE); checkPane.setBackground(Color.WHITE);
checkPane.add(temp); checkPane.add(temp);
checkPane.add(label); checkPane.add(label);
@ -95,8 +108,8 @@ public class UICheckListPopup extends UIPopupMenu {
JCheckBox checkBox = new JCheckBox(); JCheckBox checkBox = new JCheckBox();
checkBox.setPreferredSize(new Dimension(20, 20)); checkBox.setPreferredSize(new Dimension(20, 20));
checkBox.setBackground(Color.WHITE); checkBox.setBackground(Color.WHITE);
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); checkBox.setIcon(IOUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL));
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); checkBox.setSelectedIcon(IOUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED));
return checkBox; return checkBox;
} }
@ -109,10 +122,12 @@ public class UICheckListPopup extends UIPopupMenu {
*/ */
private void addMouseListener(final JCheckBox checkBox, final UILabel label) { private void addMouseListener(final JCheckBox checkBox, final UILabel label) {
label.addMouseListener(new MouseAdapter() { label.addMouseListener(new MouseAdapter() {
@Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
label.setBackground(Color.WHITE); label.setBackground(Color.WHITE);
} }
@Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
label.setOpaque(true); label.setOpaque(true);
label.setBackground(mouseEnteredColor); label.setBackground(mouseEnteredColor);
@ -133,6 +148,7 @@ public class UICheckListPopup extends UIPopupMenu {
JCheckBox checkBox = checkBoxList.get(i); JCheckBox checkBox = checkBoxList.get(i);
if (i == 0) { if (i == 0) {
checkBox.addItemListener(new ItemListener() { checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
//全选checkbox事件 //全选checkbox事件
doSelectAll(checkBoxList.get(0).isSelected()); doSelectAll(checkBoxList.get(0).isSelected());
@ -140,6 +156,7 @@ public class UICheckListPopup extends UIPopupMenu {
}); });
} else { } else {
checkBox.addItemListener(new ItemListener() { checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
//do半选判断放在commit事件里 //do半选判断放在commit事件里
commit(); commit();
@ -157,10 +174,19 @@ public class UICheckListPopup extends UIPopupMenu {
private void doSelectAll(boolean isSelected) { private void doSelectAll(boolean isSelected) {
for (int i = 1; i < checkBoxList.size(); i++) { for (int i = 1; i < checkBoxList.size(); i++) {
//全选和反全选都不考虑全选按钮本身 //全选和反全选都不考虑全选按钮本身
if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) {
checkBoxList.get(i).setSelected(isSelected); checkBoxList.get(i).setSelected(isSelected);
} }
} }
}
public void setSelectedValue(Map<Object, Boolean> selectedValues) {
List<Object> allValue = Arrays.asList(values);
for (Object value : selectedValues.keySet()) {
int index = allValue.indexOf(value);
checkBoxList.get(index + 1).setSelected(selectedValues.get(value));
}
}
/** /**
* 获取所有选中的值 * 获取所有选中的值
@ -214,9 +240,10 @@ public class UICheckListPopup extends UIPopupMenu {
} }
public void addActionListener(ActionListener listener) { public void addActionListener(ActionListener listener) {
if (!listeners.contains(listener)) if (!listeners.contains(listener)) {
listeners.add(listener); listeners.add(listener);
} }
}
public void removeActionListener(ActionListener listener) { public void removeActionListener(ActionListener listener) {
if (listeners.contains(listener)) { if (listeners.contains(listener)) {

27
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -11,14 +11,23 @@ import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.Icon;
import java.awt.*; import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.FontMetrics;
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;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 设计器下拉复选框组件 * 设计器下拉复选框组件
@ -125,7 +134,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private UITextField createEditor() { private UITextField createEditor() {
UITextField editor = new UITextField(); UITextField editor = new UITextField();
editor.setEditable(false); editor.setEditable(false);
editor.setPreferredSize(new Dimension(180, 20)); editor.setPreferredSize(new Dimension(110, 20));
addPopupListener(editor); addPopupListener(editor);
return editor; return editor;
@ -138,6 +147,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
*/ */
private void addPopupListener(Component component) { private void addPopupListener(Component component) {
component.addMouseListener(new MouseAdapter() { component.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
togglePopup(); togglePopup();
} }
@ -166,6 +176,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private class PopupAction implements ActionListener { private class PopupAction implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) { if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) {
selectedValues = popup.getSelectedValues(); selectedValues = popup.getSelectedValues();
@ -292,14 +303,16 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
} }
public void addActionListener(ActionListener listener) { public void addActionListener(ActionListener listener) {
if (!listeners.contains(listener)) if (!listeners.contains(listener)) {
listeners.add(listener); listeners.add(listener);
} }
}
public void removeActionListener(ActionListener listener) { public void removeActionListener(ActionListener listener) {
if (listeners.contains(listener)) if (listeners.contains(listener)) {
listeners.remove(listener); listeners.remove(listener);
} }
}
protected void fireActionPerformed(ActionEvent e) { protected void fireActionPerformed(ActionEvent e) {
for (ActionListener l : listeners) { for (ActionListener l : listeners) {
@ -307,6 +320,10 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
} }
} }
public void setSelectedValues(Map<Object, Boolean> map) {
popup.setSelectedValue(map);
}
/** /**
* 简单的测试demo * 简单的测试demo
* @param args * @param args

5
designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java

@ -438,11 +438,6 @@ public class UIResizableContainer extends JPanel {
containerWidth = containerWidth > MAX_WIDTH ? MAX_WIDTH : containerWidth; containerWidth = containerWidth > MAX_WIDTH ? MAX_WIDTH : containerWidth;
containerWidth = containerWidth < MIN_WIDTH ? MIN_WIDTH : containerWidth; containerWidth = containerWidth < MIN_WIDTH ? MIN_WIDTH : containerWidth;
if (containerWidth < MIN_WIDTH) {
upPane.setVisible(false);
downPane.setVisible(false);
containerWidth = toolPaneHeight;
}
refreshContainer(); refreshContainer();
if (DesignerMode.isAuthorityEditing()) { if (DesignerMode.isAuthorityEditing()) {
DesignerContext.getDesignerFrame().doResize(); DesignerContext.getDesignerFrame().doResize();

6
designer-base/src/main/java/com/fr/design/gui/ilable/MultilineLabel.java

@ -19,15 +19,15 @@ import com.fr.design.gui.itextarea.UITextArea;
*/ */
public class MultilineLabel extends UITextArea { public class MultilineLabel extends UITextArea {
public MultilineLabel() { public MultilineLabel() {
initComponents(); initCurrentComponents();
} }
public MultilineLabel(String s) { public MultilineLabel(String s) {
super(s); super(s);
initComponents(); initCurrentComponents();
} }
private void initComponents() { private void initCurrentComponents() {
adjustUI(); adjustUI();
} }

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

@ -7,6 +7,7 @@ package com.fr.design.gui.imenu;
import com.fr.design.utils.ColorRoutines; import com.fr.design.utils.ColorRoutines;
import com.fr.design.utils.ThemeUtils; import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.ActionMap; import javax.swing.ActionMap;
@ -579,7 +580,8 @@ public class UIBasicMenuItemUI extends MenuItemUI {
*/ */
private boolean isInternalFrameSystemMenu() { private boolean isInternalFrameSystemMenu() {
String actionCommand = menuItem.getActionCommand(); String actionCommand = menuItem.getActionCommand();
return (actionCommand == "Close") || (actionCommand == "Minimize") || (actionCommand == "Restore") || (actionCommand == "Maximize"); return (StringUtils.equals(actionCommand,"Close") || StringUtils.equals(actionCommand,"Minimize")
|| StringUtils.equals(actionCommand,"Restore") || StringUtils.equals(actionCommand,"Maximize"));
} }
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////

14
designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java

@ -1,5 +1,7 @@
package com.fr.design.gui.iscrollbar; package com.fr.design.gui.iscrollbar;
import com.fr.design.constants.UIConstants;
import com.fr.stable.StringUtils;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
@ -20,7 +22,6 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener; import java.awt.event.MouseMotionListener;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import javax.swing.BoundedRangeModel; import javax.swing.BoundedRangeModel;
import javax.swing.InputMap; import javax.swing.InputMap;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -38,8 +39,6 @@ import javax.swing.event.ChangeListener;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.ScrollBarUI; import javax.swing.plaf.ScrollBarUI;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import com.fr.design.constants.UIConstants;
import sun.swing.DefaultLookup; import sun.swing.DefaultLookup;
/** /**
@ -148,6 +147,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* *
* @param c * @param c
*/ */
@Override
public void installUI(JComponent c) { public void installUI(JComponent c) {
scrollbar = (JScrollBar) c; scrollbar = (JScrollBar) c;
thumbRect = new Rectangle(0, 0, 0, 0); thumbRect = new Rectangle(0, 0, 0, 0);
@ -163,6 +163,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* *
* @param c * @param c
*/ */
@Override
public void uninstallUI(JComponent c) { public void uninstallUI(JComponent c) {
scrollbar = (JScrollBar) c; scrollbar = (JScrollBar) c;
uninstallListeners(); uninstallListeners();
@ -357,6 +358,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
/** /**
* 只画Thumb * 只画Thumb
*/ */
@Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
Rectangle thumbBounds = getThumbBounds(); Rectangle thumbBounds = getThumbBounds();
if (thumbBounds.intersects(g.getClipBounds())) { if (thumbBounds.intersects(g.getClipBounds())) {
@ -380,6 +382,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* @see #getMaximumSize * @see #getMaximumSize
* @see #getMinimumSize * @see #getMinimumSize
*/ */
@Override
public Dimension getPreferredSize(JComponent c) { public Dimension getPreferredSize(JComponent c) {
return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth); return (scrollbar.getOrientation() == JScrollBar.VERTICAL) ? new Dimension(scrollBarWidth, 48) : new Dimension(48, scrollBarWidth);
} }
@ -390,6 +393,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* @see #getMinimumSize * @see #getMinimumSize
* @see #getPreferredSize * @see #getPreferredSize
*/ */
@Override
public Dimension getMaximumSize(JComponent c) { public Dimension getMaximumSize(JComponent c) {
return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
} }
@ -937,6 +941,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
private transient int direction = +1; private transient int direction = +1;
@Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
isPressing = false; isPressing = false;
if (isDragging) { if (isDragging) {
@ -968,6 +973,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
* one page. If there is no thumb then page up if the mouse is in the * one page. If there is no thumb then page up if the mouse is in the
* upper half of the track. * upper half of the track.
*/ */
@Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e); boolean isMiddle = !isSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton(e);
if (SwingUtilities.isRightMouseButton(e) || isMiddle) { if (SwingUtilities.isRightMouseButton(e) || isMiddle) {
@ -1313,7 +1319,7 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo
public void propertyChange(PropertyChangeEvent e) { public void propertyChange(PropertyChangeEvent e) {
String propertyName = e.getPropertyName(); String propertyName = e.getPropertyName();
if ("model" == propertyName) { if (StringUtils.equals("model", propertyName)) {
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue(); BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue();
BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue(); BoundedRangeModel newModel = (BoundedRangeModel) e.getNewValue();
oldModel.removeChangeListener(modelListener); oldModel.removeChangeListener(modelListener);

31
designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java

@ -0,0 +1,31 @@
package com.fr.design.gui.ispinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
/**
* Created by IntelliJ IDEA.
* Author : Hugh.C
* Date: 19-08-28
* Time: 下午2:19
*/
public class UnsignedIntUISpinner extends UISpinner {
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
}
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
}
@Override
protected UINumberField initNumberField() {
return new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
};
}
}

31
designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java

@ -3,11 +3,15 @@
*/ */
package com.fr.design.gui.itable; package com.fr.design.gui.itable;
import java.awt.*; import com.fr.general.ComparatorUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -16,9 +20,6 @@ import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import com.fr.general.ComparatorUtils;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
@ -109,8 +110,8 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public TableCellEditor getCellEditor(int row, int column) { public TableCellEditor getCellEditor(int row, int column) {
if (groups != null) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (groups != null && pIndex != null) {
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y == 0) { if (pIndex.y == 0) {
return super.getCellEditor(row, column); return super.getCellEditor(row, column);
@ -162,7 +163,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() > 1) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() > 1) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -180,7 +181,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -263,6 +264,9 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public void setValueAt(Object aValue, int row, int column) { public void setValueAt(Object aValue, int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex == null) {
return;
}
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y != 0) { if (pIndex.y != 0) {
Object old_value = getValueAt(row, column); Object old_value = getValueAt(row, column);
@ -276,16 +280,11 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
PropertyGroup group = groups.get(pIndex.x); if (pIndex == null) {
if (pIndex.y == 0) {
if (column == 0) {
return false;
} else {
return false; return false;
} }
} else { PropertyGroup group = groups.get(pIndex.x);
return column == 1 && group.getModel().isEditable(pIndex.y - 1); return pIndex.y != 0 && (column == 1 && group.getModel().isEditable(pIndex.y - 1));
}
} }
} }
} }

2
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

@ -244,7 +244,7 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); FineLoggerFactory.getLogger().error(ee.getMessage(), ee);
} }
} }
if (getRowCount() < 1 || selectedRow.length < 0) { if (getRowCount() < 1) {
return; return;
} }

3
designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java

@ -153,6 +153,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
try { try {
Thread.sleep(3); Thread.sleep(3);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
} }
} }
if (currentPanel != panel) { if (currentPanel != panel) {
@ -202,7 +203,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
} }
@Override @Override
public int getSelectedIndex() { public synchronized int getSelectedIndex() {
return selectedIndex; return selectedIndex;
} }

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

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

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

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

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

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

1
designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java

@ -127,6 +127,7 @@ public class NumberDragBar extends JComponent {
revalidate(); revalidate();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.toString()); FineLoggerFactory.getLogger().error(e.toString());
Thread.currentThread().interrupt();
} }
} }
}); });

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

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

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java

@ -366,7 +366,9 @@ public class RSyntaxDocument extends RDocument implements Iterable<Token>,
*/ */
public boolean getShouldIndentNextLine(int line) { public boolean getShouldIndentNextLine(int line) {
Token t = getTokenListForLine(line); Token t = getTokenListForLine(line);
if (t != null) {
t = t.getLastNonCommentNonWhitespaceToken(); t = t.getLastNonCommentNonWhitespaceToken();
}
return tokenMaker.getShouldIndentNextLineAfter(t); return tokenMaker.getShouldIndentNextLineAfter(t);
} }

404
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java

File diff suppressed because it is too large Load Diff

369
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java

@ -9,6 +9,24 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
import javax.swing.JLabel;
import javax.swing.JViewport;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.Position;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import java.awt.Color; import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Point; import java.awt.Point;
@ -16,23 +34,9 @@ import java.awt.Rectangle;
import java.awt.Shape; import java.awt.Shape;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Caret;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.Position;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane;
/** /**
@ -122,7 +126,7 @@ public class RSyntaxUtilities implements SwingConstants {
/** /**
* Used internally. * Used internally.
*/ */
private static final char[] JS_KEYWORD_RETURN = { 'r', 'e', 't', 'u', 'r', 'n' }; private static final char[] JS_KEYWORD_RETURN = {'r', 'e', 't', 'u', 'r', 'n'};
/** /**
* Used internally. * Used internally.
@ -146,10 +150,10 @@ public class RSyntaxUtilities implements SwingConstants {
public static final String escapeForHtml(String s, public static final String escapeForHtml(String s,
String newlineReplacement, boolean inPreBlock) { String newlineReplacement, boolean inPreBlock) {
if (s==null) { if (s == null) {
return null; return null;
} }
if (newlineReplacement==null) { if (newlineReplacement == null) {
newlineReplacement = ""; newlineReplacement = "";
} }
final String tabString = " "; final String tabString = " ";
@ -157,14 +161,13 @@ public class RSyntaxUtilities implements SwingConstants {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i=0; i<s.length(); i++) { for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i); char ch = s.charAt(i);
switch (ch) { switch (ch) {
case ' ': case ' ':
if (inPreBlock || !lastWasSpace) { if (inPreBlock || !lastWasSpace) {
sb.append(' '); sb.append(' ');
} } else {
else {
sb.append("&nbsp;"); sb.append("&nbsp;");
} }
lastWasSpace = true; lastWasSpace = true;
@ -208,8 +211,8 @@ public class RSyntaxUtilities implements SwingConstants {
* @return The rendering hints, or <code>null</code> if they cannot be * @return The rendering hints, or <code>null</code> if they cannot be
* determined. * determined.
*/ */
public static Map<?,?> getDesktopAntiAliasHints() { public static Map<?, ?> getDesktopAntiAliasHints() {
return (Map<?,?>)Toolkit.getDefaultToolkit(). return (Map<?, ?>) Toolkit.getDefaultToolkit().
getDesktopProperty("awt.font.desktophints"); getDesktopProperty("awt.font.desktophints");
} }
@ -223,7 +226,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static Color getFoldedLineBottomColor(RSyntaxTextArea textArea) { public static Color getFoldedLineBottomColor(RSyntaxTextArea textArea) {
Color color = Color.gray; Color color = Color.gray;
Gutter gutter = RSyntaxUtilities.getGutter(textArea); Gutter gutter = RSyntaxUtilities.getGutter(textArea);
if (gutter!=null) { if (gutter != null) {
color = gutter.getFoldIndicatorForeground(); color = gutter.getFoldIndicatorForeground();
} }
return color; return color;
@ -245,7 +248,7 @@ public class RSyntaxUtilities implements SwingConstants {
if (parent instanceof JViewport) { if (parent instanceof JViewport) {
parent = parent.getParent(); parent = parent.getParent();
if (parent instanceof RTextScrollPane) { if (parent instanceof RTextScrollPane) {
RTextScrollPane sp = (RTextScrollPane)parent; RTextScrollPane sp = (RTextScrollPane) parent;
gutter = sp.getGutter(); // Should always be non-null gutter = sp.getGutter(); // Should always be non-null
} }
} }
@ -267,7 +270,7 @@ public class RSyntaxUtilities implements SwingConstants {
// This property is defined by all standard LaFs, even Nimbus (!), // This property is defined by all standard LaFs, even Nimbus (!),
// but you never know what crazy LaFs there are... // but you never know what crazy LaFs there are...
Color fg = UIManager.getColor("Label.foreground"); Color fg = UIManager.getColor("Label.foreground");
if (fg==null) { if (fg == null) {
fg = new JLabel().getForeground(); fg = new JLabel().getForeground();
} }
@ -286,7 +289,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static String getLeadingWhitespace(String text) { public static String getLeadingWhitespace(String text) {
int count = 0; int count = 0;
int len = text.length(); int len = text.length();
while (count<len && RSyntaxUtilities.isWhitespace(text.charAt(count))) { while (count < len && RSyntaxUtilities.isWhitespace(text.charAt(count))) {
count++; count++;
} }
return text.substring(0, count); return text.substring(0, count);
@ -310,7 +313,7 @@ public class RSyntaxUtilities implements SwingConstants {
Element elem = root.getElement(line); Element elem = root.getElement(line);
int startOffs = elem.getStartOffset(); int startOffs = elem.getStartOffset();
int endOffs = elem.getEndOffset() - 1; int endOffs = elem.getEndOffset() - 1;
String text = doc.getText(startOffs, endOffs-startOffs); String text = doc.getText(startOffs, endOffs - startOffs);
return getLeadingWhitespace(text); return getLeadingWhitespace(text);
} }
@ -319,7 +322,7 @@ public class RSyntaxUtilities implements SwingConstants {
Element map = d.getDefaultRootElement(); Element map = d.getDefaultRootElement();
int index = map.getElementIndex(offs); int index = map.getElementIndex(offs);
Element elem = map.getElement(index); Element elem = map.getElement(index);
if ((offs>=elem.getStartOffset()) && (offs<elem.getEndOffset())) { if ((offs >= elem.getStartOffset()) && (offs < elem.getEndOffset())) {
return elem; return elem;
} }
return null; return null;
@ -358,13 +361,14 @@ public class RSyntaxUtilities implements SwingConstants {
int x0) int x0)
throws BadLocationException { throws BadLocationException {
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
// Ensure p0 and p1 are valid document positions. // Ensure p0 and p1 are valid document positions.
if (p0<0) if (p0 < 0) {
throw new BadLocationException("Invalid document position", p0); throw new BadLocationException("Invalid document position", p0);
else if (p1>doc.getLength()) } else if (p1 > doc.getLength()) {
throw new BadLocationException("Invalid document position", p1); throw new BadLocationException("Invalid document position", p1);
}
// Ensure p0 and p1 are in the same line, and get the start/end // Ensure p0 and p1 are in the same line, and get the start/end
// offsets for that line. // offsets for that line.
@ -373,9 +377,10 @@ public class RSyntaxUtilities implements SwingConstants {
// We do ">1" because p1 might be the first position on the next line // We do ">1" because p1 might be the first position on the next line
// or the last position on the previous one. // or the last position on the previous one.
// if (lineNum!=map.getElementIndex(p1)) // if (lineNum!=map.getElementIndex(p1))
if (Math.abs(lineNum-map.getElementIndex(p1))>1) if (Math.abs(lineNum - map.getElementIndex(p1)) > 1) {
throw new IllegalArgumentException("p0 and p1 are not on the " + throw new IllegalArgumentException("p0 and p1 are not on the " +
"same line (" + p0 + ", " + p1 + ")."); "same line (" + p0 + ", " + p1 + ").");
}
// Get the token list. // Get the token list.
Token t = doc.getTokenListForLine(lineNum); Token t = doc.getTokenListForLine(lineNum);
@ -410,7 +415,7 @@ public class RSyntaxUtilities implements SwingConstants {
public static Point getMatchingBracketPosition(RSyntaxTextArea textArea, public static Point getMatchingBracketPosition(RSyntaxTextArea textArea,
Point input) { Point input) {
if (input==null) { if (input == null) {
input = new Point(); input = new Point();
} }
input.setLocation(-1, -1); input.setLocation(-1, -1);
@ -419,25 +424,25 @@ public class RSyntaxUtilities implements SwingConstants {
// Actually position just BEFORE caret. // Actually position just BEFORE caret.
int caretPosition = textArea.getCaretPosition() - 1; int caretPosition = textArea.getCaretPosition() - 1;
RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument(); RSyntaxDocument doc = (RSyntaxDocument) textArea.getDocument();
char bracket = 0; char bracket = 0;
// If the caret was at offset 0, we can't check "to its left." // If the caret was at offset 0, we can't check "to its left."
if (caretPosition>=0) { if (caretPosition >= 0) {
bracket = doc.charAt(caretPosition); bracket = doc.charAt(caretPosition);
} }
// Try to match a bracket "to the right" of the caret if one // Try to match a bracket "to the right" of the caret if one
// was not found on the left. // was not found on the left.
int index = BRACKETS.indexOf(bracket); int index = BRACKETS.indexOf(bracket);
if (index==-1 && caretPosition<doc.getLength()-1) { if (index == -1 && caretPosition < doc.getLength() - 1) {
bracket = doc.charAt(++caretPosition); bracket = doc.charAt(++caretPosition);
} }
// First, see if the char was a bracket (one of "{[()]}"). // First, see if the char was a bracket (one of "{[()]}").
if (index==-1) { if (index == -1) {
index = BRACKETS.indexOf(bracket); index = BRACKETS.indexOf(bracket);
if (index==-1) { if (index == -1) {
return input; return input;
} }
} }
@ -455,14 +460,13 @@ public class RSyntaxUtilities implements SwingConstants {
Token token = doc.getTokenListForLine(curLine); Token token = doc.getTokenListForLine(curLine);
token = RSyntaxUtilities.getTokenAtOffset(token, caretPosition); token = RSyntaxUtilities.getTokenAtOffset(token, caretPosition);
// All brackets are always returned as "separators." // All brackets are always returned as "separators."
if (token.getType()!=Token.SEPARATOR) { if (Objects.requireNonNull(token).getType() != Token.SEPARATOR) {
return input; return input;
} }
if (index<3) { // One of "{[(" if (index < 3) { // One of "{[("
goForward = true; goForward = true;
bracketMatch = BRACKETS.charAt(index + 3); bracketMatch = BRACKETS.charAt(index + 3);
} } else { // One of ")]}"
else { // One of ")]}"
goForward = false; goForward = false;
bracketMatch = BRACKETS.charAt(index - 3); bracketMatch = BRACKETS.charAt(index - 3);
} }
@ -479,33 +483,32 @@ public class RSyntaxUtilities implements SwingConstants {
while (true) { while (true) {
doc.getText(start,end-start, charSegment); doc.getText(start, end - start, charSegment);
int segOffset = charSegment.offset; int segOffset = charSegment.offset;
for (int i=segOffset; i<segOffset+charSegment.count; i++) { for (int i = segOffset; i < segOffset + charSegment.count; i++) {
char ch = charSegment.array[i]; char ch = charSegment.array[i];
if (ch==bracket) { if (ch == bracket) {
if (haveTokenList==false) { if (!haveTokenList) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
token = RSyntaxUtilities.getTokenAtOffset(token, offset); token = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (token.getType()==Token.SEPARATOR) if (Objects.requireNonNull(token).getType() == Token.SEPARATOR) {
numEmbedded++; numEmbedded++;
} }
} else if (ch == bracketMatch) {
else if (ch==bracketMatch) { if (!haveTokenList) {
if (haveTokenList==false) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
token = RSyntaxUtilities.getTokenAtOffset(token, offset); token = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (token.getType()==Token.SEPARATOR) { if (Objects.requireNonNull(token).getType() == Token.SEPARATOR) {
if (numEmbedded==0) { if (numEmbedded == 0) {
if (textArea.isCodeFoldingEnabled() && if (textArea.isCodeFoldingEnabled() &&
textArea.getFoldManager().isLineHidden(curLine)) { textArea.getFoldManager().isLineHidden(curLine)) {
return input; // Match hidden in a fold return input; // Match hidden in a fold
@ -521,8 +524,9 @@ public class RSyntaxUtilities implements SwingConstants {
// Bail out if we've gone through all lines and // Bail out if we've gone through all lines and
// haven't found the match. // haven't found the match.
if (++curLine==lastLine) if (++curLine == lastLine) {
return input; return input;
}
// Otherwise, go through the next line. // Otherwise, go through the next line.
haveTokenList = false; haveTokenList = false;
@ -548,34 +552,33 @@ public class RSyntaxUtilities implements SwingConstants {
while (true) { while (true) {
doc.getText(start,end-start, charSegment); doc.getText(start, end - start, charSegment);
int segOffset = charSegment.offset; int segOffset = charSegment.offset;
int iStart = segOffset + charSegment.count - 1; int iStart = segOffset + charSegment.count - 1;
for (int i=iStart; i>=segOffset; i--) { for (int i = iStart; i >= segOffset; i--) {
char ch = charSegment.array[i]; char ch = charSegment.array[i];
if (ch==bracket) { if (ch == bracket) {
if (haveTokenList==false) { if (!haveTokenList) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
t2 = RSyntaxUtilities.getTokenAtOffset(token, offset); t2 = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (t2.getType()==Token.SEPARATOR) if (Objects.requireNonNull(t2).getType() == Token.SEPARATOR) {
numEmbedded++; numEmbedded++;
} }
} else if (ch == bracketMatch) {
else if (ch==bracketMatch) { if (!haveTokenList) {
if (haveTokenList==false) {
token = doc.getTokenListForLine(curLine); token = doc.getTokenListForLine(curLine);
haveTokenList = true; haveTokenList = true;
} }
int offset = start + (i-segOffset); int offset = start + (i - segOffset);
t2 = RSyntaxUtilities.getTokenAtOffset(token, offset); t2 = RSyntaxUtilities.getTokenAtOffset(token, offset);
if (t2.getType()==Token.SEPARATOR) { if (Objects.requireNonNull(t2).getType() == Token.SEPARATOR) {
if (numEmbedded==0) { if (numEmbedded == 0) {
input.setLocation(caretPosition, offset); input.setLocation(caretPosition, offset);
return input; return input;
} }
@ -587,7 +590,7 @@ public class RSyntaxUtilities implements SwingConstants {
// Bail out if we've gone through all lines and // Bail out if we've gone through all lines and
// haven't found the match. // haven't found the match.
if (--curLine==-1) { if (--curLine == -1) {
return input; return input;
} }
@ -625,10 +628,10 @@ public class RSyntaxUtilities implements SwingConstants {
*/ */
public static final Token getNextImportantToken(Token t, public static final Token getNextImportantToken(Token t,
RSyntaxTextArea textArea, int line) { RSyntaxTextArea textArea, int line) {
while (t!=null && t.isPaintable() && t.isCommentOrWhitespace()) { while (t != null && t.isPaintable() && t.isCommentOrWhitespace()) {
t = t.getNextToken(); t = t.getNextToken();
} }
if ((t==null || !t.isPaintable()) && line<textArea.getLineCount()-1) { if ((t == null || !t.isPaintable()) && line < textArea.getLineCount() - 1) {
t = textArea.getTokenListForLine(++line); t = textArea.getTokenListForLine(++line);
return getNextImportantToken(t, textArea, line); return getNextImportantToken(t, textArea, line);
} }
@ -642,7 +645,7 @@ public class RSyntaxUtilities implements SwingConstants {
* Some views may not be visible, * Some views may not be visible,
* they might not be in the same order found in the model, or they just * they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model.<p> * might not allow access to some of the locations in the model.<p>
* * <p>
* NOTE: You should only call this method if the passed-in * NOTE: You should only call this method if the passed-in
* <code>javax.swing.text.View</code> is an instance of * <code>javax.swing.text.View</code> is an instance of
* {@link TokenOrientedView} and <code>javax.swing.text.TabExpander</code>; * {@link TokenOrientedView} and <code>javax.swing.text.TabExpander</code>;
@ -661,8 +664,8 @@ public class RSyntaxUtilities implements SwingConstants {
* </ul> * </ul>
* @return the location within the model that best represents the next * @return the location within the model that best represents the next
* location visual position * location visual position
* @exception BadLocationException * @throws BadLocationException
* @exception IllegalArgumentException if <code>direction</code> * @throws IllegalArgumentException if <code>direction</code>
* doesn't have one of the legal values above * doesn't have one of the legal values above
*/ */
public static int getNextVisualPositionFrom(int pos, Position.Bias b, public static int getNextVisualPositionFrom(int pos, Position.Bias b,
@ -670,7 +673,7 @@ public class RSyntaxUtilities implements SwingConstants {
Position.Bias[] biasRet, View view) Position.Bias[] biasRet, View view)
throws BadLocationException { throws BadLocationException {
RSyntaxTextArea target = (RSyntaxTextArea)view.getContainer(); RSyntaxTextArea target = (RSyntaxTextArea) view.getContainer();
biasRet[0] = Position.Bias.Forward; biasRet[0] = Position.Bias.Forward;
// Do we want the "next position" above, below, to the left or right? // Do we want the "next position" above, below, to the left or right?
@ -688,37 +691,39 @@ public class RSyntaxUtilities implements SwingConstants {
// YECK! Ideally, the x location from the magic caret // YECK! Ideally, the x location from the magic caret
// position would be passed in. // position would be passed in.
Point mcp; Point mcp;
if (c != null) if (c != null) {
mcp = c.getMagicCaretPosition(); mcp = c.getMagicCaretPosition();
else } else {
mcp = null; mcp = null;
}
int x; int x;
if (mcp == null) { if (mcp == null) {
Rectangle loc = target.modelToView(pos); Rectangle loc = Objects.requireNonNull(target).modelToView(pos);
x = (loc == null) ? 0 : loc.x; x = (loc == null) ? 0 : loc.x;
} } else {
else {
x = mcp.x; x = mcp.x;
} }
if (direction == NORTH) if (direction == NORTH) {
pos = getPositionAbove(target,pos,x,(TabExpander)view); pos = getPositionAbove(target, pos, x, (TabExpander) view);
else } else {
pos = getPositionBelow(target,pos,x,(TabExpander)view); pos = getPositionBelow(target, pos, x, (TabExpander) view);
}
break; break;
case WEST: case WEST:
if(pos == -1) { if (pos == -1) {
pos = Math.max(0, view.getEndOffset() - 1); pos = Math.max(0, view.getEndOffset() - 1);
} } else {
else {
pos = Math.max(0, pos - 1); pos = Math.max(0, pos - 1);
if (target.isCodeFoldingEnabled()) { if (target.isCodeFoldingEnabled()) {
int last = target.getLineOfOffset(pos+1); int last = target.getLineOfOffset(pos + 1);
int current = target.getLineOfOffset(pos); int current = target.getLineOfOffset(pos);
if (last!=current) { // If moving up a line... if (last != current) { // If moving up a line...
FoldManager fm = target.getFoldManager(); FoldManager fm = target.getFoldManager();
if (fm.isLineHidden(current)) { if (fm.isLineHidden(current)) {
while (--current>0 && fm.isLineHidden(current)); while (--current > 0 && fm.isLineHidden(current)) {
;
}
pos = target.getLineEndOffset(current) - 1; pos = target.getLineEndOffset(current) - 1;
} }
} }
@ -727,21 +732,22 @@ public class RSyntaxUtilities implements SwingConstants {
break; break;
case EAST: case EAST:
if(pos == -1) { if (pos == -1) {
pos = view.getStartOffset(); pos = view.getStartOffset();
} } else {
else {
pos = Math.min(pos + 1, view.getDocument().getLength()); pos = Math.min(pos + 1, view.getDocument().getLength());
if (target.isCodeFoldingEnabled()) { if (target.isCodeFoldingEnabled()) {
int last = target.getLineOfOffset(pos-1); int last = target.getLineOfOffset(pos - 1);
int current = target.getLineOfOffset(pos); int current = target.getLineOfOffset(pos);
if (last!=current) { // If moving down a line... if (last != current) { // If moving down a line...
FoldManager fm = target.getFoldManager(); FoldManager fm = target.getFoldManager();
if (fm.isLineHidden(current)) { if (fm.isLineHidden(current)) {
int lineCount = target.getLineCount(); int lineCount = target.getLineCount();
while (++current<lineCount && fm.isLineHidden(current)); while (++current < lineCount && fm.isLineHidden(current)) {
pos = current==lineCount ? ;
target.getLineEndOffset(last)-1 : // Was the last visible line }
pos = current == lineCount ?
target.getLineEndOffset(last) - 1 : // Was the last visible line
target.getLineStartOffset(current); target.getLineStartOffset(current);
} }
} }
@ -770,23 +776,22 @@ public class RSyntaxUtilities implements SwingConstants {
* @param x the X coordinate >= 0 * @param x the X coordinate >= 0
* @return the position >= 0 if the request can be computed, otherwise * @return the position >= 0 if the request can be computed, otherwise
* a value of -1 will be returned. * a value of -1 will be returned.
* @exception BadLocationException if the offset is out of range * @throws BadLocationException if the offset is out of range
*/ */
public static final int getPositionAbove(RSyntaxTextArea c, int offs, public static final int getPositionAbove(RSyntaxTextArea c, int offs,
float x, TabExpander e) throws BadLocationException { float x, TabExpander e) throws BadLocationException {
TokenOrientedView tov = (TokenOrientedView)e; TokenOrientedView tov = (TokenOrientedView) e;
Token token = tov.getTokenListForPhysicalLineAbove(offs); Token token = tov.getTokenListForPhysicalLineAbove(offs);
if (token==null) if (token == null) {
return -1; return -1;
}
// A line containing only Token.NULL is an empty line. // A line containing only Token.NULL is an empty line.
else if (token.getType()==Token.NULL) { else if (token.getType() == Token.NULL) {
int line = c.getLineOfOffset(offs); // Sure to be >0 ?? int line = c.getLineOfOffset(offs); // Sure to be >0 ??
return c.getLineStartOffset(line-1); return c.getLineStartOffset(line - 1);
} } else {
else {
return token.getListOffset(c, e, 0, x); return token.getListOffset(c, e, 0, x);
} }
@ -804,26 +809,25 @@ public class RSyntaxUtilities implements SwingConstants {
* @param x the X coordinate >= 0 * @param x the X coordinate >= 0
* @return the position >= 0 if the request can be computed, otherwise * @return the position >= 0 if the request can be computed, otherwise
* a value of -1 will be returned. * a value of -1 will be returned.
* @exception BadLocationException if the offset is out of range * @throws BadLocationException if the offset is out of range
*/ */
public static final int getPositionBelow(RSyntaxTextArea c, int offs, public static final int getPositionBelow(RSyntaxTextArea c, int offs,
float x, TabExpander e) throws BadLocationException { float x, TabExpander e) throws BadLocationException {
TokenOrientedView tov = (TokenOrientedView)e; TokenOrientedView tov = (TokenOrientedView) e;
Token token = tov.getTokenListForPhysicalLineBelow(offs); Token token = tov.getTokenListForPhysicalLineBelow(offs);
if (token==null) if (token == null) {
return -1; return -1;
}
// A line containing only Token.NULL is an empty line. // A line containing only Token.NULL is an empty line.
else if (token.getType()==Token.NULL) { else if (token.getType() == Token.NULL) {
int line = c.getLineOfOffset(offs); // Sure to be > c.getLineCount()-1 ?? int line = c.getLineOfOffset(offs); // Sure to be > c.getLineCount()-1 ??
// return c.getLineStartOffset(line+1); // return c.getLineStartOffset(line+1);
FoldManager fm = c.getFoldManager(); FoldManager fm = c.getFoldManager();
line = fm.getVisibleLineBelow(line); line = fm.getVisibleLineBelow(line);
return c.getLineStartOffset(line); return c.getLineStartOffset(line);
} } else {
else {
return token.getListOffset(c, e, 0, x); return token.getListOffset(c, e, 0, x);
} }
@ -841,18 +845,18 @@ return c.getLineStartOffset(line);
* @see #getNextImportantToken(Token, RSyntaxTextArea, int) * @see #getNextImportantToken(Token, RSyntaxTextArea, int)
*/ */
public static final Token getPreviousImportantToken( public static final Token getPreviousImportantToken(
RSyntaxTextArea textArea, int line){ RSyntaxTextArea textArea, int line) {
if (line<0) { if (line < 0) {
return null; return null;
} }
Token t = textArea.getTokenListForLine(line); Token t = textArea.getTokenListForLine(line);
if (t!=null) { if (t != null) {
t = t.getLastNonCommentNonWhitespaceToken(); t = t.getLastNonCommentNonWhitespaceToken();
if (t!=null) { if (t != null) {
return t; return t;
} }
} }
return getPreviousImportantToken(textArea, line-1); return getPreviousImportantToken(textArea, line - 1);
} }
@ -868,10 +872,11 @@ return c.getLineStartOffset(line);
* none of the tokens are at that offset. * none of the tokens are at that offset.
*/ */
public static final Token getTokenAtOffset(Token tokenList, int offset) { public static final Token getTokenAtOffset(Token tokenList, int offset) {
for (Token t=tokenList; t!=null && t.isPaintable(); t=t.getNextToken()){ for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
if (t.containsPosition(offset)) if (t.containsPosition(offset)) {
return t; return t;
} }
}
return null; return null;
} }
@ -895,18 +900,20 @@ return c.getLineStartOffset(line);
return offs; return offs;
} }
String s = doc.getText(offs, lineEnd-offs-1); String s = doc.getText(offs, lineEnd - offs - 1);
if (s!=null && s.length()>0) { // Should always be true if (s != null && s.length() > 0) { // Should always be true
int i = 0; int i = 0;
int count = s.length(); int count = s.length();
char ch = s.charAt(i); char ch = s.charAt(i);
if (Character.isWhitespace(ch)) { if (Character.isWhitespace(ch)) {
while (i<count && Character.isWhitespace(s.charAt(i++))); while (i < count && Character.isWhitespace(s.charAt(i++))) {
;
} }
else if (Character.isLetterOrDigit(ch)) { } else if (Character.isLetterOrDigit(ch)) {
while (i<count && Character.isLetterOrDigit(s.charAt(i++))); while (i < count && Character.isLetterOrDigit(s.charAt(i++))) {
;
} }
else { } else {
i = 2; i = 2;
} }
offs += i - 1; offs += i - 1;
@ -935,23 +942,22 @@ return c.getLineStartOffset(line);
} }
int lineStart = line.getStartOffset(); int lineStart = line.getStartOffset();
if (offs==lineStart) { // Start of the line. if (offs == lineStart) { // Start of the line.
return offs; return offs;
} }
int endOffs = Math.min(offs+1, doc.getLength()); int endOffs = Math.min(offs + 1, doc.getLength());
String s = doc.getText(lineStart, endOffs-lineStart); String s = doc.getText(lineStart, endOffs - lineStart);
if(s != null && s.length() > 0) { if (s != null && s.length() > 0) {
int i = s.length() - 1; int i = s.length() - 1;
char ch = s.charAt(i); char ch = s.charAt(i);
if (Character.isWhitespace(ch)) { if (Character.isWhitespace(ch)) {
while (i>0 && Character.isWhitespace(s.charAt(i-1))) { while (i > 0 && Character.isWhitespace(s.charAt(i - 1))) {
i--; i--;
} }
offs = lineStart + i; offs = lineStart + i;
} } else if (Character.isLetterOrDigit(ch)) {
else if (Character.isLetterOrDigit(ch)) { while (i > 0 && Character.isLetterOrDigit(s.charAt(i - 1))) {
while (i>0 && Character.isLetterOrDigit(s.charAt(i-1))) {
i--; i--;
} }
offs = lineStart + i; offs = lineStart + i;
@ -968,7 +974,7 @@ return c.getLineStartOffset(line);
* Determines the width of the given token list taking tabs * Determines the width of the given token list taking tabs
* into consideration. This is implemented in a 1.1 style coordinate * into consideration. This is implemented in a 1.1 style coordinate
* system where ints are used and 72dpi is assumed.<p> * system where ints are used and 72dpi is assumed.<p>
* * <p>
* This method also assumes that the passed-in token list begins at * This method also assumes that the passed-in token list begins at
* x-pixel <code>0</code> in the view (for tab purposes). * x-pixel <code>0</code> in the view (for tab purposes).
* *
@ -1000,7 +1006,7 @@ return c.getLineStartOffset(line);
RSyntaxTextArea textArea, RSyntaxTextArea textArea,
TabExpander e, float x0) { TabExpander e, float x0) {
float width = x0; float width = x0;
for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
width += t.getWidth(textArea, e, width); width += t.getWidth(textArea, e, width);
} }
return width - x0; return width - x0;
@ -1029,12 +1035,12 @@ return c.getLineStartOffset(line);
RSyntaxTextArea textArea, TabExpander e, RSyntaxTextArea textArea, TabExpander e,
float x0, int upTo) { float x0, int upTo) {
float width = 0; float width = 0;
for (Token t=tokenList; t!=null&&t.isPaintable(); t=t.getNextToken()) { for (Token t = tokenList; t != null && t.isPaintable(); t = t.getNextToken()) {
if (t.containsPosition(upTo)) { if (t.containsPosition(upTo)) {
return width + t.getWidthUpTo(upTo-t.getOffset(), textArea, e, return width + t.getWidthUpTo(upTo - t.getOffset(), textArea, e,
x0+width); x0 + width);
} }
width += t.getWidth(textArea, e, x0+width); width += t.getWidth(textArea, e, x0 + width);
} }
return width; return width;
} }
@ -1052,7 +1058,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it might be that ch>255, and thus // We need the first condition as it might be that ch>255, and thus
// not in our table. '}' is the highest-valued char in the bracket // not in our table. '}' is the highest-valued char in the bracket
// set. // set.
return ch<='}' && (dataTable[ch]&BRACKET_MASK)>0; return ch <= '}' && (dataTable[ch] & BRACKET_MASK) > 0;
} }
@ -1066,7 +1072,7 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the digit mask). // that table position has the digit mask).
return ch>='0' && ch<='9'; return ch >= '0' && ch <= '9';
} }
@ -1082,7 +1088,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). 'f' is the highest-valued // not a valid index into our table). 'f' is the highest-valued
// char that is a valid hex character. // char that is a valid hex character.
return (ch<='f') && (dataTable[ch]&HEX_CHARACTER_MASK)>0; return (ch <= 'f') && (dataTable[ch] & HEX_CHARACTER_MASK) > 0;
} }
@ -1097,7 +1103,7 @@ return c.getLineStartOffset(line);
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). '~' is the highest-valued // not a valid index into our table). '~' is the highest-valued
// char that is a valid Java operator. // char that is a valid Java operator.
return (ch<='~') && (dataTable[ch]&JAVA_OPERATOR_MASK)>0; return (ch <= '~') && (dataTable[ch] & JAVA_OPERATOR_MASK) > 0;
} }
@ -1110,7 +1116,7 @@ return c.getLineStartOffset(line);
public static final boolean isLetter(char ch) { public static final boolean isLetter(char ch) {
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). // not a valid index into our table).
return (ch<='z') && (dataTable[ch]&LETTER_MASK)>0; return (ch <= 'z') && (dataTable[ch] & LETTER_MASK) > 0;
} }
@ -1123,7 +1129,7 @@ return c.getLineStartOffset(line);
public static final boolean isLetterOrDigit(char ch) { public static final boolean isLetterOrDigit(char ch) {
// We need the first condition as it could be that ch>255 (and thus // We need the first condition as it could be that ch>255 (and thus
// not a valid index into our table). // not a valid index into our table).
return (ch<='z') && (dataTable[ch]&LETTER_OR_DIGIT_MASK)>0; return (ch <= 'z') && (dataTable[ch] & LETTER_OR_DIGIT_MASK) > 0;
} }
@ -1137,7 +1143,7 @@ return c.getLineStartOffset(line);
* @see #getHyperlinkForeground() * @see #getHyperlinkForeground()
*/ */
public static final boolean isLightForeground(Color fg) { public static final boolean isLightForeground(Color fg) {
return fg.getRed()>0xa0 && fg.getGreen()>0xa0 && fg.getBlue()>0xa0; return fg.getRed() > 0xa0 && fg.getGreen() > 0xa0 && fg.getBlue() > 0xa0;
} }
@ -1153,7 +1159,7 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the whitespace mask). // that table position has the whitespace mask).
return ch==' ' || ch=='\t'; return ch == ' ' || ch == '\t';
} }
@ -1168,21 +1174,21 @@ return c.getLineStartOffset(line);
public static boolean regexCanFollowInJavaScript(Token t) { public static boolean regexCanFollowInJavaScript(Token t) {
char ch; char ch;
// We basically try to mimic Eclipse's JS editor's behavior here. // We basically try to mimic Eclipse's JS editor's behavior here.
return t==null || return t == null ||
//t.isOperator() || //t.isOperator() ||
(t.length()==1 && ( (t.length() == 1 && (
(ch=t.charAt(0))=='=' || (ch = t.charAt(0)) == '=' ||
ch=='(' || ch == '(' ||
ch==',' || ch == ',' ||
ch=='?' || ch == '?' ||
ch==':' || ch == ':' ||
ch=='[' || ch == '[' ||
ch=='!' || ch == '!' ||
ch=='&' ch == '&'
)) || )) ||
/* Operators "==", "===", "!=", "!==" */ /* Operators "==", "===", "!=", "!==" */
(t.getType()==Token.OPERATOR && (t.getType() == Token.OPERATOR &&
t.charAt(t.length()-1)=='=') || t.charAt(t.length() - 1) == '=') ||
t.is(Token.RESERVED_WORD_2, JS_KEYWORD_RETURN); t.is(Token.RESERVED_WORD_2, JS_KEYWORD_RETURN);
} }
@ -1203,8 +1209,9 @@ return c.getLineStartOffset(line);
// We do it this way as we'd need to do two conditions anyway (first // We do it this way as we'd need to do two conditions anyway (first
// to check that ch<255 so it can index into our table, then whether // to check that ch<255 so it can index into our table, then whether
// that table position has the upper-case mask). // that table position has the upper-case mask).
if (ch>='A' && ch<='Z') if (ch >= 'A' && ch <= 'Z') {
return (char)(ch | 0x20); return (char) (ch | 0x20);
}
return ch; return ch;
} }
@ -1231,17 +1238,18 @@ return c.getLineStartOffset(line);
private static final int getOSImpl() { private static final int getOSImpl() {
int os = OS_OTHER; int os = OS_OTHER;
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if (osName!=null) { // Should always be true. if (osName != null) { // Should always be true.
osName = osName.toLowerCase(); osName = osName.toLowerCase();
if (osName.indexOf("windows") > -1) if (osName.contains("windows")) {
os = OS_WINDOWS; os = OS_WINDOWS;
else if (osName.indexOf("mac os x") > -1) } else if (osName.contains("mac os x")) {
os = OS_MAC_OSX; os = OS_MAC_OSX;
else if (osName.indexOf("linux") > -1) } else if (osName.contains("linux")) {
os = OS_LINUX; os = OS_LINUX;
else } else {
os = OS_OTHER; os = OS_OTHER;
} }
}
return os; return os;
} }
@ -1260,11 +1268,11 @@ return c.getLineStartOffset(line);
int flags = 0; int flags = 0;
if (!matchCase) { if (!matchCase) {
flags = Pattern.CASE_INSENSITIVE|Pattern.UNICODE_CASE; flags = Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE;
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i=0; i<wildcard.length(); i++) { for (int i = 0; i < wildcard.length(); i++) {
char ch = wildcard.charAt(i); char ch = wildcard.charAt(i);
switch (ch) { switch (ch) {
case '*': case '*':
@ -1274,18 +1282,23 @@ return c.getLineStartOffset(line);
sb.append('.'); sb.append('.');
break; break;
case '^': case '^':
if (i>0 || escapeStartChar) { if (i > 0 || escapeStartChar) {
sb.append('\\'); sb.append('\\');
} }
sb.append('^'); sb.append('^');
break; break;
case '\\': case '\\':
case '.': case '|': case '.':
case '+': case '-': case '|':
case '+':
case '-':
case '$': case '$':
case '[': case ']': case '[':
case '{': case '}': case ']':
case '(': case ')': case '{':
case '}':
case '(':
case ')':
sb.append('\\').append(ch); sb.append('\\').append(ch);
break; break;
default: default:

229
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java

@ -9,24 +9,37 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.text.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
* The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea} * The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea}
* when word wrap is disabled. It implements syntax highlighting for * when word wrap is disabled. It implements syntax highlighting for
* programming languages using the colors and font styles specified by the * programming languages using the colors and font styles specified by the
* <code>RSyntaxTextArea</code>.<p> * <code>RSyntaxTextArea</code>.<p>
* * <p>
* You don't really have to do anything to use this class, as * You don't really have to do anything to use this class, as
* {@link RSyntaxTextAreaUI} automatically sets the text area's view to be * {@link RSyntaxTextAreaUI} automatically sets the text area's view to be
* an instance of this class if word wrap is disabled.<p> * an instance of this class if word wrap is disabled.<p>
* * <p>
* The tokens that specify how to paint the syntax-highlighted text are gleaned * The tokens that specify how to paint the syntax-highlighted text are gleaned
* from the text area's {@link RSyntaxDocument}. * from the text area's {@link RSyntaxDocument}.
* *
@ -105,7 +118,7 @@ public class SyntaxView extends View implements TabExpander,
tabSize = getTabSize() * metrics.charWidth(' '); tabSize = getTabSize() * metrics.charWidth(' ');
Element lines = getElement(); Element lines = getElement();
int n = lines.getElementCount(); int n = lines.getElementCount();
for (int i=0; i<n; i++) { for (int i = 0; i < n; i++) {
Element line = lines.getElement(i); Element line = lines.getElement(i);
float w = getLineWidth(i); float w = getLineWidth(i);
if (w > longLineWidth) { if (w > longLineWidth) {
@ -149,8 +162,7 @@ public class SyntaxView extends View implements TabExpander,
if ((area0 != null) && (area1 != null)) { if ((area0 != null) && (area1 != null)) {
Rectangle dmg = area0.union(area1); // damage. Rectangle dmg = area0.union(area1); // damage.
host.repaint(dmg.x, dmg.y, dmg.width, dmg.height); host.repaint(dmg.x, dmg.y, dmg.width, dmg.height);
} } else
else
host.repaint(); host.repaint();
} }
} }
@ -174,8 +186,8 @@ public class SyntaxView extends View implements TabExpander,
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
token = token.getNextToken(); token = token.getNextToken();
} }
@ -212,15 +224,15 @@ public class SyntaxView extends View implements TabExpander,
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
// Selection starts in this token // Selection starts in this token
if (token.containsPosition(selStart)) { if (token.containsPosition(selStart)) {
if (selStart>token.getOffset()) { if (selStart > token.getOffset()) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selStart - tempToken.getOffset(); tempToken.textCount = selStart - tempToken.getOffset();
nextX = painter.paint(tempToken,g,nextX,y,host, this, clipStart); nextX = painter.paint(tempToken, g, nextX, y, host, this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selStart); tempToken.makeStartAt(selStart);
// Clone required since token and tempToken must be // Clone required since token and tempToken must be
@ -229,20 +241,19 @@ public class SyntaxView extends View implements TabExpander,
} }
int tokenLen = token.length(); int tokenLen = token.length();
int selCount = Math.min(tokenLen, selEnd-token.getOffset()); int selCount = Math.min(tokenLen, selEnd - token.getOffset());
if (selCount==tokenLen) { if (selCount == tokenLen) {
nextX = painter.paintSelected(token, g, nextX,y, host, nextX = painter.paintSelected(token, g, nextX, y, host,
this, clipStart); this, clipStart);
} } else {
else {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selCount; tempToken.textCount = selCount;
nextX = painter.paintSelected(tempToken, g, nextX,y, host, nextX = painter.paintSelected(tempToken, g, nextX, y, host,
this, clipStart); this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(token.getOffset() + selCount); tempToken.makeStartAt(token.getOffset() + selCount);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, nextX = painter.paint(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
@ -252,24 +263,24 @@ public class SyntaxView extends View implements TabExpander,
else if (token.containsPosition(selEnd)) { else if (token.containsPosition(selEnd)) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selEnd - tempToken.getOffset(); tempToken.textCount = selEnd - tempToken.getOffset();
nextX = painter.paintSelected(tempToken, g, nextX,y, host, this, nextX = painter.paintSelected(tempToken, g, nextX, y, host, this,
clipStart); clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selEnd); tempToken.makeStartAt(selEnd);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
// This token is entirely selected // This token is entirely selected
else if (token.getOffset()>=selStart && else if (token.getOffset() >= selStart &&
token.getEndOffset()<=selEnd) { token.getEndOffset() <= selEnd) {
nextX = painter.paintSelected(token, g, nextX,y, host, this, nextX = painter.paintSelected(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
// This token is entirely unselected // This token is entirely unselected
else { else {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
token = token.getNextToken(); token = token.getNextToken();
@ -298,10 +309,10 @@ public class SyntaxView extends View implements TabExpander,
* @return The width of the line. * @return The width of the line.
*/ */
private float getLineWidth(int lineNumber) { private float getLineWidth(int lineNumber) {
Token tokenList = ((RSyntaxDocument)getDocument()). Token tokenList = ((RSyntaxDocument) getDocument()).
getTokenListForLine(lineNumber); getTokenListForLine(lineNumber);
return RSyntaxUtilities.getTokenListWidth(tokenList, return RSyntaxUtilities.getTokenListWidth(tokenList,
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this); this);
} }
@ -320,8 +331,8 @@ public class SyntaxView extends View implements TabExpander,
* SwingConstants.NORTH, or SwingConstants.SOUTH. * SwingConstants.NORTH, or SwingConstants.SOUTH.
* @return the location within the model that best represents the next * @return the location within the model that best represents the next
* location visual position. * location visual position.
* @exception BadLocationException * @throws BadLocationException
* @exception IllegalArgumentException for an invalid direction * @throws IllegalArgumentException for an invalid direction
*/ */
@Override @Override
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
@ -341,7 +352,7 @@ public class SyntaxView extends View implements TabExpander,
* Typically the view is told to render into the span * Typically the view is told to render into the span
* that is returned, although there is no guarantee. * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view. * The parent may choose to resize or break the view.
* @exception IllegalArgumentException for an invalid axis * @throws IllegalArgumentException for an invalid axis
*/ */
@Override @Override
public float getPreferredSpan(int axis) { public float getPreferredSpan(int axis) {
@ -357,13 +368,13 @@ public class SyntaxView extends View implements TabExpander,
// We update lineHeight here as when this method is first // We update lineHeight here as when this method is first
// called, lineHeight isn't initialized. If we don't do it // called, lineHeight isn't initialized. If we don't do it
// here, we get no vertical scrollbar (as lineHeight==0). // here, we get no vertical scrollbar (as lineHeight==0).
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
// return getElement().getElementCount() * lineHeight; // return getElement().getElementCount() * lineHeight;
int visibleLineCount = getElement().getElementCount(); int visibleLineCount = getElement().getElementCount();
if (host.isCodeFoldingEnabled()) { if (host.isCodeFoldingEnabled()) {
visibleLineCount -= host.getFoldManager().getHiddenLineCount(); visibleLineCount -= host.getFoldManager().getHiddenLineCount();
} }
return visibleLineCount * lineHeight; return visibleLineCount * lineHeight;
default: default:
throw new IllegalArgumentException("Invalid axis: " + axis); throw new IllegalArgumentException("Invalid axis: " + axis);
} }
@ -378,7 +389,7 @@ return visibleLineCount * lineHeight;
*/ */
private final int getRhsCorrection() { private final int getRhsCorrection() {
int rhsCorrection = 10; int rhsCorrection = 10;
if (host!=null) { if (host != null) {
rhsCorrection = host.getRightHandSideCorrection(); rhsCorrection = host.getRightHandSideCorrection();
} }
return rhsCorrection; return rhsCorrection;
@ -391,7 +402,7 @@ return visibleLineCount * lineHeight;
* @return The tab size. * @return The tab size.
*/ */
private int getTabSize() { private int getTabSize() {
Integer i = (Integer)getDocument().getProperty( Integer i = (Integer) getDocument().getProperty(
PlainDocument.tabSizeAttribute); PlainDocument.tabSizeAttribute);
int size = (i != null) ? i.intValue() : 5; int size = (i != null) ? i.intValue() : 5;
return size; return size;
@ -411,22 +422,21 @@ return visibleLineCount * lineHeight;
* the document, <code>null</code> is returned. * the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineAbove(int offset) { public Token getTokenListForPhysicalLineAbove(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
if (fm==null) { if (fm == null) {
line--; line--;
if (line>=0) { if (line >= 0) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} } else {
else {
line = fm.getVisibleLineAbove(line); line = fm.getVisibleLineAbove(line);
if (line>=0) { if (line >= 0) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} }
// int line = map.getElementIndex(offset) - 1; // int line = map.getElementIndex(offset) - 1;
// if (line>=0) // if (line>=0)
// return document.getTokenListForLine(line); // return document.getTokenListForLine(line);
@ -447,22 +457,21 @@ else {
* line in the document, <code>null</code> is returned. * line in the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineBelow(int offset) { public Token getTokenListForPhysicalLineBelow(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int lineCount = map.getElementCount(); int lineCount = map.getElementCount();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
if (!host.isCodeFoldingEnabled()) { if (!host.isCodeFoldingEnabled()) {
if (line<lineCount-1) { if (line < lineCount - 1) {
return document.getTokenListForLine(line+1); return document.getTokenListForLine(line + 1);
} }
} } else {
else {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
line = fm.getVisibleLineBelow(line); line = fm.getVisibleLineBelow(line);
if (line>=0 && line<lineCount) { if (line >= 0 && line < lineCount) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} }
// int line = map.getElementIndex(offset); // int line = map.getElementIndex(offset);
// int lineCount = map.getElementCount(); // int lineCount = map.getElementCount();
// if (line<lineCount-1) // if (line<lineCount-1)
@ -500,13 +509,13 @@ else {
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
if (host.isCodeFoldingEnabled()) { if (host != null && host.isCodeFoldingEnabled()) {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
int hiddenCount = fm.getHiddenLineCountAbove(line); int hiddenCount = fm.getHiddenLineCountAbove(line);
line -= hiddenCount; line -= hiddenCount;
} }
r = new Rectangle(alloc.x, alloc.y + line*lineHeight, r = new Rectangle(alloc.x, alloc.y + line * lineHeight,
alloc.width, lineHeight); alloc.width, lineHeight);
} }
return r; return r;
@ -520,7 +529,7 @@ if (host.isCodeFoldingEnabled()) {
* @param pos the position to convert >= 0 * @param pos the position to convert >= 0
* @param a the allocated region to render into * @param a the allocated region to render into
* @return the bounding box of the given position * @return the bounding box of the given position
* @exception BadLocationException if the given position does not * @throws BadLocationException if the given position does not
* represent a valid location in the associated document * represent a valid location in the associated document
* @see View#modelToView * @see View#modelToView
*/ */
@ -530,7 +539,7 @@ if (host.isCodeFoldingEnabled()) {
// line coordinates // line coordinates
Element map = getElement(); Element map = getElement();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int lineIndex = map.getElementIndex(pos); int lineIndex = map.getElementIndex(pos);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
Rectangle lineArea = lineToRect(a, lineIndex); Rectangle lineArea = lineToRect(a, lineIndex);
@ -542,7 +551,7 @@ if (host.isCodeFoldingEnabled()) {
// We use this method instead as it returns the actual bounding box, // We use this method instead as it returns the actual bounding box,
// not just the x-coordinate. // not just the x-coordinate.
lineArea = tokenList.listOffsetToView( lineArea = tokenList.listOffsetToView(
(RSyntaxTextArea)getContainer(), this, pos, (RSyntaxTextArea) getContainer(), this, pos,
tabBase, lineArea); tabBase, lineArea);
return lineArea; return lineArea;
@ -554,7 +563,7 @@ if (host.isCodeFoldingEnabled()) {
* Provides a mapping, for a given region, from the document model * Provides a mapping, for a given region, from the document model
* coordinate space to the view coordinate space. The specified region is * coordinate space to the view coordinate space. The specified region is
* created as a union of the first and last character positions.<p> * created as a union of the first and last character positions.<p>
* * <p>
* This is implemented to subtract the width of the second character, as * This is implemented to subtract the width of the second character, as
* this view's <code>modelToView</code> actually returns the width of the * this view's <code>modelToView</code> actually returns the width of the
* character instead of "1" or "0" like the View implementations in * character instead of "1" or "0" like the View implementations in
@ -578,9 +587,9 @@ if (host.isCodeFoldingEnabled()) {
* @param a the area of the view, which encompasses the requested region * @param a the area of the view, which encompasses the requested region
* @return the bounding box which is a union of the region specified * @return the bounding box which is a union of the region specified
* by the first and last character positions * by the first and last character positions
* @exception BadLocationException if the given position does * @throws BadLocationException if the given position does
* not represent a valid location in the associated document * not represent a valid location in the associated document
* @exception IllegalArgumentException if <code>b0</code> or * @throws IllegalArgumentException if <code>b0</code> or
* <code>b1</code> are not one of the * <code>b1</code> are not one of the
* legal <code>Position.Bias</code> values listed above * legal <code>Position.Bias</code> values listed above
* @see View#viewToModel * @see View#viewToModel
@ -592,7 +601,7 @@ if (host.isCodeFoldingEnabled()) {
Shape s0 = modelToView(p0, a, b0); Shape s0 = modelToView(p0, a, b0);
Shape s1; Shape s1;
if (p1 ==getEndOffset()) { if (p1 == getEndOffset()) {
try { try {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
@ -600,20 +609,19 @@ if (host.isCodeFoldingEnabled()) {
} }
if (s1 == null) { if (s1 == null) {
// Assume extends left to right. // Assume extends left to right.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y, s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
1, alloc.height); 1, alloc.height);
} }
} } else {
else {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} }
Rectangle r0 = s0 instanceof Rectangle ? (Rectangle)s0 : s0.getBounds(); Rectangle r0 = s0 instanceof Rectangle ? (Rectangle) s0 : s0.getBounds();
Rectangle r1 = s1 instanceof Rectangle ? (Rectangle)s1 : s1.getBounds(); Rectangle r1 = s1 instanceof Rectangle ? (Rectangle) s1 : s1.getBounds();
if (r0.y != r1.y) { if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view. // If it spans lines, force it to be the width of the view.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
r0.x = alloc.x; r0.x = alloc.x;
r0.width = alloc.width; r0.width = alloc.width;
@ -627,7 +635,7 @@ if (host.isCodeFoldingEnabled()) {
// this, one character too many is highlighted thanks to our // this, one character too many is highlighted thanks to our
// modelToView() implementation returning the actual width of the // modelToView() implementation returning the actual width of the
// character requested! // character requested!
if (p1>p0) r0.width -= r1.width; if (p1 > p0) r0.width -= r1.width;
return r0; return r0;
@ -647,7 +655,7 @@ if (host.isCodeFoldingEnabled()) {
public float nextTabStop(float x, int tabOffset) { public float nextTabStop(float x, int tabOffset) {
if (tabSize == 0) if (tabSize == 0)
return x; return x;
int ntabs = (((int)x) - tabBase) / tabSize; int ntabs = (((int) x) - tabBase) / tabSize;
return tabBase + ((ntabs + 1) * tabSize); return tabBase + ((ntabs + 1) * tabSize);
} }
@ -662,12 +670,12 @@ if (host.isCodeFoldingEnabled()) {
@Override @Override
public void paint(Graphics g, Shape a) { public void paint(Graphics g, Shape a) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
tabBase = alloc.x; tabBase = alloc.x;
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Rectangle clip = g.getClipBounds(); Rectangle clip = g.getClipBounds();
// An attempt to speed things up for files with long lines. Note that // An attempt to speed things up for files with long lines. Note that
@ -695,52 +703,51 @@ if (host.isCodeFoldingEnabled()) {
boolean useSelectedTextColor = host.getUseSelectedTextColor(); boolean useSelectedTextColor = host.getUseSelectedTextColor();
RSyntaxTextAreaHighlighter h = RSyntaxTextAreaHighlighter h =
(RSyntaxTextAreaHighlighter)host.getHighlighter(); (RSyntaxTextAreaHighlighter) host.getHighlighter();
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D) g;
Token token; Token token;
//System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1)); //System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1));
TokenPainter painter = host.getTokenPainter(); TokenPainter painter = host.getTokenPainter();
int line = linesAbove; int line = linesAbove;
//int count = 0; //int count = 0;
while (y<clip.y+clip.height+ascent && line<lineCount) { while (y < clip.y + clip.height + ascent && line < lineCount) {
Fold fold = fm.getFoldForLine(line); Fold fold = fm.getFoldForLine(line);
Element lineElement = map.getElement(line); Element lineElement = map.getElement(line);
int startOffset = lineElement.getStartOffset(); int startOffset = lineElement.getStartOffset();
//int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 : //int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 :
// lineElement.getEndOffset()-1); // lineElement.getEndOffset()-1);
int endOffset = lineElement.getEndOffset()-1; // Why always "-1"? int endOffset = lineElement.getEndOffset() - 1; // Why always "-1"?
h.paintLayeredHighlights(g2d, startOffset, endOffset, h.paintLayeredHighlights(g2d, startOffset, endOffset,
a, host, this); a, host, this);
// Paint a line of text. // Paint a line of text.
token = document.getTokenListForLine(line); token = document.getTokenListForLine(line);
if (!useSelectedTextColor || selStart==selEnd || if (!useSelectedTextColor || selStart == selEnd ||
(startOffset>=selEnd || endOffset<selStart)) { (startOffset >= selEnd || endOffset < selStart)) {
drawLine(painter, token, g2d, x,y); drawLine(painter, token, g2d, x, y);
} } else {
else {
//System.out.println("Drawing line with selection: " + line); //System.out.println("Drawing line with selection: " + line);
drawLineWithSelection(painter,token,g2d, x,y, selStart, selEnd); drawLineWithSelection(painter, token, g2d, x, y, selStart, selEnd);
} }
if (fold!=null && fold.isCollapsed()) { if (fold != null && fold.isCollapsed()) {
// Visible indicator of collapsed lines // Visible indicator of collapsed lines
Color c = RSyntaxUtilities.getFoldedLineBottomColor(host); Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
if (c!=null) { if (c != null) {
g.setColor(c); g.setColor(c);
g.drawLine(x,y+lineHeight-ascent-1, g.drawLine(x, y + lineHeight - ascent - 1,
alloc.width,y+lineHeight-ascent-1); alloc.width, y + lineHeight - ascent - 1);
} }
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
do { do {
int hiddenLineCount = fold.getLineCount(); int hiddenLineCount = fold.getLineCount();
if (hiddenLineCount==0) { if (hiddenLineCount == 0) {
// Fold parser identified a zero-line fold region. // Fold parser identified a zero-line fold region.
// This is really a bug, but we'll be graceful here // This is really a bug, but we'll be graceful here
// and avoid an infinite loop. // and avoid an infinite loop.
@ -748,7 +755,7 @@ if (host.isCodeFoldingEnabled()) {
} }
line += hiddenLineCount; line += hiddenLineCount;
fold = fm.getFoldForLine(line); fold = fm.getFoldForLine(line);
} while (fold!=null && fold.isCollapsed()); } while (fold != null && fold.isCollapsed());
} }
@ -824,7 +831,7 @@ if (host.isCodeFoldingEnabled()) {
if (added != null) { if (added != null) {
int addedAt = ec.getIndex(); // FIXME: Is this correct????? int addedAt = ec.getIndex(); // FIXME: Is this correct?????
for (int i = 0; i < added.length; i++) for (int i = 0; i < added.length; i++)
possiblyUpdateLongLine(added[i], addedAt+i); possiblyUpdateLongLine(added[i], addedAt + i);
} }
if (removed != null) { if (removed != null) {
for (int i = 0; i < removed.length; i++) { for (int i = 0; i < removed.length; i++) {
@ -841,14 +848,12 @@ if (host.isCodeFoldingEnabled()) {
// This occurs when syntax highlighting only changes on lines // This occurs when syntax highlighting only changes on lines
// (i.e. beginning a multiline comment). // (i.e. beginning a multiline comment).
else if (changes.getType()==DocumentEvent.EventType.CHANGE) { else if (changes.getType() == DocumentEvent.EventType.CHANGE) {
//System.err.println("Updating the damage due to a CHANGE event..."); //System.err.println("Updating the damage due to a CHANGE event...");
int startLine = changes.getOffset(); int startLine = changes.getOffset();
int endLine = changes.getLength(); int endLine = changes.getLength();
damageLineRange(startLine,endLine, a, host); damageLineRange(startLine, endLine, a, host);
} } else {
else {
Element map = getElement(); Element map = getElement();
int line = map.getElementIndex(changes.getOffset()); int line = map.getElementIndex(changes.getOffset());
damageLineRange(line, line, a, host); damageLineRange(line, line, a, host);
@ -861,14 +866,12 @@ if (host.isCodeFoldingEnabled()) {
// because it has gotten longer. // because it has gotten longer.
longLineWidth = getLineWidth(line); longLineWidth = getLineWidth(line);
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} } else {
else {
// If long line gets updated, update the status bars too. // If long line gets updated, update the status bars too.
if (possiblyUpdateLongLine(e, line)) if (possiblyUpdateLongLine(e, line))
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} }
} } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
if (map.getElement(line) == longLine) { if (map.getElement(line) == longLine) {
// removed from longest line... recalc // removed from longest line... recalc
longLineWidth = -1; // Must do this! longLineWidth = -1; // Must do this!
@ -884,7 +887,7 @@ if (host.isCodeFoldingEnabled()) {
* Checks to see if the font metrics and longest line are up-to-date. * Checks to see if the font metrics and longest line are up-to-date.
*/ */
private void updateMetrics() { private void updateMetrics() {
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Font f = host.getFont(); Font f = host.getFont();
if (font != f) { if (font != f) {
// The font changed, we need to recalculate the longest line! // The font changed, we need to recalculate the longest line!
@ -910,7 +913,7 @@ if (host.isCodeFoldingEnabled()) {
bias[0] = Position.Bias.Forward; bias[0] = Position.Bias.Forward;
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int x = (int) fx; int x = (int) fx;
int y = (int) fy; int y = (int) fy;
@ -936,9 +939,9 @@ if (host.isCodeFoldingEnabled()) {
Element map = doc.getDefaultRootElement(); Element map = doc.getDefaultRootElement();
int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() ); int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
//System.out.print("--- " + lineIndex); //System.out.print("--- " + lineIndex);
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true); lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
//System.out.println(" => " + lineIndex); //System.out.println(" => " + lineIndex);
if (lineIndex >= map.getElementCount()) { if (lineIndex >= map.getElementCount()) {
return host.getLastVisibleOffset(); return host.getLastVisibleOffset();
@ -960,9 +963,9 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
tabBase = alloc.x; tabBase = alloc.x;
int offs = tokenList.getListOffset( int offs = tokenList.getListOffset(
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this, tabBase, x); this, tabBase, x);
return offs!=-1 ? offs : p0; return offs != -1 ? offs : p0;
} }
} // End of else. } // End of else.
@ -981,11 +984,13 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
if (host != null) {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
if (!fm.isLineHidden(line)) { if (!fm.isLineHidden(line)) {
line -= fm.getHiddenLineCountAbove(line); line -= fm.getHiddenLineCountAbove(line);
return alloc.y + line*lineHeight; return alloc.y + line * lineHeight;
}
} }
} }

38
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java

@ -9,15 +9,33 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.text.*;
import javax.swing.text.Position.Bias;
import javax.swing.event.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter; import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.stable.CommonUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.BoxView;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.LayeredHighlighter;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.Position.Bias;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
@ -93,7 +111,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
int p = p0; int p = p0;
RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer(); RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
float currentWidth = getWidth(); float currentWidth = getWidth();
if (currentWidth==Integer.MAX_VALUE) if (CommonUtils.equals(currentWidth, Integer.MAX_VALUE))
currentWidth = getPreferredSpan(X_AXIS); currentWidth = getPreferredSpan(X_AXIS);
// Make sure width>0; this is a huge hack to fix a bug where // Make sure width>0; this is a huge hack to fix a bug where
// loading text into an RTextArea before it is visible if word wrap // loading text into an RTextArea before it is visible if word wrap
@ -128,7 +146,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
//System.err.println("------ ending calculateBreakPosition() --------"); //System.err.println("------ ending calculateBreakPosition() --------");
// return p; // return p;
return p + 1; return p + 1;
} }
//private int getBreakLocation(Token t, FontMetrics fm, int x0, int x, //private int getBreakLocation(Token t, FontMetrics fm, int x0, int x,
@ -1044,8 +1062,8 @@ return p + 1;
// Code folding may have hidden the last line. If so, return the last // Code folding may have hidden the last line. If so, return the last
// visible offset instead of the last offset. // visible offset instead of the last offset.
if (host.isCodeFoldingEnabled() && v==getView(getViewCount()-1) && if (v != null && host.isCodeFoldingEnabled() && v == getView(getViewCount() - 1) &&
offs==v.getEndOffset()-1) { offs == v.getEndOffset() - 1) {
offs = host.getLastVisibleOffset(); offs = host.getLastVisibleOffset();
} }
@ -1170,7 +1188,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
switch (axis) { switch (axis) {
case View.X_AXIS: case View.X_AXIS:
float width = getWidth(); float width = getWidth();
if (width == Integer.MAX_VALUE) { if (CommonUtils.equals(width, Integer.MAX_VALUE)) {
// We have been initially set to MAX_VALUE, but we don't // We have been initially set to MAX_VALUE, but we don't
// want this as our preferred. // want this as our preferred.
return 100f; return 100f;

5
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java

@ -18,6 +18,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.ErrorStrip;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token;
import com.fr.stable.StringUtils;
/** /**
@ -60,6 +61,7 @@ public class TaskTagParser extends AbstractParser {
} }
@SuppressWarnings("squid:S2259")
public ParseResult parse(RSyntaxDocument doc, String style) { public ParseResult parse(RSyntaxDocument doc, String style) {
Element root = doc.getDefaultRootElement(); Element root = doc.getDefaultRootElement();
@ -101,6 +103,9 @@ public class TaskTagParser extends AbstractParser {
} }
if (start>-1) { if (start>-1) {
if (StringUtils.isEmpty(text)) {
continue;
}
text = text.substring(start); text = text.substring(start);
// TODO: Strip off end of MLC's if they're there. // TODO: Strip off end of MLC's if they're there.
int len = text.length(); int len = text.length();

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java

@ -349,6 +349,10 @@ public class LineNumberList extends AbstractGutterComponent
int width = metrics.stringWidth(number); int width = metrics.stringWidth(number);
g.drawString(number, rhs-width,y); g.drawString(number, rhs-width,y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
@ -371,6 +375,10 @@ public class LineNumberList extends AbstractGutterComponent
String number = Integer.toString(line + getLineNumberingStartIndex() - 1); String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
g.drawString(number, RHS_BORDER_WIDTH, y); g.drawString(number, RHS_BORDER_WIDTH, y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java

@ -635,6 +635,9 @@ public class RTextArea extends RTextAreaBase implements Printable {
parent = parent.getParent(); parent = parent.getParent();
} }
KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE"); KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE");
if (inputMap == null) {
return;
}
inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction); inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction);
} }

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java

@ -902,6 +902,8 @@ public class RTextAreaEditorKit extends DefaultEditorKit {
} }
} catch (BadLocationException bl) { } catch (BadLocationException bl) {
} }
}else if (textArea == null) {
throw new IllegalArgumentException("RTextArea can not be null!");
} }
if (beep) if (beep)

10
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java

@ -9,6 +9,8 @@
*/ */
package com.fr.design.gui.syntax.ui.rtextarea; package com.fr.design.gui.syntax.ui.rtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
@ -95,9 +97,9 @@ public class VolatileImageBackgroundPainterStrategy
try { try {
tracker.waitForID(1); tracker.waitForID(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(),e);
bgImage = null; bgImage = null;
return; Thread.currentThread().interrupt();
} finally { } finally {
tracker.removeImage(i, 1); tracker.removeImage(i, 1);
} }
@ -106,9 +108,9 @@ public class VolatileImageBackgroundPainterStrategy
try { try {
tracker.waitForID(0); tracker.waitForID(0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(),e);
bgImage = null; bgImage = null;
return; Thread.currentThread().interrupt();
} finally { } finally {
tracker.removeImage(bgImage, 0); tracker.removeImage(bgImage, 0);
} }

6
designer-base/src/main/java/com/fr/design/icon/LockIcon.java

@ -34,6 +34,7 @@ public class LockIcon extends ImageIcon {
} }
} }
@Override
public void paintIcon(Component c, Graphics g, int x, int y) { public void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) { if (mainImage != null) {
g.drawImage(mainImage, x, y, c); g.drawImage(mainImage, x, y, c);
@ -48,6 +49,7 @@ public class LockIcon extends ImageIcon {
* *
* @param image the image * @param image the image
*/ */
@Override
protected void loadImage(Image image) { protected void loadImage(Image image) {
synchronized (tracker) { synchronized (tracker) {
tracker.addImage(image, 0); tracker.addImage(image, 0);
@ -55,6 +57,7 @@ public class LockIcon extends ImageIcon {
tracker.waitForID(0, 0); tracker.waitForID(0, 0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
loadStatus = tracker.statusID(0, false); loadStatus = tracker.statusID(0, false);
@ -70,6 +73,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the <code>Image</code> object for this <code>ImageIcon</code> * @return the <code>Image</code> object for this <code>ImageIcon</code>
*/ */
@Override
public Image getImage() { public Image getImage() {
return mainImage; return mainImage;
} }
@ -85,6 +89,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the width in pixels of this icon * @return the width in pixels of this icon
*/ */
@Override
public int getIconWidth() { public int getIconWidth() {
return width; return width;
} }
@ -94,6 +99,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the height in pixels of this icon * @return the height in pixels of this icon
*/ */
@Override
public int getIconHeight() { public int getIconHeight() {
return height; return height;
} }

1
designer-base/src/main/java/com/fr/design/icon/WarningIcon.java

@ -59,6 +59,7 @@ public class WarningIcon extends ImageIcon {
tracker.waitForID(0, 0); tracker.waitForID(0, 0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
tracker.statusID(0, false); tracker.statusID(0, false);

12
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -217,6 +217,18 @@ public class FRGUIPaneFactory {
return jp; return jp;
} }
/**
* 创建一个靠左空边框面板间隔小firsthgap 为0
*
* @return JPanel对象
*/
public static JPanel createTinyHGapFlowInnerContainer_M_Pane_First0() {
JPanel jp = new JPanel();
jp.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
jp.setLayout(new FRLeftFlowLayout(0, 5, 0));
return jp;
}
/** /**
* 创建一个靠左空边框面板间隔中等 * 创建一个靠左空边框面板间隔中等
* *

6
designer-base/src/main/java/com/fr/design/layout/TableLayout.java

@ -1218,7 +1218,7 @@ public class TableLayout implements LayoutManager2, Serializable {
* @param z indicates row or column * @param z indicates row or column
* @param availableSize amount of space available in the container * @param availableSize amount of space available in the container
*/ */
@SuppressWarnings("squid:S3518")
protected void assignFillSize(int z, int availableSize) { protected void assignFillSize(int z, int availableSize) {
// Skip if there is no more space to allocate // Skip if there is no more space to allocate
if (availableSize <= 0) if (availableSize <= 0)
@ -1290,7 +1290,7 @@ public class TableLayout implements LayoutManager2, Serializable {
* @return the amount of space available after absolute crs have been assigned * @return the amount of space available after absolute crs have been assigned
* sizes * sizes
*/ */
@SuppressWarnings("squid:S3518")
protected int assignPrefMinSize protected int assignPrefMinSize
(int z, int availableSize, double typeOfSize) { (int z, int availableSize, double typeOfSize) {
// Get variables referring to columns or rows (crs) // Get variables referring to columns or rows (crs)
@ -1727,7 +1727,7 @@ public class TableLayout implements LayoutManager2, Serializable {
* *
* @return a dimension indicating the container's preferred or minimum size * @return a dimension indicating the container's preferred or minimum size
*/ */
@SuppressWarnings("squid:S3518")
protected int calculateLayoutSize protected int calculateLayoutSize
(Container container, int z, double typeOfSize, Entry entryList[], (Container container, int z, double typeOfSize, Entry entryList[],
Dimension prefMinSize[]) { Dimension prefMinSize[]) {

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

@ -308,16 +308,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
}); });
this.addDesignerOpenedListener(new DesignerOpenedListener() {
@Override
public void designerOpened() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
});
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setVisible(false); this.setVisible(false);
this.setExtendedState(JFrame.MAXIMIZED_BOTH); this.setExtendedState(JFrame.MAXIMIZED_BOTH);
@ -327,6 +317,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
this.progressDialog = new ProgressDialog(this); this.progressDialog = new ProgressDialog(this);
} }
public void resizeFrame() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize();
}
public void closeAuthorityEditing() { public void closeAuthorityEditing() {
DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL);
WestRegionContainerPane.getInstance().replaceDownPane( WestRegionContainerPane.getInstance().replaceDownPane(
@ -1094,6 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
thread.join(); thread.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("Map Thread Error"); FineLoggerFactory.getLogger().error("Map Thread Error");
Thread.currentThread().interrupt();
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(

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

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

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

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

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

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

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

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

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

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

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

@ -11,6 +11,8 @@ import com.fr.design.web.CustomIconPane;
import com.fr.form.ui.WidgetInfoConfig; import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -33,6 +35,7 @@ import java.util.ArrayList;
public class TabIconConfigPane extends JPanel { public class TabIconConfigPane extends JPanel {
private UIButton editIconButton; private UIButton editIconButton;
private UIButton deleteIconButton;
private String curIconName; private String curIconName;
private IconButton selectIconButton; private IconButton selectIconButton;
private ArrayList<IconButton> iconButtons = new ArrayList<IconButton>(); private ArrayList<IconButton> iconButtons = new ArrayList<IconButton>();
@ -43,7 +46,7 @@ public class TabIconConfigPane extends JPanel {
public void initComp(int count) { public void initComp(int count) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); JPanel panel = FRGUIPaneFactory.createTinyHGapFlowInnerContainer_M_Pane_First0();
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
editIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); 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.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
@ -63,12 +66,28 @@ public class TabIconConfigPane extends JPanel {
curIconName = cip.update(); curIconName = cip.update();
setShowIconImage(); setShowIconImage();
TabIconConfigPane.this.repaint(); TabIconConfigPane.this.repaint();
deleteIconButton.setEnabled(true);
} }
}); });
editDialog.setVisible(true); editDialog.setVisible(true);
} }
}); });
editIconButton.setEnabled(false); editIconButton.setEnabled(false);
deleteIconButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Delete"));
deleteIconButton.setFont(FRFont.getInstance("Helvetica", Font.PLAIN, 12, Color.decode("#3A383A")));
deleteIconButton.setPreferredSize(new Dimension(62, 20));
panel.add(deleteIconButton);
deleteIconButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
curIconName = "";
setShowIconImage();
TabIconConfigPane.this.repaint();
deleteIconButton.setEnabled(false);
}
});
deleteIconButton.setEnabled(false);
this.add(panel, BorderLayout.CENTER); this.add(panel, BorderLayout.CENTER);
JPanel northPane = new JPanel(); JPanel northPane = new JPanel();
@ -163,6 +182,7 @@ public class TabIconConfigPane extends JPanel {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
selectIconButton = this; selectIconButton = this;
editIconButton.setEnabled(true); editIconButton.setEnabled(true);
deleteIconButton.setEnabled(StringUtils.isNotEmpty(this.getIconName()));
TabIconConfigPane.this.repaint();// repaint TabIconConfigPane.this.repaint();// repaint
} }

123
designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java

@ -1,29 +1,46 @@
package com.fr.design.mainframe.toolbar; package com.fr.design.mainframe.toolbar;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.gui.frpane.LoadingBasicPane; import com.fr.design.gui.frpane.LoadingBasicPane;
import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import javax.swing.JPanel; import javax.swing.*;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.LinkedBlockingQueue; import java.util.Map;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.Executors;
/** /**
* Created by XiaXiang on 2017/4/13. * 按钮面板管理类
*
* @author XiaXiang
* @date 2017/4/13
*/ */
public class UpdateActionManager { public class UpdateActionManager {
private static UpdateActionManager updateActionManager = null; private static UpdateActionManager updateActionManager = null;
private List<UpdateActionModel> updateActions; private List<UpdateActionModel> updateActions;
private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
1, 2, private Map<String, UpdateAction> updateActionsIndexCache = new HashMap<>(16);
30000L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(), private static boolean isRegisterIndexSearchTextTask = false;
new ThreadFactoryBuilder().setNameFormat("alphafine-thread-%s").build());//目前测下来一个线程慢慢做处理总共大概也只要两秒,暂时就这样
/**
* 限制初始化
*/
private UpdateActionManager() {
}
public synchronized static UpdateActionManager getUpdateActionManager() { public synchronized static UpdateActionManager getUpdateActionManager() {
if (updateActionManager == null) { if (updateActionManager == null) {
@ -55,22 +72,92 @@ public class UpdateActionManager {
return null; return null;
} }
public synchronized void dealWithSearchText(final String paneClass, final UpdateAction updateAction) { /**
threadPoolExecutor.allowCoreThreadTimeOut(true); * 处理action的搜索文本
threadPoolExecutor.execute(new Runnable() { * 缓存逻辑
* 1.首次索引或缓存失效的时候更新版本会使缓存失效会将索引缓存存到env.xml
* 下次直接加载
* 2.需要重新索引则等待设计器初始化完毕之后单线程运行索引任务
*
* @param paneClass 面板类名
* @param updateAction 待处理的updateAction
*/
public void dealWithSearchText(String paneClass, UpdateAction updateAction) {
Map<String, String> actionSearchTextCache = AlphaFineConfigManager.getInstance().getActionSearchTextCache();
if (!cacheValid()
|| actionSearchTextCache.isEmpty()
|| !actionSearchTextCache.containsKey(paneClass)) {
if (!updateActionsIndexCache.containsKey(paneClass)) {
updateActionsIndexCache.put(paneClass, updateAction);
}
registerIndexSearchTextTask();
} else {
updateAction.setSearchText(actionSearchTextCache.get(paneClass));
}
}
/**
* 缓存是否有效
* 注意开发工程版本为不是安装版本
* 索引只会出现在首次启动
*
* @return true有效false失效
*/
private boolean cacheValid() {
return ComparatorUtils.equals(GeneralUtils.readBuildNO(), AlphaFineConfigManager.getInstance().getCacheBuildNO());
}
/**
* 由于是UI线程不考虑并发问题
*/
private void registerIndexSearchTextTask() {
if (isRegisterIndexSearchTextTask) {
return;
}
isRegisterIndexSearchTextTask = true;
// 没有缓存或者缓存失效的时候,等待设计器启动之后开始索引任务
EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
// 使用单线程索引
ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("IndexAlphaFineSearchText"));
for (Map.Entry<String, UpdateAction> cache : updateActionsIndexCache.entrySet()) {
es.execute(new IndexTask(cache.getKey(), cache.getValue()));
}
updateActionsIndexCache = null;
es.shutdown();
// 标记一下缓存版本
AlphaFineConfigManager.getInstance().setCacheBuildNO(GeneralUtils.readBuildNO());
}
});
}
/**
* 索引任务
*/
class IndexTask implements Runnable {
private String className;
private UpdateAction updateAction;
IndexTask(String className, UpdateAction updateAction) {
this.className = className;
this.updateAction = updateAction;
}
@Override @Override
public void run() { public void run() {
JPanel panel = null; JPanel panel;
try { try {
panel = (JPanel) StableUtils.classForName(paneClass).newInstance(); panel = (JPanel) StableUtils.classForName(className).newInstance();
if (panel instanceof LoadingBasicPane) { if (panel instanceof LoadingBasicPane) {
panel = ((LoadingBasicPane) panel).getAllComponents(); panel = ((LoadingBasicPane) panel).getAllComponents();
} }
updateAction.setSearchText(updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer())); String componentTexts = updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer());
updateAction.setSearchText(componentTexts);
AlphaFineConfigManager.getInstance().setActionSearchTextCache(className, componentTexts);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
});
} }
} }

18
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java

@ -8,6 +8,7 @@ import com.fr.stable.StableUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResourceOutputStream; import com.fr.workspace.resource.WorkResourceOutputStream;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -34,16 +35,15 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (node == null) { if (node == null) {
return null; return null;
} }
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath(); String envPath = node.getEnvPath();
// envPath必须以vcs开头 // envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { if (!envPath.startsWith(vcsCacheDir)) {
return null; return null;
} }
InputStream in = new ByteArrayInputStream( InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1)) StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1))
) )
); );
@ -63,13 +63,13 @@ public class VcsCacheFileNodeFile extends FileNodeFILE {
if (ComparatorUtils.equals(node, null)) { if (ComparatorUtils.equals(node, null)) {
return null; return null;
} }
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
String envPath = node.getEnvPath(); String envPath = node.getEnvPath();
// envPath必须以reportLets开头 // envPath必须以VcsCacheRelativePath开头
if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { if (!envPath.startsWith(vcsCacheDir)) {
return null; return null;
} }
return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1))); return new WorkResourceOutputStream(StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1)));
} }
} }

8
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -19,6 +19,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.filesystem.VcsFileSystem;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@ -45,8 +46,6 @@ public class VcsHelper implements JTemplateActionListener {
public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png"); public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png");
public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png"); public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png");
public final static int OFFSET = 2; public final static int OFFSET = 2;
private final static String VCS_DIR = "vcs";
public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache");
private static final int MINUTE = 60 * 1000; private static final int MINUTE = 60 * 1000;
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private static final VcsHelper instance = new VcsHelper(); private static final VcsHelper instance = new VcsHelper();
@ -89,12 +88,13 @@ public class VcsHelper implements JTemplateActionListener {
} }
private String getEditingFilename() { private String getEditingFilename() {
String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String editingFilePath = jt.getEditingFILE().getPath(); String editingFilePath = jt.getEditingFILE().getPath();
if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY);
} else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) { } else if (editingFilePath.startsWith(vcsCacheDir)) {
editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY); editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY);
} }
if (editingFilePath.startsWith("/")) { if (editingFilePath.startsWith("/")) {
editingFilePath = editingFilePath.substring(1); editingFilePath = editingFilePath.substring(1);

7
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

@ -19,12 +19,11 @@ public class VcsLabel extends ActionLabel {
} }
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
if (ui != null) { if (ui != null && g != null) {
Graphics scratchGraphics = (g == null) ? null : g.create(); Graphics scratchGraphics = g.create();
try { try {
ui.update(scratchGraphics, this); ui.update(scratchGraphics, this);
} } finally {
finally {
scratchGraphics.dispose(); scratchGraphics.dispose();
} }
} }

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

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

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

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

21
designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

@ -2,10 +2,12 @@ package com.fr.design.menu;
import com.fr.design.gui.itoolbar.UIToolBarUI; import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import org.jetbrains.annotations.Nullable;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
@ -16,11 +18,11 @@ public class ToolBarDef {
// item List. // item List.
private List<ShortCut> shortcutList = new ArrayList<ShortCut>(); private List<ShortCut> shortcutList = new ArrayList<ShortCut>();
/* /**
* 一个static的方法生成一个JToolBar * 一个static的方法生成一个JToolBar
*/ */
public static UIToolbar createJToolBar(final Color background) { public static UIToolbar createJToolBar(final Color background) {
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI(){ UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() {
@Override @Override
public void paint(Graphics g, JComponent c) { public void paint(Graphics g, JComponent c) {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
@ -33,7 +35,7 @@ public class ToolBarDef {
} }
/* /**
* 一个static的方法生成一个JToolBar * 一个static的方法生成一个JToolBar
*/ */
public static UIToolbar createJToolBar() { public static UIToolbar createJToolBar() {
@ -49,22 +51,23 @@ public class ToolBarDef {
return this.shortcutList.size(); return this.shortcutList.size();
} }
@Nullable
public ShortCut getShortCut(int index) { public ShortCut getShortCut(int index) {
return this.shortcutList.get(index); return this.shortcutList.get(index);
} }
// 用可变参数,方便添加数组 /**
* 用可变参数方便添加数组
*/
public void addShortCut(ShortCut... shortcut) { public void addShortCut(ShortCut... shortcut) {
for(ShortCut i : shortcut){ Collections.addAll(this.shortcutList, shortcut);
this.shortcutList.add(i);
}
} }
public void clearShortCuts() { public void clearShortCuts() {
this.shortcutList.clear(); this.shortcutList.clear();
} }
/* /**
* 根据当前的ToolBarDef,更新toolBar * 根据当前的ToolBarDef,更新toolBar
*/ */
public void updateToolBar(UIToolbar toolBar) { public void updateToolBar(UIToolbar toolBar) {
@ -73,8 +76,10 @@ public class ToolBarDef {
int actionCount = this.getShortCutCount(); int actionCount = this.getShortCutCount();
for (int i = 0; i < actionCount; i++) { for (int i = 0; i < actionCount; i++) {
ShortCut shortcut = this.getShortCut(i); ShortCut shortcut = this.getShortCut(i);
if (shortcut != null) {
shortcut.intoJToolBar(toolBar); shortcut.intoJToolBar(toolBar);
} }
} }
}
} }

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

@ -16,6 +16,7 @@ import com.fr.design.parameter.ParameterReader;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
import java.awt.Dialog; import java.awt.Dialog;
import java.awt.Frame; import java.awt.Frame;
@ -65,8 +66,9 @@ public class DesignModuleFactory {
instance.creators4Hyperlink = nameableCreators; instance.creators4Hyperlink = nameableCreators;
} }
@NotNull
public static NameableCreator[] getCreators4Hyperlink() { public static NameableCreator[] getCreators4Hyperlink() {
return instance.creators4Hyperlink; return instance.creators4Hyperlink == null? new NameableCreator[0]:instance.creators4Hyperlink;
} }
public static void registerExtraWidgetOptions(WidgetOption[] options) { public static void registerExtraWidgetOptions(WidgetOption[] options) {

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

@ -6,6 +6,8 @@ import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.ispinner.UnsignedIntUISpinner;
import com.fr.design.gui.style.FRFontPane; import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -14,14 +16,18 @@ 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.SwingConstants;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; 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 javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.Dimension;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
@ -37,9 +43,15 @@ public class WatermarkPane extends BasicPane {
private TinyFormulaPane formulaPane; private TinyFormulaPane formulaPane;
// 字号 // 字号
private UIComboBox fontSizeComboBox; private UIComboBox fontSizeComboBox;
//横向间距
private UISpinner horizontalGapSpinner;
//横向间距
private UISpinner verticalGapSpinner;
// 文字颜色 // 文字颜色
private NewColorSelectPane colorPane; private NewColorSelectPane colorPane;
private static final Dimension SPINNER_DIMENSION = new Dimension(75, 20);
public WatermarkPane() { public WatermarkPane() {
initComponents(); initComponents();
} }
@ -73,6 +85,7 @@ public class WatermarkPane extends BasicPane {
} }
populateFourmula(watermark.getText()); populateFourmula(watermark.getText());
populateFontSize(watermark.getFontSize()); populateFontSize(watermark.getFontSize());
populateWatermarkGap(watermark);
populateColor(watermark.getColor()); populateColor(watermark.getColor());
paintPreviewPane(); paintPreviewPane();
} }
@ -81,6 +94,8 @@ public class WatermarkPane extends BasicPane {
WatermarkAttr watermark = new WatermarkAttr(); WatermarkAttr watermark = new WatermarkAttr();
watermark.setText(formulaPane.getUITextField().getText()); watermark.setText(formulaPane.getUITextField().getText());
watermark.setFontSize((int)fontSizeComboBox.getSelectedItem()); watermark.setFontSize((int)fontSizeComboBox.getSelectedItem());
watermark.setHorizontalGap((int) horizontalGapSpinner.getValue());
watermark.setVerticalGap((int) verticalGapSpinner.getValue());
watermark.setColor(colorPane.getColor()); watermark.setColor(colorPane.getColor());
colorPane.updateUsedColor(); colorPane.updateUsedColor();
return watermark; return watermark;
@ -98,20 +113,39 @@ public class WatermarkPane extends BasicPane {
formulaPane = new TinyFormulaPane(); formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true); fontSizeComboBox.setEditable(true);
horizontalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 200);
verticalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
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);
//水印间距面板
JPanel watermarkGapPane = new JPanel(new BorderLayout(10, 0));
JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 10, 0);
jp.add(horizontalGapSpinner);
jp.add(verticalGapSpinner);
watermarkGapPane.add(jp, BorderLayout.CENTER);
JPanel watermarkGapTipsPane = new JPanel(new BorderLayout());
JPanel tipsJp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 10, 0);
tipsJp.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), SwingConstants.CENTER));
tipsJp.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), SwingConstants.CENTER));
watermarkGapTipsPane.add(tipsJp, BorderLayout.CENTER);
colorPane = new NewColorSelectPane(); colorPane = new NewColorSelectPane();
JPanel colorLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel colorLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
colorLabelPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Text_Color")), BorderLayout.NORTH); colorLabelPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Text_Color")), BorderLayout.NORTH);
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double[] rowSize = {p,p,p}; double[] rowSize = {p, p, p, p, p};
double[] columnSize = { p, MAX_WIDTH}; double[] columnSize = {p, MAX_WIDTH};
JPanel rightContentPane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{ JPanel rightContentPane = TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Watermark_Text")), formulaPane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Watermark_Text")), formulaPane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Font_Size")), fontSizeTypePane}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Font_Size")), fontSizeTypePane},
{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Watermark_Gap")),watermarkGapPane },
{null,watermarkGapTipsPane },
{colorLabelPane, colorPane}, {colorLabelPane, colorPane},
}, rowSize, columnSize, 10); }, rowSize, columnSize, 10);
rightContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12)); rightContentPane.setBorder(BorderFactory.createEmptyBorder(15, 12, 10, 12));
@ -131,6 +165,36 @@ public class WatermarkPane extends BasicPane {
}); });
} }
protected void populateWatermarkGap(WatermarkAttr watermark){
this.horizontalGapSpinner.setValue(watermark.getHorizontalGap());
this.horizontalGapSpinner.addUISpinnerFocusListenner(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
paintPreviewPane();
}
@Override
public void focusLost(FocusEvent e) {
paintPreviewPane();
}
});
this.verticalGapSpinner.setValue(watermark.getVerticalGap());
this.verticalGapSpinner.addUISpinnerFocusListenner(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
paintPreviewPane();
}
@Override
public void focusLost(FocusEvent e) {
paintPreviewPane();
}
});
}
protected void paintPreviewPane(){ protected void paintPreviewPane(){
watermarkPreviewPane.repaint(update()); watermarkPreviewPane.repaint(update());
} }

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

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

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

Loading…
Cancel
Save