Browse Source

REPORT-12710

final/10.0
Mata.Li 6 years ago
parent
commit
55a372ec03
  1. 243
      designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java
  2. 3
      designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

243
designer-form/src/main/java/com/fr/design/designer/properties/EventPropertyTable.java

@ -23,124 +23,131 @@ import java.util.ArrayList;
public class EventPropertyTable extends UIListControlPane { public class EventPropertyTable extends UIListControlPane {
private XCreator creator; private XCreator creator;
private FormDesigner designer; private FormDesigner designer;
public EventPropertyTable(FormDesigner designer) { public EventPropertyTable(FormDesigner designer) {
super(); super();
this.designer = designer; this.designer = designer;
} }
@Override @Override
public String getAddItemText() { public String getAddItemText() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Event"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Event");
} }
public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane { public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane {
@Override @Override
protected JavaScriptActionPane createJavaScriptActionPane() { protected JavaScriptActionPane createJavaScriptActionPane() {
return new JavaScriptActionPane() { return new JavaScriptActionPane() {
@Override @Override
protected DBManipulationPane createDBManipulationPane() { protected DBManipulationPane createDBManipulationPane() {
return new DBManipulationPane(ValueEditorPaneFactory.formEditors()); return new DBManipulationPane(ValueEditorPaneFactory.formEditors());
} }
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Callback_Function"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Callback_Function");
} }
@Override
protected EmailPane initEmaiPane() { @Override
return new FormEmailPane(); protected EmailPane initEmaiPane() {
} return new FormEmailPane();
@Override }
public boolean isForm() {
return true; @Override
} public boolean isForm() {
return true;
protected String[] getDefaultArgs() { }
return new String[0];
} protected String[] getDefaultArgs() {
return new String[0];
}; }
}
};
@Override }
protected boolean supportCellAction() {
return false; @Override
} protected boolean supportCellAction() {
} return false;
}
private String switchLang(String eventName) { }
// 在 properties 文件中找到相应的 key 值
private String switchLang(String eventName) {
// 在 properties 文件中找到相应的 key 值
String localeKey = ReportEngineEventMapping.getLocaleName(eventName); String localeKey = ReportEngineEventMapping.getLocaleName(eventName);
return com.fr.design.i18n.Toolkit.i18nText(localeKey); return com.fr.design.i18n.Toolkit.i18nText(localeKey);
} }
/** /**
* 刷新 * 刷新
*/ */
public void refresh() { public void refresh() {
int selectionSize = designer.getSelectionModel().getSelection().size(); int selectionSize = designer.getSelectionModel().getSelection().size();
if (selectionSize == 0 || selectionSize == 1) { if (selectionSize == 0 || selectionSize == 1) {
this.creator = selectionSize == 0 ? designer.getRootComponent() : designer.getSelectionModel() this.creator = selectionSize == 0 ? designer.getRootComponent() : designer.getSelectionModel()
.getSelection().getSelectedCreator(); .getSelection().getSelectedCreator();
} else { } else {
this.creator = null; this.creator = null;
((DefaultListModel) nameableList.getModel()).removeAllElements(); ((DefaultListModel) nameableList.getModel()).removeAllElements();
checkButtonEnabled(); checkButtonEnabled();
return; return;
} }
Widget widget = creator.toData(); Widget widget = creator.toData();
refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
}
ArrayList<NameObject> nameObjectList = new ArrayList<>();
for (int i = 0, size = widget.getListenerSize(); i < size; i++) { public void populateNameObjects() {
Listener listener = widget.getListener(i); Widget widget = creator.toData();
if (!listener.isDefault()) {
nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener)); ArrayList<NameObject> nameObjectList = new ArrayList<>();
} for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
} Listener listener = widget.getListener(i);
populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()])); if (!listener.isDefault()) {
checkButtonEnabled(); nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener));
this.repaint(); }
} }
populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()]));
/** checkButtonEnabled();
* 更新控件事件 this.repaint();
* @param creator 控件 }
*/
public void updateWidgetListener(XCreator creator) { /**
(creator.toData()).clearListeners(); * 更新控件事件
Nameable[] res = this.update(); *
for (int i = 0; i < res.length; i++) { * @param creator 控件
NameObject nameObject = (NameObject)res[i]; */
(creator.toData()).addListener((Listener) nameObject.getObject()); public void updateWidgetListener(XCreator creator) {
} (creator.toData()).clearListeners();
Nameable[] res = this.update();
designer.fireTargetModified(); for (int i = 0; i < res.length; i++) {
checkButtonEnabled(); NameObject nameObject = (NameObject) res[i];
} (creator.toData()).addListener((Listener) nameObject.getObject());
}
@Override
protected String title4PopupWindow() { designer.fireTargetModified();
return "Event"; checkButtonEnabled();
} }
@Override @Override
public NameableCreator[] createNameableCreators() { protected String title4PopupWindow() {
return new NameableCreator[]{ return "Event";
new EventCreator(Widget.EVENT_STATECHANGE, WidgetEventListenerUpdatePane.class) }
};
} @Override
public NameableCreator[] createNameableCreators() {
@Override return new NameableCreator[]{
public void saveSettings() { new EventCreator(Widget.EVENT_STATECHANGE, WidgetEventListenerUpdatePane.class)
if (isPopulating) { };
return; }
}
updateWidgetListener(creator); @Override
} public void saveSettings() {
if (isPopulating) {
return;
}
updateWidgetListener(creator);
}
} }

3
designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java

@ -108,6 +108,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
*/ */
private void initTables() { private void initTables() {
formWidgetCardPane.populate(); formWidgetCardPane.populate();
eventTable.refresh();
if (mobileExtraPropertyPanes != null) { if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {
@ -233,7 +234,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
public void tabChanged(int index) { public void tabChanged(int index) {
//切换的时候再populate //切换的时候再populate
if (index == 1) { if (index == 1) {
eventTable.refresh(); eventTable.populateNameObjects();
} else if (index == 2) { } else if (index == 2) {
if (mobileExtraPropertyPanes != null) { if (mobileExtraPropertyPanes != null) {
for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) {

Loading…
Cancel
Save