Browse Source

Merge pull request #9216 in DESIGN/design from release/11.0 to final/11.0

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

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) { public JTemplate(T t, FILE file, boolean isNewFile, Parameter[] parameters) {
super(t); super(t);
if (isNewFile) {
// REPORT-58486: 必须在初始的UndoState创建前设置主题,使得初始的UndoState就包含了主题效果
setUpTheme4NewTemplate();
}
beforeInit(); beforeInit();
// 判断是否切换设计器状态到禁止拷贝剪切 // 判断是否切换设计器状态到禁止拷贝剪切
if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) {
@ -1926,10 +1930,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected void setUpTheme4NewTemplate() { protected void setUpTheme4NewTemplate() {
TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate(); TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate();
TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); TemplateThemeAttrMark themeAttrMark = getTarget().getAttrMark(TemplateThemeAttrMark.XML_TAG);
if (themeAttrMark == null) { if (themeAttrMark == null) {
themeAttrMark = new TemplateThemeAttrMark(); themeAttrMark = new TemplateThemeAttrMark();
template.addAttrMark(themeAttrMark); getTarget().addAttrMark(themeAttrMark);
} }
themeAttrMark.setName(theme.getName()); themeAttrMark.setName(theme.getName());
themeAttrMark.setDark(theme.isDark()); 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,保证最后全面刷新一次 //优先级为-1,保证最后全面刷新一次
GeneralContext.listenPluginRunningChanged(pluginOnRunOrStopListener, pluginFilter); GeneralContext.listenPluginRunningChanged(pluginOnRunOrStopListener, pluginFilter);
// 在设计器启动时仅在最后一个插件启用时候进行刷新一次 如果插件启用过程中存在实现了设计器接口的插件 // 在设计器启动时仅在最后一个插件启用时候进行刷新一次 如果插件启用过程中存在实现了设计器接口的插件
boolean needRefresh = DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isVisible() && existDesignExtraPlugin; if (existDesignExtraPlugin) {
if (needRefresh) {
refreshAll(northEastPane, ad); 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; package com.fr.design.mainframe.theme;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.theme.SupportThemedCellInnerBorderFeature;
import com.fr.workspace.server.theme.ThemedCellBorderFeature; import com.fr.workspace.server.theme.ThemedCellBorderFeature;
/** /**
@ -12,6 +11,6 @@ import com.fr.workspace.server.theme.ThemedCellBorderFeature;
public class ThemedFeatureController { public class ThemedFeatureController {
public static boolean isCellStyleSupportInnerBorder() { public static boolean isCellStyleSupportInnerBorder() {
ThemedCellBorderFeature controller = WorkContext.getCurrent().get(ThemedCellBorderFeature.class); ThemedCellBorderFeature controller = WorkContext.getCurrent().get(ThemedCellBorderFeature.class);
return controller instanceof SupportThemedCellInnerBorderFeature; return controller.isSupport();
} }
} }

9
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.DetectorResult;
import com.fr.env.detect.bean.DetectorType; 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.FineDbDirtyDetector;
import com.fr.env.detect.impl.FineDbLockedDetector; import com.fr.env.detect.impl.FineDbLockedDetector;
import com.fr.env.detect.impl.FineDbPermissionDetector; import com.fr.env.detect.impl.FineDbPermissionDetector;
@ -42,9 +43,11 @@ public class DetectorBridge {
DetectorManager manager = new DetectorManager(); DetectorManager manager = new DetectorManager();
manager.register(new FineDbDirtyDetector()); // 按照顺序构造检测链
manager.register(new FineDbPermissionDetector()); manager.register(DetectorChain.construct(
manager.register(new FineDbLockedDetector()); new FineDbLockedDetector(),
new FineDbPermissionDetector(),
new FineDbDirtyDetector()));
manager.register(new JarInconsistentDetector()); manager.register(new JarInconsistentDetector());
manager.register(new JarLackDetector()); 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.DetectorResult;
import com.fr.env.detect.bean.DetectorType; import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.impl.DetectorChain;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@ -17,8 +19,23 @@ import java.util.stream.Stream;
**/ **/
class DetectorManager { class DetectorManager {
/**
* 检测链的列表
*/
private List<DetectorChain> chains = new ArrayList<>();
/**
* 单纯的检测器的列表
*/
private List<ExceptionDetector> detectors = new ArrayList<>(); private List<ExceptionDetector> detectors = new ArrayList<>();
public void register(DetectorChain chain) {
if (chain != null) {
chains.add(chain);
}
}
public void register(ExceptionDetector detector) { public void register(ExceptionDetector detector) {
if (detector != null) { if (detector != null) {
@ -32,7 +49,13 @@ class DetectorManager {
.map(ExceptionDetector::detect) .map(ExceptionDetector::detect)
.filter(Objects::nonNull); .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); resultList.forEach(DetectorResult::log);
return resultList.stream(); return resultList.stream();
@ -40,7 +63,13 @@ class DetectorManager {
public DetectorResult detect(DetectorType type) { 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())) .filter((detector -> type == detector.type()))
.findFirst() .findFirst()
.map(ExceptionDetector::detect); .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.env.detect.thowable.ThrowableConverter;
import com.fr.third.org.apache.commons.lang3.StringUtils; import com.fr.third.org.apache.commons.lang3.StringUtils;
import com.fr.third.org.hsqldb.HsqlException; import com.fr.third.org.hsqldb.HsqlException;
import com.fr.workspace.WorkContext;
/** /**
* created by Harrison on 2022/05/24 * created by Harrison on 2022/05/24
@ -37,11 +38,20 @@ public class FineDbLockedConverter implements ThrowableConverter {
@Override @Override
public DetectorResult convert(Throwable throwable) { public DetectorResult convert(Throwable throwable) {
// 远程不执行
if (!WorkContext.getCurrent().isLocal()) {
return null;
}
Throwable sign = throwable; Throwable sign = throwable;
while (sign.getClass() != HsqlException.class) { while (sign != null && sign.getClass() != HsqlException.class) {
sign = sign.getCause(); sign = sign.getCause();
} }
if (sign == null) {
return null;
}
DetectorType type = DetectorType.FINE_DB_LOCKED; DetectorType type = DetectorType.FINE_DB_LOCKED;
String message = sign.getMessage(); String message = sign.getMessage();

43
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.DetectorResult;
import com.fr.env.detect.bean.DetectorType; import com.fr.env.detect.bean.DetectorType;
import com.fr.env.detect.thowable.ThrowableConverter; 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.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 下的权限检测 * HSQL 下的权限检测
* * <p>
* created by Harrison on 2022/05/24 * created by Harrison on 2022/05/24
**/ **/
public class FineDbPermissionConverter implements ThrowableConverter { public class FineDbPermissionConverter implements ThrowableConverter {
public static final String PERMISSION = "permission"; public static final String EMBED_DB_NAME = "finedb";
@Override @Override
public boolean accept(Throwable throwable) { public boolean accept(Throwable throwable) {
@ -33,15 +40,37 @@ public class FineDbPermissionConverter implements ThrowableConverter {
@Override @Override
public DetectorResult convert(Throwable throwable) { public DetectorResult convert(Throwable throwable) {
// 远程不执行
if (!WorkContext.getCurrent().isLocal()) {
return null;
}
Throwable sign = throwable; Throwable sign = throwable;
while (sign.getClass() != HsqlException.class) { while (sign != null && sign.getClass() != HsqlException.class) {
sign = sign.getCause(); sign = sign.getCause();
} }
DetectorType type = DetectorType.FINE_DB_PERMISSION; if (sign == null) {
String message = sign.getMessage(); return null;
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() return DetectorResult.builder()
.withType(type) .withType(type)
.withTips(Toolkit.i18nText(type.getTipsLocale())) .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); 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_PERMISSION, "Fine-Design_Error_Finedb_Permission_Backup_Reset");
solutionMap.put(DetectorType.FINE_DB_DIRTY, "Fine-Design_Error_Finedb_Dirty_Backup_Reset"); solutionMap.put(DetectorType.FINE_DB_DIRTY, "Fine-Design_Error_Finedb_Dirty_Backup_Reset");
} }

Loading…
Cancel
Save