Browse Source

Merge pull request #1179 in DESIGN/design from feature/10.0 to release/10.0

* commit '80c867f685324dc64cded890f50fb84bfd601556': (217 commits)
  KERNEL-418 更新升级重构
  REPORT-22587 新版本插件管理,下载资源交互样式
  REPORT-19946 Linux设计器
  REPORT-19946 Linux设计器
  sonar问题修复
  REPORT-22291 撤销
  REPORT-20329 sonar问题修复
  REPORT-22291 模版版本控制,远程设计刚升级到10.0.4的工程,默认配置项开启
  REPORT-19946 Linux设计器
  KERNEL-418 更新升级重构
  KERNEL-418 更新升级重构
  MOBILE-23325 【单选按钮样式】图文按钮:上传图片后,移动端图片显示很模糊
  KERNEL-418 更新升级重构
  无jira任务,sonar问题修复
  无jira任务,sonar问题修复
  KERNEL-418 更新升级重构
  REPORT-19946 Linux设计器
  REPORT-19946 Linux设计器
  KERNEL-418 更新升级重构
  CHART-10233 插件超链
  ...
feature/big-screen
neil 5 years ago
parent
commit
3b6429b17d
  1. 2
      designer-base/src/main/java/com/fr/design/DesignState.java
  2. 43
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 11
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 24
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  5. 37
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  6. 11
      designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java
  7. 519
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  8. 79
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  9. 24
      designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java
  10. 16
      designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java
  11. 26
      designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java
  12. 23
      designer-base/src/main/java/com/fr/design/beans/BasicStorePane.java
  13. 6
      designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java
  14. 3
      designer-base/src/main/java/com/fr/design/border/UIRoundedBorder.java
  15. 3
      designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java
  16. 2
      designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java
  17. 44
      designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java
  18. 8
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  19. 18
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  20. 58
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java
  21. 27
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java
  22. 3
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java
  23. 6
      designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java
  24. 17
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  25. 3
      designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java
  26. 7
      designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java
  27. 2
      designer-base/src/main/java/com/fr/design/dialog/JWizardPanel.java
  28. 8
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  29. 2
      designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java
  30. 48
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  31. 2
      designer-base/src/main/java/com/fr/design/extra/PluginControlPane.java
  32. 16
      designer-base/src/main/java/com/fr/design/extra/PluginFromStorePane.java
  33. 2
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  34. 36
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  35. 2
      designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java
  36. 20
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  37. 4
      designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java
  38. 4
      designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java
  39. 13
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  40. 14
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  41. 10
      designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java
  42. 10
      designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java
  43. 1
      designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java
  44. 8
      designer-base/src/main/java/com/fr/design/formula/VariableResolverAdapter.java
  45. 36
      designer-base/src/main/java/com/fr/design/fun/ExportAttrTabProvider.java
  46. 24
      designer-base/src/main/java/com/fr/design/fun/MobileWidgetStyleProvider.java
  47. 36
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractExportAttrTabProvider.java
  48. 20
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileWidgetStyleProvider.java
  49. 3
      designer-base/src/main/java/com/fr/design/gui/UIDefaultTheme.java
  50. 3
      designer-base/src/main/java/com/fr/design/gui/autocomplete/LanguageAwareCompletionProvider.java
  51. 4
      designer-base/src/main/java/com/fr/design/gui/autocomplete/ParameterizedCompletionContext.java
  52. 14
      designer-base/src/main/java/com/fr/design/gui/borders/UIFrameBorder.java
  53. 8
      designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java
  54. 2
      designer-base/src/main/java/com/fr/design/gui/columnrow/ColumnRowPane.java
  55. 4
      designer-base/src/main/java/com/fr/design/gui/controlpane/ObjectUIControlPane.java
  56. 10
      designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java
  57. 1
      designer-base/src/main/java/com/fr/design/gui/demo/LoadingPaneDemo.java
  58. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java
  59. 6
      designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java
  60. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java
  61. 1
      designer-base/src/main/java/com/fr/design/gui/frpane/LoadingBasicPaneTest.java
  62. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UINumberSlidePane.java
  63. 3
      designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java
  64. 6
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java
  65. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  66. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java
  67. 2
      designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java
  68. 4
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  69. 2
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBoxUI.java
  70. 1
      designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBox.java
  71. 1
      designer-base/src/main/java/com/fr/design/gui/icombobox/LazyComboBoxTest.java
  72. 12
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxButton.java
  73. 51
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  74. 27
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  75. 5
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIResizableContainer.java
  76. 6
      designer-base/src/main/java/com/fr/design/gui/ilable/MultilineLabel.java
  77. 4
      designer-base/src/main/java/com/fr/design/gui/imenu/UIBasicMenuItemUI.java
  78. 20
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  79. 18
      designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java
  80. 25
      designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java
  81. 46
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  82. 31
      designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java
  83. 2
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java
  84. 3
      designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  85. 22
      designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java
  86. 32
      designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java
  87. 1
      designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java
  88. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/CodeTemplateManager.java
  89. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java
  90. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java
  91. 110
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java
  92. 173
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java
  93. 9
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java
  94. 9
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java
  95. 73
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
  96. 34
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
  97. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/folding/HtmlFoldParser.java
  98. 11
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java
  99. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java
  100. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java
  101. Some files were not shown because too many files have changed in this diff Show More

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

@ -1,9 +1,7 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.workspace.WorkContext;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.

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

@ -145,12 +145,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
//记录当前激活码的在线激活状态. //记录当前激活码的在线激活状态.
private int activeKeyStatus = -1; private int activeKeyStatus = -1;
private boolean joinProductImprove = true; private boolean joinProductImprove = true;
private boolean embedServerLazyStartup = false;
//最近使用的颜色 //最近使用的颜色
private ColorSelectConfigManager configManager = new ColorSelectConfigManager(); private ColorSelectConfigManager configManager = new ColorSelectConfigManager();
/** /**
* alphafine * alphafine
*/ */
private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance();
private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance();
@ -264,6 +266,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();
} }
} }
} }
@ -316,8 +319,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()) {
@ -333,11 +337,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");
@ -650,9 +662,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());
} }
@ -711,6 +720,24 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
designerPushUpdateConfigManager.setAutoPushUpdateEnabled(autoPushUpdateEnabled); designerPushUpdateConfigManager.setAutoPushUpdateEnabled(autoPushUpdateEnabled);
} }
/**
* 内置服务器是否使用时启动
*
* @return 结果
*/
public boolean isEmbedServerLazyStartup() {
return embedServerLazyStartup;
}
/**
* 设置内置服务器使用时启动
*
* @param embedServerLazyStartup 使用时启动
*/
public void setEmbedServerLazyStartup(boolean embedServerLazyStartup) {
this.embedServerLazyStartup = embedServerLazyStartup;
}
/** /**
* 是否磁盘空间参数 * 是否磁盘空间参数
* *
@ -1525,7 +1552,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) {
@ -1608,6 +1635,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if ((tmpVal = reader.getAttrAsString("recentSelectedConnection", null)) != null) { if ((tmpVal = reader.getAttrAsString("recentSelectedConnection", null)) != null) {
this.setRecentSelectedConnection(tmpVal); this.setRecentSelectedConnection(tmpVal);
} }
this.setEmbedServerLazyStartup(reader.getAttrAsBoolean("embedServerLazyStartup", false));
} }
private void readReportPaneAttributions(XMLableReader reader) { private void readReportPaneAttributions(XMLableReader reader) {
@ -1852,6 +1880,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (this.isTemplateTreePaneExpanded()) { if (this.isTemplateTreePaneExpanded()) {
writer.attr("templateTreePaneExpanded", this.isTemplateTreePaneExpanded()); writer.attr("templateTreePaneExpanded", this.isTemplateTreePaneExpanded());
} }
if (this.isEmbedServerLazyStartup()) {
writer.attr("embedServerLazyStartup", this.isEmbedServerLazyStartup());
}
writer.end(); writer.end();
} }

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;
@ -39,6 +36,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();
@ -220,6 +218,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) {

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

@ -1,13 +1,16 @@
package com.fr.design; package com.fr.design;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.os.impl.RestartAction;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -154,12 +157,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) {
@ -168,19 +171,23 @@ public class RestartHelper {
}catch (Exception e){ }catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
if (OperatingSystem.isMacOS()) { OSBasedAction osBasedAction = OSSupportCenter.getAction(RestartAction.class);
restartInMacOS(installHome, filesToBeDelete); osBasedAction.execute(filesToBeDelete);
} else {
restartInWindows(installHome, filesToBeDelete);
}
} 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();
} }
} }
private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { /* private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder(); ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<String>(); List<String> commands = new ArrayList<String>();
commands.add("open"); commands.add("open");
@ -203,4 +210,16 @@ public class RestartHelper {
builder.command(commands); builder.command(commands);
builder.start(); builder.start();
} }
private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<String>();
//现在先写的是restart.sh
commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh");
if (ArrayUtils.isNotEmpty(filesToBeDelete)) {
commands.add(StableUtils.join(filesToBeDelete, "+"));
}
builder.command(commands);
builder.start();
}*/
} }

11
designer-base/src/main/java/com/fr/design/actions/community/QuestionAction.java

@ -10,11 +10,10 @@ import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
public class QuestionAction extends UpdateAction public class QuestionAction extends UpdateAction {
{
public QuestionAction() public QuestionAction() {
{ this.setMenuKeySet(QUESTIONS); this.setMenuKeySet(QUESTIONS);
this.setName(getMenuKeySet().getMenuName()); this.setName(getMenuKeySet().getMenuName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/question.png"));
@ -22,11 +21,11 @@ public class QuestionAction extends UpdateAction
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) public void actionPerformed(ActionEvent arg0) {
{
String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions"); String url = CloudCenter.getInstance().acquireUrlByKind("bbs.questions");
BrowseUtils.browser(url); BrowseUtils.browser(url);
} }
public static final MenuKeySet QUESTIONS = new MenuKeySet() { public static final MenuKeySet QUESTIONS = new MenuKeySet() {
@Override @Override
public char getMnemonic() { public char getMnemonic() {

519
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -1,9 +1,10 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.cluster.ClusterBridge;
import com.fr.config.Configuration; import com.fr.config.Configuration;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -17,19 +18,19 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIDictionaryComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.UIProgressBarUI;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -37,35 +38,25 @@ import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig; import com.fr.general.log.Log4jConfig;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.third.apache.log4j.Level; import com.fr.third.apache.log4j.Level;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.Worker; import com.fr.transaction.Worker;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory; import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.JFileChooser; import com.fr.workspace.server.vcs.git.config.GcConfig;
import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.KeyStroke; import javax.swing.event.*;
import javax.swing.SwingUtilities; import java.awt.*;
import javax.swing.event.ChangeEvent; import java.awt.event.*;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File; import java.io.File;
import java.net.URI; import java.text.DecimalFormat;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException;
import static com.fr.design.i18n.Toolkit.i18nText;
/** /**
* 选项对话框 * 选项对话框
@ -111,7 +102,6 @@ public class PreferencePane extends BasicPane {
private static final String DISPLAY_EQUALS = "+"; private static final String DISPLAY_EQUALS = "+";
private static final String MINUS = "MINUS"; private static final String MINUS = "MINUS";
private static final String DISPLAY_MINUS = "-"; private static final String DISPLAY_MINUS = "-";
private static final String PRIVACY_POLICY = "design.privacy";
private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG}; private static final Level[] LOG = {Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG};
@ -148,15 +138,23 @@ public class PreferencePane extends BasicPane {
private UICheckBox useUniverseDBMCheckbox; private UICheckBox useUniverseDBMCheckbox;
private UICheckBox joinProductImproveCheckBox; private UICheckBox joinProductImproveCheckBox;
private UICheckBox autoPushUpdateCheckBox; private UICheckBox autoPushUpdateCheckBox;
private UICheckBox embedServerLazyStartupCheckBox;
private UICheckBox vcsEnableCheckBox; private UICheckBox vcsEnableCheckBox;
private UICheckBox saveCommitCheckBox; private UICheckBox saveCommitCheckBox;
private UICheckBox useIntervalCheckBox; private UICheckBox useIntervalCheckBox;
private IntegerEditor saveIntervalEditor; private IntegerEditor saveIntervalEditor;
private UICheckBox gcEnableCheckBox;
private UIButton gcButton;
private UILabel remindVcsLabel; private UILabel remindVcsLabel;
private UILabel linkLabel;
private JDialog gcDialog;
private UILabel gcMessage = new UILabel();
private JPanel gcDialogDownPane = new JPanel();
private JPanel gcProgressBarPanel = new JPanel();
private JProgressBar gcProgressBar;
private Timer gcProgressTimer;
private UIButton gcOkButton = new UIButton(i18nText("Fine-Design_Report_OK"));
public PreferencePane() { public PreferencePane() {
this.initComponents(); this.initComponents();
@ -169,9 +167,9 @@ public class PreferencePane extends BasicPane {
UITabbedPane jtabPane = new UITabbedPane(); UITabbedPane jtabPane = new UITabbedPane();
JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel generalPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_General"), generalPane); jtabPane.addTab(i18nText("Fine-Design_Basic_General"), generalPane);
JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel advancePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
jtabPane.addTab(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"), advancePane); jtabPane.addTab(i18nText("Fine-Design_Basic_Advanced"), advancePane);
contentPane.add(jtabPane, BorderLayout.NORTH); contentPane.add(jtabPane, BorderLayout.NORTH);
createFunctionPane(generalPane); createFunctionPane(generalPane);
@ -192,75 +190,71 @@ public class PreferencePane extends BasicPane {
createServerPane(advancePane); createServerPane(advancePane);
JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Oracle_All_Tables")); JPanel oraclePane = FRGUIPaneFactory.createTitledBorderPane("Oracle" + i18nText("Fine-Design_Basic_Oracle_All_Tables"));
oracleSpace = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables"));
oraclePane.add(oracleSpace); oraclePane.add(oracleSpace);
// JPanel debuggerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Develop_Tools")); JPanel debuggerPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Develop_Tools"));
// openDebugComboBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window")); openDebugComboBox = new UICheckBox(i18nText("Fine-Design_Basic_Open_Debug_Window"));
// debuggerPane.add(openDebugComboBox, BorderLayout.CENTER); debuggerPane.add(openDebugComboBox, BorderLayout.CENTER);
// advancePane.add(debuggerPane); advancePane.add(debuggerPane);
//
// JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager")); JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager"));
// useOptimizedUPMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager"));
// upmSelectorPane.add(useOptimizedUPMCheckbox); upmSelectorPane.add(useOptimizedUPMCheckbox);
// advancePane.add(upmSelectorPane); advancePane.add(upmSelectorPane);
//
// JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Manager")); JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager"));
// useUniverseDBMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager"));
// dbmSelectorPane.add(useUniverseDBMCheckbox); dbmSelectorPane.add(useUniverseDBMCheckbox);
// advancePane.add(dbmSelectorPane); advancePane.add(dbmSelectorPane);
JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Product_Improve")); JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve"));
joinProductImproveCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Join_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve"));
linkLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Privacy_Policy")); improvePane.add(joinProductImproveCheckBox);
linkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
linkLabel.setForeground(UIConstants.NORMAL_BLUE); if(SupportOSImpl.AUTOPUSHUPDATE.support()){
linkLabel.addMouseListener(new MouseAdapter(){ autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update"));
@Override improvePane.add(autoPushUpdateCheckBox);
public void mouseClicked(MouseEvent e) {
try {
Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind(PRIVACY_POLICY)));
} catch (Exception e1) {
FineLoggerFactory.getLogger().error(e1.getMessage(), e1);
}
} }
}); /*
double p = TableLayout.PREFERRED;
double rowSize[] = {p};
double columnSize[] = {p, p};
Component[][] components = {
{joinProductImproveCheckBox, linkLabel},
};
JPanel choosePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
improvePane.add(choosePane);
if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) { if (DesignerPushUpdateManager.getInstance().isAutoPushUpdateSupported()) {
autoPushUpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Automatic_Push_Update")); autoPushUpdateCheckBox = new UICheckBox(i18nText("Fine-Design_Automatic_Push_Update"));
improvePane.add(autoPushUpdateCheckBox); improvePane.add(autoPushUpdateCheckBox);
} }*/
JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
spaceUpPane.add(oraclePane, BorderLayout.NORTH); spaceUpPane.add(oraclePane, BorderLayout.NORTH);
spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER); spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER);
spaceUpPane.add(improvePane, BorderLayout.SOUTH); spaceUpPane.add(improvePane, BorderLayout.SOUTH);
advancePane.add(spaceUpPane); advancePane.add(spaceUpPane);
JPanel embedServerPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Embed_Server"));
embedServerLazyStartupCheckBox = new UICheckBox(i18nText("Fine-Design_Startup_When_Needed"));
embedServerPanel.add(embedServerLazyStartupCheckBox);
advancePane.add(embedServerPanel);
} }
private void createVcsSettingPane(JPanel generalPane) { private void createVcsSettingPane(JPanel generalPane) {
JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title")); JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Vcs_Title"));
generalPane.add(vcsPane); generalPane.add(vcsPane);
remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind")); remindVcsLabel = new UILabel(i18nText("Fine-Design_Vcs_Remind"));
remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit());
vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto")); vcsEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_SaveAuto"));
saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete")); saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(60); saveIntervalEditor = new IntegerEditor(60);
useIntervalCheckBox = new UICheckBox(); useIntervalCheckBox = new UICheckBox();
//gc面板
JPanel gcControlPane = createGcControlPane();
JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(vcsEnableCheckBox);
enableVcsPanel.add(remindVcsLabel); enableVcsPanel.add(remindVcsLabel);
JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
final UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every")); final UILabel everyLabel = new UILabel(i18nText("Fine-Design_Vcs_Every"));
final UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay")); final UILabel delayLabel = new UILabel(i18nText("Fine-Design_Vcs_Delay"));
intervalPanel.add(useIntervalCheckBox); intervalPanel.add(useIntervalCheckBox);
intervalPanel.add(everyLabel); intervalPanel.add(everyLabel);
intervalPanel.add(saveIntervalEditor); intervalPanel.add(saveIntervalEditor);
@ -287,24 +281,60 @@ public class PreferencePane extends BasicPane {
vcsPane.add(enableVcsPanel); vcsPane.add(enableVcsPanel);
vcsPane.add(intervalPanel); vcsPane.add(intervalPanel);
vcsPane.add(saveCommitCheckBox); vcsPane.add(saveCommitCheckBox);
vcsPane.add(gcControlPane);
}
/**
* 模创建板版本gc 配置操作面板
*
* @return 面板
*/
private JPanel createGcControlPane() {
//gc面板
JPanel gcControlPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
JPanel gcButtonPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 40, 0));
gcEnableCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_Storage_Optimization"));
gcButton = initGcButton();
gcButtonPane.add(gcButton);
gcControlPane.add(gcEnableCheckBox);
gcControlPane.add(gcButtonPane);
gcButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
tryGc();
}
});
gcEnableCheckBox.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
gcButton.setEnabled(gcEnableCheckBox.isSelected());
}
});
//集群下禁用
if (ClusterBridge.isClusterMode()) {
gcEnableCheckBox.setEnabled(false);
gcButton.setEnabled(false);
}
return gcControlPane;
} }
private void createFunctionPane(JPanel generalPane) { private void createFunctionPane(JPanel generalPane) {
JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Function")); JPanel functionPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Function"));
generalPane.add(functionPane); generalPane.add(functionPane);
//添加supportUndo选择项 //添加supportUndo选择项
supportUndoCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Undo")); supportUndoCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Undo"));
functionPane.add(supportUndoCheckBox); functionPane.add(supportUndoCheckBox);
//添加maxUndoLimit //添加maxUndoLimit
//String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"}; //String[] undoTimes = {"最大撤销次数","5次","10次","15次","20次","50次"};
String[] undoTimes = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)") String[] undoTimes = {i18nText("Fine-Design_Basic_Max_Undo_Limit"), MAX_UNDO_LIMIT_5 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_10 + i18nText("Fine-Design_Basic_Time(s)")
, MAX_UNDO_LIMIT_15 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Time(s)")}; , MAX_UNDO_LIMIT_15 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_20 + i18nText("Fine-Design_Basic_Time(s)"), MAX_UNDO_LIMIT_50 + i18nText("Fine-Design_Basic_Time(s)")};
maxUndoLimit = new UIComboBox(undoTimes); maxUndoLimit = new UIComboBox(undoTimes);
functionPane.add(maxUndoLimit); functionPane.add(maxUndoLimit);
//不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数 //不支持撤销则不能选择撤销可缓存,也不能设置最大撤销次数
supportUndoCheckBox.addActionListener(new ActionListener() { supportUndoCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
maxUndoLimit.setEnabled(supportUndoCheckBox.isSelected()); maxUndoLimit.setEnabled(supportUndoCheckBox.isSelected());
} }
@ -313,31 +343,32 @@ public class PreferencePane extends BasicPane {
//添加supportDefaultParentCalculate选择项 //添加supportDefaultParentCalculate选择项
supportDefaultParentCalculateCheckBox = new UICheckBox( supportDefaultParentCalculateCheckBox = new UICheckBox(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate")); i18nText("Fine-Design_Basic_Preference_Support_Default_Parent_Calculate"));
functionPane.add(supportDefaultParentCalculateCheckBox); functionPane.add(supportDefaultParentCalculateCheckBox);
} }
private void createEditPane(JPanel generalPane) { private void createEditPane(JPanel generalPane) {
//samuel:编辑器设置 //samuel:编辑器设置
JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Editor_Preference")); JPanel editPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Editor_Preference"));
generalPane.add(editPane); generalPane.add(editPane);
//设置是否支持将字符串编辑为公式 //设置是否支持将字符串编辑为公式
supportStringToFormulaBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Support_String_To_Formula")); supportStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Report_Support_String_To_Formula"));
editPane.add(supportStringToFormulaBox); editPane.add(supportStringToFormulaBox);
//是否默认转化 //是否默认转化
defaultStringToFormulaBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Always")); defaultStringToFormulaBox = new UICheckBox(i18nText("Fine-Design_Basic_Always"));
editPane.add(defaultStringToFormulaBox); editPane.add(defaultStringToFormulaBox);
//不支持转化则不能默认执行 //不支持转化则不能默认执行
supportStringToFormulaBox.addActionListener(new ActionListener() { supportStringToFormulaBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
defaultStringToFormulaBox.setEnabled(supportStringToFormulaBox.isSelected()); defaultStringToFormulaBox.setEnabled(supportStringToFormulaBox.isSelected());
} }
}); });
JPanel keyStrokePane = new JPanel(new BorderLayout()); JPanel keyStrokePane = new JPanel(new BorderLayout());
keyStrokePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST); keyStrokePane.add(new UILabel(i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
shortCutLabel = new UILabel(); shortCutLabel = new UILabel();
keyStrokePane.add(shortCutLabel, BorderLayout.CENTER); keyStrokePane.add(shortCutLabel, BorderLayout.CENTER);
editPane.add(keyStrokePane); editPane.add(keyStrokePane);
@ -367,7 +398,7 @@ public class PreferencePane extends BasicPane {
requestFocusInWindow(); requestFocusInWindow();
label = new UILabel(text); label = new UILabel(text);
add(GUICoreUtils.createBorderLayoutPane( add(GUICoreUtils.createBorderLayoutPane(
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Current_Auto_Complete_Shortcut") + ":"), new UILabel(i18nText("Fine-Design_Basic_Support_Current_Auto_Complete_Shortcut") + ":"),
BorderLayout.WEST, BorderLayout.WEST,
label, label,
BorderLayout.CENTER), BorderLayout.CENTER),
@ -401,24 +432,24 @@ public class PreferencePane extends BasicPane {
private void createGuiOfGridPane(JPanel generalPane) { private void createGuiOfGridPane(JPanel generalPane) {
// GridPane // GridPane
JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Setting_Grid")); JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Grid"));
generalPane.add(guiOfGridPane); generalPane.add(guiOfGridPane);
supportCellEditorDefCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition")); supportCellEditorDefCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition"));
guiOfGridPane.add(supportCellEditorDefCheckBox); guiOfGridPane.add(supportCellEditorDefCheckBox);
isDragPermitedCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited")); isDragPermitedCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited"));
guiOfGridPane.add(isDragPermitedCheckBox); guiOfGridPane.add(isDragPermitedCheckBox);
} }
private void createColorSettingPane(JPanel generalPane) { private void createColorSettingPane(JPanel generalPane) {
// Color Setting Pane // Color Setting Pane
JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Setting_Colors")); JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors"));
generalPane.add(colorSettingPane); generalPane.add(colorSettingPane);
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Grid_Line_Color")); new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color"));
new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color")); new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color"));
gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"));
gridLineColorTBButton.setEnabled(this.isEnabled()); gridLineColorTBButton.setEnabled(this.isEnabled());
@ -427,10 +458,10 @@ public class PreferencePane extends BasicPane {
paginationLineColorTBButton.setEnabled(this.isEnabled()); paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
leftPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Grid_Line_Color") + ":")); leftPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color") + ":"));
leftPane.add(gridLineColorTBButton); leftPane.add(gridLineColorTBButton);
JPanel rightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel rightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
rightPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color") + ":")); rightPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color") + ":"));
rightPane.add(paginationLineColorTBButton); rightPane.add(paginationLineColorTBButton);
colorSettingPane.add(leftPane); colorSettingPane.add(leftPane);
colorSettingPane.add(rightPane); colorSettingPane.add(rightPane);
@ -440,9 +471,9 @@ public class PreferencePane extends BasicPane {
//richer:选择导出log文件的目录. //richer:选择导出log文件的目录.
JPanel logPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); JPanel logPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
advancePane.add(logPane); advancePane.add(logPane);
JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Export_Setting")); JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Export_Setting"));
logPane.add(logExportPane); logPane.add(logExportPane);
UILabel logLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_Export_Log_Directory") + ":"); UILabel logLabel = new UILabel(i18nText("Fine-Design_Basic_Select_Export_Log_Directory") + ":");
logExportPane.add(logLabel, BorderLayout.WEST); logExportPane.add(logLabel, BorderLayout.WEST);
logExportDirectoryField = new UITextField(24); logExportDirectoryField = new UITextField(24);
logExportPane.add(logExportDirectoryField, BorderLayout.CENTER); logExportPane.add(logExportDirectoryField, BorderLayout.CENTER);
@ -450,6 +481,7 @@ public class PreferencePane extends BasicPane {
logExportPane.add(chooseDirBtn, BorderLayout.EAST); logExportPane.add(chooseDirBtn, BorderLayout.EAST);
chooseDirBtn.setPreferredSize(new Dimension(25, 25)); chooseDirBtn.setPreferredSize(new Dimension(25, 25));
chooseDirBtn.addActionListener(new ActionListener() { chooseDirBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
JFileChooser fileChooser = new JFileChooser(); JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@ -461,11 +493,12 @@ public class PreferencePane extends BasicPane {
} }
}); });
JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Level_Setting")); JPanel logLevelPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Level_Setting"));
logPane.add(logLevelPane); logPane.add(logLevelPane);
logLevelComboBox = new UIComboBox(LOG); logLevelComboBox = new UIComboBox(LOG);
logLevelPane.add(logLevelComboBox); logLevelPane.add(logLevelComboBox);
logLevelComboBox.addActionListener(new ActionListener() { logLevelComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Configurations.update(new Worker() { Configurations.update(new Worker() {
@Override @Override
@ -485,13 +518,13 @@ public class PreferencePane extends BasicPane {
private void createLanPane(JPanel generalPane) { private void createLanPane(JPanel generalPane) {
// ben:选择版本语言; // ben:选择版本语言;
JPanel languageAndDashBoard_pane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane(); JPanel languageAndDashBoard_pane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_S_Pane();
JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_Language")); JPanel LanguagePane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Choose_Language"));
generalPane.add(languageAndDashBoard_pane); generalPane.add(languageAndDashBoard_pane);
languageAndDashBoard_pane.add(LanguagePane); languageAndDashBoard_pane.add(LanguagePane);
languageComboBox = createLanguageComboBox(); languageComboBox = createLanguageComboBox();
ActionLabel languageLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Designer_Language")); ActionLabel languageLabel = new ActionLabel(i18nText("Fine-Design_Basic_Designer_Language"));
languageLabel.addActionListener(new ActionListener() { languageLabel.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -505,7 +538,7 @@ public class PreferencePane extends BasicPane {
dlg.setVisible(true); dlg.setVisible(true);
} }
}); });
UILabel noticeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效 UILabel noticeLabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));//sail:提示重启后生效
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double rowSize[] = {p}; double rowSize[] = {p};
double columnSize[] = {p, p, p}; double columnSize[] = {p, p, p};
@ -551,16 +584,16 @@ public class PreferencePane extends BasicPane {
double rowSize[] = {p}; double rowSize[] = {p};
// 长度单位选择 // 长度单位选择
JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Setting_Ruler_Units")); JPanel lengthPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Setting_Ruler_Units"));
advancePane.add(lengthPane); advancePane.add(lengthPane);
pageLengthComboBox = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_MM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH")}); pageLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH")});
pageLengthComboBox.setPreferredSize(new Dimension(80, 20)); pageLengthComboBox.setPreferredSize(new Dimension(80, 20));
pageLengthComboBox.setMinimumSize(new Dimension(80, 20)); pageLengthComboBox.setMinimumSize(new Dimension(80, 20));
reportLengthComboBox = new UIComboBox(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_MM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT_Duplicate")}); reportLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH"), i18nText("Fine-Design_Report_Unit_PT_Duplicate")});
reportLengthComboBox.setPreferredSize(new Dimension(80, 20)); reportLengthComboBox.setPreferredSize(new Dimension(80, 20));
reportLengthComboBox.setMinimumSize(new Dimension(80, 20)); reportLengthComboBox.setMinimumSize(new Dimension(80, 20));
UILabel pagelengthLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":"); UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":");
UILabel reportLengthLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Report_Design_Ruler_Units") + ":"); UILabel reportLengthLabel = new UILabel(i18nText("Fine-Design_Basic_Report_Design_Ruler_Units") + ":");
Component[][] lengthComponents = { Component[][] lengthComponents = {
{pagelengthLabel, pageLengthComboBox, reportLengthLabel, reportLengthComboBox}, {pagelengthLabel, pageLengthComboBox, reportLengthLabel, reportLengthComboBox},
}; };
@ -573,13 +606,13 @@ public class PreferencePane extends BasicPane {
double rowSize[] = {p}; double rowSize[] = {p};
double columnSize[] = {p, p, p}; double columnSize[] = {p, p, p};
JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Port_Setting")); JPanel serverPortPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Web_Preview_Port_Setting"));
advancePane.add(serverPortPane); advancePane.add(serverPortPane);
portEditor = new IntegerEditor(); portEditor = new IntegerEditor();
portEditor.setPreferredSize(new Dimension(80, 20)); portEditor.setPreferredSize(new Dimension(80, 20));
portEditor.setMinimumSize(new Dimension(80, 20)); portEditor.setMinimumSize(new Dimension(80, 20));
UILabel notiJlabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Work_After_Restart_Designer")); UILabel notiJlabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Port") + ":"); UILabel serverPortLabel = new UILabel(i18nText("Fine-Design_Basic_Web_Preview_Port") + ":");
Component[][] portComponents = { Component[][] portComponents = {
{serverPortLabel, portEditor, notiJlabel}, {serverPortLabel, portEditor, notiJlabel},
}; };
@ -588,10 +621,10 @@ public class PreferencePane extends BasicPane {
} }
private JPanel createMemoryPane() { private JPanel createMemoryPane() {
JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template")); JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Caching_Template"));
UILabel memoryLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Max_Caching_Template")); UILabel memoryLabel = new UILabel(i18nText("Fine-Design_Basic_Preference_Max_Caching_Template"));
UILabel memoryTipLabel = FRWidgetFactory.createLineWrapLabel( UILabel memoryTipLabel = FRWidgetFactory.createLineWrapLabel(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip"), MEMORY_TIP_LABEL_MAX_WIDTH); i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip"), MEMORY_TIP_LABEL_MAX_WIDTH);
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0)); memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT); cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
@ -604,7 +637,7 @@ public class PreferencePane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Window_Preference"); return i18nText("Fine-Design_Basic_M_Window_Preference");
} }
/** /**
@ -654,7 +687,8 @@ public class PreferencePane extends BasicPane {
saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval()); saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval());
saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit()); saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit());
useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval());
gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable());
gcButton.setEnabled(gcEnableCheckBox.isSelected());
supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef());
isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited()); isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited());
@ -673,10 +707,10 @@ public class PreferencePane extends BasicPane {
this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort()));
// openDebugComboBox.setSelected(designerEnvManager.isOpenDebug()); openDebugComboBox.setSelected(designerEnvManager.isOpenDebug());
// useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM());
//
// useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM());
this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace());
this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit()); this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit());
@ -685,6 +719,8 @@ public class PreferencePane extends BasicPane {
if (this.autoPushUpdateCheckBox != null) { if (this.autoPushUpdateCheckBox != null) {
this.autoPushUpdateCheckBox.setSelected(designerEnvManager.isAutoPushUpdateEnabled()); this.autoPushUpdateCheckBox.setSelected(designerEnvManager.isAutoPushUpdateEnabled());
} }
this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup());
} }
private int chooseCase(int sign) { private int chooseCase(int sign) {
@ -741,16 +777,29 @@ public class PreferencePane extends BasicPane {
designerEnvManager.setJettyServerPort(portEditor.getValue().intValue()); designerEnvManager.setJettyServerPort(portEditor.getValue().intValue());
// designerEnvManager.setOpenDebug(openDebugComboBox.isSelected()); designerEnvManager.setOpenDebug(openDebugComboBox.isSelected());
designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected());
designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue());
designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected());
designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected());
VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager();
vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue()); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue());
vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected());
vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected());
vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected()); vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected());
Configurations.update(new Worker() {
@Override
public void run() {
GcConfig.getInstance().setGcEnable(gcEnableCheckBox.isSelected());
}
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{GcConfig.class};
}
});
if (this.autoPushUpdateCheckBox != null) { if (this.autoPushUpdateCheckBox != null) {
designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected()); designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected());
} }
@ -772,21 +821,20 @@ public class PreferencePane extends BasicPane {
} }
}); });
// Configurations.update(new Worker() { Configurations.update(new Worker() {
// @Override @Override
// public void run() { public void run() {
// ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected());
// ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected());
// } }
//
// @Override
// public Class<? extends Configuration>[] targets() {
// return new Class[] {ServerPreferenceConfig.class};
// }
// });
@Override
public Class<? extends Configuration>[] targets() {
return new Class[]{ServerPreferenceConfig.class};
} }
});
}
// 如果语言设置改变了,则显示重启对话框 // 如果语言设置改变了,则显示重启对话框
public void showRestartDialog() { public void showRestartDialog() {
@ -795,12 +843,12 @@ public class PreferencePane extends BasicPane {
} }
int rv = JOptionPane.showOptionDialog( int rv = JOptionPane.showOptionDialog(
null, null,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Language_Change_Successful"), i18nText("Fine-Design_Basic_Language_Change_Successful"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION,
JOptionPane.INFORMATION_MESSAGE, JOptionPane.INFORMATION_MESSAGE,
null, null,
new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Restart_Designer_Later")}, new String[]{i18nText("Fine-Design_Basic_Restart_Designer"), i18nText("Fine-Design_Basic_Restart_Designer_Later")},
null null
); );
if (rv == JOptionPane.OK_OPTION) { if (rv == JOptionPane.OK_OPTION) {
@ -822,4 +870,203 @@ public class PreferencePane extends BasicPane {
public BasicDialog showWindow(Window window, DialogActionListener l) { public BasicDialog showWindow(Window window, DialogActionListener l) {
return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT)); return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT));
} }
private void tryGc() {
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
private long size = 0;
@Override
protected Boolean doInBackground() {
size = WorkContext.getCurrent().get(VcsOperator.class).immediatelyGc();
return true;
}
@Override
protected void done() {
try {
get();
} catch (ExecutionException e) {
updateGcDialogPanelInfo(i18nText("Fine-Design_Vcs_Need_Update_Remote_Server_Jar"));
return;
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
updateGcDialogPanelInfo(i18nText("Fine-Design_Vcs_Reduce_File_Size") + fileSizeConvert(size));
gcDialogDownPane.revalidate();
gcDialogDownPane.repaint();
gcDialogDownPane.add(gcOkButton);
}
};
worker.execute();
initGcDialog();
gcOkButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
gcDialog.dispose();
}
});
gcDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
stopGcProgressTimer();
worker.cancel(true);
}
});
gcDialog.setVisible(true);
gcDialog.dispose();
}
/**
* gc 后更新进度条面板信息
*
* @param message
*/
private void updateGcDialogPanelInfo(String message) {
stopGcProgressTimer();
gcMessage.setText(message);
if (null != gcProgressBar) {
gcProgressBarPanel.remove(gcProgressBar);
}
if (null != gcDialog) {
gcDialog.setTitle(i18nText("Fine-Design_Form_Joption_News"));
}
}
/**
* 初始化 gc 对话框
*/
private void initGcDialog() {
gcDialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(PreferencePane.this), i18nText("Fine-Design_Vcs_Clean_Progress") + "...", true);
gcDialog.setSize(new Dimension(340, 140));
JPanel jp = new JPanel();
//中上
JPanel gcUpPane = new JPanel();
gcUpPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
gcUpPane.add(new UILabel(UIManager.getIcon("OptionPane.informationIcon")));
gcProgressBarPanel = createProgressBarPane();
gcUpPane.add(gcProgressBarPanel);
//中下
gcDialogDownPane = new JPanel();
gcDialogDownPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
jp.add(gcUpPane);
jp.add(gcDialogDownPane);
gcDialog.add(jp);
gcDialog.setResizable(false);
gcDialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(PreferencePane.this));
}
/**
* gc 进度条面板
*
* @return
*/
private JPanel createProgressBarPane() {
JPanel jp = new JPanel();
VerticalFlowLayout layout = new VerticalFlowLayout();
layout.setAlignLeft(true);
jp.setLayout(layout);
//提示
gcMessage = new UILabel(i18nText("Fine-Design_Vcs_Cleaning"));
// 创建一个进度条
gcProgressBar = createGcProgressBar(0, 30, 240, 15, Color.GREEN);
gcProgressTimer = createGcProgressTimer(500, gcProgressBar);
gcProgressTimer.start();
jp.add(gcMessage);
jp.add(gcProgressBar);
return jp;
}
/**
* 创建 gc 进度条
*
* @param min 最小值
* @param max 最大值
* @param width 宽度
* @param height 高度
* @param color 填充的图片颜色
* @return
*/
private JProgressBar createGcProgressBar(int min, int max, int width, int height, Color color) {
// 创建一个进度条
JProgressBar progressBar = new JProgressBar(min, max);
UIProgressBarUI progressBarUI = new UIProgressBarUI();
progressBar.setUI(progressBarUI);
//颜色(进度条里的小方块)
progressBar.setForeground(color);
progressBar.setOpaque(false);
progressBar.setPreferredSize(new Dimension(width, height));
return progressBar;
}
/**
* @param delay 每隔 delay 毫秒更新进度
* @param progressBar 要更新的进度条
* @return
*/
private Timer createGcProgressTimer(int delay, final JProgressBar progressBar) {
if (null == progressBar) {
return null;
}
// 模拟延时操作进度, 每隔 delay / 1000 秒更新进度
Timer timer = new Timer(delay, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int currentProgress = progressBar.getValue() + 1;
if (currentProgress > progressBar.getMaximum()) {
currentProgress = progressBar.getMinimum();
}
progressBar.setValue(currentProgress);
}
});
return timer;
}
/**
* 停止进度条模拟计时器
*/
private void stopGcProgressTimer() {
if (null == gcProgressTimer) {
return;
}
gcProgressTimer.stop();
}
/**
* 将字节转换成 KB or MB or GB 保留两位小数
*
* @param size
* @return
*/
private String fileSizeConvert(long size) {
DecimalFormat df = new DecimalFormat("0.00");
double n = 1024d;
if (size > Math.pow(n, 3)) {
return df.format(size / Math.pow(n, 3)) + "GB";
}
if (size > Math.pow(n, 2)) {
return df.format(size / Math.pow(n, 2)) + "MB";
}
return df.format(size / n) + "KB";
}
/**
* 立即清理的Button
*
* @return
*/
private UIButton initGcButton() {
UIButton gcButton = new UIButton(i18nText("Fine-Design_Vcs_Clean"));
gcButton.setPreferredSize(new Dimension(100, 15));
gcButton.setRoundBorder(true, Constants.LEFT);
return gcButton;
}
} }

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;
}
} }

24
designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java

@ -1,24 +1,17 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.config.ServerPreferenceConfig;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.connect.ConnectionManagerPane;
import com.fr.design.data.datapane.connect.ConnectionShowPane; import com.fr.design.data.datapane.connect.ConnectionShowPane;
import com.fr.design.data.datapane.connect.DatabaseConnectionPane; import com.fr.design.data.datapane.connect.DatabaseConnectionPane;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.NameInspector; import com.fr.design.gui.NameInspector;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.dcm.UniversalDatabaseOpener; import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.design.os.impl.DatabaseDialogAction;
import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionConfig;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -60,14 +53,11 @@ public class ConnectionListAction extends UpdateAction {
* @param evt 事件 * @param evt 事件
*/ */
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
if (ServerPreferenceConfig.getInstance().isUseUniverseDBM()) { OSBasedAction osBasedAction = OSSupportCenter.getAction(DatabaseDialogAction.class);
UniversalDatabaseOpener.showUniverseDatabaseDialog(); osBasedAction.execute();
} else {
openDesignDatabaseManager();
}
} }
private void openDesignDatabaseManager() { /* private void openDesignDatabaseManager() {
DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); final ConnectionConfig datasourceManager = ConnectionConfig.getInstance();
final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() {
@ -108,7 +98,7 @@ public class ConnectionListAction extends UpdateAction {
}); });
databaseListDialog.setVisible(true); databaseListDialog.setVisible(true);
} }
*/
/** /**
* 更新datasourceManager * 更新datasourceManager

16
designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java

@ -1,11 +1,11 @@
package com.fr.design.actions.server; package com.fr.design.actions.server;
import com.fr.config.ServerPreferenceConfig;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.extra.WebViewDlgHelper;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
import com.fr.design.upm.UpmFinder; import com.fr.design.os.impl.PMDialogAction;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -16,22 +16,18 @@ import java.awt.event.ActionEvent;
* @since 8.0 * @since 8.0
*/ */
public class PluginManagerAction extends UpdateAction { public class PluginManagerAction extends UpdateAction {
private static String PLUGIN_MANAGER_ROUTE = "#management/plugin";
public PluginManagerAction() { public PluginManagerAction() {
this.setMenuKeySet(PLUGIN_MANAGER); this.setMenuKeySet(PLUGIN_MANAGER);
this.setName(getMenuKeySet().getMenuKeySetName()); this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png")); this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png"));
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
// 可以启用新版本的插件商店(使用JxBrowser作为容器) // 可以启用新版本的插件商店(使用JxBrowser作为容器)
if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) { OSBasedAction osBasedAction = OSSupportCenter.getAction(PMDialogAction.class);
UpmFinder.showUPMDialog(); osBasedAction.execute();
} else {
WebViewDlgHelper.createPluginDialog();
}
} }
public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() {

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){
}
} }

23
designer-base/src/main/java/com/fr/design/beans/BasicStorePane.java

@ -0,0 +1,23 @@
package com.fr.design.beans;
import com.fr.common.annotations.Open;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/9/24
* 数据存取视图界面
*/
@Open
public abstract class BasicStorePane<T> extends BasicBeanPane<T> {
@Override
public T updateBean() {
return null;
}
public abstract void populateBean(T t);
@Override
public abstract void updateBean(T t);
}

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/border/UIRoundedBorder.java

@ -44,13 +44,14 @@ public class UIRoundedBorder extends LineBorder {
return lineStyle; return lineStyle;
} }
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
Color oldColor = g.getColor(); Color oldColor = g.getColor();
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(lineColor); g2d.setColor(lineColor);
GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1, height-1, roundedCorner, roundedCorner),lineStyle); GraphHelper.draw(g2d, new RoundRectangle2D.Double(x, y, width - 1.0D, height - 1.0D, roundedCorner, roundedCorner), lineStyle);
g2d.setColor(oldColor); g2d.setColor(oldColor);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
} }

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;

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

@ -0,0 +1,44 @@
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,
/**
* 启动完成
*/
STARTUP_COMPLETE;
private static DesignerLaunchStatus status;
public static DesignerLaunchStatus getStatus() {
return status;
}
public static void setStatus(DesignerLaunchStatus state) {
status = state;
EventDispatcher.fire(DesignerLaunchStatus.getStatus());
}
}

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);

18
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -2,6 +2,7 @@ package com.fr.design.data;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor; import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.core.DataCoreXmlUtils;
@ -30,6 +31,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException; import com.fr.general.data.TableDataException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
@ -48,8 +50,8 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Timer; import java.util.concurrent.ScheduledExecutorService;
import java.util.TimerTask; import java.util.concurrent.TimeUnit;
/** /**
* 设计器管理操作数据集的类: * 设计器管理操作数据集的类:
@ -444,11 +446,18 @@ public abstract class DesignTableDataManager {
} catch (Exception e) { } catch (Exception e) {
throw new TableDataException(e.getMessage(), e); throw new TableDataException(e.getMessage(), e);
} finally { } finally {
new Timer().schedule(new TimerTask() { ScheduledExecutorService scheduledExecutorService = ModuleContext
.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory(""));
scheduledExecutorService.schedule(new Runnable() {
@Override
public void run() { public void run() {
if (loadingBar != null) {
loadingBar.close(); loadingBar.close();
} }
}, 100); }
}, 100, TimeUnit.MILLISECONDS);
scheduledExecutorService.shutdown();
} }
} }
@ -513,6 +522,7 @@ public abstract class DesignTableDataManager {
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter. if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
final ParameterInputPane pPane = new ParameterInputPane(inParameters); final ParameterInputPane pPane = new ParameterInputPane(inParameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() { public void doOk() {
parameterMap.putAll(pPane.update()); parameterMap.putAll(pPane.update());
} }

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() {

27
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;
@ -217,6 +218,7 @@ 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)) {
@ -249,6 +251,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
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();
} }
@ -264,7 +267,6 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
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));
@ -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();
@ -356,8 +359,8 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
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);
@ -402,6 +405,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
} }
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,6 +480,7 @@ 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("");
@ -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();
@ -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,6 +852,7 @@ 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;
@ -941,6 +949,10 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
loadedTreeModel(); loadedTreeModel();
} }
if (treeModel == null) {
FineLoggerFactory.getLogger().info("The file is wrong or bad, can not create the XMLReader.");
return;
}
if (treeModel.getChildCount(treeModel.getRoot()) == 1) { if (treeModel.getChildCount(treeModel.getRoot()) == 1) {
treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0)); treeModel = new DefaultTreeModel((ExpandMutableTreeNode) treeModel.getChild(treeModel.getRoot(), 0));
} else { } else {
@ -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) {

3
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java

@ -41,6 +41,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
} }
}; };
@Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize(); Dimension dim = super.getPreferredSize();
dim.width = 340; dim.width = 340;
@ -81,7 +82,7 @@ public class MaxMemRowCountPanel extends UIToolbar {
public void setValue(int value) { public void setValue(int value) {
if (value >= 0) { if (value >= 0) {
showMaxPanel(); showMaxPanel();
numberSpinner.setValue(Integer.valueOf(value)); numberSpinner.setValue(value);
} else { } else {
showAllPanel(); showAllPanel();
} }

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);

17
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 {
/** /**

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();
} }

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

@ -168,7 +168,7 @@ public class JWizardPanel extends BasicPane {
public void addNotify() { public void addNotify() {
if (firstNotify) { if (firstNotify) {
Font font = stepTitleLabel.getFont(); Font font = stepTitleLabel.getFont();
font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10); font = font.deriveFont(Font.BOLD, font.getSize() * 14 / 10.0F);
stepTitleLabel.setFont(font); stepTitleLabel.setFont(font);
firstNotify = false; firstNotify = false;
} }

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");
} }

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

@ -96,7 +96,7 @@ public class PluginOperateUtils {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Confirmed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Delete_Confirmed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.OK_CANCEL_OPTION,
JOptionPane.INFORMATION_MESSAGE JOptionPane.WARNING_MESSAGE
); );
if (rv == JOptionPane.OK_OPTION) { if (rv == JOptionPane.OK_OPTION) {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);

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);
} }
} }

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

@ -163,7 +163,7 @@ public class QQLoginWebPane extends JFXPanel {
final BooleanProperty confirmationResult = new SimpleBooleanProperty(); final BooleanProperty confirmationResult = new SimpleBooleanProperty();
// initialize the confirmation dialog // initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.UTILITY); final Stage dialog = new Stage(StageStyle.UTILITY);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2 + DEFAULT_OFFEST); dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2.0D + DEFAULT_OFFEST);
dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 + DEFAULT_OFFEST); dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 + DEFAULT_OFFEST);
dialog.setHeight(DEFAULT_CONFIRM_HEIGHT); dialog.setHeight(DEFAULT_CONFIRM_HEIGHT);
dialog.setWidth(DEFAULT_CONFIRM_WIDTH); dialog.setWidth(DEFAULT_CONFIRM_WIDTH);

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

@ -5,18 +5,16 @@ 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.general.http.HttpToolbox; import com.fr.general.http.HttpToolbox;
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;
@ -260,21 +258,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
@ -290,7 +279,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);
} }

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

@ -53,7 +53,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
null, null,
null null
); );
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return; return;
} }
List<PluginTask> pluginTasks = result.getPreTasks(); List<PluginTask> pluginTasks = result.getPreTasks();
@ -73,7 +73,7 @@ public class InstallFromDiskCallback extends AbstractPluginTaskCallback {
null, null,
null null
); );
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return; return;
} }
PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback); PluginOperateUtils.updatePluginFromDisk(zipFile, jsCallback);

4
designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java

@ -51,7 +51,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
null, null,
null null
); );
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return; return;
} }
List<PluginTask> pluginTasks = result.getPreTasks(); List<PluginTask> pluginTasks = result.getPreTasks();
@ -71,7 +71,7 @@ public class UpdateFromDiskCallback extends AbstractPluginTaskCallback {
null, null,
null null
); );
if (rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) { if (rv == JOptionPane.NO_OPTION || rv == JOptionPane.CANCEL_OPTION || rv == JOptionPane.CLOSED_OPTION) {
return; return;
} }
PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback); PluginOperateUtils.installPluginFromDisk(zipFile, jsCallback);

13
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() {

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

@ -325,7 +325,7 @@ public class MutilTempalteTabPane extends JComponent {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度 double maxWidth = getWidth() - LIST_BUTTON_WIDTH * 1.0D; //最大宽度
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
paintBackgroundAndLine(g2d, maxWidth); paintBackgroundAndLine(g2d, maxWidth);
} }
@ -398,8 +398,8 @@ public class MutilTempalteTabPane extends JComponent {
//画下面的那条线 //画下面的那条线
if (templateStartX < maxWidth) { if (templateStartX < maxWidth) {
GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2);
generalPath.moveTo((float) templateStartX, getHeight() - 1); generalPath.moveTo((float) templateStartX, getHeight() - 1.0F);
generalPath.lineTo((float) maxWidth, getHeight() - 1); generalPath.lineTo((float) maxWidth, getHeight() - 1.0F);
g2d.fill(generalPath); g2d.fill(generalPath);
//TODO hzzz delete //TODO hzzz delete
// g2d.setPaint(UIConstants.LINE_COLOR); // g2d.setPaint(UIConstants.LINE_COLOR);
@ -409,7 +409,7 @@ public class MutilTempalteTabPane extends JComponent {
private void paintDefaultBackground(Graphics2D g2d) { private void paintDefaultBackground(Graphics2D g2d) {
//画默认背景 //画默认背景
g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND)); g2d.setPaint(new GradientPaint(1, 1, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND, 1, getHeight() - 1.0F, UIConstants.TEMPLATE_TAB_PANE_BACKGROUND));
g2d.fillRect(0, 0, getWidth(), getHeight()); g2d.fillRect(0, 0, getWidth(), getHeight());
} }
@ -535,7 +535,7 @@ public class MutilTempalteTabPane extends JComponent {
double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX};
double[] y = {1, getHeight() + 1, getHeight() + 1, 1, 1}; double[] y = {1, getHeight() + 1, getHeight() + 1, 1, 1};
RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7);
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1, UIConstants.SELECT_TAB)); g2d.setPaint(new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, getHeight() - 1.0F, UIConstants.SELECT_TAB));
//选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标
double specialLocation1 = 2.5; double specialLocation1 = 2.5;
double specialLocation2 = 4.330127; double specialLocation2 = 4.330127;
@ -590,9 +590,9 @@ public class MutilTempalteTabPane extends JComponent {
double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX};
double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1};
if (selfIndex == mouseOveredIndex) { if (selfIndex == mouseOveredIndex) {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1, UIConstants.HOVER_BLUE)); g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1.0F, UIConstants.HOVER_BLUE));
} else { } else {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1.0F, UIConstants.SHADOW_GREY));
} }

10
designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java

@ -11,6 +11,7 @@ import com.fr.stable.CoreConstants;
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.authority.AuthorityOperator; import com.fr.workspace.server.authority.AuthorityOperator;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import java.util.ArrayList; import java.util.ArrayList;
@ -39,14 +40,15 @@ public class NodeAuthProcessor {
authPaths.clear(); authPaths.clear();
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
try { try {
String username = WorkContext.getCurrent().getConnection().getUserName(); String userName = WorkContext.getCurrent().getConnection().getUserName();
// 远程设计获取全部设计成员的权限列表 String userId = WorkContext.getCurrent().get(DecisionOperator.class).getUserIdByName(userName);
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(); // 远程设计获取设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities(userId);
DesignAuthority authority = null; DesignAuthority authority = null;
if (authorities != null) { if (authorities != null) {
for (DesignAuthority designAuthority : authorities) { for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) { if (ComparatorUtils.equals(designAuthority.getUsername(), userName)) {
authority = designAuthority; authority = designAuthority;
} }
} }

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();

36
designer-base/src/main/java/com/fr/design/fun/ExportAttrTabProvider.java

@ -1,14 +1,8 @@
package com.fr.design.fun; package com.fr.design.fun;
import com.fr.design.report.AbstractExportPane; import com.fr.design.beans.BasicStorePane;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
import javax.swing.*;
/**
* Created by vito on 16/5/5.
*/
/** /**
* 导出属性Tab页的接口 * 导出属性Tab页的接口
*/ */
@ -18,31 +12,9 @@ public interface ExportAttrTabProvider extends Mutable {
int CURRENT_LEVEL = 1; int CURRENT_LEVEL = 1;
/** /**
* 转换成SwingComponent * 转换成业务视图界面
*
* @return JComponent
*/
JComponent toSwingComponent();
/**
* 转换成AbstractExportPane
*
* @return AbstractExportPane
*/
AbstractExportPane toExportPane();
/**
* tab的标题
*
* @return
*/
String title();
/**
* tag标签
* *
* @return tag名称 * @return 业务视图界面
* @deprecated 将来不使用tag作为区分
*/ */
String tag(); BasicStorePane<?> toServiceComponent();
} }

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();
}

36
designer-base/src/main/java/com/fr/design/fun/impl/AbstractExportAttrTabProvider.java

@ -1,9 +1,14 @@
package com.fr.design.fun.impl; package com.fr.design.fun.impl;
import com.fr.design.beans.BasicStorePane;
import com.fr.design.fun.ExportAttrTabProvider; import com.fr.design.fun.ExportAttrTabProvider;
import com.fr.design.report.AbstractExportPane;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.impl.AbstractProvider;
import com.fr.stable.fun.mark.API; import com.fr.stable.fun.mark.API;
import javax.swing.*;
/** /**
* Created by vito on 16/5/5. * Created by vito on 16/5/5.
*/ */
@ -14,6 +19,37 @@ public abstract class AbstractExportAttrTabProvider extends AbstractProvider imp
return CURRENT_LEVEL; return CURRENT_LEVEL;
} }
/**
* @see ExportAttrTabProvider#toServiceComponent()
*/
@Deprecated
public AbstractExportPane toExportPane() {
return null;
}
/**
* @see ExportAttrTabProvider#toServiceComponent()
*/
@Deprecated
public JComponent toSwingComponent() {
return toServiceComponent();
}
@Deprecated
public String title() {
return StringUtils.EMPTY;
}
@Deprecated
public String tag() {
return StringUtils.EMPTY;
}
@Override
public BasicStorePane<?> toServiceComponent() {
return toExportPane();
}
@Override @Override
public String mark4Provider() { public String mark4Provider() {
return this.getClass().getName(); return this.getClass().getName();

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);

14
designer-base/src/main/java/com/fr/design/gui/borders/UIFrameBorder.java

@ -141,8 +141,8 @@ public class UIFrameBorder extends AbstractBorder implements UIResource {
int spread1 = ThemeUtils.FRAME_SPREAD_DARK_DISABLED; int spread1 = ThemeUtils.FRAME_SPREAD_DARK_DISABLED;
int spread2 = ThemeUtils.FRAME_SPREAD_LIGHT_DISABLED; int spread2 = ThemeUtils.FRAME_SPREAD_LIGHT_DISABLED;
int y2 = y; int y2 = y;
Color borderColor = null; Color borderColor = isActive ? ThemeUtils.FRAME_BORDER_COLOR : ThemeUtils.FRAME_BORDER_DISABLED_COLOR;
drawFirstCaption(g, borderColor, spread1, spread2, x, y2, w); drawFirstCaption(g, borderColor, x, y2, w);
Color c2 = ColorRoutines.darken(c, 4 * spread1); Color c2 = ColorRoutines.darken(c, 4 * spread1);
drawSecondCaption(g, c2, c, spread2, x, y2, w); drawSecondCaption(g, c2, c, spread2, x, y2, w);
c2 = ColorRoutines.darken(c, 6 * spread1); c2 = ColorRoutines.darken(c, 6 * spread1);
@ -257,14 +257,8 @@ public class UIFrameBorder extends AbstractBorder implements UIResource {
g.drawLine(x + w - 4, y2, x + w - 4, y2); g.drawLine(x + w - 4, y2, x + w - 4, y2);
} }
private void drawFirstCaption(Graphics g, Color borderColor, int spread1, int spread2, int x, int y2, int w) {
if (isActive) { private void drawFirstCaption(Graphics g, Color borderColor, int x, int y2, int w) {
borderColor = ThemeUtils.FRAME_BORDER_COLOR;
spread1 = ThemeUtils.FRAME_SPREAD_DARK;
spread2 = ThemeUtils.FRAME_SPREAD_LIGHT;
} else {
borderColor = ThemeUtils.FRAME_BORDER_DISABLED_COLOR;
}
// always paint the semi-transparent parts // always paint the semi-transparent parts
// 1 // 1
// blend // blend

8
designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java

@ -1,12 +1,10 @@
package com.fr.design.gui.chart; package com.fr.design.gui.chart;
import javax.swing.JComponent;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.stable.core.PropertyChangeListener; import com.fr.stable.core.PropertyChangeListener;
import javax.swing.JComponent;
/** /**
* @author kunsnat E-mail:kunsnat@gmail.com * @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-7-10 上午09:19:36 * @version 创建时间2013-7-10 上午09:19:36
@ -19,7 +17,5 @@ public abstract class MiddleChartComponent extends JComponent {
public abstract void reset(); public abstract void reset();
public abstract BaseChart getEditingChart();
public abstract void addStopEditingListener(PropertyChangeListener list); public abstract void addStopEditingListener(PropertyChangeListener list);
} }

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();
} }

6
designer-base/src/main/java/com/fr/design/gui/frpane/CommitTabbedPane.java

@ -296,7 +296,7 @@ public class CommitTabbedPane extends JComponent implements MouseListener, Mous
double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX}; double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX};
double[] y = {-1, getHeight(), getHeight(), -1, -1}; double[] y = {-1, getHeight(), getHeight(), -1, -1};
RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(startX, 1, this.getWidth(), this.getHeight(), 7, 7); RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(startX, 1, this.getWidth(), this.getHeight(), 7, 7);
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length);
generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]);
@ -345,9 +345,9 @@ public class CommitTabbedPane extends JComponent implements MouseListener, Mous
double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX}; double[] x = {startX, startX, startX + tabWidth, startX + tabWidth, startX};
double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1};
if (selfIndex == mouseOveredIndex) { if (selfIndex == mouseOveredIndex) {
g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); g2d.setPaint(new GradientPaint(1, 1, new Color(255, 255, 255), 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
} else { } else {
g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1f, UIConstants.NORMAL_BACKGROUND));
} }

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();

6
designer-base/src/main/java/com/fr/design/gui/ibutton/UIBasicButtonUI.java

@ -321,9 +321,9 @@ public class UIBasicButtonUI extends MetalButtonUI {
//harry: 画带有高光的按钮。 //harry: 画带有高光的按钮。
private void drawHighLightButton(Graphics2D g2, Color color1, Color color2, int w, int h) { private void drawHighLightButton(Graphics2D g2, Color color1, Color color2, int w, int h) {
GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1, color2); GradientPaint buttonPaint = new GradientPaint(0, 0, color1, 0, h - 1f, color2);
GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.2f)); GradientPaint buttonHighLightPaint = new GradientPaint(0, 0, new Color(1.0f, 1.0f, 1.0f, 0.6f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.2f));
GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2, new Color(1.0f, 1.0f, 1.0f, 0.4f)); GradientPaint buttonHighLightLinePaint = new GradientPaint(1, 1, new Color(1.0f, 1.0f, 1.0f, 0.8f), 0, h / 2f, new Color(1.0f, 1.0f, 1.0f, 0.4f));
g2.setPaint(buttonPaint); g2.setPaint(buttonPaint);
g2.fillRoundRect(0, 0, w - 1, h - 1, 3, 3); g2.fillRoundRect(0, 0, w - 1, h - 1, 3, 3);
g2.setPaint(buttonHighLightLinePaint);//按钮内侧高光线(内发光,0%阻塞) g2.setPaint(buttonHighLightLinePaint);//按钮内侧高光线(内发光,0%阻塞)

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java

@ -251,7 +251,7 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
protected void paintOtherBorder(Graphics g) { protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke); g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.draw(shape); g2d.draw(shape);
} }

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButton.java

@ -232,7 +232,7 @@ public class UISliderButton extends JButton implements UIObserver {
protected void paintOtherBorder(Graphics g) { protected void paintOtherBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
g2d.setStroke(borderStroke); g2d.setStroke(borderStroke);
Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1f, getHeight() - 1f, UIConstants.ARC, UIConstants.ARC);
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.draw(shape); g2d.draw(shape);
} }

2
designer-base/src/main/java/com/fr/design/gui/ibutton/UISliderButtonUI.java

@ -176,7 +176,7 @@ public class UISliderButtonUI extends BasicButtonUI {
private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) { private void fillNormal(Graphics2D g2d, int x, int y, int width, int height, boolean isRound, int rectDirection, boolean isAuthorityEdited, boolean isPressedPainted) {
GradientPaint gp; GradientPaint gp;
if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) { if (DesignerMode.isAuthorityEditing() && isAuthorityEdited) {
gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1, UIConstants.AUTHORITY_DARK_BLUE); gp = new GradientPaint(1, 1, UIConstants.AUTHORITY_BLUE, 1, height - 1f, UIConstants.AUTHORITY_DARK_BLUE);
} else if (isPressedPainted) { } else if (isPressedPainted) {
gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB); gp = new GradientPaint(1, 1, UIConstants.SELECT_TAB, 1, height - 1, UIConstants.SELECT_TAB);
}else{ }else{

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"));
} }
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////

20
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -3,10 +3,12 @@ package com.fr.design.gui.iprogressbar;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.stable.os.support.OSBasedAction;
import com.fr.stable.os.support.OSSupportCenter;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -29,7 +31,12 @@ public class ProgressDialog extends UIDialog {
setUndecorated(true); setUndecorated(true);
setSize(parent.getSize()); setSize(parent.getSize());
setLocationRelativeTo(null); setLocationRelativeTo(null);
OSSupportCenter.buildAction(new OSBasedAction() {
@Override
public void execute(Object... objects) {
setOpacity(0.5f); setOpacity(0.5f);
}
}, SupportOSImpl.OPACITY);
initComponent(); initComponent();
} }
@ -47,6 +54,7 @@ public class ProgressDialog extends UIDialog {
progressBar.setBorderPainted(false); progressBar.setBorderPainted(false);
progressBar.setOpaque(false); progressBar.setOpaque(false);
progressBar.setBorder(null); progressBar.setBorder(null);
progressBar.setMaximum(1000);
panel.add(progressBar, BorderLayout.CENTER); panel.add(progressBar, BorderLayout.CENTER);
text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER); text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Project"), JLabel.CENTER);
FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334)); FRFont font = FRFont.getInstance().applySize(14).applyForeground(new ColorUIResource(333334));
@ -54,7 +62,6 @@ public class ProgressDialog extends UIDialog {
panel.add(text, BorderLayout.SOUTH); panel.add(text, BorderLayout.SOUTH);
panel.setVisible(true); panel.setVisible(true);
centerDialog.getContentPane().add(panel); centerDialog.getContentPane().add(panel);
} }
@Override @Override
@ -72,11 +79,20 @@ public class ProgressDialog extends UIDialog {
progressBar.setValue(value); progressBar.setValue(value);
} }
public void setProgressMaximum(int value) {
progressBar.setMaximum(value);
}
public int getProgressMaximum() {
return progressBar.getMaximum();
}
@Override @Override
public void dispose() { public void dispose() {
centerDialog.dispose(); centerDialog.dispose();
super.dispose(); super.dispose();
} }
public void updateLoadingText(String text) { public void updateLoadingText(String text) {
this.text.setText(text); this.text.setText(text);
} }

18
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,16 +1319,16 @@ 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);
newModel.addChangeListener(modelListener); newModel.addChangeListener(modelListener);
scrollbar.repaint(); scrollbar.repaint();
scrollbar.revalidate(); scrollbar.revalidate();
} else if ("orientation" == propertyName) { } else if (StringUtils.equals("orientation", propertyName)) {
updateButtonDirections(); updateButtonDirections();
} else if ("componentOrientation" == propertyName) { } else if (StringUtils.equals("componentOrientation", propertyName)) {
updateButtonDirections(); updateButtonDirections();
InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED); InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED);
SwingUtilities.replaceUIInputMap(scrollbar, JComponent.WHEN_FOCUSED, inputMap); SwingUtilities.replaceUIInputMap(scrollbar, JComponent.WHEN_FOCUSED, inputMap);

25
designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java

@ -9,9 +9,11 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ibutton.UIButtonUI;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.utils.MathUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -37,6 +39,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
private String spinnerName = StringUtils.EMPTY; private String spinnerName = StringUtils.EMPTY;
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
private boolean lessMinValue = false;
public UISpinner(double minValue, double maxValue, double dierta) { public UISpinner(double minValue, double maxValue, double dierta) {
@ -91,6 +94,18 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
return textField; return textField;
} }
public UIButton getNextButton() {
return nextButton;
}
public boolean isLessMinValue() {
return lessMinValue;
}
public void resetLessMinValue() {
lessMinValue = false;
}
public void setValue(double value) { public void setValue(double value) {
setValue(value, true); setValue(value, true);
} }
@ -107,9 +122,10 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
if (globalNameListener != null && shouldResponseNameListener()) { if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName); globalNameListener.setGlobalName(spinnerName);
} }
value = value < minValue ? minValue : value; lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value; value = value > maxValue ? maxValue : value;
if (value == this.value) { if (CommonUtils.equals(value, this.value)) {
return; return;
} }
this.value = value; this.value = value;
@ -129,10 +145,11 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver
if (globalNameListener != null && shouldResponseNameListener()) { if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(spinnerName); globalNameListener.setGlobalName(spinnerName);
} }
value = value < minValue ? minValue : value; lessMinValue = value < minValue;
value = lessMinValue ? minValue : value;
value = value > maxValue ? maxValue : value; value = value > maxValue ? maxValue : value;
if (value == this.value) { if (CommonUtils.equals(value, this.value)) {
return; return;
} }
this.value = value; this.value = value;

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

@ -0,0 +1,46 @@
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 {
private double minValue;
private double maxValue;
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
this.minValue = minValue;
this.maxValue = maxValue;
}
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
this.minValue = minValue;
this.maxValue = maxValue;
}
@Override
protected UINumberField initNumberField() {
return new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
public NumberDocument createNumberDocument() {
return new NumberDocument() {
public boolean isContinueInsertWhenOverMaxOrMinValue() {
return true;
}
};
}
};
}
}

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;
} }

22
designer-base/src/main/java/com/fr/design/gui/itextfield/UIIntNumberField.java

@ -1,11 +1,10 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import com.fr.design.gui.itextfield.UINumberField;
import javax.swing.text.AttributeSet; import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument; import javax.swing.text.PlainDocument;
import java.awt.*; import java.awt.Toolkit;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -16,10 +15,10 @@ import java.awt.*;
*/ */
public class UIIntNumberField extends UINumberField { public class UIIntNumberField extends UINumberField {
public void setFieldDocument() { public void setFieldDocument() {
setDocument(new NumberDocument()); setDocument(createNumberDocument());
} }
class NumberDocument extends PlainDocument { public class NumberDocument extends PlainDocument {
public NumberDocument() { public NumberDocument() {
} }
@ -33,7 +32,7 @@ public class UIIntNumberField extends UINumberField {
String strNew = str.substring(0, offset) + s + str.substring(offset, getLength()); String strNew = str.substring(0, offset) + s + str.substring(offset, getLength());
if (isOverMaxOrMinValue(strNew)) { if (isOverMaxOrMinValue(strNew) && !isContinueInsertWhenOverMaxOrMinValue()) {
Toolkit.getDefaultToolkit().beep(); Toolkit.getDefaultToolkit().beep();
return; return;
} }
@ -42,8 +41,21 @@ public class UIIntNumberField extends UINumberField {
super.insertString(offset, s, a); super.insertString(offset, s, a);
} }
/**
* 是否继续插入输入的字符 - 当超出范围时
*
* @return true : 继续插入输入的字符
*/
public boolean isContinueInsertWhenOverMaxOrMinValue() {
return false;
}
private boolean isOverMaxOrMinValue( String strNew) { private boolean isOverMaxOrMinValue( String strNew) {
return (Double.parseDouble(strNew)<getMinValue() || Double.parseDouble(strNew)>getMaxValue()); return (Double.parseDouble(strNew)<getMinValue() || Double.parseDouble(strNew)>getMaxValue());
} }
} }
public NumberDocument createNumberDocument() {
return new NumberDocument();
}
} }

32
designer-base/src/main/java/com/fr/design/gui/style/FormatePaneNumField.java

@ -1,10 +1,14 @@
package com.fr.design.gui.style; package com.fr.design.gui.style;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.module.ModuleContext;
import com.fr.value.ClearableLazyValue;
import org.jetbrains.annotations.NotNull;
import java.util.Timer; import java.util.concurrent.ScheduledExecutorService;
import java.util.TimerTask; import java.util.concurrent.TimeUnit;
/** /**
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -14,31 +18,35 @@ import java.util.TimerTask;
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
public class FormatePaneNumField extends UITextField { public class FormatePaneNumField extends UITextField {
private Timer timer; private ClearableLazyValue<ScheduledExecutorService> ses = new ClearableLazyValue<ScheduledExecutorService>() {
@NotNull
@Override
protected ScheduledExecutorService compute() {
return ModuleContext.getExecutor()
.newSingleThreadScheduledExecutor(new NamedThreadFactory("FormatePaneNumFieldRunChange"));
}
};
public FormatePaneNumField() { public FormatePaneNumField() {
super(); super();
} }
@Override
protected void attributeChange() { protected void attributeChange() {
if (!AbstractAttrNoScrollPane.isHasChangeListener()) { if (!AbstractAttrNoScrollPane.isHasChangeListener()) {
return; return;
} }
if(timer != null){ ses.getValue().schedule(new Runnable() {
timer.cancel();
}
timer = new Timer();
timer.schedule(new TimerTask() {
@Override @Override
public void run() { public void run() {
runChange(); runChange();
} }
},100); }, 100, TimeUnit.MILLISECONDS);
} }
protected void runChange() { protected void runChange() {
super.attributeChange(); super.attributeChange();
timer.cancel(); ses.getValue().shutdown();
ses.drop();
} }
} }

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);
} }

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

@ -3016,11 +3016,6 @@ private boolean fractionalFontMetricsEnabled;
return he; return he;
} }
private final boolean equal(LinkGeneratorResult e1,
LinkGeneratorResult e2) {
return e1.getSourceOffset()==e2.getSourceOffset();
}
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (getHyperlinksEnabled() && isScanningForLinks && if (getHyperlinksEnabled() && isScanningForLinks &&
@ -3080,8 +3075,7 @@ private boolean fractionalFontMetricsEnabled;
isLinkAtOffset(RSyntaxTextArea.this, offs); isLinkAtOffset(RSyntaxTextArea.this, offs);
if (newResult!=null) { if (newResult!=null) {
// Repaint if we're at a new link now. // Repaint if we're at a new link now.
if (linkGeneratorResult==null || if (linkGeneratorResult==null || newResult.getSourceOffset() != linkGeneratorResult.getSourceOffset()) {
!equal(newResult, linkGeneratorResult)) {
repaint(); repaint();
} }
linkGeneratorResult = newResult; linkGeneratorResult = newResult;

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

@ -8,23 +8,33 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import java.awt.event.*;
import java.util.ResourceBundle;
import java.util.Stack;
import javax.swing.*;
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.FoldCollapser; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldCollapser;
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.rsyntaxtextarea.templates.CodeTemplate; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.templates.CodeTemplate;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter; import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.design.gui.syntax.ui.rtextarea.IconRowHeader; import com.fr.design.gui.syntax.ui.rtextarea.IconRowHeader;
import com.fr.design.gui.syntax.ui.rtextarea.RecordableTextAction;
import com.fr.design.gui.syntax.ui.rtextarea.RTextArea; import com.fr.design.gui.syntax.ui.rtextarea.RTextArea;
import com.fr.design.gui.syntax.ui.rtextarea.RTextAreaEditorKit; import com.fr.design.gui.syntax.ui.rtextarea.RTextAreaEditorKit;
import com.fr.design.gui.syntax.ui.rtextarea.RecordableTextAction;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
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.Segment;
import javax.swing.text.TextAction;
import java.awt.Component;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.util.Objects;
import java.util.Stack;
/** /**
@ -269,8 +279,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
fold.setCollapsed(collapse); fold.setCollapsed(collapse);
} }
possiblyRepaintGutter(textArea); possiblyRepaintGutter(textArea);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }
@ -473,15 +482,13 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
} }
t = t.getNextToken(); t = t.getNextToken();
} }
} } else if (t.length() == 2 && t.charAt(0) == '/' &&
else if (t.length()==2 && t.charAt(0)=='/' &&
(t.charAt(1) == '>' || (t.charAt(1) == '>' ||
t.charAt(1) == ']')) { t.charAt(1) == ']')) {
if (!stack.isEmpty()) { // Always true for valid XML if (!stack.isEmpty()) { // Always true for valid XML
stack.pop(); stack.pop();
} }
} } else if (t.length() == 2 &&
else if (t.length()==2 &&
(t.charAt(0) == '<' || t.charAt(0) == '[') && (t.charAt(0) == '<' || t.charAt(0) == '[') &&
t.charAt(1) == '/') { t.charAt(1) == '/') {
String tagName = null; String tagName = null;
@ -494,7 +501,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
} }
} }
t = t.getNextToken(); t = Objects.requireNonNull(t).getNextToken();
} }
@ -536,8 +543,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
FoldCollapser collapser = new FoldCollapser(); FoldCollapser collapser = new FoldCollapser();
collapser.collapseFolds(rsta.getFoldManager()); collapser.collapseFolds(rsta.getFoldManager());
possiblyRepaintGutter(textArea); possiblyRepaintGutter(textArea);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }
@ -585,8 +591,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
}; };
collapser.collapseFolds(rsta.getFoldManager()); collapser.collapseFolds(rsta.getFoldManager());
possiblyRepaintGutter(textArea); possiblyRepaintGutter(textArea);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }
@ -671,8 +676,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// Shrink by decreaseAmount. // Shrink by decreaseAmount.
ss.font = font.deriveFont(newSize); ss.font = font.deriveFont(newSize);
changed = true; changed = true;
} } else if (oldSize > MINIMUM_SIZE) {
else if (oldSize>MINIMUM_SIZE) {
// Can't shrink by full decreaseAmount, but // Can't shrink by full decreaseAmount, but
// can shrink a little bit. // can shrink a little bit.
ss.font = font.deriveFont(MINIMUM_SIZE); ss.font = font.deriveFont(MINIMUM_SIZE);
@ -690,8 +694,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// Shrink by decreaseAmount. // Shrink by decreaseAmount.
rsta.setFont(font.deriveFont(newSize)); rsta.setFont(font.deriveFont(newSize));
changed = true; changed = true;
} } else if (oldSize > MINIMUM_SIZE) {
else if (oldSize>MINIMUM_SIZE) {
// Can't shrink by full decreaseAmount, but // Can't shrink by full decreaseAmount, but
// can shrink a little bit. // can shrink a little bit.
rsta.setFont(font.deriveFont(MINIMUM_SIZE)); rsta.setFont(font.deriveFont(MINIMUM_SIZE));
@ -717,9 +720,9 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
parent.repaint(); parent.repaint();
} }
} }
} } else {
else
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
}
} }
@ -789,8 +792,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
UIManager.getLookAndFeel(). UIManager.getLookAndFeel().
provideErrorFeedback(textArea); provideErrorFeedback(textArea);
} }
} } else {
else {
Element elem = map.getElement(line1); Element elem = map.getElement(line1);
try { try {
handleDecreaseIndent(elem, document, tabSize); handleDecreaseIndent(elem, document, tabSize);
@ -1038,8 +1040,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
expand(fm.getFold(i)); expand(fm.getFold(i));
} }
possiblyRepaintGutter(rsta); possiblyRepaintGutter(rsta);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }
@ -1128,8 +1129,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// Go to the position AFTER the bracket so the previous // Go to the position AFTER the bracket so the previous
// bracket (which we were just on) is highlighted. // bracket (which we were just on) is highlighted.
rsta.setCaretPosition(bracketInfo.y + 1); rsta.setCaretPosition(bracketInfo.y + 1);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }
@ -1184,8 +1184,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// Grow by increaseAmount. // Grow by increaseAmount.
ss.font = font.deriveFont(newSize); ss.font = font.deriveFont(newSize);
changed = true; changed = true;
} } else if (oldSize < MAXIMUM_SIZE) {
else if (oldSize<MAXIMUM_SIZE) {
// Can't grow by full increaseAmount, but // Can't grow by full increaseAmount, but
// can grow a little bit. // can grow a little bit.
ss.font = font.deriveFont(MAXIMUM_SIZE); ss.font = font.deriveFont(MAXIMUM_SIZE);
@ -1203,8 +1202,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// Grow by increaseAmount. // Grow by increaseAmount.
rsta.setFont(font.deriveFont(newSize)); rsta.setFont(font.deriveFont(newSize));
changed = true; changed = true;
} } else if (oldSize < MAXIMUM_SIZE) {
else if (oldSize<MAXIMUM_SIZE) {
// Can't grow by full increaseAmount, but // Can't grow by full increaseAmount, but
// can grow a little bit. // can grow a little bit.
rsta.setFont(font.deriveFont(MAXIMUM_SIZE)); rsta.setFont(font.deriveFont(MAXIMUM_SIZE));
@ -1230,9 +1228,9 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
parent.repaint(); parent.repaint();
} }
} }
} } else {
else
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
}
} }
@ -1282,9 +1280,10 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
*/ */
private static final int atEndOfLine(int pos, String s, int sLen) { private static final int atEndOfLine(int pos, String s, int sLen) {
for (int i = pos; i < sLen; i++) { for (int i = pos; i < sLen; i++) {
if (!RSyntaxUtilities.isWhitespace(s.charAt(i))) if (!RSyntaxUtilities.isWhitespace(s.charAt(i))) {
return i; return i;
} }
}
return -1; return -1;
} }
@ -1299,8 +1298,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
char ch = t.charAt(0); char ch = t.charAt(0);
if (ch == '{') { if (ch == '{') {
openCount++; openCount++;
} } else if (ch == '}') {
else if (ch=='}') {
openCount--; openCount--;
} }
} }
@ -1323,8 +1321,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
// If we're auto-indenting... // If we're auto-indenting...
if (noSelection && textArea.isAutoIndentEnabled()) { if (noSelection && textArea.isAutoIndentEnabled()) {
insertNewlineWithAutoIndent(textArea); insertNewlineWithAutoIndent(textArea);
} } else {
else {
textArea.replaceSelection("\n"); textArea.replaceSelection("\n");
if (noSelection) { if (noSelection) {
possiblyCloseCurlyBrace(textArea, null); possiblyCloseCurlyBrace(textArea, null);
@ -1472,7 +1469,8 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
if (dotLine != markLine) { if (dotLine != markLine) {
int first = Math.min(dotLine, markLine); int first = Math.min(dotLine, markLine);
int last = Math.max(dotLine, markLine); int last = Math.max(dotLine, markLine);
Element elem; int start; Element elem;
int start;
// Since we're using Document.insertString(), we must mimic the // Since we're using Document.insertString(), we must mimic the
// soft tab behavior provided by RTextArea.replaceSelection(). // soft tab behavior provided by RTextArea.replaceSelection().
@ -1509,8 +1507,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
} finally { } finally {
textArea.endAtomicEdit(); textArea.endAtomicEdit();
} }
} } else {
else {
textArea.replaceSelection("\t"); textArea.replaceSelection("\t");
} }
@ -1559,14 +1556,15 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
if (rsta.isCodeFoldingEnabled()) { // Start of next visible line if (rsta.isCodeFoldingEnabled()) { // Start of next visible line
FoldManager fm = rsta.getFoldManager(); FoldManager fm = rsta.getFoldManager();
int lineCount = root.getElementCount(); int lineCount = root.getElementCount();
while (++line<lineCount && fm.isLineHidden(line)); while (++line < lineCount && fm.isLineHidden(line)) {
;
}
if (line < lineCount) { // Found a lower visible line if (line < lineCount) { // Found a lower visible line
offs = root.getElement(line).getStartOffset(); offs = root.getElement(line).getStartOffset();
} }
// No lower visible line - we're already at last visible offset // No lower visible line - we're already at last visible offset
return offs; return offs;
} } else {
else {
return offs + 1; // Start of next line. return offs + 1; // Start of next line.
} }
} }
@ -1621,8 +1619,9 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
@Override @Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
if (!textArea.isEditable() || !textArea.isEnabled()) if (!textArea.isEditable() || !textArea.isEnabled()) {
return; return;
}
RSyntaxTextArea rsta = (RSyntaxTextArea) textArea; RSyntaxTextArea rsta = (RSyntaxTextArea) textArea;
@ -1726,14 +1725,15 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
RSyntaxTextArea rsta = (RSyntaxTextArea) textArea; RSyntaxTextArea rsta = (RSyntaxTextArea) textArea;
if (rsta.isCodeFoldingEnabled()) { // End of next visible line if (rsta.isCodeFoldingEnabled()) { // End of next visible line
FoldManager fm = rsta.getFoldManager(); FoldManager fm = rsta.getFoldManager();
while (--line>=0 && fm.isLineHidden(line)); while (--line >= 0 && fm.isLineHidden(line)) {
;
}
if (line >= 0) { // Found an earlier visible line if (line >= 0) { // Found an earlier visible line
offs = root.getElement(line).getEndOffset() - 1; offs = root.getElement(line).getEndOffset() - 1;
} }
// No earlier visible line - we must be at offs==0... // No earlier visible line - we must be at offs==0...
return offs; return offs;
} } else {
else {
return start - 1; // End of previous line. return start - 1; // End of previous line.
} }
} }
@ -1879,8 +1879,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
doc.insertString(end + startEnd[0].length(), startEnd[1], doc.insertString(end + startEnd[0].length(), startEnd[1],
null); null);
} }
} } else {
else {
doc.remove(start, startEnd[0].length()); doc.remove(start, startEnd[0].length());
if (startEnd[1] != null) { if (startEnd[1] != null) {
int temp = startEnd[1].length(); int temp = startEnd[1].length();
@ -1923,8 +1922,7 @@ public class RSyntaxTextAreaEditorKit extends RTextAreaEditorKit {
fold.toggleCollapsedState(); fold.toggleCollapsedState();
} }
possiblyRepaintGutter(textArea); possiblyRepaintGutter(textArea);
} } else {
else {
UIManager.getLookAndFeel().provideErrorFeedback(rsta); UIManager.getLookAndFeel().provideErrorFeedback(rsta);
} }
} }

173
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;
/** /**
@ -163,8 +167,7 @@ public class RSyntaxUtilities implements SwingConstants {
case ' ': case ' ':
if (inPreBlock || !lastWasSpace) { if (inPreBlock || !lastWasSpace) {
sb.append(' '); sb.append(' ');
} } else {
else {
sb.append("&nbsp;"); sb.append("&nbsp;");
} }
lastWasSpace = true; lastWasSpace = true;
@ -361,10 +364,11 @@ public class RSyntaxUtilities implements SwingConstants {
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);
@ -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);
} }
@ -487,24 +491,23 @@ public class RSyntaxUtilities implements SwingConstants {
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)) {
@ -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;
@ -557,24 +561,23 @@ public class RSyntaxUtilities implements SwingConstants {
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;
@ -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,
@ -688,29 +691,29 @@ 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);
@ -718,7 +721,9 @@ public class RSyntaxUtilities implements SwingConstants {
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;
} }
} }
@ -729,8 +734,7 @@ public class RSyntaxUtilities implements SwingConstants {
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);
@ -739,7 +743,9 @@ public class RSyntaxUtilities implements SwingConstants {
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 ? pos = current == lineCount ?
target.getLineEndOffset(last) - 1 : // Was the last visible line 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,15 +809,16 @@ 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) {
@ -821,9 +827,7 @@ public class RSyntaxUtilities implements SwingConstants {
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);
} }
@ -869,9 +873,10 @@ return c.getLineStartOffset(line);
*/ */
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;
} }
@ -901,12 +906,14 @@ return c.getLineStartOffset(line);
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;
@ -949,8 +956,7 @@ return c.getLineStartOffset(line);
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--;
} }
@ -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).
* *
@ -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;
} }
@ -1233,15 +1240,16 @@ return c.getLineStartOffset(line);
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;
} }
@ -1280,12 +1288,17 @@ return c.getLineStartOffset(line);
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:

9
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/Style.java

@ -9,6 +9,7 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
@ -123,15 +124,15 @@ public class Style implements Cloneable {
Style clone = null; Style clone = null;
try { try {
clone = (Style)super.clone(); clone = (Style)super.clone();
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
}
clone.foreground = foreground; clone.foreground = foreground;
clone.background = background; clone.background = background;
clone.font = font; clone.font = font;
clone.underline = underline; clone.underline = underline;
clone.fontMetrics = fontMetrics; clone.fontMetrics = fontMetrics;
} catch (CloneNotSupportedException cnse) { // Never happens
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
clone = null;
}
return clone; return clone;
} }

9
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxScheme.java

@ -9,6 +9,7 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Graphics2D; import java.awt.Graphics2D;
@ -122,10 +123,6 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
SyntaxScheme shcs = null; SyntaxScheme shcs = null;
try { try {
shcs = (SyntaxScheme) super.clone(); shcs = (SyntaxScheme) super.clone();
} catch (CloneNotSupportedException cnse) { // Never happens
cnse.printStackTrace();
return null;
}
shcs.styles = new Style[styles.length]; shcs.styles = new Style[styles.length];
for (int i = 0; i < styles.length; i++) { for (int i = 0; i < styles.length; i++) {
Style s = styles[i]; Style s = styles[i];
@ -133,6 +130,10 @@ public class SyntaxScheme implements Cloneable, TokenTypes {
shcs.styles[i] = (Style) s.clone(); shcs.styles[i] = (Style) s.clone();
} }
} }
} catch (CloneNotSupportedException cnse) { // Never happens
FineLoggerFactory.getLogger().error(cnse.getMessage(), cnse);
shcs = null;
}
return shcs; return shcs;
} }

73
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}.
* *
@ -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();
} }
} }
@ -233,8 +245,7 @@ public class SyntaxView extends View implements TabExpander,
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,
@ -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) {
@ -363,7 +374,7 @@ int visibleLineCount = getElement().getElementCount();
if (host.isCodeFoldingEnabled()) { if (host.isCodeFoldingEnabled()) {
visibleLineCount -= host.getFoldManager().getHiddenLineCount(); visibleLineCount -= host.getFoldManager().getHiddenLineCount();
} }
return visibleLineCount * lineHeight; return (float) visibleLineCount * lineHeight;
default: default:
throw new IllegalArgumentException("Invalid axis: " + axis); throw new IllegalArgumentException("Invalid axis: " + axis);
} }
@ -420,8 +431,7 @@ if (fm==null) {
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);
@ -455,8 +465,7 @@ 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) {
@ -501,7 +510,7 @@ else {
// 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;
@ -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
*/ */
@ -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
@ -605,8 +614,7 @@ if (host.isCodeFoldingEnabled()) {
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();
@ -720,8 +728,7 @@ if (host.isCodeFoldingEnabled()) {
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);
} }
@ -846,9 +853,7 @@ if (host.isCodeFoldingEnabled()) {
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!
@ -982,12 +985,14 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
// 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;
} }
} }
}
return -1; return -1;

34
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
@ -1044,7 +1062,7 @@ 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;

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

@ -149,7 +149,7 @@ public class HtmlFoldParser implements FoldParser {
} }
// ?> or %> // ?> or %>
else if (t.startsWith(LANG_END[language])) { else if (currentFold != null && t.startsWith(LANG_END[language])) {
int phpEnd = t.getEndOffset() - 1; int phpEnd = t.getEndOffset() - 1;
currentFold.setEndOffset(phpEnd); currentFold.setEndOffset(phpEnd);
Fold parentFold = currentFold.getParent(); Fold parentFold = currentFold.getParent();

11
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java

@ -10,12 +10,13 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea.modes; package com.fr.design.gui.syntax.ui.rsyntaxtextarea.modes;
import java.io.*; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.AbstractJFlexTokenMaker;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenImpl;
import java.io.IOException;
import java.util.Stack; import java.util.Stack;
import javax.swing.text.Segment; import javax.swing.text.Segment;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.*;
/** /**
* Scanner for makefiles.<p> * Scanner for makefiles.<p>
@ -763,7 +764,7 @@ public final void yybegin(int newState) {
} }
case 25: break; case 25: break;
case 12: case 12:
{ if (!varDepths.empty() && varDepths.peek()==Boolean.TRUE) { { if (!varDepths.empty() && Boolean.TRUE.equals(varDepths.peek())) {
varDepths.pop(); varDepths.pop();
if (varDepths.empty()) { if (varDepths.empty()) {
addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL); addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);
@ -772,7 +773,7 @@ public final void yybegin(int newState) {
} }
case 26: break; case 26: break;
case 11: case 11:
{ if (!varDepths.empty() && varDepths.peek()==Boolean.FALSE) { { if (!varDepths.empty() && Boolean.FALSE.equals(varDepths.peek())) {
varDepths.pop(); varDepths.pop();
if (varDepths.empty()) { if (varDepths.empty()) {
addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL); addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL);

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 {"

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

Loading…
Cancel
Save