Browse Source

Merge pull request #12579 in DESIGN/design from bugfix/11.0 to feature/x

* commit 'dc2c430a07e8c9f46045293b1d8e483a1c464256':
  无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 对模板进行重命名后,版本管理仍存在,但是每个版本内容都是一样的
  REPORT-101409 【版本管理三期】删除无权限的版本没有失败提示
  REPORT-101608 【版本管理三期】通过版本中心入口进入版本详情,未保存的模板触发还原,选择保存还原会失败 代码规范
  REPORT-101773 【版本管理三期】版本详情页面选择版本删除,删完一个操作框的按钮就点不动了
  REPORT-101608 【版本管理三期】通过版本中心入口进入版本详情,未保存的模板触发还原,选择保存还原会失败
  REPORT-101482 【版本管理二期】迁移失败/成功的提示,都有个帮助文档的跳转
  REPORT-101608 【版本管理三期】通过版本中心入口进入版本详情,未保存的模板触发还原,选择保存还原会失败
  REPORT-101026 【版本管理三期】预览版本文件,有报错
  REPORT-99740 FRM报表块,get (-1,-1)类型的ColumnRow报错
  REPORT-101605 【版本管理三期】版本中心进入的版本详情入口,删除模板所有版本后,版本中心没有刷新
feature/x
superman 1 year ago
parent
commit
dfd0069c08
  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. 77
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  5. 40
      designer-base/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java
  6. 91
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java
  7. 60
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsProcessFailedWrapper.java
  8. 32
      designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableOperatorListener.java
  9. 113
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCloseTemplateHelper.java
  10. 27
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  11. 36
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsNewPaneWrapper.java
  12. 50
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java
  13. 74
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java
  14. 31
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java
  15. 97
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java
  16. 9
      designer-base/src/test/java/com/fr/design/jxbrowser/MimeTypeTest.java
  17. 2
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java
  18. 22
      designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java
  19. 4
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  20. 2
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java
  21. 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) {

77
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -36,9 +36,9 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.mainframe.manager.search.searcher.control.pane.TemplateTreeSearchToolbarPane;
import com.fr.design.mainframe.vcs.RecycleAction;
import com.fr.design.mainframe.vcs.common.VcsCloseTemplateHelper;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.mainframe.vcs.ui.FileVersionsPanel;
import com.fr.design.mainframe.vcs.ui.VcsNewPane;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
@ -46,7 +46,6 @@ import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.event.Event;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
@ -392,15 +391,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
private boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(jt)) {
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
return false;
}
/**
* 按钮状态改变
*/
@ -505,7 +495,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void actionPerformed(ActionEvent e) {
String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath();
path = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, path);
boolean currentEditing = isCurrentEditing(path);
boolean currentEditing = VcsCloseTemplateHelper.isCurrentEditing(path);
if (VcsHelper.getInstance().isLegacyMode()) {
// 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本)
closeOpenedTemplate(path, currentEditing);
@ -513,16 +503,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
fileVersionTablePanel.showFileVersionsPane();
stateChange();
} else {
checkTemplateSavedAndShowVcsNewPane(path, currentEditing);
VcsCloseTemplateHelper.checkTemplateSavedAndShowVcsNewPane(path, currentEditing);
}
}
private void showVcsNewPane(String path) {
VcsNewPane panel = new VcsNewPane(path);
panel.showDialog();
}
/**
* 版本管理可用状态的监控
@ -577,61 +561,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
/**
* 如果指定模板已经打开
* <p>1.如果该模板已保存则正常打开新版本管理弹窗
* <p>2.如果该模板未保存触发保存逻辑
* <li>a.如果用户选择保存则保存并不关闭模板弹出新版本管理弹窗
* <li>b.如果用户选择不保存则关闭当前模板弹出新版本管理弹窗
* <li>c.如果用户选择取消, 则啥操作都不做
*
* @param path
* @param isCurrentEditing
*/
private void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing) {
for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) {
if (!jTemplate.isALLSaved()) {
MultiTemplateTabPane.getInstance().setIsCloseCurrent(isCurrentEditing);
MultiTemplateTabPane.getInstance().closeFormat(jTemplate);
confirmCloseAndShowVcsNewPane(jTemplate, path);
return;
}
}
}
showVcsNewPane(path);
}
private void confirmCloseAndShowVcsNewPane(JTemplate<?, ?> specifiedTemplate, String path) {
if (specifiedTemplate == null) {
return;
}
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
CallbackSaveWorker worker = specifiedTemplate.save();
worker.addSuccessCallback(() -> {
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
showVcsNewPane(path);
});
worker.start(specifiedTemplate.getRuntimeId());
} else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate);
showVcsNewPane(path);
}
} else {
showVcsNewPane(path);
}
}
private void closeTpl(JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
MultiTemplateTabPane.getInstance().closeAndFreeLock(specifiedTemplate);
MultiTemplateTabPane.getInstance().activePrevTemplateAfterClose();
}
}
/**

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

91
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsOperatorWorker.java

@ -10,7 +10,9 @@ import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import com.fr.workspace.server.vcs.v2.VcsTaskResult;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import java.util.ArrayList;
import java.util.List;
@ -26,7 +28,7 @@ import java.util.concurrent.ExecutionException;
public class VcsOperatorWorker {
private int count = 0;
private static final int FREQ = 5;
private static final int FREQ = 6;
private String successStr;
@ -102,21 +104,16 @@ public class VcsOperatorWorker {
*
* @param vcsEntities 需要还原的版本
*/
public void batchRestore(List<VcsEntity> vcsEntities) {
List<String> failedList = new ArrayList<>();
startProcess(vcsEntities, failedList, (vcsEntity, operator) -> {
public void batchRestore(List<VcsEntity> vcsEntities, VcsTableOperatorListener listener) {
VcsProcessFailedWrapper wrapper = new VcsProcessFailedWrapper();
startProcess(vcsEntities, wrapper, (vcsEntity, operator) -> {
String fileName = vcsEntity.getFilename();
boolean result = true;
try {
operator.restoreVersion(fileName);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
result = false;
VcsTaskResult result = operator.restoreVersion(fileName);
if (!result.isSuccess()) {
wrapper.addFailedEntity(vcsEntity);
}
if (!result) {
failedList.add(fileName+PREFIX+vcsEntity.getVersion()+TAIL);
}
});
return result;
}, listener);
}
@ -126,25 +123,21 @@ public class VcsOperatorWorker {
* @param vcsEntities 需要删除的版本
* @param all 是否需要删除所有版本
*/
public void batchDelete(List<VcsEntity> vcsEntities, boolean all) {
List<String> failedList = new ArrayList<>();
startProcess(vcsEntities, failedList, (vcsEntity, operator) -> {
public void batchDelete(List<VcsEntity> vcsEntities, boolean all, VcsTableOperatorListener listener) {
VcsProcessFailedWrapper wrapper = new VcsProcessFailedWrapper();
startProcess(vcsEntities, wrapper, (vcsEntity, operator) -> {
String fileName = vcsEntity.getFilename();
boolean result = true;
try {
if (all) {
operator.deleteVersionForRecycle(fileName);
} else {
operator.deleteVersion(fileName, vcsEntity.getVersion());
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
result = false;
VcsTaskResult result;
if (all) {
result = operator.deleteVersionForRecycle(fileName);
} else {
result = operator.deleteVersion(fileName, vcsEntity.getVersion(), VcsEntity.CommitType.TYPE_DEFAULT);
}
if (!result) {
failedList.add(fileName+PREFIX+vcsEntity.getVersion()+TAIL);
if (!result.isSuccess()) {
wrapper.addFailedEntity(vcsEntity);
}
});
return result;
}, listener);
}
@ -153,9 +146,9 @@ public class VcsOperatorWorker {
*
* @param entity VcsEntity
*/
public void doDelete(VcsEntity entity) {
public void doDelete(VcsEntity entity, VcsTableOperatorListener listener) {
String fileName = entity.getFilename();
start4Single(entity, (vcsEntity, operator) -> operator.deleteVersionForRecycle(fileName), fileName + everyFailedStr);
start4Single(entity, (vcsEntity, operator) -> operator.deleteVersionForRecycle(fileName), fileName + everyFailedStr, listener);
}
/**
@ -163,12 +156,11 @@ public class VcsOperatorWorker {
*
* @param entity 版本
*/
public void deleteTargetVersion(VcsEntity entity) {
public void deleteTargetVersion(VcsEntity entity, VcsTableOperatorListener listener) {
String fileName = entity.getFilename();
int version = entity.getVersion();
start4Single(entity, (vcsEntity, operator) -> {
operator.deleteVersion(fileName, version);
}, fileName + everyFailedStr);
VcsEntity.CommitType commitType = entity.getCommitType();
start4Single(entity, (vcsEntity, operator) -> operator.deleteVersion(fileName, version, commitType), fileName + everyFailedStr, listener);
}
@ -177,16 +169,17 @@ public class VcsOperatorWorker {
*
* @param entity 版本
*/
public void updateEntityAnnotation(VcsEntity entity) {
public void updateEntityAnnotation(VcsEntity entity, VcsTableOperatorListener listener) {
start4Single(entity, (vcsEntity, operator) -> {
operator.updateVersion(entity);
}, everyFailedStr);
return new VcsTaskResult(true);
}, everyFailedStr, listener);
}
private void startProcess(List<VcsEntity> vcsEntities, List<String> failedList, VcsWorkerOperator workerOperator) {
private void startProcess(List<VcsEntity> vcsEntities, VcsProcessFailedWrapper wrapper, VcsWorkerOperator workerOperator, VcsTableOperatorListener listener) {
try {
dialog.getProgressBar().setMaximum(vcsEntities.size());
start4Batch(vcsEntities, failedList, workerOperator);
start4Batch(vcsEntities, wrapper, workerOperator, listener);
dialog.showDialog();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -202,13 +195,15 @@ public class VcsOperatorWorker {
return (count > FREQ && count % FREQ == 0) || count < FREQ;
}
private void start4Single(VcsEntity entity, VcsWorkerOperator vcsWorkerOperator, String failedTip) {
private void start4Single(VcsEntity entity, VcsWorkerOperator vcsWorkerOperator, String failedTip, VcsTableOperatorListener listener) {
new SwingWorker<Boolean, Void>() {
@Override
protected void done() {
try {
if (!get()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), failedTip);
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()), failedTip);
} else {
listener.updateUI();
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
@ -218,16 +213,16 @@ public class VcsOperatorWorker {
protected Boolean doInBackground() throws Exception {
try {
VcsOperator operator = WorkContext.getCurrent().get(VcsOperator.class);
vcsWorkerOperator.process(entity, operator);
VcsTaskResult result = vcsWorkerOperator.process(entity, operator);
return result.isSuccess();
} catch (Exception e) {
return false;
}
return true;
}
}.execute();
}
private void start4Batch(List<VcsEntity> vcsEntities, List<String> failedList, VcsWorkerOperator workerOperator) {
private void start4Batch(List<VcsEntity> vcsEntities, VcsProcessFailedWrapper wrapper, VcsWorkerOperator workerOperator, VcsTableOperatorListener listener) {
new SwingWorker<Boolean, Integer>() {
@Override
protected Boolean doInBackground() throws Exception {
@ -239,7 +234,7 @@ public class VcsOperatorWorker {
publish(count);
}
}
return failedList.isEmpty();
return wrapper.isAllSuccess();
}
@Override
protected void process(List<Integer> chunks) {
@ -249,7 +244,9 @@ public class VcsOperatorWorker {
protected void done() {
dialog.closeDialog();
try {
List<String> failedList = wrapper.getDetailFailedList();
showErrorDetailPane(get(), failedList, failedList.size(), vcsEntities.size() - failedList.size());
listener.updateUI(wrapper);
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
@ -286,6 +283,6 @@ public class VcsOperatorWorker {
* @param vcsEntity 版本
* @param operator 操作类
*/
void process(VcsEntity vcsEntity, VcsOperator operator) throws Exception;
VcsTaskResult process(VcsEntity vcsEntity, VcsOperator operator) throws Exception;
}
}

60
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsProcessFailedWrapper.java

@ -0,0 +1,60 @@
package com.fr.design.mainframe.vcs;
import com.fr.report.entity.VcsEntity;
import java.util.ArrayList;
import java.util.List;
/**
* 版本管理处理失败列表的包装类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/28
*/
public class VcsProcessFailedWrapper {
private static final String PREFIX = "(v.";
private static final String TAIL = ")";
private List<VcsEntity> failedList = new ArrayList<>();
/**
* 添加处理失败的VcsEntity
*
* @param entity entity
*/
public void addFailedEntity(VcsEntity entity) {
failedList.add(entity);
}
/**
* 获取用于展示的详细失败信息列表
*/
public List<String> getDetailFailedList() {
List<String> detailList = new ArrayList<>();
for (VcsEntity entity : failedList) {
detailList.add(entity.getFilename()+PREFIX+entity.getVersion()+TAIL);
}
return detailList;
}
/**
* 获取处理失败的vcsEntity的名称列表
*/
public List<String> getFailedNameList() {
List<String> detailList = new ArrayList<>();
for (VcsEntity entity : failedList) {
detailList.add(entity.getFilename());
}
return detailList;
}
/**
* 处理是否全部成功
*/
public boolean isAllSuccess() {
return failedList.isEmpty();
}
}

32
designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableOperatorListener.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.vcs;
import java.util.List;
/**
* 版本管理表格操作事件
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/27
*/
public interface VcsTableOperatorListener {
/**
* 处理操作
*/
default void doOperator(List<VcsTableEntity> entityList){}
/**
* 更新界面
*/
default void updateUI(){}
/**
* 根据处理失败的内容来更新界面
*
* @param wrapper 失败内容
*/
default void updateUI(VcsProcessFailedWrapper wrapper){}
}

113
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCloseTemplateHelper.java

@ -0,0 +1,113 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.MultiTemplateTabPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.vcs.ui.VcsNewPane;
import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
/**
* 版本管理关闭模板辅助类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/27
*/
public class VcsCloseTemplateHelper {
/**
* 根据传入的pane与dialog生成指定面板的Vcs模板关闭的处理方法
* 如果指定模板已经打开
* <p>1.如果该模板已保存则正常打开新版本管理弹窗
* <p>2.如果该模板未保存触发保存逻辑
* <li>a.如果用户选择保存则保存并不关闭模板弹出新版本管理弹窗
* <li>b.如果用户选择不保存则关闭当前模板弹出新版本管理弹窗
* <li>c.如果用户选择取消, 则啥操作都不做
*
* @param path 对应模板路径
* @param isCurrentEditing 是否是正在编辑的模板
* @param parent 生成的新版本管理的详情面板的父面板
*/
public static void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing, BasicDialog parent, VcsNewPane pane) {
VcsNewPaneWrapper wrapper = new VcsNewPaneWrapper(path, parent, pane);
for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) {
if (!jTemplate.isALLSaved()) {
MultiTemplateTabPane.getInstance().setIsCloseCurrent(isCurrentEditing);
MultiTemplateTabPane.getInstance().closeFormat(jTemplate);
confirmCloseAndShowVcsNewPane(jTemplate, wrapper);
return;
}
}
}
wrapper.show();
}
/**
* 自己生成新的VcsNewPane的Vcs模板关闭的处理方法
*/
public static void checkTemplateSavedAndShowVcsNewPane(String path, boolean isCurrentEditing) {
checkTemplateSavedAndShowVcsNewPane(path, isCurrentEditing, null, null);
}
/**
* 是否是当前编辑的模板
*
* @param path 对应模板路径
* @return 是则返回true
*/
public static boolean isCurrentEditing(String path) {
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(jt)) {
String editing = jt.getEditingFILE().getPath();
return ComparatorUtils.equals(editing, path);
}
return false;
}
private static void confirmCloseAndShowVcsNewPane(JTemplate<?, ?> specifiedTemplate, VcsNewPaneWrapper wrapper) {
if (specifiedTemplate == null) {
return;
}
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
String.format("%s\"%s\" ?",Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save"), specifiedTemplate.getEditingFILE()),
Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION) {
CallbackSaveWorker worker = specifiedTemplate.save();
worker.addSuccessCallback(() -> {
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
SwingUtilities.invokeLater(wrapper::show);
});
worker.start(specifiedTemplate.getRuntimeId());
} else if (returnVal == JOptionPane.NO_OPTION) {
closeTpl(specifiedTemplate);
wrapper.show();
}
} else {
wrapper.show();
}
}
private static void closeTpl(JTemplate<?, ?> specifiedTemplate) {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
MultiTemplateTabPane.getInstance().closeAndFreeLock(specifiedTemplate);
MultiTemplateTabPane.getInstance().activePrevTemplateAfterClose();
}
}

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

@ -22,6 +22,7 @@ import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginManager;
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;
@ -64,6 +65,8 @@ public class VcsHelper implements JTemplateActionListener {
private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10";
private final static String VCS_FILE_SLASH = "/";
private final static String SERVICE_NAME_MOVE = "moveVcs";
private static final String VCS_VERSIONS = "reportlets_versions";
private static final String VERSION_MARK = ".v";
private static final VcsHelper INSTANCE = new VcsHelper();
private static ScheduledExecutorService saveSchedule;
@ -252,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();
}
}
@ -398,4 +405,14 @@ public class VcsHelper implements JTemplateActionListener {
public boolean checkAutoSaveSupport() {
return VcsConfigManager.getInstance().isUseAutoSave() && !VcsHelper.getInstance().isLegacyMode();
}
/**
* 获取文件路径
*
* @param entity
* @return
*/
public String getFilePath(VcsEntity entity) {
return StableUtils.pathJoin(VCS_VERSIONS, entity.getFilename() + VERSION_MARK + entity.getVersion());
}
}

36
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsNewPaneWrapper.java

@ -0,0 +1,36 @@
package com.fr.design.mainframe.vcs.common;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.mainframe.vcs.ui.VcsNewPane;
/**
* 构建VcsNewPane的包装类
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/27
*/
public class VcsNewPaneWrapper {
private String path;
private BasicDialog dialog;
private VcsNewPane pane;
public VcsNewPaneWrapper(String path, BasicDialog dialog, VcsNewPane pane) {
this.path = path;
this.dialog = dialog;
this.pane = pane;
}
/**
* 显示面板
*/
public void show() {
if (pane != null) {
pane.showDialog(dialog);
} else {
VcsNewPane newPane = new VcsNewPane(path);
newPane.showDialog(dialog);
}
}
}

50
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/RecyclePane.java

@ -10,7 +10,9 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.vcs.VcsOperatorWorker;
import com.fr.design.mainframe.vcs.TableEntity;
import com.fr.design.mainframe.vcs.TableValueOperator;
import com.fr.design.mainframe.vcs.VcsProcessFailedWrapper;
import com.fr.design.mainframe.vcs.VcsTableEntity;
import com.fr.design.mainframe.vcs.VcsTableOperatorListener;
import com.fr.report.entity.VcsEntity;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
@ -25,7 +27,9 @@ import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.fr.design.i18n.Toolkit.i18nText;
@ -44,6 +48,8 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
public static final Icon ICON_DELETE = IconUtils.readSVGIcon("/com/fr/design/standard/vcslist/vcs_recycle_delete", IconUtils.ICON_TYPE_NORMAL);
public static final Icon ICON_DELETE_DISABLE = IconUtils.readSVGIcon("/com/fr/design/standard/vcslist/vcs_recycle_delete", IconUtils.ICON_TYPE_DISABLED);
private Set<VcsTableOperatorListener> listenerSet = new HashSet<>();
protected UITextField searchTextField;
protected UILabel deleteLabel;
@ -160,7 +166,12 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
fireListener(new VcsResponseListener() {
@Override
public void doAfterChooseYes(List<VcsEntity> selectList) {
VcsOperatorWorker.createDeleteWorker().batchDelete(selectList, isNeedDeleteAllVersion());
VcsOperatorWorker.createDeleteWorker(). batchDelete(selectList, isNeedDeleteAllVersion(), new VcsTableOperatorListener() {
@Override
public void updateUI(VcsProcessFailedWrapper wrapper) {
updateVcsUI(wrapper);
}
});
}
}, true);
}
@ -177,7 +188,12 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
fireListener(new VcsResponseListener() {
@Override
public void doAfterChooseYes(List<VcsEntity> selectList) {
VcsOperatorWorker.createRestoreWorker().batchRestore(selectList);
VcsOperatorWorker.createRestoreWorker().batchRestore(selectList, new VcsTableOperatorListener() {
@Override
public void updateUI(VcsProcessFailedWrapper wrapper) {
updateVcsUI(wrapper);
}
});
}
}, false);
}
@ -210,14 +226,17 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (selVal == JOptionPane.YES_OPTION) {
tableEntities = model.getList().stream().filter(tableEntity -> !tableEntity.isSelect()).collect(Collectors.toList());
model.setList(tableEntities);
model.fireTableDataChanged();
listener.doAfterChooseYes(selectList);
}
}
}
private void updateVcsUI(VcsProcessFailedWrapper wrapper) {
tableEntities = model.getList().stream().filter(tableEntity -> !tableEntity.isSelect() || wrapper.getFailedNameList().contains(tableEntity.getFilename())).collect(Collectors.toList());
model.setList(new ArrayList<>(tableEntities));
model.fireTableDataChanged();
fireVcsListener(model.getList());
}
/**
* 显示弹窗
@ -274,6 +293,25 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
this.parentDialog = parentDialog;
}
/**
* 添加版本管理表格操作事件
*
* @param listener 版本管理表格操作事件
*/
public void addVcsListener(VcsTableOperatorListener listener) {
listenerSet.add(listener);
}
/**
* 触发版本管理表格操作事件
*/
public void fireVcsListener(List<VcsTableEntity> tableEntities) {
for (VcsTableOperatorListener listener : listenerSet) {
listener.doOperator(tableEntities);
}
}
/**
* 删除范围
*
@ -340,7 +378,7 @@ public class RecyclePane extends AbstractSupportSelectTablePane<VcsTableEntity>
* @param entities
*/
public void updateTableList(List<VcsTableEntity> entities) {
tableEntities = entities;
tableEntities = new ArrayList<>(entities);
}
/**

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

@ -4,15 +4,20 @@ 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;
import com.fr.design.mainframe.vcs.VcsTableEntity;
import com.fr.design.mainframe.vcs.VcsTableOperatorListener;
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;
@ -23,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;
/**
@ -104,7 +112,8 @@ public class VcsCenterPane extends VcsNewPane {
@Override
public void mouseClicked(MouseEvent e) {
JTable table = tableContentPane.getEditTable();
Object o = table.getValueAt(table.getEditingRow(), table.getEditingColumn());
int row = table.getEditingRow();
Object o = table.getValueAt(row, table.getEditingColumn());
if (o instanceof VcsTableEntity) {
VcsEntity entity = ((VcsTableEntity) o).getEntity();
String fileName = entity.getFilename();
@ -115,10 +124,15 @@ public class VcsCenterPane extends VcsNewPane {
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (selVal == JOptionPane.YES_OPTION) {
VcsOperatorWorker.createDeleteWorker().doDelete(entity);
removeTarget((VcsTableEntity) o);
model.getList().remove(o);
model.fireTableDataChanged();
VcsOperatorWorker.createDeleteWorker().doDelete(entity, new VcsTableOperatorListener() {
@Override
public void updateUI() {
removeTarget((VcsTableEntity) o);
model.fireTableRowsDeleted(row, row);
model.removeRow(row);
model.fireTableDataChanged();
}
});
}
}
}
@ -140,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
@ -154,13 +191,23 @@ public class VcsCenterPane extends VcsNewPane {
Object o = table.getValueAt(table.getEditingRow(), table.getEditingColumn());
if (o instanceof VcsTableEntity) {
VcsEntity entity = ((VcsTableEntity) o).getEntity();
VcsNewPane pane = new VcsNewPane(getTemplateTruePath(entity.getFilename())) {
String path = getTemplateTruePath(entity.getFilename());
VcsNewPane pane = new VcsNewPane(path) {
@Override
protected String title4PopupWindow() {
return entity.getFilename()+Toolkit.i18nText("Fine-Design_Vcs_Version_Tips");
}
};
pane.showDialog(getDialog());
pane.addVcsListener(new VcsTableOperatorListener() {
@Override
public void doOperator(List<VcsTableEntity> entityList) {
if (entities.size() == 0) {
model.getList().remove(o);
model.fireTableDataChanged();
}
}
});
VcsCloseTemplateHelper.checkTemplateSavedAndShowVcsNewPane(path, VcsCloseTemplateHelper.isCurrentEditing(path), getDialog(), pane);
}
}
});
@ -182,8 +229,9 @@ public class VcsCenterPane extends VcsNewPane {
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
getParentDialog().doOK();
getParentDialog().dispose();
BasicDialog parent = getParentDialog();
parent.doOK();
parent.dispose();
}
});
}
@ -193,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/VcsMovePanel.java

@ -11,6 +11,7 @@ import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.ModernUIProgressBarUI;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.i18n.LocaleLinkProvider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
@ -18,6 +19,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.vcs.VcsExceptionUtils;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.ThemeUtils;
import com.fr.design.widget.FRWidgetFactory;
@ -74,6 +76,12 @@ public class VcsMovePanel extends BasicPane {
private static final int DEFAULT_VALUE = 5;
private static final String HELP_KEY = "Fine-Design_Vcs_Move_Help_Link";
private static final String HELP_KEY_DEFAULT = "Fine-Design_Vcs_Move_Help_Link_Default";
private static final String HELP_URL = LocaleLinkProvider.getInstance().getLink(HELP_KEY, HELP_KEY_DEFAULT);
public static final String SETTING = "SETTING";
public static final String PROCESS = "PROCESS";
@ -121,6 +129,8 @@ public class VcsMovePanel extends BasicPane {
private boolean visible = false;
private UILabel seeLabel;
private UILabel helpLabel;
public VcsMovePanel(CardLayout cardLayout, JPanel parentPane, MoveCallBack callBack, BasicDialog parentDialog) {
this.parentCard = cardLayout;
@ -407,6 +417,9 @@ public class VcsMovePanel extends BasicPane {
body.add(new UILabel(StringUtils.BLANK));
body.add(tipLabel);
body.add(new UILabel(StringUtils.BLANK));
JPanel panel = createHelpPane();
body.add(panel);
body.add(new UILabel(StringUtils.BLANK));
body.add(button);
statusPane.add(body);
statusPane.setLayout(FRGUIPaneFactory.createCenterLayout(body, 0.5f, 0.5f));
@ -417,6 +430,24 @@ public class VcsMovePanel extends BasicPane {
tipLabel.setAlignmentX(CENTER_ALIGNMENT);
}
private JPanel createHelpPane() {
JPanel panel = new JPanel();
seeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_See"));
seeLabel.setForeground(TIP_COLOR);
helpLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Help"));
helpLabel.setForeground(LABEL_COLOR);
helpLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
helpLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
BrowseUtils.browser(HELP_URL);
}
});
panel.add(seeLabel);
panel.add(helpLabel);
return panel;
}
private class MoveWorker extends SwingWorker<Boolean, Integer> {

97
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;
@ -11,25 +12,35 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.vcs.TableValueOperator;
import com.fr.design.mainframe.vcs.VcsOperatorWorker;
import com.fr.design.mainframe.vcs.VcsTableEntity;
import com.fr.design.mainframe.vcs.VcsTableOperatorListener;
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;
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.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
@ -51,6 +62,7 @@ public class VcsNewPane extends RecyclePane {
protected static int EDIT_COL = 4;
private static final String PATH = "path";
private static final int DOUBLE_CLICK_COUNT = 2;
protected VcsOperatorPane operatorPane;
@ -170,40 +182,74 @@ public class VcsNewPane extends RecyclePane {
private void restoreEntity(VcsEntity entity) {
new SwingWorker<Void, Void>() {
new SwingWorker<VcsTaskResult, Void>() {
@Override
protected Void doInBackground() throws Exception {
protected VcsTaskResult doInBackground() throws Exception {
String path = VcsHelper.getInstance().getFilePath(entity);
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到指定版本
WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(entity);
return null;
//最里面的文件系统的write会吞异常,这边就一直默认成功吧,日志里会体现失败的情况
return new VcsTaskResult(true);
}
@Override
protected void done() {
//step3.如果原来原模板已经打开则关闭原模板,打开rollback后的新模板
List<JTemplate<?, ?>> templateList = HistoryTemplateListCache.getInstance().getHistoryList();
for (JTemplate<?, ?> template : templateList) {
if (StringUtils.equals(filePath, template.getPath())) {
MultiTemplateTabPane.getInstance().setIsCloseCurrent(HistoryTemplateListCache.getInstance().isCurrentEditingFile(filePath));
MultiTemplateTabPane.getInstance().closeFormat(template);
MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(template);
break;
try {
VcsTaskResult result = get();
if (result.isSuccess()) {
//step3.如果原来原模板已经打开则关闭原模板,打开rollback后的新模板
List<JTemplate<?, ?>> templateList = HistoryTemplateListCache.getInstance().getHistoryList();
for (JTemplate<?, ?> template : templateList) {
if (StringUtils.equals(filePath, template.getPath())) {
MultiTemplateTabPane.getInstance().setIsCloseCurrent(HistoryTemplateListCache.getInstance().isCurrentEditingFile(filePath));
MultiTemplateTabPane.getInstance().closeFormat(template);
MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(template);
break;
}
}
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(filePath, false)));
} else {
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);
}
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(filePath, false)));
}
}.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() {
@Override
public void mouseClicked(MouseEvent e) {
JTable table = tableContentPane.getEditTable();
int row = table.getEditingColumn();
Object o = table.getValueAt(table.getEditingRow(), row);
int row = table.getEditingRow();
Object o = table.getValueAt(row, table.getEditingColumn());
if (o instanceof VcsTableEntity) {
VcsEntity entity = ((VcsTableEntity) o).getEntity();
int selVal = FineJOptionPane.showConfirmDialog(
@ -213,9 +259,15 @@ public class VcsNewPane extends RecyclePane {
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (selVal == JOptionPane.YES_OPTION) {
model.getList().remove(o);
model.fireTableDataChanged();
VcsOperatorWorker.createDeleteWorker().deleteTargetVersion(entity);
VcsOperatorWorker.createDeleteWorker().deleteTargetVersion(entity, new VcsTableOperatorListener() {
@Override
public void updateUI() {
model.fireTableRowsDeleted(row, row);
model.removeRow(row);
model.fireTableDataChanged();
}
});
fireVcsListener(model.getList());
}
}
}
@ -231,7 +283,6 @@ public class VcsNewPane extends RecyclePane {
if (o instanceof VcsTableEntity) {
VcsEntity entity = ((VcsTableEntity) o).getEntity();
previewEntity(entity);
VcsNewPane.this.saveSettingAndCloseDialog();
}
}
});
@ -336,9 +387,13 @@ public class VcsNewPane extends RecyclePane {
@Override
public void doOK() {
entity.setCommitMsg(getMsgTestArea().getText());
VcsOperatorWorker.createUpdateWorker().updateEntityAnnotation(entity);
setVisible(false);
model.fireTableDataChanged();
VcsOperatorWorker.createUpdateWorker().updateEntityAnnotation(entity, new VcsTableOperatorListener() {
@Override
public void updateUI() {
setVisible(false);
model.fireTableDataChanged();
}
});
}
};
dialog.setVisible(true);

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

22
designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java

@ -24,13 +24,16 @@ import com.fr.stable.ColumnRow;
import com.fr.stable.EssentialUtils;
import com.fr.stable.StringUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class SortColumnRowPane extends JPanel implements UIObserver {
@ -260,8 +263,10 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
disableHeaderCellsStyleMap = new HashMap<>();
tempHeaderCells = new ArrayList<>();
for (ColumnRow columnRow : notSelectables) {
TemplateCellElement templateCellElement
= elementCase.getTemplateCellElement(columnRow.column, columnRow.row);
TemplateCellElement templateCellElement = null;
if (columnRow != ColumnRow.ERROR) {
templateCellElement = elementCase.getTemplateCellElement(columnRow.column, columnRow.row);
}
if (templateCellElement == null) {
templateCellElement = new DefaultTemplateCellElement(columnRow.column, columnRow.row);
elementCase.addCellElement(templateCellElement);
@ -280,8 +285,11 @@ public class SortColumnRowPane extends JPanel implements UIObserver {
if (cellSelectionManager != null) {
try {
for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) {
TemplateCellElement headerTemplateCellElement
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
TemplateCellElement headerTemplateCellElement = null;
if (headerColumnRow != ColumnRow.ERROR) {
headerTemplateCellElement
= elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row);
}
if (headerTemplateCellElement != null) {
headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow));
}

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