|
|
|
@ -8,8 +8,11 @@ import com.fr.design.actions.insert.cell.FormulaCellAction;
|
|
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
|
import com.fr.design.formula.FormulaFactory; |
|
|
|
|
import com.fr.design.formula.UIFormula; |
|
|
|
|
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
|
|
|
|
import com.fr.design.gui.frpane.AttributeChangeListener; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
import com.fr.design.gui.style.TextFormatPane; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
@ -35,6 +38,7 @@ import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 公式快速编辑面板,同文本数字编辑拆分 |
|
|
|
@ -46,6 +50,7 @@ import java.awt.event.KeyEvent;
|
|
|
|
|
public class CellFormulaQuickEditor extends CellQuickEditor { |
|
|
|
|
//文本域
|
|
|
|
|
private UITextField formulaTextField; |
|
|
|
|
private TextFormatPane formatPane; |
|
|
|
|
//编辑状态
|
|
|
|
|
private boolean isEditing = false; |
|
|
|
|
|
|
|
|
@ -136,10 +141,59 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
|
|
|
|
|
pane.add(formulaButton, BorderLayout.EAST); |
|
|
|
|
|
|
|
|
|
content.add(pane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
Component[][] componentLines = new Component[][] { |
|
|
|
|
new Component[]{EMPTY_LABEL, content}, |
|
|
|
|
new Component[]{createFormatPane(), null}, |
|
|
|
|
}; |
|
|
|
|
double[] rowSize = new double[componentLines.length]; |
|
|
|
|
Arrays.fill(rowSize, TableLayout.PREFERRED); |
|
|
|
|
double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL }; |
|
|
|
|
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ |
|
|
|
|
new Component[]{EMPTY_LABEL, content}}, |
|
|
|
|
new double[]{TableLayout.PREFERRED}, |
|
|
|
|
new double[]{TableLayout.PREFERRED, TableLayout.FILL}, HGAP, VGAP); |
|
|
|
|
new Component[]{EMPTY_LABEL, content}, |
|
|
|
|
new Component[]{createFormatPane(), null}, |
|
|
|
|
}, |
|
|
|
|
rowSize, columnSize, HGAP, VGAP); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private JPanel createFormatPane() { |
|
|
|
|
formatPane = new TextFormatPane(); |
|
|
|
|
AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() { |
|
|
|
|
@Override |
|
|
|
|
protected JPanel createContentPane() { |
|
|
|
|
return formatPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initContentPane() { |
|
|
|
|
leftContentPane = createContentPane(); |
|
|
|
|
if (leftContentPane != null) { |
|
|
|
|
leftContentPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
|
|
this.add(leftContentPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
container.addAttributeChangeListener(new AttributeChangeListener() { |
|
|
|
|
@Override |
|
|
|
|
public void attributeChange() { |
|
|
|
|
isEditing = true; |
|
|
|
|
|
|
|
|
|
CellSelection cs1 = (CellSelection) tc.getSelection(); |
|
|
|
|
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); |
|
|
|
|
|
|
|
|
|
if (cellElement == null) { |
|
|
|
|
CellSelection cs = (CellSelection) tc.getSelection(); |
|
|
|
|
cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow()); |
|
|
|
|
tc.getEditingElementCase().addCellElement(cellElement, false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cellElement.setStyle(formatPane.update(cellElement.getStyle())); |
|
|
|
|
|
|
|
|
|
fireTargetModified(); |
|
|
|
|
isEditing = false; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return container; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -202,6 +256,11 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
|
|
|
|
|
} |
|
|
|
|
showText(str); |
|
|
|
|
formulaTextField.setEditable(tc.isSelectedOneCell()); |
|
|
|
|
|
|
|
|
|
if (cellElement != null) { |
|
|
|
|
Style style = cellElement.getStyle(); |
|
|
|
|
formatPane.populateBean(style); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|