Browse Source

Pull request #7100: KERNEL-9860 插件修改xml中active标签逻辑重构

Merge in DESIGN/design from ~YVAN/design:release/11.0 to release/11.0

* commit 'b6d38f7f2eab0689ddcca04ad722bfc40841574c':
  KERNEL-9860 插件修改xml中active标签逻辑重构 跟vito讨论了下,决定模板报错的一键处理这儿,也是需要修改xml的,因为也是用户自己点的处理
  KERNEL-9860 插件修改xml中active标签逻辑重构 【问题原因】rt 【改动思路】详见https://kms.fineres.com/pages/viewpage.action?pageId=289590798 【review建议】
bugfix/11.0
Yvan 3 years ago
parent
commit
0155250ccc
  1. 29
      designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java
  2. 12
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  3. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java

29
designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java

@ -60,11 +60,14 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PluginView plugin = controlPane.getSelectedPlugin(); PluginView plugin = controlPane.getSelectedPlugin();
if (plugin != null) { if (plugin != null) {
boolean isActive = plugin.isActive(); PluginContext pluginContext = getPluginContextByView(plugin);
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); if (pluginContext == null) {
final String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled"); return;
if (isActive) { }
PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() { boolean running = pluginContext.isRunning();
final String modifyMessage = running ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled");
if (running) {
PluginManager.getController().forbidPersistently(pluginContext.getMarker(), new PluginTaskCallback() {
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
@ -75,7 +78,7 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
} }
}); });
} else { } else {
PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() { PluginManager.getController().enablePersistently(pluginContext.getMarker(), new PluginTaskCallback() {
@Override @Override
public void done(PluginTaskResult result) { public void done(PluginTaskResult result) {
if (result.isSuccess()) { if (result.isSuccess()) {
@ -145,13 +148,25 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
} }
private void changeTextForButton(PluginView plugin) { private void changeTextForButton(PluginView plugin) {
if (plugin.isActive()) { PluginContext pluginContext = getPluginContextByView(plugin);
if (pluginContext == null) {
return;
}
if (pluginContext.isRunning()) {
disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Disable")); disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Disable"));
} else { } else {
disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Active")); disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Active"));
} }
} }
private PluginContext getPluginContextByView(PluginView pluginView) {
if (pluginView != null) {
PluginMarker pluginMarker = PluginMarker.create(pluginView.getID(), pluginView.getVersion());
return PluginManager.getContext(pluginMarker);
}
return null;
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Installed"; return "Installed";

12
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -99,9 +99,9 @@ public class PluginOperateUtils {
public void run() { public void run() {
PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo);
PluginContext plugin = PluginManager.getContext(pluginMarker); PluginContext plugin = PluginManager.getContext(pluginMarker);
boolean active = plugin.isActive(); boolean isRunning = plugin.isRunning();
PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback); PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(isRunning, jsCallback);
if (active) { if (isRunning) {
PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder); PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder);
if (forbidReminder != null && forbidReminder.getContent() != null) { if (forbidReminder != null && forbidReminder.getContent() != null) {
// 禁用前提示 // 禁用前提示
@ -113,14 +113,14 @@ public class PluginOperateUtils {
JOptionPane.WARNING_MESSAGE JOptionPane.WARNING_MESSAGE
); );
if (rv == JOptionPane.OK_OPTION) { if (rv == JOptionPane.OK_OPTION) {
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback);
} }
} else { } else {
// 正常禁用 // 正常禁用
PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback);
} }
} else { } else {
PluginManager.getController().enable(pluginMarker, modifyStatusCallback); PluginManager.getController().enablePersistently(pluginMarker, modifyStatusCallback);
} }
} }
}); });

2
designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java

@ -220,7 +220,7 @@ public class DesignerAppUtils {
Multimap<String, PluginMarkerAdapter> stringPluginMarkerAdapterMultimap = popPluginInfoMap(key); Multimap<String, PluginMarkerAdapter> stringPluginMarkerAdapterMultimap = popPluginInfoMap(key);
Collection<PluginMarkerAdapter> disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN); Collection<PluginMarkerAdapter> disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN);
for (PluginMarkerAdapter disablePlugin : disablePlugins) { for (PluginMarkerAdapter disablePlugin : disablePlugins) {
PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); PluginManager.getController().enablePersistently(disablePlugin, new ModifyStatusCallback(false));
} }
Collection<PluginMarkerAdapter> uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN); Collection<PluginMarkerAdapter> uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN);

Loading…
Cancel
Save