Browse Source

REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>可保存设置,但有bug

master
plough 7 years ago
parent
commit
957bf49988
  1. 73
      designer/src/com/fr/design/widget/WidgetEventPane.java
  2. 26
      designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java

73
designer/src/com/fr/design/widget/WidgetEventPane.java

@ -4,7 +4,9 @@ package com.fr.design.widget;
import java.util.ArrayList;
import java.util.List;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.controlpane.ObjectUIControlPane;
import com.fr.design.present.CellWriteAttrPane;
import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.gui.controlpane.NameableCreator;
@ -15,17 +17,27 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.event.Listener;
import com.fr.form.ui.Widget;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.privilege.finegrain.WidgetPrivilegeControl;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.stable.ReportConstants;
import com.fr.stable.Nameable;
public class WidgetEventPane extends ObjectUIControlPane {
private ElementCasePane ePane;
public WidgetEventPane() {
this(null);
}
public WidgetEventPane(ElementCasePane pane) {
super(pane);
ePane = pane;
this.setNameListEditable(false);
}
@ -41,6 +53,67 @@ public class WidgetEventPane extends ObjectUIControlPane {
@Override
public void saveSettings() {
final TemplateElementCase tplEC = ePane.getEditingElementCase();
final CellSelection finalCS = (CellSelection) ePane.getSelection();
TemplateCellElement editCellElement = tplEC.getTemplateCellElement(finalCS.getColumn(), finalCS.getRow());
if (editCellElement == null) {
editCellElement = new DefaultTemplateCellElement(finalCS.getColumn(), finalCS.getRow());
tplEC.addCellElement(editCellElement);
}
final BasicPane bp = populateBasicPane(editCellElement);
// 需要先行后列地增加新元素。
for (int j = 0; j < finalCS.getRowSpan(); j++) {
for (int i = 0; i < finalCS.getColumnSpan(); i++) {
int column = i + finalCS.getColumn();
int row = j + finalCS.getRow();
editCellElement = tplEC.getTemplateCellElement(column, row);
if (editCellElement == null) {
editCellElement = new DefaultTemplateCellElement(column, row);
tplEC.addCellElement(editCellElement);
}
// alex:不加这一句话会导致跨行跨列的格子被多次update
if (editCellElement.getColumn() != column || editCellElement.getRow() != row) {
continue;
}
updateBasicPane(bp, editCellElement);
Object editElementValue = editCellElement.getValue();
if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) {
// TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面
GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement);
}
}
}
ePane.fireTargetModified();
}
private BasicPane populateBasicPane(TemplateCellElement cellElement) {
CellWriteAttrPane pane = new CellWriteAttrPane(ePane);
//got simple cell element from column and row.
pane.populate(cellElement);
return pane;
}
private void updateBasicPane(BasicPane bp, TemplateCellElement cellElement) {
CellWriteAttrPane pane = (CellWriteAttrPane) bp;
if (cellElement.getWidget() == null) {
pane.update(cellElement);
return;
}
try {
Widget oldWidget = (Widget) cellElement.getWidget().clone();
pane.update(cellElement);
//这边需要重新设置权限细粒度的hashset是因为Update是直接生成一个新的来update的,所以以前里面的hashset都没有了
Widget newWidget = cellElement.getWidget();
if (newWidget.getClass() == oldWidget.getClass()) {
newWidget.setWidgetPrivilegeControl((WidgetPrivilegeControl) oldWidget.getWidgetPrivilegeControl().clone());
}
} catch (Exception e) {
FRLogger.getLogger().error(e.getMessage());
}
}
@Override

26
designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java

@ -8,6 +8,7 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.gui.frpane.ListenerUpdatePane;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptActionPane;
@ -42,6 +43,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.util.ArrayList;
public class EventPropertyTable extends UIListControlPane {
@ -89,7 +91,8 @@ public class EventPropertyTable extends UIListControlPane {
public void addNameObject(NameObject nameObject, int index) {
DefaultListModel model = (DefaultListModel) nameableList.getModel();
model.add(index, nameObject);
// model.add(index, nameObject);
model.add(index, new ListModelElement(nameObject));
nameableList.setSelectedIndex(index);
nameableList.ensureIndexIsVisible(index);
@ -201,6 +204,7 @@ public class EventPropertyTable extends UIListControlPane {
* 刷新
*/
public void refresh() {
isPopulating = true;
int selectionSize = designer.getSelectionModel().getSelection().size();
if (selectionSize == 0 || selectionSize == 1) {
this.creator = selectionSize == 0 ? designer.getRootComponent() : designer.getSelectionModel()
@ -215,31 +219,41 @@ public class EventPropertyTable extends UIListControlPane {
refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
((DefaultListModel) nameableList.getModel()).removeAllElements();
// ((DefaultListModel) nameableList.getModel()).removeAllElements();
ArrayList<NameObject> nameObjectList = new ArrayList<>();
for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
Listener listener = widget.getListener(i);
if (!listener.isDefault()) {
addNameObject(new NameObject(switchLang(listener.getEventName()) + (i + 1), listener), i);
// addNameObject(new NameObject(switchLang(listener.getEventName()) + (i + 1), listener), i);
nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener));
}
}
populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()]));
checkButtonEnabled();
this.repaint();
isPopulating = false;
}
/**
* 更新控件事件
* @param creator 控件
*/
public void updateWidgetListener(XCreator creator) {
public void updateWidgetListener(XCreator creator, boolean isSaving) {
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel();
(creator.toData()).clearListeners();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
(creator.toData()).addListener((Listener) ((NameObject) listModel.getElementAt(i)).getObject());
NameObject nameObject = isSaving ? (NameObject)((ListModelElement) listModel.getElementAt(i)).wrapper : (NameObject)(listModel.getElementAt(i));
(creator.toData()).addListener((Listener) nameObject.getObject());
}
designer.fireTargetModified();
checkButtonEnabled();
}
public void updateWidgetListener(XCreator creator) {
updateWidgetListener(creator, true);
}
@Override
protected String title4PopupWindow() {
return "Event";
@ -254,7 +268,7 @@ public class EventPropertyTable extends UIListControlPane {
@Override
public void saveSettings() {
updateWidgetListener(creator, true);
}
private class DnDTransferHandler extends TransferHandler {

Loading…
Cancel
Save