Browse Source

bug fix 代码质量

master
XiaXiang 8 years ago
parent
commit
6e401c117c
  1. 2
      designer/src/com/fr/design/mainframe/alphafine/CellType.java
  2. 16
      designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java
  3. 50
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  4. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java
  5. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java
  6. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java
  7. 2
      designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java

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

@ -4,7 +4,7 @@ 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 {
RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6); RECOMMEND(0), ACTION(1), DOCUMENT(2), FILE(3), PLUGIN(4), REUSE(5), NO_RESULT(6), MORE(7);
private int typeValue; private int typeValue;

16
designer/src/com/fr/design/mainframe/alphafine/cell/model/MoreModel.java

@ -10,14 +10,16 @@ import com.fr.json.JSONObject;
public class MoreModel extends AlphaCellModel { public class MoreModel extends AlphaCellModel {
private boolean needMore; private boolean needMore;
private boolean isLoading; private boolean isLoading;
private CellType contentType;
public MoreModel(String name, String content, boolean needMore, CellType type) { public MoreModel(String name, String content, boolean needMore, CellType type) {
super(name, content, type); super(name, content, CellType.MORE);
this.needMore = needMore; this.needMore = needMore;
this.contentType = type;
} }
public MoreModel(String name, CellType type) { public MoreModel(String name) {
super(name, null, type); super(name, null, CellType.MORE);
this.needMore = false; this.needMore = false;
} }
@ -66,4 +68,12 @@ public class MoreModel extends AlphaCellModel {
public boolean isNeedToSendToServer() { public boolean isNeedToSendToServer() {
return false; return false;
} }
public CellType getContentType() {
return contentType;
}
public void setContentType(CellType contentType) {
this.contentType = contentType;
}
} }

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

@ -414,15 +414,21 @@ public class AlphaFineDialog extends UIDialog {
} }
private void showResult(final AlphaCellModel selectedValue) { private void showResult(final AlphaCellModel selectedValue) {
if (selectedValue instanceof FileModel) { switch (selectedValue.getType()) {
case FILE:
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane(); showDefaultPreviewPane();
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) { if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
checkWorker(); checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() { this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override @Override
protected BufferedImage doInBackground() throws Exception { protected BufferedImage doInBackground() {
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); Form form = null;
try {
form = FormIO.readForm(FRContext.getCurrentEnv(), fileName);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
return FormIO.exportFormAsImage(form); return FormIO.exportFormAsImage(form);
} }
@ -448,8 +454,13 @@ public class AlphaFineDialog extends UIDialog {
checkWorker(); checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() { this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override @Override
protected BufferedImage doInBackground() throws Exception { protected BufferedImage doInBackground() {
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName); WorkBook workBook = null;
try {
workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook); BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook);
return bufferedImage; return bufferedImage;
} }
@ -472,15 +483,22 @@ public class AlphaFineDialog extends UIDialog {
} }
}; };
this.showWorker.execute(); this.showWorker.execute();
} }
} else if (selectedValue instanceof DocumentModel) { break;
case ACTION:
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new ActionPreviewPane());
validate();
repaint();
break;
case DOCUMENT:
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
rightSearchResultPane.add(new DocumentPreviewPane(((DocumentModel) selectedValue).getName(), ((DocumentModel) selectedValue).getContent())); rightSearchResultPane.add(new DocumentPreviewPane((selectedValue).getName(), (selectedValue).getContent()));
validate(); validate();
repaint(); repaint();
} else if (selectedValue instanceof PluginModel) { break;
case PLUGIN:
case REUSE:
showDefaultPreviewPane(); showDefaultPreviewPane();
checkWorker(); checkWorker();
this.showWorker = new SwingWorker<Image, Void>() { this.showWorker = new SwingWorker<Image, Void>() {
@ -504,7 +522,7 @@ public class AlphaFineDialog extends UIDialog {
try { try {
if (!isCancelled()) { if (!isCancelled()) {
rightSearchResultPane.removeAll(); rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane(((PluginModel) selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice())); rightSearchResultPane.add(new PluginPreviewPane((selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate(); validate();
repaint(); repaint();
} }
@ -517,12 +535,10 @@ public class AlphaFineDialog extends UIDialog {
} }
}; };
this.showWorker.execute(); this.showWorker.execute();
break;
default:
return;
} else if (selectedValue instanceof ActionModel) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new ActionPreviewPane());
validate();
repaint();
} }
} }
@ -727,7 +743,7 @@ public class AlphaFineDialog extends UIDialog {
private SearchResult getMoreResult(MoreModel selectedValue) { private SearchResult getMoreResult(MoreModel selectedValue) {
SearchResult moreResult; SearchResult moreResult;
switch (selectedValue.getType()) { switch (selectedValue.getContentType()) {
case PLUGIN: case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult(); moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult();
break; break;

2
designer/src/com/fr/design/mainframe/alphafine/search/manager/ActionSearchManager.java

@ -20,7 +20,7 @@ import java.util.List;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class ActionSearchManager implements AlphaFineSearchProcessor { public class ActionSearchManager implements AlphaFineSearchProcessor {
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"), CellType.ACTION); private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Set"));
private static ActionSearchManager actionSearchManager = null; private static ActionSearchManager actionSearchManager = null;
private SearchResult filterModelList; private SearchResult filterModelList;
private SearchResult lessModelList; private SearchResult lessModelList;

2
designer/src/com/fr/design/mainframe/alphafine/search/manager/DocumentSearchManager.java

@ -19,7 +19,7 @@ import com.fr.stable.StringUtils;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class DocumentSearchManager implements AlphaFineSearchProcessor { public class DocumentSearchManager implements AlphaFineSearchProcessor {
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"), CellType.DOCUMENT); private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_COMMUNITY_HELP"));
private static DocumentSearchManager documentSearchManager = null; private static DocumentSearchManager documentSearchManager = null;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;

2
designer/src/com/fr/design/mainframe/alphafine/search/manager/FileSearchManager.java

@ -30,7 +30,7 @@ public class FileSearchManager implements AlphaFineSearchProcessor {
private static final String DS_NAME = "dsname=\""; private static final String DS_NAME = "dsname=\"";
private static final String FRM_PREFIX = "k:frm "; private static final String FRM_PREFIX = "k:frm ";
private static final String CPT_PREFIX = "k:cpt "; private static final String CPT_PREFIX = "k:cpt ";
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"), CellType.FILE); private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer_Templates"));
private static FileSearchManager fileSearchManager = null; private static FileSearchManager fileSearchManager = null;
private SearchResult filterModelList; private SearchResult filterModelList;
private SearchResult lessModelList; private SearchResult lessModelList;

2
designer/src/com/fr/design/mainframe/alphafine/search/manager/PluginSearchManager.java

@ -23,7 +23,7 @@ import java.net.URLEncoder;
* Created by XiaXiang on 2017/3/27. * Created by XiaXiang on 2017/3/27.
*/ */
public class PluginSearchManager implements AlphaFineSearchProcessor { public class PluginSearchManager implements AlphaFineSearchProcessor {
private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"), CellType.PLUGIN); private static final MoreModel TITLE_MODEL = new MoreModel(Inter.getLocText("FR-Designer-Plugin_Addon"));
private static PluginSearchManager pluginSearchManager = null; private static PluginSearchManager pluginSearchManager = null;
private SearchResult lessModelList; private SearchResult lessModelList;
private SearchResult moreModelList; private SearchResult moreModelList;

Loading…
Cancel
Save