Browse Source

bug fix

master
XiaXiang 8 years ago
parent
commit
a7456326cb
  1. 15
      designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java
  2. 22
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  3. 102
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecentSearchManager.java
  4. 19
      designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java

15
designer/src/com/fr/design/mainframe/alphafine/cell/model/ActionModel.java

@ -13,7 +13,7 @@ import javax.swing.*;
public class ActionModel extends AlphaCellModel { public class ActionModel extends AlphaCellModel {
private Action action; private Action action;
private String actionName; private String className;
public ActionModel(String name, String content, CellType type) { public ActionModel(String name, String content, CellType type) {
super(name, content, type); super(name, content, type);
@ -43,11 +43,6 @@ public class ActionModel extends AlphaCellModel {
this.setDescription(description); this.setDescription(description);
} }
public ActionModel(String name, Action action) {
super(name, null, CellType.ACTION);
this.action = action;
}
public Action getAction() { public Action getAction() {
return action; return action;
} }
@ -69,14 +64,14 @@ public class ActionModel extends AlphaCellModel {
@Override @Override
public String getStoreInformation() { public String getStoreInformation() {
return getActionName(); return getClassName();
} }
public String getActionName() { public String getClassName() {
return getAction().getClass().getName(); return getAction().getClass().getName();
} }
public void setActionName(String actionName) { public void setClassName(String className) {
this.actionName = actionName; this.className = className;
} }
} }

22
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.alphafine.model.SearchResult;
import com.fr.design.mainframe.toolbar.UpdateActionManager; import com.fr.design.mainframe.toolbar.UpdateActionManager;
import com.fr.design.mainframe.toolbar.UpdateActionModel; import com.fr.design.mainframe.toolbar.UpdateActionModel;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -71,24 +72,17 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
} }
/** /**
* 根据类名反射获取对象 * 根据类名获取对象
* @param actionName * @param actionName
* @return * @return
*/ */
public static ActionModel getModelFromCloud(String actionName ) { public static ActionModel getModelFromCloud(String actionName ) {
UpdateAction action = null; List<UpdateActionModel> updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions();
String name = null; for (UpdateActionModel updateActionModel : updateActions) {
try { if (ComparatorUtils.equals(actionName, updateActionModel.getClassName())) {
Class<?> className = Class.forName(actionName); return new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction());
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());
} }
return new ActionModel(name, action); return null;
} }
} }

102
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.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; 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.CellModelHelper;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.*;
import com.fr.design.mainframe.alphafine.cell.model.MoreModel;
import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.file.XMLFileManager; import com.fr.file.XMLFileManager;
import com.fr.general.ComparatorUtils; 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 final int MAX_SIZE = 3;
private static RecentSearchManager recentSearchManager = null; private static RecentSearchManager recentSearchManager = null;
private static File recentFile = null; private static File recentFile = null;
private List<String> fileList;
private List<String> actionList;
private List<String> documentList;
private SearchResult modelList; private SearchResult modelList;
private List<String> pluginList; private List<AlphaCellModel> fileList = new ArrayList<>();
private List<AlphaCellModel> actionList = new ArrayList<>();
private List<AlphaCellModel> documentList = new ArrayList<>();
private List<AlphaCellModel> pluginList = new ArrayList<>();
private List<AlphaCellModel> recentModelList = new ArrayList<>(); private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>(); private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
@ -95,17 +95,73 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
} }
} }
private void addModelToList(List<AlphaCellModel> list, String name) { private void addModelToList(List<AlphaCellModel> list, String name) {
try { try {
AlphaCellModel model = CellModelHelper.getModelFromJson(new JSONObject(name)); AlphaCellModel model = getModelFromJson(new JSONObject(name));
if (model != null) { if (model != null) {
list.add(CellModelHelper.getModelFromJson(new JSONObject(name))); list.add(model);
} }
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); 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<AlphaCellModel> getFileList() {
return fileList;
}
public List<AlphaCellModel> getActionList() {
return actionList;
}
public List<AlphaCellModel> getDocumentList() {
return documentList;
}
public List<AlphaCellModel> getPluginList() {
return pluginList;
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG); writer.startTAG(XML_TAG);
@ -135,37 +191,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return "alphafine_recent.xml"; return "alphafine_recent.xml";
} }
public List<String> getFileList() {
return fileList;
}
public void setFileList(List<String> fileList) {
this.fileList = fileList;
}
public List<String> getActionList() {
return actionList;
}
public void setActionList(List<String> actionList) {
this.actionList = actionList;
}
public List<String> getDocumentList() {
return documentList;
}
public void setDocumentList(List<String> documentList) {
this.documentList = documentList;
}
public List<String> getPluginList() {
return pluginList;
}
public void setPluginList(List<String> pluginList) {
this.pluginList = pluginList;
}
/** /**
* 获取xml * 获取xml

19
designer_base/src/com/fr/design/mainframe/toolbar/UpdateActionModel.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe.toolbar; package com.fr.design.mainframe.toolbar;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.stable.StringUtils;
import com.fr.stable.pinyin.PinyinFormat; import com.fr.stable.pinyin.PinyinFormat;
import com.fr.stable.pinyin.PinyinHelper; import com.fr.stable.pinyin.PinyinHelper;
@ -16,7 +15,7 @@ public class UpdateActionModel {
private static final String SEPARATOR = "/"; private static final String SEPARATOR = "/";
private String parentName; private String parentName;
private String actionName; private String actionName;
private String relatedKey; private String className;
private String searchKey; private String searchKey;
private UpdateAction action; private UpdateAction action;
@ -80,14 +79,6 @@ public class UpdateActionModel {
this.actionName = actionName; this.actionName = actionName;
} }
public String getRelatedKey() {
return relatedKey;
}
public void setRelatedKey(String relatedKey) {
this.relatedKey = relatedKey;
}
public String getSearchKey() { public String getSearchKey() {
return searchKey; return searchKey;
} }
@ -95,4 +86,12 @@ public class UpdateActionModel {
public void setSearchKey(String searchKey) { public void setSearchKey(String searchKey) {
this.searchKey = searchKey; this.searchKey = searchKey;
} }
public String getClassName() {
return getAction().getClass().getName();
}
public void setClassName(String className) {
this.className = className;
}
} }

Loading…
Cancel
Save