Browse Source

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

* commit 'fe57f8dd93a331637f47afa4d860cc12a5e41ab5':
  REPORT-72851 去除无用导入
  REPORT-72851 TitlePlaceProcessor 11.0.2之后版本不生效了
  REPORT-73800【设计器环境监测】windows下没有finedb权限,设计器报错脏数据 把脏数据的逻辑修改后,导致即便只是锁住、没权限也会出现这个问题。 所以,这里添加一个检测链,前一个检测后,后一个才能继续检测。 并在对具体的类型检测时,保持原来的逻辑
  REPORT-73775【设计器环境监测】日志报错finedb占用,错误弹窗显示脏数据 国际化 KEY 值写错了, 改一下。
  REPORT-70647 远程设计器场景下主题内边框配置无法使用
  REPORT-73741 fix: 公式校验报错信息中字符串位置从1开始
  REPORT-73670 新建表单背景没有应用主题
feature/x
superman 2 years ago
parent
commit
1754d4ed08
  1. 4
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java
  2. 8
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. 3
      designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java
  4. 3
      designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java
  5. 11
      designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java
  6. 33
      designer-base/src/main/java/com/fr/env/detect/base/DetectorManager.java
  7. 46
      designer-base/src/main/java/com/fr/env/detect/impl/DetectorChain.java
  8. 12
      designer-base/src/main/java/com/fr/env/detect/impl/converter/FineDbLockedConverter.java
  9. 45
      designer-base/src/main/java/com/fr/env/detect/impl/converter/FineDbPermissionConverter.java
  10. 2
      designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

4
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -886,9 +886,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
if (checkResult.isValid()) {
showMessageDialog(checkResult.getTips(), checkResult.isValid(), false);
} else {
int columns = checkResult.getFormulaCoordinates().getColumns();
int columns = checkResult.getFormulaCoordinates().getColumns() + 1;
String position = StringUtils.EMPTY;
if (columns >= 0) {
if (columns > 0) {
position = Toolkit.i18nText("Fine-Design_Basic_Formula_The") + columns
+ Toolkit.i18nText("Fine-Design_Basic_Formula_Error_Position") + " ";
}

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

@ -190,6 +190,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
public JTemplate(T t, FILE file, boolean isNewFile, Parameter[] parameters) {
super(t);
if (isNewFile) {
// REPORT-58486: 必须在初始的UndoState创建前设置主题,使得初始的UndoState就包含了主题效果
setUpTheme4NewTemplate();
}
beforeInit();
// 判断是否切换设计器状态到禁止拷贝剪切
if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
@ -1926,10 +1930,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected void setUpTheme4NewTemplate() {
TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate();
TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG);
TemplateThemeAttrMark themeAttrMark = getTarget().getAttrMark(TemplateThemeAttrMark.XML_TAG);
if (themeAttrMark == null) {
themeAttrMark = new TemplateThemeAttrMark();
template.addAttrMark(themeAttrMark);
getTarget().addAttrMark(themeAttrMark);
}
themeAttrMark.setName(theme.getName());
themeAttrMark.setDark(theme.isDark());

3
designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java

@ -100,8 +100,7 @@ public class NorthRegionContainerPane extends JPanel {
//优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(pluginOnRunOrStopListener, pluginFilter);
// 在设计器启动时仅在最后一个插件启用时候进行刷新一次 如果插件启用过程中存在实现了设计器接口的插件
boolean needRefresh = DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isVisible() && existDesignExtraPlugin;
if (needRefresh) {
if (existDesignExtraPlugin) {
refreshAll(northEastPane, ad);
}
}

3
designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedFeatureController.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.theme;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.theme.SupportThemedCellInnerBorderFeature;
import com.fr.workspace.server.theme.ThemedCellBorderFeature;
/**
@ -12,6 +11,6 @@ import com.fr.workspace.server.theme.ThemedCellBorderFeature;
public class ThemedFeatureController {
public static boolean isCellStyleSupportInnerBorder() {
ThemedCellBorderFeature controller = WorkContext.getCurrent().get(ThemedCellBorderFeature.class);
return controller instanceof SupportThemedCellInnerBorderFeature;
return controller.isSupport();
}
}

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

@ -2,6 +2,7 @@ package com.fr.env.detect.base;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.impl.DetectorChain;
import com.fr.env.detect.impl.FineDbDirtyDetector;
import com.fr.env.detect.impl.FineDbLockedDetector;
import com.fr.env.detect.impl.FineDbPermissionDetector;
@ -41,10 +42,12 @@ public class DetectorBridge {
protected @NotNull DetectorManager compute() {
DetectorManager manager = new DetectorManager();
manager.register(new FineDbDirtyDetector());
manager.register(new FineDbPermissionDetector());
manager.register(new FineDbLockedDetector());
// 按照顺序构造检测链
manager.register(DetectorChain.construct(
new FineDbLockedDetector(),
new FineDbPermissionDetector(),
new FineDbDirtyDetector()));
manager.register(new JarInconsistentDetector());
manager.register(new JarLackDetector());

33
designer-base/src/main/java/com/fr/env/detect/base/DetectorManager.java vendored

@ -2,8 +2,10 @@ package com.fr.env.detect.base;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.impl.DetectorChain;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@ -17,8 +19,23 @@ import java.util.stream.Stream;
**/
class DetectorManager {
/**
* 检测链的列表
*/
private List<DetectorChain> chains = new ArrayList<>();
/**
* 单纯的检测器的列表
*/
private List<ExceptionDetector> detectors = new ArrayList<>();
public void register(DetectorChain chain) {
if (chain != null) {
chains.add(chain);
}
}
public void register(ExceptionDetector detector) {
if (detector != null) {
@ -32,7 +49,13 @@ class DetectorManager {
.map(ExceptionDetector::detect)
.filter(Objects::nonNull);
List<DetectorResult> resultList = results.collect(Collectors.toList());
Stream<DetectorResult> chainResults = chains.stream()
.map(DetectorChain::detect)
.filter(Objects::nonNull);
List<DetectorResult> resultList = Stream.concat(results, chainResults)
.collect(Collectors.toList());
resultList.forEach(DetectorResult::log);
return resultList.stream();
@ -40,7 +63,13 @@ class DetectorManager {
public DetectorResult detect(DetectorType type) {
Optional<DetectorResult> result = detectors.stream()
Stream<ExceptionDetector> chainDetectors = chains.stream()
.map(DetectorChain::getDetectors)
.flatMap(Collection::stream);
Stream<ExceptionDetector> allDetectors = Stream.concat(detectors.stream(), chainDetectors);
Optional<DetectorResult> result = allDetectors
.filter((detector -> type == detector.type()))
.findFirst()
.map(ExceptionDetector::detect);

46
designer-base/src/main/java/com/fr/env/detect/impl/DetectorChain.java vendored

@ -0,0 +1,46 @@
package com.fr.env.detect.impl;
import com.fr.env.detect.base.ExceptionDetector;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorStatus;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* 检测链
* 责任链模式 有先后顺序哪一个先获得哪一个先终止
*
* created by Harrison on 2022/06/16
**/
public class DetectorChain {
private List<ExceptionDetector> detectors = new ArrayList<>();
public static DetectorChain construct(ExceptionDetector... detectors) {
DetectorChain detectorChain = new DetectorChain();
detectorChain.detectors = Arrays.stream(detectors).collect(Collectors.toList());
return detectorChain;
}
@Nullable
public DetectorResult detect() {
for (ExceptionDetector detector : detectors) {
DetectorResult result = detector.detect();
if (result != null && result.getStatus() == DetectorStatus.EXCEPTION) {
return result;
}
}
return null;
}
public List<ExceptionDetector> getDetectors() {
return this.detectors;
}
}

12
designer-base/src/main/java/com/fr/env/detect/impl/converter/FineDbLockedConverter.java vendored

@ -7,6 +7,7 @@ import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.thowable.ThrowableConverter;
import com.fr.third.org.apache.commons.lang3.StringUtils;
import com.fr.third.org.hsqldb.HsqlException;
import com.fr.workspace.WorkContext;
/**
* created by Harrison on 2022/05/24
@ -36,12 +37,21 @@ public class FineDbLockedConverter implements ThrowableConverter {
*/
@Override
public DetectorResult convert(Throwable throwable) {
// 远程不执行
if (!WorkContext.getCurrent().isLocal()) {
return null;
}
Throwable sign = throwable;
while (sign.getClass() != HsqlException.class) {
while (sign != null && sign.getClass() != HsqlException.class) {
sign = sign.getCause();
}
if (sign == null) {
return null;
}
DetectorType type = DetectorType.FINE_DB_LOCKED;
String message = sign.getMessage();

45
designer-base/src/main/java/com/fr/env/detect/impl/converter/FineDbPermissionConverter.java vendored

@ -5,17 +5,24 @@ import com.fr.env.detect.base.DetectorConstants;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.thowable.ThrowableConverter;
import com.fr.third.org.apache.commons.lang3.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.org.apache.commons.io.FileUtils;
import com.fr.third.org.hsqldb.HsqlException;
import com.fr.workspace.WorkContext;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.util.Collection;
/**
* HSQL 下的权限检测
*
* <p>
* created by Harrison on 2022/05/24
**/
public class FineDbPermissionConverter implements ThrowableConverter {
public static final String PERMISSION = "permission";
public static final String EMBED_DB_NAME = "finedb";
@Override
public boolean accept(Throwable throwable) {
@ -33,15 +40,37 @@ public class FineDbPermissionConverter implements ThrowableConverter {
@Override
public DetectorResult convert(Throwable throwable) {
// 远程不执行
if (!WorkContext.getCurrent().isLocal()) {
return null;
}
Throwable sign = throwable;
while (sign.getClass() != HsqlException.class) {
while (sign != null && sign.getClass() != HsqlException.class) {
sign = sign.getCause();
}
if (sign == null) {
return null;
}
DetectorType type = DetectorType.FINE_DB_PERMISSION;
String message = sign.getMessage();
if (StringUtils.containsIgnoreCase(message, PERMISSION)) {
String fineDbDirectory = WorkContext.getCurrent().getPath() + File.separator + ProjectConstants.EMBED_DB_DIRECTORY + File.separator + EMBED_DB_NAME;
Collection<File> files = FileUtils.listFiles(new File(fineDbDirectory), null, true);
Boolean isPermitted = files.stream()
.map((file -> {
try {
// 进行权限判断
new RandomAccessFile(file, "rw");
return true;
} catch (FileNotFoundException e) {
return false;
}
}))
.reduce((a, b) -> a & b)
.orElse(Boolean.FALSE);
if (!isPermitted) {
DetectorType type = DetectorType.FINE_DB_PERMISSION;
return DetectorResult.builder()
.withType(type)
.withTips(Toolkit.i18nText(type.getTipsLocale()))

2
designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java

@ -80,7 +80,7 @@ public class LifecycleFatalErrorHandler {
final EnumMap<DetectorType, String> solutionMap = new EnumMap<>(DetectorType.class);
{
solutionMap.put(DetectorType.FINE_DB_LOCKED, "Fine-Design_Error_Finedb_Dirty_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_LOCKED, "Fine-Design_Error_Finedb_Locked_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_PERMISSION, "Fine-Design_Error_Finedb_Permission_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_DIRTY, "Fine-Design_Error_Finedb_Dirty_Backup_Reset");
}

Loading…
Cancel
Save