Browse Source

代码质量

master
XiaXiang 7 years ago
parent
commit
0656c731f4
  1. 25
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  2. 4
      designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java
  3. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java
  4. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java
  5. 3
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java
  6. 8
      designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java
  7. 2
      designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java
  8. 2
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

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

@ -4,30 +4,33 @@ package com.fr.design.mainframe.alphafine;
* Created by XiaXiang on 2017/4/27. * Created by XiaXiang on 2017/4/27.
*/ */
public enum CellType { public enum CellType {
PLUGIN(0), DOCUMENT(1), FILE(2), ACTION(3), REUSE(4); RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5);
private int cellType; private int typeValue;
CellType(int type) { CellType(int type) {
this.cellType = type; this.typeValue = type;
} }
public static CellType parse(int cellType) { public static CellType parse(int cellType) {
CellType type; CellType type;
switch (cellType) { switch (cellType) {
case 0: case 0:
type = PLUGIN; type = RECOMMEND;
break; break;
case 1: case 1:
type = DOCUMENT; type = ACTION;
break; break;
case 2: case 2:
type = FILE; type = DOCUMENT;
break; break;
case 3: case 3:
type = ACTION; type = FILE;
break; break;
case 4: case 4:
type = PLUGIN;
break;
case 5:
type = REUSE; type = REUSE;
break; break;
default: default:
@ -36,12 +39,12 @@ public enum CellType {
return type; return type;
} }
public int getCellType() { public int getTypeValue() {
return cellType; return typeValue;
} }
public void setCellType(int cellType) { public void setTypeValue(int typeValue) {
this.cellType = cellType; this.typeValue = typeValue;
} }
} }

4
designer/src/com/fr/design/mainframe/alphafine/cell/CellModelHelper.java

@ -14,9 +14,9 @@ import com.fr.json.JSONObject;
public class CellModelHelper { public class CellModelHelper {
private static final String RESULT = "result"; private static final String RESULT = "result";
public static AlphaCellModel jsonToModel(JSONObject object) { public static AlphaCellModel jsonToModel(JSONObject object) {
int cellType = object.optInt("cellType"); int typeValue = object.optInt("cellType");
AlphaCellModel cellModel = null; AlphaCellModel cellModel = null;
switch (CellType.parse(cellType)) { switch (CellType.parse(typeValue)) {
case ACTION: case ACTION:
cellModel = ActionSearchManager.getModelFromCloud(object.optString(RESULT)); cellModel = ActionSearchManager.getModelFromCloud(object.optString(RESULT));
break; break;

2
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/ActionModel.java

@ -55,7 +55,7 @@ public class ActionModel extends AlphaCellModel implements Serializable {
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("result", getAction().getClass().getName()).put("cellType", getType().getCellType()); object.put("result", getAction().getClass().getName()).put("cellType", getType().getTypeValue());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }

2
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/DocumentModel.java

@ -39,7 +39,7 @@ public class DocumentModel extends AlphaCellModel {
try { try {
JSONObject modelObject = JSONObject.create(); JSONObject modelObject = JSONObject.create();
modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId()); modelObject.put("title", getName()).put("summary", getContent()).put("did", getDocumentId());
object.put("result", modelObject).put("cellType", getType().getCellType()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error("DocumentModel: " + e.getMessage()); FRLogger.getLogger().error("DocumentModel: " + e.getMessage());
} }

3
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/FileModel.java

@ -5,7 +5,6 @@ import com.fr.design.mainframe.alphafine.CellType;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import org.apache.xerces.impl.xpath.regex.REUtil;
/** /**
* Created by XiaXiang on 2017/4/20. * Created by XiaXiang on 2017/4/20.
@ -35,7 +34,7 @@ public class FileModel extends AlphaCellModel{
public JSONObject ModelToJson() { public JSONObject ModelToJson() {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
object.put("result", getFilePath()).put("cellType", getType().getCellType()); object.put("result", getFilePath()).put("cellType", getType().getTypeValue());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }

8
designer/src/com/fr/design/mainframe/alphafine/cell/cellModel/PluginModel.java

@ -2,14 +2,10 @@ package com.fr.design.mainframe.alphafine.cell.cellModel;
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.CellType;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/** /**
* Created by XiaXiang on 2017/4/20. * Created by XiaXiang on 2017/4/20.
*/ */
@ -100,8 +96,8 @@ public class PluginModel extends AlphaCellModel {
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {
JSONObject modelObject = JSONObject.create(); JSONObject modelObject = JSONObject.create();
modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getCellType()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink()); modelObject.put("name", getName()).put("description", getContent()).put("pic", getImageUrl()).put("version", getVersion()).put("jartime", getJartime()).put("type", getType().getTypeValue()).put("price", getPrice()).put("id", getPluginId()).put("link", getLink());
object.put("result", modelObject).put("cellType", getType().getCellType()); object.put("result", modelObject).put("cellType", getType().getTypeValue());
} catch (JSONException e) { } catch (JSONException e) {
FRLogger.getLogger().error(e.getMessage()); FRLogger.getLogger().error(e.getMessage());
} }

2
designer/src/com/fr/design/mainframe/alphafine/cell/cellRender/ContentCellRender.java

@ -32,7 +32,7 @@ public class ContentCellRender implements ListCellRenderer<Object> {
panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); panel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0));
AlphaCellModel model = (AlphaCellModel) value; AlphaCellModel model = (AlphaCellModel) value;
name.setText(model.getName()); name.setText(model.getName());
String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getCellType() + ".png"; String iconUrl = "/com/fr/design/mainframe/alphafine/images/alphafine" + model.getType().getTypeValue() + ".png";
name.setIcon(new ImageIcon(getClass().getResource(iconUrl))); name.setIcon(new ImageIcon(getClass().getResource(iconUrl)));
name.setFont(AlphaFineConstants.MEDIUM_FONT); name.setFont(AlphaFineConstants.MEDIUM_FONT);
name.setForeground(AlphaFineConstants.BLACK); name.setForeground(AlphaFineConstants.BLACK);

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

@ -579,7 +579,7 @@ public class AlphaFineDialog extends UIDialog {
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); String activitykey = DesignerEnvManager.getEnvManager().getActivationKey();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String key = searchKey; String key = searchKey;
int resultkind = cellModel.getType().getCellType(); int resultkind = cellModel.getType().getTypeValue();
String resultValue = CellModelHelper.getResultValueFromModel(cellModel); String resultValue = CellModelHelper.getResultValueFromModel(cellModel);
JSONObject object = JSONObject.create(); JSONObject object = JSONObject.create();
try { try {

Loading…
Cancel
Save