|
|
@ -1,13 +1,9 @@ |
|
|
|
package com.fr.design.mainframe.manager.search.searcher.control.pane; |
|
|
|
package com.fr.design.mainframe.manager.search.searcher.control.pane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.fr.base.svg.IconUtils; |
|
|
|
import com.fr.design.data.datapane.management.search.pane.FineSearchPane; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
|
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; |
|
|
|
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager; |
|
|
|
import com.fr.design.search.TreeSearchStatus; |
|
|
|
import com.fr.design.search.TreeSearchStatus; |
|
|
@ -15,20 +11,13 @@ import com.fr.design.search.event.TreeSearchStatusChangeEvent; |
|
|
|
import com.fr.design.search.event.TreeSearchStatusChangeListener; |
|
|
|
import com.fr.design.search.event.TreeSearchStatusChangeListener; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.event.DocumentEvent; |
|
|
|
import javax.swing.event.DocumentEvent; |
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
import java.awt.CardLayout; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Insets; |
|
|
|
|
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
|
|
|
|
import java.awt.event.FocusListener; |
|
|
|
|
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 模板搜索工具栏 |
|
|
|
* 模板搜索工具栏 |
|
|
@ -57,12 +46,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 搜索面板 |
|
|
|
* 搜索面板 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private JPanel searchPane; |
|
|
|
private FineSearchPane searchPane; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 搜索输入框 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private UITextField searchTextField; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 内容面板 |
|
|
|
* 内容面板 |
|
|
@ -78,7 +62,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
TemplateTreeSearchManager.getInstance().startSearch(searchTextField.getText()); |
|
|
|
TemplateTreeSearchManager.getInstance().startSearch(searchPane.getText()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -99,63 +83,24 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
contentPane.add(searchPane, SEARCH_PANE); |
|
|
|
contentPane.add(searchPane, SEARCH_PANE); |
|
|
|
contentPane.add(toolbarPane, TOOLBAR_PANE); |
|
|
|
contentPane.add(toolbarPane, TOOLBAR_PANE); |
|
|
|
cardLayout.show(contentPane, TOOLBAR_PANE); |
|
|
|
cardLayout.show(contentPane, TOOLBAR_PANE); |
|
|
|
|
|
|
|
contentPane.setBorder(new ScaledEmptyBorder(6, 8, 6, 8)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initSearchPane() { |
|
|
|
private void initSearchPane() { |
|
|
|
searchPane = new JPanel(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR)); |
|
|
|
|
|
|
|
searchPane.setBackground(Color.WHITE); |
|
|
|
|
|
|
|
// 左侧搜索图标
|
|
|
|
|
|
|
|
UILabel searchLabel = new UILabel(new LazyIcon("search")); |
|
|
|
|
|
|
|
searchLabel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); |
|
|
|
|
|
|
|
searchLabel.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
// do nothing
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// 中间输入框
|
|
|
|
|
|
|
|
initSearchTextField(); |
|
|
|
|
|
|
|
// 右侧返回图标
|
|
|
|
|
|
|
|
UILabel returnLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/clear")); |
|
|
|
|
|
|
|
returnLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Tree_Search_Return")); |
|
|
|
|
|
|
|
returnLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 11)); |
|
|
|
|
|
|
|
returnLabel.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
TemplateTreeSearchManager.getInstance().outOfSearchMode(); |
|
|
|
|
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
searchPane.add(searchLabel, BorderLayout.WEST); |
|
|
|
searchPane = new FineSearchPane(); |
|
|
|
searchPane.add(searchTextField, BorderLayout.CENTER); |
|
|
|
searchPane.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Search_Press_Enter_For_Search")); |
|
|
|
searchPane.add(returnLabel, BorderLayout.EAST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initSearchTextField() { |
|
|
|
initSearchTextFieldListener(); |
|
|
|
searchTextField = new UITextField(){ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Insets getInsets() { |
|
|
|
|
|
|
|
return new Insets(2, 4, 0, 4); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
searchTextField.setBorderPainted(false); |
|
|
|
|
|
|
|
searchTextField.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Search_Press_Enter_For_Search")); |
|
|
|
|
|
|
|
searchTextField.addFocusListener(new FocusListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.NORMAL_BLUE)); |
|
|
|
|
|
|
|
searchPane.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
searchPane.addClearActionListener(e -> { |
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
TemplateTreeSearchManager.getInstance().outOfSearchMode(); |
|
|
|
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR)); |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
searchPane.repaint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
this.searchTextField.getDocument().addDocumentListener(new DocumentListener() { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initSearchTextFieldListener() { |
|
|
|
|
|
|
|
searchPane.addDocumentListener(new DocumentListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
@ -169,11 +114,11 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
public void changedUpdate(DocumentEvent e) { |
|
|
|
public void changedUpdate(DocumentEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.searchTextField.addKeyListener(enterPressed); |
|
|
|
searchPane.addKeyListener(enterPressed); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void dealWithTextChange() { |
|
|
|
private void dealWithTextChange() { |
|
|
|
if (StringUtils.isEmpty(searchTextField.getText()) && TemplateTreeSearchManager.getInstance().isInSearchMode()) { |
|
|
|
if (StringUtils.isEmpty(searchPane.getText()) && TemplateTreeSearchManager.getInstance().isInSearchMode()) { |
|
|
|
// 如果是搜索模式下,看作是用户删除输入框文字,仅复原TemplateTreePane
|
|
|
|
// 如果是搜索模式下,看作是用户删除输入框文字,仅复原TemplateTreePane
|
|
|
|
TemplateTreeSearchManager.getInstance().restoreTreePane(); |
|
|
|
TemplateTreeSearchManager.getInstance().restoreTreePane(); |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
|
TemplateTreePane.getInstance().refreshDockingView(); |
|
|
@ -195,7 +140,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setPlaceHolder(String placeHolder) { |
|
|
|
public void setPlaceHolder(String placeHolder) { |
|
|
|
this.searchTextField.setPlaceholder(placeHolder); |
|
|
|
this.searchPane.setPlaceholder(placeHolder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -207,7 +152,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS |
|
|
|
public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) { |
|
|
|
public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) { |
|
|
|
TreeSearchStatus treeSearchStatus = event.getTreeSearchStatus(); |
|
|
|
TreeSearchStatus treeSearchStatus = event.getTreeSearchStatus(); |
|
|
|
if (treeSearchStatus == TreeSearchStatus.NOT_IN_SEARCH_MODE) { |
|
|
|
if (treeSearchStatus == TreeSearchStatus.NOT_IN_SEARCH_MODE) { |
|
|
|
this.searchTextField.setText(StringUtils.EMPTY); |
|
|
|
searchPane.setText(StringUtils.EMPTY); |
|
|
|
switchPane(TOOLBAR_PANE); |
|
|
|
switchPane(TOOLBAR_PANE); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
switchPane(SEARCH_PANE); |
|
|
|
switchPane(SEARCH_PANE); |
|
|
|