|
|
|
@ -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,6 +82,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
private JList searchResultList; |
|
|
|
|
private SearchListModel searchListModel; |
|
|
|
|
private SwingWorker searchWorker; |
|
|
|
|
private SwingWorker showWorker; |
|
|
|
|
//是否强制打开,因为面板是否关闭绑定了全局鼠标事件,这里需要处理一下
|
|
|
|
|
private boolean forceOpen; |
|
|
|
|
|
|
|
|
@ -102,7 +91,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
super(parent); |
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
|
initProperties(); |
|
|
|
|
initListener(); |
|
|
|
|
initGlobalListener(); |
|
|
|
|
initComponents(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -112,12 +101,10 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @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); |
|
|
|
@ -132,7 +119,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void doClickAction() { |
|
|
|
|
|
|
|
|
|
AlphaFineHelper.showAlphaFineDialog(false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -140,24 +126,21 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* 初始化全部组件 |
|
|
|
|
*/ |
|
|
|
|
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,10 +163,8 @@ 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()); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -195,7 +174,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
private void initProperties() { |
|
|
|
|
|
|
|
|
|
setUndecorated(true); |
|
|
|
|
addComponentListener(new ComponentHandler()); |
|
|
|
|
setSize(AlphaFineConstants.FIELD_SIZE); |
|
|
|
@ -209,7 +187,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param win |
|
|
|
|
*/ |
|
|
|
|
private void centerWindow(Window win) { |
|
|
|
|
|
|
|
|
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
|
|
|
|
|
|
|
|
|
Dimension winSize = win.getSize(); |
|
|
|
@ -226,13 +203,12 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
@ -243,21 +219,21 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
*/ |
|
|
|
|
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; |
|
|
|
@ -281,7 +257,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* 初始化搜索面板 |
|
|
|
|
*/ |
|
|
|
|
private void initSearchResultComponents() { |
|
|
|
|
|
|
|
|
|
searchResultList = new JList(); |
|
|
|
|
searchListModel = new SearchListModel(new SearchResult()); |
|
|
|
|
searchResultList.setModel(searchListModel); |
|
|
|
@ -289,7 +264,6 @@ 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); |
|
|
|
@ -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()); |
|
|
|
|
} |
|
|
|
@ -339,28 +311,25 @@ 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()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -369,7 +338,6 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
* @param searchText |
|
|
|
|
*/ |
|
|
|
|
private void doNormalSearch(String searchText) { |
|
|
|
|
|
|
|
|
|
getRecentList(searchText); |
|
|
|
|
getRecommendList(searchText); |
|
|
|
|
getActionList(searchText); |
|
|
|
@ -378,18 +346,15 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
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(); |
|
|
|
@ -397,8 +362,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
@ -406,8 +370,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
@ -415,8 +378,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
@ -424,8 +386,7 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
@ -434,71 +395,13 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化监听器 |
|
|
|
|
*/ |
|
|
|
|
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) { |
|
|
|
|
if (selectedValue instanceof FileModel) { |
|
|
|
|
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,38 +532,106 @@ 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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -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++) { |
|
|
|
@ -861,12 +838,10 @@ public class AlphaFineDialog extends UIDialog {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isForceOpen() { |
|
|
|
|
|
|
|
|
|
return forceOpen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setForceOpen(boolean forceOpen) { |
|
|
|
|
|
|
|
|
|
this.forceOpen = forceOpen; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|