Browse Source

代码质量

master
XiaXiang 8 years ago
parent
commit
b463496675
  1. 19
      designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 35
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  3. 9
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java
  4. 2
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  5. 5
      designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java
  6. 9
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java
  7. 16
      designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java
  8. 9
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  9. 27
      designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java
  10. 8
      designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java
  11. 20
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java
  12. 2
      designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java
  13. 8
      designer/src/com/fr/design/parameter/ParameterDefinitePane.java

19
designer/src/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -14,15 +14,29 @@ import java.io.File;
*/
public class AlphaFineHelper {
/**
* 弹出alphafine搜索面板
*/
public static void showAlphaFineDialog() {
AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
dialog.setVisible(true);
}
/**
* 获取文件名上级目录
* @param text
* @return
*/
public static String findFolderName (String text) {
return getSplitText(text, 2);
}
/**
* 分割字符串获取文件名文件名上级目录等
* @param text
* @param index
* @return
*/
private static String getSplitText(String text, int index) {
if (StringUtils.isNotBlank(text)) {
String[] textArray = text.split("/");
@ -33,6 +47,11 @@ public class AlphaFineHelper {
return null;
}
/**
* 获取文件名
* @param text
* @return
*/
public static String findFileName (String text) {
return getSplitText(text, 1);
}

35
designer/src/com/fr/design/mainframe/alphafine/CellType.java

@ -7,43 +7,18 @@ public enum CellType {
RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
private int typeValue;
private static final int RECOMMEND_VALUE = 0;
private static final int ACTION_VALUE = 1;
private static final int DOCUMENT_VALUE = 2;
private static final int FILE_VALUE = 3;
private static final int PLUGIN_VALUE = 4;
private static final int REUSE_VALUE = 5;
CellType(int type) {
this.typeValue = type;
}
public static CellType parse(int typeValue) {
CellType type;
switch (typeValue) {
case RECOMMEND_VALUE:
type = RECOMMEND;
break;
case ACTION_VALUE:
type = ACTION;
break;
case DOCUMENT_VALUE:
type = DOCUMENT;
break;
case FILE_VALUE:
type = FILE;
break;
case PLUGIN_VALUE:
type = PLUGIN;
break;
case REUSE_VALUE:
type = REUSE;
break;
default:
type = FILE;
}
for (CellType type : CellType.values()) {
if (type.getTypeValue() == typeValue) {
return type;
}
}
return FILE;
}
public int getTypeValue() {

9
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/AlphaCellModel.java

@ -60,8 +60,17 @@ public abstract class AlphaCellModel {
this.description = description;
}
/**
* model转json
* @return
* @throws JSONException
*/
abstract public JSONObject ModelToJson() throws JSONException;
/**
* 获取需要保存到云中心的信息
* @return
*/
abstract public String getStoreInformation();
}

2
designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -561,7 +561,7 @@ public class AlphaFineDialog extends UIDialog {
* @param cellModel
*/
private void saveHistory(String searchText, AlphaCellModel cellModel) {
RecentSearchManager recentSearchManager = RecentSearchManager.getInstance();
RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger();
recentSearchManager.addRecentModel(searchText, cellModel);
recentSearchManager.saveXMLFile();
sendToServer(searchText, cellModel);

5
designer/src/com/fr/design/mainframe/alphafine/searchManager/ActionSearchManager.java

@ -68,6 +68,11 @@ public class ActionSearchManager implements AlphaFineSearchProcessor {
return moreModelList;
}
/**
* 根据类名反射获取对象
* @param actionName
* @return
*/
public static ActionModel getModelFromCloud(String actionName ) {
UpdateAction action = null;
String name = null;

9
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaFineSearchProcessor.java

@ -6,7 +6,16 @@ import com.fr.design.mainframe.alphafine.model.SearchResult;
* Created by XiaXiang on 2017/3/27.
*/
public interface AlphaFineSearchProcessor {
/**
* 获取默认显示条数
* @param searchText
* @return
*/
SearchResult getLessSearchResult(String searchText);
/**
* 获取剩余条数
* @return
*/
SearchResult getMoreSearchResult();
}

16
designer/src/com/fr/design/mainframe/alphafine/searchManager/AlphaSearchManager.java

@ -30,24 +30,24 @@ public class AlphaSearchManager implements AlphaFineSearchProcessor {
fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager();
recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getInstance();
recentSearchManager = RecentSearchManager.getRecentSearchManger();
}
}
@Override
public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult latestModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText);
latestModelList.addAll(concludeModelList);
latestModelList.addAll(actionModelList);
latestModelList.addAll(fileModelList);
latestModelList.addAll(documentModelList);
latestModelList.addAll(pluginModelList);
return latestModelList;
recentModelList.addAll(concludeModelList);
recentModelList.addAll(actionModelList);
recentModelList.addAll(fileModelList);
recentModelList.addAll(documentModelList);
recentModelList.addAll(pluginModelList);
return recentModelList;
}
public SearchResult showDefaultSearchResult() {

9
designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java

@ -56,13 +56,13 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.moreModelList.add(cellModel);
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT));
}
}
}
} catch (JSONException e) {
@ -75,6 +75,11 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return lessModelList;
}
/**
* 根据json信息获取文档model
* @param object
* @return
*/
public static DocumentModel getModelFromCloud(JSONObject object) {
String name = object.optString("title");
String content = object.optString("summary");

27
designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java

@ -108,6 +108,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
}
/**
* 搜索模板
* @param searchText
* @param node
* @param isAlreadyContain
* @return
*/
private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
@ -124,6 +131,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
return moreModelList;
}
/**
* 获取工作目录下所有符合要求的模板
* @param env
* @param rootFilePath
* @param recurse
* @return
*/
private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>();
try {
@ -134,6 +148,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
return fileNodeList;
}
/**
* 获取当前工作目录下所有模板
* @param env
* @param rootFilePath
* @param nodeList
* @param recurse
* @throws Exception
*/
private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.listFile(rootFilePath);
for (int i = 0; i < fns.length; i++) {
@ -150,6 +172,11 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
}
}
/**
* 根据文件路径获取文件模型
* @param filePath
* @return
*/
public static FileModel getModelFromCloud(String filePath) {
String name = AlphaFineHelper.findFileName(filePath);
String content = AlphaFineHelper.findFolderName(filePath);

8
designer/src/com/fr/design/mainframe/alphafine/searchManager/PluginSearchManager.java

@ -63,13 +63,12 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
this.moreModelList.add(cellModel);
}
if (jsonArray.length() > 0) {
if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN));
} else {
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN));
}
}
}
} catch (Exception e) {
@ -110,6 +109,11 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return this.moreModelList;
}
/**
* 根据json获取对应的插件model
* @param object
* @return
*/
public static PluginModel getModelFromCloud(JSONObject object) {
JSONObject jsonObject = object.optJSONObject("result");
if (jsonObject != null) {

20
designer/src/com/fr/design/mainframe/alphafine/searchManager/RecentSearchManager.java

@ -45,7 +45,7 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
private List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
public synchronized static RecentSearchManager getInstance() {
public synchronized static RecentSearchManager getRecentSearchManger() {
if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager();
try {
@ -163,6 +163,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
this.pluginList = pluginList;
}
/**
* 获取xml
* @return
*/
private File getRecentFile() {
if (recentFile == null) {
recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName());
@ -179,6 +183,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return envFile;
}
/**
* 创建XML
* @param envFile
*/
private void createRecentFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
@ -230,6 +238,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
this.recentModelList = recentModelList;
}
/**
* 根据搜索字段获取对应的model列表
* @param searchText
* @return
*/
public List<AlphaCellModel> getRecentModelList(String searchText) {
recentModelList = new ArrayList<>();
for (String key : recentKVModelMap.keySet()) {
@ -244,6 +257,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return recentModelList;
}
/**
* 将搜索结果加入到当前MAP中
* @param searchKey
* @param cellModel
*/
public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(searchKey);

2
designer/src/com/fr/design/mainframe/alphafine/searchManager/RecommendSearchManager.java

@ -45,7 +45,7 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
if (jsonArray != null && jsonArray.length() > 0) {
for (int i = 0; i < jsonArray.length(); i++) {
AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i));
if (!RecentSearchManager.getInstance().getRecentModelList().contains(alphaCellModel)) {
if (!RecentSearchManager.getRecentSearchManger().getRecentModelList().contains(alphaCellModel)) {
this.modelList.add(alphaCellModel);
}
}

8
designer/src/com/fr/design/parameter/ParameterDefinitePane.java

@ -103,7 +103,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
}
};
this.add(paraDesignEditor.createWrapper(), BorderLayout.CENTER);
// WidgetToolBarPane.getInstance(formParaDesignEditor);
// WidgetToolBarPane.getRecentSearchManger(formParaDesignEditor);
setButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png"));
setButton.set4ToolbarButton();
@ -378,7 +378,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
currentIndex++;
parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter);
refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView();
// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) {
propertyChangeListener.propertyChange();
@ -398,7 +398,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
currentIndex = currentIndex + NUM_IN_A_LINE - currentIndex % NUM_IN_A_LINE;
parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter);
refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView();
// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) {
propertyChangeListener.propertyChange();
@ -420,7 +420,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
parameterArray = null;
refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView();
// FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) {
propertyChangeListener.propertyChange();

Loading…
Cancel
Save