|
|
|
@ -27,7 +27,6 @@ import com.fr.form.main.Form;
|
|
|
|
|
import com.fr.form.main.FormIO; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.FRLogger; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.general.http.HttpClient; |
|
|
|
|
import com.fr.io.TemplateWorkBookIO; |
|
|
|
@ -60,29 +59,18 @@ import java.util.concurrent.ExecutionException;
|
|
|
|
|
* Created by XiaXiang on 2017/3/21. |
|
|
|
|
*/ |
|
|
|
|
public class AlphaFineDialog extends UIDialog { |
|
|
|
|
|
|
|
|
|
private static final String ADVANCED_SEARCH_MARK = "k:"; |
|
|
|
|
private static final String ACTION_MARK_SHORT = "k:1 "; |
|
|
|
|
|
|
|
|
|
private static final String ACTION_MARK = "k:setting "; |
|
|
|
|
|
|
|
|
|
private static final String DOCUMENT_MARK_SHORT = "k:2 "; |
|
|
|
|
|
|
|
|
|
private static final String DOCUMENT_MARK = "k:help "; |
|
|
|
|
|
|
|
|
|
private static final String FILE_MARK_SHORT = "k:3 "; |
|
|
|
|
|
|
|
|
|
private static final String FILE_MARK = "k:reportlets "; |
|
|
|
|
|
|
|
|
|
private static final String CPT_MARK = "k:cpt "; |
|
|
|
|
|
|
|
|
|
private static final String FRM_MARK = "k:frm "; |
|
|
|
|
|
|
|
|
|
private static final String DS_MARK = "k:ds "; |
|
|
|
|
|
|
|
|
|
private static final String DS_NAME = "dsname=\""; |
|
|
|
|
|
|
|
|
|
private static final String PLUGIN_MARK_SHORT = "k:4 "; |
|
|
|
|
|
|
|
|
|
private static final String PLUGIN_MARK = "k:shop "; |
|
|
|
|
|
|
|
|
|
private AlphaFineTextField searchTextField; |
|
|
|
@ -94,30 +82,29 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
private JList searchResultList; |
|
|
|
|
private SearchListModel searchListModel; |
|
|
|
|
private SwingWorker searchWorker; |
|
|
|
|
private SwingWorker showWorker; |
|
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
|
private boolean forceOpen; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AlphaFineDialog(Frame parent, boolean forceOpen) { |
|
|
|
|
super(parent); |
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
|
initProperties(); |
|
|
|
|
initListener(); |
|
|
|
|
initGlobalListener(); |
|
|
|
|
initComponents(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 全局快捷键 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static AWTEventListener listener() { |
|
|
|
|
|
|
|
|
|
return new AWTEventListener() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void eventDispatched(AWTEvent event) { |
|
|
|
|
|
|
|
|
|
if (event instanceof KeyEvent) { |
|
|
|
|
KeyEvent e = (KeyEvent) event; |
|
|
|
|
KeyStroke keyStroke = (KeyStroke) KeyStroke.getAWTKeyStrokeForEvent(e); |
|
|
|
@ -125,39 +112,35 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
if (ComparatorUtils.equals(keyStroke.toString(), storeKeyStroke.toString()) && AlphaFinePane.getAlphaFinePane().isVisible()) { |
|
|
|
|
doClickAction(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void doClickAction() { |
|
|
|
|
|
|
|
|
|
AlphaFineHelper.showAlphaFineDialog(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化全部组件 |
|
|
|
|
*/ |
|
|
|
|
private void initComponents() { |
|
|
|
|
|
|
|
|
|
searchTextField = new AlphaFineTextField("AlphaFine"); |
|
|
|
|
searchTextField.setFont(AlphaFineConstants.GREATER_FONT); |
|
|
|
|
searchTextField.setBackground(Color.white); |
|
|
|
|
searchTextField.setBorderPainted(false); |
|
|
|
|
searchTextField.initKeyListener(this); |
|
|
|
|
JPanel topPane = new JPanel(new BorderLayout()); |
|
|
|
|
UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/bigsearch.png")); |
|
|
|
|
UILabel iconLabel = new UILabel(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/bigsearch.png"))); |
|
|
|
|
iconLabel.setPreferredSize(AlphaFineConstants.ICON_LABEL_SIZE); |
|
|
|
|
iconLabel.setOpaque(true); |
|
|
|
|
iconLabel.setBackground(Color.white); |
|
|
|
|
topPane.add(iconLabel, BorderLayout.WEST); |
|
|
|
|
topPane.add(searchTextField, BorderLayout.CENTER); |
|
|
|
|
closeButton = new UIButton() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
|
|
|
|
|
g.setColor(Color.white); |
|
|
|
|
g.fillRect(0, 0, getSize().width, getSize().height); |
|
|
|
|
super.paintComponent(g); |
|
|
|
@ -165,13 +148,11 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
}; |
|
|
|
|
closeButton.setContentAreaFilled(false); |
|
|
|
|
closeButton.setPreferredSize(AlphaFineConstants.CLOSE_BUTTON_SIZE); |
|
|
|
|
closeButton.setIcon(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/alphafine_close.png")); |
|
|
|
|
closeButton.setIcon(new ImageIcon(getClass().getResource("/com/fr/design/mainframe/alphafine/images/alphafine_close.png"))); |
|
|
|
|
closeButton.set4ToolbarButton(); |
|
|
|
|
closeButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
|
|
dispose(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -182,38 +163,34 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
topPane.add(borderLabel, BorderLayout.SOUTH); |
|
|
|
|
add(topPane, BorderLayout.CENTER); |
|
|
|
|
searchTextField.getDocument().addDocumentListener(new DocumentAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void textChanged(DocumentEvent e) { |
|
|
|
|
|
|
|
|
|
doSearch(searchTextField.getText()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private void initProperties() { |
|
|
|
|
|
|
|
|
|
setUndecorated(true); |
|
|
|
|
addComponentListener(new ComponentHandler()); |
|
|
|
|
setSize(AlphaFineConstants.FIELD_SIZE); |
|
|
|
|
centerWindow(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置面板位置 |
|
|
|
|
* |
|
|
|
|
* @param win |
|
|
|
|
*/ |
|
|
|
|
private void centerWindow(Window win) { |
|
|
|
|
|
|
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dimension winSize = win.getSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (winSize.height > screenSize.height) { |
|
|
|
|
winSize.height = screenSize.height; |
|
|
|
|
} |
|
|
|
@ -223,41 +200,40 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
//这里设置位置:水平居中,竖直偏上
|
|
|
|
|
win.setLocation((screenSize.width - winSize.width) / 2, (screenSize.height - winSize.height) / AlphaFineConstants.SHOW_SIZE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: 2017/5/8 xiaxiang: 窗体圆角setShape()有毛边,重写paint方法可以解决毛边问题,但带来了别的问题,处理比较麻烦,暂用setShape();
|
|
|
|
|
// public void paint(Graphics g){
|
|
|
|
|
//
|
|
|
|
|
// Graphics2D g2 = (Graphics2D) g.create();
|
|
|
|
|
// RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
|
|
// qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
|
|
|
|
// g2.setRenderingHints(qualityHints);
|
|
|
|
|
// g2.setPaint(Color.WHITE);
|
|
|
|
|
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 25, 25);
|
|
|
|
|
// g2.fillRoundRect(0, 0, getWidth(), getHeight(), 15, 15);
|
|
|
|
|
// g2.dispose();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 执行搜索 |
|
|
|
|
* |
|
|
|
|
* @param text |
|
|
|
|
*/ |
|
|
|
|
private void doSearch(String text) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(text) || text.equals("AlphaFine")) { |
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(text) || isNeedSearch(text)) { |
|
|
|
|
removeSearchResult(); |
|
|
|
|
} else if (text.contains("'")) { |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
showSearchResult(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isNeedSearch(String text) { |
|
|
|
|
return ComparatorUtils.equals("AlphaFine", text) || text.contains("'"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 移除搜索结果 |
|
|
|
|
*/ |
|
|
|
|
private void removeSearchResult() { |
|
|
|
|
|
|
|
|
|
if (searchResultPane != null) { |
|
|
|
|
remove(searchResultPane); |
|
|
|
|
searchResultPane = null; |
|
|
|
@ -265,7 +241,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
setSize(AlphaFineConstants.FIELD_SIZE); |
|
|
|
|
repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 展示搜索结果 |
|
|
|
|
*/ |
|
|
|
@ -276,12 +252,11 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
initSearchWorker(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化搜索面板 |
|
|
|
|
*/ |
|
|
|
|
private void initSearchResultComponents() { |
|
|
|
|
|
|
|
|
|
searchResultList = new JList(); |
|
|
|
|
searchListModel = new SearchListModel(new SearchResult()); |
|
|
|
|
searchResultList.setModel(searchListModel); |
|
|
|
@ -289,8 +264,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
searchResultPane.setPreferredSize(AlphaFineConstants.CONTENT_SIZE); |
|
|
|
|
searchResultPane.setLayout(new BorderLayout()); |
|
|
|
|
searchResultList.setCellRenderer(new ContentCellRender()); |
|
|
|
|
searchResultList.setFixedCellHeight(AlphaFineConstants.CELL_HEIGHT); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leftSearchResultPane = new UIScrollPane(searchResultList); |
|
|
|
|
leftSearchResultPane.setBackground(Color.white); |
|
|
|
|
leftSearchResultPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
|
|
@ -303,7 +277,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
add(searchResultPane, BorderLayout.SOUTH); |
|
|
|
|
setSize(AlphaFineConstants.FULL_SIZE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 异步加载搜索结果 |
|
|
|
|
*/ |
|
|
|
@ -315,15 +289,13 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
this.searchWorker = new SwingWorker() { |
|
|
|
|
@Override |
|
|
|
|
protected Object doInBackground() throws Exception { |
|
|
|
|
|
|
|
|
|
rebuildList(searchTextField.getText().toLowerCase()); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void done() { |
|
|
|
|
|
|
|
|
|
if (!isCancelled() && searchListModel.getSize() > 0) { |
|
|
|
|
if (!isCancelled() && searchListModel.getSize() > 1) { |
|
|
|
|
searchResultList.setSelectedIndex(1); |
|
|
|
|
showResult(searchResultList.getSelectedIndex(), searchResultList.getSelectedValue()); |
|
|
|
|
} |
|
|
|
@ -331,7 +303,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
}; |
|
|
|
|
this.searchWorker.execute(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 重新构建搜索结果列表 |
|
|
|
|
* 先根据输入判断是不是隐藏的搜索功能 |
|
|
|
@ -339,37 +311,33 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param searchText |
|
|
|
|
*/ |
|
|
|
|
private void rebuildList(String searchText) { |
|
|
|
|
|
|
|
|
|
searchListModel.removeAllElements(); |
|
|
|
|
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { |
|
|
|
|
getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
return; |
|
|
|
|
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { |
|
|
|
|
getDocumentList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
return; |
|
|
|
|
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { |
|
|
|
|
getFileList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
return; |
|
|
|
|
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { |
|
|
|
|
getFileList(searchText); |
|
|
|
|
return; |
|
|
|
|
} else if (searchText.startsWith(DS_MARK)) { |
|
|
|
|
getFileList(DS_NAME + searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
return; |
|
|
|
|
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { |
|
|
|
|
getPluginList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
return; |
|
|
|
|
if (searchText.startsWith(ADVANCED_SEARCH_MARK)) { |
|
|
|
|
if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK)) { |
|
|
|
|
getActionList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
} else if (searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { |
|
|
|
|
getDocumentList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
} else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK)) { |
|
|
|
|
getFileList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
} else if (searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK)) { |
|
|
|
|
getFileList(searchText); |
|
|
|
|
} else if (searchText.startsWith(DS_MARK)) { |
|
|
|
|
getFileList(DS_NAME + searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
} else if (searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { |
|
|
|
|
getPluginList(searchText.substring(searchText.indexOf(StringUtils.BLANK) + 1, searchText.length())); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
doNormalSearch(searchText.trim()); |
|
|
|
|
} |
|
|
|
|
doNormalSearch(searchText.trim()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 普通搜索 |
|
|
|
|
* |
|
|
|
|
* @param searchText |
|
|
|
|
*/ |
|
|
|
|
private void doNormalSearch(String searchText) { |
|
|
|
|
|
|
|
|
|
getRecentList(searchText); |
|
|
|
|
getRecommendList(searchText); |
|
|
|
|
getActionList(searchText); |
|
|
|
@ -377,116 +345,54 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
getDocumentList(searchText); |
|
|
|
|
getPluginList(searchText); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getDocumentList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getDocumentList(final String searchText) { |
|
|
|
|
SearchResult documentModelList = DocumentSearchManager.getDocumentSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : documentModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getFileList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getFileList(final String searchText) { |
|
|
|
|
SearchResult fileModelList = FileSearchManager.getFileSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : fileModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getActionList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getActionList(final String searchText) { |
|
|
|
|
SearchResult actionModelList = ActionSearchManager.getActionSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : actionModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getPluginList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getPluginList(final String searchText) { |
|
|
|
|
SearchResult pluginModelList = PluginSearchManager.getPluginSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : pluginModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getRecommendList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getRecommendList(final String searchText) { |
|
|
|
|
SearchResult recommendModelList = RecommendSearchManager.getRecommendSearchManager().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : recommendModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private synchronized void getRecentList(final String searchText) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void getRecentList(final String searchText) { |
|
|
|
|
SearchResult recentModelList = RecentSearchManager.getRecentSearchManger().getLessSearchResult(searchText); |
|
|
|
|
for (Object object : recentModelList) { |
|
|
|
|
AlphaFineHelper.checkCancel(); |
|
|
|
|
searchListModel.addElement(object); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化监听器 |
|
|
|
|
*/ |
|
|
|
|
private void initListListener() { |
|
|
|
|
/** |
|
|
|
|
* 鼠标监听器 |
|
|
|
|
*/ |
|
|
|
|
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()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 键盘监听器 |
|
|
|
|
*/ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void showResult(int index, final Object selectedValue) { |
|
|
|
@ -494,11 +400,8 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
final String fileName = ((FileModel) selectedValue).getFilePath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1); |
|
|
|
|
showDefaultPreviewPane(); |
|
|
|
|
if (fileName.endsWith(ProjectConstants.FRM_SUFFIX)) { |
|
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
|
|
this.searchWorker.cancel(true); |
|
|
|
|
this.searchWorker = null; |
|
|
|
|
} |
|
|
|
|
this.searchWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
|
checkWorker(); |
|
|
|
|
this.showWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
|
@Override |
|
|
|
|
protected BufferedImage doInBackground() throws Exception { |
|
|
|
|
Form form = FormIO.readForm(FRContext.getCurrentEnv(), fileName); |
|
|
|
@ -522,13 +425,10 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.searchWorker.execute(); |
|
|
|
|
this.showWorker.execute(); |
|
|
|
|
} else if (fileName.endsWith(ProjectConstants.CPT_SUFFIX)) { |
|
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
|
|
this.searchWorker.cancel(true); |
|
|
|
|
this.searchWorker = null; |
|
|
|
|
} |
|
|
|
|
this.searchWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
|
checkWorker(); |
|
|
|
|
this.showWorker = new SwingWorker<BufferedImage, Void>() { |
|
|
|
|
@Override |
|
|
|
|
protected BufferedImage doInBackground() throws Exception { |
|
|
|
|
WorkBook workBook = (WorkBook) TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), fileName); |
|
|
|
@ -553,11 +453,10 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.searchWorker.execute(); |
|
|
|
|
this.showWorker.execute(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if (selectedValue instanceof DocumentModel) { |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
rightSearchResultPane.add(new DocumentPreviewPane(((DocumentModel) selectedValue).getName(), ((DocumentModel) selectedValue).getContent())); |
|
|
|
@ -565,18 +464,19 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
repaint(); |
|
|
|
|
} else if (selectedValue instanceof PluginModel) { |
|
|
|
|
showDefaultPreviewPane(); |
|
|
|
|
if (this.searchWorker != null && !this.searchWorker.isDone()) { |
|
|
|
|
this.searchWorker.cancel(true); |
|
|
|
|
this.searchWorker = null; |
|
|
|
|
} |
|
|
|
|
this.searchWorker = new SwingWorker<Image, Void>() { |
|
|
|
|
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) { |
|
|
|
|
bufferedImage = IOUtils.readImage("/com/fr/design/mainframe/alphafine/images/default_product.png"); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
@ -598,7 +498,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.searchWorker.execute(); |
|
|
|
|
this.showWorker.execute(); |
|
|
|
|
|
|
|
|
|
} else if (selectedValue instanceof ActionModel) { |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
@ -609,6 +509,16 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查 |
|
|
|
|
*/ |
|
|
|
|
private void checkWorker() { |
|
|
|
|
if (this.showWorker != null && !this.showWorker.isDone()) { |
|
|
|
|
this.showWorker.cancel(true); |
|
|
|
|
this.showWorker = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void HandleMoreOrLessResult(int index, MoreModel selectedValue) { |
|
|
|
|
if (selectedValue.getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowAll"))) { |
|
|
|
|
selectedValue.setContent(Inter.getLocText("FR-Designer_AlphaFine_ShowLess")); |
|
|
|
@ -622,41 +532,109 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
private void showDefaultPreviewPane() { |
|
|
|
|
rightSearchResultPane.removeAll(); |
|
|
|
|
UILabel label = new UILabel(IOUtils.readIcon("/com/fr/design/mainframe/alphafine/images/opening.gif")); |
|
|
|
|
label.setBorder(BorderFactory.createEmptyBorder(120,0,0,0)); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void initListener() { |
|
|
|
|
/** |
|
|
|
|
* 为面板添加全局监听器 |
|
|
|
|
*/ |
|
|
|
|
private void initGlobalListener() { |
|
|
|
|
initAWTEventListener(); |
|
|
|
|
|
|
|
|
|
initMouseListener(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 为面板中各组件添加监听器 |
|
|
|
|
*/ |
|
|
|
|
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,实现键盘操作 |
|
|
|
|
*/ |
|
|
|
|
searchTextField.addKeyListener(new KeyAdapter() { |
|
|
|
|
@Override |
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { |
|
|
|
|
searchResultList.requestFocus(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 窗口拖拽 |
|
|
|
|
*/ |
|
|
|
|
private void initMouseListener() { |
|
|
|
|
|
|
|
|
|
addMouseMotionListener(new MouseMotionAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
doMouseDragged(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
doMousePressed(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -787,7 +765,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 点击显示更多时,添加对应的model到list;点击收起是移除model |
|
|
|
|
* |
|
|
|
@ -795,7 +773,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param selectedValue |
|
|
|
|
*/ |
|
|
|
|
private void rebuildShowMoreList(int index, MoreModel selectedValue) { |
|
|
|
|
|
|
|
|
|
SearchResult moreResult = getMoreResult(selectedValue); |
|
|
|
|
if ((selectedValue).getContent().equals(Inter.getLocText("FR-Designer_AlphaFine_ShowLess"))) { |
|
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
@ -804,14 +781,14 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} else { |
|
|
|
|
for (int i = 0; i < moreResult.size(); i++) { |
|
|
|
|
this.searchListModel.remove(index + AlphaFineConstants.SHOW_SIZE + 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.searchResultList.validate(); |
|
|
|
|
this.searchResultList.repaint(); |
|
|
|
|
validate(); |
|
|
|
|
repaint(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void rebuildList() { |
|
|
|
@ -858,16 +835,14 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
public void setSearchWorker(SwingWorker searchWorker) { |
|
|
|
|
this.searchWorker = searchWorker; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isForceOpen() { |
|
|
|
|
|
|
|
|
|
return forceOpen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setForceOpen(boolean forceOpen) { |
|
|
|
|
|
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |