xiaxiang 8 years ago
parent
commit
d77d991667
  1. 254
      designer_base/src/com/fr/plugin/PluginManager.java

254
designer_base/src/com/fr/PluginManager.java → designer_base/src/com/fr/plugin/PluginManager.java

@ -1,128 +1,128 @@
package com.fr.plugin; package com.fr.plugin;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.file.XMLFileManager; import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* Author : daisy * Author : daisy
* Version: 6.5.6 * Version: 6.5.6
* Date: 13-12-20 * Date: 13-12-20
* Time: 下午5:05 * Time: 下午5:05
*/ */
public class PluginManager extends XMLFileManager { public class PluginManager extends XMLFileManager {
private static PluginManager pluginManager = null; private static PluginManager pluginManager = null;
private String extensionPoint = StringUtils.EMPTY; private String extensionPoint = StringUtils.EMPTY;
private ArrayList<UpdateAction> resultList = new ArrayList<UpdateAction>(); private ArrayList<UpdateAction> resultList = new ArrayList<UpdateAction>();
public synchronized static PluginManager getInstance() { public synchronized static PluginManager getInstance() {
if (pluginManager == null) { if (pluginManager == null) {
pluginManager = new PluginManager(); pluginManager = new PluginManager();
} }
return pluginManager; return pluginManager;
} }
public PluginManager() { public PluginManager() {
} }
/** /**
* 文件名 * 文件名
* @return 文件名 * @return 文件名
*/ */
public String fileName() { public String fileName() {
return "plugin.xml"; return "plugin.xml";
} }
public void setExtensionPoint(String point) { public void setExtensionPoint(String point) {
extensionPoint = point; extensionPoint = point;
resultList.clear(); resultList.clear();
pluginManager.readXMLFile(); pluginManager.readXMLFile();
} }
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (extensionPoint == StringUtils.EMPTY) { if (extensionPoint == StringUtils.EMPTY) {
return; return;
} }
if (reader.getTagName().equals("PluginManager")) { if (reader.getTagName().equals("PluginManager")) {
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
readExtension(reader); readExtension(reader);
} }
}); });
} }
} }
private void readExtension(XMLableReader reader) { private void readExtension(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
if (reader.getTagName().equals("Extension")) { if (reader.getTagName().equals("Extension")) {
String name = null, tmpVal = null; String name = null, tmpVal = null;
if ((tmpVal = reader.getAttrAsString("position", null)) != null) { if ((tmpVal = reader.getAttrAsString("position", null)) != null) {
name = tmpVal; name = tmpVal;
} }
if (!ComparatorUtils.equals(name, extensionPoint)) { if (!ComparatorUtils.equals(name, extensionPoint)) {
return; return;
} }
reader.readXMLObject(new XMLReadable() { reader.readXMLObject(new XMLReadable() {
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
readActions(reader); readActions(reader);
} }
}); });
} }
} }
} }
private void readActions(XMLableReader reader) { private void readActions(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
if (reader.getTagName().equals("Action")) { if (reader.getTagName().equals("Action")) {
String name = null, tmpVal = null; String name = null, tmpVal = null;
if ((tmpVal = reader.getAttrAsString("class", null)) != null) { if ((tmpVal = reader.getAttrAsString("class", null)) != null) {
name = tmpVal; name = tmpVal;
} }
//读取模板数据集菜单 //读取模板数据集菜单
if (name.isEmpty()) { if (name.isEmpty()) {
return; return;
} }
try { try {
UpdateAction action = (UpdateAction) GeneralUtils.classForName(name).newInstance(); UpdateAction action = (UpdateAction) GeneralUtils.classForName(name).newInstance();
PluginManager.this.resultList.add(action); PluginManager.this.resultList.add(action);
} catch (Exception exp) { } catch (Exception exp) {
FRLogger.getLogger().error(exp.getMessage(), exp); FRLogger.getLogger().error(exp.getMessage(), exp);
} }
} }
} }
} }
public ArrayList<UpdateAction> getResultList() { public ArrayList<UpdateAction> getResultList() {
return resultList; return resultList;
} }
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
} }
} }
Loading…
Cancel
Save