xiaxiang 8 years ago
parent
commit
00cc0ec45a
  1. 254
      designer_base/src/com/fr/PluginManager.java
  2. 39
      designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

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

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

39
designer_base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -8,31 +8,10 @@ import com.fr.base.FRContext;
import com.fr.design.DesignState;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.community.BBSAction;
import com.fr.design.actions.community.BugAction;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
import com.fr.design.actions.community.UpAction;
import com.fr.design.actions.community.VideoAction;
import com.fr.design.actions.file.CloseCurrentTemplateAction;
import com.fr.design.actions.file.ExitDesignerAction;
import com.fr.design.actions.file.OpenRecentReportMenuDef;
import com.fr.design.actions.file.OpenTemplateAction;
import com.fr.design.actions.file.PreferenceAction;
import com.fr.design.actions.file.SwitchExistEnv;
import com.fr.design.actions.help.AboutAction;
import com.fr.design.actions.help.FeedBackAction;
import com.fr.design.actions.help.ForumAction;
import com.fr.design.actions.help.SupportQQAction;
import com.fr.design.actions.help.TutorialAction;
import com.fr.design.actions.help.WebDemoAction;
import com.fr.design.actions.server.ConnectionListAction;
import com.fr.design.actions.server.FunctionManagerAction;
import com.fr.design.actions.server.GlobalParameterAction;
import com.fr.design.actions.server.GlobalTableDataAction;
import com.fr.design.actions.server.PlatformManagerAction;
import com.fr.design.actions.server.PluginManagerAction;
import com.fr.design.actions.community.*;
import com.fr.design.actions.file.*;
import com.fr.design.actions.help.*;
import com.fr.design.actions.server.*;
import com.fr.design.file.NewTemplatePane;
import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.TableDataPaneProcessor;
@ -55,7 +34,10 @@ import com.fr.stable.ProductConstants;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.Set;
/**
* @author richer
@ -151,10 +133,11 @@ public abstract class ToolBarMenuDock {
// 添加服务器菜单
menuList.add(createServerMenuDef(plus));
// 添加帮助菜单
menuList.add(createHelpMenuDef());
// 添加社区菜单
// 添加社区菜单
menuList.add(createCommunityMenuDef());
return menuList.toArray(new MenuDef[menuList.size()]);
}
@ -359,7 +342,7 @@ public abstract class ToolBarMenuDock {
for (ShortCut shortCut : otherCommunityShortCuts) {
menuDef.addShortCut(shortCut);
}
insertMenu(menuDef, MenuHandler.HELP);
insertMenu(menuDef, MenuHandler.BBS);
return menuDef;
}
/**

Loading…
Cancel
Save