Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
Yvan 3 years ago
parent
commit
17680ddd80
  1. 5
      designer-base/src/main/java/com/fr/env/EnvPrepare.java
  2. 136
      designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java
  3. 5
      designer-base/src/main/java/com/fr/env/detect/base/DetectorBridge.java
  4. 8
      designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java
  5. 3
      designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java
  6. 9
      designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java
  7. 21
      designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java
  8. 15
      designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java
  9. 51
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java
  10. 4
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

5
designer-base/src/main/java/com/fr/env/detect/EnvPrepare.java → designer-base/src/main/java/com/fr/env/EnvPrepare.java vendored

@ -1,5 +1,6 @@
package com.fr.env.detect;
package com.fr.env;
import com.fr.env.detect.EnvDetectorCenter;
import com.fr.module.Activator;
/**
@ -21,6 +22,6 @@ public class EnvPrepare extends Activator {
@Override
public void stop() {
EnvDetectorCenter.getInstance().destroy();
}
}

136
designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java vendored

@ -10,6 +10,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.env.detect.base.DetectorBridge;
import com.fr.env.detect.base.DetectorUtil;
import com.fr.env.detect.base.EnvDetectorConfig;
import com.fr.env.detect.bean.DetectorResult;
import com.fr.env.detect.bean.DetectorStatus;
import com.fr.event.Event;
@ -36,6 +37,43 @@ import java.util.stream.Stream;
**/
public class EnvDetectorCenter {
private final Listener<Null> AFTER_START_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.SERVER_LAUNCH)) {
stop();
}
}
};
private final Listener<Null> BEFORE_START_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
PROCESS.set(DetectorProcess.SERVER_LAUNCH);
start();
}
};
private final Listener<Null> START_UP_COMPLETE_LISTENER = new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
};
private final Listener<Workspace> AFTER_SWITCH_LISTENER = new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
};
private final AtomicReference<DetectorProcess> PROCESS = new AtomicReference<>();
public static EnvDetectorCenter getInstance() {
return EnvDetectorCenterHolder.INSTANCE;
}
@ -44,54 +82,36 @@ public class EnvDetectorCenter {
private static final EnvDetectorCenter INSTANCE = new EnvDetectorCenter();
}
private final AtomicReference<DetectorProcess> PROCESS = new AtomicReference<>();
/**
* 初始化
*/
public void init() {
// 如果已经启动了,则不再启动
if (PROCESS.get() != null) {
return;
}
start();
// 默认是启动
PROCESS.set(DetectorProcess.DESIGN_LAUNCH);
start();
// 添加启动完成监听
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
});
// 切换完成后的监听
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener<Workspace>() {
@Override
public void on(Event event, Workspace param) {
if (isSameProcess(DetectorProcess.DESIGN_LAUNCH)) {
stop();
}
}
});
// 打开内置服务器
EventDispatcher.listen(EmbedServerEvent.BeforeStart, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
PROCESS.set(DetectorProcess.SERVER_LAUNCH);
start();
}
});
EventDispatcher.listen(EmbedServerEvent.AfterStart, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
if (isSameProcess(DetectorProcess.SERVER_LAUNCH)) {
stop();
}
}
});
listen();
}
/**
* 销毁一般用在模块关闭中
*/
public void destroy() {
stopListen();
// 重置内容
DetectorBridge.getInstance().reset();
// 关闭逻辑
DetectorBridge.getInstance().stop();
PROCESS.set(null);
}
/**
@ -121,13 +141,17 @@ public class EnvDetectorCenter {
*/
public void stop() {
// 一分钟后执行
// 结束
DetectorBridge.getInstance().stop();
// 30s后执行
DelayHelper.delayCall(EnvDetectorCenter.class.getName(), () -> {
// 如果当前没开启,则直接返回
if (!EnvDetectorConfig.getInstance().isEnabled()) {
return;
}
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect();
// 结束
DetectorBridge.getInstance().stop();
// 展示效果
NotificationDialogProperties properties = new NotificationDialogProperties(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Detect_Notification_Title"));
@ -162,6 +186,28 @@ public class EnvDetectorCenter {
.collect(Collectors.toList());
}
private void listen() {
// 添加启动完成监听
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, START_UP_COMPLETE_LISTENER);
// 切换完成后的监听
EventDispatcher.listen(WorkspaceEvent.AfterSwitch, AFTER_SWITCH_LISTENER);
// 内置服务器监听
EventDispatcher.listen(EmbedServerEvent.BeforeStart, BEFORE_START_LISTENER);
EventDispatcher.listen(EmbedServerEvent.AfterStart, AFTER_START_LISTENER);
}
private void stopListen() {
EventDispatcher.stopListen(START_UP_COMPLETE_LISTENER);
EventDispatcher.stopListen(AFTER_SWITCH_LISTENER);
EventDispatcher.stopListen(BEFORE_START_LISTENER);
EventDispatcher.stopListen(AFTER_START_LISTENER);
}
private enum DetectorProcess {
/**

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

@ -71,6 +71,11 @@ public class DetectorBridge {
}
}
public void reset() {
ThrowableStore.getInstance().reset();
}
/**
* 针对某一项进行检测
* 主要用于手动检测时

8
designer-base/src/main/java/com/fr/env/detect/impl/JarInconsistentDetector.java vendored

@ -54,7 +54,6 @@ public class JarInconsistentDetector extends AbstractExceptionDetector {
if (WorkContext.getCurrent().isLocal()) {
return detectLocal();
} else {
return detectLocalAndRemote();
}
@ -75,13 +74,14 @@ public class JarInconsistentDetector extends AbstractExceptionDetector {
Map<String, String> remoteMap = groupBy(remoteInfos);
MapDifference<String, String> difference = Maps.difference(localMap, remoteMap);
Map<String, String> diffInCommon = difference.entriesInCommon();
// 获取本地远程不一样的部分
Map<String, MapDifference.ValueDifference<String>> diffs = difference.entriesDiffering();
if (diffInCommon.isEmpty()) {
if (diffs.isEmpty()) {
return DetectorResult.normal(type());
}
Set<String> inConsistentJars = diffInCommon.keySet();
Set<String> inConsistentJars = diffs.keySet();
String message = StringUtils.join(inConsistentJars, SEPARATOR);
Message.Simple tipsMessage = new Message.Simple(Toolkit.i18nText("Fine_Design_Basic_Detect_Server") + Toolkit.i18nText(type().getTipsLocale()) + message);

3
designer-base/src/main/java/com/fr/env/detect/impl/JarLackDetector.java vendored

@ -78,7 +78,8 @@ public class JarLackDetector extends AbstractExceptionDetector {
}
private boolean isLackInfo(BuildInfo e) {
return StringUtils.isNotEmpty(e.getGroupBuild());
return StringUtils.isEmpty(e.getGroupBuild());
}
private Message tipsMessage(List<BuildInfo> infos) {

9
designer-base/src/main/java/com/fr/env/detect/impl/converter/ClassConflictConvertor.java vendored

@ -110,13 +110,18 @@ public class ClassConflictConvertor implements ThrowableConverter {
}
}
// 如果少于两个,则不需要提示
if (allPath.size() < 2) {
return null;
}
String msg = StringUtils.join(allPath, SEPARATOR);
DetectorType type = DetectorType.JAR_CONFLICT;
return DetectorResult.exception(type,
ExceptionTips.create(Toolkit.i18nText(type.getTipsLocale(), msg)),
ExceptionTips.create(Toolkit.i18nText(type.getTipsLocale()) + msg),
ExceptionSolution.create(Toolkit.i18nText(type.getSolutionLocale()), DetectorConstants.JAR_HELP_LINK, null),
ExceptionLog.create(Toolkit.i18nText(type.getLogLocale()), msg));
ExceptionLog.create(Toolkit.i18nText(type.getLogLocale()) + msg));
}
@NotNull

21
designer-base/src/main/java/com/fr/env/detect/thowable/ThrowableLogAppender.java vendored

@ -1,6 +1,6 @@
package com.fr.env.detect.thowable;
import com.fr.log.FineLoggerFactory;
import com.fr.general.FRLogger;
import com.fr.log.LogHandler;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.Filter;
@ -32,12 +32,15 @@ public class ThrowableLogAppender extends AbstractAppender {
@Override
public void append(LogEvent logEvent) {
if (logEvent.getLevel() == Level.ERROR) {
Throwable thrown = logEvent.getThrown();
if (thrown != null) {
ThrowableStore.getInstance().add(thrown);
try {
if (logEvent.getLevel() == Level.ERROR) {
Throwable thrown = logEvent.getThrown();
if (thrown != null) {
ThrowableStore.getInstance().add(thrown);
}
}
} catch (Throwable ignore) {
}
}
@ -57,11 +60,11 @@ public class ThrowableLogAppender extends AbstractAppender {
public void enable() {
FineLoggerFactory.getLogger().addLogAppender(logHandler);
FRLogger.getLogger().addExtendLogAppender(logHandler);
}
public void disable() {
FineLoggerFactory.getLogger().removeLogAppender(logHandler);
FRLogger.getLogger().removeExtendLogAppender(logHandler);
}
}

15
designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java vendored

@ -166,7 +166,11 @@ public class EnvDetectorDialog extends JDialog {
}
private void startDetecting(UIButton detectButton) {
// 重新检测的时候需要处理一些逻辑
if (buttonStatus == EnvDetectorButtonStatus.A_NEW) {
reInit();
}
// 执行前
buttonStatus = buttonStatus.next();
UIUtil.invokeLaterIfNeeded(() -> detectButton.setText(buttonStatus.getDesc()));
@ -222,6 +226,15 @@ public class EnvDetectorDialog extends JDialog {
detectWorker.execute();
}
private void reInit() {
currentDetectIndex = 0;
for (EnvDetectorItem e : model.getItems()) {
e.setResult(null);
}
// 刷新一下面板-开始执行啦
UIUtil.invokeLaterIfNeeded(EnvDetectorDialog.this::refresh);
}
private void stopDetecting(UIButton detectButton) {
buttonStatus = buttonStatus.next();

51
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

@ -421,25 +421,37 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
@Override
public void itemStateChanged(ItemEvent e) {
Style elementStyle = cellElement.getStyle();
FRFont frFont = elementStyle.getFRFont();
if (showContent.getSelectedIndex() == 3) {
fileNamePane.setPreferredSize(new Dimension(100, 20));
fileNameLayout.show(fileNamePane, "content");
frFont = frFont.applyForeground(Color.blue);
frFont = frFont.applyUnderline(Constants.LINE_THIN);
} else {
fileNameLayout.show(fileNamePane, "none");
fileNamePane.setPreferredSize(new Dimension(0, 0));
frFont = frFont.applyForeground(Color.black);
frFont = frFont.applyUnderline(Constants.LINE_NONE);
if (e.getStateChange() == ItemEvent.SELECTED) {
if (showContent.getSelectedIndex() == 3) {
fileNamePane.setPreferredSize(new Dimension(100, 20));
fileNameLayout.show(fileNamePane, "content");
} else {
fileNameLayout.show(fileNamePane, "none");
fileNamePane.setPreferredSize(new Dimension(0, 0));
}
handleCellShowStyleChange(e);
}
cellElement.setStyle(elementStyle.deriveFRFont(frFont));
}
});
return fileNamePane;
}
private void handleCellShowStyleChange(ItemEvent itemEvent) {
CellGUIAttr cellGUIAttr = getCellGUIAttr();
int selectedIndex = showContent.getSelectedIndex();
boolean showAsDownload = cellGUIAttr.isShowAsDownload();
Style elementStyle = cellElement.getStyle();
FRFont frFont = elementStyle.getFRFont();
if (!showAsDownload && selectedIndex == 3) {
frFont = frFont.applyForeground(Color.blue);
frFont = frFont.applyUnderline(Constants.LINE_THIN);
} else if (showAsDownload && selectedIndex != 3) {
frFont = frFont.applyForeground(Color.black);
frFont = frFont.applyUnderline(Constants.LINE_NONE);
}
cellElement.setStyle(elementStyle.deriveFRFont(frFont));
}
private void initAllNames() {
defaultAutoRadioButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Follow_Paper_Settings"));
@ -475,15 +487,20 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Other");
}
private CellGUIAttr getCellGUIAttr() {
CellGUIAttr cellGUIAttr = cellElement.getCellGUIAttr();
if (cellGUIAttr == null) {
cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR;
}
return cellGUIAttr;
}
@Override
protected void populateBean() {
this.currentPageFixedRowDataTipLabel.setText(" (" + Toolkit.i18nText("Fine-Design_Report_CellWrite_No_Page_Fixed_Row_Cell") + ")");
this.pageFixedRowDataCell = null;
checkPageFixedRow();
CellGUIAttr cellGUIAttr = cellElement.getCellGUIAttr();
if (cellGUIAttr == null) {
cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR;
}
CellGUIAttr cellGUIAttr = getCellGUIAttr();
// 支持 跟随页面设置 选项 = 不在编辑表单中的报表块 && 不在大屏模板cpt组件中
boolean supportFollowTplDefine = !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT)

4
designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

@ -2,6 +2,7 @@ package com.fr.start.module;
import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper;
import com.fr.design.file.TemplateResourceManager;
import com.fr.design.utils.DesignUtils;
import com.fr.file.TmpFileUtils;
import com.fr.general.CloudCenter;
@ -28,6 +29,9 @@ public class PreStartActivator extends Activator {
// 创建监听服务
DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix());
// 在插件引擎模块起来前 初始化下插件接口监听
TemplateResourceManager.getResource();
initLanguage();
}

Loading…
Cancel
Save