|
|
|
@ -3,7 +3,8 @@ package com.fr.quickeditor.cellquick;
|
|
|
|
|
import com.fr.base.Formula; |
|
|
|
|
import com.fr.base.Style; |
|
|
|
|
import com.fr.base.TextFormat; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.gui.itextarea.UITextArea; |
|
|
|
|
import com.fr.grid.GridKeyListener; |
|
|
|
|
import com.fr.grid.selection.CellSelection; |
|
|
|
|
import com.fr.quickeditor.CellQuickEditor; |
|
|
|
|
import com.fr.report.ReportHelper; |
|
|
|
@ -22,12 +23,8 @@ import java.awt.event.KeyEvent;
|
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public class CellStringQuickEditor extends CellQuickEditor { |
|
|
|
|
|
|
|
|
|
//instance
|
|
|
|
|
private static CellStringQuickEditor THIS; |
|
|
|
|
//文本域
|
|
|
|
|
//TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。
|
|
|
|
|
private UITextField stringTextField; |
|
|
|
|
//文本域 直接可以自适应大小
|
|
|
|
|
private UITextArea stringTextArea; |
|
|
|
|
//编辑状态
|
|
|
|
|
private boolean isEditing = false; |
|
|
|
|
|
|
|
|
@ -39,17 +36,17 @@ public class CellStringQuickEditor extends CellQuickEditor {
|
|
|
|
|
private DocumentListener documentListener = new DocumentListener() { |
|
|
|
|
@Override |
|
|
|
|
public void insertUpdate(DocumentEvent e) { |
|
|
|
|
changeReportPaneCell(stringTextField.getText().trim()); |
|
|
|
|
changeReportPaneCell(stringTextArea.getText().trim()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void removeUpdate(DocumentEvent e) { |
|
|
|
|
changeReportPaneCell(stringTextField.getText().trim()); |
|
|
|
|
changeReportPaneCell(stringTextArea.getText().trim()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void changedUpdate(DocumentEvent e) { |
|
|
|
|
changeReportPaneCell(stringTextField.getText().trim()); |
|
|
|
|
changeReportPaneCell(stringTextArea.getText().trim()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
@ -60,22 +57,38 @@ public class CellStringQuickEditor extends CellQuickEditor {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 详细信息面板 |
|
|
|
|
* todo 文本框可自适应大小,公式编辑新写一个 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public JComponent createCenterBody() { |
|
|
|
|
JPanel content = new JPanel(new BorderLayout()); |
|
|
|
|
content.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); |
|
|
|
|
stringTextField = new UITextField(); |
|
|
|
|
stringTextField.addKeyListener(new KeyAdapter() { |
|
|
|
|
stringTextArea = new UITextArea(); |
|
|
|
|
stringTextArea.addKeyListener(new KeyAdapter() { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
if (tc == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
|
//todo yaoh.wu虽然模仿选中单元格按enter可以做到,但是原理没有弄清楚。
|
|
|
|
|
GridKeyListener dispatchListener = new GridKeyListener(tc.getGrid()); |
|
|
|
|
dispatchListener.keyPressed(e); |
|
|
|
|
dispatchListener.keyTyped(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
|
if (tc != null) { |
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
tc.getGrid().dispatchEvent(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
content.add(stringTextField, BorderLayout.CENTER); |
|
|
|
|
content.add(stringTextArea, BorderLayout.CENTER); |
|
|
|
|
return content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -107,7 +120,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
fireTargetModified(); |
|
|
|
|
stringTextField.requestFocus(); |
|
|
|
|
stringTextArea.requestFocus(); |
|
|
|
|
isEditing = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -133,7 +146,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
showText(str); |
|
|
|
|
stringTextField.setEditable(tc.isSelectedOneCell()); |
|
|
|
|
stringTextArea.setEditable(tc.isSelectedOneCell()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -146,9 +159,9 @@ public class CellStringQuickEditor extends CellQuickEditor {
|
|
|
|
|
if (isEditing) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
stringTextField.getDocument().removeDocumentListener(documentListener); |
|
|
|
|
stringTextField.setText(str); |
|
|
|
|
stringTextField.getDocument().addDocumentListener(documentListener); |
|
|
|
|
stringTextArea.getDocument().removeDocumentListener(documentListener); |
|
|
|
|
stringTextArea.setText(str); |
|
|
|
|
stringTextArea.getDocument().addDocumentListener(documentListener); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|