Browse Source

Merge pull request #9323 in DESIGN/design from release/10.0 to final/10.0

* commit '6164f3b8d9aa85639fd3eebb1f3c47bf194246ff':
  REPORT-71839 设计器启动时启动服务器,仍连曾断开的服务器,会有远程更新提醒
  REPORT-71839 设计器启动时启动服务器,仍连曾断开的服务器,会有远程更新提醒
  REPORT-71839 设计器启动时启动服务器,仍连曾断开的服务器,会有远程更新提醒
  REPORT-71839 设计器启动时启动服务器,仍连曾断开的服务器,会有远程更新提醒
  REPORT-70562 帮助文档 url更新
  REPORT-70562 导出字体字号问题-添加配置
  REPORT-72570 富文本导出问题
  REPORT-71476 新建保存后,目录没有选中模板,重命名不应该高亮 同步到10.0
  REPORT-73106 将参数面板控件剪切到一个新的cpt,原frm界面就变成和cpt一样
superman 2 years ago
parent
commit
2a0d0599b5
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 11
      designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java
  3. 1
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  4. 19
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  5. 10
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  6. 18
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  7. 8
      designer-form/src/main/java/com/fr/design/form/util/FontTransformUtil.java
  8. 42
      designer-form/src/main/java/com/fr/design/form/util/HtmlPaintUtils.java
  9. 49
      designer-form/src/test/java/com/fr/design/form/util/HtmlPaintUtilsTest.java
  10. 9
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextCellEditor.java
  11. 4
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  12. 81
      designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java
  13. 13
      designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java
  14. 12
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

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

@ -427,9 +427,11 @@ public class EnvChangeEntrance {
DesignerExiter.getInstance().execute();
} else {
updateNotRememberPwdEnv();
if (DesignerContext.getDesignerFrame().isVisible()) {
VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName());
}
}
}
@Override
public void doCancel() {

11
designer-base/src/main/java/com/fr/design/gui/ilable/ActionLabel.java

@ -13,11 +13,16 @@ import java.awt.event.MouseEvent;
*/
public class ActionLabel extends UILabel {
private ActionListener actionListener;
private Color color;
public ActionLabel(String text) {
super(text);
this(text, Color.blue);
}
this.setForeground(Color.blue);
public ActionLabel(String text, Color color) {
super(text);
this.color = color;
this.setForeground(color);
this.addMouseListener(mouseInputAdapter);
this.addMouseMotionListener(mouseInputAdapter);
}
@ -33,7 +38,7 @@ public class ActionLabel extends UILabel {
public void paintComponent(Graphics _gfx) {
super.paintComponent(_gfx);
_gfx.setColor(Color.blue);
_gfx.setColor(this.color);
_gfx.drawLine(0, this.getHeight() - 1, this.getWidth(), this.getHeight() - 1);
}

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

@ -1555,6 +1555,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
refreshToolArea();
}
DesignerFrameFileDealerPane.getInstance().refresh();
DesignerFrameFileDealerPane.getInstance().stateChange();
}
});

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

@ -52,6 +52,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.swing.SwingWorker;
/**
* @author pengda
@ -95,9 +96,23 @@ public class VersionCheckUtils {
}
public static void showVersionCheckDialog(String envName) {
if (!VersionCheckUtils.versionCheck(envName)) {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() {
return !VersionCheckUtils.versionCheck(envName);
}
@Override
protected void done() {
try {
if (get()) {
showNotificationDialog(envName);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().warn(e.getMessage(), e);
}
}
}.execute();
}
private static void showNotificationDialog(String envName) {
@ -294,7 +309,7 @@ public class VersionCheckUtils {
private static boolean isPluginNeedIgnore(JSONObject remotePlugin) {
return ComparatorUtils.equals(remotePlugin.getString(RUNNING), "false") || (remotePlugin.containsKey(SYNC) && !remotePlugin.getBoolean(SYNC))
|| (remotePlugin.containsKey(GROUP) && ComparatorUtils.equals(remotePlugin.containsKey(GROUP), BI) || remotePlugin.getString(ID).startsWith(BIPREFIX)
|| (remotePlugin.containsKey(GROUP) && ComparatorUtils.equals(remotePlugin.getString(GROUP), BI) || remotePlugin.getString(ID).startsWith(BIPREFIX)
|| pluginsNeedIgnore.contains(remotePlugin.getString(ID)));
}

10
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -16,6 +16,7 @@ import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.monitor.DesignerLifecycleMonitorContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
@ -84,10 +85,19 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
collectUserInformation();
checkVersion();
}
});
}
private void checkVersion() {
try {
VersionCheckUtils.showVersionCheckDialog(DesignerEnvManager.getEnvManager().getCurEnvName());
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("Check Service Failed");
}
}
public void show() {
UIUtil.invokeLaterIfNeeded(this::refreshTemplateTree);
}

18
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -25,7 +25,6 @@ import com.fr.design.fun.FormWidgetOptionProvider;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection;
import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.utils.ComponentUtils;
import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
@ -140,11 +139,28 @@ public class SelectionModel {
if (cutSelection != null) {
cutSelection.cut2ClipBoard(clipboard);
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED);
setSelectedCreator(hasSelectedParaComponent() ? designer.getParaComponent() : designer.getRootComponent());
designer.repaint();
}
}
}
/**
* 判断是否选中参数面板中的组件
* @return boolean
*/
private boolean hasSelectedParaComponent() {
XCreator[] roots = selection.getSelectedCreators();
if (roots.length > 0) {
for (XCreator creator : roots) {
if ((creator.getParent() instanceof XWParameterLayout)) {
return true;
}
}
}
return false;
}
/**
* 复制当前选中的组件到剪切板
*/

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

81
designer-realize/src/main/java/com/fr/design/report/ExportUniversalPane.java

@ -0,0 +1,81 @@
package com.fr.design.report;
import com.fr.base.CustomConfig;
import com.fr.config.Configuration;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.CloudCenter;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
/**
* @author hades
* @version 11.0
* Created by hades on 2022/5/26
*/
public class ExportUniversalPane extends BasicPane {
private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("help.alt_font.zh_CN", "https://help.fanruan.com/finereport/doc-view-4707.html");
private UICheckBox specialCharacterExport;
public ExportUniversalPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
JPanel outerNorthPane =FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Universal_Export_Config"));
JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
JPanel specialCharacterExportPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
specialCharacterExport = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Universal_Export_Special_Character"));
specialCharacterExport.setSelected(true);
specialCharacterExportPane.add(specialCharacterExport);
northPane.add(specialCharacterExportPane);
JPanel labelPane = new JPanel(new BorderLayout());
labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
UILabel centerLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Universal_Export_Special_Character_Tip"));
centerLabel.setForeground(Color.GRAY);
ActionLabel rightLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Report_Universal_Export_More_Alternative_Fonts"), UIConstants.FLESH_BLUE);
rightLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
BrowseUtils.browser(HELP_URL);
}
});
labelPane.add(centerLabel, BorderLayout.CENTER);
labelPane.add(rightLabel, BorderLayout.EAST);
northPane.add(labelPane);
outerNorthPane.add(northPane);
this.add(outerNorthPane);
}
@Override
protected String title4PopupWindow() {
return "ExportUniversalPane";
}
public void populate() {
this.specialCharacterExport.setSelected(CustomConfig.getInstance().isOptimizedSpecialCharacterExport());
}
public void update() {
Configurations.modify(new WorkerFacade(CustomConfig.class) {
@Override
public void run() {
CustomConfig.getInstance().setOptimizedSpecialCharacterExport(specialCharacterExport.isSelected());
}
});
}
}

13
designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java

@ -5,6 +5,7 @@ import com.fr.design.beans.BasicStorePane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.fun.ExportAttrTabProvider;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.i18n.Toolkit;
import com.fr.io.attr.ReportExportAttr;
import javax.swing.*;
@ -17,12 +18,15 @@ public class ReportExportAttrPane extends BasicPane {
private ExcelExportPane excelExportPane;
private PDFExportPane pdfExportPane;
private WordExportPane wordExportPane;
private ExportUniversalPane exportUniversalPane;
private List<BasicStorePane<?>> paneList;
public ReportExportAttrPane() {
UITabbedPane uiTabbedPane = new UITabbedPane();
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
exportUniversalPane = new ExportUniversalPane();
uiTabbedPane.addTab(Toolkit.i18nText("Fine-Design_Report_Universal_Export"), exportUniversalPane);
excelExportPane = new ExcelExportPane();
uiTabbedPane.addTab("Excel", excelExportPane);
pdfExportPane = new PDFExportPane();
@ -49,6 +53,10 @@ public class ReportExportAttrPane extends BasicPane {
reportExportAttr = new ReportExportAttr();
}
if (this.exportUniversalPane != null) {
this.exportUniversalPane.populate();
}
if (this.excelExportPane != null) {
this.excelExportPane.populate(reportExportAttr.getExcelExportAttr());
}
@ -69,6 +77,11 @@ public class ReportExportAttrPane extends BasicPane {
public ReportExportAttr update() {
ReportExportAttr reportExportAttr = new ReportExportAttr();
if (this.exportUniversalPane != null) {
this.exportUniversalPane.update();
}
if (this.excelExportPane != null) {
reportExportAttr.setExcelExportAttr(this.excelExportPane.update());
}

12
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -61,18 +61,6 @@ public class DesignerWorkspaceProvider extends Activator {
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(null, workspaceInfo);
} else {
WorkContext.switchTo(workspace);
//在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可
final String selectEnv = current;
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null aNull) {
try {
VersionCheckUtils.showVersionCheckDialog(selectEnv);
} catch (Exception e) {
FineLoggerFactory.getLogger().warn("Check Service Failed");
}
}
});
}
} catch (Throwable e) {
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(e, workspaceInfo);

Loading…
Cancel
Save