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 7 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; 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.constants.LayoutConstants;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.dialog.UIDialog;
import com.fr.design.foldablepane.UIExpandablePane; 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.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; 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.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;
@ -20,68 +16,114 @@ import com.fr.form.ui.IframeEditor;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ParameterProvider; 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> { public class IframeEditorDefinePane extends AbstractDataModify<IframeEditor> {
private UITextField srcTextField;
private ReportletParameterViewPane parameterViewPane; private static final int P_W = 610;
private UICheckBox horizontalCheck; private static final int P_H = 580;
private UICheckBox verticalCheck; private UITextField srcTextField;
private ReportletParameterViewPane parameterViewPane;
public IframeEditorDefinePane() { private UICheckBox horizontalCheck;
this.initComponents(); private UICheckBox verticalCheck;
} private UIButton parameterViewPaneButton;
private List<ParameterProvider> list;
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); public IframeEditorDefinePane() {
JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane(); this.initComponents();
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"))); private void initComponents() {
attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible"))); this.setLayout(FRGUIPaneFactory.createBorderLayout());
contentPane.add(attr); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
double p = TableLayout.PREFERRED; JPanel contentPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane();
double f = TableLayout.FILL; contentPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
double[] rowSize = { p, p, p, p }; JPanel attr = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane();
double[] columnSize = { p, f }; attr.add(horizontalCheck = new UICheckBox(Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible")));
attr.add(verticalCheck = new UICheckBox(Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible")));
java.awt.Component[][] coms = { contentPane.add(attr);
{ horizontalCheck, null }, double p = TableLayout.PREFERRED;
{ verticalCheck, null }, double f = TableLayout.FILL;
{ new UILabel(Inter.getLocText("Form-Url") + ":"), srcTextField = new UITextField() }, double[] rowSize = {p, p, p, p};
{ new UILabel(Inter.getLocText("Parameter") + ":"), parameterViewPane = new ReportletParameterViewPane() } }; double[] columnSize = {p, f};
int[][] rowCount = {{1, 1},{1, 1},{1, 1}, {1, 1}};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(coms, rowSize, columnSize, rowCount, LayoutConstants.VGAP_SMALL, 5); parameterViewPaneButton = new UIButton(Inter.getLocText("FR-Designer_Edit"));
parameterViewPaneButton.addActionListener(parameterListener);
parameterViewPane = new ReportletParameterViewPane();
contentPane.add(panel);
java.awt.Component[][] coms = {
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 20, contentPane); {horizontalCheck, null},
this.add(uiExpandablePane, BorderLayout.NORTH); {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);
@Override
protected String title4PopupWindow() {
return "iframe"; contentPane.add(panel);
}
UIExpandablePane uiExpandablePane = new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), 280, 24, contentPane);
@Override this.add(uiExpandablePane, BorderLayout.NORTH);
public void populateBean(IframeEditor e) {
srcTextField.setText(e.getSrc()); }
parameterViewPane.populate(e.getParameters());
this.horizontalCheck.setSelected(e.isOverflowx()); ActionListener parameterListener = new ActionListener() {
this.verticalCheck.setSelected(e.isOverflowy()); @Override
} public void actionPerformed(ActionEvent e) {
List<ParameterProvider> paraList = parameterViewPane.update();
@Override list = new ArrayList<ParameterProvider>();
public IframeEditor updateBean() { ParameterProvider pr = null;
IframeEditor ob = new IframeEditor(); for (ParameterProvider parameterProvider : paraList) {
ob.setSrc(srcTextField.getText()); try {
List<ParameterProvider> parameterList = parameterViewPane.update(); pr = (ParameterProvider) parameterProvider.clone();
ob.setParameters(parameterList.toArray(new ParameterProvider[parameterList.size()])); } catch (CloneNotSupportedException e1) {
ob.setOverflowx(this.horizontalCheck.isSelected()); e1.printStackTrace();
ob.setOverflowy(this.verticalCheck.isSelected()); }
return ob; 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. * Defin hyperlink.
* in fact,this is a TablEditorPane * in fact,this is a TablEditorPane
*
* @editor zhou * @editor zhou
* @since 2012-3-23下午3:48:10 * @since 2012-3-23下午3:48:10
*/ */
public class ReportletParameterViewPane extends BasicPane { public class ReportletParameterViewPane extends BasicPane {
private UITableEditorPane<ParameterProvider> editorPane; private UITableEditorPane<ParameterProvider> editorPane;
public ReportletParameterViewPane() { public ReportletParameterViewPane() {
this(null, ParameterTableModel.NO_CHART_USE); this(null, ParameterTableModel.NO_CHART_USE);
} }
// kunsnat: 控制是否用Chart的热点链接actions // kunsnat: 控制是否用Chart的热点链接actions
public ReportletParameterViewPane(int useParaType) { public ReportletParameterViewPane(int useParaType) {
this(null, useParaType); this(null, useParaType);
} }
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) { public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType) {
this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType), this(actions, useParaType, ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType),
ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType)); ValueEditorPaneFactory.createVallueEditorPaneWithUseType(useParaType));
} }
public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { public ReportletParameterViewPane(int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this(null, useParaType, valueEditorPane, valueRenderPane); this(null, useParaType, valueEditorPane, valueRenderPane);
} }
public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) { public ReportletParameterViewPane(UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.initComponent(actions, useParaType, 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) { public void initComponent(final UITableEditAction[] actions, int useParaType, ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
if (useParaType != ParameterTableModel.NO_CHART_USE) { if (useParaType != ParameterTableModel.NO_CHART_USE) {
ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) { ParameterTableModel model = new ParameterTableModel(valueEditorPane, valueRenderPane, this) {
@Override @Override
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
UITableEditAction[] tableEditActions = new UITableEditAction[] { new AddChartParameterAction(), new DeleteAction(this.component), UITableEditAction[] tableEditActions = new UITableEditAction[]{new AddChartParameterAction(), new DeleteAction(this.component),
new MoveUpAction(), new MoveDownAction() }; new MoveUpAction(), new MoveDownAction()};
return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions); return (UITableEditAction[]) ArrayUtils.addAll(tableEditActions, actions);
} }
}; };
editorPane = new UITableEditorPane<ParameterProvider>(model); editorPane = new UITableEditorPane<ParameterProvider>(model);
} else { } else {
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() { editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() {
@Override @Override
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions); return (UITableEditAction[]) ArrayUtils.addAll(super.createAction(), actions);
} }
}); });
} }
this.add(editorPane, BorderLayout.CENTER); this.add(editorPane, BorderLayout.CENTER);
} }
/** /**
* 增加事件监听 * 增加事件监听
* @param l 加的东东 *
* @param l 加的东东
*/ */
public void addTableEditorListener(TableModelListener l) { public void addTableEditorListener(TableModelListener l) {
editorPane.addTableListener(l); editorPane.addTableListener(l);
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("Parameters"); return Inter.getLocText("Parameters");
} }
public void populate(ParameterProvider[] parameters) { public void populate(ParameterProvider[] parameters) {
if (parameters == null) { if (parameters == null) {
return; return;
} }
editorPane.populate(parameters); editorPane.populate(parameters);
} }
public void populate(KV[] kv) { public void populate(KV[] kv) {
if (kv == null) { if (kv == null) {
return; return;
} }
Parameter[] parameters = new Parameter[kv.length]; Parameter[] parameters = new Parameter[kv.length];
for (int i = 0; i < kv.length; i++) { for (int i = 0; i < kv.length; i++) {
parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue()); parameters[i] = new Parameter(kv[i].getKey(), kv[i].getValue());
} }
this.populate(parameters); this.populate(parameters);
} }
public List<ParameterProvider> update() { public List<ParameterProvider> update() {
return editorPane.update(); return editorPane.update();
} }
public void update(List list) {
editorPane.update(list);
}
/** /**
* 更新 * 更新
* @return 数组 *
* @return 数组
*/ */
public KV[] updateKV() { public KV[] updateKV() {
List<ParameterProvider> list = this.update(); List<ParameterProvider> list = this.update();
int length = list.size(); int length = list.size();
KV[] kv = new KV[length]; KV[] kv = new KV[length];
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
kv[i] = new KV(); kv[i] = new KV();
kv[i].setKey(list.get(i).getName()); kv[i].setKey(list.get(i).getName());
kv[i].setValue( list.get(i).getValue()); kv[i].setValue(list.get(i).getValue());
} }
return kv; return kv;
} }
} }

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

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

Loading…
Cancel
Save