Browse Source

Merge pull request #11856 in DESIGN/design from release/11.0 to bugfix/11.0

* commit 'fd8b3a07a211c70551670787f4ef9b94773211f5':
  REPORT-92893 锁定的模板,重复另存副本,设计器页面模板内容不更新--注释
  REPORT-92893 锁定的模板,重复另存副本,设计器页面模板内容不更新
  REPORT-82787 图表空数据提示配置页面,默认图片需补充繁中版
  REPORT-82787 图表空数据提示配置页面,默认图片需补充繁中版
  REPORT-82787 图表空数据提示配置页面,默认图片需补充繁中版
  REPORT-82787 图表空数据提示配置页面,默认图片需补充繁中版
  REPORT-82787 图表空数据提示配置页面,默认图片需补充繁中版
  REPORT-91327 修复BasicTableDataUtilsTest
  REPORT-91327 修复DesignTableDataManagerTest
bugfix/11.0
superman 2 years ago
parent
commit
affd89e889
  1. 2
      designer-base/src/main/java/com/fr/design/lock/LockInfoDialog.java
  2. 63
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java
  3. 14
      designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java
  4. 2
      designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java
  5. 38
      designer-chart/src/main/java/com/fr/design/locale/impl/EmptyDataMark.java
  6. 11
      designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java
  7. 0
      designer-chart/src/main/resources/com/fr/design/images/en_us_emptydata.png
  8. 0
      designer-chart/src/main/resources/com/fr/design/images/zh_cn_emptydata.png
  9. 0
      designer-chart/src/main/resources/com/fr/design/images/zh_tw_emptydata.png

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

@ -99,7 +99,7 @@ public class LockInfoDialog extends JDialog {
return; return;
} }
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath()); final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath());
TemplateUtils.createAndOpenTemplate( TemplateUtils.createAndReOpenTemplate(
Toolkit.i18nText("Fine_Design_Template_Lock_Copy"), Toolkit.i18nText("Fine_Design_Template_Lock_Copy"),
new FileNodeFILE(new FileNode(selectedFilePath, false)), new FileNodeFILE(new FileNode(selectedFilePath, false)),
false, false,

63
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -19,6 +19,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator; import com.fr.workspace.server.lock.TplOperator;
import org.jetbrains.annotations.Nullable;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import java.io.OutputStream; import java.io.OutputStream;
@ -47,7 +48,7 @@ public class TemplateUtils {
} }
/** /**
* 创建新的模板文件并打开模板并在创建备份模板成功后执行doAfterCreate * 创建新的模板文件并并判断新的模板文件是否之前已经被开打如果已经打开需要reOpen
* *
* @param prefix 模板文件名称前缀 * @param prefix 模板文件名称前缀
* @param file 模板文件 * @param file 模板文件
@ -55,14 +56,39 @@ public class TemplateUtils {
* 为true时以CurrentEditingTemplate为准创建新模板 * 为true时以CurrentEditingTemplate为准创建新模板
* 为false时以传入的File文件为准创建新模板此文件可以不是编辑状态 * 为false时以传入的File文件为准创建新模板此文件可以不是编辑状态
* @param openNewTemplate 是否需要在创建后打开模板 * @param openNewTemplate 是否需要在创建后打开模板
* @param doAfterCreateTemplate 创建备份模板成功后调用
*/ */
public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { public static void createAndReOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate) {
String fileName = file.getName();
String oldPath = file.getPath(); String oldPath = file.getPath();
file = getSavedFile(prefix, file);
if (file == null) {
return;
}
Runnable doAfterCreateTemplate;
//判断一下要保存的文件是否已打开
int index = HistoryTemplateListCache.getInstance().contains(file);
if (index == -1) {
doAfterCreateTemplate = () -> {};
} else {
JTemplate template = HistoryTemplateListCache.getInstance().getHistoryList().get(index);
doAfterCreateTemplate = () -> HistoryTemplateListCache.getInstance().closeSelectedReport(template);
}
createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, doAfterCreateTemplate);
}
/**
* 返回值可以为null, 为null表示没有点击保存按钮或者传递进来的文件file本身不满足格式要求
*
* @param prefix 模板文件名称前缀
* @param file 模板文件
* @return 最后选择的要保存的文件
*/
@Nullable
private static FILE getSavedFile(String prefix, FILE file) {
String fileName = file.getName();
int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT); int indexOfLastDot = fileName.lastIndexOf(CoreConstants.DOT);
if (indexOfLastDot < 0) { if (indexOfLastDot < 0) {
return; return null;
} }
String suffix = fileName.substring(indexOfLastDot + 1); String suffix = fileName.substring(indexOfLastDot + 1);
FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true); FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(true, true);
@ -74,15 +100,36 @@ public class TemplateUtils {
fileChooserPane.enableFileNameTextFiled(); fileChooserPane.enableFileNameTextFiled();
if (isCancel(result)) { if (isCancel(result)) {
return; return null;
} }
if (isOk(result)) { if (isOk(result)) {
file = fileChooserPane.getSelectedFILE(); return fileChooserPane.getSelectedFILE();
createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, doAfterCreateTemplate);
} }
return null;
} }
/**
* 创建新的模板文件并打开模板并在创建备份模板成功后执行doAfterCreate
*
* @param prefix 模板文件名称前缀
* @param file 模板文件
* @param createByEditingTemplate 是否根据 当前编辑模板 来创建新模板
* 为true时以CurrentEditingTemplate为准创建新模板
* 为false时以传入的File文件为准创建新模板此文件可以不是编辑状态
* @param openNewTemplate 是否需要在创建后打开模板
* @param doAfterCreateTemplate 创建备份模板成功后调用
*/
public static void createAndOpenTemplate(String prefix, FILE file, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) {
String oldPath = file.getPath();
file = getSavedFile(prefix, file);
if (file == null) {
return;
}
createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, doAfterCreateTemplate);
}
private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) { private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, Runnable doAfterCreateTemplate) {
new SwingWorker<Boolean, Void>() { new SwingWorker<Boolean, Void>() {

14
designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java

@ -50,19 +50,19 @@ public class BasicTableDataUtilsTest extends TestCase {
TableDataSource source = EasyMock.mock(TableDataSource.class); TableDataSource source = EasyMock.mock(TableDataSource.class);
TableData tableData = EasyMock.mock(TableData.class); TableData tableData = EasyMock.mock(TableData.class);
EasyMock.expect(source.getTableData("ds1")).andReturn(tableData).anyTimes(); EasyMock.expect(source.getTableData("ds1")).andReturn(tableData).anyTimes();
EasyMock.expect(source.getTableData("test-ds1")).andReturn(tableData).anyTimes(); EasyMock.expect(source.getTableData("test_ds1")).andReturn(tableData).anyTimes();
EasyMock.expect(source.getTableData("test-ds11")).andReturn(null).anyTimes(); EasyMock.expect(source.getTableData("test_ds11")).andReturn(null).anyTimes();
EasyMock.replay(source, tableData); EasyMock.replay(source, tableData);
Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false)); Assert.assertEquals("test_ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false));
Assert.assertEquals("test-ds11", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false)); Assert.assertEquals("test_ds11", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false));
source = EasyMock.mock(TableDataSource.class); source = EasyMock.mock(TableDataSource.class);
EasyMock.expect(source.getTableData("ds1")).andReturn(null).anyTimes(); EasyMock.expect(source.getTableData("ds1")).andReturn(null).anyTimes();
EasyMock.expect(source.getTableData("test-ds1")).andReturn(null).anyTimes(); EasyMock.expect(source.getTableData("test_ds1")).andReturn(null).anyTimes();
EasyMock.replay(source); EasyMock.replay(source);
Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false)); Assert.assertEquals("test_ds1", BasicTableDataUtils.getTableDataName(true, source, "ds1", "test", false));
Assert.assertEquals("ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false)); Assert.assertEquals("ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", false));
Assert.assertEquals("test-ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", true)); Assert.assertEquals("test_ds1", BasicTableDataUtils.getTableDataName(false, source, "ds1", "test", true));
} }

2
designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java

@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class}) @PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class, TemplateTableDataWrapper.class})
@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) @SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"})
public class DesignTableDataManagerTest { public class DesignTableDataManagerTest {

38
designer-chart/src/main/java/com/fr/design/locale/impl/EmptyDataMark.java

@ -1,38 +0,0 @@
package com.fr.design.locale.impl;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.locale.LocaleMark;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* 根据本地化信息设置服务器图表空数据提示图标
*
* @author obo
* @since 11.0
* Created on 2023/3/22
*/
public class EmptyDataMark implements LocaleMark<BufferedImage> {
private Map<Locale, BufferedImage> map = new HashMap<>();
private static final BufferedImage ZH_EMPTY_DATA = IOUtils.readImage("/com/fr/design/images/zh_emptydata.png");
private static final BufferedImage US_EMPTY_DATA = IOUtils.readImage("/com/fr/design/images/us_emptydata.png");
private static final BufferedImage ZH_TRADITIONAL_EMPTY_DATA = IOUtils.readImage("/com/fr/design/images/zh_traditional_emptydata.png");
public EmptyDataMark() {
map.put(Locale.CHINA, ZH_EMPTY_DATA);
map.put(Locale.US, US_EMPTY_DATA);
map.put(Locale.TAIWAN, ZH_TRADITIONAL_EMPTY_DATA);
}
@Override
public BufferedImage getValue() {
BufferedImage result = map.get(GeneralContext.getLocale());
return result == null ? US_EMPTY_DATA : result;
}
}

11
designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java

@ -10,13 +10,12 @@ import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.locale.impl.EmptyDataMark;
import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane; import com.fr.design.style.background.image.ImagePreviewPane;
import com.fr.design.utils.ImageUtils; import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.image.LocaleImageFactory;
import com.fr.general.locale.LocaleMark; import com.fr.general.locale.image.LocaleImageMark;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper; import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -35,7 +34,6 @@ import java.awt.GridLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
/** /**
@ -63,10 +61,11 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private Image emptyDataImage = DEFAULT_EMPTY_DATA_IMAGE; private Image emptyDataImage = DEFAULT_EMPTY_DATA_IMAGE;
private SwingWorker<Void, Void> imageWorker; private SwingWorker<Void, Void> imageWorker;
private static final String EMPTY_DATA_IMAGE_PATH = "/com/fr/design/images/emptydata.png";
static { static {
LocaleMark<BufferedImage> localeMark = LocaleCenter.getMark(EmptyDataMark.class); LocaleImageMark localeImageMark = LocaleImageFactory.getOrCreateLocaleMark(EMPTY_DATA_IMAGE_PATH);
DEFAULT_EMPTY_DATA_IMAGE = localeMark.getValue(); DEFAULT_EMPTY_DATA_IMAGE = localeImageMark.getValue();
} }
@Override @Override

0
designer-chart/src/main/resources/com/fr/design/images/us_emptydata.png → designer-chart/src/main/resources/com/fr/design/images/en_us_emptydata.png

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

0
designer-chart/src/main/resources/com/fr/design/images/zh_emptydata.png → designer-chart/src/main/resources/com/fr/design/images/zh_cn_emptydata.png

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

0
designer-chart/src/main/resources/com/fr/design/images/zh_traditional_emptydata.png → designer-chart/src/main/resources/com/fr/design/images/zh_tw_emptydata.png

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Loading…
Cancel
Save