Browse Source

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

* commit '99ef284a333d73c96f89fff400506e6e4af3d6b0':
  无jira任务 单元测试
  REPORT-102243 修复图表富文本编辑器自定义样式图标异常
  REPORT-101409 【版本管理三期】删除无权限的版本没有失败提示
  REPORT-101409 【版本管理三期】删除无权限的版本没有失败提示
  REPORT-79271 feat:兼容处理调整为新增功能点
  REPORT-79271 feat:考虑兼容
  REPORT-101740 【版本管理三期】版本中心打开被锁定的模板,没有提示
  REPORT-101800 修改单元格内容的格式,单元格内容会清空 【问题原因】编辑一个新的单元格时,对单元格属性进行修改,之前的方式 getCellElements 拿到的并不是实际正在编辑的单元格,拿到的是一个手动创建的对象(单元格内容为null),后续对单元格进行更新时,单元格的内容被覆盖更新为null。 【改动思路】获取当前编辑的所有单元格均使用 getAllCellElements
  REPORT-79271 feat:FVS支持图表单元格数据来源
  REPORT-101740 【版本管理三期】版本中心打开被锁定的模板,没有提示
  REPORT-87551 对模板进行重命名后,版本管理仍存在,但是每个版本内容都是一样的
bugfix/11.0
superman 11 months ago
parent
commit
dc2c430a07
  1. 17
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  2. 11
      designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java
  3. 14
      designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java
  4. 40
      designer-base/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java
  5. 14
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  6. 37
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java
  7. 31
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java
  8. 9
      designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java
  9. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java
  10. 4
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  11. 2
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java
  12. 6
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

17
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -239,11 +239,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
String lock = node.getLock();
boolean showLockInfo = LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo()
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)
? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
boolean showLockInfo = needShowLockInfo(lock, selectedFilePath, node);
if (showLockInfo) {
UserInfo userInfo = WorkContext.getCurrent().get(LockInfoOperator.class).getUserInfo(selectedFilePath);
node.setLock(UUID.randomUUID().toString());
@ -257,6 +253,17 @@ public class TemplateTreePane extends JPanel implements FileOperations {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
}
/**
* 是否需要展示锁定信息
*/
public static boolean needShowLockInfo(String lock, String selectedFilePath, FileNode node) {
return LockInfoUtils.isCompatibleOperator()
|| LockInfoUtils.unableGetLockInfo()
|| WorkContext.getCurrent().get(LockInfoOperator.class).isTplUnLocked(selectedFilePath)
? (lock != null && !lock.equals(node.getUserID()))
: WorkContext.getCurrent().get(LockInfoOperator.class).isTplLocked(selectedFilePath);
}
private void checkDevelopForBiddenTemplate(String selectedFilePath) {
JTemplate<?, ?> template = getOpenedTemplate(selectedFilePath);
if (template != null && template.isForbidden()) {

11
designer-base/src/main/java/com/fr/design/jxbrowser/MimeType.java

@ -83,21 +83,20 @@ public enum MimeType {
* 如果没有尝试使用 Files.probeContentType 检测
* 如果没有默认返回 text/html
*
* @param url url路径
* @param resourcePath 资源路径
* @return MimeType
*/
public static String parseMimeType(String url) {
if (StringUtils.isBlank(url)) {
public static String parseMimeType(String resourcePath) {
if (StringUtils.isBlank(resourcePath)) {
return HTML.mimeType;
}
String finalPath = url.split("\\?")[0];
Optional<MimeType> mimeType = Arrays.stream(values())
.filter(type -> finalPath.endsWith(type.suffix))
.filter(type -> resourcePath.endsWith(type.suffix))
.findFirst();
if (mimeType.isPresent()) {
return mimeType.get().mimeType;
} else {
return getFileMimeType(finalPath);
return getFileMimeType(resourcePath);
}
}

14
designer-base/src/main/java/com/fr/design/jxbrowser/NxInterceptRequestCallback.java

@ -20,6 +20,7 @@ import com.teamdev.jxbrowser.net.callback.InterceptUrlRequestCallback;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@ -80,8 +81,9 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
protected Optional<UrlRequestJob> generateFileProtocolUrlRequestJob(Params params, String path) {
try {
InputStream inputStream = getResourceStream(path);
String mimeType = MimeType.parseMimeType(path);
String resourcePath = getResourcePath(path);
InputStream inputStream = getResourceStream(resourcePath);
String mimeType = MimeType.parseMimeType(resourcePath);
byte[] bytes;
if (isHtml(mimeType)) {
String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8);
@ -104,7 +106,11 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
* @return 输入流
* @throws Exception IO异常
*/
private InputStream getResourceStream(String path) throws Exception {
private InputStream getResourceStream(String path) {
return IOUtils.readResource(path);
}
private static String getResourcePath(String path) throws UnsupportedEncodingException {
int index = path.indexOf("=");
if (index > 0) {
path = path.substring(index + 1);
@ -115,7 +121,7 @@ public class NxInterceptRequestCallback implements InterceptUrlRequestCallback {
// 通过自定义协议之后的url会自动encode一些中文字符,这里做一个decode,否则会导致路径访问失败
path = URLDecoder.decode(path, StandardCharsets.UTF_8.name());
}
return IOUtils.readResource(path);
return path;
}
private boolean isHtml(String mimeType) {

40
designer-base/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java

@ -3,6 +3,9 @@ package com.fr.design.mainframe.chart.mode;
import com.fr.common.annotations.Open;
import com.fr.design.base.mode.DesignModeContext;
import java.util.HashSet;
import java.util.Set;
/**
* @author shine
* @version 10.0
@ -13,6 +16,19 @@ public class ChartEditContext {
private static ChartEditMode current = ChartEditMode.NORMAL;
private static final Set<DuchampFeature> features = new HashSet<>();
/**
* 功能点枚举
*/
public enum DuchampFeature {
SUPPORT_REPORT_DATA
}
/**
* 切换图表编辑模式
* @param mode 图表编辑模式
*/
public static void switchTo(ChartEditMode mode) {
current = mode;
}
@ -33,4 +49,28 @@ public class ChartEditContext {
public static boolean supportTheme() {
return !DesignModeContext.isDuchampMode();
}
/**
* 注册功能点
*/
public static void addDuchampFeature(DuchampFeature feature) {
features.add(feature);
}
/**
* 移除功能点
*/
public static void removeDuchampFeature(DuchampFeature feature) {
features.remove(feature);
}
/**
* 当前模式下是否支持单元格数据来源
*/
public static boolean supportReportData() {
if (normalMode()) {
return true;
}
return features.contains(DuchampFeature.SUPPORT_REPORT_DATA);
}
}

14
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -255,13 +255,17 @@ public class VcsHelper implements JTemplateActionListener {
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
String oldPath = oldName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY);
List<VcsEntity> oldVcsEntities = operator.getVersions(oldPath);
String replaceName = newName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY);
for (VcsEntity oldVcsEntity : oldVcsEntities) {
operator.saveVersion(oldVcsEntity.getUsername(), newName.replaceFirst(VCS_FILE_SLASH, StringUtils.EMPTY), oldVcsEntity.getCommitMsg(), oldVcsEntity.getVersion());
operator.deleteVersion(oldPath, oldVcsEntity.getVersion());
if (!VcsHelper.getInstance().isLegacyMode()) {
operator.renameVersion(oldVcsEntity, replaceName);
} else {
operator.saveVersion(oldVcsEntity.getUsername(), replaceName, oldVcsEntity.getCommitMsg(), oldVcsEntity.getVersion());
operator.deleteVersion(oldPath, oldVcsEntity.getVersion());
}
}
FineLoggerFactory.getLogger().debug("moveVcs success. from {} to {}", oldName, newName);
if (GcConfig.getInstance().isGcEnable()) {
FineLoggerFactory.getLogger().debug("moveVcs success. from {} to {}", oldName, replaceName);
if (GcConfig.getInstance().isGcEnable() && VcsHelper.getInstance().isLegacyMode()) {
operator.gc();
}
}

37
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java

@ -4,8 +4,10 @@ import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.lock.LockInfoUtils;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsOperatorWorker;
@ -15,6 +17,7 @@ import com.fr.design.mainframe.vcs.common.VcsCloseTemplateHelper;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.report.entity.VcsEntity;
import com.fr.report.lock.LockInfoOperator;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
@ -25,10 +28,13 @@ import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
@ -148,12 +154,35 @@ public class VcsCenterPane extends VcsNewPane {
if (o instanceof VcsTableEntity) {
VcsEntity entity = ((VcsTableEntity) o).getEntity();
saveSettingAndCloseDialog();
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(getTemplateTruePath(entity.getFilename()), false)));
showTemplate(entity.getFilename(), new FileNode(getTemplateTruePath(entity.getFilename()), false));
}
}
});
}
private void showTemplate(String filename, FileNode node) {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
String selectedFilePath = getTemplateTruePath(filename);
String lock = node.getLock();
return TemplateTreePane.needShowLockInfo(lock, selectedFilePath, node);
}
@Override
protected void done() {
try {
if (!get()) {
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(node));
} else {
FineJOptionPane.showMessageDialog(VcsCenterPane.this, Toolkit.i18nText("Fine-Design_Vcs_Open_Lock_Tip"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE);
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}.execute();
}
private void initManagerListener() {
manager.addMouseListener(new MouseAdapter() {
@Override
@ -212,12 +241,6 @@ public class VcsCenterPane extends VcsNewPane {
return TITLE;
}
private String getTemplateTruePath(String filename) {
return StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, filename);
}
@Override
protected String getDeleteTip(int size) {
return Toolkit.i18nText("Fine-Design_Vcs_Delete_Select_All_Version");

31
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

@ -4,6 +4,7 @@ import com.fr.base.svg.IconUtils;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MultiTemplateTabPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
@ -16,10 +17,15 @@ import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.FileNodes;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.report.InconsistentLockException;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResource;
import com.fr.workspace.server.vcs.VcsFileUtils;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.v2.VcsTaskResult;
@ -29,6 +35,7 @@ import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -179,9 +186,12 @@ public class VcsNewPane extends RecyclePane {
@Override
protected VcsTaskResult doInBackground() throws Exception {
String path = VcsHelper.getInstance().getFilePath(entity);
if (!ResourceIOUtils.exist(path)) {
if (!WorkContext.getCurrent().get(WorkResource.class).exist(path)) {
return new VcsTaskResult(false, new FileNotFoundException());
}
if (checkLock(entity.getFilename())) {
return new VcsTaskResult(false, new InconsistentLockException());
}
//step1.设置还原的用户名
entity.setUsername(VcsHelper.getInstance().getCurrentUsername());
//step2.rollback到指定版本
@ -206,7 +216,11 @@ public class VcsNewPane extends RecyclePane {
}
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(filePath, false)));
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"));
if (result.getException() instanceof FileNotFoundException) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"));
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Vcs_Open_Lock_Tip"), UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.ERROR_MESSAGE);
}
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
@ -215,6 +229,19 @@ public class VcsNewPane extends RecyclePane {
}.execute();
}
private boolean checkLock(String filename) {
String selectedFilePath = getTemplateTruePath(filename);
FileNode node = new FileNode(getTemplateTruePath(filename), false);
String lock = node.getLock();
return TemplateTreePane.needShowLockInfo(lock, selectedFilePath, node);
}
/**
* 获取模板的路径
*/
public String getTemplateTruePath(String filename) {
return StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, filename);
}
private void initDeleteListener() {
delete.addMouseListener(new MouseAdapter() {

9
designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java

@ -13,9 +13,10 @@ public class MimeTypeTest {
@Test
public void getMimeType() {
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html"));
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.html?a=ji"));
Assert.assertEquals("text/html", MimeType.parseMimeType("http://a.xml?a=ji"));
Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpg?a=ji"));
Assert.assertEquals("image/jpeg", MimeType.parseMimeType("http://a.jpeg?a=ji"));
Assert.assertEquals("truetype",
MimeType.parseMimeType("emb://com/fr/web/ui/resources?path=/com/fr/web/ui/font/iconfont.ttf"));
Assert.assertEquals("font/woff",
MimeType.parseMimeType("http://a.html?path=com/fr/ui/a.woff"));
// 对资源来说不存在http://a.jpg?a=ji这种情况,之前多虑了
}
}

2
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java

@ -68,7 +68,7 @@ public class NormalChartDataPane extends DataContentsPane {
label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH,ChartDataPane.LABEL_HEIGHT));
northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null}));
northPane.setBorder(BorderFactory.createEmptyBorder(0,5,0,8));
if (ChartEditContext.normalMode()) {
if (ChartEditContext.supportReportData()) {
this.add(northPane, BorderLayout.NORTH);
}
this.add(cardPane, BorderLayout.CENTER);

4
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -815,10 +815,6 @@ public class CellSelection extends Selection {
return cellElements;
}
public Set<TemplateCellElement> getCellElements() {
return cellElements;
}
@Override
public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().reInit(ePane);

2
designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

@ -442,7 +442,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
CellSelection cs = (CellSelection) tc.getSelection();
TemplateElementCase editingElementCase = tc.getEditingElementCase();
Set<TemplateCellElement> allCellElements = cs.getCellElements();
Set<TemplateCellElement> allCellElements = cs.getAllCellElements(editingElementCase);
Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle();
Style style = formatPane.update(oldStyle);
for (TemplateCellElement cellElement : allCellElements) {

6
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -241,7 +241,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
dataPane.update(cellElement);
CellSelection selection = (CellSelection) tc.getSelection();
Set<TemplateCellElement> allCellElements = selection.getCellElements();
Set<TemplateCellElement> allCellElements = selection.getAllCellElements(tc.getEditingElementCase());
groupPane.update(allCellElements);
}
@ -319,7 +319,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override
public void itemStateChanged(ItemEvent e) {
CellSelection selection = (CellSelection) tc.getSelection();
Set<TemplateCellElement> allCellElements = selection.getCellElements();
Set<TemplateCellElement> allCellElements = selection.getAllCellElements(tc.getEditingElementCase());
if (e == null || e.getStateChange() == ItemEvent.DESELECTED) {
//分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存
groupPane.update(allCellElements);
@ -351,7 +351,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (!selectedOneCell) {
// 只有在批量操作的时候才需要判断是否隐藏条件面板
CellSelection selection = (CellSelection) tc.getSelection();
boolean sameDSName = checkSameDSName(selection.getCellElements());
boolean sameDSName = checkSameDSName(selection.getAllCellElements(tc.getEditingElementCase()));
conditionPane.setVisible(sameDSName);
} else {
conditionPane.setVisible(true);

Loading…
Cancel
Save