diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 958d1fa652..8301a0ca32 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -2240,7 +2240,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writer.attr("layoutTemplateStyle", this.getLayoutTemplateStyle()); writer.attr("showServerDatasetAuthTip", this.isShowServerDatasetAuthTip()); writer.attr("useOptimizedUPM4Adapter", this.isUseOptimizedUPM4Adapter()); - writer.attr("propertiesUsable", false); + writer.attr("propertiesUsable", this.isPropertiesUsable()); writer.end(); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java index 7aee00e24d..5e4cc2cd42 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java @@ -40,10 +40,13 @@ public class SummaryMethodComboBox extends UIComboBox { * 更新公式选择. */ public void populateBean(AbstractDataFunction function) { - for (int i = 0; i < CLASS_ARRAY.length; i++) { - if (function != null && ComparatorUtils.equals(function.getClass(), CLASS_ARRAY[i])) { - setSelectedIndex(i); - break; + if (function != null) { + for (int i = 0; i < CLASS_ARRAY.length; i++) { + if (this.getModel() != null && this.getModel().getSize() > i + && ComparatorUtils.equals(function.getClass(), CLASS_ARRAY[i])) { + setSelectedIndex(i); + break; + } } } } diff --git a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java index 6192649aba..72945b31c9 100644 --- a/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java +++ b/designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java @@ -198,23 +198,6 @@ public class SaveSomeTemplatePane extends BasicPane { return true; } - - public int saveLastOneTemplate() { - JTemplate specifiedTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (!specifiedTemplate.isALLSaved()) { - specifiedTemplate.stopEditing(); - int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - if (returnVal == JOptionPane.YES_OPTION) { - specifiedTemplate.saveTemplate(); - FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName())); - } - return returnVal; - } - return JOptionPane.YES_OPTION; - } - - protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save"); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 812cb86b1a..4751649b83 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -172,17 +172,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } //关闭前当前模板 停止编辑 HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().stopEditing(); - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); - // 只有一个文件未保存时 - if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { - int choose = saveSomeTempaltePane.saveLastOneTemplate(); - if (choose != JOptionPane.CANCEL_OPTION) { - DesignerFrame.this.exit(); - } - } else { - if (saveSomeTempaltePane.showSavePane()) { - DesignerFrame.this.exit(); - } + SaveSomeTemplatePane saveSomeTemplatePane = new SaveSomeTemplatePane(true); + // 全部保存成功才退出 + if (saveSomeTemplatePane.showSavePane()) { + DesignerFrame.this.exit(); } } @@ -1225,4 +1218,4 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void setServerConfig(boolean serverConfig) { this.serverConfig = serverConfig; } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index b8e5468dbc..c086ddac97 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -448,8 +448,8 @@ public abstract class JTemplate> */ public FILE templateToStashFile4Envchange() { FILE file = this.getEditingFILE(); - if (file.isEnvFile() && !isSaved()) { - // 切换工作目录时,存在未保存的环境文件时,将其转化为与环境无关的内存文件,再创建暂存文件 + if (file.isEnvFile()) { + // 切换工作目录时,模板锁信息被清除,因此这里需要将环境相关模板文件转化为与环境无关的内存模板文件,再创建暂存文件 return new StashedFILE(new MemFILE(file.getName()), exportBaseBook2ByteArray(), template.suffix()); } else { // 其它情况下,直接创建暂存文件 diff --git a/designer-base/src/main/java/com/fr/env/detect/EnvPrepare.java b/designer-base/src/main/java/com/fr/env/EnvPrepare.java similarity index 82% rename from designer-base/src/main/java/com/fr/env/detect/EnvPrepare.java rename to designer-base/src/main/java/com/fr/env/EnvPrepare.java index 258d579aaa..288d2f09c6 100644 --- a/designer-base/src/main/java/com/fr/env/detect/EnvPrepare.java +++ b/designer-base/src/main/java/com/fr/env/EnvPrepare.java @@ -1,5 +1,6 @@ -package com.fr.env.detect; +package com.fr.env; +import com.fr.env.detect.EnvDetectorCenter; import com.fr.module.Activator; /** @@ -21,6 +22,6 @@ public class EnvPrepare extends Activator { @Override public void stop() { - + EnvDetectorCenter.getInstance().destroy(); } } diff --git a/designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java b/designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java index 98938a4f8e..070d63d850 100644 --- a/designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java +++ b/designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java @@ -10,6 +10,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; import com.fr.env.detect.base.DetectorBridge; import com.fr.env.detect.base.DetectorUtil; +import com.fr.env.detect.base.EnvDetectorConfig; import com.fr.env.detect.bean.DetectorResult; import com.fr.env.detect.bean.DetectorStatus; import com.fr.event.Event; @@ -36,6 +37,43 @@ import java.util.stream.Stream; **/ public class EnvDetectorCenter { + private final Listener AFTER_START_LISTENER = new Listener() { + @Override + public void on(Event event, Null param) { + if (isSameProcess(DetectorProcess.SERVER_LAUNCH)) { + stop(); + } + } + }; + private final Listener BEFORE_START_LISTENER = new Listener() { + @Override + public void on(Event event, Null param) { + PROCESS.set(DetectorProcess.SERVER_LAUNCH); + start(); + } + }; + + + private final Listener START_UP_COMPLETE_LISTENER = new Listener() { + + @Override + public void on(Event event, Null param) { + if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) { + stop(); + } + } + }; + private final Listener AFTER_SWITCH_LISTENER = new Listener() { + @Override + public void on(Event event, Workspace param) { + if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) { + stop(); + } + } + }; + + private final AtomicReference PROCESS = new AtomicReference<>(); + public static EnvDetectorCenter getInstance() { return EnvDetectorCenterHolder.INSTANCE; } @@ -44,54 +82,36 @@ public class EnvDetectorCenter { private static final EnvDetectorCenter INSTANCE = new EnvDetectorCenter(); } - private final AtomicReference PROCESS = new AtomicReference<>(); - /** * 初始化 */ public void init() { + // 如果已经启动了,则不再启动 + if (PROCESS.get() != null) { + return; + } + + start(); // 默认是启动 PROCESS.set(DetectorProcess.DESIGN_LAUNCH); - start(); - - // 添加启动完成监听 - EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener() { - @Override - public void on(Event event, Null param) { - if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) { - stop(); - } - } - }); - - // 切换完成后的监听 - EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { - @Override - public void on(Event event, Workspace param) { - if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) { - stop(); - } - } - }); - - // 打开内置服务器 - EventDispatcher.listen(EmbedServerEvent.BeforeStart, new Listener() { - @Override - public void on(Event event, Null param) { - PROCESS.set(DetectorProcess.SERVER_LAUNCH); - start(); - } - }); - EventDispatcher.listen(EmbedServerEvent.AfterStart, new Listener() { - @Override - public void on(Event event, Null param) { - if (isSameProcess(DetectorProcess.SERVER_LAUNCH)) { - stop(); - } - } - }); + + listen(); + } + + + /** + * 销毁,一般用在模块关闭中 + */ + public void destroy() { + + stopListen(); + // 重置内容 + DetectorBridge.getInstance().reset(); + // 关闭逻辑 + DetectorBridge.getInstance().stop(); + PROCESS.set(null); } /** @@ -121,13 +141,17 @@ public class EnvDetectorCenter { */ public void stop() { - // 一分钟后执行 + // 结束 + DetectorBridge.getInstance().stop(); + + // 30s后执行 DelayHelper.delayCall(EnvDetectorCenter.class.getName(), () -> { - + + // 如果当前没开启,则直接返回 + if (!EnvDetectorConfig.getInstance().isEnabled()) { + return; + } Stream resultStream = DetectorBridge.getInstance().detect(); - - // 结束 - DetectorBridge.getInstance().stop(); // 展示效果 NotificationDialogProperties properties = new NotificationDialogProperties(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title")); @@ -162,6 +186,28 @@ public class EnvDetectorCenter { .collect(Collectors.toList()); } + + private void listen() { + + // 添加启动完成监听 + EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, START_UP_COMPLETE_LISTENER); + + // 切换完成后的监听 + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, AFTER_SWITCH_LISTENER); + + // 内置服务器监听 + EventDispatcher.listen(EmbedServerEvent.BeforeStart, BEFORE_START_LISTENER); + EventDispatcher.listen(EmbedServerEvent.AfterStart, AFTER_START_LISTENER); + } + + private void stopListen() { + + EventDispatcher.stopListen(START_UP_COMPLETE_LISTENER); + EventDispatcher.stopListen(AFTER_SWITCH_LISTENER); + EventDispatcher.stopListen(BEFORE_START_LISTENER); + EventDispatcher.stopListen(AFTER_START_LISTENER); + } + private enum DetectorProcess { /** diff --git a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java index 0d5b60bc09..50bca7fd1c 100644 --- a/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java +++ b/designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java @@ -71,6 +71,11 @@ public class DetectorBridge { } } + public void reset() { + + ThrowableStore.getInstance().reset(); + } + /** * 针对某一项进行检测 * 主要用于手动检测时 diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java b/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java index 679671997b..b13195067b 100644 --- a/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java +++ b/designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java @@ -54,7 +54,6 @@ public class JarInconsistentDetector extends AbstractExceptionDetector { if (WorkContext.getCurrent().isLocal()) { return detectLocal(); - } else { return detectLocalAndRemote(); } @@ -75,13 +74,14 @@ public class JarInconsistentDetector extends AbstractExceptionDetector { Map remoteMap = groupBy(remoteInfos); MapDifference difference = Maps.difference(localMap, remoteMap); - Map diffInCommon = difference.entriesInCommon(); + // 获取本地远程不一样的部分 + Map> diffs = difference.entriesDiffering(); - if (diffInCommon.isEmpty()) { + if (diffs.isEmpty()) { return DetectorResult.normal(type()); } - Set inConsistentJars = diffInCommon.keySet(); + Set inConsistentJars = diffs.keySet(); String message = StringUtils.join(inConsistentJars, SEPARATOR); Message.Simple tipsMessage = new Message.Simple(Toolkit.i18nText("Fine_Design_Basic_Detect_Server") + Toolkit.i18nText(type().getTipsLocale()) + message); diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java b/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java index 74c908000a..8c85da202e 100644 --- a/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java +++ b/designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java @@ -78,7 +78,8 @@ public class JarLackDetector extends AbstractExceptionDetector { } private boolean isLackInfo(BuildInfo e) { - return StringUtils.isNotEmpty(e.getGroupBuild()); + + return StringUtils.isEmpty(e.getGroupBuild()); } private Message tipsMessage(List infos) { diff --git a/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java b/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java index 3432d976d7..ab2b16ed9a 100644 --- a/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java +++ b/designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java @@ -110,13 +110,18 @@ public class ClassConflictConvertor implements ThrowableConverter { } } + // 如果少于两个,则不需要提示 + if (allPath.size() < 2) { + return null; + } + String msg = StringUtils.join(allPath, SEPARATOR); DetectorType type = DetectorType.JAR_CONFLICT; return DetectorResult.exception(type, - ExceptionTips.create(Toolkit.i18nText(type.getTipsLocale(), msg)), + ExceptionTips.create(Toolkit.i18nText(type.getTipsLocale()) + msg), ExceptionSolution.create(Toolkit.i18nText(type.getSolutionLocale()), DetectorConstants.JAR_HELP_LINK, null), - ExceptionLog.create(Toolkit.i18nText(type.getLogLocale()), msg)); + ExceptionLog.create(Toolkit.i18nText(type.getLogLocale()) + msg)); } @NotNull diff --git a/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java b/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java index 14210b8fb2..bcb4736e1d 100644 --- a/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java +++ b/designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java @@ -1,6 +1,6 @@ package com.fr.env.detect.thowable; -import com.fr.log.FineLoggerFactory; +import com.fr.general.FRLogger; import com.fr.log.LogHandler; import com.fr.third.apache.logging.log4j.Level; import com.fr.third.apache.logging.log4j.core.Filter; @@ -32,12 +32,15 @@ public class ThrowableLogAppender extends AbstractAppender { @Override public void append(LogEvent logEvent) { - - if (logEvent.getLevel() == Level.ERROR) { - Throwable thrown = logEvent.getThrown(); - if (thrown != null) { - ThrowableStore.getInstance().add(thrown); + + try { + if (logEvent.getLevel() == Level.ERROR) { + Throwable thrown = logEvent.getThrown(); + if (thrown != null) { + ThrowableStore.getInstance().add(thrown); + } } + } catch (Throwable ignore) { } } @@ -57,11 +60,11 @@ public class ThrowableLogAppender extends AbstractAppender { public void enable() { - FineLoggerFactory.getLogger().addLogAppender(logHandler); + FRLogger.getLogger().addExtendLogAppender(logHandler); } public void disable() { - - FineLoggerFactory.getLogger().removeLogAppender(logHandler); + + FRLogger.getLogger().removeExtendLogAppender(logHandler); } } diff --git a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java index 64d6f41682..96120e317f 100644 --- a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java +++ b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java @@ -166,7 +166,11 @@ public class EnvDetectorDialog extends JDialog { } private void startDetecting(UIButton detectButton) { - + + // 重新检测的时候需要处理一些逻辑 + if (buttonStatus == EnvDetectorButtonStatus.A_NEW) { + reInit(); + } // 执行前 buttonStatus = buttonStatus.next(); UIUtil.invokeLaterIfNeeded(() -> detectButton.setText(buttonStatus.getDesc())); @@ -222,6 +226,15 @@ public class EnvDetectorDialog extends JDialog { detectWorker.execute(); } + private void reInit() { + currentDetectIndex = 0; + for (EnvDetectorItem e : model.getItems()) { + e.setResult(null); + } + // 刷新一下面板-开始执行啦 + UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh); + } + private void stopDetecting(UIButton detectButton) { buttonStatus = buttonStatus.next(); diff --git a/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java b/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java index ec77559856..ea3e72c3f5 100644 --- a/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java +++ b/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java @@ -10,6 +10,8 @@ import com.fr.workspace.WorkContext; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; @@ -62,9 +64,9 @@ public class ConfigToPropMigrator { initDirectory(); try (Connection c = DriverManager.getConnection(url); - FileOutputStream entityOut = new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH); - FileOutputStream classHelperOut = new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH); - FileOutputStream xmlEntityOut = new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH)) { + OutputStreamWriter xmlEntityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH), StandardCharsets.UTF_8); + OutputStreamWriter entityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH), StandardCharsets.UTF_8); + OutputStreamWriter classHelperOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH), StandardCharsets.UTF_8)) { processClassOrEntity(c, new Properties(), SELECT_FOR_ENTITY, entityOut); processClassOrEntity(c, new Properties(), SELECT_FOR_CLASSNAME, classHelperOut); @@ -84,7 +86,7 @@ public class ConfigToPropMigrator { } } - private void processClassOrEntity(Connection c, Properties map, String sql, FileOutputStream outputStream) throws SQLException, IOException { + private void processClassOrEntity(Connection c, Properties map, String sql, OutputStreamWriter writer) throws SQLException, IOException { PreparedStatement query = c.prepareStatement(sql); ResultSet resultSet = query.executeQuery(); while (resultSet.next()) { @@ -94,19 +96,19 @@ public class ConfigToPropMigrator { map.setProperty(id, value); } } - map.store(outputStream, null); + map.store(writer, null); } - private void processXmlEntity(Connection c, Properties map, FileOutputStream outputStream) throws SQLException, IOException { + private void processXmlEntity(Connection c, Properties map, OutputStreamWriter writer) throws SQLException, IOException { PreparedStatement query = c.prepareStatement(SELECT_FOR_XML_ENTITY); ResultSet resultSet = query.executeQuery(); while (resultSet.next()) { String id = resultSet.getString(1); Blob value = resultSet.getBlob(2); byte[] bytes = value.getBytes(1L, (int) value.length()); - map.setProperty(id, new String(bytes)); + map.setProperty(id, new String(bytes, StandardCharsets.UTF_8)); } - map.store(outputStream, null); + map.store(writer, null); } public void deletePropertiesCache() { diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java index 73ee26234b..4085c7f10c 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java @@ -81,7 +81,10 @@ public class ChartConditionPane extends LiteConditionPane { return this; } }); - conditionValuePane = ValueEditorPaneFactory.createAllValueEditorPane(); + Editor[] editors = ValueEditorPaneFactory.allEditors(); + ColSelectedWithSummaryMethodEditor colSelectedWithSummaryMethodEditor = new ColSelectedWithSummaryMethodEditor(); + Editor[] allEditors = ArrayUtils.add(editors,colSelectedWithSummaryMethodEditor); + conditionValuePane = ValueEditorPaneFactory.createValueEditorPane(allEditors,StringUtils.EMPTY,StringUtils.EMPTY); conditionKeyComboBox.setPreferredSize(new Dimension(175, conditionKeyComboBox.getPreferredSize().height)); conditionOPComboBox.setPreferredSize(new Dimension(80, 20)); Component[][] components = { diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java index a949e9ecde..5388684e74 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java @@ -38,11 +38,11 @@ public class ColSelectedWithSummaryMethodEditor extends Editor这是一条测试数据"; + Style style0 = Style.DEFAULT_STYLE; + Assert.assertEquals(16, HtmlPaintUtils.deriveMaxFontFromRichChar(style0, testHtml0).getFRFont().getSize()); + + // 单元格字体size更大 + String testHtml1 = "这是一条测试数据"; + Style style1 = Style.DEFAULT_STYLE; + int oldFontSize = style1.getFRFont().getSize(); + Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style1, testHtml1).getFRFont().getSize()); + + // 富文本字体size更大 不同文本 有不同size + String testHtml2 = "这是一条测试数"; + Style style2 = Style.DEFAULT_STYLE; + Assert.assertEquals(23, HtmlPaintUtils.deriveMaxFontFromRichChar(style2, testHtml2).getFRFont().getSize()); + + + // 异常场景1 + String testHtml3 = "xxxx奇怪的格式xxxx"; + Style style3 = Style.DEFAULT_STYLE; + oldFontSize = style1.getFRFont().getSize(); + Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style3, testHtml3).getFRFont().getSize()); + + // 异常场景2 + String testHtml4 = "这是一条测试数据"; + Style style4 = Style.DEFAULT_STYLE; + oldFontSize = style1.getFRFont().getSize(); + Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style4, testHtml4).getFRFont().getSize()); + + + } + + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java index 1019281355..1d2a5eda26 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java @@ -1,5 +1,8 @@ package com.fr.design.cell.editor; +import com.fr.design.mainframe.DesignerContext; +import com.fr.general.GeneralUtils; +import com.fr.design.form.util.HtmlPaintUtils; import java.awt.Component; import javax.swing.SwingUtilities; @@ -42,6 +45,11 @@ public class RichTextCellEditor extends AbstractCellEditor implements @Override public void doOk() { RichTextCellEditor.this.fireEditingStopped(); + CellElement newCellElement = parentTplEC.getTemplateCellElement(cellElement.getColumn(), cellElement.getRow()); + if (cellElement.getCellGUIAttr().isShowAsHTML()) { + newCellElement.setStyle(HtmlPaintUtils.deriveMaxFontFromRichChar(newCellElement.getStyle(), GeneralUtils.objectToString(newCellElement.getValue()))); + DesignerContext.getDesignerFrame().refreshToolbar(); + } } @Override @@ -49,7 +57,6 @@ public class RichTextCellEditor extends AbstractCellEditor implements RichTextCellEditor.this.fireEditingCanceled(); } }); - richTextDialog.addDialogActionListener(this); this.richTextPane.populate(parentTplEC, cellElement); setShowAsHtml(cellElement); diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index f95681be32..74654cd2ef 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -366,9 +366,7 @@ public class RichTextToolBar extends BasicPane { }; private int roundUp(double num) { - String numStr = Double.toString(num); - numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); - return Integer.valueOf(numStr); + return FontTransformUtil.roundUp(num); } private CaretListener textCareListener = new CaretListener() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java index 9ceec2a2f8..8de2a0d637 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java @@ -191,7 +191,9 @@ public class AlphaFineConstants { public static final Icon BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bulb.svg"); - public static final Icon BLUE_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/blue_bulb.svg"); + public static final Icon YELLOW_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/yellow_bulb.svg"); + + public static final Icon LIGHT_YELLOW_BULB_ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg"); public static final String HOT_SEARCH = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Hot_Search"); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index db89cf3482..b6819f56ca 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -33,6 +33,7 @@ import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager; import com.fr.design.mainframe.alphafine.search.manager.impl.SegmentationManager; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; import java.awt.BorderLayout; @@ -66,8 +67,11 @@ import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.SwingConstants; import javax.swing.Timer; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; /** * @author hades @@ -241,13 +245,10 @@ public class AlphaFineFrame extends JFrame { topRightPane.setBackground(Color.WHITE); JPanel tipPane = new JPanel(new BorderLayout()); tipPane.setBackground(Color.WHITE); - String toolTip = AlphaFineShortCutUtil.getDisplayShortCut(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Short_Cut", DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortcuts())); tipIconLabel = new UILabel(AlphaFineConstants.BULB_ICON); tipIconLabel.addMouseListener(tipMouseListener); - tipIconLabel.setToolTipText(toolTip); useTipLabel = new UILabel(SKILLS); useTipLabel.addMouseListener(tipMouseListener); - useTipLabel.setToolTipText(toolTip); useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); tipPane.add(tipIconLabel, BorderLayout.WEST); tipPane.add(useTipLabel, BorderLayout.CENTER); @@ -264,19 +265,63 @@ public class AlphaFineFrame extends JFrame { private MouseAdapter tipMouseListener = new MouseAdapter() { + private JPopupMenu popupMenu; + @Override public void mouseEntered(MouseEvent e) { - useTipLabel.setForeground(UIConstants.FLESH_BLUE); - tipIconLabel.setIcon(AlphaFineConstants.BLUE_BULB_ICON); + tipIconLabel.setIcon(AlphaFineConstants.YELLOW_BULB_ICON); } @Override public void mouseExited(MouseEvent e) { - useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); - tipIconLabel.setIcon(AlphaFineConstants.BULB_ICON); + if (popupMenu == null || !popupMenu.isShowing()) { + useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); + tipIconLabel.setIcon(AlphaFineConstants.BULB_ICON); + } + } + + @Override + public void mousePressed(MouseEvent e) { + useTipLabel.setForeground(UIConstants.FLESH_BLUE); + tipIconLabel.setIcon(AlphaFineConstants.LIGHT_YELLOW_BULB_ICON); + popupMenu = createTipPop(); + GUICoreUtils.showPopupMenu(popupMenu, e.getComponent(), e.getComponent().getX() - 60, e.getComponent().getY() + 20); } }; + + private JPopupMenu createTipPop() { + JPanel panel = new JPanel(new BorderLayout()); + String toolTip = AlphaFineShortCutUtil.getDisplayShortCut(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Short_Cut", DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getShortcuts())); + UILabel label = new UILabel(toolTip); + label.setForeground(AlphaFineConstants.FOREGROUND_COLOR_8); + label.setBackground(Color.WHITE); + panel.add(label); + panel.setBackground(Color.WHITE); + JPopupMenu popupMenu = new JPopupMenu(); + popupMenu.setBorder(BorderFactory.createEmptyBorder(20, 5, 10, 5)); + popupMenu.add(panel); + popupMenu.setBackground(Color.WHITE); + popupMenu.addPopupMenuListener(new PopupMenuListener() { + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + // do nothing + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + useTipLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6); + tipIconLabel.setIcon(AlphaFineConstants.BULB_ICON); + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + // do nothing + } + }); + return popupMenu; + } + private JPanel createSearchPane() { JPanel searchPane = new JPanel(new BorderLayout()); searchPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index eeaf8f920f..742629af01 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -421,25 +421,37 @@ public class CellOtherSetPane extends AbstractCellAttrPane { @Override public void itemStateChanged(ItemEvent e) { - Style elementStyle = cellElement.getStyle(); - FRFont frFont = elementStyle.getFRFont(); - if (showContent.getSelectedIndex() == 3) { - fileNamePane.setPreferredSize(new Dimension(100, 20)); - fileNameLayout.show(fileNamePane, "content"); - frFont = frFont.applyForeground(Color.blue); - frFont = frFont.applyUnderline(Constants.LINE_THIN); - } else { - fileNameLayout.show(fileNamePane, "none"); - fileNamePane.setPreferredSize(new Dimension(0, 0)); - frFont = frFont.applyForeground(Color.black); - frFont = frFont.applyUnderline(Constants.LINE_NONE); + if (e.getStateChange() == ItemEvent.SELECTED) { + if (showContent.getSelectedIndex() == 3) { + fileNamePane.setPreferredSize(new Dimension(100, 20)); + fileNameLayout.show(fileNamePane, "content"); + } else { + fileNameLayout.show(fileNamePane, "none"); + fileNamePane.setPreferredSize(new Dimension(0, 0)); + } + handleCellShowStyleChange(e); } - cellElement.setStyle(elementStyle.deriveFRFont(frFont)); } }); return fileNamePane; } + private void handleCellShowStyleChange(ItemEvent itemEvent) { + CellGUIAttr cellGUIAttr = getCellGUIAttr(); + int selectedIndex = showContent.getSelectedIndex(); + boolean showAsDownload = cellGUIAttr.isShowAsDownload(); + Style elementStyle = cellElement.getStyle(); + FRFont frFont = elementStyle.getFRFont(); + if (!showAsDownload && selectedIndex == 3) { + frFont = frFont.applyForeground(Color.blue); + frFont = frFont.applyUnderline(Constants.LINE_THIN); + } else if (showAsDownload && selectedIndex != 3) { + frFont = frFont.applyForeground(Color.black); + frFont = frFont.applyUnderline(Constants.LINE_NONE); + } + cellElement.setStyle(elementStyle.deriveFRFont(frFont)); + } + private void initAllNames() { defaultAutoRadioButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Follow_Paper_Settings")); @@ -475,15 +487,20 @@ public class CellOtherSetPane extends AbstractCellAttrPane { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Other"); } + private CellGUIAttr getCellGUIAttr() { + CellGUIAttr cellGUIAttr = cellElement.getCellGUIAttr(); + if (cellGUIAttr == null) { + cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; + } + return cellGUIAttr; + } + @Override protected void populateBean() { this.currentPageFixedRowDataTipLabel.setText(" (" + Toolkit.i18nText("Fine-Design_Report_CellWrite_No_Page_Fixed_Row_Cell") + ")"); this.pageFixedRowDataCell = null; checkPageFixedRow(); - CellGUIAttr cellGUIAttr = cellElement.getCellGUIAttr(); - if (cellGUIAttr == null) { - cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; - } + CellGUIAttr cellGUIAttr = getCellGUIAttr(); // 支持 跟随页面设置 选项 = 不在编辑表单中的报表块 && 不在大屏模板cpt组件中 boolean supportFollowTplDefine = !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT) diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index 9ac98286e8..0518c6884f 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java @@ -35,6 +35,7 @@ import com.fr.design.mainframe.share.ui.base.ui.PlaceHolderUI; import com.fr.design.mainframe.share.util.ShareUIUtils; import com.fr.design.share.effect.EffectItemGroup; import com.fr.design.share.utils.ShareDialogUtils; +import com.fr.file.FileCommonUtils; import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.bean.StyleThemeBean; import com.fr.form.share.constants.ShareComponentConstants; @@ -659,6 +660,15 @@ public class ShareMainPane extends JPanel { Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); return false; } + if (FileCommonUtils.isFileNameValid(name)) { + FineJOptionPane.showMessageDialog( + shareDialog, + Toolkit.i18nText("Fine-Design_Share_Generate_Failure_Illegal_Component_Name_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon")); + return false; + } if (upload && StringUtils.isEmpty(content.getText())) { FineJOptionPane.showMessageDialog(shareDialog, Toolkit.i18nText("Fine-Design_Share_Lack_Content"), Toolkit.i18nText("Fine-Design_Basic_Error"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 917de56f0d..4149753f72 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -158,26 +158,26 @@ public class DesignerStartup extends Activator { private void registerDaoSelector() { // 注入设计器db cache 是否可用 - DaoSelectorFactory.registerDaoSelector(() -> false); -// DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); -// if (info.getType() == DesignerWorkspaceType.Remote) { -// } else { -// String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); -// String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, -// EncryptionConstants.PROPERTY_NAME); -// String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); -// String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); -// String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); -// // 校验 平台迁移文件/缓存文件 -// boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); -// DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() -// && OptimizeUtil.isOpen() -// && existPropCache -// // demo启动时 前后目录可能会不一致 造成读取缓存失败 -// && !startupArgsValue.getValue().isDemo() -// && !new File(dbConfigPath).exists()); -// -// } + DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); + if (info.getType() == DesignerWorkspaceType.Remote) { + DaoSelectorFactory.registerDaoSelector(() -> false); + } else { + String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); + String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, + EncryptionConstants.PROPERTY_NAME); + String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); + String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); + String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); + // 校验 平台迁移文件/缓存文件 + boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); + DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() + && OptimizeUtil.isOpen() + && existPropCache + // demo启动时 前后目录可能会不一致 造成读取缓存失败 + && !startupArgsValue.getValue().isDemo() + && !new File(dbConfigPath).exists()); + + } } private String generatePath(String webInfPath, String name) { diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index 65cdc1c30d..fa795fb372 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -2,6 +2,7 @@ package com.fr.start.module; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; +import com.fr.design.file.TemplateResourceManager; import com.fr.design.utils.DesignUtils; import com.fr.file.TmpFileUtils; import com.fr.general.CloudCenter; @@ -28,6 +29,9 @@ public class PreStartActivator extends Activator { // 创建监听服务 DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix()); + // 在插件引擎模块起来前 初始化下插件接口监听 + TemplateResourceManager.getResource(); + initLanguage(); } diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg new file mode 100644 index 0000000000..16608753f1 --- /dev/null +++ b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg @@ -0,0 +1,4 @@ + + + + diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/yellow_bulb.svg b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/yellow_bulb.svg new file mode 100644 index 0000000000..cabda1d9d9 --- /dev/null +++ b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/yellow_bulb.svg @@ -0,0 +1,4 @@ + + + +