|
|
@ -68,15 +68,19 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
private SearchListModel searchListModel; |
|
|
|
private SearchListModel searchListModel; |
|
|
|
private SwingWorker searchWorker; |
|
|
|
private SwingWorker searchWorker; |
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
private boolean foreOpen; |
|
|
|
private boolean forceOpen; |
|
|
|
|
|
|
|
|
|
|
|
public AlphaFineDialog(Frame parent, boolean foreOpen) { |
|
|
|
public AlphaFineDialog(Frame parent, boolean forceOpen) { |
|
|
|
super(parent); |
|
|
|
super(parent); |
|
|
|
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
initProperties(); |
|
|
|
initProperties(); |
|
|
|
initListener(); |
|
|
|
initListener(); |
|
|
|
initComponents(); |
|
|
|
initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 初始化全部组件 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initComponents() { |
|
|
|
private void initComponents() { |
|
|
|
searchTextField = new AlphaFineTextField("AlphaFine"); |
|
|
|
searchTextField = new AlphaFineTextField("AlphaFine"); |
|
|
|
searchTextField.setFont(AlphaFineConstants.GREATER_FONT); |
|
|
|
searchTextField.setFont(AlphaFineConstants.GREATER_FONT); |
|
|
@ -122,6 +126,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initProperties() { |
|
|
|
private void initProperties() { |
|
|
|
setUndecorated(true); |
|
|
|
setUndecorated(true); |
|
|
|
addComponentListener(new ComponentHandler()); |
|
|
|
addComponentListener(new ComponentHandler()); |
|
|
@ -129,6 +136,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
centerWindow(this); |
|
|
|
centerWindow(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置面板位置 |
|
|
|
|
|
|
|
* @param win |
|
|
|
|
|
|
|
*/ |
|
|
|
private void centerWindow(Window win) { |
|
|
|
private void centerWindow(Window win) { |
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
|
|
|
|
|
|
|
|
@ -144,6 +155,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
win.setLocation((screenSize.width - winSize.width ) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); |
|
|
|
win.setLocation((screenSize.width - winSize.width ) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 执行搜索,暂时字符要求超过两个才开始搜索 |
|
|
|
|
|
|
|
* @param text |
|
|
|
|
|
|
|
*/ |
|
|
|
private void doSearch(String text) { |
|
|
|
private void doSearch(String text) { |
|
|
|
if (text.length() < 2 || text.contains("'")) { |
|
|
|
if (text.length() < 2 || text.contains("'")) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -156,6 +171,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 移除搜索结果 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void removeSearchResult() { |
|
|
|
private void removeSearchResult() { |
|
|
|
if (searchResultPane != null) { |
|
|
|
if (searchResultPane != null) { |
|
|
|
remove(searchResultPane); |
|
|
|
remove(searchResultPane); |
|
|
@ -178,7 +196,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 展示搜索结果 |
|
|
|
|
|
|
|
* @param searchText |
|
|
|
|
|
|
|
*/ |
|
|
|
private void showSearchResult(String searchText) { |
|
|
|
private void showSearchResult(String searchText) { |
|
|
|
if (searchResultPane == null) { |
|
|
|
if (searchResultPane == null) { |
|
|
|
initSearchResultComponents(); |
|
|
|
initSearchResultComponents(); |
|
|
@ -187,6 +208,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
initSearchWorker(searchText); |
|
|
|
initSearchWorker(searchText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 初始化搜索面板 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initSearchResultComponents() { |
|
|
|
private void initSearchResultComponents() { |
|
|
|
searchResultList = new JList(); |
|
|
|
searchResultList = new JList(); |
|
|
|
searchResultPane = new JPanel(); |
|
|
|
searchResultPane = new JPanel(); |
|
|
@ -208,6 +232,10 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
setSize(AlphaFineConstants.FULL_SIZE); |
|
|
|
setSize(AlphaFineConstants.FULL_SIZE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 异步加载搜索结构 |
|
|
|
|
|
|
|
* @param searchText |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initSearchWorker(final String searchText) { |
|
|
|
private void initSearchWorker(final String searchText) { |
|
|
|
searchResultList.setModel(new SearchListModel(AlphaSearchManager.getSearchManager().showDefaultSearchResult())); |
|
|
|
searchResultList.setModel(new SearchListModel(AlphaSearchManager.getSearchManager().showDefaultSearchResult())); |
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
@ -230,6 +258,13 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
searchResultList.repaint(); |
|
|
|
searchResultList.repaint(); |
|
|
|
validate(); |
|
|
|
validate(); |
|
|
|
repaint(); |
|
|
|
repaint(); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 默认选中第1项,第0项为title |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (searchResultList.getModel().getSize() > 0) { |
|
|
|
|
|
|
|
searchResultList.setSelectedIndex(1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (InterruptedException e) { |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
|
FRLogger.getLogger().error(e.getMessage()); |
|
|
@ -243,7 +278,14 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
this.searchWorker.execute(); |
|
|
|
this.searchWorker.execute(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 初始化监听器 |
|
|
|
|
|
|
|
* @param searchText |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initListListener(final String searchText) { |
|
|
|
private void initListListener(final String searchText) { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 鼠标监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
searchResultList.addMouseListener(new MouseAdapter() { |
|
|
|
searchResultList.addMouseListener(new MouseAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
@ -262,7 +304,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: 2017/5/8 xiaxiang: e.getClickCount() == 1 时,偶发性的不能触发,所以先放到valueChanged
|
|
|
|
/** |
|
|
|
|
|
|
|
*单击时触发右侧面板展示搜索结果 |
|
|
|
|
|
|
|
*/ |
|
|
|
searchResultList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
searchResultList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
|
public void valueChanged(ListSelectionEvent e) { |
|
|
@ -273,6 +317,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 键盘监听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
searchResultList.addKeyListener(new KeyAdapter() { |
|
|
|
searchResultList.addKeyListener(new KeyAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
@ -435,6 +482,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 窗口拖拽 |
|
|
|
|
|
|
|
*/ |
|
|
|
private void initMouseListener() { |
|
|
|
private void initMouseListener() { |
|
|
|
addMouseMotionListener(new MouseMotionAdapter() { |
|
|
|
addMouseMotionListener(new MouseMotionAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -487,9 +537,9 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
Point p = k.getLocationOnScreen(); |
|
|
|
Point p = k.getLocationOnScreen(); |
|
|
|
Rectangle dialogRectangle = AlphaFineDialog.this.getBounds(); |
|
|
|
Rectangle dialogRectangle = AlphaFineDialog.this.getBounds(); |
|
|
|
Rectangle paneRectangle = new Rectangle(AlphaFinePane.createAlphaFinePane().getLocationOnScreen(), AlphaFinePane.createAlphaFinePane().getSize()); |
|
|
|
Rectangle paneRectangle = new Rectangle(AlphaFinePane.createAlphaFinePane().getLocationOnScreen(), AlphaFinePane.createAlphaFinePane().getSize()); |
|
|
|
if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !foreOpen) { |
|
|
|
if (!dialogRectangle.contains(p) && !paneRectangle.contains(p) && !forceOpen) { |
|
|
|
AlphaFineDialog.this.dispose(); |
|
|
|
AlphaFineDialog.this.dispose(); |
|
|
|
foreOpen = false; |
|
|
|
forceOpen = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -604,15 +654,20 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 点击显示更多时,添加对应的model到list;点击收起是移除model |
|
|
|
|
|
|
|
* @param index |
|
|
|
|
|
|
|
* @param selectedValue |
|
|
|
|
|
|
|
*/ |
|
|
|
private void rebuildShowMoreList(int index, MoreModel selectedValue) { |
|
|
|
private void rebuildShowMoreList(int index, MoreModel selectedValue) { |
|
|
|
SearchResult moreResult = getMoreResult(selectedValue); |
|
|
|
SearchResult moreResult = getMoreResult(selectedValue); |
|
|
|
if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { |
|
|
|
if((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { |
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
this.searchListModel.insertElementAt(moreResult.get(i), index + AlphaFineConstants.SHOW_SIZE -1 + i); |
|
|
|
this.searchListModel.insertElementAt(moreResult.get(i), index + AlphaFineConstants.SHOW_SIZE + 1 + i); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
this.searchListModel.removeElementAt(index + AlphaFineConstants.SHOW_SIZE - 1); |
|
|
|
this.searchListModel.removeElementAt(index + AlphaFineConstants.SHOW_SIZE + 1); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -669,11 +724,11 @@ public class AlphaFineDialog extends UIDialog { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isForeOpen() { |
|
|
|
public boolean isForceOpen() { |
|
|
|
return foreOpen; |
|
|
|
return forceOpen; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setForeOpen(boolean foreOpen) { |
|
|
|
public void setForceOpen(boolean forceOpen) { |
|
|
|
this.foreOpen = foreOpen; |
|
|
|
this.forceOpen = forceOpen; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |