|
|
|
@ -71,6 +71,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
private static final String PLUGIN_MARK_SHORT = "k:4 "; |
|
|
|
|
private static final String PLUGIN_MARK = "k:shop "; |
|
|
|
|
private static final String PLACE_HOLDER = Inter.getLocText("FR-Designer_AlphaFine"); |
|
|
|
|
private static final int MAX_SHOW_SIZE = 12; |
|
|
|
|
|
|
|
|
|
private AlphaFineTextField searchTextField; |
|
|
|
|
private UIButton closeButton; |
|
|
|
@ -89,7 +90,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
|
private boolean forceOpen; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AlphaFineDialog(Frame parent, boolean forceOpen) { |
|
|
|
|
super(parent); |
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
@ -161,12 +161,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
}); |
|
|
|
|
topPane.add(closeButton, BorderLayout.EAST); |
|
|
|
|
add(topPane, BorderLayout.CENTER); |
|
|
|
|
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { |
|
|
|
|
@Override |
|
|
|
|
protected void textChanged(DocumentEvent e) { |
|
|
|
|
doSearch(searchTextField.getText()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -174,7 +168,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
*/ |
|
|
|
|
private void initSearchTextField() { |
|
|
|
|
searchTextField = new AlphaFineTextField(PLACE_HOLDER); |
|
|
|
|
initTextFieldKeyListener(); |
|
|
|
|
initTextFieldListener(); |
|
|
|
|
searchTextField.setFont(AlphaFineConstants.GREATER_FONT); |
|
|
|
|
searchTextField.setBackground(Color.WHITE); |
|
|
|
|
searchTextField.setBorderPainted(false); |
|
|
|
@ -228,16 +222,11 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param text |
|
|
|
|
*/ |
|
|
|
|
private void doSearch(String text) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(text) || isNeedSearch(text)) { |
|
|
|
|
removeSearchResult(); |
|
|
|
|
} else { |
|
|
|
|
showSearchResult(); |
|
|
|
|
} |
|
|
|
|
showSearchResult(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
boolean isNeedSearch(String text) { |
|
|
|
|
return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'"); |
|
|
|
|
boolean isNoNeedSearch(String text) { |
|
|
|
|
return ComparatorUtils.equals(PLACE_HOLDER, text) || text.contains("'") || StringUtils.isBlank(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -272,17 +261,17 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
searchResultPane = null; |
|
|
|
|
} |
|
|
|
|
setSize(AlphaFineConstants.FIELD_SIZE); |
|
|
|
|
repaint(); |
|
|
|
|
refreshContainer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 展示搜索结果 |
|
|
|
|
*/ |
|
|
|
|
private void showSearchResult() { |
|
|
|
|
private void showSearchResult(String text) { |
|
|
|
|
if (searchResultPane == null) { |
|
|
|
|
initSearchResultComponents(); |
|
|
|
|
} |
|
|
|
|
initSearchWorker(); |
|
|
|
|
initSearchWorker(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -299,8 +288,8 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
searchResultList.setCellRenderer(new ContentCellRender()); |
|
|
|
|
|
|
|
|
|
leftSearchResultPane = new UIScrollPane(searchResultList); |
|
|
|
|
leftSearchResultPane.setBorder(null); |
|
|
|
|
leftSearchResultPane.setBackground(Color.WHITE); |
|
|
|
|
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
|
|
|
leftSearchResultPane.setPreferredSize(new Dimension(AlphaFineConstants.LEFT_WIDTH, AlphaFineConstants.CONTENT_HEIGHT)); |
|
|
|
|
rightSearchResultPane = new JPanel(); |
|
|
|
|
rightSearchResultPane.setBackground(Color.WHITE); |
|
|
|
@ -317,7 +306,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
/** |
|
|
|
|
* 异步加载搜索结果 |
|
|
|
|
*/ |
|
|
|
|
private void initSearchWorker() { |
|
|
|
|
private void initSearchWorker(final String text) { |
|
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
|
|
this.searchWorker.cancel(true); |
|
|
|
|
this.searchWorker = null; |
|
|
|
@ -325,9 +314,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
this.searchWorker = new SwingWorker() { |
|
|
|
|
@Override |
|
|
|
|
protected Object doInBackground() throws Exception { |
|
|
|
|
resumeLeftPane(); |
|
|
|
|
splitLabel.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigloading.gif"))); |
|
|
|
|
rebuildList(searchTextField.getText().toLowerCase()); |
|
|
|
|
rebuildList(text); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -347,11 +334,9 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
*/ |
|
|
|
|
private void resumeLeftPane() { |
|
|
|
|
if (searchResultPane != null && defaultPane != null) { |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
searchResultPane.remove(defaultPane); |
|
|
|
|
defaultPane = null; |
|
|
|
|
searchResultPane.add(leftSearchResultPane, BorderLayout.WEST); |
|
|
|
|
refreshContainer(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -394,25 +379,26 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
*/ |
|
|
|
|
private void rebuildList(String searchText) { |
|
|
|
|
resetContainer(); |
|
|
|
|
|
|
|
|
|
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) { |
|
|
|
|
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getActionList(storeText); |
|
|
|
|
buildActionList(storeText); |
|
|
|
|
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getDocumentList(storeText); |
|
|
|
|
buildDocumentList(storeText); |
|
|
|
|
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getFileList(storeText); |
|
|
|
|
buildFileList(storeText); |
|
|
|
|
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getFileList(searchText); |
|
|
|
|
buildFileList(searchText); |
|
|
|
|
} else if (searchText.startsWith(DS_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getFileList(DS_NAME + storeText); |
|
|
|
|
buildFileList(DS_NAME + storeText); |
|
|
|
|
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { |
|
|
|
|
storeText = searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length()); |
|
|
|
|
getPluginList(storeText); |
|
|
|
|
buildPluginList(storeText); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
storeText = searchText.trim(); |
|
|
|
@ -425,9 +411,11 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* 重置面板 |
|
|
|
|
*/ |
|
|
|
|
private void resetContainer() { |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
splitLabel.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigloading.gif"))); |
|
|
|
|
resumeLeftPane(); |
|
|
|
|
searchListModel.removeAllElements(); |
|
|
|
|
searchListModel.resetSelectedState(); |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
refreshContainer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -437,23 +425,22 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param searchText |
|
|
|
|
*/ |
|
|
|
|
private void doNormalSearch(String searchText) { |
|
|
|
|
getRecentList(searchText); |
|
|
|
|
getRecommendList(searchText); |
|
|
|
|
getActionList(searchText); |
|
|
|
|
getFileList(searchText); |
|
|
|
|
getDocumentList(searchText); |
|
|
|
|
getPluginList(searchText); |
|
|
|
|
buildRecentList(searchText); |
|
|
|
|
buildRecommendList(searchText); |
|
|
|
|
buildActionList(searchText); |
|
|
|
|
buildFileList(searchText); |
|
|
|
|
buildDocumentList(searchText); |
|
|
|
|
buildPluginList(searchText); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getDocumentList(final String searchText) { |
|
|
|
|
private void buildDocumentList(final String searchText) { |
|
|
|
|
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : documentModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getFileList(final String searchText) { |
|
|
|
|
private void buildFileList(final String searchText) { |
|
|
|
|
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : fileModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
@ -461,34 +448,30 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getActionList(final String searchText) { |
|
|
|
|
private void buildActionList(final String searchText) { |
|
|
|
|
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : actionModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getPluginList(final String searchText) { |
|
|
|
|
private void buildPluginList(final String searchText) { |
|
|
|
|
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : pluginModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getRecommendList(final String searchText) { |
|
|
|
|
private void buildRecommendList(final String searchText) { |
|
|
|
|
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : recommendModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void getRecentList(final String searchText) { |
|
|
|
|
private void buildRecentList(final String searchText) { |
|
|
|
|
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); |
|
|
|
|
for (AlphaCellModel object : recentModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -639,11 +622,10 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) { |
|
|
|
|
if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) { |
|
|
|
|
private void dealWithMoreOrLessResult(int index, MoreModel selectedValue) { |
|
|
|
|
if (ComparatorUtils.equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"), selectedValue.getContent())) { |
|
|
|
|
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess")); |
|
|
|
|
rebuildShowMoreList(index, selectedValue); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowAll")); |
|
|
|
|
rebuildShowMoreList(index, selectedValue); |
|
|
|
@ -655,8 +637,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
UILabel label = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/opening.gif"))); |
|
|
|
|
label.setBorder(BorderFactory.createEmptyBorder(120, 0, 0, 0)); |
|
|
|
|
rightSearchResultPane.add(label, BorderLayout.CENTER); |
|
|
|
|
validate(); |
|
|
|
|
repaint(); |
|
|
|
|
refreshContainer(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -667,18 +648,15 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 为textfield添加键盘监听器 |
|
|
|
|
* 为textfield添加监听器 |
|
|
|
|
*/ |
|
|
|
|
private void initTextFieldKeyListener() { |
|
|
|
|
private void initTextFieldListener() { |
|
|
|
|
searchTextField.addKeyListener(new KeyAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_DOWN) { |
|
|
|
|
searchResultList.requestFocus(); |
|
|
|
|
searchResultList.setSelectedIndex(searchResultList.getSelectedIndex() + 1); |
|
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
|
doNavigate(); |
|
|
|
|
saveHistory(searchResultList.getSelectedValue()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -690,7 +668,25 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
AlphaFineDialog.this.setVisible(false); |
|
|
|
|
} else { |
|
|
|
|
searchTextField.setText(null); |
|
|
|
|
removeSearchResult(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { |
|
|
|
|
@Override |
|
|
|
|
protected void textChanged(DocumentEvent e) { |
|
|
|
|
if (isNoNeedSearch(searchTextField.getText())) { |
|
|
|
|
removeSearchResult(); |
|
|
|
|
} else { |
|
|
|
|
try { |
|
|
|
|
Thread.sleep(10); |
|
|
|
|
doSearch(searchTextField.getText()); |
|
|
|
|
} catch (InterruptedException e1) { |
|
|
|
|
FRLogger.getLogger().error(e1.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -726,7 +722,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void checkValid() throws Exception { |
|
|
|
|
|
|
|
|
|
//不处理
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void doNavigate() { |
|
|
|
@ -778,7 +774,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
if (!httpClient.isServerAlive()) { |
|
|
|
|
FRLogger.getLogger().error("Failed to sent data to server!"); |
|
|
|
|
} |
|
|
|
|
httpClient.setTimeout(5000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -935,7 +930,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
saveHistory(selectedValue); |
|
|
|
|
} else if (e.getClickCount() == 1) { |
|
|
|
|
if (selectedValue instanceof MoreModel && ((MoreModel) selectedValue).isNeedMore()) { |
|
|
|
|
HandleMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); |
|
|
|
|
dealWithMoreOrLessResult(selectedIndex, (MoreModel) selectedValue); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -971,10 +966,23 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void addElement(AlphaCellModel element) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
int index = myDelegate.size(); |
|
|
|
|
myDelegate.add(element); |
|
|
|
|
fireContentsChanged(this, index, index); |
|
|
|
|
fireSelectedStateChanged(element, index); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void fireContentsChanged(Object source, int index0, int index1) { |
|
|
|
|
if (myDelegate.size() > MAX_SHOW_SIZE) { |
|
|
|
|
leftSearchResultPane.getVerticalScrollBar().setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); |
|
|
|
|
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 2)); |
|
|
|
|
} else { |
|
|
|
|
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
|
|
|
} |
|
|
|
|
super.fireContentsChanged(source, index0, index1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|