Browse Source

KERNEL-9860 插件修改xml中active标签逻辑重构

【问题原因】rt
【改动思路】详见https://kms.fineres.com/pages/viewpage.action?pageId=289590798
【review建议】
bugfix/11.0
Yvan 3 years ago
parent
commit
cbdbc9d5d0
  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

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) {
PluginView plugin = controlPane.getSelectedPlugin();
if (plugin != null) {
boolean isActive = plugin.isActive();
PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion());
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");
if (isActive) {
PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() {
PluginContext pluginContext = getPluginContextByView(plugin);
if (pluginContext == null) {
return;
}
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
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
@ -75,7 +78,7 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
}
});
} else {
PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() {
PluginManager.getController().enablePersistently(pluginContext.getMarker(), new PluginTaskCallback() {
@Override
public void done(PluginTaskResult result) {
if (result.isSuccess()) {
@ -145,13 +148,25 @@ public class PluginInstalledPane extends PluginAbstractViewPane {
}
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"));
} else {
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
protected String title4PopupWindow() {
return "Installed";

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

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

Loading…
Cancel
Save