Browse Source

Merge branch 'feature/x' of https://code.fineres.com/scm/~yuan.wang/design into feature/x

feature/x
Yuan.Wang 2 years ago
parent
commit
fdc3ca6837
  1. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 11
      designer-base/src/main/java/com/fr/design/data/datapane/SummaryMethodComboBox.java
  3. 17
      designer-base/src/main/java/com/fr/design/file/SaveSomeTemplatePane.java
  4. 17
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 4
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  6. 5
      designer-base/src/main/java/com/fr/env/EnvPrepare.java
  7. 136
      designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java
  8. 5
      designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java
  9. 8
      designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java
  10. 3
      designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java
  11. 9
      designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
  12. 21
      designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java
  13. 15
      designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java
  14. 18
      designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java
  15. 5
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java
  16. 4
      designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java
  17. 8
      designer-form/src/main/java/com/fr/design/form/util/FontTransformUtil.java
  18. 42
      designer-form/src/main/java/com/fr/design/form/util/HtmlPaintUtils.java
  19. 49
      designer-form/src/test/java/com/fr/design/form/util/HtmlPaintUtilsTest.java
  20. 9
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java
  21. 4
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  22. 4
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  23. 59
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  24. 51
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java
  25. 10
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java
  26. 40
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  27. 4
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java
  28. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg
  29. 4
      designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/yellow_bulb.svg

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

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

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

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

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

@ -448,8 +448,8 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/
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 {
// 其它情况下,直接创建暂存文件

5
designer-base/src/main/java/com/fr/env/detect/EnvPrepare.java → designer-base/src/main/java/com/fr/env/EnvPrepare.java vendored

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

136
designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java vendored

@ -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<Null> AFTER_START_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.SERVER_LAUNCH)) {
stop();
}
}
};
private final Listener<Null> BEFORE_START_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
PROCESS.set(DetectorProcess.SERVER_LAUNCH);
start();
}
};
private final Listener<Null> START_UP_COMPLETE_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
};
private final Listener<Workspace> AFTER_SWITCH_LISTENER = new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
};
private final AtomicReference<DetectorProcess> 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<DetectorProcess> 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<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
});
// 切换完成后的监听
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
});
// 打开内置服务器
EventDispatcher.listen(EmbedServerEvent.BeforeStart, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
PROCESS.set(DetectorProcess.SERVER_LAUNCH);
start();
}
});
EventDispatcher.listen(EmbedServerEvent.AfterStart, new Listener<Null>() {
@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<DetectorResult> 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 {
/**

5
designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java vendored

@ -71,6 +71,11 @@ public class DetectorBridge {
}
}
public void reset() {
ThrowableStore.getInstance().reset();
}
/**
* 针对某一项进行检测
* 主要用于手动检测时

8
designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java vendored

@ -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<String, String> remoteMap = groupBy(remoteInfos);
MapDifference<String, String> difference = Maps.difference(localMap, remoteMap);
Map<String, String> diffInCommon = difference.entriesInCommon();
// 获取本地远程不一样的部分
Map<String, MapDifference.ValueDifference<String>> diffs = difference.entriesDiffering();
if (diffInCommon.isEmpty()) {
if (diffs.isEmpty()) {
return DetectorResult.normal(type());
}
Set<String> inConsistentJars = diffInCommon.keySet();
Set<String> 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);

3
designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java vendored

@ -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<BuildInfo> infos) {

9
designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java vendored

@ -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

21
designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java vendored

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

15
designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java vendored

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

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

5
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ChartConditionPane.java

@ -81,7 +81,10 @@ public class ChartConditionPane extends LiteConditionPane<CommonCondition> {
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 = {

4
designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/ColSelectedWithSummaryMethodEditor.java

@ -38,11 +38,11 @@ public class ColSelectedWithSummaryMethodEditor extends Editor<DSColumnWithSumma
}
public static void refreshCommonChartFieldNames(Chart chart) {
//do nothing
refreshComboBoxModel(ChartDataHelper.getCommonChartFieldNames(chart));
}
public static void refreshCustomChartTableFieldNames(Chart chart, CustomPlotType plotType) {
// do nothing
refreshComboBoxModel(ChartDataHelper.getCustomChartTableFieldNames(chart, plotType));
}
private static void refreshComboBoxModel(String[] columnNames) {

8
designer-form/src/main/java/com/fr/design/form/util/FontTransformUtil.java

@ -5,6 +5,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.FormAdaptiveConfigUIProcessor;
import com.fr.stable.Constants;
import com.fr.stable.unit.PT;
import java.math.BigDecimal;
/**
@ -43,4 +44,11 @@ public class FontTransformUtil {
return value * (double) Constants.DEFAULT_FONT_PAINT_RESOLUTION / (double) getDesignerFontResolution();
}
public static int roundUp(double num) {
String numStr = Double.toString(num);
numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString();
return Integer.valueOf(numStr);
}
}

42
designer-form/src/main/java/com/fr/design/form/util/HtmlPaintUtils.java

@ -0,0 +1,42 @@
package com.fr.design.form.util;
import com.fr.base.Style;
import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 富文本导出工具栏
*
* @author hades
* @version 11.0
* Created by hades on 2022/5/19
*/
public class HtmlPaintUtils {
private static final Pattern FONT_SIZE_PATTERN = Pattern.compile(Pattern.quote("font-size:") + "(.*?)" + Pattern.quote("px"));
/**
* 设置单元格字体为富文本中的最大字体
*
* @param style
*/
public static Style deriveMaxFontFromRichChar(Style style, String html) {
int maxSize = style.getFRFont().getSize();
Matcher matcher = FONT_SIZE_PATTERN.matcher(html);
while (matcher.find()) {
String value = matcher.group(1);
try {
double pxSize = Double.parseDouble(value);
int ptSize = FontTransformUtil.roundUp(FontTransformUtil.px2pt(pxSize));
maxSize = Math.max(maxSize, ptSize);
} catch (Throwable e) {
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
}
}
FRFont cellFont = style.getFRFont();
return style.deriveFRFont(cellFont.applySize(maxSize));
}
}

49
designer-form/src/test/java/com/fr/design/form/util/HtmlPaintUtilsTest.java

@ -0,0 +1,49 @@
package com.fr.design.form.util;
import com.fr.base.Style;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/5/25
*/
public class HtmlPaintUtilsTest extends TestCase {
public void testDeriveMaxFontFromRichChar() {
// 富文本字体size更大
String testHtml0 = "<span style=\"font-size:21px;font-family:'宋体';\">这是一条测试数据</span>";
Style style0 = Style.DEFAULT_STYLE;
Assert.assertEquals(16, HtmlPaintUtils.deriveMaxFontFromRichChar(style0, testHtml0).getFRFont().getSize());
// 单元格字体size更大
String testHtml1 = "<span style=\"font-size:7px;font-family:'宋体';\">这是一条测试数据</span>";
Style style1 = Style.DEFAULT_STYLE;
int oldFontSize = style1.getFRFont().getSize();
Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style1, testHtml1).getFRFont().getSize());
// 富文本字体size更大 不同文本 有不同size
String testHtml2 = "<span style=\"font-size:21px;font-family:'宋体';\">这是一条测</span><span style=\"font-size:31px;font-family:'宋体';\">试数</span><span style=\"font-size:21px;font-family:'宋体';\">据</span>";
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 = "<span style=\"font-size:xxxxpx;font-family:'宋体';\">这是一条测试数据</span>";
Style style4 = Style.DEFAULT_STYLE;
oldFontSize = style1.getFRFont().getSize();
Assert.assertEquals(oldFontSize, HtmlPaintUtils.deriveMaxFontFromRichChar(style4, testHtml4).getFRFont().getSize());
}
}

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

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

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

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

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

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

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

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

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/light_yellow_bulb.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="5.40283" y="12.9943" width="5.16667" height="1.20556" rx="0.602778" fill="#FBB03B" fill-opacity="0.7"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.40234 9.68892V10.506C4.10652 9.66092 3.25 8.19854 3.25 6.53611C3.25 3.92043 5.37043 1.8 7.98611 1.8C10.6018 1.8 12.7222 3.92043 12.7222 6.53611C12.7222 8.1985 11.8657 9.66084 10.57 10.5059V11.2724C10.57 11.748 10.1845 12.1335 9.70888 12.1335H6.26443C5.78885 12.1335 5.40332 11.748 5.40332 11.2724V9.64432C5.40267 9.65911 5.40234 9.67398 5.40234 9.68892ZM7.22753 3.55733C7.34074 3.8092 7.22833 4.10516 6.97646 4.21837C6.22719 4.55514 5.67439 5.25006 5.53469 6.08273C5.489 6.35507 5.23119 6.5388 4.95885 6.49311C4.68652 6.44742 4.50278 6.18961 4.54847 5.91727C4.74465 4.74793 5.51914 3.77702 6.56649 3.30627C6.81836 3.19306 7.11432 3.30546 7.22753 3.55733ZM5.71997 7.5277C5.60631 7.27603 5.31015 7.16416 5.05848 7.27782C4.80682 7.39148 4.69494 7.68763 4.8086 7.9393C4.83113 7.98918 4.85479 8.03844 4.87955 8.08703C5.00491 8.33308 5.30599 8.43092 5.55204 8.30556C5.79809 8.1802 5.89593 7.87911 5.77057 7.63306C5.7529 7.59839 5.73603 7.56326 5.71997 7.5277Z" fill="#FBB03B" fill-opacity="0.7"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

4
designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/yellow_bulb.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="5.40283" y="12.9943" width="5.16667" height="1.20556" rx="0.602778" fill="#FBB03B"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.40234 9.68892V10.506C4.10652 9.66092 3.25 8.19854 3.25 6.53611C3.25 3.92043 5.37043 1.8 7.98611 1.8C10.6018 1.8 12.7222 3.92043 12.7222 6.53611C12.7222 8.1985 11.8657 9.66084 10.57 10.5059V11.2724C10.57 11.748 10.1845 12.1335 9.70888 12.1335H6.26443C5.78885 12.1335 5.40332 11.748 5.40332 11.2724V9.64432C5.40267 9.65911 5.40234 9.67398 5.40234 9.68892ZM7.22753 3.55733C7.34074 3.8092 7.22833 4.10516 6.97646 4.21837C6.22719 4.55514 5.67439 5.25006 5.53469 6.08273C5.489 6.35507 5.23119 6.5388 4.95885 6.49311C4.68652 6.44742 4.50278 6.18961 4.54847 5.91727C4.74465 4.74793 5.51914 3.77702 6.56649 3.30627C6.81836 3.19306 7.11432 3.30546 7.22753 3.55733ZM5.71997 7.5277C5.60631 7.27603 5.31015 7.16416 5.05848 7.27782C4.80682 7.39148 4.69494 7.68763 4.8086 7.9393C4.83113 7.98918 4.85479 8.03844 4.87955 8.08703C5.00491 8.33308 5.30599 8.43092 5.55204 8.30556C5.79809 8.1802 5.89593 7.87911 5.77057 7.63306C5.7529 7.59839 5.73603 7.56326 5.71997 7.5277Z" fill="#FBB03B"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

Loading…
Cancel
Save