|
|
@ -32,10 +32,12 @@ import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.event.TreeSelectionEvent; |
|
|
|
import javax.swing.event.TreeSelectionEvent; |
|
|
|
import javax.swing.event.TreeSelectionListener; |
|
|
|
import javax.swing.event.TreeSelectionListener; |
|
|
|
import javax.swing.tree.*; |
|
|
|
import javax.swing.tree.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.*; |
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import java.util.Locale; |
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 公式编辑面板 |
|
|
|
* 公式编辑面板 |
|
|
|
* @editor zhou |
|
|
|
* @editor zhou |
|
|
@ -61,28 +63,15 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
initComponents(); |
|
|
|
initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void initComponents() { |
|
|
|
private void initFormulaTextAreaKeyListener(){ |
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// text
|
|
|
|
|
|
|
|
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
|
|
|
this.add(textPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":" |
|
|
|
|
|
|
|
+ " "); |
|
|
|
|
|
|
|
formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
|
|
|
|
|
|
|
formulaTextArea = new RSyntaxTextArea(); |
|
|
|
|
|
|
|
configFormulaArea(); |
|
|
|
|
|
|
|
formulaTextArea.addKeyListener(this); |
|
|
|
formulaTextArea.addKeyListener(this); |
|
|
|
|
|
|
|
|
|
|
|
formulaTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
formulaTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
formulaTextArea.setForeground(Color.black); |
|
|
|
formulaTextArea.setForeground(Color.black); |
|
|
|
String text = formulaTextArea.getText(); |
|
|
|
String text = formulaTextArea.getText(); |
|
|
|
// 判断在中文输入状态是否还包含提示符 要删掉
|
|
|
|
// 判断在中文输入状态是否还包含提示符 要删掉
|
|
|
|
String tip = "\n\n\n" + Inter.getLocText("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"); |
|
|
|
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; |
|
|
@ -90,9 +79,10 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFormulaTextAreaMouseListener(){ |
|
|
|
formulaTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
formulaTextArea.addMouseListener(new MouseAdapter() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
insertPosition = formulaTextArea.getCaretPosition(); |
|
|
|
insertPosition = formulaTextArea.getCaretPosition(); |
|
|
@ -115,52 +105,81 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea); |
|
|
|
} |
|
|
|
formulaTextAreaScrollPane.setBorder(null); |
|
|
|
|
|
|
|
textPane.add(formulaLabel, BorderLayout.NORTH); |
|
|
|
|
|
|
|
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tipsPane
|
|
|
|
|
|
|
|
JPanel tipsPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
this.add(tipsPane, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel searchPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
private void initFormulaTextArea(){ |
|
|
|
searchPane.add(keyWordTextField, BorderLayout.CENTER); |
|
|
|
formulaTextArea = new RSyntaxTextArea(); |
|
|
|
UIButton searchButton = new UIButton(Inter.getLocText("Search")); |
|
|
|
configFormulaArea(); |
|
|
|
searchPane.add(searchButton, BorderLayout.EAST); |
|
|
|
initFormulaTextAreaKeyListener(); |
|
|
|
tipsPane.add(searchPane, BorderLayout.NORTH); |
|
|
|
initFormulaTextAreaMouseListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
search(toFind, false); |
|
|
|
search(toFind, false); |
|
|
|
|
|
|
|
|
|
|
|
fixFunctionNameList(); |
|
|
|
fixFunctionNameList(); |
|
|
|
e.consume(); |
|
|
|
e.consume(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initTipsPane(){ |
|
|
|
|
|
|
|
// tipsPane
|
|
|
|
|
|
|
|
JPanel tipsPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
this.add(tipsPane, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JPanel searchPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
searchPane.add(keyWordTextField, BorderLayout.CENTER); |
|
|
|
|
|
|
|
UIButton searchButton = new UIButton(Inter.getLocText("FR-Designer_FormulaPane_Search")); |
|
|
|
|
|
|
|
searchPane.add(searchButton, BorderLayout.EAST); |
|
|
|
|
|
|
|
tipsPane.add(searchPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
initKeyWordTextFieldKeyListener(); |
|
|
|
tipsList = new JList(listModel); |
|
|
|
tipsList = new JList(listModel); |
|
|
|
tipsList.addMouseListener(new DoubleClick()); |
|
|
|
tipsList.addMouseListener(new DoubleClick()); |
|
|
|
UIScrollPane tipsScrollPane = new UIScrollPane(tipsList); |
|
|
|
UIScrollPane tipsScrollPane = new UIScrollPane(tipsList); |
|
|
|
tipsScrollPane.setPreferredSize(new Dimension(170, 75)); |
|
|
|
tipsScrollPane.setPreferredSize(new Dimension(170, 75)); |
|
|
|
tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
tipsScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
|
|
|
|
|
|
|
|
tipsPane.add(tipsScrollPane, BorderLayout.CENTER); |
|
|
|
tipsPane.add(tipsScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
searchButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
|
|
|
|
search(toFind, false); |
|
|
|
|
|
|
|
formulaTextArea.requestFocusInWindow(); |
|
|
|
|
|
|
|
fixFunctionNameList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void initComponents() { |
|
|
|
|
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
// text
|
|
|
|
|
|
|
|
JPanel textPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
|
|
|
this.add(textPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
JPanel checkBoxandbuttonPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
UILabel formulaLabel = new UILabel(Inter.getLocText("FormulaD-Input_formula_in_the_text_area_below") + ":" |
|
|
|
|
|
|
|
+ " "); |
|
|
|
|
|
|
|
formulaLabel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); |
|
|
|
|
|
|
|
initFormulaTextArea(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIScrollPane formulaTextAreaScrollPane = new UIScrollPane(formulaTextArea); |
|
|
|
|
|
|
|
formulaTextAreaScrollPane.setBorder(null); |
|
|
|
|
|
|
|
textPane.add(formulaLabel, BorderLayout.NORTH); |
|
|
|
|
|
|
|
textPane.add(formulaTextAreaScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
textPane.add(checkBoxandbuttonPane, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initTipsPane(); |
|
|
|
|
|
|
|
|
|
|
|
UIButton checkValidButton = new UIButton(Inter.getLocText("FormulaD-Check_Valid")); |
|
|
|
UIButton checkValidButton = new UIButton(Inter.getLocText("FormulaD-Check_Valid")); |
|
|
|
checkValidButton.addActionListener(checkValidActionListener); |
|
|
|
checkValidButton.addActionListener(checkValidActionListener); |
|
|
@ -169,20 +188,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
checkBoxPane.setPreferredSize(new Dimension(450, 30)); |
|
|
|
checkBoxPane.setPreferredSize(new Dimension(450, 30)); |
|
|
|
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); |
|
|
|
checkBoxandbuttonPane.add(checkBoxPane, BorderLayout.WEST); |
|
|
|
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); |
|
|
|
checkBoxandbuttonPane.add(checkValidButton, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
|
|
extendCheckBoxPane(checkBoxPane); |
|
|
|
extendCheckBoxPane(checkBoxPane); |
|
|
|
|
|
|
|
|
|
|
|
searchButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
|
|
|
|
String toFind = keyWordTextField.getText(); |
|
|
|
|
|
|
|
search(toFind, false); |
|
|
|
|
|
|
|
formulaTextArea.requestFocusInWindow(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fixFunctionNameList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea(); |
|
|
|
variableTreeAndDescriptionArea = new VariableTreeAndDescriptionArea(); |
|
|
|
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH); |
|
|
|
this.add(variableTreeAndDescriptionArea, BorderLayout.SOUTH); |
|
|
|
} |
|
|
|
} |
|
|
@ -253,11 +259,17 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
this.formulaTextArea.setText(StringUtils.EMPTY); |
|
|
|
this.formulaTextArea.setText(StringUtils.EMPTY); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//hugh:为啥会是10呢?搞不懂~~~
|
|
|
|
|
|
|
|
private static final int KEY_10 = 10; |
|
|
|
|
|
|
|
//上下左右
|
|
|
|
|
|
|
|
private static final int KEY_37 = 37; |
|
|
|
|
|
|
|
private static final int KEY_38 = 38; |
|
|
|
|
|
|
|
private static final int KEY_39 = 39; |
|
|
|
|
|
|
|
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(); |
|
|
|
if (key == 38 || key == 40 || key == 37 || key == 39 || key == 10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合
|
|
|
|
if (key == KEY_38 || key == KEY_40 || key == KEY_37 || key == KEY_39 || key == KEY_10) //如果是删除符号 ,为了可读性 没有和其他按键的程序相融合
|
|
|
|
{ |
|
|
|
{ |
|
|
|
listModel.removeAllElements(); |
|
|
|
listModel.removeAllElements(); |
|
|
|
currentPosition = formulaTextArea.getCaretPosition(); |
|
|
|
currentPosition = formulaTextArea.getCaretPosition(); |
|
|
@ -461,7 +473,8 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
String content = formula.getContent(); |
|
|
|
String content = formula.getContent(); |
|
|
|
if (content.trim().equals("=")) { |
|
|
|
if (content.trim().equals("=")) { |
|
|
|
this.formulaTextArea.setForeground(Color.gray); |
|
|
|
this.formulaTextArea.setForeground(Color.gray); |
|
|
|
this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("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
|
|
|
|
|
|
|
|
this.formulaTextArea.setText("\n\n\n" + Inter.getLocText("FR-Designer_FormulaPane_Tips")); |
|
|
|
this.formulaTextArea.setCaretPosition(0); |
|
|
|
this.formulaTextArea.setCaretPosition(0); |
|
|
|
ifHasBeenWriten = 0; |
|
|
|
ifHasBeenWriten = 0; |
|
|
|
this.listModel.removeAllElements(); |
|
|
|
this.listModel.removeAllElements(); |
|
|
@ -549,21 +562,20 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
this.initComponents(); |
|
|
|
this.initComponents(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
private void initFunctionTypeList(JPanel functionPane){ |
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Function
|
|
|
|
|
|
|
|
JPanel functionPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
this.add(functionPane, BorderLayout.WEST); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)); |
|
|
|
functionTypeScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
|
functionTypeScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
|
functionPane.add(this.createNamePane(Inter.getLocText("FormulaD-Function_category") + ":", functionTypeScrollPane), BorderLayout.WEST); |
|
|
|
functionPane.add(this.createNamePane(Inter.getLocText("FormulaD-Function_category") + ":", functionTypeScrollPane), BorderLayout.WEST); |
|
|
|
functionTypeList.setCellRenderer(new DefaultListCellRenderer() { |
|
|
|
initTypeListCellRenderer(); |
|
|
|
|
|
|
|
initGroupTypeModel(); |
|
|
|
|
|
|
|
initTypeListSelectionListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initTypeListCellRenderer(){ |
|
|
|
|
|
|
|
functionTypeList.setCellRenderer( |
|
|
|
|
|
|
|
new DefaultListCellRenderer() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
|
@ -573,47 +585,43 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
functionTypeListModel.addElement(FunctionConstants.COMMON); |
|
|
|
|
|
|
|
for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) { |
|
|
|
|
|
|
|
functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
functionTypeListModel.addElement(FunctionConstants.ALL); |
|
|
|
|
|
|
|
functionTypeListModel.addElement(FunctionConstants.CUSTOM); |
|
|
|
|
|
|
|
functionTypeListModel.addElement(FunctionConstants.PLUGIN); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
if (!(selectedValue instanceof FunctionGroup)) { |
|
|
|
if (!(selectedValue instanceof FunctionGroup)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NameAndDescription[] nads = ((FunctionGroup) selectedValue).getDescriptions(); |
|
|
|
NameAndDescription[] nads = ((FunctionGroup) selectedValue).getDescriptions(); |
|
|
|
functionNameModel = (DefaultListModel) functionNameList.getModel(); |
|
|
|
functionNameModel = (DefaultListModel) functionNameList.getModel(); |
|
|
|
|
|
|
|
|
|
|
|
functionNameModel.clear(); |
|
|
|
functionNameModel.clear(); |
|
|
|
|
|
|
|
|
|
|
|
for (NameAndDescription nad : nads) { |
|
|
|
for (NameAndDescription nad : nads) { |
|
|
|
functionNameModel.addElement(nad); |
|
|
|
functionNameModel.addElement(nad); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (functionNameModel.size() > 0) { |
|
|
|
if (functionNameModel.size() > 0) { |
|
|
|
functionNameList.setSelectedIndex(0); |
|
|
|
functionNameList.setSelectedIndex(0); |
|
|
|
functionNameList.ensureIndexIsVisible(0); |
|
|
|
functionNameList.ensureIndexIsVisible(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
private void initGroupTypeModel(){ |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
functionTypeListModel.addElement(FunctionConstants.COMMON); |
|
|
|
functionNameScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
|
for (int i = 0; i < FunctionConstants.EMBFUNCTIONS.length; i++) { |
|
|
|
functionPane.add( |
|
|
|
functionTypeListModel.addElement(FunctionConstants.EMBFUNCTIONS[i]); |
|
|
|
this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane), |
|
|
|
} |
|
|
|
BorderLayout.CENTER); |
|
|
|
functionTypeListModel.addElement(FunctionConstants.ALL); |
|
|
|
functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
functionTypeListModel.addElement(FunctionConstants.CUSTOM); |
|
|
|
|
|
|
|
functionTypeListModel.addElement(FunctionConstants.PLUGIN); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//hugh: 从函数分组插件中添加分组
|
|
|
|
|
|
|
|
FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameListCellRenderer(){ |
|
|
|
functionNameList.setCellRenderer(new DefaultListCellRenderer() { |
|
|
|
functionNameList.setCellRenderer(new DefaultListCellRenderer() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -625,7 +633,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initFunctionNameListSelectionListener(){ |
|
|
|
functionNameList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
functionNameList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
|
public void valueChanged(ListSelectionEvent evt) { |
|
|
@ -640,11 +650,11 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
descriptionTextArea.moveCaretPosition(0); |
|
|
|
descriptionTextArea.moveCaretPosition(0); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
|
Object selectedValue = functionNameList.getSelectedValue(); |
|
|
|
Object selectedValue = functionNameList.getSelectedValue(); |
|
|
|
if (!(selectedValue instanceof NameAndDescription)) { |
|
|
|
if (!(selectedValue instanceof NameAndDescription)) { |
|
|
@ -654,7 +664,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
applyText(insert); |
|
|
|
applyText(insert); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (SwingUtilities.isRightMouseButton(evt)) { |
|
|
|
if (SwingUtilities.isRightMouseButton(evt)) { |
|
|
|
JPopupMenu popupMenu = new JPopupMenu(); |
|
|
|
JPopupMenu popupMenu = new JPopupMenu(); |
|
|
|
LookDetailAction lookDetailAction = new LookDetailAction(); |
|
|
|
LookDetailAction lookDetailAction = new LookDetailAction(); |
|
|
@ -665,24 +674,28 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// vairable.
|
|
|
|
private void initFunctionNameList(JPanel functionPane){ |
|
|
|
variablesTree = new JTree(); |
|
|
|
functionNameList = new JList(new DefaultListModel()); |
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|
UIScrollPane functionNameScrollPane = new UIScrollPane(functionNameList); |
|
|
|
variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
functionNameScrollPane.setPreferredSize(new Dimension(140, 200)); |
|
|
|
this.add(this.createNamePane( |
|
|
|
functionPane.add( |
|
|
|
Inter.getLocText("Variables") + ":", variablesTreePane), BorderLayout.CENTER); |
|
|
|
this.createNamePane(Inter.getLocText("FormulaD-Function_name") + ":", functionNameScrollPane), |
|
|
|
variablesTree.setRootVisible(false); |
|
|
|
BorderLayout.CENTER); |
|
|
|
variablesTree.setShowsRootHandles(true); |
|
|
|
functionNameScrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
variablesTree.addMouseListener(applyTextMouseListener); |
|
|
|
initFunctionNameListCellRenderer(); |
|
|
|
variablesTree.setCellRenderer(applyTreeCellRenderer); |
|
|
|
initFunctionNameListSelectionListener(); |
|
|
|
|
|
|
|
initFunctionNameListMouseListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initDescriptionTextArea(){ |
|
|
|
// Description
|
|
|
|
// Description
|
|
|
|
descriptionTextArea = new UITextArea(16, 27); |
|
|
|
descriptionTextArea = new UITextArea(16, 27); |
|
|
|
|
|
|
|
|
|
|
|
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea); |
|
|
|
UIScrollPane desScrollPane = new UIScrollPane(descriptionTextArea); |
|
|
|
desScrollPane.setBorder(null); |
|
|
|
desScrollPane.setBorder(null); |
|
|
|
this.add(this.createNamePane(Inter.getLocText("Formula_Description") + ":", desScrollPane), BorderLayout.EAST); |
|
|
|
this.add(this.createNamePane(Inter.getLocText("FR-Designer_FormulaPane_Formula_Description") + ":", desScrollPane), BorderLayout.EAST); |
|
|
|
descriptionTextArea.setBackground(new Color(255, 255, 225)); |
|
|
|
descriptionTextArea.setBackground(new Color(255, 255, 225)); |
|
|
|
descriptionTextArea.setLineWrap(true); |
|
|
|
descriptionTextArea.setLineWrap(true); |
|
|
|
descriptionTextArea.setWrapStyleWord(true); |
|
|
|
descriptionTextArea.setWrapStyleWord(true); |
|
|
@ -696,63 +709,84 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
variablesTree.addTreeSelectionListener(new TreeSelectionListener() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void valueChanged(TreeSelectionEvent e) { |
|
|
|
|
|
|
|
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); |
|
|
|
|
|
|
|
if (selectedValue == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
StringBuilder desBuf = new StringBuilder(); |
|
|
|
private StringBuilder getText(TextUserObject selectedValue,String path) throws IOException{ |
|
|
|
try { |
|
|
|
|
|
|
|
Reader desReader; |
|
|
|
Reader desReader; |
|
|
|
String path; |
|
|
|
StringBuilder desBuf = new StringBuilder(); |
|
|
|
|
|
|
|
InputStream desInputStream = BaseUtils.readResource(path+ ((TextUserObject) selectedValue).displayText+".txt"); |
|
|
|
Locale locale = FRContext.getLocale(); |
|
|
|
|
|
|
|
if (locale.equals(Locale.CHINA)) { |
|
|
|
|
|
|
|
path = "/com/fr/design/insert/formula/variable/cn/"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
path = "/com/fr/design/insert/formula/variable/en/"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectedValue instanceof TextUserObject) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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( |
|
|
|
desReader = new InputStreamReader(desInputStream); |
|
|
|
desInputStream); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
BufferedReader reader = new BufferedReader(desReader); |
|
|
|
BufferedReader reader = new BufferedReader( |
|
|
|
|
|
|
|
desReader); |
|
|
|
|
|
|
|
String lineText; |
|
|
|
String lineText; |
|
|
|
while ((lineText = reader.readLine()) != null) { |
|
|
|
while ((lineText = reader.readLine()) != null) { |
|
|
|
if (desBuf.length() > 0) { |
|
|
|
if (desBuf.length() > 0) { |
|
|
|
desBuf.append('\n'); |
|
|
|
desBuf.append('\n'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
desBuf.append(lineText); |
|
|
|
desBuf.append(lineText); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
reader.close(); |
|
|
|
reader.close(); |
|
|
|
desReader.close(); |
|
|
|
desReader.close(); |
|
|
|
|
|
|
|
return desBuf; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initVariablesTreeSelectionListener(){ |
|
|
|
|
|
|
|
variablesTree.addTreeSelectionListener(new TreeSelectionListener() { |
|
|
|
|
|
|
|
public void valueChanged(TreeSelectionEvent e) { |
|
|
|
|
|
|
|
Object selectedValue = ((DefaultMutableTreeNode) variablesTree.getLastSelectedPathComponent()).getUserObject(); |
|
|
|
|
|
|
|
if (selectedValue == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
StringBuilder desBuf = new StringBuilder(); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String path; |
|
|
|
|
|
|
|
Locale locale = FRContext.getLocale(); |
|
|
|
|
|
|
|
if (locale.equals(Locale.CHINA)) { |
|
|
|
|
|
|
|
path = "/com/fr/design/insert/formula/variable/cn/"; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
path = "/com/fr/design/insert/formula/variable/en/"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (selectedValue instanceof TextUserObject) { |
|
|
|
|
|
|
|
desBuf = getText((TextUserObject)selectedValue,path); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException exp) { |
|
|
|
} catch (IOException exp) { |
|
|
|
FRContext.getLogger().error(exp.getMessage(), exp); |
|
|
|
FRContext.getLogger().error(exp.getMessage(), exp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
descriptionTextArea.setText(desBuf.toString()); |
|
|
|
descriptionTextArea.setText(desBuf.toString()); |
|
|
|
|
|
|
|
|
|
|
|
descriptionTextArea.moveCaretPosition(0); |
|
|
|
descriptionTextArea.moveCaretPosition(0); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initVariablesTree(){ |
|
|
|
|
|
|
|
// vairable.
|
|
|
|
|
|
|
|
variablesTree = new JTree(); |
|
|
|
|
|
|
|
UIScrollPane variablesTreePane = new UIScrollPane(variablesTree); |
|
|
|
|
|
|
|
variablesTreePane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC)); |
|
|
|
|
|
|
|
this.add(this.createNamePane( |
|
|
|
|
|
|
|
Inter.getLocText("FR-Designer_FormulaPane_Variables") + ":", variablesTreePane), BorderLayout.CENTER); |
|
|
|
|
|
|
|
variablesTree.setRootVisible(false); |
|
|
|
|
|
|
|
variablesTree.setShowsRootHandles(true); |
|
|
|
|
|
|
|
variablesTree.addMouseListener(applyTextMouseListener); |
|
|
|
|
|
|
|
variablesTree.setCellRenderer(applyTreeCellRenderer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initDescriptionTextArea(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initVariablesTreeSelectionListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
|
|
|
|
this.setLayout(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
// Function
|
|
|
|
|
|
|
|
JPanel functionPane = new JPanel(new BorderLayout(4, 4)); |
|
|
|
|
|
|
|
this.add(functionPane, BorderLayout.WEST); |
|
|
|
|
|
|
|
initFunctionTypeList(functionPane); |
|
|
|
|
|
|
|
initFunctionNameList(functionPane); |
|
|
|
|
|
|
|
initVariablesTree(); |
|
|
|
// 选择:
|
|
|
|
// 选择:
|
|
|
|
functionTypeList.setSelectedIndex(0); |
|
|
|
functionTypeList.setSelectedIndex(0); |
|
|
|
} |
|
|
|
} |
|
|
@ -763,7 +797,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
private class LookDetailAction extends UpdateAction { |
|
|
|
private class LookDetailAction extends UpdateAction { |
|
|
|
|
|
|
|
|
|
|
|
public LookDetailAction() { |
|
|
|
public LookDetailAction() { |
|
|
|
this.setName(Inter.getLocText("Function_Detail")); |
|
|
|
this.setName(Inter.getLocText("FR-Designer_FormulaPane_Function_Detail")); |
|
|
|
this.setMnemonic('L'); |
|
|
|
this.setMnemonic('L'); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
|
|
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png")); |
|
|
|
} |
|
|
|
} |
|
|
@ -778,7 +812,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
BasicPane basicPane = new BasicPane() { |
|
|
|
BasicPane basicPane = new BasicPane() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return Inter.getLocText("Function_Detail"); |
|
|
|
return Inter.getLocText("FR-Designer_FormulaPane_Function_Detail"); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
basicPane.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
basicPane.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
@ -869,52 +903,28 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
rootNode.add(bindCellNode); |
|
|
|
rootNode.add(bindCellNode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
rootNode.add(new TextFolderUserObject(Inter.getLocText("FormulaD-Data_Fields"), |
|
|
|
MutableTreeNode tableTreeNode = new TextFolderUserObject( |
|
|
|
|
|
|
|
Inter.getLocText("FormulaD-Data_Fields"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"), |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/table.png"), |
|
|
|
variableResolver.resolveColumnNames()).createMutableTreeNode(); |
|
|
|
variableResolver.resolveColumnNames()).createMutableTreeNode()); |
|
|
|
|
|
|
|
|
|
|
|
rootNode.add(tableTreeNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Set cutReport Variable
|
|
|
|
// Set cutReport Variable
|
|
|
|
rootNode.add(new TextFolderUserObject( |
|
|
|
rootNode.add(new TextFolderUserObject(Inter.getLocText("FR-Designer_FormulaPane_Variables"), |
|
|
|
Inter.getLocText("Variables"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"), |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/variable.png"), |
|
|
|
variableResolver.resolveCurReportVariables()).createMutableTreeNode()); |
|
|
|
variableResolver.resolveCurReportVariables()).createMutableTreeNode()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
rootNode.add(new TextFolderUserObject(Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}), |
|
|
|
rootNode.add(new TextFolderUserObject( |
|
|
|
|
|
|
|
Inter.getLocText(new String[]{"Datasource-Datasource", "Parameter"}), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"), |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"), |
|
|
|
variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode()); |
|
|
|
variableResolver.resolveTableDataParameterVariables()).createMutableTreeNode()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
rootNode.add(new TextFolderUserObject(Inter.getLocText("ParameterD-Report_Parameter"), |
|
|
|
MutableTreeNode reportParameterTreeNode = new TextFolderUserObject( |
|
|
|
|
|
|
|
Inter.getLocText("ParameterD-Report_Parameter"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"), |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/m_report/p.gif"), |
|
|
|
variableResolver.resolveReportParameterVariables()).createMutableTreeNode(); |
|
|
|
variableResolver.resolveReportParameterVariables()).createMutableTreeNode()); |
|
|
|
|
|
|
|
|
|
|
|
rootNode.add(reportParameterTreeNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
rootNode.add(new TextFolderUserObject(Inter.getLocText("M_Server-Global_Parameters"), |
|
|
|
MutableTreeNode globalParameterTreeNode = new TextFolderUserObject( |
|
|
|
|
|
|
|
Inter.getLocText("M_Server-Global_Parameters"), |
|
|
|
|
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"), |
|
|
|
BaseUtils.readIcon("/com/fr/design/images/dialog/parameter.gif"), |
|
|
|
variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode(); |
|
|
|
variableResolver.resolveGlobalParameterVariables()).createMutableTreeNode()); |
|
|
|
rootNode.add(globalParameterTreeNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
variableModel.reload(); |
|
|
|
variableModel.reload(); |
|
|
|
|
|
|
|
|
|
|
|
// Expand
|
|
|
|
// Expand
|
|
|
|
for (int row = 0; row < this.variablesTree.getRowCount(); row++) { |
|
|
|
for (int row = 0; row < this.variablesTree.getRowCount(); row++) { |
|
|
|
this.variablesTree.expandRow(row); |
|
|
|
this.variablesTree.expandRow(row); |
|
|
@ -993,6 +1003,6 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ |
|
|
|
buffer.append("|"); |
|
|
|
buffer.append("|"); |
|
|
|
buffer.append("\n"); |
|
|
|
buffer.append("\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println(buffer.toString()); |
|
|
|
FRContext.getLogger().debug(buffer.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |