plough
7 years ago
31 changed files with 2517 additions and 1628 deletions
@ -0,0 +1,38 @@ |
|||||||
|
package com.fr.design.dscolumn; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.cell.CellEditorPane; |
||||||
|
import com.fr.report.cell.TemplateCellElement; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 单元格元素 数据列 基本设置内容面板 |
||||||
|
* |
||||||
|
* @author yaoh.wu |
||||||
|
* @version 2017年7月25日 |
||||||
|
* @since 9.0 |
||||||
|
*/ |
||||||
|
public class DSColumnAdvancedEditorPane extends CellEditorPane { |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String getIconPath() { |
||||||
|
return "Advanced"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return "Advanced"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(TemplateCellElement cellElement) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,84 @@ |
|||||||
|
package com.fr.design.dscolumn; |
||||||
|
|
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.cell.CellEditorPane; |
||||||
|
import com.fr.report.cell.TemplateCellElement; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* 单元格元素 数据列 高级设置内容面板 |
||||||
|
* |
||||||
|
* @author yaoh.wu |
||||||
|
* @version 2017年7月25日 |
||||||
|
* @since 9.0 |
||||||
|
*/ |
||||||
|
public class DSColumnBasicEditorPane extends CellEditorPane { |
||||||
|
|
||||||
|
//数据集和数据列
|
||||||
|
private SelectedDataColumnPane dataPane; |
||||||
|
//数据分组设置
|
||||||
|
private ResultSetGroupDockingPane groupPane; |
||||||
|
//当前编辑的单元格
|
||||||
|
private TemplateCellElement cellElement; |
||||||
|
//条件过滤按钮面板
|
||||||
|
private JPanel conditionPane; |
||||||
|
|
||||||
|
public DSColumnBasicEditorPane(TemplateCellElement cellElement, SelectedDataColumnPane dataPane, ResultSetGroupDockingPane groupPane, JPanel conditionPane) { |
||||||
|
this.setLayout(new BorderLayout()); |
||||||
|
this.cellElement = cellElement; |
||||||
|
this.dataPane = dataPane; |
||||||
|
this.groupPane = groupPane; |
||||||
|
this.conditionPane = conditionPane; |
||||||
|
this.add(this.createContentPane(), BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String getIconPath() { |
||||||
|
return "Basic"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return "Basic"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public void update() { |
||||||
|
dataPane.update(this.cellElement); |
||||||
|
groupPane.update(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populate(TemplateCellElement cellElement) { |
||||||
|
this.cellElement = cellElement; |
||||||
|
dataPane.populate(null, cellElement); |
||||||
|
groupPane.populate(cellElement); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 创建有内容的面板显示信息 |
||||||
|
* |
||||||
|
* @return content JPanel |
||||||
|
*/ |
||||||
|
private JPanel createContentPane() { |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] columnSize = {f}; |
||||||
|
double[] rowSize = {p, p, p}; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
//数据集列选择
|
||||||
|
new Component[]{this.dataPane}, |
||||||
|
//数据分组设置
|
||||||
|
new Component[]{this.groupPane}, |
||||||
|
//条件过滤
|
||||||
|
new Component[]{this.conditionPane} |
||||||
|
}; |
||||||
|
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
|
} |
||||||
|
} |
@ -1,247 +1,252 @@ |
|||||||
package com.fr.design.dscolumn; |
package com.fr.design.dscolumn; |
||||||
|
|
||||||
import com.fr.base.Parameter; |
import com.fr.base.Parameter; |
||||||
import com.fr.design.data.DesignTableDataManager; |
import com.fr.data.SimpleDSColumn; |
||||||
import com.fr.data.SimpleDSColumn; |
import com.fr.data.TableDataSource; |
||||||
import com.fr.data.TableDataSource; |
import com.fr.design.data.DesignTableDataManager; |
||||||
import com.fr.design.data.datapane.TableDataComboBox; |
import com.fr.design.data.datapane.TableDataComboBox; |
||||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.design.dialog.BasicDialog; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.dialog.BasicPane; |
||||||
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
import com.fr.design.dialog.DialogActionAdapter; |
||||||
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import com.fr.design.gui.icombobox.LazyComboBox; |
import com.fr.design.gui.icombobox.LazyComboBox; |
||||||
import com.fr.design.layout.TableLayout; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.layout.TableLayoutHelper; |
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||||
import com.fr.design.mainframe.DesignerContext; |
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||||
import com.fr.design.dialog.BasicDialog; |
import com.fr.design.layout.TableLayout; |
||||||
import com.fr.design.dialog.BasicPane; |
import com.fr.design.layout.TableLayoutHelper; |
||||||
import com.fr.design.dialog.DialogActionAdapter; |
import com.fr.design.mainframe.DesignerContext; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.general.data.TableDataColumn; |
import com.fr.general.data.TableDataColumn; |
||||||
import com.fr.report.cell.CellElement; |
import com.fr.report.cell.CellElement; |
||||||
import com.fr.report.cell.TemplateCellElement; |
import com.fr.report.cell.TemplateCellElement; |
||||||
import com.fr.report.cell.cellattr.core.group.DSColumn; |
import com.fr.report.cell.cellattr.core.group.DSColumn; |
||||||
import com.fr.stable.ParameterProvider; |
import com.fr.stable.ParameterProvider; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
import java.awt.event.ItemEvent; |
import java.awt.event.ItemEvent; |
||||||
import java.awt.event.ItemListener; |
import java.awt.event.ItemListener; |
||||||
import java.util.ArrayList; |
import java.util.ArrayList; |
||||||
import java.util.List; |
import java.util.List; |
||||||
import java.util.regex.Pattern; |
import java.util.regex.Pattern; |
||||||
|
|
||||||
public class SelectedDataColumnPane extends BasicPane { |
/** |
||||||
protected UITableEditorPane<ParameterProvider> editorPane; |
* 数据集列动态参数设置组件 |
||||||
protected Parameter[] ps; |
* |
||||||
|
* @author yaoh.wu |
||||||
protected TableDataComboBox tableNameComboBox; |
* @version 2017年7月26日 |
||||||
protected LazyComboBox columnNameComboBox; |
* 9.0设计器更新,修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示 |
||||||
private ItemListener itemListener; |
* @since 8.0 |
||||||
|
*/ |
||||||
private UIButton paramButton; |
public class SelectedDataColumnPane extends BasicPane { |
||||||
|
private UITableEditorPane<ParameterProvider> editorPane; |
||||||
public SelectedDataColumnPane() { |
private Parameter[] ps; |
||||||
this(true); |
|
||||||
} |
TableDataComboBox tableNameComboBox; |
||||||
|
LazyComboBox columnNameComboBox; |
||||||
public SelectedDataColumnPane(boolean showParameterButton) { |
private ItemListener itemListener; |
||||||
initComponent(showParameterButton); |
|
||||||
} |
private UIButton paramButton; |
||||||
|
|
||||||
/** |
public SelectedDataColumnPane() { |
||||||
* 初始化组件 |
this(true); |
||||||
* |
} |
||||||
* @param showParameterButton 是否显示参数按钮 |
|
||||||
* |
SelectedDataColumnPane(boolean showParameterButton) { |
||||||
*/ |
initComponent(showParameterButton); |
||||||
public void initComponent(boolean showParameterButton) { |
} |
||||||
initTableNameComboBox(); |
|
||||||
if (showParameterButton) { |
/** |
||||||
initWithParameterButton(); |
* 初始化组件 |
||||||
} |
* |
||||||
columnNameComboBox = new LazyComboBox() { |
* @param showParameterButton 是否显示参数按钮 |
||||||
|
*/ |
||||||
@Override |
public void initComponent(boolean showParameterButton) { |
||||||
public Object[] load() { |
initTableNameComboBox(); |
||||||
List<String> l = calculateColumnNameList(); |
if (showParameterButton) { |
||||||
return l.toArray(new String[l.size()]); |
initWithParameterButton(); |
||||||
} |
} |
||||||
|
columnNameComboBox = new LazyComboBox() { |
||||||
}; |
@Override |
||||||
columnNameComboBox.setEditable(true); |
public Object[] load() { |
||||||
double p = TableLayout.PREFERRED; |
List<String> l = calculateColumnNameList(); |
||||||
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":"); |
return l.toArray(new String[l.size()]); |
||||||
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":"); |
} |
||||||
if (showParameterButton) { |
}; |
||||||
label1.setPreferredSize(new Dimension(200, 25)); |
columnNameComboBox.setEditable(true); |
||||||
label2.setPreferredSize(new Dimension(200, 25)); |
double f = TableLayout.FILL; |
||||||
} |
double p = TableLayout.PREFERRED; |
||||||
if (showParameterButton) { |
UILabel label1 = new UILabel(Inter.getLocText("TableData")); |
||||||
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}}; |
UILabel label3 = new UILabel(Inter.getLocText("DataColumn")); |
||||||
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p})); |
if (showParameterButton) { |
||||||
} else { |
//todo 国际化
|
||||||
double f = TableLayout.FILL; |
UILabel label2 = new UILabel("param"); |
||||||
double[] columnSize = {p, f}; |
Component[][] components = { |
||||||
double[] rowSize = {p, p}; |
{label1, tableNameComboBox}, |
||||||
Component[][] components = new Component[][]{ |
{label2, paramButton}, |
||||||
new Component[]{label1, tableNameComboBox}, |
{label3, columnNameComboBox} |
||||||
new Component[]{label2, columnNameComboBox} |
}; |
||||||
}; |
this.setLayout(new BorderLayout()); |
||||||
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
this.add(TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p, p}, new double[]{p, f})); |
||||||
this.setLayout(new BorderLayout()); |
} else { |
||||||
this.add(jPanel, BorderLayout.CENTER); |
double[] columnSize = {p, f}; |
||||||
} |
double[] rowSize = {p, p}; |
||||||
} |
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{label1, tableNameComboBox}, |
||||||
protected void initTableNameComboBox() { |
new Component[]{label3, columnNameComboBox} |
||||||
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
}; |
||||||
tableNameComboBox.addItemListener(new ItemListener() { |
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
@Override |
this.setLayout(new BorderLayout()); |
||||||
public void itemStateChanged(ItemEvent e) { |
this.add(jPanel, BorderLayout.CENTER); |
||||||
columnNameComboBox.setLoaded(false); |
} |
||||||
// columnNameComboBox.loadList();
|
} |
||||||
} |
|
||||||
}); |
|
||||||
tableNameComboBox.setPreferredSize(new Dimension(100, 20)); |
public void populate(TableDataSource source, TemplateCellElement cellElement) { |
||||||
} |
if (cellElement == null) { |
||||||
|
return; |
||||||
private void initWithParameterButton() { |
} |
||||||
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel()); |
if (itemListener != null) { |
||||||
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); |
removeListener(itemListener); |
||||||
paramButton.addActionListener(new ActionListener() { |
} |
||||||
public void actionPerformed(ActionEvent e) { |
Object value = cellElement.getValue(); |
||||||
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
if (!(value instanceof DSColumn)) { |
||||||
@Override |
return; |
||||||
public void doOk() { |
} |
||||||
List<ParameterProvider> parameterList = editorPane.update(); |
DSColumn dsColumn = (DSColumn) value; |
||||||
ps = parameterList.toArray(new Parameter[parameterList.size()]); |
String dsName = dsColumn.getDSName(); |
||||||
} |
tableNameComboBox.setSelectedTableDataByName(dsName); |
||||||
}); |
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn())); |
||||||
|
ps = dsColumn.getParameters(); |
||||||
editorPane.populate(ps == null ? new Parameter[0] : ps); |
|
||||||
paramDialog.setVisible(true); |
addListener(itemListener); |
||||||
} |
} |
||||||
}); |
|
||||||
} |
public void update(CellElement cellElement) { |
||||||
|
if (cellElement == null) { |
||||||
@Override |
return; |
||||||
protected String title4PopupWindow() { |
} |
||||||
return "DSColumn"; |
Object value = cellElement.getValue(); |
||||||
} |
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) { |
||||||
|
return; |
||||||
public void populate(TableDataSource source, TemplateCellElement cellElement) { |
} |
||||||
if (cellElement == null) { |
DSColumn dsColumn = null; |
||||||
return; |
if (value == null || !(value instanceof DSColumn)) { |
||||||
} |
dsColumn = new DSColumn(); |
||||||
|
cellElement.setValue(dsColumn); |
||||||
if (itemListener != null) { |
} |
||||||
removeListener(itemListener); |
dsColumn = (DSColumn) cellElement.getValue(); |
||||||
} |
|
||||||
|
SimpleDSColumn simpleDSColumn = updateColumnPane(); |
||||||
Object value = cellElement.getValue(); |
dsColumn.setDSName(simpleDSColumn.getDsName()); |
||||||
if (!(value instanceof DSColumn)) { |
dsColumn.setColumn(simpleDSColumn.getColumn()); |
||||||
return; |
|
||||||
} |
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null); |
||||||
|
} |
||||||
DSColumn dsColumn = (DSColumn) value; |
|
||||||
String dsName = dsColumn.getDSName(); |
/** |
||||||
tableNameComboBox.setSelectedTableDataByName(dsName); |
* 更新面板 |
||||||
columnNameComboBox.setSelectedItem(TableDataColumn.getColumnName(dsColumn.getColumn())); |
* |
||||||
ps = dsColumn.getParameters(); |
* @return 更新后的值 |
||||||
|
*/ |
||||||
addListener(itemListener); |
public SimpleDSColumn updateColumnPane() { |
||||||
} |
SimpleDSColumn dsColumn = new SimpleDSColumn(); |
||||||
|
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem(); |
||||||
public void update(CellElement cellElement) { |
if (tableDataWrappe == null) { |
||||||
if (cellElement == null) { |
return null; |
||||||
return; |
} |
||||||
} |
dsColumn.setDsName(tableDataWrappe.getTableDataName()); |
||||||
Object value = cellElement.getValue(); |
TableDataColumn column; |
||||||
if (this.tableNameComboBox.getSelectedItem() == null && this.columnNameComboBox.getSelectedItem() == null) { |
String columnExp = (String) this.columnNameComboBox.getSelectedItem(); |
||||||
return; |
if (isColumnName(columnExp)) { |
||||||
} |
String number = columnExp.substring(1); |
||||||
DSColumn dsColumn = null; |
Pattern pattern = Pattern.compile("[^\\d]"); |
||||||
if (value == null || !(value instanceof DSColumn)) { |
if (pattern.matcher(number).find()) { |
||||||
dsColumn = new DSColumn(); |
column = TableDataColumn.createColumn(columnExp); |
||||||
cellElement.setValue(dsColumn); |
} else { |
||||||
} |
int serialNumber = Integer.parseInt(columnExp.substring(1)); |
||||||
dsColumn = (DSColumn) cellElement.getValue(); |
column = TableDataColumn.createColumn(serialNumber); |
||||||
|
} |
||||||
SimpleDSColumn simpleDSColumn = updateColumnPane(); |
} else { |
||||||
dsColumn.setDSName(simpleDSColumn.getDsName()); |
column = TableDataColumn.createColumn(columnExp); |
||||||
dsColumn.setColumn(simpleDSColumn.getColumn()); |
} |
||||||
|
dsColumn.setColumn(column); |
||||||
dsColumn.setParameters((ps != null && ps.length > 0) ? ps : null); |
return dsColumn; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 更新面板 |
* 添加监听事件 |
||||||
* |
* |
||||||
* @return 更新后的值 |
* @param i 监听事件 |
||||||
* |
*/ |
||||||
*/ |
public void addListener(ItemListener i) { |
||||||
public SimpleDSColumn updateColumnPane() { |
itemListener = i; |
||||||
SimpleDSColumn dsColumn = new SimpleDSColumn(); |
tableNameComboBox.addItemListener(i); |
||||||
TableDataWrapper tableDataWrappe = this.tableNameComboBox.getSelectedItem(); |
columnNameComboBox.addItemListener(i); |
||||||
if (tableDataWrappe == null) { |
} |
||||||
return null; |
|
||||||
} |
/** |
||||||
dsColumn.setDsName(tableDataWrappe.getTableDataName()); |
* 移除监听事件 |
||||||
TableDataColumn column; |
* |
||||||
String columnExp = (String) this.columnNameComboBox.getSelectedItem(); |
* @param i 监听事件 |
||||||
if (isColumnName(columnExp)) { |
*/ |
||||||
String number = columnExp.substring(1); |
public void removeListener(ItemListener i) { |
||||||
Pattern pattern = Pattern.compile("[^\\d]"); |
tableNameComboBox.removeItemListener(i); |
||||||
if (pattern.matcher(number).find()) { |
columnNameComboBox.removeItemListener(i); |
||||||
column = TableDataColumn.createColumn(columnExp); |
} |
||||||
} else { |
|
||||||
int serialNumber = Integer.parseInt(columnExp.substring(1)); |
|
||||||
column = TableDataColumn.createColumn(serialNumber); |
protected void initTableNameComboBox() { |
||||||
} |
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||||
} else { |
tableNameComboBox.addItemListener(new ItemListener() { |
||||||
column = TableDataColumn.createColumn(columnExp); |
@Override |
||||||
} |
public void itemStateChanged(ItemEvent e) { |
||||||
dsColumn.setColumn(column); |
columnNameComboBox.setLoaded(false); |
||||||
return dsColumn; |
} |
||||||
} |
}); |
||||||
|
tableNameComboBox.setPreferredSize(new Dimension(100, 20)); |
||||||
private boolean isColumnName(String columnExp) { |
} |
||||||
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); |
|
||||||
|
@Override |
||||||
} |
protected String title4PopupWindow() { |
||||||
|
return "DSColumn"; |
||||||
/** |
} |
||||||
* 添加监听事件 |
|
||||||
* |
|
||||||
* @param i 监听事件 |
private void initWithParameterButton() { |
||||||
* |
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel()); |
||||||
*/ |
paramButton = new UIButton(Inter.getLocText("TableData_Dynamic_Parameter_Setting")); |
||||||
public void addListener(ItemListener i) { |
paramButton.addActionListener(new ActionListener() { |
||||||
itemListener = i; |
public void actionPerformed(ActionEvent e) { |
||||||
tableNameComboBox.addItemListener(i); |
BasicDialog paramDialog = editorPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||||
columnNameComboBox.addItemListener(i); |
@Override |
||||||
} |
public void doOk() { |
||||||
|
List<ParameterProvider> parameterList = editorPane.update(); |
||||||
/** |
ps = parameterList.toArray(new Parameter[parameterList.size()]); |
||||||
* 移除监听事件 |
} |
||||||
* |
}); |
||||||
* @param i 监听事件 |
|
||||||
* |
editorPane.populate(ps == null ? new Parameter[0] : ps); |
||||||
*/ |
paramDialog.setVisible(true); |
||||||
public void removeListener(ItemListener i) { |
} |
||||||
tableNameComboBox.removeItemListener(i); |
}); |
||||||
columnNameComboBox.removeItemListener(i); |
} |
||||||
} |
|
||||||
|
|
||||||
private List<String> calculateColumnNameList() { |
private boolean isColumnName(String columnExp) { |
||||||
if (this.tableNameComboBox.getSelectedItem() != null) { |
return StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); |
||||||
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); |
} |
||||||
} |
|
||||||
return new ArrayList<String>(); |
|
||||||
} |
private List<String> calculateColumnNameList() { |
||||||
|
if (this.tableNameComboBox.getSelectedItem() != null) { |
||||||
|
return this.tableNameComboBox.getSelectedItem().calculateColumnNameList(); |
||||||
|
} |
||||||
|
return new ArrayList<String>(); |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.fr.design.mainframe.cell; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.report.cell.TemplateCellElement; |
||||||
|
|
||||||
|
/** |
||||||
|
* 右侧单元格元素面板抽象类 |
||||||
|
* |
||||||
|
* @author yaoh.wu |
||||||
|
* @version 2017年7月25日 |
||||||
|
* @since 9.0 |
||||||
|
*/ |
||||||
|
public abstract class CellEditorPane extends BasicPane { |
||||||
|
|
||||||
|
public abstract String getIconPath(); |
||||||
|
|
||||||
|
public abstract String title4PopupWindow(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 从面板拿数据保存 |
||||||
|
*/ |
||||||
|
public abstract void update(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新面板数据 |
||||||
|
* |
||||||
|
* @param cellElement 单元格 |
||||||
|
*/ |
||||||
|
public abstract void populate(TemplateCellElement cellElement); |
||||||
|
} |
@ -1,57 +1,57 @@ |
|||||||
package com.fr.design.mainframe.cell; |
package com.fr.design.mainframe.cell; |
||||||
|
|
||||||
import java.awt.BorderLayout; |
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.selection.QuickEditor; |
||||||
import javax.swing.BorderFactory; |
import com.fr.general.Inter; |
||||||
import javax.swing.JPanel; |
|
||||||
|
import javax.swing.*; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import java.awt.*; |
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.design.selection.QuickEditor; |
/** |
||||||
|
* QuickEditorRegion |
||||||
/** |
* |
||||||
* QuickEditorRegion |
* @author zhou, yaoh.wu |
||||||
* |
* @version 2017年7月25日 |
||||||
* @editor zhou |
* @since 8.0 |
||||||
* @since 2012-3-23下午3:21:36 |
*/ |
||||||
*/ |
|
||||||
|
public class QuickEditorRegion extends JPanel { |
||||||
public class QuickEditorRegion extends JPanel { |
|
||||||
|
|
||||||
public static QuickEditorRegion getInstance() { |
private static QuickEditorRegion singleton = new QuickEditorRegion(); |
||||||
return singleton; |
private static JPanel EMPTY; |
||||||
} |
|
||||||
|
private QuickEditorRegion() { |
||||||
public static JPanel getEmptyEditor() { |
this.setLayout(new BorderLayout()); |
||||||
if(EMPTY == null) { |
} |
||||||
EMPTY = new JPanel(new BorderLayout()); |
|
||||||
UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"})+"!"); |
public static QuickEditorRegion getInstance() { |
||||||
content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); |
return singleton; |
||||||
EMPTY.add(content, BorderLayout.CENTER); |
} |
||||||
} |
|
||||||
return EMPTY; |
public static JPanel getEmptyEditor() { |
||||||
} |
if (EMPTY == null) { |
||||||
|
EMPTY = new JPanel(new BorderLayout()); |
||||||
private static QuickEditorRegion singleton = new QuickEditorRegion(); |
UILabel content = new UILabel(Inter.getLocText(new String[]{"DataFunction-None", "HJS-Message", "Form-Widget_Property_Table"}) + "!"); |
||||||
private static JPanel EMPTY; |
content.setBorder(BorderFactory.createEmptyBorder(0, 70, 0, 0)); |
||||||
|
EMPTY.add(content, BorderLayout.CENTER); |
||||||
public QuickEditorRegion() { |
} |
||||||
this.setLayout(new BorderLayout()); |
return EMPTY; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 传值 |
* 更新面板显示数据 |
||||||
* |
* |
||||||
* @param ePane |
* @param currentEditor 当前正在编辑的单元格编辑器或者默认的单元格编辑器 |
||||||
*/ |
*/ |
||||||
public void populate(final QuickEditor quickEditor) { |
public void populate(final QuickEditor currentEditor) { |
||||||
this.removeAll(); |
this.removeAll(); |
||||||
if(quickEditor.getComponentCount() == 0) { |
if (currentEditor.getComponentCount() == 0) { |
||||||
this.add(getEmptyEditor(), BorderLayout.CENTER); |
this.add(getEmptyEditor(), BorderLayout.CENTER); |
||||||
} else { |
} else { |
||||||
this.add(quickEditor, BorderLayout.CENTER); |
this.add(currentEditor, BorderLayout.CENTER); |
||||||
} |
} |
||||||
validate(); |
validate(); |
||||||
repaint(); |
repaint(); |
||||||
} |
} |
||||||
} |
} |
@ -1,238 +1,231 @@ |
|||||||
package com.fr.design.present; |
package com.fr.design.present; |
||||||
|
|
||||||
import java.awt.*; |
|
||||||
|
|
||||||
import javax.swing.JComponent; |
|
||||||
|
|
||||||
import com.fr.design.constants.UIConstants; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import javax.swing.SpinnerNumberModel; |
|
||||||
import javax.swing.border.TitledBorder; |
|
||||||
import javax.swing.event.ChangeEvent; |
|
||||||
import javax.swing.event.ChangeListener; |
|
||||||
import javax.swing.event.DocumentEvent; |
|
||||||
import javax.swing.event.DocumentListener; |
|
||||||
|
|
||||||
import com.fr.design.beans.FurtherBasicBeanPane; |
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
import com.fr.design.border.UIRoundedBorder; |
import com.fr.design.border.UIRoundedBorder; |
||||||
|
import com.fr.design.constants.UIConstants; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UIBasicSpinner; |
||||||
import com.fr.design.gui.itextfield.UITextField; |
import com.fr.design.gui.itextfield.UITextField; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
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.utils.gui.GUICoreUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.report.cell.cellattr.CurrencyLineAttr; |
import com.fr.report.cell.cellattr.CurrencyLineAttr; |
||||||
import com.fr.report.cell.cellattr.CurrencyLinePresent; |
import com.fr.report.cell.cellattr.CurrencyLinePresent; |
||||||
import com.fr.report.cell.painter.barcode.BarcodeException; |
import com.fr.report.cell.painter.barcode.BarcodeException; |
||||||
import com.fr.report.core.CurrencyLineImpl; |
import com.fr.report.core.CurrencyLineImpl; |
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
|
||||||
import com.fr.design.gui.ispinner.UIBasicSpinner; |
import javax.swing.*; |
||||||
|
import javax.swing.border.TitledBorder; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import javax.swing.event.DocumentEvent; |
||||||
|
import javax.swing.event.DocumentListener; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
/** |
/** |
||||||
* |
|
||||||
* @author zhou |
* @author zhou |
||||||
* @since 2012-6-4下午7:34:52 |
* @since 2012-6-4下午7:34:52 |
||||||
*/ |
*/ |
||||||
public class CurrencyLinePane extends FurtherBasicBeanPane<CurrencyLinePresent> { |
public class CurrencyLinePane extends FurtherBasicBeanPane<CurrencyLinePresent> { |
||||||
private static final int VS_NUM = 4; |
private static final int VS_NUM = 4; |
||||||
private static final int VG_NUM = 6; |
private static final int VG_NUM = 6; |
||||||
private UIBasicSpinner intPartSpinner; |
private UIBasicSpinner intPartSpinner; |
||||||
private UIBasicSpinner deciPartSpinner; |
private UIBasicSpinner deciPartSpinner; |
||||||
private UITextField textField; |
private UITextField textField; |
||||||
private CurrencyLinePreviewPane CurrencyLinePreviewPane; |
private CurrencyLinePreviewPane CurrencyLinePreviewPane; |
||||||
private int intPart = 9; |
private int intPart = 9; |
||||||
private int deciPart = 3; |
private int deciPart = 3; |
||||||
|
|
||||||
private static final int POSITION = 8; |
private static final int POSITION = 8; |
||||||
ChangeListener listener2 = new ChangeListener() { |
ChangeListener listener2 = new ChangeListener() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void stateChanged(ChangeEvent e) { |
public void stateChanged(ChangeEvent e) { |
||||||
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
||||||
} |
} |
||||||
|
|
||||||
}; |
}; |
||||||
|
|
||||||
DocumentListener listener = new DocumentListener() { |
DocumentListener listener = new DocumentListener() { |
||||||
@Override |
@Override |
||||||
public void insertUpdate(DocumentEvent e) { |
public void insertUpdate(DocumentEvent e) { |
||||||
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void removeUpdate(DocumentEvent e) { |
public void removeUpdate(DocumentEvent e) { |
||||||
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void changedUpdate(DocumentEvent e) { |
public void changedUpdate(DocumentEvent e) { |
||||||
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
CurrencyLinePreviewPane.setObject(textField.getText(), update()); |
||||||
} |
} |
||||||
}; |
}; |
||||||
|
|
||||||
public CurrencyLinePane() { |
public CurrencyLinePane() { |
||||||
this.initComponents(); |
this.initComponents(); |
||||||
} |
} |
||||||
|
|
||||||
protected void initComponents() { |
protected void initComponents() { |
||||||
// 整数位选择
|
// 整数位选择
|
||||||
intPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(9, 1, 20, 1)); |
intPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(9, 1, 20, 1)); |
||||||
intPartSpinner.setPreferredSize(new Dimension(45, 20)); |
intPartSpinner.setPreferredSize(new Dimension(135, 20)); |
||||||
|
|
||||||
// 小数位选择
|
// 小数位选择
|
||||||
deciPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 10, 1)); |
deciPartSpinner = new UIBasicSpinner(new SpinnerNumberModel(2, 1, 10, 1)); |
||||||
deciPartSpinner.setPreferredSize(new Dimension(45, 20)); |
deciPartSpinner.setPreferredSize(new Dimension(135, 20)); |
||||||
// 预览区域
|
// 预览区域
|
||||||
textField = new UITextField(10); |
textField = new UITextField(10); |
||||||
|
|
||||||
CurrencyLinePreviewPane = new CurrencyLinePreviewPane(); |
CurrencyLinePreviewPane = new CurrencyLinePreviewPane(); |
||||||
CurrencyLinePreviewPane.setPreferredSize(new Dimension(0, 145)); |
CurrencyLinePreviewPane.setPreferredSize(new Dimension(0, 145)); |
||||||
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
JPanel borderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); |
TitledBorder titledBorder = new TitledBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 5), Inter.getLocText("StyleFormat-Sample"), 4, 2, this.getFont(), UIConstants.LINE_COLOR); |
||||||
borderPane.setBorder(titledBorder); |
borderPane.setBorder(titledBorder); |
||||||
borderPane.add(CurrencyLinePreviewPane, BorderLayout.CENTER); |
borderPane.add(CurrencyLinePreviewPane, BorderLayout.CENTER); |
||||||
|
|
||||||
textField.requestFocus(); |
textField.requestFocus(); |
||||||
|
|
||||||
double vs = VS_NUM; |
double vs = VS_NUM; |
||||||
double vg = VG_NUM; |
double vg = VG_NUM; |
||||||
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,p,p }; |
double[] rowSize = {p, p, p, p}; |
||||||
|
|
||||||
|
|
||||||
Component[][] components = new Component[][]{ |
Component[][] components = new Component[][]{ |
||||||
new Component[]{new UILabel(Inter.getLocText("Data") + ":", UILabel.RIGHT),textField}, |
new Component[]{new UILabel(Inter.getLocText("Data"), UILabel.LEFT), textField}, |
||||||
new Component[]{borderPane,null}, |
new Component[]{borderPane, null}, |
||||||
new Component[]{new UILabel(Inter.getLocText("IntPart") + ":", UILabel.RIGHT), groupPane(intPartSpinner)}, |
new Component[]{new UILabel(Inter.getLocText("IntPart"), UILabel.LEFT), groupPane(intPartSpinner)}, |
||||||
new Component[]{new UILabel(Inter.getLocText("DeciPart") + ":", UILabel.RIGHT), groupPane(deciPartSpinner)} |
new Component[]{new UILabel(Inter.getLocText("DeciPart"), UILabel.LEFT), groupPane(deciPartSpinner)} |
||||||
|
|
||||||
} ; |
}; |
||||||
|
|
||||||
JPanel linePane = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); |
JPanel linePane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
this.setLayout(new BorderLayout()); |
this.setLayout(new BorderLayout()); |
||||||
this.add(linePane,BorderLayout.CENTER); |
this.add(linePane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
textField.getDocument().addDocumentListener(listener); |
||||||
textField.getDocument().addDocumentListener(listener); |
intPartSpinner.addChangeListener(listener2); |
||||||
intPartSpinner.addChangeListener(listener2); |
deciPartSpinner.addChangeListener(listener2); |
||||||
deciPartSpinner.addChangeListener(listener2); |
textField.setText("123456.78"); |
||||||
textField.setText("123456.78"); |
} |
||||||
} |
|
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
* 窗口名 |
* 窗口名 |
||||||
* @return 同上 |
* @return 同上 |
||||||
*/ |
*/ |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Currency_Line"); |
return Inter.getLocText("Currency_Line"); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public CurrencyLineAttr update() { |
public CurrencyLineAttr update() { |
||||||
CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); |
CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); |
||||||
currencylineAttr.setintPart(((Integer)this.intPartSpinner.getValue()).intValue()); |
currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); |
||||||
currencylineAttr.setdeciPart(((Integer)this.deciPartSpinner.getValue()).intValue()); |
currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); |
||||||
return currencylineAttr; |
return currencylineAttr; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public void setintPart(int intpart) { |
public void setintPart(int intpart) { |
||||||
this.intPart = intpart; |
this.intPart = intpart; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public void setdeciPart(int decipart) { |
public void setdeciPart(int decipart) { |
||||||
this.deciPart = decipart; |
this.deciPart = decipart; |
||||||
} |
} |
||||||
|
|
||||||
private class CurrencyLinePreviewPane extends JPanel { |
private class CurrencyLinePreviewPane extends JPanel { |
||||||
private String text; |
private String text; |
||||||
CurrencyLineAttr currencyLineAttr; |
CurrencyLineAttr currencyLineAttr; |
||||||
|
|
||||||
public CurrencyLinePreviewPane() { |
public CurrencyLinePreviewPane() { |
||||||
// setBackground(Color.white);
|
// setBackground(Color.white);
|
||||||
} |
} |
||||||
|
|
||||||
public void setObject(String text, CurrencyLineAttr currencyLineAttr) { |
public void setObject(String text, CurrencyLineAttr currencyLineAttr) { |
||||||
this.text = text; |
this.text = text; |
||||||
this.currencyLineAttr = currencyLineAttr; |
this.currencyLineAttr = currencyLineAttr; |
||||||
GUICoreUtils.repaint(this); |
GUICoreUtils.repaint(this); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void paintComponent(Graphics g) { |
public void paintComponent(Graphics g) { |
||||||
super.paintComponent(g); |
super.paintComponent(g); |
||||||
if (text == null){ |
if (text == null) { |
||||||
return; |
return; |
||||||
|
} |
||||||
|
Dimension size = this.getSize(); |
||||||
|
try { |
||||||
|
CurrencyLineImpl currencyLineImpl = new CurrencyLineImpl(text, currencyLineAttr); |
||||||
|
currencyLineImpl.draw((Graphics2D) g, (int) (size.getWidth()), (int) (size.getHeight())); |
||||||
|
} catch (BarcodeException e) { |
||||||
|
Color oldColor = g.getColor(); |
||||||
|
g.setColor(Color.red); |
||||||
|
g.drawString(e.getMessage(), (int) (size.getWidth() / POSITION), (int) (size.getHeight() / POSITION)); |
||||||
|
g.setColor(oldColor); |
||||||
} |
} |
||||||
Dimension size = this.getSize(); |
} |
||||||
try { |
|
||||||
CurrencyLineImpl currencyLineImpl = new CurrencyLineImpl(text, currencyLineAttr); |
} |
||||||
currencyLineImpl.draw((Graphics2D)g, (int)(size.getWidth()), (int)(size.getHeight())); |
|
||||||
} catch (BarcodeException e) { |
protected static JPanel groupPane(JComponent comp) { |
||||||
Color oldColor = g.getColor(); |
JPanel jp = new JPanel(); |
||||||
g.setColor(Color.red); |
jp.setBorder(null); |
||||||
g.drawString(e.getMessage(), (int)(size.getWidth() / POSITION), (int)(size.getHeight() / POSITION)); |
jp.setLayout(new FlowLayout(FlowLayout.LEFT)); |
||||||
g.setColor(oldColor); |
jp.add(comp); |
||||||
} |
return jp; |
||||||
} |
} |
||||||
|
|
||||||
} |
@Override |
||||||
|
|
||||||
protected static JPanel groupPane(JComponent comp) { |
|
||||||
JPanel jp = new JPanel(); |
|
||||||
jp.setBorder(null); |
|
||||||
jp.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
||||||
jp.add(comp); |
|
||||||
return jp; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
/** |
/** |
||||||
* 是否为该类型 |
* 是否为该类型 |
||||||
* @param ob 对象 |
* @param ob 对象 |
||||||
* @return 同上 |
* @return 同上 |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public boolean accept(Object ob) { |
public boolean accept(Object ob) { |
||||||
return ob instanceof CurrencyLinePresent; |
return ob instanceof CurrencyLinePresent; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 重置 |
* 重置 |
||||||
*/ |
*/ |
||||||
public void reset() { |
public void reset() { |
||||||
this.intPartSpinner.setValue(9); |
this.intPartSpinner.setValue(9); |
||||||
this.deciPartSpinner.setValue(3); |
this.deciPartSpinner.setValue(3); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void populateBean(CurrencyLinePresent ob) { |
public void populateBean(CurrencyLinePresent ob) { |
||||||
CurrencyLineAttr currencyLine = ob.getCurrencyLineAttr(); |
CurrencyLineAttr currencyLine = ob.getCurrencyLineAttr(); |
||||||
if (currencyLine == null) { |
if (currencyLine == null) { |
||||||
currencyLine = new CurrencyLineAttr(); |
currencyLine = new CurrencyLineAttr(); |
||||||
} |
} |
||||||
this.intPartSpinner.setValue(new Integer(currencyLine.getintPart())); |
this.intPartSpinner.setValue(new Integer(currencyLine.getintPart())); |
||||||
this.deciPartSpinner.setValue(new Integer(currencyLine.getdeciPart())); |
this.deciPartSpinner.setValue(new Integer(currencyLine.getdeciPart())); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public CurrencyLinePresent updateBean() { |
public CurrencyLinePresent updateBean() { |
||||||
CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); |
CurrencyLineAttr currencylineAttr = new CurrencyLineAttr(); |
||||||
currencylineAttr.setintPart(((Integer)this.intPartSpinner.getValue()).intValue()); |
currencylineAttr.setintPart(((Integer) this.intPartSpinner.getValue()).intValue()); |
||||||
currencylineAttr.setdeciPart(((Integer)this.deciPartSpinner.getValue()).intValue()); |
currencylineAttr.setdeciPart(((Integer) this.deciPartSpinner.getValue()).intValue()); |
||||||
return new CurrencyLinePresent(currencylineAttr); |
return new CurrencyLinePresent(currencylineAttr); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -1,123 +1,129 @@ |
|||||||
package com.fr.quickeditor; |
package com.fr.quickeditor; |
||||||
|
|
||||||
import com.fr.base.BaseUtils; |
import com.fr.base.BaseUtils; |
||||||
import com.fr.design.actions.utils.DeprecatedActionManager; |
import com.fr.design.actions.utils.DeprecatedActionManager; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
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.DesignerContext; |
import com.fr.design.mainframe.DesignerContext; |
||||||
import com.fr.design.mainframe.ElementCasePane; |
import com.fr.design.mainframe.ElementCasePane; |
||||||
import com.fr.design.selection.QuickEditor; |
import com.fr.design.selection.QuickEditor; |
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.grid.selection.CellSelection; |
import com.fr.grid.selection.CellSelection; |
||||||
import com.fr.report.cell.TemplateCellElement; |
import com.fr.report.cell.TemplateCellElement; |
||||||
import com.fr.stable.ColumnRow; |
import com.fr.stable.ColumnRow; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
||||||
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
||||||
import java.awt.event.MouseAdapter; |
import java.awt.event.MouseAdapter; |
||||||
import java.awt.event.MouseEvent; |
import java.awt.event.MouseEvent; |
||||||
|
|
||||||
/** |
/** |
||||||
* |
* @author zhou |
||||||
* @author zhou |
* @since 2012-7-23下午5:16:53 |
||||||
* @since 2012-7-23下午5:16:53 |
*/ |
||||||
*/ |
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
||||||
public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> { |
|
||||||
|
protected UITextField columnRowTextField; |
||||||
protected UITextField columnRowTextField; |
private UIButton cellElementEditButton; |
||||||
protected UIButton cellElementEditButton; |
protected TemplateCellElement cellElement; |
||||||
protected TemplateCellElement cellElement; |
|
||||||
|
public CellQuickEditor() { |
||||||
public CellQuickEditor() { |
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, p}; |
||||||
double[] rowSize = { p,p,p}; |
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{new UILabel(" " + Inter.getLocText("Cell")), columnRowTextField = initColumnRowTextField()}, |
||||||
Component[][] components = new Component[][]{ |
new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content") + " "), cellElementEditButton = initCellElementEditButton()}, |
||||||
new Component[]{new UILabel(" "+Inter.getLocText("Cell")),columnRowTextField = initColumnRowTextField()}, |
new Component[]{createCenterBody(), null} |
||||||
new Component[]{new UILabel(Inter.getLocText("HF-Insert_Content")+" "),cellElementEditButton = initCellElementEditButton()}, |
}; |
||||||
new Component[]{createCenterBody(),null} |
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
}; |
this.setLayout(new BorderLayout()); |
||||||
|
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); |
this.add(panel, BorderLayout.CENTER); |
||||||
this.setLayout(new BorderLayout()); |
} |
||||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
|
||||||
this.add(panel,BorderLayout.CENTER); |
/** |
||||||
|
* 初始化添加按钮 |
||||||
|
* TODO 9.0 换成下拉菜单后原来的快捷键不好处理,先跳过。 |
||||||
|
* |
||||||
} |
* @return UIButton |
||||||
|
*/ |
||||||
protected UIButton initCellElementEditButton() { |
private UIButton initCellElementEditButton() { |
||||||
final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); |
final UIButton cellElementEditButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); |
||||||
cellElementEditButton.addMouseListener(new MouseAdapter() { |
cellElementEditButton.addMouseListener(new MouseAdapter() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void mousePressed(MouseEvent evt) { |
public void mousePressed(MouseEvent evt) { |
||||||
GUICoreUtils.showPopMenuWithParentWidth(DeprecatedActionManager.getCellMenu(tc).createJPopupMenu(), cellElementEditButton, 0, cellElementEditButton.getY() - 6); |
GUICoreUtils.showPopMenuWithParentWidth(DeprecatedActionManager.getCellMenu(tc).createJPopupMenu(), cellElementEditButton, 0, cellElementEditButton.getY() - 6); |
||||||
} |
} |
||||||
}); |
}); |
||||||
return cellElementEditButton; |
return cellElementEditButton; |
||||||
} |
} |
||||||
|
|
||||||
protected UITextField initColumnRowTextField() { |
/** |
||||||
final UITextField columnRowTextField = new UITextField(4); |
* 初始化单元格域,存储当前选择的单元格,例A3,B4等 |
||||||
// barry:输入位置定位单元格
|
* |
||||||
columnRowTextField.addActionListener(new ActionListener() { |
* @return 单元格信息文本域 |
||||||
|
*/ |
||||||
@Override |
private UITextField initColumnRowTextField() { |
||||||
public void actionPerformed(ActionEvent e) { |
final UITextField columnRowTextField = new UITextField(4); |
||||||
ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText()); |
|
||||||
|
// barry:输入位置定位单元格
|
||||||
// barry:检查输入是否正确
|
columnRowTextField.addActionListener(new ActionListener() { |
||||||
if (!ColumnRow.validate(columnRowEdit)) { |
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
Object[] options = { Inter.getLocText("OK") }; |
ColumnRow columnRowEdit = ColumnRow.valueOf(columnRowTextField.getText()); |
||||||
JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), Inter.getLocText("Warning"), |
// barry:检查输入是否正确
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); |
if (!ColumnRow.validate(columnRowEdit)) { |
||||||
|
Object[] options = {Inter.getLocText("OK")}; |
||||||
// 重新选中当前的selection,把columnRowTextField
|
JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Please_Input_Letters+Numbers(A1,AA1,A11....)"), Inter.getLocText("Warning"), |
||||||
tc.setSelection(tc.getSelection()); |
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); |
||||||
return; |
// 重新选中当前的selection,把columnRowTextField
|
||||||
} |
tc.setSelection(tc.getSelection()); |
||||||
|
return; |
||||||
JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar(); |
} |
||||||
int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow(); |
JScrollBar verticalBar = tc.getVerticalScrollBar(), horizontalBar = tc.getHorizontalScrollBar(); |
||||||
|
int m = columnRowEdit.getColumn(), n = columnRowEdit.getRow(); |
||||||
verticalBar.setMaximum(n); |
verticalBar.setMaximum(n); |
||||||
verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); |
verticalBar.setValue(n < 21 ? verticalBar.getValue() : n - 20); |
||||||
horizontalBar.setMaximum(m); |
horizontalBar.setMaximum(m); |
||||||
horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); |
horizontalBar.setValue(m < 13 ? horizontalBar.getValue() : m - 12); |
||||||
|
tc.setSelection(new CellSelection(m, n, 1, 1)); |
||||||
tc.setSelection(new CellSelection(m, n, 1, 1)); |
tc.requestFocus(); |
||||||
tc.requestFocus(); |
} |
||||||
} |
}); |
||||||
}); |
return columnRowTextField; |
||||||
return columnRowTextField; |
} |
||||||
} |
|
||||||
|
|
||||||
public abstract JComponent createCenterBody(); |
/** |
||||||
|
* 初始化详细信息面板 |
||||||
@Override |
* |
||||||
protected void refresh() { |
* @return JComponent 待显示的详细信息面板 |
||||||
CellSelection cs = (CellSelection)tc.getSelection(); |
*/ |
||||||
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); |
public abstract JComponent createCenterBody(); |
||||||
columnRowTextField.setText(columnRow.toString()); |
|
||||||
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); |
/** |
||||||
refreshDetails(); |
* 刷新 |
||||||
} |
*/ |
||||||
|
@Override |
||||||
protected abstract void refreshDetails(); |
protected void refresh() { |
||||||
|
CellSelection cs = (CellSelection) tc.getSelection(); |
||||||
|
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); |
||||||
|
columnRowTextField.setText(columnRow.toString()); |
||||||
|
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); |
||||||
|
refreshDetails(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新详细信息 |
||||||
|
*/ |
||||||
|
protected abstract void refreshDetails(); |
||||||
} |
} |
@ -1,61 +1,63 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import java.awt.event.ActionEvent; |
import com.fr.base.BaseUtils; |
||||||
import java.awt.event.ActionListener; |
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
import javax.swing.BorderFactory; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import javax.swing.JComponent; |
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.base.BaseUtils; |
import com.fr.general.Inter; |
||||||
import com.fr.design.cell.editor.BiasTextPainterCellEditor.BiasTextPainterPane; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.report.cell.painter.BiasTextPainter; |
||||||
import com.fr.design.mainframe.DesignerContext; |
|
||||||
import com.fr.design.dialog.DialogActionAdapter; |
import javax.swing.*; |
||||||
import com.fr.general.ComparatorUtils; |
import java.awt.event.ActionEvent; |
||||||
import com.fr.general.Inter; |
import java.awt.event.ActionListener; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
|
||||||
import com.fr.report.cell.painter.BiasTextPainter; |
/** |
||||||
|
* 单元格元素斜线编辑器 |
||||||
public class CellBiasTextPainterEditor extends CellQuickEditor { |
* TODO 9.0 大体没有改动 |
||||||
|
*/ |
||||||
@Override |
public class CellBiasTextPainterEditor extends CellQuickEditor { |
||||||
public JComponent createCenterBody() { |
|
||||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); |
@Override |
||||||
editbutton.addActionListener(new ActionListener() { |
public JComponent createCenterBody() { |
||||||
|
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png")); |
||||||
@Override |
editbutton.addActionListener(new ActionListener() { |
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
showEditingDialog(); |
@Override |
||||||
} |
public void actionPerformed(ActionEvent e) { |
||||||
}); |
showEditingDialog(); |
||||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
} |
||||||
editbutton.setMargin(null); |
}); |
||||||
editbutton.setOpaque(false); |
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||||
return editbutton; |
editbutton.setMargin(null); |
||||||
} |
editbutton.setOpaque(false); |
||||||
|
return editbutton; |
||||||
private void showEditingDialog() { |
} |
||||||
final BiasTextPainter oldbiasTextPainter = (BiasTextPainter)cellElement.getValue(); |
|
||||||
final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); |
private void showEditingDialog() { |
||||||
biasTextPainterPane.populate(oldbiasTextPainter); |
final BiasTextPainter oldbiasTextPainter = (BiasTextPainter) cellElement.getValue(); |
||||||
biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
final BiasTextPainterPane biasTextPainterPane = new BiasTextPainterPane(); |
||||||
|
biasTextPainterPane.populate(oldbiasTextPainter); |
||||||
@Override |
biasTextPainterPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||||
public void doOk() { |
|
||||||
BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); |
@Override |
||||||
if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { |
public void doOk() { |
||||||
cellElement.setValue(newbiasTextPainter); |
BiasTextPainter newbiasTextPainter = biasTextPainterPane.update(); |
||||||
fireTargetModified(); |
if (!ComparatorUtils.equals(oldbiasTextPainter, newbiasTextPainter)) { |
||||||
} |
cellElement.setValue(newbiasTextPainter); |
||||||
} |
fireTargetModified(); |
||||||
|
} |
||||||
}).setVisible(true); |
} |
||||||
} |
|
||||||
|
}).setVisible(true); |
||||||
@Override |
} |
||||||
protected void refreshDetails() { |
|
||||||
// TODO Auto-generated method stub
|
@Override |
||||||
|
protected void refreshDetails() { |
||||||
} |
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
} |
} |
@ -1,111 +1,201 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import com.fr.design.actions.columnrow.DSColumnAdvancedAction; |
import com.fr.design.actions.columnrow.DSColumnConditionAction; |
||||||
import com.fr.design.actions.columnrow.DSColumnBasicAction; |
import com.fr.design.dscolumn.DSColumnAdvancedEditorPane; |
||||||
import com.fr.design.actions.columnrow.DSColumnConditionAction; |
import com.fr.design.dscolumn.DSColumnBasicEditorPane; |
||||||
import com.fr.design.constants.LayoutConstants; |
import com.fr.design.dscolumn.ResultSetGroupDockingPane; |
||||||
import com.fr.design.dscolumn.ResultSetGroupDockingPane; |
import com.fr.design.dscolumn.SelectedDataColumnPane; |
||||||
import com.fr.design.dscolumn.SelectedDataColumnPane; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.design.gui.ibutton.UIHeadGroup; |
||||||
import com.fr.design.layout.TableLayout; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.layout.TableLayoutHelper; |
import com.fr.design.layout.TableLayout; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.design.mainframe.cell.CellEditorPane; |
||||||
import javax.swing.*; |
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
import java.awt.*; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
import java.awt.event.ItemEvent; |
|
||||||
import java.awt.event.ItemListener; |
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
public class CellDSColumnEditor extends CellQuickEditor { |
import java.awt.event.ItemEvent; |
||||||
private JPanel dsColumnRegion; |
import java.awt.event.ItemListener; |
||||||
private JPanel centerPane; |
import java.util.ArrayList; |
||||||
private SelectedDataColumnPane dataPane; |
|
||||||
private ResultSetGroupDockingPane groupPane; |
/** |
||||||
private ItemListener groupListener = new ItemListener() { |
* 单元格元素 数据列编辑器 |
||||||
|
* |
||||||
@Override |
* @author yaoh.wu |
||||||
public void itemStateChanged(ItemEvent e) { |
* @version 2017年7月24日 |
||||||
if (e == null) { |
* @since 9.0 |
||||||
//分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存
|
*/ |
||||||
groupPane.update(); |
public class CellDSColumnEditor extends CellQuickEditor { |
||||||
fireTargetModified(); |
|
||||||
return; |
private JPanel dsColumnRegion; |
||||||
} |
private JPanel centerPane; |
||||||
if (e.getStateChange() == ItemEvent.DESELECTED) { |
//数据集列选择组件
|
||||||
if (!isEditing) { |
private SelectedDataColumnPane dataPane; |
||||||
return; |
//数据分组设置组件
|
||||||
} |
private ResultSetGroupDockingPane groupPane; |
||||||
groupPane.update(); |
//过滤条件面板
|
||||||
fireTargetModified(); |
private JPanel conditionPane; |
||||||
} |
// 基本和高级设置
|
||||||
} |
private ArrayList<CellEditorPane> paneList; |
||||||
}; |
// 基本和高级设置 卡片布局
|
||||||
|
private CardLayout card; |
||||||
private ItemListener dataListener = new ItemListener() { |
// 基本和高级设置 容器面板
|
||||||
|
private JPanel center; |
||||||
@Override |
// 卡片布局TAB切换按钮
|
||||||
public void itemStateChanged(ItemEvent e) { |
private UIHeadGroup tabsHeaderIconPane; |
||||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
// 分组设置监听器
|
||||||
if (!isEditing) { |
private ItemListener groupListener = new ItemListener() { |
||||||
return; |
@Override |
||||||
} |
public void itemStateChanged(ItemEvent e) { |
||||||
dataPane.update(cellElement); |
if (e == null) { |
||||||
fireTargetModified(); |
//分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存
|
||||||
} |
groupPane.update(); |
||||||
} |
fireTargetModified(); |
||||||
}; |
return; |
||||||
|
} |
||||||
private CellDSColumnEditor() { |
if (e.getStateChange() == ItemEvent.DESELECTED) { |
||||||
super(); |
if (!isEditing) { |
||||||
} |
return; |
||||||
|
} |
||||||
@Override |
groupPane.update(); |
||||||
public JComponent createCenterBody() { |
fireTargetModified(); |
||||||
double p = TableLayout.PREFERRED; |
} |
||||||
double f = TableLayout.FILL; |
} |
||||||
double[] columnSize = {p, f}; |
}; |
||||||
double[] rowSize = {p, p, p, p}; |
//数据集列设置监听器
|
||||||
Component[][] components = new Component[][]{}; |
private ItemListener dataListener = new ItemListener() { |
||||||
dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
@Override |
||||||
centerPane = new JPanel(new BorderLayout(0, 0)); |
public void itemStateChanged(ItemEvent e) { |
||||||
centerPane.add(dsColumnRegion, BorderLayout.CENTER); |
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||||
return centerPane; |
if (!isEditing) { |
||||||
} |
return; |
||||||
|
} |
||||||
// august:这里面的东西都全部重新动态生成,不然容易出错
|
dataPane.update(cellElement); |
||||||
@Override |
fireTargetModified(); |
||||||
protected void refreshDetails() { |
} |
||||||
JPanel pane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); |
} |
||||||
pane.add(new UIButton(new DSColumnConditionAction(tc)), BorderLayout.WEST); |
}; |
||||||
pane.add(new UIButton(new DSColumnAdvancedAction(tc)), BorderLayout.CENTER); |
|
||||||
double p = TableLayout.PREFERRED; |
private CellDSColumnEditor() { |
||||||
double f = TableLayout.FILL; |
super(); |
||||||
double[] columnSize = {p, f}; |
} |
||||||
double[] rowSize = {p, p, p, p}; |
|
||||||
Component[][] components = new Component[][]{ |
/** |
||||||
new Component[]{new UIButton(new DSColumnBasicAction(tc)), null}, |
* Test Main |
||||||
new Component[]{pane, null}, |
* |
||||||
new Component[]{dataPane = new SelectedDataColumnPane(false), null}, |
* @param args 参数 |
||||||
new Component[]{groupPane = new ResultSetGroupDockingPane(tc), null} |
*/ |
||||||
}; |
public static void main(String[] args) { |
||||||
centerPane.removeAll(); |
JFrame jf = new JFrame("test"); |
||||||
dsColumnRegion = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
||||||
centerPane.add(dsColumnRegion, BorderLayout.CENTER); |
JPanel content = (JPanel) jf.getContentPane(); |
||||||
dataPane.addListener(dataListener); |
content.setLayout(new BorderLayout()); |
||||||
groupPane.addListener(groupListener); |
content.add(new CellDSColumnEditor(), BorderLayout.CENTER); |
||||||
dataPane.populate(null, cellElement); |
GUICoreUtils.centerWindow(jf); |
||||||
groupPane.populate(cellElement); |
jf.setSize(220, 400); |
||||||
this.validate(); |
jf.setVisible(true); |
||||||
} |
} |
||||||
|
|
||||||
|
/** |
||||||
/** |
* 创建面板占位 |
||||||
* for 关闭时候释放 |
* |
||||||
*/ |
* @return JComponent 详细信息面板 |
||||||
public void release () { |
*/ |
||||||
super.release(); |
@Override |
||||||
dsColumnRegion = null; |
public JComponent createCenterBody() { |
||||||
centerPane = null; |
this.createPanes(); |
||||||
} |
this.createSwitchTab(); |
||||||
|
dsColumnRegion = new JPanel(new BorderLayout()); |
||||||
|
dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); |
||||||
|
dsColumnRegion.add(center, BorderLayout.CENTER); |
||||||
|
centerPane = new JPanel(new BorderLayout()); |
||||||
|
centerPane.add(dsColumnRegion, BorderLayout.CENTER); |
||||||
|
return centerPane; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 内容全部重新动态生成,不然容易出错 |
||||||
|
* 刷新详细信息面板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
protected void refreshDetails() { |
||||||
|
|
||||||
|
this.createPanes(); |
||||||
|
this.createSwitchTab(); |
||||||
|
dsColumnRegion = new JPanel(new BorderLayout()); |
||||||
|
dsColumnRegion.add(tabsHeaderIconPane, BorderLayout.NORTH); |
||||||
|
dsColumnRegion.add(center, BorderLayout.CENTER); |
||||||
|
//必须removeAll之后再添加;重新再实例化一个centerJPanel,因为对象变了会显示不出来
|
||||||
|
centerPane.removeAll(); |
||||||
|
centerPane.add(dsColumnRegion, BorderLayout.CENTER); |
||||||
|
for (CellEditorPane cellEditorPane : paneList) { |
||||||
|
cellEditorPane.populate(cellElement); |
||||||
|
} |
||||||
|
this.validate(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 关闭时候释放 |
||||||
|
*/ |
||||||
|
public void release() { |
||||||
|
super.release(); |
||||||
|
dsColumnRegion = null; |
||||||
|
centerPane = null; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 初始化基本和高级设置切换tab |
||||||
|
*/ |
||||||
|
private void createSwitchTab() { |
||||||
|
String[] iconArray = new String[paneList.size()]; |
||||||
|
card = new CardLayout(); |
||||||
|
center = new JPanel(card); |
||||||
|
center.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||||
|
for (int i = 0; i < paneList.size(); i++) { |
||||||
|
CellEditorPane pane = paneList.get(i); |
||||||
|
iconArray[i] = pane.getIconPath(); |
||||||
|
center.add(pane, pane.title4PopupWindow()); |
||||||
|
} |
||||||
|
tabsHeaderIconPane = new UIHeadGroup(iconArray) { |
||||||
|
@Override |
||||||
|
public void tabChanged(int index) { |
||||||
|
card.show(center, paneList.get(index).title4PopupWindow()); |
||||||
|
paneList.get(index).populate(cellElement); |
||||||
|
} |
||||||
|
}; |
||||||
|
tabsHeaderIconPane.setNeedLeftRightOutLine(false); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 刷新数据列基本和高级设置面板 |
||||||
|
*/ |
||||||
|
private void createPanes() { |
||||||
|
paneList = new ArrayList<>(); |
||||||
|
|
||||||
|
/*基本设置面板*/ |
||||||
|
this.dataPane = new SelectedDataColumnPane(); |
||||||
|
this.groupPane = new ResultSetGroupDockingPane(tc); |
||||||
|
double p = TableLayout.PREFERRED, f = TableLayout.FILL; |
||||||
|
double[] rowSize = {p}, columnSize = {p, f}; |
||||||
|
UILabel uiLabel = new UILabel("filter"); |
||||||
|
UIButton uiButton = new UIButton(); |
||||||
|
if (tc != null) { |
||||||
|
//第一次初始化时tc为空,引发NullPointerException
|
||||||
|
uiButton = new UIButton(new DSColumnConditionAction(tc)); |
||||||
|
} |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{uiLabel, uiButton} |
||||||
|
}; |
||||||
|
this.conditionPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
|
dataPane.addListener(dataListener); |
||||||
|
groupPane.addListener(groupListener); |
||||||
|
paneList.add(new DSColumnBasicEditorPane(cellElement, dataPane, groupPane, conditionPane)); |
||||||
|
|
||||||
|
/*高级设置面板*/ |
||||||
|
paneList.add(new DSColumnAdvancedEditorPane()); |
||||||
|
} |
||||||
} |
} |
@ -1,75 +1,77 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import java.awt.event.ActionEvent; |
import com.fr.base.BaseUtils; |
||||||
import java.awt.event.ActionListener; |
import com.fr.base.Style; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
import javax.swing.BorderFactory; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
import javax.swing.JComponent; |
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.report.SelectImagePane; |
||||||
import com.fr.base.BaseUtils; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.base.Style; |
import com.fr.general.Inter; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
import com.fr.design.mainframe.DesignerContext; |
import com.fr.report.cell.cellattr.CellImage; |
||||||
import com.fr.design.report.SelectImagePane; |
|
||||||
import com.fr.design.dialog.DialogActionAdapter; |
import javax.swing.*; |
||||||
import com.fr.general.ComparatorUtils; |
import java.awt.event.ActionEvent; |
||||||
import com.fr.general.Inter; |
import java.awt.event.ActionListener; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
|
||||||
import com.fr.report.cell.cellattr.CellImage; |
/** |
||||||
|
* 单元格元素图片编辑器 |
||||||
public class CellImageQuickEditor extends CellQuickEditor { |
* TODO 9.0大体上没有改动 |
||||||
private static CellImageQuickEditor THIS; |
*/ |
||||||
|
public class CellImageQuickEditor extends CellQuickEditor { |
||||||
public static final CellImageQuickEditor getInstance() { |
private static CellImageQuickEditor THIS; |
||||||
if(THIS == null) { |
|
||||||
THIS = new CellImageQuickEditor(); |
public static final CellImageQuickEditor getInstance() { |
||||||
} |
if (THIS == null) { |
||||||
return THIS; |
THIS = new CellImageQuickEditor(); |
||||||
} |
} |
||||||
|
return THIS; |
||||||
private CellImageQuickEditor() { |
} |
||||||
super(); |
|
||||||
} |
private CellImageQuickEditor() { |
||||||
|
super(); |
||||||
@Override |
} |
||||||
public JComponent createCenterBody() { |
|
||||||
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); |
@Override |
||||||
editbutton.addActionListener(new ActionListener() { |
public JComponent createCenterBody() { |
||||||
|
UIButton editbutton = new UIButton(Inter.getLocText("Edit"), BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png")); |
||||||
@Override |
editbutton.addActionListener(new ActionListener() { |
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
showEditingDialog(); |
@Override |
||||||
} |
public void actionPerformed(ActionEvent e) { |
||||||
}); |
showEditingDialog(); |
||||||
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
} |
||||||
editbutton.setMargin(null); |
}); |
||||||
editbutton.setOpaque(false); |
editbutton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||||
return editbutton; |
editbutton.setMargin(null); |
||||||
} |
editbutton.setOpaque(false); |
||||||
|
return editbutton; |
||||||
private void showEditingDialog() { |
} |
||||||
final SelectImagePane imageEditorPane = new SelectImagePane(); |
|
||||||
imageEditorPane.populate(cellElement); |
private void showEditingDialog() { |
||||||
final Object oldValue = cellElement.getValue(); |
final SelectImagePane imageEditorPane = new SelectImagePane(); |
||||||
final Style oldStyle = cellElement.getStyle(); |
imageEditorPane.populate(cellElement); |
||||||
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
final Object oldValue = cellElement.getValue(); |
||||||
|
final Style oldStyle = cellElement.getStyle(); |
||||||
@Override |
imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||||
public void doOk() { |
|
||||||
CellImage cellImage = imageEditorPane.update(); |
@Override |
||||||
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
public void doOk() { |
||||||
cellElement.setValue(cellImage.getImage()); |
CellImage cellImage = imageEditorPane.update(); |
||||||
cellElement.setStyle(cellImage.getStyle()); |
if (!ComparatorUtils.equals(cellImage.getImage(), oldValue) || !ComparatorUtils.equals(cellImage.getStyle(), oldStyle)) { |
||||||
fireTargetModified(); |
cellElement.setValue(cellImage.getImage()); |
||||||
} |
cellElement.setStyle(cellImage.getStyle()); |
||||||
} |
fireTargetModified(); |
||||||
|
} |
||||||
}).setVisible(true); |
} |
||||||
} |
|
||||||
|
}).setVisible(true); |
||||||
@Override |
} |
||||||
protected void refreshDetails() { |
|
||||||
|
@Override |
||||||
} |
protected void refreshDetails() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
} |
} |
@ -1,50 +1,50 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import javax.swing.BorderFactory; |
import com.fr.design.actions.insert.cell.RichTextCellAction; |
||||||
import javax.swing.JComponent; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.general.Inter; |
||||||
import com.fr.design.actions.insert.cell.RichTextCellAction; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
|
||||||
import com.fr.general.Inter; |
import javax.swing.*; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
|
||||||
|
/** |
||||||
public class CellRichTextEditor extends CellQuickEditor { |
* 单元格元素富文本编辑器 |
||||||
private UIButton subReportButton; |
* TODO 9.0 大体上没有改动 |
||||||
private static CellRichTextEditor THIS; |
*/ |
||||||
|
public class CellRichTextEditor extends CellQuickEditor { |
||||||
public static final CellRichTextEditor getInstance() { |
private UIButton subReportButton; |
||||||
if(THIS == null) { |
private static CellRichTextEditor THIS; |
||||||
THIS = new CellRichTextEditor(); |
|
||||||
} |
public static final CellRichTextEditor getInstance() { |
||||||
return THIS; |
if (THIS == null) { |
||||||
} |
THIS = new CellRichTextEditor(); |
||||||
|
} |
||||||
private CellRichTextEditor() { |
return THIS; |
||||||
super(); |
} |
||||||
} |
|
||||||
|
private CellRichTextEditor() { |
||||||
/** |
super(); |
||||||
* 创建界面上中间的部分 |
} |
||||||
* |
|
||||||
* @return 界面元素 |
/** |
||||||
* |
* 创建界面上中间的部分 |
||||||
* |
* |
||||||
* @date 2014-12-7-下午9:41:52 |
* @return 界面元素 |
||||||
* |
* @date 2014-12-7-下午9:41:52 |
||||||
*/ |
*/ |
||||||
public JComponent createCenterBody() { |
public JComponent createCenterBody() { |
||||||
subReportButton = new UIButton(); |
subReportButton = new UIButton(); |
||||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||||
subReportButton.setMargin(null); |
subReportButton.setMargin(null); |
||||||
subReportButton.setOpaque(false); |
subReportButton.setOpaque(false); |
||||||
return subReportButton; |
return subReportButton; |
||||||
} |
} |
||||||
|
|
||||||
@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("FR-Designer_RichTextEditor")); |
||||||
subReportButton.setAction(subReportCellAction); |
subReportButton.setAction(subReportCellAction); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -1,151 +1,155 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import java.awt.event.KeyAdapter; |
import com.fr.base.Formula; |
||||||
import java.awt.event.KeyEvent; |
import com.fr.base.Style; |
||||||
|
import com.fr.base.TextFormat; |
||||||
import javax.swing.JComponent; |
import com.fr.design.gui.itextfield.UITextField; |
||||||
import javax.swing.event.DocumentEvent; |
import com.fr.grid.selection.CellSelection; |
||||||
import javax.swing.event.DocumentListener; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
|
import com.fr.report.ReportHelper; |
||||||
import com.fr.base.Formula; |
import com.fr.report.cell.DefaultTemplateCellElement; |
||||||
import com.fr.base.Style; |
import com.fr.stable.ColumnRow; |
||||||
import com.fr.base.TextFormat; |
import com.fr.stable.StringUtils; |
||||||
import com.fr.design.gui.itextfield.UITextField; |
|
||||||
import com.fr.grid.selection.CellSelection; |
import javax.swing.*; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
import javax.swing.event.DocumentEvent; |
||||||
import com.fr.report.ReportHelper; |
import javax.swing.event.DocumentListener; |
||||||
import com.fr.report.cell.DefaultTemplateCellElement; |
import java.awt.event.KeyAdapter; |
||||||
import com.fr.stable.ColumnRow; |
import java.awt.event.KeyEvent; |
||||||
import com.fr.stable.StringUtils; |
|
||||||
|
/** |
||||||
public class CellStringQuickEditor extends CellQuickEditor { |
* |
||||||
|
*/ |
||||||
|
public class CellStringQuickEditor extends CellQuickEditor { |
||||||
private static CellStringQuickEditor THIS; |
//instance
|
||||||
|
private static CellStringQuickEditor THIS; |
||||||
private UITextField stringTextField; |
//文本域
|
||||||
|
//TODO 9.0 文本域要根据具体文本数量自适应大小,比较难搞,先跳过。
|
||||||
private boolean isEditing = false; |
private UITextField stringTextField; |
||||||
|
//编辑状态
|
||||||
public static final CellStringQuickEditor getInstance() { |
private boolean isEditing = false; |
||||||
if (THIS == null) { |
|
||||||
THIS = new CellStringQuickEditor(); |
public static CellStringQuickEditor getInstance() { |
||||||
} |
if (THIS == null) { |
||||||
return THIS; |
THIS = new CellStringQuickEditor(); |
||||||
} |
} |
||||||
|
return THIS; |
||||||
// august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置
|
} |
||||||
private boolean reserveInResult = false; |
|
||||||
private boolean reserveOnWriteOrAnaly = true; |
//august:如果是原来编辑的是公式,要保留公式里的这些属性,不然在公式和字符串转化时,就会丢失这些属性设置。
|
||||||
|
private boolean reserveInResult = false; |
||||||
private CellStringQuickEditor() { |
private boolean reserveOnWriteOrAnaly = true; |
||||||
super(); |
|
||||||
} |
private DocumentListener documentListener = new DocumentListener() { |
||||||
|
@Override |
||||||
@Override |
public void insertUpdate(DocumentEvent e) { |
||||||
/** |
changeReportPaneCell(stringTextField.getText().trim()); |
||||||
* |
} |
||||||
*/ |
|
||||||
public JComponent createCenterBody() { |
@Override |
||||||
stringTextField = new UITextField(); |
public void removeUpdate(DocumentEvent e) { |
||||||
stringTextField.addKeyListener(new KeyAdapter() { |
changeReportPaneCell(stringTextField.getText().trim()); |
||||||
|
} |
||||||
@Override |
|
||||||
public void keyReleased(KeyEvent e) { |
@Override |
||||||
if (tc != null) { |
public void changedUpdate(DocumentEvent e) { |
||||||
tc.getGrid().dispatchEvent(e); |
changeReportPaneCell(stringTextField.getText().trim()); |
||||||
} |
} |
||||||
} |
|
||||||
|
}; |
||||||
}); |
|
||||||
|
private CellStringQuickEditor() { |
||||||
return stringTextField; |
super(); |
||||||
} |
} |
||||||
|
|
||||||
DocumentListener documentListener = new DocumentListener() { |
/** |
||||||
|
* 详细信息面板 |
||||||
@Override |
* todo 文本框可自适应大小,公式编辑也是在这边,如果是公式那么要加一个公式编辑器的触发按钮 |
||||||
public void insertUpdate(DocumentEvent e) { |
*/ |
||||||
changeReportPaneCell(stringTextField.getText().trim()); |
@Override |
||||||
} |
public JComponent createCenterBody() { |
||||||
|
stringTextField = new UITextField(); |
||||||
@Override |
stringTextField.addKeyListener(new KeyAdapter() { |
||||||
public void removeUpdate(DocumentEvent e) { |
@Override |
||||||
changeReportPaneCell(stringTextField.getText().trim()); |
public void keyReleased(KeyEvent e) { |
||||||
} |
if (tc != null) { |
||||||
|
tc.getGrid().dispatchEvent(e); |
||||||
@Override |
} |
||||||
public void changedUpdate(DocumentEvent e) { |
} |
||||||
changeReportPaneCell(stringTextField.getText().trim()); |
}); |
||||||
} |
return stringTextField; |
||||||
|
} |
||||||
}; |
|
||||||
|
|
||||||
protected void changeReportPaneCell(String tmpText) { |
private void changeReportPaneCell(String tmpText) { |
||||||
isEditing = true; |
isEditing = true; |
||||||
//refresh一下,如果单元格内有新添加的控件,此时并不知道
|
//refresh一下,如果单元格内有新添加的控件,此时并不知道
|
||||||
CellSelection cs1 = (CellSelection) tc.getSelection(); |
CellSelection cs1 = (CellSelection) tc.getSelection(); |
||||||
ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); |
ColumnRow columnRow = ColumnRow.valueOf(cs1.getColumn(), cs1.getRow()); |
||||||
columnRowTextField.setText(columnRow.toString()); |
columnRowTextField.setText(columnRow.toString()); |
||||||
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); |
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow()); |
||||||
|
|
||||||
if (cellElement == null) { |
if (cellElement == null) { |
||||||
CellSelection cs = (CellSelection) tc.getSelection(); |
CellSelection cs = (CellSelection) tc.getSelection(); |
||||||
cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); |
cellElement = new DefaultTemplateCellElement(cs.getColumn(), cs.getRow()); |
||||||
tc.getEditingElementCase().addCellElement(cellElement, false); |
tc.getEditingElementCase().addCellElement(cellElement, false); |
||||||
} |
} |
||||||
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
if (tmpText != null && (tmpText.length() > 0 && tmpText.charAt(0) == '=')) { |
||||||
Formula textFormula = new Formula(tmpText); |
Formula textFormula = new Formula(tmpText); |
||||||
textFormula.setReserveInResult(reserveInResult); |
textFormula.setReserveInResult(reserveInResult); |
||||||
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
textFormula.setReserveOnWriteOrAnaly(reserveOnWriteOrAnaly); |
||||||
cellElement.setValue(textFormula); |
cellElement.setValue(textFormula); |
||||||
} else { |
} else { |
||||||
Style style = cellElement.getStyle(); |
Style style = cellElement.getStyle(); |
||||||
if (cellElement != null && style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
if (style != null && style.getFormat() != null && style.getFormat() == TextFormat.getInstance()) { |
||||||
cellElement.setValue(tmpText); |
cellElement.setValue(tmpText); |
||||||
} else { |
} else { |
||||||
cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
cellElement.setValue(ReportHelper.convertGeneralStringAccordingToExcel(tmpText)); |
||||||
} |
} |
||||||
} |
} |
||||||
fireTargetModified(); |
fireTargetModified(); |
||||||
stringTextField.requestFocus(); |
stringTextField.requestFocus(); |
||||||
isEditing = false; |
isEditing = false; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
/** |
||||||
protected void refreshDetails() { |
* 刷新详细内容 |
||||||
String str = null; |
*/ |
||||||
if (cellElement == null) { |
@Override |
||||||
str = StringUtils.EMPTY; |
protected void refreshDetails() { |
||||||
} else { |
String str; |
||||||
Object value = cellElement.getValue(); |
if (cellElement == null) { |
||||||
if (value == null) { |
str = StringUtils.EMPTY; |
||||||
str = StringUtils.EMPTY; |
} else { |
||||||
} else if (value instanceof Formula) { |
Object value = cellElement.getValue(); |
||||||
Formula formula = (Formula) value; |
if (value == null) { |
||||||
str = formula.getContent(); |
str = StringUtils.EMPTY; |
||||||
reserveInResult = formula.isReserveInResult(); |
} else if (value instanceof Formula) { |
||||||
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
Formula formula = (Formula) value; |
||||||
} else { |
str = formula.getContent(); |
||||||
str = value.toString(); |
reserveInResult = formula.isReserveInResult(); |
||||||
} |
reserveOnWriteOrAnaly = formula.isReserveOnWriteOrAnaly(); |
||||||
} |
} else { |
||||||
showText(str); |
str = value.toString(); |
||||||
stringTextField.setEditable(tc.isSelectedOneCell()); |
} |
||||||
} |
} |
||||||
|
showText(str); |
||||||
/** |
stringTextField.setEditable(tc.isSelectedOneCell()); |
||||||
* |
} |
||||||
* @param str |
|
||||||
*/ |
/** |
||||||
public void showText(String str) { |
* 显示文本 |
||||||
// 本编辑框在输入过程中引发的后续事件如果还调用了本框的setText方法不能执行
|
* |
||||||
if (isEditing) { |
* @param str 文本 |
||||||
return; |
*/ |
||||||
} |
public void showText(String str) { |
||||||
stringTextField.getDocument().removeDocumentListener(documentListener); |
// 正在编辑时不处理
|
||||||
stringTextField.setText(str); |
if (isEditing) { |
||||||
stringTextField.getDocument().addDocumentListener(documentListener); |
return; |
||||||
} |
} |
||||||
|
stringTextField.getDocument().removeDocumentListener(documentListener); |
||||||
|
stringTextField.setText(str); |
||||||
|
stringTextField.getDocument().addDocumentListener(documentListener); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
@ -1,42 +1,45 @@ |
|||||||
package com.fr.quickeditor.cellquick; |
package com.fr.quickeditor.cellquick; |
||||||
|
|
||||||
import javax.swing.BorderFactory; |
import com.fr.design.actions.insert.cell.SubReportCellAction; |
||||||
import javax.swing.JComponent; |
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.general.Inter; |
||||||
import com.fr.design.actions.insert.cell.SubReportCellAction; |
import com.fr.quickeditor.CellQuickEditor; |
||||||
import com.fr.design.gui.ibutton.UIButton; |
|
||||||
import com.fr.general.Inter; |
import javax.swing.*; |
||||||
import com.fr.quickeditor.CellQuickEditor; |
|
||||||
|
/** |
||||||
public class CellSubReportEditor extends CellQuickEditor { |
* 单元格元素子报表编辑器 |
||||||
private UIButton subReportButton; |
* TODO 9.0大体上没有改动 |
||||||
private static CellSubReportEditor THIS; |
*/ |
||||||
|
public class CellSubReportEditor extends CellQuickEditor { |
||||||
public static final CellSubReportEditor getInstance() { |
private UIButton subReportButton; |
||||||
if(THIS == null) { |
private static CellSubReportEditor THIS; |
||||||
THIS = new CellSubReportEditor(); |
|
||||||
} |
public static final CellSubReportEditor getInstance() { |
||||||
return THIS; |
if (THIS == null) { |
||||||
} |
THIS = new CellSubReportEditor(); |
||||||
|
} |
||||||
private CellSubReportEditor() { |
return THIS; |
||||||
super(); |
} |
||||||
} |
|
||||||
|
private CellSubReportEditor() { |
||||||
@Override |
super(); |
||||||
public JComponent createCenterBody() { |
} |
||||||
subReportButton = new UIButton(); |
|
||||||
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
@Override |
||||||
subReportButton.setMargin(null); |
public JComponent createCenterBody() { |
||||||
subReportButton.setOpaque(false); |
subReportButton = new UIButton(); |
||||||
return subReportButton; |
subReportButton.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); |
||||||
} |
subReportButton.setMargin(null); |
||||||
|
subReportButton.setOpaque(false); |
||||||
@Override |
return subReportButton; |
||||||
protected void refreshDetails() { |
} |
||||||
SubReportCellAction subReportCellAction = new SubReportCellAction(tc); |
|
||||||
subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); |
@Override |
||||||
subReportButton.setAction(subReportCellAction); |
protected void refreshDetails() { |
||||||
} |
SubReportCellAction subReportCellAction = new SubReportCellAction(tc); |
||||||
|
subReportCellAction.setName(Inter.getLocText(new String[]{"Edit", "Sub_Report"})); |
||||||
|
subReportButton.setAction(subReportCellAction); |
||||||
|
} |
||||||
|
|
||||||
} |
} |
@ -1,69 +1,67 @@ |
|||||||
package com.fr.design.data.datapane; |
package com.fr.design.data.datapane; |
||||||
|
|
||||||
import java.awt.*; |
|
||||||
|
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
|
|
||||||
import com.fr.design.constants.LayoutConstants; |
import com.fr.design.constants.LayoutConstants; |
||||||
import com.fr.design.data.datapane.preview.PreviewLabel; |
import com.fr.design.data.datapane.preview.PreviewLabel; |
||||||
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; |
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
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.DesignerBean; |
import com.fr.design.mainframe.DesignerBean; |
||||||
import com.fr.design.mainframe.DesignerContext; |
import com.fr.design.mainframe.DesignerContext; |
||||||
import com.fr.general.Inter; |
|
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
public class VerticalChoosePane extends ChoosePane implements DesignerBean{ |
public class VerticalChoosePane extends ChoosePane implements DesignerBean { |
||||||
|
|
||||||
public VerticalChoosePane(Previewable previewable) { |
public VerticalChoosePane(Previewable previewable) { |
||||||
this(previewable, -1); |
this(previewable, -1); |
||||||
} |
} |
||||||
|
|
||||||
public VerticalChoosePane(Previewable previewable, int labelSize) { |
public VerticalChoosePane(Previewable previewable, int labelSize) { |
||||||
super(previewable, labelSize); |
super(previewable, labelSize); |
||||||
DesignerContext.setDesignerBean("databasename", this); |
DesignerContext.setDesignerBean("databasename", this); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) { |
protected void initComponentsLayout(PreviewLabel previewLabel, int labelSize) { |
||||||
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, p }; |
double[] rowSize = {p, p, p}; |
||||||
|
|
||||||
JPanel rs = new JPanel(new BorderLayout(0, 0)); |
JPanel rs = new JPanel(new BorderLayout(0, 0)); |
||||||
rs.add(tableNameComboBox, BorderLayout.CENTER); |
rs.add(tableNameComboBox, BorderLayout.CENTER); |
||||||
rs.add(GUICoreUtils.createFlowPane(new Component[]{new RefreshLabel(this), previewLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); |
rs.add(GUICoreUtils.createFlowPane(new Component[]{new RefreshLabel(this), previewLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); |
||||||
|
|
||||||
UILabel l1 = new UILabel(Inter.getLocText("Database") + ":", UILabel.RIGHT); |
UILabel l1 = new UILabel(Inter.getLocText("FR-Designer_Database"), UILabel.LEFT); |
||||||
UILabel l2 = new UILabel(Inter.getLocText("Model") + ":", UILabel.RIGHT); |
UILabel l2 = new UILabel(Inter.getLocText("FR-Designer_Model"), UILabel.LEFT); |
||||||
UILabel l3 = new UILabel(Inter.getLocText(new String[]{"Database", "Table"}) + ":", UILabel.RIGHT); |
UILabel l3 = new UILabel(Inter.getLocText(new String[]{"FR-Designer_Database", "FR-Designer_Table"}), UILabel.LEFT); |
||||||
|
|
||||||
if (labelSize > 0) { |
if (labelSize > 0) { |
||||||
Dimension pSize = new Dimension(labelSize, 20); |
Dimension pSize = new Dimension(labelSize, 20); |
||||||
l1.setPreferredSize(pSize); |
l1.setPreferredSize(pSize); |
||||||
l2.setPreferredSize(pSize); |
l2.setPreferredSize(pSize); |
||||||
l3.setPreferredSize(pSize); |
l3.setPreferredSize(pSize); |
||||||
} |
} |
||||||
|
|
||||||
Component[][] components = new Component[][]{ |
Component[][] components = new Component[][]{ |
||||||
new Component[]{l1, dsNameComboBox}, |
new Component[]{l1, dsNameComboBox}, |
||||||
new Component[]{l2, schemaBox}, |
new Component[]{l2, schemaBox}, |
||||||
new Component[]{l3, rs} |
new Component[]{l3, rs} |
||||||
}; |
}; |
||||||
|
|
||||||
JPanel content = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); |
JPanel content = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
this.setLayout(new BorderLayout()); |
this.setLayout(new BorderLayout()); |
||||||
this.add(content,BorderLayout.CENTER); |
this.add(content, BorderLayout.CENTER); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override |
@Override |
||||||
public void refreshBeanElement() { |
public void refreshBeanElement() { |
||||||
initDsNameComboBox(); |
initDsNameComboBox(); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
@ -0,0 +1,418 @@ |
|||||||
|
package com.fr.design.editor; |
||||||
|
|
||||||
|
import com.fr.base.Formula; |
||||||
|
import com.fr.design.DesignerEnvManager; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.editor.editor.*; |
||||||
|
import com.fr.design.event.GlobalNameListener; |
||||||
|
import com.fr.design.event.GlobalNameObserver; |
||||||
|
import com.fr.design.event.UIObserver; |
||||||
|
import com.fr.design.event.UIObserverListener; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
|
import com.fr.design.gui.imenu.UIMenuItem; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.DesignerContext; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by MoMeak on 2017/7/26. |
||||||
|
*/ |
||||||
|
|
||||||
|
public class DoubleDeckValueEditorPane extends BasicPane implements UIObserver, GlobalNameObserver { |
||||||
|
|
||||||
|
private static final int CENTERPANE_WIDTH = 200; |
||||||
|
private Editor[] cards; |
||||||
|
|
||||||
|
private Editor currentEditor; |
||||||
|
|
||||||
|
private UIButton arrowButton; |
||||||
|
private JPopupMenu menu; |
||||||
|
private JPanel centerPane; |
||||||
|
private CardLayout cardLayout; |
||||||
|
private Object value; |
||||||
|
private UIButtonGroup upButton; |
||||||
|
private GlobalNameListener globalNameListener = null; |
||||||
|
private UIObserverListener uiObserverListener = null; |
||||||
|
|
||||||
|
public DoubleDeckValueEditorPane(Editor[] cards) { |
||||||
|
this(cards, null, null); |
||||||
|
} |
||||||
|
|
||||||
|
public DoubleDeckValueEditorPane(Editor[] cards, String popupName, String textEditorValue) { |
||||||
|
initComponents(cards, popupName, textEditorValue, CENTERPANE_WIDTH); |
||||||
|
} |
||||||
|
|
||||||
|
public DoubleDeckValueEditorPane(Editor[] cards, String popupName, String textEditorValue, int centerPaneWidth) { |
||||||
|
initComponents(cards, popupName, textEditorValue, centerPaneWidth); |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
JFrame jf = new JFrame("test"); |
||||||
|
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||||
|
JPanel content = (JPanel) jf.getContentPane(); |
||||||
|
content.setLayout(new BorderLayout()); |
||||||
|
content.add(new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula"))}), BorderLayout.NORTH); |
||||||
|
GUICoreUtils.centerWindow(jf); |
||||||
|
jf.setSize(290, 400); |
||||||
|
jf.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initComponents(final Editor[] cards, String popupName, String textEditorValue, int centerPaneWidth) { |
||||||
|
this.setLayout(new BorderLayout(0, 4)); |
||||||
|
this.cards = cards; |
||||||
|
|
||||||
|
final String[] nameArray = new String[cards.length]; |
||||||
|
for (int i = 0; i < cards.length; i++) { |
||||||
|
nameArray[i] = cards[i].getName(); |
||||||
|
} |
||||||
|
upButton = new UIButtonGroup(nameArray); |
||||||
|
upButton.setAllToolTips(nameArray); |
||||||
|
this.add(upButton, BorderLayout.NORTH); |
||||||
|
|
||||||
|
|
||||||
|
centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
|
||||||
|
setCurrentEditor(0); |
||||||
|
|
||||||
|
centerPane.setPreferredSize(new Dimension(centerPaneWidth, centerPane.getPreferredSize().height)); |
||||||
|
menu = createPopMenu(); |
||||||
|
upButton.addChangeListener(new ChangeListener() { |
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
if (globalNameListener != null) { |
||||||
|
globalNameListener.setGlobalName(Inter.getLocText("CellWrite-InsertRow_Policy")); |
||||||
|
} |
||||||
|
Object oldValue = currentEditor.getValue(); |
||||||
|
setCurrentEditor(upButton.getSelectedIndex()); |
||||||
|
currentEditor.selected(); |
||||||
|
value = currentEditor.getValue(); |
||||||
|
if (uiObserverListener != null) { |
||||||
|
uiObserverListener.doChange(); |
||||||
|
} |
||||||
|
|
||||||
|
DoubleDeckValueEditorPane.this.firePropertyChange("value", oldValue, value); |
||||||
|
} |
||||||
|
}); |
||||||
|
this.add(centerPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText("FR-Designer_Values-Editor"); |
||||||
|
} |
||||||
|
|
||||||
|
public Editor getCurrentEditor() { |
||||||
|
return currentEditor; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCurrentEditorIndex() { |
||||||
|
for (int i = 0; i < cards.length; i++) { |
||||||
|
if (cards[i].getClass() == currentEditor.getClass()) { |
||||||
|
return i; |
||||||
|
} |
||||||
|
} |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCurrentEditor(int i) { |
||||||
|
currentEditor = this.cards[i]; |
||||||
|
centerPane.removeAll(); |
||||||
|
centerPane.add(currentEditor); |
||||||
|
centerPane.validate(); |
||||||
|
centerPane.repaint(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setCurrentEditor(Class editorClass) { |
||||||
|
for (int i = 0; i < cards.length; i++) { |
||||||
|
if (cards[i].getClass() == editorClass) { |
||||||
|
setCurrentEditor(i); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private JPopupMenu createPopMenu() { |
||||||
|
JPopupMenu scate = new JPopupMenu(); |
||||||
|
|
||||||
|
if (this.cards == null) { |
||||||
|
return scate; |
||||||
|
} |
||||||
|
|
||||||
|
for (int i = 0; i < this.cards.length; i++) { |
||||||
|
UIMenuItem item = new UIMenuItem(cards[i].getName()); |
||||||
|
final int j = i; |
||||||
|
item.addActionListener(new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (globalNameListener != null) { |
||||||
|
globalNameListener.setGlobalName(Inter.getLocText("CellWrite-InsertRow_Policy")); |
||||||
|
} |
||||||
|
Object oldValue = currentEditor.getValue(); |
||||||
|
setCurrentEditor(j); |
||||||
|
currentEditor.selected(); |
||||||
|
value = currentEditor.getValue(); |
||||||
|
if (uiObserverListener != null) { |
||||||
|
uiObserverListener.doChange(); |
||||||
|
} |
||||||
|
|
||||||
|
DoubleDeckValueEditorPane.this.firePropertyChange("value", oldValue, value); |
||||||
|
} |
||||||
|
}); |
||||||
|
scate.add(item); |
||||||
|
if (i < cards.length - 1) { |
||||||
|
scate.addSeparator(); |
||||||
|
} |
||||||
|
} |
||||||
|
return scate; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Object object) { |
||||||
|
for (int i = 0; i < cards.length; i++) { |
||||||
|
if (cards[i].accept(object)) { |
||||||
|
setCardValue(i, object); |
||||||
|
|
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Object object, String name) { |
||||||
|
for (int i = 0; i < cards.length; i++) { |
||||||
|
if (cards[i].accept(object) && ComparatorUtils.equals(cards[i].getName(), name)) { |
||||||
|
setCardValue(i, object); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setCardValue(int i, Object object) { |
||||||
|
setCurrentEditor(i); |
||||||
|
cards[i].setValue(object); |
||||||
|
// kunsnat: bug7861 所有的Editor值都要跟随改变, 因为populate的editor 从""
|
||||||
|
// 一定是最后的Editor哦.
|
||||||
|
for (int j = 0; j < cards.length; j++) { |
||||||
|
if (i == j) { |
||||||
|
upButton.setSelectedIndex(i); |
||||||
|
continue; |
||||||
|
} |
||||||
|
this.cards[j].setValue(null); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Object update() { |
||||||
|
String name = currentEditor.getName(); |
||||||
|
Object columnIndex = currentEditor.getValue(); |
||||||
|
//bug86542,这边为啥要new一个公式出来,只保留content,其他属性全不要了?
|
||||||
|
// if (ComparatorUtils.equals(name, Inter.getLocText("Formula"))) {
|
||||||
|
// columnIndex = new Formula(columnIndex == null ? "" : columnIndex.toString());
|
||||||
|
// }
|
||||||
|
|
||||||
|
return columnIndex; |
||||||
|
} |
||||||
|
|
||||||
|
public Object update(String makeAdiff) { |
||||||
|
String name = currentEditor.getName(); |
||||||
|
Object columnIndex = currentEditor.getValue(); |
||||||
|
Object columnName = StringUtils.EMPTY; |
||||||
|
|
||||||
|
if (ComparatorUtils.equals(name, Inter.getLocText("FR-Designer_Formula"))) { |
||||||
|
columnIndex = new Formula(columnIndex == null ? "" : columnIndex.toString()); |
||||||
|
} |
||||||
|
|
||||||
|
if (currentEditor instanceof ColumnNameEditor) { |
||||||
|
columnName = ((ColumnNameEditor) currentEditor).getColumnName(); |
||||||
|
} |
||||||
|
|
||||||
|
return new Object[]{columnIndex, columnName}; |
||||||
|
} |
||||||
|
|
||||||
|
public Object update(boolean isXMLA) { |
||||||
|
String name = currentEditor.getName(); |
||||||
|
Object columnIndex = currentEditor.getValue(); |
||||||
|
Object columnName = StringUtils.EMPTY; |
||||||
|
|
||||||
|
if (ComparatorUtils.equals(name, Inter.getLocText("FR-Designer_Formula"))) { |
||||||
|
columnIndex = new Formula(columnIndex == null ? "" : columnIndex.toString()); |
||||||
|
} |
||||||
|
|
||||||
|
if (isXMLA) { |
||||||
|
columnName = ((XMLANameEditor) currentEditor).getColumnName(); |
||||||
|
} |
||||||
|
|
||||||
|
return new Object[]{columnIndex, columnName}; |
||||||
|
} |
||||||
|
|
||||||
|
public void setEditors(Editor[] editors, Object obj) { |
||||||
|
this.cards = editors; |
||||||
|
this.populate(obj); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 检查是否有效 |
||||||
|
* |
||||||
|
* @throws Exception 异常 |
||||||
|
*/ |
||||||
|
public void checkValid() throws Exception { |
||||||
|
if (!(currentEditor instanceof TextEditor)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
int i; |
||||||
|
boolean containFormulaType = false; |
||||||
|
for (i = 0; i < cards.length; i++) { |
||||||
|
if (ComparatorUtils.equals(cards[i].getName(), Inter.getLocText("FR-Engine_Parameter-Formula"))) { |
||||||
|
containFormulaType = true; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
if (!containFormulaType) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
final int j = i; |
||||||
|
|
||||||
|
if (!(currentEditor instanceof TextEditor)) { |
||||||
|
return; |
||||||
|
} |
||||||
|
String string = (String) currentEditor.getValue(); |
||||||
|
if (isFormula(string)) { |
||||||
|
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager(); |
||||||
|
if (designerEnvManager.isSupportStringToFormula()) { |
||||||
|
if (!designerEnvManager.isDefaultStringToFormula()) { |
||||||
|
int returnValue = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Edit_String_To_Formula") |
||||||
|
+ "?", Inter.getLocText("FR-Designer_Tooltips"), JOptionPane.YES_NO_OPTION); |
||||||
|
if (returnValue == JOptionPane.OK_OPTION) { |
||||||
|
|
||||||
|
setCurrentEditor(j); |
||||||
|
Formula formula = new Formula(string); |
||||||
|
currentEditor.setValue(formula); |
||||||
|
} |
||||||
|
} else { |
||||||
|
setCurrentEditor(j); |
||||||
|
Formula formula = new Formula(string); |
||||||
|
currentEditor.setValue(formula); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private boolean isFormula(String string) { |
||||||
|
return StringUtils.isNotBlank(string) && (string.length() > 0 && string.charAt(0) == '='); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setEnabled(boolean enabled) { |
||||||
|
arrowButton.setEnabled(enabled); |
||||||
|
for (Editor card : cards) { |
||||||
|
card.setEnabled(enabled); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 重置组件 |
||||||
|
*/ |
||||||
|
public void resetComponets() { |
||||||
|
for (Editor card : cards) { |
||||||
|
card.reset(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 清除组件数据 |
||||||
|
*/ |
||||||
|
public void clearComponentsData() { |
||||||
|
for (Editor card : cards) { |
||||||
|
card.clearData(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Editor[] getCards() { |
||||||
|
return this.cards; |
||||||
|
} |
||||||
|
|
||||||
|
public JPopupMenu getMenu() { |
||||||
|
return this.menu; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 注册全局名字监听事件 |
||||||
|
* |
||||||
|
* @param listener 观察者监听事件 |
||||||
|
*/ |
||||||
|
public void registerNameListener(GlobalNameListener listener) { |
||||||
|
globalNameListener = listener; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 是否对名字listener监听器做出响应 |
||||||
|
* |
||||||
|
* @return 如果要做出响应,则返回true |
||||||
|
*/ |
||||||
|
public boolean shouldResponseNameListener() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public void setGlobalName(String name) { |
||||||
|
for (Editor card : cards) { |
||||||
|
setComponentGlobalName(card, name); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void setComponentGlobalName(Container card, String name) { |
||||||
|
for (int i = 0, len = card.getComponentCount(); i < len; i++) { |
||||||
|
Component component = card.getComponent(i); |
||||||
|
if (component instanceof GlobalNameObserver) { |
||||||
|
((GlobalNameObserver) component).setGlobalName(name); |
||||||
|
} else { |
||||||
|
setComponentGlobalName((Container) component, name); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 给组件登记一个观察者监听事件 |
||||||
|
* |
||||||
|
* @param listener 观察者监听事件 |
||||||
|
*/ |
||||||
|
public void registerChangeListener(UIObserverListener listener) { |
||||||
|
uiObserverListener = listener; |
||||||
|
for (Editor card : cards) { |
||||||
|
doLoop(card, listener); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void doLoop(Container card, UIObserverListener listener) { |
||||||
|
for (int i = 0, len = card.getComponentCount(); i < len; i++) { |
||||||
|
Component component = card.getComponent(i); |
||||||
|
if (component instanceof UIObserver) { |
||||||
|
((UIObserver) component).registerChangeListener(listener); |
||||||
|
} else { |
||||||
|
doLoop((Container) component, listener); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 组件是否需要响应添加的观察者事件 |
||||||
|
* |
||||||
|
* @return 如果需要响应观察者事件则返回true,否则返回false |
||||||
|
*/ |
||||||
|
public boolean shouldResponseChangeListener() { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
@ -1,107 +1,123 @@ |
|||||||
package com.fr.design.present.dict; |
package com.fr.design.present.dict; |
||||||
|
|
||||||
import java.awt.*; |
import com.fr.base.BaseUtils; |
||||||
|
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import javax.swing.JPanel; |
|
||||||
import javax.swing.event.DocumentListener; |
|
||||||
|
|
||||||
import com.fr.base.Formula; |
import com.fr.base.Formula; |
||||||
import com.fr.data.impl.FormulaDictionary; |
import com.fr.data.impl.FormulaDictionary; |
||||||
import com.fr.design.beans.FurtherBasicBeanPane; |
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
|
import com.fr.design.editor.editor.FormulaEditor; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
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.editor.editor.FormulaEditor; |
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.DocumentListener; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
public class FormulaDictPane extends FurtherBasicBeanPane<FormulaDictionary> { |
public class FormulaDictPane extends FurtherBasicBeanPane<FormulaDictionary> { |
||||||
private FormulaEditor keyFormulaEditor; |
|
||||||
private FormulaEditor valueFormulaEditor; |
|
||||||
|
|
||||||
public FormulaDictPane() { |
private static final int EDITOR_COLUMN = 15; |
||||||
initComponents(); |
private FormulaEditor keyFormulaEditor; |
||||||
} |
private FormulaEditor valueFormulaEditor; |
||||||
|
|
||||||
|
public FormulaDictPane() { |
||||||
|
initComponents(); |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
JFrame jf = new JFrame("test"); |
||||||
|
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||||
|
JPanel content = (JPanel) jf.getContentPane(); |
||||||
|
content.setLayout(new BorderLayout()); |
||||||
|
content.add(new FormulaDictPane(), BorderLayout.NORTH); |
||||||
|
GUICoreUtils.centerWindow(jf); |
||||||
|
jf.setSize(250, 400); |
||||||
|
jf.setVisible(true); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponents() { |
||||||
|
keyFormulaEditor = new FormulaEditor(); |
||||||
|
keyFormulaEditor.setColumns(EDITOR_COLUMN); |
||||||
|
JPanel keyFormulaContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
||||||
|
keyFormulaEditor.setPreferredSize(new Dimension(148, 20)); |
||||||
|
Icon icon = BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png"); |
||||||
|
keyFormulaContainer.add(new JLabel(icon)); |
||||||
|
keyFormulaContainer.add(keyFormulaEditor); |
||||||
|
|
||||||
|
valueFormulaEditor = new FormulaEditor(); |
||||||
|
valueFormulaEditor.setColumns(EDITOR_COLUMN); |
||||||
|
|
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double[] columnSize = {p, f}; |
||||||
|
double[] rowSize = {p, p, p, p, p, p}; |
||||||
|
|
||||||
|
UILabel tag = new UILabel(Inter.getLocText("Formula_Dictionary_Display_Examples_Html")); |
||||||
|
JPanel t = new JPanel(new BorderLayout()); |
||||||
|
t.add(tag, BorderLayout.NORTH); |
||||||
|
|
||||||
|
Formula vf = new Formula("$$$"); |
||||||
|
valueFormulaEditor = new FormulaEditor("", vf); |
||||||
|
|
||||||
|
JPanel valueFormulaContainer = new JPanel(new FlowLayout(FlowLayout.RIGHT)); |
||||||
|
valueFormulaEditor.setPreferredSize(new Dimension(148, 20)); |
||||||
|
valueFormulaContainer.add(new JLabel(icon)); |
||||||
|
valueFormulaContainer.add(valueFormulaEditor); |
||||||
|
|
||||||
private void initComponents() { |
|
||||||
keyFormulaEditor = new FormulaEditor(); |
|
||||||
keyFormulaEditor.setColumns(15); |
|
||||||
valueFormulaEditor = new FormulaEditor(); |
|
||||||
valueFormulaEditor.setColumns(15); |
|
||||||
|
|
||||||
double p = TableLayout.PREFERRED; |
|
||||||
double f = TableLayout.FILL; |
|
||||||
double[] columnSize = { f }; |
|
||||||
double[] rowSize = { p,p,p,p,p }; |
|
||||||
// ActionLabel tips = new ActionLabel("(对应实际值范围内的每个值)") {
|
|
||||||
// @Override
|
|
||||||
// public JToolTip createToolTip() {
|
|
||||||
// MultiLineToolTip tip = new MultiLineToolTip();
|
|
||||||
// tip.setComponent(this);
|
|
||||||
// tip.setOpaque(false);
|
|
||||||
// return tip;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// tips.setToolTipText(Inter.getLocText("Formula_Dictionary_Display_Examples"));
|
|
||||||
// JPanel cc = new JPanel(new BorderLayout());
|
|
||||||
// cc.add(tips, BorderLayout.WEST);
|
|
||||||
|
|
||||||
UILabel tag = new UILabel(Inter.getLocText("Formula_Dictionary_Display_Examples_Html")); |
|
||||||
JPanel t = new JPanel(new BorderLayout()); |
|
||||||
t.add(tag, BorderLayout.WEST); |
|
||||||
|
|
||||||
Formula vf = new Formula("$$$"); |
|
||||||
valueFormulaEditor = new FormulaEditor("",vf); |
|
||||||
Component[][] components = new Component[][]{ |
Component[][] components = new Component[][]{ |
||||||
new Component[]{new UILabel(Inter.getLocText("Actual_Value") + ":")}, |
new Component[]{null, null}, |
||||||
new Component[]{keyFormulaEditor}, |
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value"), UILabel.LEFT), keyFormulaContainer}, |
||||||
new Component[]{new UILabel(Inter.getLocText("Display_Value") + ":")}, |
new Component[]{null, null}, |
||||||
new Component[]{valueFormulaEditor}, |
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value"), UILabel.LEFT), valueFormulaContainer}, |
||||||
new Component[]{t} |
new Component[]{null, null}, |
||||||
|
new Component[]{t, null} |
||||||
}; |
}; |
||||||
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize); |
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); |
||||||
this.setLayout(new BorderLayout()); |
this.setLayout(new BorderLayout()); |
||||||
this.add(panel,BorderLayout.CENTER); |
this.add(panel, BorderLayout.CENTER); |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
public void addChangeListener(DocumentListener l) { |
public void addChangeListener(DocumentListener l) { |
||||||
keyFormulaEditor.addDocumentListener(l); |
keyFormulaEditor.addDocumentListener(l); |
||||||
valueFormulaEditor.addDocumentListener(l); |
valueFormulaEditor.addDocumentListener(l); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("Formula"); |
return Inter.getLocText("FR-Designer_Formula"); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void populateBean(FormulaDictionary dict) { |
public void populateBean(FormulaDictionary dict) { |
||||||
keyFormulaEditor.setValue(new Formula(dict.getProduceFormula() == null ? StringUtils.EMPTY : dict.getProduceFormula())); |
keyFormulaEditor.setValue(new Formula(dict.getProduceFormula() == null ? StringUtils.EMPTY : dict.getProduceFormula())); |
||||||
valueFormulaEditor.setValue(new Formula(dict.getExcuteFormula() == null ? StringUtils.EMPTY : dict.getExcuteFormula())); |
valueFormulaEditor.setValue(new Formula(dict.getExcuteFormula() == null ? StringUtils.EMPTY : dict.getExcuteFormula())); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public FormulaDictionary updateBean() { |
public FormulaDictionary updateBean() { |
||||||
FormulaDictionary dict = new FormulaDictionary(); |
FormulaDictionary dict = new FormulaDictionary(); |
||||||
if (keyFormulaEditor.getValue() != null) { |
if (keyFormulaEditor.getValue() != null) { |
||||||
dict.setProduceFormula(keyFormulaEditor.getValue().getContent()); |
dict.setProduceFormula(keyFormulaEditor.getValue().getContent()); |
||||||
} |
} |
||||||
if (valueFormulaEditor.getValue() != null) { |
if (valueFormulaEditor.getValue() != null) { |
||||||
dict.setExcuteFormula(valueFormulaEditor.getValue().getContent()); |
dict.setExcuteFormula(valueFormulaEditor.getValue().getContent()); |
||||||
} |
} |
||||||
|
|
||||||
return dict; |
return dict; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public boolean accept(Object ob) { |
public boolean accept(Object ob) { |
||||||
return ob instanceof FormulaDictionary; |
return ob instanceof FormulaDictionary; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void reset() { |
public void reset() { |
||||||
keyFormulaEditor.reset(); |
keyFormulaEditor.reset(); |
||||||
valueFormulaEditor.reset(); |
valueFormulaEditor.reset(); |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue