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. 17
      designer/src/com/fr/design/mainframe/alphafine/searchManager/DocumentSearchManager.java
  9. 27
      designer/src/com/fr/design/mainframe/alphafine/searchManager/FileSearchManager.java
  10. 16
      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 { public class AlphaFineHelper {
/**
* 弹出alphafine搜索面板
*/
public static void showAlphaFineDialog() { public static void showAlphaFineDialog() {
AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame()); AlphaFineDialog dialog = new AlphaFineDialog(DesignerContext.getDesignerFrame());
dialog.setVisible(true); dialog.setVisible(true);
} }
/**
* 获取文件名上级目录
* @param text
* @return
*/
public static String findFolderName (String text) { public static String findFolderName (String text) {
return getSplitText(text, 2); return getSplitText(text, 2);
} }
/**
* 分割字符串获取文件名文件名上级目录等
* @param text
* @param index
* @return
*/
private static String getSplitText(String text, int index) { private static String getSplitText(String text, int index) {
if (StringUtils.isNotBlank(text)) { if (StringUtils.isNotBlank(text)) {
String[] textArray = text.split("/"); String[] textArray = text.split("/");
@ -33,6 +47,11 @@ public class AlphaFineHelper {
return null; return null;
} }
/**
* 获取文件名
* @param text
* @return
*/
public static String findFileName (String text) { public static String findFileName (String text) {
return getSplitText(text, 1); 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); RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
private int typeValue; 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) { CellType(int type) {
this.typeValue = type; this.typeValue = type;
} }
public static CellType parse(int typeValue) { public static CellType parse(int typeValue) {
CellType type; for (CellType type : CellType.values()) {
switch (typeValue) { if (type.getTypeValue() == typeValue) {
case RECOMMEND_VALUE: return type;
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;
} }
return type; return FILE;
} }
public int getTypeValue() { 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; this.description = description;
} }
/**
* model转json
* @return
* @throws JSONException
*/
abstract public JSONObject ModelToJson() throws JSONException; abstract public JSONObject ModelToJson() throws JSONException;
/**
* 获取需要保存到云中心的信息
* @return
*/
abstract public String getStoreInformation(); 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 * @param cellModel
*/ */
private void saveHistory(String searchText, AlphaCellModel cellModel) { private void saveHistory(String searchText, AlphaCellModel cellModel) {
RecentSearchManager recentSearchManager = RecentSearchManager.getInstance(); RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger();
recentSearchManager.addRecentModel(searchText, cellModel); recentSearchManager.addRecentModel(searchText, cellModel);
recentSearchManager.saveXMLFile(); recentSearchManager.saveXMLFile();
sendToServer(searchText, cellModel); 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; return moreModelList;
} }
/**
* 根据类名反射获取对象
* @param actionName
* @return
*/
public static ActionModel getModelFromCloud(String actionName ) { public static ActionModel getModelFromCloud(String actionName ) {
UpdateAction action = null; UpdateAction action = null;
String name = 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. * Created by XiaXiang on 2017/3/27.
*/ */
public interface AlphaFineSearchProcessor { public interface AlphaFineSearchProcessor {
/**
* 获取默认显示条数
* @param searchText
* @return
*/
SearchResult getLessSearchResult(String searchText); SearchResult getLessSearchResult(String searchText);
/**
* 获取剩余条数
* @return
*/
SearchResult getMoreSearchResult(); 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(); fileSearchManager = FileSearchManager.getFileSearchManager();
actionSearchManager = ActionSearchManager.getActionSearchManager(); actionSearchManager = ActionSearchManager.getActionSearchManager();
recommendSearchManager = RecommendSearchManager.getRecommendSearchManager(); recommendSearchManager = RecommendSearchManager.getRecommendSearchManager();
recentSearchManager = RecentSearchManager.getInstance(); recentSearchManager = RecentSearchManager.getRecentSearchManger();
} }
} }
@Override @Override
public synchronized SearchResult getLessSearchResult(String searchText) { public synchronized SearchResult getLessSearchResult(String searchText) {
SearchResult latestModelList = recentSearchManager.getLessSearchResult(searchText); SearchResult recentModelList = recentSearchManager.getLessSearchResult(searchText);
SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText); SearchResult concludeModelList = recommendSearchManager.getLessSearchResult(searchText);
SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText); SearchResult actionModelList = actionSearchManager.getLessSearchResult(searchText);
SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText); SearchResult fileModelList = fileSearchManager.getLessSearchResult(searchText);
SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText); SearchResult documentModelList = documentSearchManager.getLessSearchResult(searchText);
SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText); SearchResult pluginModelList = pluginSearchManager.getLessSearchResult(searchText);
latestModelList.addAll(concludeModelList); recentModelList.addAll(concludeModelList);
latestModelList.addAll(actionModelList); recentModelList.addAll(actionModelList);
latestModelList.addAll(fileModelList); recentModelList.addAll(fileModelList);
latestModelList.addAll(documentModelList); recentModelList.addAll(documentModelList);
latestModelList.addAll(pluginModelList); recentModelList.addAll(pluginModelList);
return latestModelList; return recentModelList;
} }
public SearchResult showDefaultSearchResult() { public SearchResult showDefaultSearchResult() {

17
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)); DocumentModel cellModel = getModelFromCloud(jsonArray.optJSONObject(i));
this.moreModelList.add(cellModel); this.moreModelList.add(cellModel);
} }
if (jsonArray.length() > 0) { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
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));
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.DOCUMENT)); } else {
} else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT));
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT));
}
} }
} }
} catch (JSONException e) { } catch (JSONException e) {
@ -75,6 +75,11 @@ public class DocumentSearchManager implements AlphaFineSearchProcessor {
return lessModelList; return lessModelList;
} }
/**
* 根据json信息获取文档model
* @param object
* @return
*/
public static DocumentModel getModelFromCloud(JSONObject object) { public static DocumentModel getModelFromCloud(JSONObject object) {
String name = object.optString("title"); String name = object.optString("title");
String content = object.optString("summary"); 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) { private boolean searchFile(String searchText, FileNode node, boolean isAlreadyContain) {
if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) { if (DesignerEnvManager.getEnvManager().getAlphafineConfigManager().isContainTemplate()) {
if (node.getName().toLowerCase().contains(searchText.toLowerCase())) { if (node.getName().toLowerCase().contains(searchText.toLowerCase())) {
@ -124,6 +131,13 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
return moreModelList; return moreModelList;
} }
/**
* 获取工作目录下所有符合要求的模板
* @param env
* @param rootFilePath
* @param recurse
* @return
*/
private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) { private List<FileNode> listTpl(Env env, String rootFilePath, boolean recurse) {
List<FileNode> fileNodeList = new ArrayList<FileNode>(); List<FileNode> fileNodeList = new ArrayList<FileNode>();
try { try {
@ -134,6 +148,14 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
return fileNodeList; 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 { private void listAll(Env env, String rootFilePath, List<FileNode> nodeList, boolean recurse) throws Exception {
FileNode[] fns = env.listFile(rootFilePath); FileNode[] fns = env.listFile(rootFilePath);
for (int i = 0; i < fns.length; i++) { 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) { public static FileModel getModelFromCloud(String filePath) {
String name = AlphaFineHelper.findFileName(filePath); String name = AlphaFineHelper.findFileName(filePath);
String content = AlphaFineHelper.findFolderName(filePath); String content = AlphaFineHelper.findFolderName(filePath);

16
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); PluginModel cellModel = getPluginModel(jsonArray.optJSONObject(i), false);
this.moreModelList.add(cellModel); this.moreModelList.add(cellModel);
} }
if (jsonArray.length() > 0) { if (jsonArray.length() > AlphaFineConstants.SHOW_SIZE) {
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));
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), Inter.getLocText("FR-Designer_AlphaFine_ShowAll"),true, CellType.PLUGIN)); } else {
} else { lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN));
lessModelList.add(0, new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN));
}
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -110,6 +109,11 @@ public class PluginSearchManager implements AlphaFineSearchProcessor {
return this.moreModelList; return this.moreModelList;
} }
/**
* 根据json获取对应的插件model
* @param object
* @return
*/
public static PluginModel getModelFromCloud(JSONObject object) { public static PluginModel getModelFromCloud(JSONObject object) {
JSONObject jsonObject = object.optJSONObject("result"); JSONObject jsonObject = object.optJSONObject("result");
if (jsonObject != null) { 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 List<AlphaCellModel> recentModelList = new ArrayList<>();
private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>(); private Map<String, List<AlphaCellModel>> recentKVModelMap = new HashMap<>();
public synchronized static RecentSearchManager getInstance() { public synchronized static RecentSearchManager getRecentSearchManger() {
if (recentSearchManager == null) { if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager(); recentSearchManager = new RecentSearchManager();
try { try {
@ -163,6 +163,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
this.pluginList = pluginList; this.pluginList = pluginList;
} }
/**
* 获取xml
* @return
*/
private File getRecentFile() { private File getRecentFile() {
if (recentFile == null) { if (recentFile == null) {
recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName()); recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName());
@ -179,6 +183,10 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return envFile; return envFile;
} }
/**
* 创建XML
* @param envFile
*/
private void createRecentFile(File envFile) { private void createRecentFile(File envFile) {
try { try {
FileWriter fileWriter = new FileWriter(envFile); FileWriter fileWriter = new FileWriter(envFile);
@ -230,6 +238,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
this.recentModelList = recentModelList; this.recentModelList = recentModelList;
} }
/**
* 根据搜索字段获取对应的model列表
* @param searchText
* @return
*/
public List<AlphaCellModel> getRecentModelList(String searchText) { public List<AlphaCellModel> getRecentModelList(String searchText) {
recentModelList = new ArrayList<>(); recentModelList = new ArrayList<>();
for (String key : recentKVModelMap.keySet()) { for (String key : recentKVModelMap.keySet()) {
@ -244,6 +257,11 @@ public class RecentSearchManager extends XMLFileManager implements AlphaFineSear
return recentModelList; return recentModelList;
} }
/**
* 将搜索结果加入到当前MAP中
* @param searchKey
* @param cellModel
*/
public void addRecentModel(String searchKey, AlphaCellModel cellModel) { public void addRecentModel(String searchKey, AlphaCellModel cellModel) {
if (recentKVModelMap.keySet().contains(searchKey)) { if (recentKVModelMap.keySet().contains(searchKey)) {
List<AlphaCellModel> cellModels = recentKVModelMap.get(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) { if (jsonArray != null && jsonArray.length() > 0) {
for (int i = 0; i < jsonArray.length(); i++) { for (int i = 0; i < jsonArray.length(); i++) {
AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(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); 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); 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 = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/parametersetting.png"));
setButton.set4ToolbarButton(); setButton.set4ToolbarButton();
@ -378,7 +378,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
currentIndex++; currentIndex++;
parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter); parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter);
refreshParameter(); refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView(); // FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();
@ -398,7 +398,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
currentIndex = currentIndex + NUM_IN_A_LINE - currentIndex % NUM_IN_A_LINE; currentIndex = currentIndex + NUM_IN_A_LINE - currentIndex % NUM_IN_A_LINE;
parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter); parameterArray = (Parameter[]) ArrayUtils.removeElement(parameterArray, parameter);
refreshParameter(); refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView(); // FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();
@ -420,7 +420,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
parameterArray = null; parameterArray = null;
refreshParameter(); refreshParameter();
// FormHierarchyTreePane.getInstance().refreshDockingView(); // FormHierarchyTreePane.getRecentSearchManger().refreshDockingView();
DesignModuleFactory.getFormHierarchyPane().refreshDockingView(); DesignModuleFactory.getFormHierarchyPane().refreshDockingView();
if (propertyChangeListener != null) { if (propertyChangeListener != null) {
propertyChangeListener.propertyChange(); propertyChangeListener.propertyChange();

Loading…
Cancel
Save