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