diff --git a/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java b/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java index fdc63feac..12b19fe12 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java +++ b/designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java @@ -13,7 +13,7 @@ import javax.swing.*; public class ActionModel extends AlphaCellModel { private Action action; - private String actionName; + private String className; public ActionModel(String name, String content, CellType type) { super(name, content, type); @@ -43,11 +43,6 @@ public class ActionModel extends AlphaCellModel { this.setDescription(description); } - public ActionModel(String name, Action action) { - super(name, null, CellType.ACTION); - this.action = action; - } - public Action getAction() { return action; } @@ -69,14 +64,14 @@ public class ActionModel extends AlphaCellModel { @Override public String getStoreInformation() { - return getActionName(); + return getClassName(); } - public String getActionName() { + public String getClassName() { return getAction().getClass().getName(); } - public void setActionName(String actionName) { - this.actionName = actionName; + public void setClassName(String className) { + this.className = className; } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java index 53fe4438a..59182594f 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java @@ -9,6 +9,7 @@ import com.fr.design.mainframe.alphafine.cell.model.ActionModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.mainframe.toolbar.UpdateActionModel; +import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.StringUtils; @@ -71,24 +72,17 @@ public class ActionSearchManager implements AlphaFineSearchProcessor { } /** - * 根据类名反射获取对象 + * 根据类名获取对象 * @param actionName * @return */ public static ActionModel getModelFromCloud(String actionName ) { - UpdateAction action = null; - String name = null; - try { - Class className = Class.forName(actionName); - action = (UpdateAction) className.newInstance(); - name = action.getName(); - } catch (ClassNotFoundException e) { - FRLogger.getLogger().error(e.getMessage()); - } catch (IllegalAccessException e) { - FRLogger.getLogger().error(e.getMessage()); - } catch (InstantiationException e) { - FRLogger.getLogger().error(e.getMessage()); + List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); + for (UpdateActionModel updateActionModel : updateActions) { + if (ComparatorUtils.equals(actionName, updateActionModel.getClassName())) { + return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction()); + } } - return new ActionModel(name, action); + return null; } } diff --git a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java index 8742c09ba..e755a1477 100644 --- a/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java +++ b/designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java @@ -3,9 +3,9 @@ package com.fr.design.mainframe.alphafine.search.manager; import com.fr.base.FRContext; import com.fr.base.Utils; import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; -import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; -import com.fr.design.mainframe.alphafine.cell.model.MoreModel; +import com.fr.design.mainframe.alphafine.cell.model.*; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.file.XMLFileManager; import com.fr.general.ComparatorUtils; @@ -38,11 +38,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear private static final int MAX_SIZE = 3; private static RecentSearchManager recentSearchManager = null; private static File recentFile = null; - private List fileList; - private List actionList; - private List documentList; private SearchResult modelList; - private List pluginList; + private List fileList = new ArrayList<>(); + private List actionList = new ArrayList<>(); + private List documentList = new ArrayList<>(); + private List pluginList = new ArrayList<>(); private List recentModelList = new ArrayList<>(); private Map> recentKVModelMap = new HashMap<>(); @@ -95,17 +95,73 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear } } + private void addModelToList(List list, String name) { try { - AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(name)); + AlphaCellModel model = getModelFromJson(new JSONObject(name)); if (model != null) { - list.add(CellModelHelper.getModelFromJson(new JSONObject(name))); + list.add(model); } } catch (JSONException e) { FRLogger.getLogger().error(e.getMessage()); } } + /** + * 转成cellModel + * @param object + * @return + */ + private AlphaCellModel getModelFromJson(JSONObject object) { + int typeValue = object.optInt("cellType"); + AlphaCellModel cellModel = null; + switch (CellType.parse(typeValue)) { + case ACTION: + cellModel = ActionSearchManager.getModelFromCloud(object.optString("result")); + if (cellModel != null) { + actionList.add(cellModel); + } + break; + case DOCUMENT: + cellModel = DocumentSearchManager.getModelFromCloud(object.optJSONObject("result")); + if (cellModel != null) { + documentList.add(cellModel); + } + break; + case FILE: + cellModel = FileSearchManager.getModelFromCloud(object.optString("result")); + if (cellModel != null) { + fileList.add(cellModel); + } + break; + case PLUGIN: + case REUSE: + cellModel = PluginSearchManager.getModelFromCloud(object.optJSONObject("result")); + if (cellModel != null) { + pluginList.add(cellModel); + } + break; + + } + return cellModel; + } + + public List getFileList() { + return fileList; + } + + public List getActionList() { + return actionList; + } + + public List getDocumentList() { + return documentList; + } + + public List getPluginList() { + return pluginList; + } + @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG(XML_TAG); @@ -135,37 +191,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear return "alphafine_recent.xml"; } - public List getFileList() { - return fileList; - } - public void setFileList(List fileList) { - this.fileList = fileList; - } - - public List getActionList() { - return actionList; - } - - public void setActionList(List actionList) { - this.actionList = actionList; - } - - public List getDocumentList() { - return documentList; - } - - public void setDocumentList(List documentList) { - this.documentList = documentList; - } - - public List getPluginList() { - return pluginList; - } - - public void setPluginList(List pluginList) { - this.pluginList = pluginList; - } /** * 获取xml diff --git a/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java b/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java index 9c701840f..4ded05f71 100644 --- a/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java +++ b/designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.toolbar; import com.fr.design.actions.UpdateAction; -import com.fr.stable.StringUtils; import com.fr.stable.pinyin.PinyinFormat; import com.fr.stable.pinyin.PinyinHelper; @@ -16,7 +15,7 @@ public class UpdateActionModel { private static final String SEPARATOR = "/"; private String parentName; private String actionName; - private String relatedKey; + private String className; private String searchKey; private UpdateAction action; @@ -80,14 +79,6 @@ public class UpdateActionModel { this.actionName = actionName; } - public String getRelatedKey() { - return relatedKey; - } - - public void setRelatedKey(String relatedKey) { - this.relatedKey = relatedKey; - } - public String getSearchKey() { return searchKey; } @@ -95,4 +86,12 @@ public class UpdateActionModel { public void setSearchKey(String searchKey) { this.searchKey = searchKey; } + + public String getClassName() { + return getAction().getClass().getName(); + } + + public void setClassName(String className) { + this.className = className; + } }