Browse Source

REPORT-31546 公式面板的说明切换偶尔会失效

feature/big-screen
Henry.Wang 4 years ago
parent
commit
9a0b3023a0
  1. 83
      designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

83
designer-base/src/main/java/com/fr/design/formula/FormulaPane.java

@ -246,44 +246,69 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula {
}
public class DoubleClick extends MouseAdapter {
String singlePressContent;
String doublePressContent;
@Override
public void mousePressed(MouseEvent e) {
int index = tipsList.getSelectedIndex();
if (index != -1) {
if (e.getClickCount() == 1) {
singlePressContent = (String) listModel.getElementAt(index);
} else if (e.getClickCount() == 2) {
doublePressContent = (String) listModel.getElementAt(index);
}
}
}
@Override
public void mouseClicked(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
int index = tipsList.getSelectedIndex();
if (index != -1) {
String currentLineContent = (String) listModel.getElementAt(index);
if (e.getClickCount() == 2) {
if (ifHasBeenWriten == 0) {
formulaTextArea.setForeground(Color.black);
formulaTextArea.setText("");
if (e.getClickCount() == 1) {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), singlePressContent)) {
singleClickActuator(singlePressContent);
}
formulaTextArea.setForeground(Color.black);
currentPosition = formulaTextArea.getCaretPosition();
String output = currentLineContent + "()";
String textAll = formulaTextArea.getText();
String textReplaced;
int position = 0;
if (insertPosition <= currentPosition) {
textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition);
position = insertPosition + output.length() - 1;
} else {
textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition);
position = currentPosition + output.length() - 1;
} else if (e.getClickCount() == 2) {
if (ComparatorUtils.equals((String) listModel.getElementAt(index), doublePressContent)) {
doubleClickActuator(doublePressContent);
}
formulaTextArea.setText(textReplaced);
formulaTextArea.requestFocusInWindow();
formulaTextArea.setCaretPosition(position);
insertPosition = position;
ifHasBeenWriten = 1;
listModel.removeAllElements();
} else if (e.getClickCount() == 1) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
}
}
private void singleClickActuator(String currentLineContent) {
refreshDescriptionTextArea(currentLineContent);
formulaTextArea.requestFocusInWindow();
fixFunctionNameList();
}
private void doubleClickActuator(String currentLineContent) {
if (ifHasBeenWriten == 0) {
formulaTextArea.setForeground(Color.black);
formulaTextArea.setText("");
}
formulaTextArea.setForeground(Color.black);
currentPosition = formulaTextArea.getCaretPosition();
String output = currentLineContent + "()";
String textAll = formulaTextArea.getText();
String textReplaced;
int position = 0;
if (insertPosition <= currentPosition) {
textReplaced = textAll.substring(0, insertPosition) + output + textAll.substring(currentPosition);
position = insertPosition + output.length() - 1;
} else {
textReplaced = textAll.substring(0, currentPosition) + output + textAll.substring(insertPosition);
position = currentPosition + output.length() - 1;
}
formulaTextArea.setText(textReplaced);
formulaTextArea.requestFocusInWindow();
formulaTextArea.setCaretPosition(position);
insertPosition = position;
ifHasBeenWriten = 1;
listModel.removeAllElements();
}
}
@Override

Loading…
Cancel
Save