Browse Source

Merge pull request #1047 in BA/design from ~MOMEAK/design9.0:9.0 to 9.0

* commit '2269bf41c3dec2b39b7db3f616f83d80f0bcf048':
  REPORT-2897 9.0设计器修改 控件设置网页框
  REPORT-2897 9.0设计器修改 控件设置网页框
master
superman 8 years ago
parent
commit
10b23d11cd
  1. 184
      designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java
  2. 183
      designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java
  3. 179
      designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java

184
designer/src/com/fr/design/widget/ui/IframeEditorDefinePane.java

@ -1,17 +1,13 @@
package com.fr.design.widget.ui;
import java.awt.*;
import java.util.List;
import javax.swing.BorderFactory;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
@ -20,68 +16,114 @@ import com.fr.form.ui.IframeEditor;
import com.fr.general.Inter;
import com.fr.stable.ParameterProvider;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
public class IframeEditorDefinePane extends AbstractDataModify<IframeEditor> {
private UITextField srcTextField;
private ReportletParameterViewPane parameterViewPane;
private UICheckBox horizontalCheck;
private UICheckBox verticalCheck;
public IframeEditorDefinePane() {
this.initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
contentPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
JPanel attr = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
attr.add(horizontalCheck = new UICheckBox(Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible")));
attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible")));
contentPane.add(attr);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = { p, p, p, p };
double[] columnSize = { p, f };
java.awt.Component[][] coms = {
{ horizontalCheck, null },
{ verticalCheck, null },
{ new UILabel(Inter.getLocText("Form-Url") + ":"), srcTextField = new UITextField() },
{ new UILabel(Inter.getLocText("Parameter") + ":"), parameterViewPane = new ReportletParameterViewPane() } };
int[][] rowCount = {{1, 1},{1, 1},{1, 1}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(coms, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, 5);
contentPane.add(panel);
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, contentPane);
this.add(uiExpandablePane, BorderLayout.NORTH);
}
@Override
protected String title4PopupWindow() {
return "iframe";
}
@Override
public void populateBean(IframeEditor e) {
srcTextField.setText(e.getSrc());
parameterViewPane.populate(e.getParameters());
this.horizontalCheck.setSelected(e.isOverflowx());
this.verticalCheck.setSelected(e.isOverflowy());
}
@Override
public IframeEditor updateBean() {
IframeEditor ob = new IframeEditor();
ob.setSrc(srcTextField.getText());
List<ParameterProvider> parameterList = parameterViewPane.update();
ob.setParameters(parameterList.toArray(new ParameterProvider[parameterList.size()]));
ob.setOverflowx(this.horizontalCheck.isSelected());
ob.setOverflowy(this.verticalCheck.isSelected());
return ob;
}
private static final int P_W = 610;
private static final int P_H = 580;
private UITextField srcTextField;
private ReportletParameterViewPane parameterViewPane;
private UICheckBox horizontalCheck;
private UICheckBox verticalCheck;
private UIButton parameterViewPaneButton;
private List<ParameterProvider> list;
public IframeEditorDefinePane() {
this.initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
contentPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
JPanel attr = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
attr.add(horizontalCheck = new UICheckBox(Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible")));
attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible")));
contentPane.add(attr);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = {p, p, p, p};
double[] columnSize = {p, f};
parameterViewPaneButton = new UIButton(Inter.getLocText("FR-Designer_Edit"));
parameterViewPaneButton.addActionListener(parameterListener);
parameterViewPane = new ReportletParameterViewPane();
java.awt.Component[][] coms = {
{horizontalCheck, null},
{verticalCheck, null},
{new UILabel(Inter.getLocText("Form-Url")), srcTextField = new UITextField()},
{new UILabel(Inter.getLocText("FR-Designer_Parameters")), parameterViewPaneButton}};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(coms, rowSize, columnSize, rowCount, 45, LayoutConstants.VGAP_LARGE);
contentPane.add(panel);
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 24, contentPane);
this.add(uiExpandablePane, BorderLayout.NORTH);
}
ActionListener parameterListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
List<ParameterProvider> paraList = parameterViewPane.update();
list = new ArrayList<ParameterProvider>();
ParameterProvider pr = null;
for (ParameterProvider parameterProvider : paraList) {
try {
pr = (ParameterProvider) parameterProvider.clone();
} catch (CloneNotSupportedException e1) {
e1.printStackTrace();
}
list.add(pr);
}
UIDialog dialog = parameterViewPane.showUnsizedWindow(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionListener() {
@Override
public void doOk() {
}
@Override
public void doCancel() {
parameterViewPane.update(list);
}
});
dialog.setSize(P_W, P_H);
dialog.setVisible(true);
}
};
@Override
protected String title4PopupWindow() {
return "iframe";
}
@Override
public void populateBean(IframeEditor e) {
srcTextField.setText(e.getSrc());
parameterViewPane.populate(e.getParameters());
this.horizontalCheck.setSelected(e.isOverflowx());
this.verticalCheck.setSelected(e.isOverflowy());
}
@Override
public IframeEditor updateBean() {
IframeEditor ob = new IframeEditor();
ob.setSrc(srcTextField.getText());
List<ParameterProvider> parameterList = parameterViewPane.update();
ob.setParameters(parameterList.toArray(new ParameterProvider[parameterList.size()]));
ob.setOverflowx(this.horizontalCheck.isSelected());
ob.setOverflowy(this.verticalCheck.isSelected());
return ob;
}
}

183
designer_base/src/com/fr/design/gui/frpane/ReportletParameterViewPane.java

@ -23,115 +23,124 @@ import java.util.List;
/**
* Defin hyperlink.
* in fact,this is a TablEditorPane
*
* @editor zhou
* @since 2012-3-23下午3:48:10
*/
public class ReportletParameterViewPane extends BasicPane {
private UITableEditorPane<ParameterProvider> editorPane;
private UITableEditorPane<ParameterProvider> editorPane;
public ReportletParameterViewPane() {
this(null, ParameterTableModel.NO_CHART_USE);
}
public ReportletParameterViewPane() {
this(null, ParameterTableModel.NO_CHART_USE);
}
// kunsnat: 控制是否用Chart的热点链接actions
public ReportletParameterViewPane(int useParaType) {
this(null, useParaType);
}
// kunsnat: 控制是否用Chart的热点链接actions
public ReportletParameterViewPane(int useParaType) {
this(null, useParaType);
}
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) {
this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType),
ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType));
}
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) {
this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType),
ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType));
}
public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this(null, useParaType, valueEditorPane, valueRenderPane);
}
public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this(null, useParaType, valueEditorPane, valueRenderPane);
}
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.initComponent(actions, useParaType, valueEditorPane, valueRenderPane);
}
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.initComponent(actions, useParaType, valueEditorPane, valueRenderPane);
}
/**
* 初始化组件
* @param actions Chart的热点链接actions
* @param useParaType 类型
*
* @param actions Chart的热点链接actions
* @param useParaType 类型
*/
public void initComponent(final UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
if (useParaType != ParameterTableModel.NO_CHART_USE) {
ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) {
@Override
public UITableEditAction[] createAction() {
UITableEditAction[] tableEditActions = new UITableEditAction[] { new AddChartParameterAction(), new DeleteAction(this.component),
new MoveUpAction(), new MoveDownAction() };
return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions);
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
} else {
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions);
}
});
}
this.add(editorPane, BorderLayout.CENTER);
}
public void initComponent(final UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
if (useParaType != ParameterTableModel.NO_CHART_USE) {
ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) {
@Override
public UITableEditAction[] createAction() {
UITableEditAction[] tableEditActions = new UITableEditAction[]{new AddChartParameterAction(), new DeleteAction(this.component),
new MoveUpAction(), new MoveDownAction()};
return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions);
}
};
editorPane = new UITableEditorPane<ParameterProvider>(model);
} else {
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions);
}
});
}
this.add(editorPane, BorderLayout.CENTER);
}
/**
* 增加事件监听
* @param l 加的东东
*
* @param l 加的东东
*/
public void addTableEditorListener(TableModelListener l) {
editorPane.addTableListener(l);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Parameters");
}
public void populate(ParameterProvider[] parameters) {
if (parameters == null) {
return;
}
editorPane.populate(parameters);
}
public void populate(KV[] kv) {
if (kv == null) {
return;
}
Parameter[] parameters = new Parameter[kv.length];
for (int i = 0; i < kv.length; i++) {
parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue());
}
this.populate(parameters);
}
public List<ParameterProvider> update() {
return editorPane.update();
}
public void addTableEditorListener(TableModelListener l) {
editorPane.addTableListener(l);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Parameters");
}
public void populate(ParameterProvider[] parameters) {
if (parameters == null) {
return;
}
editorPane.populate(parameters);
}
public void populate(KV[] kv) {
if (kv == null) {
return;
}
Parameter[] parameters = new Parameter[kv.length];
for (int i = 0; i < kv.length; i++) {
parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue());
}
this.populate(parameters);
}
public List<ParameterProvider> update() {
return editorPane.update();
}
public void update(List list) {
editorPane.update(list);
}
/**
* 更新
* @return 数组
*
* @return 数组
*/
public KV[] updateKV() {
List<ParameterProvider> list = this.update();
int length = list.size();
KV[] kv = new KV[length];
for (int i = 0; i < length; i++) {
kv[i] = new KV();
kv[i].setKey(list.get(i).getName());
kv[i].setValue( list.get(i).getValue());
}
return kv;
}
public KV[] updateKV() {
List<ParameterProvider> list = this.update();
int length = list.size();
KV[] kv = new KV[length];
for (int i = 0; i < length; i++) {
kv[i] = new KV();
kv[i].setKey(list.get(i).getName());
kv[i].setValue(list.get(i).getValue());
}
return kv;
}
}

179
designer_base/src/com/fr/design/gui/itableeditorpane/UITableEditorPane.java

@ -1,12 +1,12 @@
package com.fr.design.gui.itableeditorpane;
import com.fr.design.constants.UIConstants;
import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
import javax.swing.*;
@ -16,56 +16,56 @@ import java.util.List;
/**
* 表格编辑面板,一般是两列.- 用泛型实现用的时候请定义T.model里面的T要一样
*
*
* @editor zhou
* @since 2012-3-28下午3:06:30
*/
public class UITableEditorPane<T> extends BasicPane {
/**
*
*/
private static final long serialVersionUID = 6855793816972735815L;
private JTable editTable;
// 放置action 的按钮.
private UITableModelAdapter<T> tableModel;
private String leftLabelName;
/**
*
*/
private static final long serialVersionUID = 6855793816972735815L;
private JTable editTable;
// 放置action 的按钮.
private UITableModelAdapter<T> tableModel;
private String leftLabelName;
private JPanel buttonPane;
public UITableEditorPane(UITableModelAdapter<T> model) {
this.tableModel = model;
this.initComponent(model.createAction());
}
public UITableEditorPane(UITableModelAdapter<T> model, String s) {
leftLabelName = s;
this.tableModel = model;
this.initComponent(model.createAction());
}
private void initComponent(UITableEditAction[] action) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pane = new JPanel(new BorderLayout(4, 4));
this.add(pane, BorderLayout.CENTER);
UILabel l = new UILabel(leftLabelName);
editTable = tableModel.createTable();
UIScrollPane scrollPane = new UIScrollPane(editTable);
scrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
pane.add(scrollPane, BorderLayout.CENTER);
initbuttonPane(action);
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
controlPane.add(buttonPane, BorderLayout.EAST);
controlPane.add(l, BorderLayout.WEST);
pane.add(controlPane, BorderLayout.NORTH);
}
public UITableModelAdapter<T> getTableModel(){
public UITableEditorPane(UITableModelAdapter<T> model) {
this.tableModel = model;
this.initComponent(model.createAction());
}
public UITableEditorPane(UITableModelAdapter<T> model, String s) {
leftLabelName = s;
this.tableModel = model;
this.initComponent(model.createAction());
}
private void initComponent(UITableEditAction[] action) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pane = new JPanel(new BorderLayout(4, 4));
this.add(pane, BorderLayout.CENTER);
UILabel l = new UILabel(leftLabelName);
editTable = tableModel.createTable();
UIScrollPane scrollPane = new UIScrollPane(editTable);
scrollPane.setBorder(new UIRoundedBorder(UIConstants.LINE_COLOR, 1, UIConstants.ARC));
pane.add(scrollPane, BorderLayout.CENTER);
initbuttonPane(action);
JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
controlPane.add(buttonPane, BorderLayout.EAST);
controlPane.add(l, BorderLayout.WEST);
pane.add(controlPane, BorderLayout.NORTH);
}
public UITableModelAdapter<T> getTableModel() {
return tableModel;
}
private void initbuttonPane(UITableEditAction[] action){
private void initbuttonPane(UITableEditAction[] action) {
buttonPane = new JPanel();
if (action != null) {
@ -87,54 +87,61 @@ public class UITableEditorPane<T> extends BasicPane {
/**
* 增加事件监听
* @param l 加的东东
*
* @param l 加的东东
*/
public void addTableListener(TableModelListener l) {
tableModel.addTableModelListener(l);
}
public void addTableListener(TableModelListener l) {
tableModel.addTableModelListener(l);
}
/**
* 移除事件监听
* @param l 去的东东
*
* @param l 去的东东
*/
public void removeTableListener(TableModelListener l) {
tableModel.removeTableModelListener(l);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("TableData_Dynamic_Parameter_Setting");
}
public void populate(T[] objs) {
tableModel.clear();
if(objs==null){
return;
}
for (T obj : objs) {
tableModel.addRow(obj);
}
this.tableModel.fireTableDataChanged();
if (objs.length > 0) {
this.editTable.getSelectionModel().setSelectionInterval(0, 0);
}
}
// TODO:august这个最好还是返回数组
public List<T> update() {
tableModel.stopCellEditing();
return tableModel.getList();
}
public int getSelectedRow() {
return this.editTable.getSelectedRow();
}
public int getSelectedColumn() {
return this.editTable.getSelectedColumn();
}
public JPanel getbuttonPane(){
public void removeTableListener(TableModelListener l) {
tableModel.removeTableModelListener(l);
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("TableData_Dynamic_Parameter_Setting");
}
public void populate(T[] objs) {
tableModel.clear();
if (objs == null) {
return;
}
for (T obj : objs) {
tableModel.addRow(obj);
}
this.tableModel.fireTableDataChanged();
if (objs.length > 0) {
this.editTable.getSelectionModel().setSelectionInterval(0, 0);
}
}
// TODO:august这个最好还是返回数组
public List<T> update() {
tableModel.stopCellEditing();
return tableModel.getList();
}
public void update(List list) {
tableModel.stopCellEditing();
tableModel.setList(list);
}
public int getSelectedRow() {
return this.editTable.getSelectedRow();
}
public int getSelectedColumn() {
return this.editTable.getSelectedColumn();
}
public JPanel getbuttonPane() {
return buttonPane;
}

Loading…
Cancel
Save