hades
4 years ago
7 changed files with 118 additions and 41 deletions
@ -0,0 +1,73 @@
|
||||
package com.fr.design; |
||||
|
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.design.fun.HyperlinkProvider; |
||||
import com.fr.design.fun.TableDataDefineProvider; |
||||
import com.fr.plugin.manage.PluginFilter; |
||||
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 com.fr.stable.fun.IOFileAttrMark; |
||||
import java.util.HashSet; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/12/17 |
||||
*/ |
||||
public class PluginRefreshManager { |
||||
|
||||
|
||||
private static final PluginRefreshManager INSTANCE = new PluginRefreshManager(); |
||||
|
||||
private final Set<String> context = new HashSet<>(); |
||||
|
||||
private final PluginEventListener pluginAfterRunEventListener = new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
// 重新载入模板xml内容 到 Workbook/Form对象中
|
||||
HistoryTemplateListCache.getInstance().reloadAllEditingTemplate(); |
||||
} |
||||
}; |
||||
|
||||
private final PluginFilter pluginFilter = pluginContext -> { |
||||
for (String xmlTag : context) { |
||||
if (pluginContext.contain(xmlTag)) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
}; |
||||
|
||||
|
||||
public static PluginRefreshManager getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
public void load() { |
||||
context.add(IOFileAttrMark.MARK_STRING); |
||||
context.add(TableDataDefineProvider.XML_TAG); |
||||
context.add(HyperlinkProvider.XML_TAG); |
||||
} |
||||
|
||||
private PluginRefreshManager() { |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginAfterRunEventListener, this.pluginFilter); |
||||
} |
||||
|
||||
public void registerItem(String xmlTag) { |
||||
context.add(xmlTag); |
||||
} |
||||
|
||||
public void removePluginListener() { |
||||
PluginListenerRegistration.getInstance().stopListen(this.pluginAfterRunEventListener); |
||||
|
||||
} |
||||
|
||||
public void addPluginListener() { |
||||
PluginListenerRegistration.getInstance().listen(PluginEventType.AfterRun, this.pluginAfterRunEventListener, this.pluginFilter); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue