xiaoxia 8 years ago
parent
commit
fecd0deb7d
  1. 28
      designer/src/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  2. 194
      designer/src/com/fr/design/mainframe/alphafine/xmlManager/RecentSearchManager.java
  3. 2
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  4. 3
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties

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

@ -19,6 +19,7 @@ import com.fr.design.mainframe.alphafine.previewPane.DocumentPreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.FilePreviewPane;
import com.fr.design.mainframe.alphafine.previewPane.PluginPreviewPane;
import com.fr.design.mainframe.alphafine.searchManager.*;
import com.fr.design.mainframe.alphafine.xmlManager.RecentSearchManager;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.form.main.Form;
@ -172,7 +173,7 @@ public class AlphaFineDialog extends UIDialog {
private void showSearchResult(String searchText) {
if (searchResultPane == null) {
initSearchResultComponents();
initListListener();
initListListener(searchText);
}
initSearchWorker(searchText);
}
@ -233,7 +234,7 @@ public class AlphaFineDialog extends UIDialog {
this.searchWorker.execute();
}
private void initListListener() {
private void initListListener(final String searchText) {
searchResultList.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@ -244,11 +245,7 @@ public class AlphaFineDialog extends UIDialog {
searchResultList.setSelectedIndex(i);
doNavigate(selectedIndex);
if (selectedValue instanceof AlphaCellModel) {
SearchResult originalResultList = LatestSearchManager.getLatestSearchManager().getLatestModelList();
originalResultList.add(searchResultList.getSelectedValue());
LatestSearchManager.getLatestSearchManager().setLatestModelList(originalResultList);
//保存最近搜索
saveHistory(originalResultList);
saveHistory(searchText, (AlphaCellModel) selectedValue);
}
} else if (e.getClickCount() == 1) {
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) {
@ -542,17 +539,14 @@ public class AlphaFineDialog extends UIDialog {
}
/**
* todo:保存到本地的逻辑待修改
* @param searchResult
* 保存本地本地常用
* @param searchText
* @param cellModel
*/
private void saveHistory(SearchResult searchResult) {
try {
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(AlphaFineHelper.getInfoFile()));
os.writeObject(searchResult);
os.close();
} catch (IOException e) {
FRLogger.getLogger().error(e.getMessage());
}
private void saveHistory(String searchText, AlphaCellModel cellModel) {
RecentSearchManager recentSearchManager = RecentSearchManager.getInstance();
recentSearchManager.getModelMap().put(cellModel.getName(), cellModel.getType().getCellType());
recentSearchManager.saveXMLFile();
sendToServer();

194
designer/src/com/fr/design/mainframe/alphafine/xmlManager/RecentSearchManager.java

@ -0,0 +1,194 @@
package com.fr.design.mainframe.alphafine.xmlManager;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.file.XMLFileManager;
import com.fr.general.IOUtils;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by XiaXiang on 2017/5/15.
*/
public class RecentSearchManager extends XMLFileManager {
private static final String XML_TAG = "AlphafineRecent";
private List<String> fileList;
private List<String> actionList;
private List<String> documentList;
private List<String> pluginList;
private Map<String, Integer> modelMap = new HashMap<>();
private static RecentSearchManager recentSearchManager = null;
public synchronized static RecentSearchManager getInstance() {
if (recentSearchManager == null) {
recentSearchManager = new RecentSearchManager();
}
try {
XMLTools.readFileXML(recentSearchManager, recentSearchManager.getRecentEnvFile());
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
return recentSearchManager;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
reader.readXMLObject(new XMLReadable() {
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String nodeName = reader.getTagName();
if (nodeName.equals("RecentModel")) {
modelMap.put(reader.getAttrAsString("name", StringUtils.EMPTY), reader.getAttrAsInt("celltype", 0));
}
}
}
});
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG);
if (!modelMap.isEmpty()) {
for (String name : modelMap.keySet()) {
writer.startTAG("RecentModel");
writer.attr("name", name);
writer.attr("celltype", modelMap.get(name));
writer.end();
}
}
writer.end();
}
@Override
public String fileName() {
return "alphafine_recent.xml";
}
public List<String> getFileList() {
return fileList;
}
public void setFileList(List<String> fileList) {
this.fileList = fileList;
}
public List<String> getActionList() {
return actionList;
}
public void setActionList(List<String> actionList) {
this.actionList = actionList;
}
public List<String> getDocumentList() {
return documentList;
}
public void setDocumentList(List<String> documentList) {
this.documentList = documentList;
}
public List<String> getPluginList() {
return pluginList;
}
public void setPluginList(List<String> pluginList) {
this.pluginList = pluginList;
}
public Map<String, Integer> getModelMap() {
return modelMap;
}
public void setModelMap(Map<String, Integer> modelMap) {
this.modelMap = modelMap;
}
private static File recentFile = null;
private File getRecentFile() {
if (recentFile == null) {
recentFile = new File(ProductConstants.getEnvHome() + File.separator + fileName());
}
return recentFile;
}
private File getRecentEnvFile() {
File envFile = getRecentFile();
if (!envFile.exists()) {
createRecentFile(envFile);
}
return envFile;
}
private void createRecentFile(File envFile) {
try {
FileWriter fileWriter = new FileWriter(envFile);
StringReader stringReader = new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><AlphafineRecent></AlphafineRecent>");
Utils.copyCharTo(stringReader, fileWriter);
stringReader.close();
fileWriter.close();
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 保存设计器的配置文件, 该文件不在env的resource目录下
* 而是在Consts.getEnvHome() + File.separator + Consts.APP_NAME
*
*
* @date 2014-9-29-上午11:04:23
*
*/
public void saveXMLFile() {
File xmlFile = this.getRecentEnvFile();
if (xmlFile == null) {
return;
}
if (!xmlFile.getParentFile().exists()) {//建立目录.
StableUtils.mkdirs(xmlFile.getParentFile());
}
String tempName = xmlFile.getName() + ProjectConstants.TEMP_SUFFIX;
File tempFile = new File(xmlFile.getParentFile(), tempName);
writeTempFile(tempFile);
IOUtils.renameTo(tempFile, xmlFile);
}
private void writeTempFile(File tempFile){
try{
OutputStream fout = new FileOutputStream(tempFile);
XMLTools.writeOutputStreamXML(this, fout);
fout.flush();
fout.close();
}catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
}
}

2
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -1997,7 +1997,7 @@ FR-Designer_AlphaFine_SearchRange=\u641C\u7D22\u8303\u56F4
FR-Designer-Plugin_Addon=\u5E94\u7528\u4E2D\u5FC3
FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5185\u5BB9
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
FR-Designer_AlphaFine_ShowAll=\u663E\u793A\u5168\u90E8
FR-Designer_AlphaFine_Conclude=\u731C\u60A8\u9700\u8981
FR-Designer_AlphaFine_Latest=\u6700\u8FD1\u5E38\u7528
FR-Designer_AlphaFine_ShowLess=\u6536\u8D77

3
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -1998,4 +1998,5 @@ FR-Designer_Templates=\u6A21\u677F
FR-Designer_Templates_Content=\u6A21\u677F\u5167\u5BB9
FR-Designer_AlphaFine_Latest=\u6700\u8FD1\u5E38\u7528
FR-Designer_AlphaFine_ShowLess=\u6536\u8D77
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_Alphafine=AlphaFine\u667A\u80FD\u641C\u7D22
FR-Designer_AlphaFine_ShowAll=\u986F\u793A\u5168\u90E8
Loading…
Cancel
Save