yaoh.wu
7 years ago
9 changed files with 714 additions and 691 deletions
@ -1,247 +1,254 @@
|
||||
package com.fr.design.dscolumn; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.data.SimpleDSColumn; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.design.data.datapane.TableDataComboBox; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||
import com.fr.design.gui.icombobox.LazyComboBox; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.data.TableDataColumn; |
||||
import com.fr.report.cell.CellElement; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.regex.Pattern; |
||||
|
||||
public class SelectedDataColumnPane extends BasicPane { |
||||
protected UITableEditorPane<ParameterProvider> editorPane; |
||||
protected Parameter[] ps; |
||||
|
||||
protected TableDataComboBox tableNameComboBox; |
||||
protected LazyComboBox columnNameComboBox; |
||||
private ItemListener itemListener; |
||||
|
||||
private UIButton paramButton; |
||||
|
||||
public SelectedDataColumnPane() { |
||||
this(true); |
||||
} |
||||
|
||||
public SelectedDataColumnPane(boolean showParameterButton) { |
||||
initComponent(showParameterButton); |
||||
} |
||||
|
||||
/** |
||||
* 初始化组件 |
||||
* |
||||
* @param showParameterButton 是否显示参数按钮 |
||||
* |
||||
*/ |
||||
public void initComponent(boolean showParameterButton) { |
||||
initTableNameComboBox(); |
||||
if (showParameterButton) { |
||||
initWithParameterButton(); |
||||
} |
||||
columnNameComboBox = new LazyComboBox() { |
||||
|
||||
@Override |
||||
public Object[] load() { |
||||
List<String> l = calculateColumnNameList(); |
||||
return l.toArray(new String[l.size()]); |
||||
} |
||||
|
||||
}; |
||||
columnNameComboBox.setEditable(true); |
||||
double p = TableLayout.PREFERRED; |
||||
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); |
||||
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":"); |
||||
if (showParameterButton) { |
||||
label1.setPreferredSize(new Dimension(200, 25)); |
||||
label2.setPreferredSize(new Dimension(200, 25)); |
||||
} |
||||
if (showParameterButton) { |
||||
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; |
||||
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); |
||||
} else { |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {p, f}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{label1, tableNameComboBox}, |
||||
new Component[]{label2, columnNameComboBox} |
||||
}; |
||||
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(jPanel, BorderLayout.CENTER); |
||||
} |
||||
} |
||||
|
||||
protected void initTableNameComboBox() { |
||||
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||
tableNameComboBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
columnNameComboBox.setLoaded(false); |
||||
// columnNameComboBox.loadList();
|
||||
} |
||||
}); |
||||
tableNameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||
} |
||||
|
||||
private void initWithParameterButton() { |
||||
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel()); |
||||
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); |
||||
paramButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
List<ParameterProvider> parameterList = editorPane.update(); |
||||
ps = parameterList.toArray(new Parameter[parameterList.size()]); |
||||
} |
||||
}); |
||||
|
||||
editorPane.populate(ps == null ? new Parameter[0] : ps); |
||||
paramDialog.setVisible(true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "DSColumn"; |
||||
} |
||||
|
||||
public void populate(TableDataSource source, TemplateCellElement cellElement) { |
||||
if (cellElement == null) { |
||||
return; |
||||
} |
||||
|
||||
if (itemListener != null) { |
||||
removeListener(itemListener); |
||||
} |
||||
|
||||
Object value = cellElement.getValue(); |
||||
if (!(value instanceof DSColumn)) { |
||||
return; |
||||
} |
||||
|
||||
DSColumn dsColumn = (DSColumn) value; |
||||
String dsName = dsColumn.getDSName(); |
||||
tableNameComboBox.setSelectedTableDataByName(dsName); |
||||
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn())); |
||||
ps = dsColumn.getParameters(); |
||||
|
||||
addListener(itemListener); |
||||
} |
||||
|
||||
public void update(CellElement cellElement) { |
||||
if (cellElement == null) { |
||||
return; |
||||
} |
||||
Object value = cellElement.getValue(); |
||||
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) { |
||||
return; |
||||
} |
||||
DSColumn dsColumn = null; |
||||
if (value == null || !(value instanceof DSColumn)) { |
||||
dsColumn = new DSColumn(); |
||||
cellElement.setValue(dsColumn); |
||||
} |
||||
dsColumn = (DSColumn) cellElement.getValue(); |
||||
|
||||
SimpleDSColumn simpleDSColumn = updateColumnPane(); |
||||
dsColumn.setDSName(simpleDSColumn.getDsName()); |
||||
dsColumn.setColumn(simpleDSColumn.getColumn()); |
||||
|
||||
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null); |
||||
} |
||||
|
||||
/** |
||||
* 更新面板 |
||||
* |
||||
* @return 更新后的值 |
||||
* |
||||
*/ |
||||
public SimpleDSColumn updateColumnPane() { |
||||
SimpleDSColumn dsColumn = new SimpleDSColumn(); |
||||
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem(); |
||||
if (tableDataWrappe == null) { |
||||
return null; |
||||
} |
||||
dsColumn.setDsName(tableDataWrappe.getTableDataName()); |
||||
TableDataColumn column; |
||||
String columnExp = (String) this.columnNameComboBox.getSelectedItem(); |
||||
if (isColumnName(columnExp)) { |
||||
String number = columnExp.substring(1); |
||||
Pattern pattern = Pattern.compile("[^\\d]"); |
||||
if (pattern.matcher(number).find()) { |
||||
column = TableDataColumn.createColumn(columnExp); |
||||
} else { |
||||
int serialNumber = Integer.parseInt(columnExp.substring(1)); |
||||
column = TableDataColumn.createColumn(serialNumber); |
||||
} |
||||
} else { |
||||
column = TableDataColumn.createColumn(columnExp); |
||||
} |
||||
dsColumn.setColumn(column); |
||||
return dsColumn; |
||||
} |
||||
|
||||
private boolean isColumnName(String columnExp) { |
||||
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 添加监听事件 |
||||
* |
||||
* @param i 监听事件 |
||||
* |
||||
*/ |
||||
public void addListener(ItemListener i) { |
||||
itemListener = i; |
||||
tableNameComboBox.addItemListener(i); |
||||
columnNameComboBox.addItemListener(i); |
||||
} |
||||
|
||||
/** |
||||
* 移除监听事件 |
||||
* |
||||
* @param i 监听事件 |
||||
* |
||||
*/ |
||||
public void removeListener(ItemListener i) { |
||||
tableNameComboBox.removeItemListener(i); |
||||
columnNameComboBox.removeItemListener(i); |
||||
} |
||||
|
||||
private List<String> calculateColumnNameList() { |
||||
if (this.tableNameComboBox.getSelectedItem() != null) { |
||||
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); |
||||
} |
||||
return new ArrayList<String>(); |
||||
} |
||||
package com.fr.design.dscolumn; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.data.SimpleDSColumn; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.TableDataComboBox; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icombobox.LazyComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.Inter; |
||||
import com.fr.general.data.TableDataColumn; |
||||
import com.fr.report.cell.CellElement; |
||||
import com.fr.report.cell.TemplateCellElement; |
||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
||||
import com.fr.stable.ParameterProvider; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.regex.Pattern; |
||||
|
||||
/** |
||||
* 数据集列动态参数设置组件 |
||||
* |
||||
* @author yaoh.wu |
||||
* @version 2017年7月26日 |
||||
* todo 9.0设计器更新,修改动态参数注入按钮部分,使其能在右侧边栏正常显示 |
||||
* @since 8.0 |
||||
*/ |
||||
public class SelectedDataColumnPane extends BasicPane { |
||||
protected UITableEditorPane<ParameterProvider> editorPane; |
||||
protected Parameter[] ps; |
||||
|
||||
protected TableDataComboBox tableNameComboBox; |
||||
protected LazyComboBox columnNameComboBox; |
||||
private ItemListener itemListener; |
||||
|
||||
private UIButton paramButton; |
||||
|
||||
public SelectedDataColumnPane() { |
||||
this(true); |
||||
} |
||||
|
||||
public SelectedDataColumnPane(boolean showParameterButton) { |
||||
initComponent(showParameterButton); |
||||
} |
||||
|
||||
/** |
||||
* 初始化组件 |
||||
* |
||||
* @param showParameterButton 是否显示参数按钮 |
||||
*/ |
||||
public void initComponent(boolean showParameterButton) { |
||||
initTableNameComboBox(); |
||||
if (showParameterButton) { |
||||
initWithParameterButton(); |
||||
} |
||||
columnNameComboBox = new LazyComboBox() { |
||||
|
||||
@Override |
||||
public Object[] load() { |
||||
List<String> l = calculateColumnNameList(); |
||||
return l.toArray(new String[l.size()]); |
||||
} |
||||
|
||||
}; |
||||
columnNameComboBox.setEditable(true); |
||||
double p = TableLayout.PREFERRED; |
||||
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); |
||||
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":"); |
||||
if (showParameterButton) { |
||||
label1.setPreferredSize(new Dimension(200, 25)); |
||||
label2.setPreferredSize(new Dimension(200, 25)); |
||||
} |
||||
if (showParameterButton) { |
||||
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; |
||||
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); |
||||
} else { |
||||
double f = TableLayout.FILL; |
||||
double[] columnSize = {p, f}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{label1, tableNameComboBox}, |
||||
new Component[]{label2, columnNameComboBox} |
||||
}; |
||||
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(jPanel, BorderLayout.CENTER); |
||||
} |
||||
} |
||||
|
||||
|
||||
public void populate(TableDataSource source, TemplateCellElement cellElement) { |
||||
if (cellElement == null) { |
||||
return; |
||||
} |
||||
|
||||
if (itemListener != null) { |
||||
removeListener(itemListener); |
||||
} |
||||
|
||||
Object value = cellElement.getValue(); |
||||
if (!(value instanceof DSColumn)) { |
||||
return; |
||||
} |
||||
|
||||
DSColumn dsColumn = (DSColumn) value; |
||||
String dsName = dsColumn.getDSName(); |
||||
tableNameComboBox.setSelectedTableDataByName(dsName); |
||||
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn())); |
||||
ps = dsColumn.getParameters(); |
||||
|
||||
addListener(itemListener); |
||||
} |
||||
|
||||
public void update(CellElement cellElement) { |
||||
if (cellElement == null) { |
||||
return; |
||||
} |
||||
Object value = cellElement.getValue(); |
||||
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) { |
||||
return; |
||||
} |
||||
DSColumn dsColumn = null; |
||||
if (value == null || !(value instanceof DSColumn)) { |
||||
dsColumn = new DSColumn(); |
||||
cellElement.setValue(dsColumn); |
||||
} |
||||
dsColumn = (DSColumn) cellElement.getValue(); |
||||
|
||||
SimpleDSColumn simpleDSColumn = updateColumnPane(); |
||||
dsColumn.setDSName(simpleDSColumn.getDsName()); |
||||
dsColumn.setColumn(simpleDSColumn.getColumn()); |
||||
|
||||
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null); |
||||
} |
||||
|
||||
/** |
||||
* 更新面板 |
||||
* |
||||
* @return 更新后的值 |
||||
*/ |
||||
public SimpleDSColumn updateColumnPane() { |
||||
SimpleDSColumn dsColumn = new SimpleDSColumn(); |
||||
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem(); |
||||
if (tableDataWrappe == null) { |
||||
return null; |
||||
} |
||||
dsColumn.setDsName(tableDataWrappe.getTableDataName()); |
||||
TableDataColumn column; |
||||
String columnExp = (String) this.columnNameComboBox.getSelectedItem(); |
||||
if (isColumnName(columnExp)) { |
||||
String number = columnExp.substring(1); |
||||
Pattern pattern = Pattern.compile("[^\\d]"); |
||||
if (pattern.matcher(number).find()) { |
||||
column = TableDataColumn.createColumn(columnExp); |
||||
} else { |
||||
int serialNumber = Integer.parseInt(columnExp.substring(1)); |
||||
column = TableDataColumn.createColumn(serialNumber); |
||||
} |
||||
} else { |
||||
column = TableDataColumn.createColumn(columnExp); |
||||
} |
||||
dsColumn.setColumn(column); |
||||
return dsColumn; |
||||
} |
||||
|
||||
/** |
||||
* 添加监听事件 |
||||
* |
||||
* @param i 监听事件 |
||||
*/ |
||||
public void addListener(ItemListener i) { |
||||
itemListener = i; |
||||
tableNameComboBox.addItemListener(i); |
||||
columnNameComboBox.addItemListener(i); |
||||
} |
||||
|
||||
/** |
||||
* 移除监听事件 |
||||
* |
||||
* @param i 监听事件 |
||||
*/ |
||||
public void removeListener(ItemListener i) { |
||||
tableNameComboBox.removeItemListener(i); |
||||
columnNameComboBox.removeItemListener(i); |
||||
} |
||||
|
||||
|
||||
protected void initTableNameComboBox() { |
||||
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||
tableNameComboBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
columnNameComboBox.setLoaded(false); |
||||
} |
||||
}); |
||||
tableNameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "DSColumn"; |
||||
} |
||||
|
||||
|
||||
private void initWithParameterButton() { |
||||
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel()); |
||||
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); |
||||
paramButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
List<ParameterProvider> parameterList = editorPane.update(); |
||||
ps = parameterList.toArray(new Parameter[parameterList.size()]); |
||||
} |
||||
}); |
||||
|
||||
editorPane.populate(ps == null ? new Parameter[0] : ps); |
||||
paramDialog.setVisible(true); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
private boolean isColumnName(String columnExp) { |
||||
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); |
||||
} |
||||
|
||||
|
||||
private List<String> calculateColumnNameList() { |
||||
if (this.tableNameComboBox.getSelectedItem() != null) { |
||||
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); |
||||
} |
||||
return new ArrayList<String>(); |
||||
} |
||||
} |
@ -1,57 +1,57 @@
|
||||
package com.fr.design.mainframe.cell; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.selection.QuickEditor; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* QuickEditorRegion |
||||
* |
||||
* @author zhou, yaoh.wu |
||||
* @version 2017年7月25日 |
||||
* @since 8.0 |
||||
*/ |
||||
|
||||
public class QuickEditorRegion extends JPanel { |
||||
|
||||
|
||||
private static QuickEditorRegion singleton = new QuickEditorRegion(); |
||||
private static JPanel EMPTY; |
||||
|
||||
private QuickEditorRegion() { |
||||
this.setLayout(new BorderLayout()); |
||||
} |
||||
|
||||
public static QuickEditorRegion getInstance() { |
||||
return singleton; |
||||
} |
||||
|
||||
public static JPanel getEmptyEditor() { |
||||
if (EMPTY == null) { |
||||
EMPTY = new JPanel(new BorderLayout()); |
||||
UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); |
||||
content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); |
||||
EMPTY.add(content, BorderLayout.CENTER); |
||||
} |
||||
return EMPTY; |
||||
} |
||||
|
||||
/** |
||||
* 更新面板显示数据 |
||||
* |
||||
* @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 |
||||
*/ |
||||
public void populate(final QuickEditor currentEditor) { |
||||
this.removeAll(); |
||||
if (currentEditor.getComponentCount() == 0) { |
||||
this.add(getEmptyEditor(), BorderLayout.CENTER); |
||||
} else { |
||||
this.add(currentEditor, BorderLayout.CENTER); |
||||
} |
||||
validate(); |
||||
repaint(); |
||||
} |
||||
package com.fr.design.mainframe.cell; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.selection.QuickEditor; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* QuickEditorRegion |
||||
* |
||||
* @author zhou, yaoh.wu |
||||
* @version 2017年7月25日 |
||||
* @since 8.0 |
||||
*/ |
||||
|
||||
public class QuickEditorRegion extends JPanel { |
||||
|
||||
|
||||
private static QuickEditorRegion singleton = new QuickEditorRegion(); |
||||
private static JPanel EMPTY; |
||||
|
||||
private QuickEditorRegion() { |
||||
this.setLayout(new BorderLayout()); |
||||
} |
||||
|
||||
public static QuickEditorRegion getInstance() { |
||||
return singleton; |
||||
} |
||||
|
||||
public static JPanel getEmptyEditor() { |
||||
if (EMPTY == null) { |
||||
EMPTY = new JPanel(new BorderLayout()); |
||||
UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); |
||||
content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); |
||||
EMPTY.add(content, BorderLayout.CENTER); |
||||
} |
||||
return EMPTY; |
||||
} |
||||
|
||||
/** |
||||
* 更新面板显示数据 |
||||
* |
||||
* @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 |
||||
*/ |
||||
public void populate(final QuickEditor currentEditor) { |
||||
this.removeAll(); |
||||
if (currentEditor.getComponentCount() == 0) { |
||||
this.add(getEmptyEditor(), BorderLayout.CENTER); |
||||
} else { |
||||
this.add(currentEditor, BorderLayout.CENTER); |
||||
} |
||||
validate(); |
||||
repaint(); |
||||
} |
||||
} |
@ -1,63 +1,63 @@
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.cell.painter.BiasTextPainter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 单元格元素斜线编辑器 |
||||
* TODO 9.0 大体没有改动 |
||||
*/ |
||||
public class CellBiasTextPainterEditor extends CellQuickEditor { |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
return editbutton; |
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); |
||||
final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); |
||||
biasTextPainterPane.populate(oldbiasTextPainter); |
||||
biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); |
||||
if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { |
||||
cellElement.setValue(newbiasTextPainter); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.cell.painter.BiasTextPainter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 单元格元素斜线编辑器 |
||||
* TODO 9.0 大体没有改动 |
||||
*/ |
||||
public class CellBiasTextPainterEditor extends CellQuickEditor { |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
return editbutton; |
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); |
||||
final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); |
||||
biasTextPainterPane.populate(oldbiasTextPainter); |
||||
biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); |
||||
if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { |
||||
cellElement.setValue(newbiasTextPainter); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
// TODO Auto-generated method stub
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,77 +1,77 @@
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.report.SelectImagePane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 单元格元素图片编辑器 |
||||
* TODO 9.0大体上没有改动 |
||||
*/ |
||||
public class CellImageQuickEditor extends CellQuickEditor { |
||||
private static CellImageQuickEditor THIS; |
||||
|
||||
public static final CellImageQuickEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellImageQuickEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellImageQuickEditor() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
return editbutton; |
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final SelectImagePane imageEditorPane = new SelectImagePane(); |
||||
imageEditorPane.populate(cellElement); |
||||
final Object oldValue = cellElement.getValue(); |
||||
final Style oldStyle = cellElement.getStyle(); |
||||
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
CellImage cellImage = imageEditorPane.update(); |
||||
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
||||
cellElement.setValue(cellImage.getImage()); |
||||
cellElement.setStyle(cellImage.getStyle()); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
|
||||
} |
||||
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.base.Style; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.report.SelectImagePane; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.cell.cellattr.CellImage; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* 单元格元素图片编辑器 |
||||
* TODO 9.0大体上没有改动 |
||||
*/ |
||||
public class CellImageQuickEditor extends CellQuickEditor { |
||||
private static CellImageQuickEditor THIS; |
||||
|
||||
public static final CellImageQuickEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellImageQuickEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellImageQuickEditor() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); |
||||
editbutton.addActionListener(new ActionListener() { |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
showEditingDialog(); |
||||
} |
||||
}); |
||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
editbutton.setMargin(null); |
||||
editbutton.setOpaque(false); |
||||
return editbutton; |
||||
} |
||||
|
||||
private void showEditingDialog() { |
||||
final SelectImagePane imageEditorPane = new SelectImagePane(); |
||||
imageEditorPane.populate(cellElement); |
||||
final Object oldValue = cellElement.getValue(); |
||||
final Style oldStyle = cellElement.getStyle(); |
||||
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
CellImage cellImage = imageEditorPane.update(); |
||||
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
||||
cellElement.setValue(cellImage.getImage()); |
||||
cellElement.setStyle(cellImage.getStyle()); |
||||
fireTargetModified(); |
||||
} |
||||
} |
||||
|
||||
}).setVisible(true); |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
|
||||
} |
||||
|
||||
} |
@ -1,50 +1,50 @@
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.design.actions.insert.cell.RichTextCellAction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* 单元格元素富文本编辑器 |
||||
* TODO 9.0 大体上没有改动 |
||||
*/ |
||||
public class CellRichTextEditor extends CellQuickEditor { |
||||
private UIButton subReportButton; |
||||
private static CellRichTextEditor THIS; |
||||
|
||||
public static final CellRichTextEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellRichTextEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellRichTextEditor() { |
||||
super(); |
||||
} |
||||
|
||||
/** |
||||
* 创建界面上中间的部分 |
||||
* |
||||
* @return 界面元素 |
||||
* @date 2014-12-7-下午9:41:52 |
||||
*/ |
||||
public JComponent createCenterBody() { |
||||
subReportButton = new UIButton(); |
||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
subReportButton.setMargin(null); |
||||
subReportButton.setOpaque(false); |
||||
return subReportButton; |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
RichTextCellAction subReportCellAction = new RichTextCellAction(tc); |
||||
subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); |
||||
subReportButton.setAction(subReportCellAction); |
||||
} |
||||
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.design.actions.insert.cell.RichTextCellAction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* 单元格元素富文本编辑器 |
||||
* TODO 9.0 大体上没有改动 |
||||
*/ |
||||
public class CellRichTextEditor extends CellQuickEditor { |
||||
private UIButton subReportButton; |
||||
private static CellRichTextEditor THIS; |
||||
|
||||
public static final CellRichTextEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellRichTextEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellRichTextEditor() { |
||||
super(); |
||||
} |
||||
|
||||
/** |
||||
* 创建界面上中间的部分 |
||||
* |
||||
* @return 界面元素 |
||||
* @date 2014-12-7-下午9:41:52 |
||||
*/ |
||||
public JComponent createCenterBody() { |
||||
subReportButton = new UIButton(); |
||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
subReportButton.setMargin(null); |
||||
subReportButton.setOpaque(false); |
||||
return subReportButton; |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
RichTextCellAction subReportCellAction = new RichTextCellAction(tc); |
||||
subReportCellAction.setName(Inter.getLocText("FR-Designer_RichTextEditor")); |
||||
subReportButton.setAction(subReportCellAction); |
||||
} |
||||
|
||||
} |
@ -1,155 +1,155 @@
|
||||
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.grid.selection.CellSelection; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.report.cell.DefaultTemplateCellElement; |
||||
import com.fr.stable.ColumnRow; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class CellStringQuickEditor extends CellQuickEditor { |
||||
//instance
|
||||
private static CellStringQuickEditor THIS; |
||||
//文本域
|
||||
//TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。
|
||||
private UITextField stringTextField; |
||||
//编辑状态
|
||||
private boolean isEditing = false; |
||||
|
||||
public static CellStringQuickEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellStringQuickEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
//august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。
|
||||
private boolean reserveInResult = false; |
||||
private boolean reserveOnWriteOrAnaly = true; |
||||
|
||||
private DocumentListener documentListener = new DocumentListener() { |
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
}; |
||||
|
||||
private CellStringQuickEditor() { |
||||
super(); |
||||
} |
||||
|
||||
/** |
||||
* 详细信息面板 |
||||
* todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 |
||||
*/ |
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
stringTextField = new UITextField(); |
||||
stringTextField.addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyReleased(KeyEvent e) { |
||||
if (tc != null) { |
||||
tc.getGrid().dispatchEvent(e); |
||||
} |
||||
} |
||||
}); |
||||
return stringTextField; |
||||
} |
||||
|
||||
|
||||
private void changeReportPaneCell(String tmpText) { |
||||
isEditing = true; |
||||
//refresh一下,如果单元格内有新添加的控件,此时并不知道
|
||||
CellSelection cs1 = (CellSelection) tc.getSelection(); |
||||
ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); |
||||
columnRowTextField.setText(columnRow.toString()); |
||||
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); |
||||
|
||||
if (cellElement == null) { |
||||
CellSelection cs = (CellSelection) tc.getSelection(); |
||||
cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); |
||||
tc.getEditingElementCase().addCellElement(cellElement, false); |
||||
} |
||||
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
||||
Formula textFormula = new Formula(tmpText); |
||||
textFormula.setReserveInResult(reserveInResult); |
||||
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
||||
cellElement.setValue(textFormula); |
||||
} else { |
||||
Style style = cellElement.getStyle(); |
||||
if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
||||
cellElement.setValue(tmpText); |
||||
} else { |
||||
cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
||||
} |
||||
} |
||||
fireTargetModified(); |
||||
stringTextField.requestFocus(); |
||||
isEditing = false; |
||||
} |
||||
|
||||
/** |
||||
* 刷新详细内容 |
||||
*/ |
||||
@Override |
||||
protected void refreshDetails() { |
||||
String str; |
||||
if (cellElement == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else { |
||||
Object value = cellElement.getValue(); |
||||
if (value == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else if (value instanceof Formula) { |
||||
Formula formula = (Formula) value; |
||||
str = formula.getContent(); |
||||
reserveInResult = formula.isReserveInResult(); |
||||
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
||||
} else { |
||||
str = value.toString(); |
||||
} |
||||
} |
||||
showText(str); |
||||
stringTextField.setEditable(tc.isSelectedOneCell()); |
||||
} |
||||
|
||||
/** |
||||
* 显示文本 |
||||
* |
||||
* @param str 文本 |
||||
*/ |
||||
public void showText(String str) { |
||||
// 正在编辑时不处理
|
||||
if (isEditing) { |
||||
return; |
||||
} |
||||
stringTextField.getDocument().removeDocumentListener(documentListener); |
||||
stringTextField.setText(str); |
||||
stringTextField.getDocument().addDocumentListener(documentListener); |
||||
} |
||||
|
||||
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.grid.selection.CellSelection; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
import com.fr.report.ReportHelper; |
||||
import com.fr.report.cell.DefaultTemplateCellElement; |
||||
import com.fr.stable.ColumnRow; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import java.awt.event.KeyAdapter; |
||||
import java.awt.event.KeyEvent; |
||||
|
||||
/** |
||||
* |
||||
*/ |
||||
public class CellStringQuickEditor extends CellQuickEditor { |
||||
//instance
|
||||
private static CellStringQuickEditor THIS; |
||||
//文本域
|
||||
//TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。
|
||||
private UITextField stringTextField; |
||||
//编辑状态
|
||||
private boolean isEditing = false; |
||||
|
||||
public static CellStringQuickEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellStringQuickEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
//august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。
|
||||
private boolean reserveInResult = false; |
||||
private boolean reserveOnWriteOrAnaly = true; |
||||
|
||||
private DocumentListener documentListener = new DocumentListener() { |
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
changeReportPaneCell(stringTextField.getText().trim()); |
||||
} |
||||
|
||||
}; |
||||
|
||||
private CellStringQuickEditor() { |
||||
super(); |
||||
} |
||||
|
||||
/** |
||||
* 详细信息面板 |
||||
* todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 |
||||
*/ |
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
stringTextField = new UITextField(); |
||||
stringTextField.addKeyListener(new KeyAdapter() { |
||||
@Override |
||||
public void keyReleased(KeyEvent e) { |
||||
if (tc != null) { |
||||
tc.getGrid().dispatchEvent(e); |
||||
} |
||||
} |
||||
}); |
||||
return stringTextField; |
||||
} |
||||
|
||||
|
||||
private void changeReportPaneCell(String tmpText) { |
||||
isEditing = true; |
||||
//refresh一下,如果单元格内有新添加的控件,此时并不知道
|
||||
CellSelection cs1 = (CellSelection) tc.getSelection(); |
||||
ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); |
||||
columnRowTextField.setText(columnRow.toString()); |
||||
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); |
||||
|
||||
if (cellElement == null) { |
||||
CellSelection cs = (CellSelection) tc.getSelection(); |
||||
cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); |
||||
tc.getEditingElementCase().addCellElement(cellElement, false); |
||||
} |
||||
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
||||
Formula textFormula = new Formula(tmpText); |
||||
textFormula.setReserveInResult(reserveInResult); |
||||
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
||||
cellElement.setValue(textFormula); |
||||
} else { |
||||
Style style = cellElement.getStyle(); |
||||
if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
||||
cellElement.setValue(tmpText); |
||||
} else { |
||||
cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
||||
} |
||||
} |
||||
fireTargetModified(); |
||||
stringTextField.requestFocus(); |
||||
isEditing = false; |
||||
} |
||||
|
||||
/** |
||||
* 刷新详细内容 |
||||
*/ |
||||
@Override |
||||
protected void refreshDetails() { |
||||
String str; |
||||
if (cellElement == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else { |
||||
Object value = cellElement.getValue(); |
||||
if (value == null) { |
||||
str = StringUtils.EMPTY; |
||||
} else if (value instanceof Formula) { |
||||
Formula formula = (Formula) value; |
||||
str = formula.getContent(); |
||||
reserveInResult = formula.isReserveInResult(); |
||||
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
||||
} else { |
||||
str = value.toString(); |
||||
} |
||||
} |
||||
showText(str); |
||||
stringTextField.setEditable(tc.isSelectedOneCell()); |
||||
} |
||||
|
||||
/** |
||||
* 显示文本 |
||||
* |
||||
* @param str 文本 |
||||
*/ |
||||
public void showText(String str) { |
||||
// 正在编辑时不处理
|
||||
if (isEditing) { |
||||
return; |
||||
} |
||||
stringTextField.getDocument().removeDocumentListener(documentListener); |
||||
stringTextField.setText(str); |
||||
stringTextField.getDocument().addDocumentListener(documentListener); |
||||
} |
||||
|
||||
} |
@ -1,45 +1,45 @@
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.design.actions.insert.cell.SubReportCellAction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* 单元格元素子报表编辑器 |
||||
* TODO 9.0大体上没有改动 |
||||
*/ |
||||
public class CellSubReportEditor extends CellQuickEditor { |
||||
private UIButton subReportButton; |
||||
private static CellSubReportEditor THIS; |
||||
|
||||
public static final CellSubReportEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellSubReportEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellSubReportEditor() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
subReportButton = new UIButton(); |
||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
subReportButton.setMargin(null); |
||||
subReportButton.setOpaque(false); |
||||
return subReportButton; |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
SubReportCellAction subReportCellAction = new SubReportCellAction(tc); |
||||
subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); |
||||
subReportButton.setAction(subReportCellAction); |
||||
} |
||||
|
||||
package com.fr.quickeditor.cellquick; |
||||
|
||||
import com.fr.design.actions.insert.cell.SubReportCellAction; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.general.Inter; |
||||
import com.fr.quickeditor.CellQuickEditor; |
||||
|
||||
import javax.swing.*; |
||||
|
||||
/** |
||||
* 单元格元素子报表编辑器 |
||||
* TODO 9.0大体上没有改动 |
||||
*/ |
||||
public class CellSubReportEditor extends CellQuickEditor { |
||||
private UIButton subReportButton; |
||||
private static CellSubReportEditor THIS; |
||||
|
||||
public static final CellSubReportEditor getInstance() { |
||||
if (THIS == null) { |
||||
THIS = new CellSubReportEditor(); |
||||
} |
||||
return THIS; |
||||
} |
||||
|
||||
private CellSubReportEditor() { |
||||
super(); |
||||
} |
||||
|
||||
@Override |
||||
public JComponent createCenterBody() { |
||||
subReportButton = new UIButton(); |
||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||
subReportButton.setMargin(null); |
||||
subReportButton.setOpaque(false); |
||||
return subReportButton; |
||||
} |
||||
|
||||
@Override |
||||
protected void refreshDetails() { |
||||
SubReportCellAction subReportCellAction = new SubReportCellAction(tc); |
||||
subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); |
||||
subReportButton.setAction(subReportCellAction); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue