Browse Source
Merge in DESIGN/design from ~HADES/design:KERNEL-6380 to release/10.0 * commit '8e34fc7c12c1d4220e89794d62d6047913339281': KERNEL-6380 调整下返回点 KERNEL-6380 添加一些注释 KERNEL-6380 修改名称 KERNEL-6380 调整下接口调用 KERNEL-6380 解耦 仅处理插件afterRun生命周期 + 重命名 KERNEL-6380 在部分插件切换的时候,需要有一个集中刷新缓存的地方 KERNEL-6380 格式调整 KERNEL-6380 在部分插件切换的时候,需要有一个集中刷新缓存的地方 KERNEL-6380 在部分插件切换的时候,需要有一个集中刷新缓存的地方feature/big-screen
ju|剧浩宇
4 years ago
8 changed files with 196 additions and 62 deletions
@ -0,0 +1,78 @@ |
|||||||
|
package com.fr.design; |
||||||
|
|
||||||
|
import com.fr.design.constants.DesignerLaunchStatus; |
||||||
|
import com.fr.design.file.HistoryTemplateListCache; |
||||||
|
import com.fr.design.fun.HyperlinkProvider; |
||||||
|
import com.fr.design.fun.TableDataDefineProvider; |
||||||
|
import com.fr.plugin.observer.PluginEvent; |
||||||
|
import com.fr.plugin.observer.PluginEventListener; |
||||||
|
import com.fr.plugin.observer.PluginEventType; |
||||||
|
import com.fr.plugin.observer.PluginListenerRegistration; |
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/17 |
||||||
|
*/ |
||||||
|
public class PluginClassRefreshManager { |
||||||
|
|
||||||
|
|
||||||
|
private static final PluginClassRefreshManager INSTANCE = new PluginClassRefreshManager(); |
||||||
|
|
||||||
|
private final Set<String> context = new HashSet<>(); |
||||||
|
|
||||||
|
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent event) { |
||||||
|
// 兼容之前版本特性
|
||||||
|
for (String tag : context) { |
||||||
|
if (event.getContext().contain(tag)) { |
||||||
|
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
// 重新载入模板xml内容 到 Workbook/Form对象中
|
||||||
|
HistoryTemplateListCache.getInstance().reloadAllEditingTemplateByPlugin(event.getContext()); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
public static PluginClassRefreshManager getInstance() { |
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public void load() { |
||||||
|
context.add(TableDataDefineProvider.XML_TAG); |
||||||
|
context.add(HyperlinkProvider.XML_TAG); |
||||||
|
} |
||||||
|
|
||||||
|
private PluginClassRefreshManager() { |
||||||
|
PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent event) { |
||||||
|
removePluginListener(); |
||||||
|
} |
||||||
|
}); |
||||||
|
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, new PluginEventListener() { |
||||||
|
@Override |
||||||
|
public void on(PluginEvent event) { |
||||||
|
addPluginListener(); |
||||||
|
if (DesignerLaunchStatus.getStatus() != DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE) { |
||||||
|
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public void removePluginListener() { |
||||||
|
PluginListenerRegistration.getInstance().stopListen(this.pluginAfterRunEventListener); |
||||||
|
} |
||||||
|
|
||||||
|
public void addPluginListener() { |
||||||
|
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginAfterRunEventListener); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.base; |
||||||
|
|
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.invoke.ClassHelper; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import java.util.Set; |
||||||
|
import junit.framework.TestCase; |
||||||
|
import org.junit.Assert; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @author hades |
||||||
|
* @version 10.0 |
||||||
|
* Created by hades on 2020/12/28 |
||||||
|
*/ |
||||||
|
public class ClassHelperTest extends TestCase { |
||||||
|
|
||||||
|
|
||||||
|
public void testGetClassLoaders() { |
||||||
|
WorkBook workBook = new WorkBook(); |
||||||
|
Set<ClassLoader> set = ClassHelper.getClassLoaders(workBook); |
||||||
|
Assert.assertFalse(set.isEmpty()); |
||||||
|
Form form = new Form(); |
||||||
|
Set<ClassLoader> set1 = ClassHelper.getClassLoaders(form); |
||||||
|
Assert.assertFalse(set1.isEmpty()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue