Browse Source

Merge pull request #1055 in BA/design from ~YAOH.WU/design_0407:9.0 to 9.0

* commit '8df5162585355e4458d882b52fa0fda627a8cf4b':
  REPORT-3348 公式快速编辑面板
  REPORT-3348 视觉调整
  REPORT-3348 添加滚动条
  排序公式按钮点击弹出公式编辑器
  REPORT-3348 普通文本编辑器面板
  REPORT-3348 单元格元素数据列,扩展属性补充空白数据设置
  REPORT-3348 jdk7内部类使用外部变量显式声明final
master
superman 7 years ago
parent
commit
58f730618e
  1. 4
      designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java
  2. 4
      designer/src/com/fr/design/module/DesignerModule.java
  3. 128
      designer/src/com/fr/quickeditor/CellQuickEditor.java
  4. 11
      designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java
  5. 40
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  6. 75
      designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java
  7. 12
      designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java
  8. 12
      designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java
  9. 53
      designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java
  10. 12
      designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java

4
designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java

@ -279,8 +279,8 @@ public class SelectedDataColumnPane extends BasicPane {
}); });
} }
private void initWithParameterButton(ElementCasePane casePane, TemplateCellElement cellElement) { private void initWithParameterButton(final ElementCasePane casePane, final TemplateCellElement cellElement) {
SelectedDataColumnPane that = this; final SelectedDataColumnPane that = this;
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel()); editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel());
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting"));
paramButton.addActionListener(new ActionListener() { paramButton.addActionListener(new ActionListener() {

4
designer/src/com/fr/design/module/DesignerModule.java

@ -169,7 +169,7 @@ public class DesignerModule extends DesignModule {
} }
@Override @Override
/** /*
* 针对不同的对象在读取Object对象的xml的时候需要使用不同的对象生成器 * 针对不同的对象在读取Object对象的xml的时候需要使用不同的对象生成器
* @return 返回对象生成器 * @return 返回对象生成器
*/ */
@ -242,7 +242,7 @@ public class DesignerModule extends DesignModule {
} }
@Override @Override
/** /*
* 返回设计器能打开的模板类型的一个数组列表 * 返回设计器能打开的模板类型的一个数组列表
* @return 可以打开的模板类型的数组 * @return 可以打开的模板类型的数组
*/ */

128
designer/src/com/fr/quickeditor/CellQuickEditor.java

@ -4,9 +4,11 @@ import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.MenuKeySet;
@ -21,8 +23,7 @@ import javax.swing.*;
import javax.swing.event.PopupMenuEvent; import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener; import javax.swing.event.PopupMenuListener;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.*;
import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -32,26 +33,78 @@ import java.util.ArrayList;
*/ */
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
/*滚动条相关配置*/
private static final int MAXVALUE = 100;
private static final int TITLE_HEIGHT = 50;
private static final int MOUSE_WHEEL_SPEED = 5;
private static final int CONTENT_PANE_WIDTH_GAP = 4;
private static final int SCROLLBAR_WIDTH = 8;
private int maxHeight = 280;
/*面板配置*/
protected UITextField columnRowTextField; protected UITextField columnRowTextField;
protected TemplateCellElement cellElement; protected TemplateCellElement cellElement;
protected UIComboBox comboBox; private UIComboBox comboBox;
private UpdateAction[] cellInsertActions; private UpdateAction[] cellInsertActions;
private MenuKeySet[] cellInsertActionNames;
private int selectedIndex; private int selectedIndex;
private JPanel leftContentPane;
private UIScrollBar scrollBar;
/*占位label*/
protected static UILabel emptyLabel = new UILabel();
static {
emptyLabel.setPreferredSize(new Dimension(60, 20));
}
public CellQuickEditor() { public CellQuickEditor() {
scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) {
@Override
public int getVisibleAmount() {
int preferredHeight = leftContentPane.getPreferredSize().height;
int e = MAXVALUE * (maxHeight) / preferredHeight;
setVisibleAmount(e);
return e;
}
@Override
public int getMaximum() {
return MAXVALUE;
}
};
scrollBar.addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
doLayout();
}
});
this.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int value = scrollBar.getValue();
value += MOUSE_WHEEL_SPEED * e.getWheelRotation();
scrollBar.setValue(value);
doLayout();
}
});
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {p, f};
double[] rowSize = {p, p}; double[] rowSize = {p, p};
JComponent centerBody = createCenterBody();
centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground()));
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{initTopContent(), null}, new Component[]{initTopContent(), null},
new Component[]{createCenterBody(), null} new Component[]{centerBody, null}
}; };
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); leftContentPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout()); this.setLayout(new BarLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); this.add(scrollBar);
this.add(panel, BorderLayout.CENTER); this.add(leftContentPane);
} }
@ -70,7 +123,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
new Component[]{insertContentLabel, cellElementEditButton}, new Component[]{insertContentLabel, cellElementEditButton},
}; };
JPanel topContent = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel topContent = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
topContent.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); topContent.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
return topContent; return topContent;
} }
@ -100,7 +153,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
for (UpdateAction action : cellInsertActions) { for (UpdateAction action : cellInsertActions) {
arrayList.add(action.getMenuKeySet().getMenuKeySetName()); arrayList.add(action.getMenuKeySet().getMenuKeySetName());
} }
comboBox.setModel(new DefaultComboBoxModel(arrayList.toArray(new String[arrayList.size()]))); comboBox.setModel(new DefaultComboBoxModel<>(arrayList.toArray(new String[arrayList.size()])));
} }
@Override @Override
@ -122,7 +175,7 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
} }
private String[] getDefaultComboBoxItems() { private String[] getDefaultComboBoxItems() {
cellInsertActionNames = ActionFactory.createCellInsertActionName(); MenuKeySet[] cellInsertActionNames = ActionFactory.createCellInsertActionName();
ArrayList<String> names = new ArrayList<>(); ArrayList<String> names = new ArrayList<>();
for (MenuKeySet cellInsertActionName : cellInsertActionNames) { for (MenuKeySet cellInsertActionName : cellInsertActionNames) {
names.add(cellInsertActionName.getMenuKeySetName()); names.add(cellInsertActionName.getMenuKeySetName());
@ -197,4 +250,55 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
* 刷新详细信息 * 刷新详细信息
*/ */
protected abstract void refreshDetails(); protected abstract void refreshDetails();
/**
* 属性面板的滚动条和内容区域的布局管理类
* yaoh.wu 由于这边不能继承{@link com.fr.design.mainframe.AbstractAttrPane.BarLayout}所以冗余了一份滚动条代码进来
*
* @see com.fr.design.mainframe.AbstractAttrPane.BarLayout
*/
protected class BarLayout implements LayoutManager {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return leftContentPane.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return leftContentPane.getMinimumSize();
}
@Override
public void layoutContainer(Container parent) {
maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT;
int beginY;
if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) {
beginY = 0;
} else {
int preferredHeight = leftContentPane.getPreferredSize().height;
int value = scrollBar.getValue();
beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount());
}
int width = parent.getWidth();
int height = parent.getHeight();
if (leftContentPane.getPreferredSize().height > maxHeight) {
leftContentPane.setBounds(0, -beginY, width - scrollBar.getWidth() - CONTENT_PANE_WIDTH_GAP, height + beginY);
scrollBar.setBounds(width - scrollBar.getWidth() - 1, 0, scrollBar.getWidth(), height);
} else {
leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height);
}
leftContentPane.validate();
}
}
} }

11
designer/src/com/fr/quickeditor/cellquick/CellBiasTextPainterEditor.java

@ -5,9 +5,10 @@ import com.fr.design.actions.insert.cell.BiasCellAction;
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.painter.BiasTextPainter; import com.fr.report.cell.painter.BiasTextPainter;
@ -25,8 +26,7 @@ public class CellBiasTextPainterEditor extends CellQuickEditor {
@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)); UIButton editButton = new UIButton(Inter.getLocText("Edit"));
UIButton editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon("/com/fr/design/images/m_insert/bias.png"));
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -34,7 +34,10 @@ public class CellBiasTextPainterEditor extends CellQuickEditor {
} }
}); });
editButton.setOpaque(false); editButton.setOpaque(false);
content.add(editButton, BorderLayout.CENTER); content.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{emptyLabel, editButton}},
new double[]{TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.FILL}), BorderLayout.CENTER);
return content; return content;
} }

40
designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -135,7 +135,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
String[] iconArray = new String[paneList.size()]; String[] iconArray = new String[paneList.size()];
card = new CardLayout(); card = new CardLayout();
cardContainer = new JPanel(card); cardContainer = new JPanel(card);
cardContainer.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
for (int i = 0; i < paneList.size(); i++) { for (int i = 0; i < paneList.size(); i++) {
CellEditorPane pane = paneList.get(i); CellEditorPane pane = paneList.get(i);
iconArray[i] = pane.getIconPath(); iconArray[i] = pane.getIconPath();
@ -227,9 +226,8 @@ public class CellDSColumnEditor extends CellQuickEditor {
new Component[]{uiLabel, uiButton} new Component[]{uiLabel, uiButton}
}; };
conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.add(this.createContentPane(), BorderLayout.CENTER); this.add(this.createContentPane(), BorderLayout.CENTER);
this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
} }
@ -281,8 +279,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
class DSColumnAdvancedEditorPane extends CellEditorPane { class DSColumnAdvancedEditorPane extends CellEditorPane {
private static final String INSET_TEXT = " ";
//排列顺序 //排列顺序
private ResultSetSortConfigPane sortPane; private ResultSetSortConfigPane sortPane;
//结果集筛选 //结果集筛选
@ -295,14 +291,16 @@ public class CellDSColumnEditor extends CellQuickEditor {
private UICheckBox veCheckBox; private UICheckBox veCheckBox;
//补充空白数据 //补充空白数据
private UICheckBox useMultiplyNumCheckBox; private UICheckBox useMultiplyNumCheckBox;
//补充空白数据目输入框 //补充空白数据目输入框
private UISpinner multiNumSpinner; private UISpinner multiNumSpinner;
//补充空白数据数目面板 可隐藏
private JPanel multiPane;
public DSColumnAdvancedEditorPane() { public DSColumnAdvancedEditorPane() {
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(this.createContentPane(), BorderLayout.CENTER); this.add(this.createContentPane(), BorderLayout.CENTER);
this.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15)); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
} }
@ -325,13 +323,11 @@ public class CellDSColumnEditor extends CellQuickEditor {
filterPane.update(cellElement); filterPane.update(cellElement);
//更新单元格扩展属性 //更新单元格扩展属性
updateExtendConfig(); updateExtendConfig();
//更新补充空白设置 //更新补充空白设置
updateMultipleConfig(); updateMultipleConfig();
} }
} }
@SuppressWarnings("Duplicates")
@Override @Override
public void populate() { public void populate() {
if (cellElement != null) { if (cellElement != null) {
@ -375,7 +371,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
/** /**
* 更新单元格扩展属性 * 更新单元格扩展属性
*/ */
@SuppressWarnings("Duplicates")
private void updateExtendConfig() { private void updateExtendConfig() {
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();
if (cellExpandAttr == null) { if (cellExpandAttr == null) {
@ -460,7 +455,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
}); });
//可扩展性 //可扩展性
JPanel extendableDirectionPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
extendableDirectionPane.add(heCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable"))); extendableDirectionPane.add(heCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Horizontal_Extendable")));
extendableDirectionPane.add(veCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable"))); extendableDirectionPane.add(veCheckBox = new UICheckBox(Inter.getLocText("ExpandD-Vertical_Extendable")));
heCheckBox.addChangeListener(new ChangeListener() { heCheckBox.addChangeListener(new ChangeListener() {
@ -478,13 +473,23 @@ public class CellDSColumnEditor extends CellQuickEditor {
} }
}); });
JPanel multiNumPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
//补充空白数据 //补充空白数据
JPanel multiNumPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Fill_blank_Data"));
useMultiplyNumCheckBox = new UICheckBox(Inter.getLocText("Column_Multiple")); JPanel checkBoxPane = new JPanel(new BorderLayout());
multiNumPane.add(useMultiplyNumCheckBox); checkBoxPane.add(useMultiplyNumCheckBox, BorderLayout.WEST);
multiNumPane.add(new UILabel(INSET_TEXT)); multiNumPane.add(checkBoxPane);
multiNumSpinner = new UISpinner(1, 10000, 1, 1); multiNumSpinner = new UISpinner(1, 10000, 1, 1);
multiNumPane.add(multiNumSpinner); //数据倍数
UILabel multipleLabel = new UILabel(Inter.getLocText("Column_Multiple"));
multipleLabel.setPreferredSize(new Dimension(60, 20));
multiPane = TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{
multipleLabel, multiNumSpinner
}
}, new double[]{P}, new double[]{P, F}
);
multiNumPane.add(multiPane);
useMultiplyNumCheckBox.addActionListener(new ActionListener() { useMultiplyNumCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
checkButtonEnabled(); checkButtonEnabled();
@ -518,8 +523,10 @@ public class CellDSColumnEditor extends CellQuickEditor {
private void checkButtonEnabled() { private void checkButtonEnabled() {
if (useMultiplyNumCheckBox.isSelected()) { if (useMultiplyNumCheckBox.isSelected()) {
multiNumSpinner.setEnabled(true); multiNumSpinner.setEnabled(true);
multiPane.setVisible(true);
} else { } else {
multiNumSpinner.setEnabled(false); multiNumSpinner.setEnabled(false);
multiPane.setVisible(false);
} }
} }
@ -588,6 +595,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (cellElement != null) { if (cellElement != null) {
Object value = cellElement.getValue(); Object value = cellElement.getValue();
if (value != null && value instanceof DSColumn) { if (value != null && value instanceof DSColumn) {
this.formulaField.populateElement(cellElement);
DSColumn dSColumn = (DSColumn) value; DSColumn dSColumn = (DSColumn) value;
int sort = dSColumn.getOrder(); int sort = dSColumn.getOrder();
this.sortTypePane.setSelectedIndex(sort); this.sortTypePane.setSelectedIndex(sort);

75
designer/src/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -5,7 +5,16 @@ import com.fr.base.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.FormulaCellAction; 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.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
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;
@ -17,6 +26,8 @@ import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -29,7 +40,7 @@ import java.awt.event.KeyEvent;
*/ */
public class CellFormulaQuickEditor extends CellQuickEditor { public class CellFormulaQuickEditor extends CellQuickEditor {
//文本域 //文本域
private UITextField stringTextField; private UITextField formulaTextField;
//编辑状态 //编辑状态
private boolean isEditing = false; private boolean isEditing = false;
@ -37,20 +48,23 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
private boolean reserveInResult = false; private boolean reserveInResult = false;
private boolean reserveOnWriteOrAnaly = true; private boolean reserveOnWriteOrAnaly = true;
//默认值
private static final String DEFAULT_FORMULA = "=";
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(formulaTextField.getText().trim());
} }
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim()); changeReportPaneCell(formulaTextField.getText().trim());
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
changeReportPaneCell(stringTextField.getText().trim()); changeReportPaneCell(formulaTextField.getText().trim());
} }
}; };
@ -65,9 +79,8 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
@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)); formulaTextField = new UITextField();
stringTextField = new UITextField(); formulaTextField.addKeyListener(new KeyAdapter() {
stringTextField.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
if (tc != null) { if (tc != null) {
@ -75,8 +88,42 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
} }
} }
}); });
content.add(stringTextField, BorderLayout.CENTER); JPanel textFieldPane = new JPanel(new BorderLayout());
return content; textFieldPane.add(formulaTextField, BorderLayout.CENTER);
textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png"));
formulaButton.setToolTipText(Inter.getLocText("Formula") + "...");
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String text = formulaTextField.getText();
final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(new Formula(text));
formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
Formula fm = formulaPane.update();
if (fm.getContent().length() <= 1) {
formulaTextField.setText(DEFAULT_FORMULA);
} else {
formulaTextField.setText(fm.getContent());
}
}
}).setVisible(true);
}
});
JPanel pane = new JPanel(new BorderLayout());
pane.add(textFieldPane, BorderLayout.CENTER);
pane.add(formulaButton, BorderLayout.EAST);
content.add(pane, BorderLayout.NORTH);
return TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{emptyLabel, content}},
new double[]{TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.FILL});
} }
@Override @Override
@ -112,7 +159,7 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
} }
} }
fireTargetModified(); fireTargetModified();
stringTextField.requestFocus(); formulaTextField.requestFocus();
isEditing = false; isEditing = false;
} }
@ -138,7 +185,7 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
} }
} }
showText(str); showText(str);
stringTextField.setEditable(tc.isSelectedOneCell()); formulaTextField.setEditable(tc.isSelectedOneCell());
} }
/** /**
@ -151,9 +198,9 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
if (isEditing) { if (isEditing) {
return; return;
} }
stringTextField.getDocument().removeDocumentListener(documentListener); formulaTextField.getDocument().removeDocumentListener(documentListener);
stringTextField.setText(str); formulaTextField.setText(str);
stringTextField.getDocument().addDocumentListener(documentListener); formulaTextField.getDocument().addDocumentListener(documentListener);
} }
} }

12
designer/src/com/fr/quickeditor/cellquick/CellImageQuickEditor.java

@ -5,10 +5,11 @@ import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.actions.insert.cell.ImageCellAction;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.report.SelectImagePane; import com.fr.design.report.SelectImagePane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.cellattr.CellImage;
@ -33,8 +34,7 @@ public class CellImageQuickEditor extends CellQuickEditor {
@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)); UIButton editButton = new UIButton(Inter.getLocText("Edit"));
UIButton editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon("/com/fr/design/images/m_insert/image.png"));
editButton.addActionListener(new ActionListener() { editButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -42,11 +42,13 @@ public class CellImageQuickEditor extends CellQuickEditor {
} }
}); });
editButton.setOpaque(false); editButton.setOpaque(false);
content.add(editButton, BorderLayout.CENTER); content.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{emptyLabel, editButton}},
new double[]{TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.FILL}), BorderLayout.CENTER);
return content; return content;
} }
@SuppressWarnings("Duplicates")
private void showEditingDialog() { private void showEditingDialog() {
final SelectImagePane imageEditorPane = new SelectImagePane(); final SelectImagePane imageEditorPane = new SelectImagePane();
imageEditorPane.populate(cellElement); imageEditorPane.populate(cellElement);

12
designer/src/com/fr/quickeditor/cellquick/CellRichTextEditor.java

@ -3,6 +3,8 @@ package com.fr.quickeditor.cellquick;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
@ -22,14 +24,15 @@ public class CellRichTextEditor extends CellQuickEditor {
super(); super();
} }
@SuppressWarnings("Duplicates")
@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));
richTextButton = new UIButton(); richTextButton = new UIButton();
richTextButton.setOpaque(false); richTextButton.setOpaque(false);
content.add(richTextButton, BorderLayout.CENTER); content.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{emptyLabel, richTextButton}},
new double[]{TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.FILL}), BorderLayout.CENTER);
return content; return content;
} }
@ -41,7 +44,8 @@ public class CellRichTextEditor extends CellQuickEditor {
@Override @Override
protected void refreshDetails() { protected void refreshDetails() {
RichTextCellAction subReportCellAction = new RichTextCellAction(tc); RichTextCellAction subReportCellAction = new RichTextCellAction(tc);
subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); subReportCellAction.setName(Inter.getLocText("Edit"));
subReportCellAction.setSmallIcon(null);
richTextButton.setAction(subReportCellAction); richTextButton.setAction(subReportCellAction);
} }

53
designer/src/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

@ -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,16 +23,11 @@ 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;
//august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。 //august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。
private boolean reserveInResult = false; private boolean reserveInResult = false;
private boolean reserveOnWriteOrAnaly = true; private boolean reserveOnWriteOrAnaly = true;
@ -39,17 +35,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 +56,37 @@ 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)); stringTextArea = new UITextArea();
stringTextField = new UITextField(); stringTextArea.addKeyListener(new KeyAdapter() {
stringTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (tc == null) {
return;
}
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
//todo 按enter键换至下一个单元格 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 +118,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
} }
} }
fireTargetModified(); fireTargetModified();
stringTextField.requestFocus(); stringTextArea.requestFocus();
isEditing = false; isEditing = false;
} }
@ -133,7 +144,7 @@ public class CellStringQuickEditor extends CellQuickEditor {
} }
} }
showText(str); showText(str);
stringTextField.setEditable(tc.isSelectedOneCell()); stringTextArea.setEditable(tc.isSelectedOneCell());
} }
/** /**
@ -146,9 +157,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

12
designer/src/com/fr/quickeditor/cellquick/CellSubReportEditor.java

@ -3,6 +3,8 @@ package com.fr.quickeditor.cellquick;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.actions.insert.cell.SubReportCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
@ -23,21 +25,23 @@ public class CellSubReportEditor extends CellQuickEditor {
super(); super();
} }
@SuppressWarnings("Duplicates")
@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));
subReportButton = new UIButton(); subReportButton = new UIButton();
subReportButton.setOpaque(false); subReportButton.setOpaque(false);
content.add(subReportButton, BorderLayout.CENTER); content.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
new Component[]{emptyLabel, subReportButton}},
new double[]{TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.FILL}), BorderLayout.CENTER);
return content; return content;
} }
@Override @Override
protected void refreshDetails() { protected void refreshDetails() {
SubReportCellAction subReportCellAction = new SubReportCellAction(tc); SubReportCellAction subReportCellAction = new SubReportCellAction(tc);
subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); subReportCellAction.setName(Inter.getLocText("Edit"));
subReportCellAction.setSmallIcon(null);
subReportButton.setAction(subReportCellAction); subReportButton.setAction(subReportCellAction);
} }

Loading…
Cancel
Save