|
|
@ -6,23 +6,22 @@ import com.fr.design.dialog.UIDialog; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.CellModelHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.CellModelHelper; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.model.*; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.alphafine.cell.model.FileModel; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.alphafine.cell.model.MoreModel; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.alphafine.cell.model.PluginModel; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; |
|
|
|
import com.fr.design.mainframe.alphafine.cell.render.ContentCellRender; |
|
|
|
import com.fr.design.mainframe.alphafine.listener.ComponentHandler; |
|
|
|
import com.fr.design.mainframe.alphafine.listener.ComponentHandler; |
|
|
|
import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; |
|
|
|
import com.fr.design.mainframe.alphafine.listener.DocumentAdapter; |
|
|
|
import com.fr.design.mainframe.alphafine.model.SearchListModel; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.alphafine.model.SearchResult; |
|
|
|
import com.fr.design.mainframe.alphafine.model.SearchResult; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.ActionPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.ActionPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.DocumentPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.FilePreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.preview.PluginPreviewPane; |
|
|
|
import com.fr.design.mainframe.alphafine.search.manager.*; |
|
|
|
import com.fr.design.mainframe.alphafine.search.manager.*; |
|
|
|
import com.fr.file.FileNodeFILE; |
|
|
|
|
|
|
|
import com.fr.file.filetree.FileNode; |
|
|
|
|
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.Form; |
|
|
|
import com.fr.form.main.FormIO; |
|
|
|
import com.fr.form.main.FormIO; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
@ -47,8 +46,6 @@ import java.awt.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
@ -79,10 +76,11 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
private Point pressedPoint; |
|
|
|
private Point pressedPoint; |
|
|
|
private UIScrollPane leftSearchResultPane; |
|
|
|
private UIScrollPane leftSearchResultPane; |
|
|
|
private JPanel rightSearchResultPane; |
|
|
|
private JPanel rightSearchResultPane; |
|
|
|
private JList searchResultList; |
|
|
|
private AlphaFineList searchResultList; |
|
|
|
private SearchListModel searchListModel; |
|
|
|
private SearchListModel searchListModel; |
|
|
|
private SwingWorker searchWorker; |
|
|
|
private SwingWorker searchWorker; |
|
|
|
private SwingWorker showWorker; |
|
|
|
private SwingWorker showWorker; |
|
|
|
|
|
|
|
private String storeText; |
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
private boolean forceOpen; |
|
|
|
private boolean forceOpen; |
|
|
|
|
|
|
|
|
|
|
@ -118,6 +116,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 打开搜索框 |
|
|
|
|
|
|
|
*/ |
|
|
|
private static void doClickAction() { |
|
|
|
private static void doClickAction() { |
|
|
|
AlphaFineHelper.showAlphaFineDialog(false); |
|
|
|
AlphaFineHelper.showAlphaFineDialog(false); |
|
|
|
} |
|
|
|
} |
|
|
@ -248,7 +249,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
private void showSearchResult() { |
|
|
|
private void showSearchResult() { |
|
|
|
if (searchResultPane == null) { |
|
|
|
if (searchResultPane == null) { |
|
|
|
initSearchResultComponents(); |
|
|
|
initSearchResultComponents(); |
|
|
|
initListListener(); |
|
|
|
initTextFieldKeyListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
initSearchWorker(); |
|
|
|
initSearchWorker(); |
|
|
|
} |
|
|
|
} |
|
|
@ -257,7 +258,8 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
* 初始化搜索面板 |
|
|
|
* 初始化搜索面板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void initSearchResultComponents() { |
|
|
|
private void initSearchResultComponents() { |
|
|
|
searchResultList = new JList(); |
|
|
|
searchResultList = new AlphaFineList(); |
|
|
|
|
|
|
|
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT); |
|
|
|
searchListModel = new SearchListModel(new SearchResult()); |
|
|
|
searchListModel = new SearchListModel(new SearchResult()); |
|
|
|
searchResultList.setModel(searchListModel); |
|
|
|
searchResultList.setModel(searchListModel); |
|
|
|
searchResultPane = new JPanel(); |
|
|
|
searchResultPane = new JPanel(); |
|
|
@ -292,14 +294,6 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
rebuildList(searchTextField.getText().toLowerCase()); |
|
|
|
rebuildList(searchTextField.getText().toLowerCase()); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void done() { |
|
|
|
|
|
|
|
if (!isCancelled() && searchListModel.getSize() > 1) { |
|
|
|
|
|
|
|
searchResultList.setSelectedIndex(1); |
|
|
|
|
|
|
|
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
this.searchWorker.execute(); |
|
|
|
this.searchWorker.execute(); |
|
|
|
} |
|
|
|
} |
|
|
@ -311,27 +305,45 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
* @param searchText |
|
|
|
* @param searchText |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void rebuildList(String searchText) { |
|
|
|
private void rebuildList(String searchText) { |
|
|
|
searchListModel.removeAllElements(); |
|
|
|
resetContainer(); |
|
|
|
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) { |
|
|
|
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) { |
|
|
|
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { |
|
|
|
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { |
|
|
|
getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
|
|
|
getActionList(storeText); |
|
|
|
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { |
|
|
|
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { |
|
|
|
getDocumentList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
|
|
|
getDocumentList(storeText); |
|
|
|
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { |
|
|
|
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { |
|
|
|
getFileList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
|
|
|
getFileList(storeText); |
|
|
|
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { |
|
|
|
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { |
|
|
|
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
getFileList(searchText); |
|
|
|
getFileList(searchText); |
|
|
|
} else if (searchText.startsWith(DS_MARK)) { |
|
|
|
} else if (searchText.startsWith(DS_MARK)) { |
|
|
|
getFileList(DS_NAME + searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
|
|
|
getFileList(DS_NAME + storeText); |
|
|
|
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { |
|
|
|
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { |
|
|
|
getPluginList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
|
|
|
getPluginList(storeText); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
doNormalSearch(searchText.trim()); |
|
|
|
storeText = searchText.trim(); |
|
|
|
|
|
|
|
doNormalSearch(storeText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 重置面板 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void resetContainer() { |
|
|
|
|
|
|
|
searchListModel.removeAllElements(); |
|
|
|
|
|
|
|
searchListModel.resetSelectedState(); |
|
|
|
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
|
|
|
rightSearchResultPane.validate(); |
|
|
|
|
|
|
|
rightSearchResultPane.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 普通搜索 |
|
|
|
* 普通搜索 |
|
|
|
* |
|
|
|
* |
|
|
@ -348,7 +360,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getDocumentList(final String searchText) { |
|
|
|
private void getDocumentList(final String searchText) { |
|
|
|
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); |
|
|
|
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); |
|
|
|
for (Object object : documentModelList) { |
|
|
|
for (AlphaCellModel object : documentModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
@ -356,7 +368,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getFileList(final String searchText) { |
|
|
|
private void getFileList(final String searchText) { |
|
|
|
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); |
|
|
|
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); |
|
|
|
for (Object object : fileModelList) { |
|
|
|
for (AlphaCellModel object : fileModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
@ -364,7 +376,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getActionList(final String searchText) { |
|
|
|
private void getActionList(final String searchText) { |
|
|
|
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); |
|
|
|
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); |
|
|
|
for (Object object : actionModelList) { |
|
|
|
for (AlphaCellModel object : actionModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
@ -372,7 +384,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getPluginList(final String searchText) { |
|
|
|
private void getPluginList(final String searchText) { |
|
|
|
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); |
|
|
|
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); |
|
|
|
for (Object object : pluginModelList) { |
|
|
|
for (AlphaCellModel object : pluginModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
@ -380,7 +392,7 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getRecommendList(final String searchText) { |
|
|
|
private void getRecommendList(final String searchText) { |
|
|
|
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); |
|
|
|
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); |
|
|
|
for (Object object : recommendModelList) { |
|
|
|
for (AlphaCellModel object : recommendModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
@ -388,123 +400,144 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
private void getRecentList(final String searchText) { |
|
|
|
private void getRecentList(final String searchText) { |
|
|
|
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); |
|
|
|
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); |
|
|
|
for (Object object : recentModelList) { |
|
|
|
for (AlphaCellModel object : recentModelList) { |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
searchListModel.addElement(object); |
|
|
|
searchListModel.addElement(object); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void showResult(int index, final Object selectedValue) { |
|
|
|
/** |
|
|
|
if (selectedValue instanceof FileModel) { |
|
|
|
* 右侧面板展示搜索结果的内容 |
|
|
|
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); |
|
|
|
* |
|
|
|
showDefaultPreviewPane(); |
|
|
|
* @param selectedValue |
|
|
|
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) { |
|
|
|
*/ |
|
|
|
checkWorker(); |
|
|
|
private void showResult(final AlphaCellModel selectedValue) { |
|
|
|
this.showWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
switch (selectedValue.getType()) { |
|
|
|
@Override |
|
|
|
case FILE: |
|
|
|
protected BufferedImage doInBackground() throws Exception { |
|
|
|
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); |
|
|
|
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); |
|
|
|
showDefaultPreviewPane(); |
|
|
|
return FormIO.exportFormAsImage(form); |
|
|
|
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) { |
|
|
|
} |
|
|
|
checkWorker(); |
|
|
|
|
|
|
|
this.showWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void done() { |
|
|
|
protected BufferedImage doInBackground() { |
|
|
|
if (!isCancelled()) { |
|
|
|
Form form = null; |
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
rightSearchResultPane.add(new FilePreviewPane(get())); |
|
|
|
form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
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()); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
validate(); |
|
|
|
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook); |
|
|
|
repaint(); |
|
|
|
return bufferedImage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
}; |
|
|
|
protected void done() { |
|
|
|
this.showWorker.execute(); |
|
|
|
if (!isCancelled()) { |
|
|
|
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) { |
|
|
|
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(); |
|
|
|
checkWorker(); |
|
|
|
this.showWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
this.showWorker = new SwingWorker<Image, Void>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected BufferedImage doInBackground() throws Exception { |
|
|
|
protected Image doInBackground() { |
|
|
|
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName); |
|
|
|
BufferedImage bufferedImage = null; |
|
|
|
BufferedImage bufferedImage = new ImageExporter().exportToImage(workBook); |
|
|
|
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; |
|
|
|
return bufferedImage; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void done() { |
|
|
|
protected void done() { |
|
|
|
if (!isCancelled()) { |
|
|
|
try { |
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
if (!isCancelled()) { |
|
|
|
try { |
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
rightSearchResultPane.add(new FilePreviewPane(get())); |
|
|
|
rightSearchResultPane.add(new PluginPreviewPane((selectedValue).getName(), get(), ((PluginModel) selectedValue).getVersion(), ((PluginModel) selectedValue).getJartime(), ((PluginModel) selectedValue).getType(), ((PluginModel) selectedValue).getPrice())); |
|
|
|
validate(); |
|
|
|
validate(); |
|
|
|
repaint(); |
|
|
|
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(); |
|
|
|
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(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -547,73 +580,16 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
initMouseListener(); |
|
|
|
initMouseListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
private void initTextFieldKeyListener() { |
|
|
|
* 为面板中各组件添加监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void initListListener() { |
|
|
|
|
|
|
|
initListMouseListener(); |
|
|
|
|
|
|
|
initListKeyListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initListKeyListener() { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 为list添加键盘监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
searchResultList.addKeyListener(new KeyAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
|
|
|
|
Object selectedValue = searchResultList.getSelectedValue(); |
|
|
|
|
|
|
|
doNavigate(searchResultList.getSelectedIndex()); |
|
|
|
|
|
|
|
if (searchResultList.getSelectedValue() instanceof AlphaCellModel) { |
|
|
|
|
|
|
|
saveHistory((AlphaCellModel) selectedValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 为textField添加键盘监听器,按上下方向键时把焦点给list,实现键盘操作 |
|
|
|
* 为textField添加键盘监听器,按上下方向键时把焦点给list,实现键盘操作 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
searchTextField.addKeyListener(new KeyAdapter() { |
|
|
|
searchTextField.addKeyListener(new KeyAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_DOWN && searchTextField.hasFocus()) { |
|
|
|
searchResultList.requestFocus(); |
|
|
|
searchResultList.requestFocus(); |
|
|
|
} |
|
|
|
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initListMouseListener() { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 鼠标监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
searchResultList.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
int selectedIndex = searchResultList.getSelectedIndex(); |
|
|
|
|
|
|
|
Object selectedValue = searchResultList.getSelectedValue(); |
|
|
|
|
|
|
|
if (e.getClickCount() == 2) { |
|
|
|
|
|
|
|
doNavigate(selectedIndex); |
|
|
|
|
|
|
|
if (selectedValue instanceof AlphaCellModel) { |
|
|
|
|
|
|
|
saveHistory((AlphaCellModel) selectedValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (e.getClickCount() == 1) { |
|
|
|
|
|
|
|
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) { |
|
|
|
|
|
|
|
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
*单击时触发右侧面板展示搜索结果 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
searchResultList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
|
|
|
|
|
if (!e.getValueIsAdjusting()) { |
|
|
|
|
|
|
|
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -689,34 +665,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void doNavigate(int index) { |
|
|
|
private void doNavigate() { |
|
|
|
AlphaFineDialog.this.dispose(); |
|
|
|
AlphaFineDialog.this.dispose(); |
|
|
|
final Object value = searchResultList.getSelectedValue(); |
|
|
|
final AlphaCellModel model = searchResultList.getSelectedValue(); |
|
|
|
if (value instanceof ActionModel) { |
|
|
|
model.doAction(); |
|
|
|
((ActionModel) value).getAction().actionPerformed(null); |
|
|
|
|
|
|
|
} else if (value instanceof FileModel) { |
|
|
|
|
|
|
|
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(((FileModel) value).getFilePath(), false))); |
|
|
|
|
|
|
|
} else if (value instanceof PluginModel) { |
|
|
|
|
|
|
|
String url = ((PluginModel) value).getPluginUrl(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Desktop.getDesktop().browse(new URI(url)); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} catch (URISyntaxException e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (value instanceof DocumentModel) { |
|
|
|
|
|
|
|
String url = ((DocumentModel) value).getDocumentUrl(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Desktop.getDesktop().browse(new URI(url)); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (URISyntaxException e) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -725,11 +677,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
* @param cellModel |
|
|
|
* @param cellModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void saveHistory(AlphaCellModel cellModel) { |
|
|
|
private void saveHistory(AlphaCellModel cellModel) { |
|
|
|
String searchText = searchTextField.getText(); |
|
|
|
|
|
|
|
RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger(); |
|
|
|
RecentSearchManager recentSearchManager = RecentSearchManager.getRecentSearchManger(); |
|
|
|
recentSearchManager.addRecentModel(searchText, cellModel); |
|
|
|
recentSearchManager.addRecentModel(storeText, cellModel); |
|
|
|
recentSearchManager.saveXMLFile(); |
|
|
|
recentSearchManager.saveXMLFile(); |
|
|
|
sendToServer(searchText, cellModel); |
|
|
|
sendToServer(storeText, cellModel); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -740,30 +691,33 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
* @param cellModel |
|
|
|
* @param cellModel |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void sendToServer(String searchKey, AlphaCellModel cellModel) { |
|
|
|
private void sendToServer(String searchKey, AlphaCellModel cellModel) { |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
if (cellModel.isNeedToSendToServer()) { |
|
|
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
|
|
|
String username = DesignerEnvManager.getEnvManager().getBBSName(); |
|
|
|
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); |
|
|
|
String uuid = DesignerEnvManager.getEnvManager().getUUID(); |
|
|
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); |
|
|
|
String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); |
|
|
|
String key = searchKey; |
|
|
|
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); |
|
|
|
int resultkind = cellModel.getType().getTypeValue(); |
|
|
|
String key = searchKey; |
|
|
|
String resultValue = CellModelHelper.getResultValueFromModel(cellModel); |
|
|
|
int resultKind = cellModel.getType().getTypeValue(); |
|
|
|
JSONObject object = JSONObject.create(); |
|
|
|
String resultValue = CellModelHelper.getResultValueFromModel(cellModel); |
|
|
|
try { |
|
|
|
JSONObject object = JSONObject.create(); |
|
|
|
object.put("uuid", uuid).put("activitykey", activitykey).put("username", username).put("createtime", createTime).put("key", key).put("resultkind", resultkind).put("resultValue", resultValue); |
|
|
|
try { |
|
|
|
} catch (JSONException e) { |
|
|
|
object.put("uuid", uuid).put("activityKey", activityKey).put("username", username).put("createTime", createTime).put("key", key).put("resultKind", resultKind).put("resultValue", resultValue); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
} catch (JSONException e) { |
|
|
|
} |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
HashMap<String, String> para = new HashMap<>(); |
|
|
|
} |
|
|
|
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
final HashMap<String, String> para = new HashMap<>(); |
|
|
|
para.put("token", CodeUtils.md5Encode(date, "", "MD5")); |
|
|
|
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); |
|
|
|
para.put("content", object.toString()); |
|
|
|
para.put("token", CodeUtils.md5Encode(date, "", "MD5")); |
|
|
|
HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_TEST_URL, para, true); |
|
|
|
para.put("content", object.toString()); |
|
|
|
httpClient.setTimeout(5000); |
|
|
|
HttpClient httpClient = new HttpClient(AlphaFineConstants.CLOUD_SERVER_URL, para, true); |
|
|
|
httpClient.asGet(); |
|
|
|
httpClient.setTimeout(5000); |
|
|
|
if (!httpClient.isServerAlive()) { |
|
|
|
httpClient.asGet(); |
|
|
|
FRLogger.getLogger().error("Failed to sent data to server!"); |
|
|
|
if (!httpClient.isServerAlive()) { |
|
|
|
|
|
|
|
FRLogger.getLogger().error("Failed to sent data to server!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -784,23 +738,11 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.searchResultList.validate(); |
|
|
|
|
|
|
|
this.searchResultList.repaint(); |
|
|
|
|
|
|
|
validate(); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void rebuildList() { |
|
|
|
|
|
|
|
this.searchResultList.validate(); |
|
|
|
|
|
|
|
this.searchResultList.repaint(); |
|
|
|
|
|
|
|
validate(); |
|
|
|
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
@ -845,4 +787,190 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
this.forceOpen = forceOpen; |
|
|
|
this.forceOpen = forceOpen; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getStoreText() { |
|
|
|
|
|
|
|
return storeText; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setStoreText(String storeText) { |
|
|
|
|
|
|
|
this.storeText = storeText; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* +-------------------------------------+ |
|
|
|
|
|
|
|
* | 自定义JList | |
|
|
|
|
|
|
|
* +-------------------------------------+ |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private class AlphaFineList extends JList<AlphaCellModel> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AlphaFineList() { |
|
|
|
|
|
|
|
initListListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 重写选中的方法 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param index |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void setSelectedIndex(int index) { |
|
|
|
|
|
|
|
if (index > 0 && checkSelectedIndex(index)) { |
|
|
|
|
|
|
|
int previousIndex = getSelectedIndex(); |
|
|
|
|
|
|
|
super.setSelectedIndex(index); |
|
|
|
|
|
|
|
AlphaCellModel cellModel = getSelectedValue(); |
|
|
|
|
|
|
|
if (cellModel != null && !cellModel.hasAction()) { |
|
|
|
|
|
|
|
if (previousIndex <= getSelectedIndex()) { |
|
|
|
|
|
|
|
setSelectedIndex(index + 1); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setSelectedIndex(index - 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ensureIndexIsVisible(getSelectedIndex()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean checkSelectedIndex(int index) { |
|
|
|
|
|
|
|
int size = getModel().getSize(); |
|
|
|
|
|
|
|
return size > 0 && index < size; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initListListener() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 为list添加键盘监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
addKeyListener(new KeyAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
|
|
|
|
doNavigate(); |
|
|
|
|
|
|
|
saveHistory(getSelectedValue()); |
|
|
|
|
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_UP) { |
|
|
|
|
|
|
|
if (getSelectedIndex() == 1) { |
|
|
|
|
|
|
|
searchTextField.requestFocus(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 为list添加鼠标监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
int selectedIndex = getSelectedIndex(); |
|
|
|
|
|
|
|
AlphaCellModel selectedValue = getSelectedValue(); |
|
|
|
|
|
|
|
if (e.getClickCount() == 2 && selectedValue.hasAction()) { |
|
|
|
|
|
|
|
doNavigate(); |
|
|
|
|
|
|
|
saveHistory(selectedValue); |
|
|
|
|
|
|
|
} else if (e.getClickCount() == 1) { |
|
|
|
|
|
|
|
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) { |
|
|
|
|
|
|
|
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
*单击时触发右侧面板展示搜索结果 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
addListSelectionListener(new ListSelectionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
|
|
|
|
|
if (!e.getValueIsAdjusting() && getSelectedValue() != null) { |
|
|
|
|
|
|
|
showResult(getSelectedValue()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* +-------------------------------------+ |
|
|
|
|
|
|
|
* | 自定义ListModel | |
|
|
|
|
|
|
|
* +-------------------------------------+ |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private class SearchListModel extends DefaultListModel<AlphaCellModel> { |
|
|
|
|
|
|
|
SearchResult myDelegate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 第一有效的项是否被选中 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean isValidSelected; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public SearchListModel(SearchResult searchResult) { |
|
|
|
|
|
|
|
this.myDelegate = searchResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void addElement(AlphaCellModel element) { |
|
|
|
|
|
|
|
int index = myDelegate.size(); |
|
|
|
|
|
|
|
myDelegate.add(element); |
|
|
|
|
|
|
|
fireContentsChanged(this, index, index); |
|
|
|
|
|
|
|
fireSelectedStateChanged(element, index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 触发选中第一有效的项 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param element |
|
|
|
|
|
|
|
* @param index |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void fireSelectedStateChanged(AlphaCellModel element, int index) { |
|
|
|
|
|
|
|
if (element.hasAction() && !isValidSelected()) { |
|
|
|
|
|
|
|
searchResultList.setSelectedIndex(index); |
|
|
|
|
|
|
|
setValidSelected(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public AlphaCellModel getElementAt(int index) { |
|
|
|
|
|
|
|
return myDelegate.get(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void add(int index, AlphaCellModel element) { |
|
|
|
|
|
|
|
myDelegate.add(index, element); |
|
|
|
|
|
|
|
fireIntervalAdded(this, index, index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public AlphaCellModel remove(int index) { |
|
|
|
|
|
|
|
AlphaCellModel object = myDelegate.get(index); |
|
|
|
|
|
|
|
myDelegate.remove(object); |
|
|
|
|
|
|
|
fireIntervalRemoved(this, index, index); |
|
|
|
|
|
|
|
return object; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public int getSize() { |
|
|
|
|
|
|
|
return this.myDelegate.size(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void removeAllElements() { |
|
|
|
|
|
|
|
this.myDelegate.clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 重置选中状态 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void resetSelectedState() { |
|
|
|
|
|
|
|
setValidSelected(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isValidSelected() { |
|
|
|
|
|
|
|
return isValidSelected; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setValidSelected(boolean selected) { |
|
|
|
|
|
|
|
isValidSelected = selected; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |