|
|
@ -2,12 +2,10 @@ package com.fr.design.formula; |
|
|
|
|
|
|
|
|
|
|
|
import com.fine.swing.ui.layout.Layouts; |
|
|
|
import com.fine.swing.ui.layout.Layouts; |
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
import com.fine.theme.light.ui.FineRoundBorder; |
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
import com.fine.theme.utils.FineUIStyle; |
|
|
|
import com.fine.theme.utils.FineUIStyle; |
|
|
|
import com.formdev.flatlaf.ui.FlatButtonBorder; |
|
|
|
|
|
|
|
import com.formdev.flatlaf.ui.FlatRoundBorder; |
|
|
|
|
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
|
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.fr.base.BaseFormula; |
|
|
|
import com.fr.base.BaseFormula; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
import com.fr.base.Parameter; |
|
|
|
import com.fr.base.Parameter; |
|
|
@ -17,9 +15,9 @@ import com.fr.base.Utils; |
|
|
|
import com.fr.base.io.IOFile; |
|
|
|
import com.fr.base.io.IOFile; |
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
import com.fr.data.TableDataSource; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.border.UIRoundedBorder; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.data.datapane.management.search.pane.FineSearchPane; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
@ -75,7 +73,6 @@ import com.fr.stable.script.Tiny; |
|
|
|
import com.fr.stable.script.TinyHunter; |
|
|
|
import com.fr.stable.script.TinyHunter; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Window; |
|
|
|
import java.awt.Window; |
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
|
|
|
import javax.swing.DefaultListCellRenderer; |
|
|
|
import javax.swing.DefaultListCellRenderer; |
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
import javax.swing.DefaultListModel; |
|
|
|
import javax.swing.Icon; |
|
|
|
import javax.swing.Icon; |
|
|
@ -87,6 +84,7 @@ import javax.swing.JPanel; |
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JTree; |
|
|
|
import javax.swing.JTree; |
|
|
|
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
@ -130,7 +128,6 @@ import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 公式编辑面板 |
|
|
|
* 公式编辑面板 |
|
|
@ -148,6 +145,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
private VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
private RSyntaxTextArea formulaTextArea; |
|
|
|
private RSyntaxTextArea formulaTextArea; |
|
|
|
private UITextField keyWordTextField = new UITextField(18); |
|
|
|
private UITextField keyWordTextField = new UITextField(18); |
|
|
|
|
|
|
|
private FineSearchPane searchPane = new FineSearchPane(); |
|
|
|
private int currentPosition = 0; |
|
|
|
private int currentPosition = 0; |
|
|
|
private int beginPosition = 0; |
|
|
|
private int beginPosition = 0; |
|
|
|
private int insertPosition = 0; |
|
|
|
private int insertPosition = 0; |
|
|
@ -238,7 +236,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initKeyWordTextFieldKeyListener() { |
|
|
|
private void initKeyWordTextFieldKeyListener() { |
|
|
|
keyWordTextField.addKeyListener(new KeyListener() { |
|
|
|
searchPane.addClearActionListener(e -> searchPane.setText(StringUtils.EMPTY)); |
|
|
|
|
|
|
|
searchPane.addKeyListener(new KeyListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyTyped(KeyEvent e) { |
|
|
|
public void keyTyped(KeyEvent e) { |
|
|
|
//do nothing
|
|
|
|
//do nothing
|
|
|
@ -252,12 +251,16 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
String toFind = searchPane.getText(); |
|
|
|
search(toFind, false); |
|
|
|
search(toFind, false); |
|
|
|
|
|
|
|
popTips(); |
|
|
|
|
|
|
|
searchPane.requestFocusInWindow(); |
|
|
|
if (tipsList.getSelectedValue() != null) { |
|
|
|
if (tipsList.getSelectedValue() != null) { |
|
|
|
fixFunctionNameList(tipsList.getSelectedValue().toString()); |
|
|
|
fixFunctionNameList(tipsList.getSelectedValue().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
e.consume(); |
|
|
|
e.consume(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -265,28 +268,17 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
|
|
|
|
|
|
|
|
private JPanel initTipsPane() { |
|
|
|
private JPanel initTipsPane() { |
|
|
|
// tipsPane
|
|
|
|
// tipsPane
|
|
|
|
UIButton searchButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaPane_Search")); |
|
|
|
searchPane.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Tree_Search_Press_Enter_For_Search")); |
|
|
|
UILabel formulaLabel = new UILabel( |
|
|
|
UILabel formulaLabel = new UILabel( |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Input_Formula_In_The_Text_Area_Below") + ":", SwingConstants.LEFT); |
|
|
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FormulaD_Input_Formula_In_The_Text_Area_Below") + ":", SwingConstants.LEFT); |
|
|
|
JPanel containerSPane = row( |
|
|
|
JPanel containerSPane = row( |
|
|
|
cell(formulaLabel), |
|
|
|
cell(formulaLabel).weight(4), |
|
|
|
flex(), |
|
|
|
cell(searchPane).weight(1) |
|
|
|
cell(keyWordTextField), |
|
|
|
|
|
|
|
cell(searchButton) |
|
|
|
|
|
|
|
).getComponent(); |
|
|
|
).getComponent(); |
|
|
|
|
|
|
|
|
|
|
|
initKeyWordTextFieldKeyListener(); |
|
|
|
initKeyWordTextFieldKeyListener(); |
|
|
|
tipsList = new JList(listModel); |
|
|
|
tipsList = new JList(listModel); |
|
|
|
tipsList.addMouseListener(new DoubleClick()); |
|
|
|
tipsList.addMouseListener(new DoubleClick()); |
|
|
|
searchButton.addActionListener(e -> { |
|
|
|
|
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
|
|
|
|
search(toFind, false); |
|
|
|
|
|
|
|
popTips(); |
|
|
|
|
|
|
|
formulaTextArea.requestFocusInWindow(); |
|
|
|
|
|
|
|
if (tipsList.getSelectedValue() != null) { |
|
|
|
|
|
|
|
fixFunctionNameList(tipsList.getSelectedValue().toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return containerSPane; |
|
|
|
return containerSPane; |
|
|
|
} |
|
|
|
} |
|
|
@ -322,7 +314,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
// text
|
|
|
|
// text
|
|
|
|
initFormulaTextArea(); |
|
|
|
initFormulaTextArea(); |
|
|
|
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea); |
|
|
|
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea); |
|
|
|
formulaTextAreaScrollPane.setBorder(new FlatRoundBorder()); |
|
|
|
formulaTextAreaScrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
|
|
|
|
|
|
|
|
// buttonPane
|
|
|
|
// buttonPane
|
|
|
|
JPanel buttonPane = row(8).getComponent(); |
|
|
|
JPanel buttonPane = row(8).getComponent(); |
|
|
@ -653,9 +645,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
popupMenu = new JPopupMenu(); |
|
|
|
popupMenu = new JPopupMenu(); |
|
|
|
JScrollPane tipsScrollPane = new JScrollPane(tipsList); |
|
|
|
JScrollPane tipsScrollPane = new JScrollPane(tipsList); |
|
|
|
popupMenu.add(tipsScrollPane); |
|
|
|
popupMenu.add(tipsScrollPane); |
|
|
|
tipsScrollPane.setPreferredSize(new Dimension(FineUIScale.scale(240), FineUIScale.scale(146))); |
|
|
|
popupMenu.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
tipsScrollPane.setPreferredSize(FineUIScale.scale(new Dimension(172, 120))); |
|
|
|
popupMenu.show(keyWordTextField, 0, 23); |
|
|
|
popupMenu.show(searchPane, 0, 28); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void search(String keyWord, boolean findDescription) { |
|
|
|
protected void search(String keyWord, boolean findDescription) { |
|
|
@ -750,10 +742,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public BasicDialog showLargeWindow(Window window, DialogActionListener l) { |
|
|
|
public BasicDialog showLargeWindow(Window window, DialogActionListener l) { |
|
|
|
int width = 900; |
|
|
|
Dimension dimension = new Dimension(900, 640); |
|
|
|
int height = 640; |
|
|
|
BasicDialog basicDialog = super.showWindowWithCustomSize(window, l, dimension); |
|
|
|
BasicDialog basicDialog = super.showWindowWithCustomSize(window, l, FineUIScale.scale(new Dimension(width, height))); |
|
|
|
basicDialog.setMinimumSize(dimension); |
|
|
|
basicDialog.setMinimumSize(FineUIScale.scale(new Dimension(width, height))); |
|
|
|
|
|
|
|
basicDialog.setResizable(true); |
|
|
|
basicDialog.setResizable(true); |
|
|
|
return basicDialog; |
|
|
|
return basicDialog; |
|
|
|
} |
|
|
|
} |
|
|
@ -1079,7 +1070,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
private JPanel initFunctionTypeList() { |
|
|
|
private JPanel initFunctionTypeList() { |
|
|
|
functionTypeList = new QuickList(functionTypeListModel); |
|
|
|
functionTypeList = new QuickList(functionTypeListModel); |
|
|
|
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList); |
|
|
|
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList); |
|
|
|
functionTypeScrollPane.setBorder(new FineRoundBorder()); |
|
|
|
functionTypeScrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
functionTypeList.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
functionTypeList.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
initTypeListCellRenderer(); |
|
|
|
initTypeListCellRenderer(); |
|
|
|
initGroupTypeModel(); |
|
|
|
initGroupTypeModel(); |
|
|
@ -1194,7 +1185,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
private JPanel initFunctionNameList() { |
|
|
|
private JPanel initFunctionNameList() { |
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
functionNameScrollPane.setBorder(new FlatButtonBorder()); |
|
|
|
functionNameScrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
functionNameList.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
functionNameList.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
initFunctionNameListCellRenderer(); |
|
|
|
initFunctionNameListCellRenderer(); |
|
|
|
initFunctionNameListSelectionListener(); |
|
|
|
initFunctionNameListSelectionListener(); |
|
|
@ -1207,6 +1198,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
descriptionTextArea = new UITextArea(); |
|
|
|
descriptionTextArea = new UITextArea(); |
|
|
|
descriptionTextArea.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
descriptionTextArea.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
descriptionTextArea.setLineWrap(true); |
|
|
|
descriptionTextArea.setLineWrap(true); |
|
|
|
|
|
|
|
descriptionTextArea.setBorder(new ScaledEmptyBorder(4, 4, 4, 4)); |
|
|
|
descriptionTextArea.setWrapStyleWord(true); |
|
|
|
descriptionTextArea.setWrapStyleWord(true); |
|
|
|
descriptionTextArea.setEditable(false); |
|
|
|
descriptionTextArea.setEditable(false); |
|
|
|
descriptionTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
descriptionTextArea.addMouseListener(new MouseAdapter() { |
|
|
@ -1275,7 +1267,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
// variable
|
|
|
|
// variable
|
|
|
|
variablesTree = new JTree(); |
|
|
|
variablesTree = new JTree(); |
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|
variablesTreePane.setBorder(new FlatRoundBorder()); |
|
|
|
variablesTreePane.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
variablesTree.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
variablesTree.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
|
|
|
variablesTree.setRootVisible(false); |
|
|
|
variablesTree.setRootVisible(false); |
|
|
|
variablesTree.setShowsRootHandles(true); |
|
|
|
variablesTree.setShowsRootHandles(true); |
|
|
@ -1285,7 +1277,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
initDescriptionTextArea(); |
|
|
|
initDescriptionTextArea(); |
|
|
|
|
|
|
|
|
|
|
|
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea); |
|
|
|
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea); |
|
|
|
desScrollPane.setBorder(null); |
|
|
|
desScrollPane.setBorder(FineBorderFactory.createWrappedRoundBorder()); |
|
|
|
initVariablesTreeSelectionListener(); |
|
|
|
initVariablesTreeSelectionListener(); |
|
|
|
return Layouts.row(LayoutConstants.HORIZONTAL_GAP, |
|
|
|
return Layouts.row(LayoutConstants.HORIZONTAL_GAP, |
|
|
|
cell(this.createNamePane( |
|
|
|
cell(this.createNamePane( |
|
|
|