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. 192
      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.
*/
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;

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 {
private boolean needMore;
private boolean isLoading;
private CellType contentType;
public MoreModel(String name, String content, boolean needMore, CellType type) {
super(name, content, type);
super(name, content, CellType.MORE);
this.needMore = needMore;
this.contentType = type;
}
public MoreModel(String name, CellType type) {
super(name, null, type);
public MoreModel(String name) {
super(name, null, CellType.MORE);
this.needMore = false;
}
@ -66,4 +68,12 @@ public class MoreModel extends AlphaCellModel {
public boolean isNeedToSendToServer() {
return false;
}
public CellType getContentType() {
return contentType;
}
public void setContentType(CellType contentType) {
this.contentType = contentType;
}
}

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

@ -414,115 +414,131 @@ public class AlphaFineDialog extends UIDialog {
}
private void showResult(final AlphaCellModel selectedValue) {
if (selectedValue instanceof FileModel) {
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane();
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName);
return FormIO.exportFormAsImage(form);
}
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
switch (selectedValue.getType()) {
case FILE:
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
showDefaultPreviewPane();
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() {
Form form = null;
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
} catch (InterruptedException e) {
form = FormIO.readForm(FRContext.getCurrentEnv(), fileName);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
}
return FormIO.exportFormAsImage(form);
}
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
validate();
repaint();
}
}
};
this.showWorker.execute();
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) {
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
@Override
protected BufferedImage doInBackground() {
WorkBook workBook = null;
try {
workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName);
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
validate();
repaint();
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook);
return bufferedImage;
}
}
};
this.showWorker.execute();
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) {
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
validate();
repaint();
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
}
};
this.showWorker.execute();
}
break;
case ACTION:
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new ActionPreviewPane());
validate();
repaint();
break;
case DOCUMENT:
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new DocumentPreviewPane((selectedValue).getName(), (selectedValue).getContent()));
validate();
repaint();
break;
case PLUGIN:
case REUSE:
showDefaultPreviewPane();
checkWorker();
this.showWorker = new SwingWorker<BufferedImage, Void>() {
this.showWorker = new SwingWorker<Image, Void>() {
@Override
protected BufferedImage doInBackground() throws Exception {
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName);
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook);
protected Image doInBackground() {
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) {
try {
bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png"));
} catch (IOException e1) {
FRLogger.getLogger().error(e.getMessage());
}
}
return bufferedImage;
}
@Override
protected void done() {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
try {
rightSearchResultPane.add(new FilePreviewPane(get()));
try {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane((selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
};
this.showWorker.execute();
break;
default:
return;
}
} else if (selectedValue instanceof DocumentModel) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new DocumentPreviewPane(((DocumentModel) selectedValue).getName(), ((DocumentModel) selectedValue).getContent()));
validate();
repaint();
} else if (selectedValue instanceof PluginModel) {
showDefaultPreviewPane();
checkWorker();
this.showWorker = new SwingWorker<Image, Void>() {
@Override
protected Image doInBackground() {
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new URL(((PluginModel) selectedValue).getImageUrl()));
} catch (IOException e) {
try {
bufferedImage = ImageIO.read(getClass().getResource("/com/fr/design/mainframe/alphafine/images/default_product.png"));
} catch (IOException e1) {
FRLogger.getLogger().error(e.getMessage());
}
}
return bufferedImage;
}
@Override
protected void done() {
try {
if (!isCancelled()) {
rightSearchResultPane.removeAll();
rightSearchResultPane.add(new PluginPreviewPane(((PluginModel) selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice()));
validate();
repaint();
}
} catch (InterruptedException e) {
FRLogger.getLogger().error(e.getMessage());
} catch (ExecutionException e) {
FRLogger.getLogger().error(e.getMessage());
}
}
};
this.showWorker.execute();
} 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) {
SearchResult moreResult;
switch (selectedValue.getType()) {
switch (selectedValue.getContentType()) {
case PLUGIN:
moreResult = PluginSearchManager.getPluginSearchManager().getMoreSearchResult();
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.
*/
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 SearchResult filterModelList;
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.
*/
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 SearchResult lessModelList;
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 FRM_PREFIX = "k:frm ";
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 SearchResult filterModelList;
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.
*/
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 SearchResult lessModelList;
private SearchResult moreModelList;

Loading…
Cancel
Save