|
|
@ -22,6 +22,7 @@ import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.general.Inter; |
|
|
|
import com.fr.parser.FRLexer; |
|
|
|
import com.fr.parser.FRLexer; |
|
|
|
import com.fr.parser.FRParser; |
|
|
|
import com.fr.parser.FRParser; |
|
|
|
|
|
|
|
import com.fr.stable.EncodeConstants; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.script.Expression; |
|
|
|
import com.fr.stable.script.Expression; |
|
|
@ -38,12 +39,14 @@ import java.awt.event.*; |
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 公式编辑面板 |
|
|
|
* 公式编辑面板 |
|
|
|
|
|
|
|
* |
|
|
|
* @editor zhou |
|
|
|
* @editor zhou |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
* @since 2012-3-29下午1:50:53 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
public class FormulaPane extends BasicPane implements KeyListener, UIFormula { |
|
|
|
|
|
|
|
|
|
|
|
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
protected VariableTreeAndDescriptionArea variableTreeAndDescriptionArea; |
|
|
|
protected RSyntaxTextArea formulaTextArea; |
|
|
|
protected RSyntaxTextArea formulaTextArea; |
|
|
@ -63,7 +66,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
initComponents(); |
|
|
|
initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFormulaTextAreaKeyListener(){ |
|
|
|
private void initFormulaTextAreaKeyListener() { |
|
|
|
formulaTextArea.addKeyListener(this); |
|
|
|
formulaTextArea.addKeyListener(this); |
|
|
|
formulaTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
formulaTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
@ -72,7 +75,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
// 判断在中文输入状态是否还包含提示符 要删掉
|
|
|
|
// 判断在中文输入状态是否还包含提示符 要删掉
|
|
|
|
//Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
|
|
|
|
//Tips:You_Can_Input_B1_To_Input_The_Data_Of_The_First_Row_Second_Column
|
|
|
|
String tip = "\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips"); |
|
|
|
String tip = "\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips"); |
|
|
|
if(text.contains(tip)) { |
|
|
|
if (text.contains(tip)) { |
|
|
|
text = text.substring(0, text.indexOf(tip)); |
|
|
|
text = text.substring(0, text.indexOf(tip)); |
|
|
|
insertPosition = 0; |
|
|
|
insertPosition = 0; |
|
|
|
formulaTextArea.setText(text); |
|
|
|
formulaTextArea.setText(text); |
|
|
@ -81,7 +84,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFormulaTextAreaMouseListener(){ |
|
|
|
private void initFormulaTextAreaMouseListener() { |
|
|
|
formulaTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
formulaTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
@ -107,21 +110,23 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFormulaTextArea(){ |
|
|
|
private void initFormulaTextArea() { |
|
|
|
formulaTextArea = new RSyntaxTextArea(); |
|
|
|
formulaTextArea = new RSyntaxTextArea(); |
|
|
|
configFormulaArea(); |
|
|
|
configFormulaArea(); |
|
|
|
initFormulaTextAreaKeyListener(); |
|
|
|
initFormulaTextAreaKeyListener(); |
|
|
|
initFormulaTextAreaMouseListener(); |
|
|
|
initFormulaTextAreaMouseListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initKeyWordTextFieldKeyListener(){ |
|
|
|
private void initKeyWordTextFieldKeyListener() { |
|
|
|
keyWordTextField.addKeyListener(new KeyListener() { |
|
|
|
keyWordTextField.addKeyListener(new KeyListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyTyped(KeyEvent e) { |
|
|
|
public void keyTyped(KeyEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
@ -134,7 +139,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTipsPane(){ |
|
|
|
private void initTipsPane() { |
|
|
|
// tipsPane
|
|
|
|
// tipsPane
|
|
|
|
JPanel tipsPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
JPanel tipsPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
this.add(tipsPane, BorderLayout.EAST); |
|
|
|
this.add(tipsPane, BorderLayout.EAST); |
|
|
@ -259,6 +264,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
this.formulaTextArea.setText(StringUtils.EMPTY); |
|
|
|
this.formulaTextArea.setText(StringUtils.EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//hugh:为啥会是10呢?搞不懂~~~
|
|
|
|
//hugh:为啥会是10呢?搞不懂~~~
|
|
|
|
private static final int KEY_10 = 10; |
|
|
|
private static final int KEY_10 = 10; |
|
|
|
//上下左右
|
|
|
|
//上下左右
|
|
|
@ -266,6 +272,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
private static final int KEY_38 = 38; |
|
|
|
private static final int KEY_38 = 38; |
|
|
|
private static final int KEY_39 = 39; |
|
|
|
private static final int KEY_39 = 39; |
|
|
|
private static final int KEY_40 = 40; |
|
|
|
private static final int KEY_40 = 40; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
int key = e.getKeyCode(); |
|
|
|
int key = e.getKeyCode(); |
|
|
@ -562,7 +569,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
this.initComponents(); |
|
|
|
this.initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionTypeList(JPanel functionPane){ |
|
|
|
private void initFunctionTypeList(JPanel functionPane) { |
|
|
|
functionTypeList = new QuickList(functionTypeListModel); |
|
|
|
functionTypeList = new QuickList(functionTypeListModel); |
|
|
|
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList); |
|
|
|
UIScrollPane functionTypeScrollPane = new UIScrollPane(functionTypeList); |
|
|
|
functionTypeScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
functionTypeScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
@ -573,7 +580,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
initTypeListSelectionListener(); |
|
|
|
initTypeListSelectionListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTypeListCellRenderer(){ |
|
|
|
private void initTypeListCellRenderer() { |
|
|
|
functionTypeList.setCellRenderer( |
|
|
|
functionTypeList.setCellRenderer( |
|
|
|
new DefaultListCellRenderer() { |
|
|
|
new DefaultListCellRenderer() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -587,7 +594,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initTypeListSelectionListener(){ |
|
|
|
private void initTypeListSelectionListener() { |
|
|
|
functionTypeList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
functionTypeList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
|
Object selectedValue = ((JList) evt.getSource()).getSelectedValue(); |
|
|
|
Object selectedValue = ((JList) evt.getSource()).getSelectedValue(); |
|
|
@ -608,7 +615,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initGroupTypeModel(){ |
|
|
|
private void initGroupTypeModel() { |
|
|
|
functionTypeListModel.addElement(FunctionConstants.COMMON); |
|
|
|
functionTypeListModel.addElement(FunctionConstants.COMMON); |
|
|
|
for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) { |
|
|
|
for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) { |
|
|
|
functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]); |
|
|
|
functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]); |
|
|
@ -621,7 +628,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel); |
|
|
|
FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameListCellRenderer(){ |
|
|
|
private void initFunctionNameListCellRenderer() { |
|
|
|
functionNameList.setCellRenderer(new DefaultListCellRenderer() { |
|
|
|
functionNameList.setCellRenderer(new DefaultListCellRenderer() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -635,7 +642,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameListSelectionListener(){ |
|
|
|
private void initFunctionNameListSelectionListener() { |
|
|
|
functionNameList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
functionNameList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
@ -652,7 +659,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameListMouseListener(){ |
|
|
|
private void initFunctionNameListMouseListener() { |
|
|
|
functionNameList.addMouseListener(new MouseAdapter() { |
|
|
|
functionNameList.addMouseListener(new MouseAdapter() { |
|
|
|
public void mouseClicked(MouseEvent evt) { |
|
|
|
public void mouseClicked(MouseEvent evt) { |
|
|
|
if (evt.getClickCount() >= 2) { |
|
|
|
if (evt.getClickCount() >= 2) { |
|
|
@ -676,7 +683,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameList(JPanel functionPane){ |
|
|
|
private void initFunctionNameList(JPanel functionPane) { |
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
functionNameScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
|
functionNameScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
@ -689,7 +696,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
initFunctionNameListMouseListener(); |
|
|
|
initFunctionNameListMouseListener(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initDescriptionTextArea(){ |
|
|
|
private void initDescriptionTextArea() { |
|
|
|
// Description
|
|
|
|
// Description
|
|
|
|
descriptionTextArea = new UITextArea(16, 27); |
|
|
|
descriptionTextArea = new UITextArea(16, 27); |
|
|
|
|
|
|
|
|
|
|
@ -711,15 +718,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private StringBuilder getText(TextUserObject selectedValue,String path) throws IOException{ |
|
|
|
private StringBuilder getText(TextUserObject selectedValue, String path) throws IOException { |
|
|
|
Reader desReader; |
|
|
|
Reader desReader; |
|
|
|
StringBuilder desBuf = new StringBuilder(); |
|
|
|
StringBuilder desBuf = new StringBuilder(); |
|
|
|
InputStream desInputStream = BaseUtils.readResource(path+ ((TextUserObject) selectedValue).displayText+".txt"); |
|
|
|
InputStream desInputStream = BaseUtils.readResource(path + ((TextUserObject) selectedValue).displayText + ".txt"); |
|
|
|
if (desInputStream == null) { |
|
|
|
if (desInputStream == null) { |
|
|
|
String description = ""; |
|
|
|
String description = ""; |
|
|
|
desReader = new StringReader(description); |
|
|
|
desReader = new StringReader(description); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
desReader = new InputStreamReader(desInputStream); |
|
|
|
desReader = new InputStreamReader(desInputStream, EncodeConstants.ENCODING_UTF_8); |
|
|
|
} |
|
|
|
} |
|
|
|
BufferedReader reader = new BufferedReader(desReader); |
|
|
|
BufferedReader reader = new BufferedReader(desReader); |
|
|
|
String lineText; |
|
|
|
String lineText; |
|
|
@ -734,7 +741,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
return desBuf; |
|
|
|
return desBuf; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initVariablesTreeSelectionListener(){ |
|
|
|
private void initVariablesTreeSelectionListener() { |
|
|
|
variablesTree.addTreeSelectionListener(new TreeSelectionListener() { |
|
|
|
variablesTree.addTreeSelectionListener(new TreeSelectionListener() { |
|
|
|
public void valueChanged(TreeSelectionEvent e) { |
|
|
|
public void valueChanged(TreeSelectionEvent e) { |
|
|
|
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); |
|
|
|
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); |
|
|
@ -751,7 +758,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
path = "/com/fr/design/insert/formula/variable/en/"; |
|
|
|
path = "/com/fr/design/insert/formula/variable/en/"; |
|
|
|
} |
|
|
|
} |
|
|
|
if (selectedValue instanceof TextUserObject) { |
|
|
|
if (selectedValue instanceof TextUserObject) { |
|
|
|
desBuf = getText((TextUserObject)selectedValue,path); |
|
|
|
desBuf = getText((TextUserObject) selectedValue, path); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException exp) { |
|
|
|
} catch (IOException exp) { |
|
|
|
FRContext.getLogger().error(exp.getMessage(), exp); |
|
|
|
FRContext.getLogger().error(exp.getMessage(), exp); |
|
|
@ -762,7 +769,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initVariablesTree(){ |
|
|
|
private void initVariablesTree() { |
|
|
|
// vairable.
|
|
|
|
// vairable.
|
|
|
|
variablesTree = new JTree(); |
|
|
|
variablesTree = new JTree(); |
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|