Browse Source

Merge pull request #1031 in BA/design from ~PLOUGH/design:9.0 to 9.0

* commit 'be2ab9031440ee29f7f66aa4badeafe9aa7aafdd':
  REPORT-3163 合作开发9.0设计器=>代码规范
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(报表)=》整合代码,实现保存设置
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>边框校正
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>去掉冗余代码
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑=>国际化;整理代码
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>bug解决;效率优化
  REPORT-3163 合作开发9.0设计器=>新列表面板=》修改弹出框的尺寸和边框
  无JIRA任务,收集模版信息时,不应该影响保存
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>可保存设置,但有bug
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>初步修改
  REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(报表)初步修改
master
superman 8 years ago
parent
commit
acc35e63b1
  1. 43
      designer/src/com/fr/design/widget/WidgetEventPane.java
  2. 62
      designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java
  3. 17
      designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java
  4. 2
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  5. 1
      designer_base/src/com/fr/design/locale/designer.properties
  6. 1
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  7. 1
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  8. 1
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  9. 1
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  10. 1
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  11. 5
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  12. 132
      designer_base/src/com/fr/design/widget/EventCreator.java
  13. 453
      designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java
  14. 9
      designer_form/src/com/fr/design/mainframe/JForm.java
  15. 21
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

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

@ -4,10 +4,13 @@ package com.fr.design.widget;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.controlpane.ObjectUIControlPane;
import com.fr.design.mainframe.CellWidgetPropertyPane;
import com.fr.design.present.CellWriteAttrPane;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ObjectJControlPane;
import com.fr.design.gui.frpane.ListenerUpdatePane; import com.fr.design.gui.frpane.ListenerUpdatePane;
import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -15,40 +18,52 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject; 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; import com.fr.stable.Nameable;
public class WidgetEventPane extends ObjectJControlPane { public class WidgetEventPane extends ObjectUIControlPane {
public WidgetEventPane() {
this(null);
}
public WidgetEventPane(ElementCasePane pane) { public WidgetEventPane(ElementCasePane pane) {
super(pane); super(pane);
this.setNameListEditable(false); this.setNameListEditable(false);
} }
@Override
public String getAddItemText() {
return Inter.getLocText("FR-Designer_Add_Event");
}
/** /**
* 生成添加按钮的NameableCreator * 生成添加按钮的NameableCreator
* @return 按钮的NameableCreator * @return 按钮的NameableCreator
*/ */
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{ return new NameableCreator[]{
EventCreator.STATECHANGE new EventCreator(Widget.EVENT_STATECHANGE, WidgetEventListenerUpdatePane.class)
}; };
} }
@Override @Override
public void saveSettings() {
CellWidgetPropertyPane.getInstance().update();
}
@Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("Event"); return Inter.getLocText("Event");
} }
public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane { public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane {
private ElementCasePane epane; private ElementCasePane epane;
public WidgetEventListenerUpdatePane() {
this(null);
}
public WidgetEventListenerUpdatePane(ElementCasePane epane){ public WidgetEventListenerUpdatePane(ElementCasePane epane){
this.epane = epane; this.epane = epane;
super.initComponents(); super.initComponents();
@ -104,7 +119,7 @@ public class WidgetEventPane extends ObjectJControlPane {
return; return;
} }
this.refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents())); this.refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
List<NameObject> list = new ArrayList<NameObject>(); List<NameObject> list = new ArrayList<NameObject>();
Listener listener; Listener listener;

62
designer_base/src/com/fr/design/gui/controlpane/ObjectUIControlPane.java

@ -0,0 +1,62 @@
package com.fr.design.gui.controlpane;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import com.fr.design.beans.BasicBeanPane;
/**
* Created by plough on 2017/8/1.
*/
public abstract class ObjectUIControlPane extends UIListControlPane {
private Object object;
public ObjectUIControlPane() {
this(null);
}
public ObjectUIControlPane(Object object) {
super();
this.object = object;
}
@Override
protected BasicBeanPane createPaneByCreators(NameableCreator creator) {
try {
if (object == null) {
return super.createPaneByCreators(creator);
} else if (object.getClass().isArray()) {
return creator.getUpdatePane().getConstructor(object.getClass()).newInstance(object);
} else {
Constructor<? extends BasicBeanPane> constructor = getConstructor(creator.getUpdatePane(), object.getClass());
return constructor == null ? super.createPaneByCreators(creator) : constructor.newInstance(object);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 传进BasicBeanPane的构造函数的参数可能是
*
* @param clazz
* @param cls
* @return
*/
private Constructor<? extends BasicBeanPane> getConstructor(Class<? extends BasicBeanPane> clazz, Class<?> cls) {
Constructor<? extends BasicBeanPane> constructor = null;
try {
constructor = clazz.getConstructor(cls);
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
}
if (constructor != null) {
return constructor;
} else {
if (cls.getName() == Object.class.getName()) {
return null;
}
return getConstructor(clazz, cls.getSuperclass());
}
}
}

17
designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java

@ -28,6 +28,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
private ToolBarDef toolbarDef; private ToolBarDef toolbarDef;
private UIToolbar toolBar; private UIToolbar toolBar;
private UIToolbar topToolBar;
protected PopupEditDialog popupEditDialog; protected PopupEditDialog popupEditDialog;
// peter:这是整体的一个cardLayout Pane // peter:这是整体的一个cardLayout Pane
protected CardLayout cardLayout; protected CardLayout cardLayout;
@ -146,7 +147,7 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
// leftContentPane.setBorder(BorderFactory.createLineBorder(new Color(201, 198, 184))); // leftContentPane.setBorder(BorderFactory.createLineBorder(new Color(201, 198, 184)));
// 顶部标签及add按钮 // 顶部标签及add按钮
UIToolbar topToolBar = new UIToolbar(); topToolBar = new UIToolbar();
topToolBar.setLayout(new BorderLayout()); topToolBar.setLayout(new BorderLayout());
ShortCut addItem = addItemShortCut().getShortCut(); ShortCut addItem = addItemShortCut().getShortCut();
addItem.intoJToolBar(topToolBar); addItem.intoJToolBar(topToolBar);
@ -246,19 +247,27 @@ public abstract class UIControlPane extends BasicPane implements UnrepeatedNameH
toolbarDef.updateToolBar(toolBar); toolbarDef.updateToolBar(toolBar);
toolBar.validate(); toolBar.validate();
toolBar.repaint(); toolBar.repaint();
// 顶部按钮
topToolBar.removeAll();
ShortCut addItem = addItemShortCut().getShortCut();
addItem.intoJToolBar(topToolBar);
topToolBar.validate();
this.repaint(); this.repaint();
} }
// 点击"编辑"按钮,弹出面板 // 点击"编辑"按钮,弹出面板
protected class PopupEditDialog extends JDialog { protected class PopupEditDialog extends JDialog {
private JComponent editPane; private JComponent editPane;
private static final int WIDTH = 490; private static final int WIDTH = 570;
private static final int HEIGHT = 570; private static final int HEIGHT = 490;
PopupEditDialog(JComponent pane) { PopupEditDialog(JComponent pane) {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
setUndecorated(true); setUndecorated(true);
pane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); pane.setBorder(BorderFactory.createEmptyBorder(20, 10, 10, 10));
this.editPane = pane; this.editPane = pane;
this.getContentPane().add(editPane, BorderLayout.CENTER); this.getContentPane().add(editPane, BorderLayout.CENTER);
setSize(WIDTH, HEIGHT); setSize(WIDTH, HEIGHT);

2
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -210,7 +210,7 @@ public abstract class UIListControlPane extends UIControlPane {
listModel.addElement(new ListModelElement(aNameableArray)); listModel.addElement(new ListModelElement(aNameableArray));
} }
if (listModel.size() > 0) { if (listModel.size() > 0 || this.nameableList.getSelectedIndex() != 0) {
this.nameableList.setSelectedIndex(0); this.nameableList.setSelectedIndex(0);
} }
this.checkButtonEnabled(); this.checkButtonEnabled();

1
designer_base/src/com/fr/design/locale/designer.properties

@ -2105,3 +2105,4 @@ FR-Designer_Insert_Formula=Insert_Formula
FR-Designer_Insert_Chart= FR-Designer_Insert_Chart=
FR-Designer_Insert_Text= FR-Designer_Insert_Text=
FR-Designer_Double= FR-Designer_Double=
FR-Designer_Add_Event=Add Event

1
designer_base/src/com/fr/design/locale/designer_en_US.properties

@ -2106,3 +2106,4 @@ FR-Designer_Insert_Formula=Insert_Formula
FR-Designer_Insert-Chart= FR-Designer_Insert-Chart=
FR-Designer_Insert-Text= FR-Designer_Insert-Text=
FR-Designer_Double= FR-Designer_Double=
FR-Designer_Add_Event=Add Event

1
designer_base/src/com/fr/design/locale/designer_ja_JP.properties

@ -2107,3 +2107,4 @@ FR-Designer_Label_Name=
FR-Designer_Insert-Chart= FR-Designer_Insert-Chart=
FR-Designer_Insert-Text= FR-Designer_Insert-Text=
FR-Designer_Insert_Formula= FR-Designer_Insert_Formula=
FR-Designer_Add_Event=

1
designer_base/src/com/fr/design/locale/designer_ko_KR.properties

@ -2107,3 +2107,4 @@ FR-Designer_Use_Params_Template=
FR-Designer_Label_Name= FR-Designer_Label_Name=
FR-Designer_Insert-Chart= FR-Designer_Insert-Chart=
FR-Designer_Insert-Text= FR-Designer_Insert-Text=
FR-Designer_Add_Event=

1
designer_base/src/com/fr/design/locale/designer_zh_CN.properties

@ -2101,3 +2101,4 @@ FR-Designer_Insert_Image=\u63D2\u5165\u56FE\u7247
FR-Designer_Insert_Chart=\u63D2\u5165\u56FE\u8868 FR-Designer_Insert_Chart=\u63D2\u5165\u56FE\u8868
FR-Designer_Insert_Text=\u63D2\u5165\u666E\u901A\u6587\u672C FR-Designer_Insert_Text=\u63D2\u5165\u666E\u901A\u6587\u672C
FR-Designer_Insert_Formula=\u63D2\u5165\u516C\u5F0F FR-Designer_Insert_Formula=\u63D2\u5165\u516C\u5F0F
FR-Designer_Add_Event=\u6DFB\u52A0\u4E8B\u4EF6

1
designer_base/src/com/fr/design/locale/designer_zh_TW.properties

@ -2107,3 +2107,4 @@ FR-Designer_Use_Params_Template=
FR-Designer_Label_Name= FR-Designer_Label_Name=
FR-Designer_Insert-Chart= FR-Designer_Insert-Chart=
FR-Designer_Insert-Text= FR-Designer_Insert-Text=
FR-Designer_Add_Event=

5
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -126,7 +126,10 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return; return;
} }
long saveTime = System.currentTimeMillis(); // 保存模板的时间点 long saveTime = System.currentTimeMillis(); // 保存模板的时间点
tic.collectInfo(template, this, openTime, saveTime); try {
tic.collectInfo(template, this, openTime, saveTime);
} catch (Throwable th) { // 不管收集过程中出现任何异常,都不应该影响模版保存
}
openTime = saveTime; // 更新 openTime,准备下一次计算 openTime = saveTime; // 更新 openTime,准备下一次计算
} }

132
designer/src/com/fr/design/widget/EventCreator.java → designer_base/src/com/fr/design/widget/EventCreator.java

@ -1,76 +1,58 @@
package com.fr.design.widget; package com.fr.design.widget;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.controlpane.NameableSelfCreator;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.form.event.Listener; import com.fr.design.gui.ilist.ListModelElement;
import com.fr.form.ui.FileEditor; import com.fr.form.event.Listener;
import com.fr.form.ui.Widget; import com.fr.form.ui.FileEditor;
import com.fr.general.Inter; import com.fr.form.ui.Widget;
import com.fr.general.NameObject; import com.fr.general.Inter;
import com.fr.stable.Nameable; import com.fr.general.NameObject;
import com.fr.stable.Nameable;
public class EventCreator extends NameableSelfCreator {
private String eventName; public class EventCreator extends NameableSelfCreator {
private String eventName;
public EventCreator(String eventName) {
super(switchLang(eventName), Listener.class, WidgetEventPane.WidgetEventListenerUpdatePane.class); public EventCreator(String eventName, Class<? extends BasicBeanPane> updatePane) {
this.eventName = eventName; super(switchLang(eventName), Listener.class, updatePane);
} this.eventName = eventName;
}
@Override
public Nameable createNameable(UnrepeatedNameHelper helper) { @Override
return new NameObject(helper.createUnrepeatedName(this.menuName()),new Listener(this.eventName)) ; public Nameable createNameable(UnrepeatedNameHelper helper) {
} return new NameObject(helper.createUnrepeatedName(this.menuName()),new Listener(this.eventName)) ;
}
public static EventCreator[] createEventCreator(String[] supportedEvents) {
EventCreator[] creators = new EventCreator[supportedEvents.length]; public static EventCreator[] createEventCreator(String[] supportedEvents, Class<? extends BasicBeanPane> updatePane) {
EventCreator[] creators = new EventCreator[supportedEvents.length];
for (int i = 0; i < supportedEvents.length; i++) {
creators[i] = new EventCreator(supportedEvents[i]); for (int i = 0; i < supportedEvents.length; i++) {
} creators[i] = new EventCreator(supportedEvents[i], updatePane);
}
return creators;
} return creators;
}
/*
* richer:国际化事件名称所有需要国际化的事件都应按格式Event-eventName来进行国际化 /*
*/ * richer:国际化事件名称所有需要国际化的事件都应按格式Event-eventName来进行国际化
public static final String switchLang(String eventName) { */
try { public static final String switchLang(String eventName) {
return Inter.getLocText("Event-" + eventName); try {
} catch (Exception e) { return Inter.getLocText("Event-" + eventName);
FRContext.getLogger().error(e.getMessage(), e); } catch (Exception e) {
return eventName; FRContext.getLogger().error(e.getMessage(), e);
} return eventName;
} }
@Override }
public void saveUpdatedBean(ListModelElement wrapper, Object bean) { @Override
((NameObject)wrapper.wrapper).setObject(bean); public void saveUpdatedBean(ListModelElement wrapper, Object bean) {
} ((NameObject)wrapper.wrapper).setObject(bean);
}
public static final EventCreator BEFOREEDIT = new EventCreator(Widget.BEFOREEDIT); @Override
public String createTooltip() {
public static final EventCreator AFTEREDIT = new EventCreator(Widget.AFTEREDIT); return null;
}
public static final EventCreator CHANGE = new EventCreator(Widget.CHANGE);
public static final EventCreator CLICK = new EventCreator(Widget.EVENT_CLICK);
public static final EventCreator SUCCESS = new EventCreator("success");
public static final EventCreator AFTERINIT = new EventCreator(Widget.AFTERINIT);
public static final EventCreator STOPEDIT = new EventCreator(Widget.STOPEDIT);
public static final EventCreator STATECHANGE = new EventCreator(Widget.EVENT_STATECHANGE);
public static final EventCreator CALLBACK = new EventCreator(FileEditor.EVENT_UPLOAD_CALLBACK);
@Override
public String createTooltip() {
return null;
}
} }

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

@ -1,243 +1,73 @@
package com.fr.design.designer.properties; package com.fr.design.designer.properties;
import com.fr.base.BaseUtils; import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.base.FRContext; import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.frpane.ListenerUpdatePane; import com.fr.design.gui.frpane.ListenerUpdatePane;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.javascript.EmailPane; import com.fr.design.javascript.EmailPane;
import com.fr.design.javascript.JavaScriptActionPane; import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.menu.MenuDef; import com.fr.design.widget.EventCreator;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.write.submit.DBManipulationPane; import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.design.form.javascript.FormEmailPane; import com.fr.design.form.javascript.FormEmailPane;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.js.JavaScriptImpl;
import com.fr.stable.Nameable; import com.fr.stable.Nameable;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.util.ArrayList;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
public class EventPropertyTable extends BasicPane { public class EventPropertyTable extends UIListControlPane {
private ShortCut[] shorts;
private XCreator creator; private XCreator creator;
private JNameEdList nameableList;
private ToolBarDef toolbarDef;
private AddItemMenuDef itemMenu;
private ShortCut editItemAction;
private ShortCut copyItemAction;
private ShortCut removeItemAction;
private UIToolbar toolbar;
private ListenerUpdatePane listenerPane;
private FormDesigner designer; private FormDesigner designer;
public EventPropertyTable(FormDesigner designer) { public EventPropertyTable(FormDesigner designer) {
super(); super();
this.designer = designer; this.designer = designer;
this.initComponents();
} }
protected void initComponents() { @Override
this.setLayout(new BorderLayout()); public String getAddItemText() {
nameableList = new JNameEdList(new DefaultListModel()); return Inter.getLocText("FR-Designer_Add_Event");
this.add(new JScrollPane(nameableList), BorderLayout.CENTER); }
nameableList.setCellRenderer(new NameableListCellRenderer()); public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane {
nameableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
nameableList.addMouseListener(listMouseListener);
nameableList.setTransferHandler(new DnDTransferHandler());
nameableList.setDropMode(DropMode.INSERT);
nameableList.setDragEnabled(true);
toolbarDef = new ToolBarDef();
shorts = new ShortCut[] { itemMenu = new AddItemMenuDef(), editItemAction = new EditItemMenuDef(),
copyItemAction = new CopyItemAction(), removeItemAction = new RemoveItemAction() };
for (ShortCut sj : shorts) {
toolbarDef.addShortCut(sj);
}
toolbar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolbar);
this.add(toolbar, BorderLayout.NORTH);
}
/**
* 指定索引添加对象
* @param nameObject 对象名
* @param index 索引
*/
public void addNameObject(NameObject nameObject, int index) {
DefaultListModel model = (DefaultListModel) nameableList.getModel();
model.add(index, nameObject);
nameableList.setSelectedIndex(index);
nameableList.ensureIndexIsVisible(index);
nameableList.repaint();
}
/**
* 刷新控件
* @param strings 字符数组
*/
public void refreshNameableCreator(String[] strings) {
itemMenu.populate(strings);
toolbarDef.updateToolBar(toolbar);
toolbar.validate();
toolbar.repaint();
this.repaint();
}
private void checkButtonEnabled() {
boolean enable = nameableList.getSelectedValue() instanceof NameObject;
itemMenu.setEnabled(this.creator != null && itemMenu.getShortCutCount() > 0);
editItemAction.setEnabled(enable);
copyItemAction.setEnabled(enable);
removeItemAction.setEnabled(enable);
}
private MouseListener listMouseListener = new MouseAdapter() {
@Override @Override
public void mouseReleased(MouseEvent evt) { protected JavaScriptActionPane createJavaScriptActionPane() {
checkButtonEnabled(); return new JavaScriptActionPane() {
if (evt.getClickCount() >= 2 && SwingUtilities.isLeftMouseButton(evt)) {
NameObject object = (NameObject) nameableList.getSelectedValue();
showEventPane(object);
}
}
};
private void showEventPane(final NameObject object) {
if (listenerPane == null) {
listenerPane = new ListenerUpdatePane() {
@Override @Override
protected JavaScriptActionPane createJavaScriptActionPane() { protected DBManipulationPane createDBManipulationPane() {
return new JavaScriptActionPane() { return new DBManipulationPane(ValueEditorPaneFactory.formEditors());
}
@Override
protected DBManipulationPane createDBManipulationPane() {
return new DBManipulationPane(ValueEditorPaneFactory.formEditors());
}
@Override
protected String title4PopupWindow() {
return Inter.getLocText("Set_Callback_Function");
}
@Override
protected EmailPane initEmaiPane() {
return new FormEmailPane();
}
@Override
public boolean isForm() {
return true;
}
protected String[] getDefaultArgs() {
return new String[0];
}
}; @Override
protected String title4PopupWindow() {
return Inter.getLocText("Set_Callback_Function");
} }
@Override @Override
protected boolean supportCellAction() { protected EmailPane initEmaiPane() {
return false; return new FormEmailPane();
}
@Override
public boolean isForm() {
return true;
} }
};
}
listenerPane.populateBean((Listener) object.getObject());
BasicDialog dialog = listenerPane.showWindow(SwingUtilities.getWindowAncestor(this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
object.setObject(listenerPane.updateBean());
updateWidgetListener(creator);
}
});
dialog.setVisible(true);
}
private class NameableListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof NameObject) {
Nameable wrappee = (NameObject) value;
this.setText(wrappee.getName());
}
return this;
}
}
/*
* 增加项的MenuDef
*/
protected class AddItemMenuDef extends MenuDef {
public AddItemMenuDef() {
this.setName(Inter.getLocText("Add"));
this.setMnemonic('A');
this.setIconPath("/com/fr/design/images/control/addPopup.png");
}
public void populate(String[] eventNames) {
this.clearShortCuts();
for (int i = 0; i < eventNames.length; i++) {
final String eventname = eventNames[i];
this.addShortCut(new UpdateAction() {
{
this.setName(switchLang(eventname));
}
public void actionPerformed(ActionEvent e) {
NameObject nameable = new NameObject(createUnrepeatedName(switchLang(eventname)), new Listener(
eventname,new JavaScriptImpl()));
EventPropertyTable.this.addNameObject(nameable, EventPropertyTable.this.nameableList.getModel() protected String[] getDefaultArgs() {
.getSize()); return new String[0];
updateWidgetListener(creator); }
}
});
}
}
}
protected class EditItemMenuDef extends UpdateAction { };
public EditItemMenuDef() {
this.setName(Inter.getLocText("Edit"));
this.setMnemonic('E');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/edit.png"));
} }
public void actionPerformed(ActionEvent evt) { @Override
if (nameableList.getSelectedValue() instanceof NameObject) { protected boolean supportCellAction() {
showEventPane((NameObject) nameableList.getSelectedValue()); return false;
}
} }
} }
@ -261,222 +91,53 @@ public class EventPropertyTable extends BasicPane {
} }
Widget widget = creator.toData(); Widget widget = creator.toData();
refreshNameableCreator(widget.supportedEvents()); refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class));
((DefaultListModel) nameableList.getModel()).removeAllElements(); ArrayList<NameObject> nameObjectList = new ArrayList<>();
for (int i = 0, size = widget.getListenerSize(); i < size; i++) { for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
Listener listener = widget.getListener(i); Listener listener = widget.getListener(i);
if (!listener.isDefault()) { if (!listener.isDefault()) {
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(); checkButtonEnabled();
this.repaint(); this.repaint();
} }
/** /**
* 更新控件事件 * 更新控件事件
* @param creator 控件 * @param creator 控件
*/ */
public void updateWidgetListener(XCreator creator) { public void updateWidgetListener(XCreator creator) {
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel(); (creator.toData()).clearListeners();
(creator.toData()).clearListeners(); Nameable[] res = this.update();
for (int i = 0, len = listModel.getSize(); i < len; i++) { for (int i = 0; i < res.length; i++) {
(creator.toData()).addListener((Listener) ((NameObject) listModel.getElementAt(i)).getObject()); NameObject nameObject = (NameObject)res[i];
} (creator.toData()).addListener((Listener) nameObject.getObject());
designer.fireTargetModified(); }
designer.fireTargetModified();
checkButtonEnabled(); checkButtonEnabled();
} }
private class RemoveItemAction extends UpdateAction {
public RemoveItemAction() {
this.setName(Inter.getLocText("Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
public void actionPerformed(ActionEvent evt) {
GUICoreUtils.removeJListSelectedNodes(SwingUtilities.getWindowAncestor(EventPropertyTable.this),
nameableList);
updateWidgetListener(creator);
}
}
/*
* CopyItem
*/
private class CopyItemAction extends UpdateAction {
public CopyItemAction() {
this.setName(Inter.getLocText("Copy"));
this.setMnemonic('C');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/copy.png"));
}
public void actionPerformed(ActionEvent evt) {
NameObject selectedNameObject = (NameObject) nameableList.getSelectedValue();
// p: 用反射机制实现
try {
NameObject newNameObject = (NameObject) BaseUtils.cloneObject(selectedNameObject);
newNameObject.setName("CopyOf" + selectedNameObject.getName());
EventPropertyTable.this.addNameObject(newNameObject, nameableList.getSelectedIndex() + 1);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
updateWidgetListener(creator);
}
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Event"; return "Event";
} }
/** @Override
* 生成不重复名字 public NameableCreator[] createNameableCreators() {
* @param prefix 字符 return new NameableCreator[]{
* @return 返回 new EventCreator(Widget.EVENT_STATECHANGE, WidgetEventListenerUpdatePane.class)
*/ };
public String createUnrepeatedName(String prefix) {
DefaultListModel model = (DefaultListModel) nameableList.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = (Nameable) model.get(i);
}
int count = 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
}
}
if (!repeated) {
return name_test;
}
count++;
}
}
private class DnDTransferHandler extends TransferHandler {
private int action;
public DnDTransferHandler() {
this(TransferHandler.MOVE);
}
public DnDTransferHandler(int action) {
this.action = action;
}
@Override
public int getSourceActions(JComponent comp) {
return action;
}
@Override
public Transferable createTransferable(JComponent comp) {
int index = nameableList.getSelectedIndex();
if (index < 0 || index >= nameableList.getModel().getSize()) {
return null;
}
return new DnDListItem((NameObject) nameableList.getSelectedValue());
}
@Override
public boolean canImport(TransferSupport support) {
if (!support.isDrop()) {
return false;
}
if (!support.isDataFlavorSupported(DnDListItem.FLAVOR)) {
return false;
}
boolean actionSupported = (action & support.getSourceDropActions()) == action;
if (actionSupported) {
support.setDropAction(action);
return true;
}
return false;
}
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (!canImport(support)) {
return false;
}
JList.DropLocation dl = (JList.DropLocation) support.getDropLocation();
int importIndex = dl.getIndex();
try {
NameObject item = (NameObject) support.getTransferable().getTransferData(DnDListItem.FLAVOR);
JList list = (JList) support.getComponent();
DefaultListModel model = (DefaultListModel) list.getModel();
for (int i = 0; i <= importIndex; i++) {
if (ComparatorUtils.equals(item,model.getElementAt(i))) {
importIndex--;
break;
}
}
model.removeElement(item);
model.insertElementAt(item, importIndex);
updateWidgetListener(creator);
} catch (UnsupportedFlavorException e) {
return false;
} catch (java.io.IOException e) {
return false;
}
return true;
}
} }
public static class DnDListItem implements Transferable { @Override
private NameObject no; public void saveSettings() {
public static final DataFlavor FLAVOR = new DataFlavor(DnDListItem.class, "DnDListItem.class"); if (isPopulating) {
return;
public DnDListItem(NameObject no) { }
this.no = no; updateWidgetListener(creator);
} }
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[] { FLAVOR };
}
@Override
/**
*是否支持 dataFlavor
*@param DataFlavor类
*@return 支持返回true
*/
public boolean isDataFlavorSupported(DataFlavor flavor) {
if (ComparatorUtils.equals(flavor,FLAVOR)) {
return true;
}
return false;
}
@Override
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (ComparatorUtils.equals(flavor,FLAVOR)) {
return no;
}
return null;
}
}
} }

9
designer_form/src/com/fr/design/mainframe/JForm.java

@ -221,14 +221,19 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
} }
}); });
formDesign.addDesignerEditListener(new DesignerEditListener() { formDesign.addDesignerEditListener(new DesignerEditListener() {
private XComponent lastAffectedCreator;
@Override @Override
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { || evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) {
setPropertyPaneChange(formDesign.getRootComponent()); setPropertyPaneChange(formDesign.getRootComponent());
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
setPropertyPaneChange(evt.getAffectedCreator()); // 防止多次触发
if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) {
return;
}
lastAffectedCreator = evt.getAffectedCreator();
setPropertyPaneChange(lastAffectedCreator);
} }
} }
}); });

21
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -4,10 +4,7 @@ import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.EventPropertyTable; import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.WidgetPropertyTable; import com.fr.design.designer.properties.WidgetPropertyTable;
import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.fun.WidgetPropertyUIProvider;
@ -130,9 +127,6 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
private void createEventTable() { private void createEventTable() {
eventTable = new EventPropertyTable(designer); eventTable = new EventPropertyTable(designer);
designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable));
eventTable.setBorder(null);
esp = new UIScrollPane(eventTable); //用来装载事件table
esp.setBorder(null);
} }
/** /**
@ -242,7 +236,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
tabbedPane.setBorder(null); tabbedPane.setBorder(null);
tabbedPane.setTabPlacement(SwingConstants.BOTTOM); tabbedPane.setTabPlacement(SwingConstants.BOTTOM);
tabbedPane.addTab(Inter.getLocText("FR-Designer_Properties"), psp); tabbedPane.addTab(Inter.getLocText("FR-Designer_Properties"), psp);
tabbedPane.addTab(Inter.getLocText("FR-Designer_Event"), esp); tabbedPane.addTab(Inter.getLocText("FR-Designer_Event"), eventTable);
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp); tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp);
} }
@ -314,6 +308,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
*/ */
private class EventPropertyDesignerAdapter implements DesignerEditListener { private class EventPropertyDesignerAdapter implements DesignerEditListener {
EventPropertyTable propertyTable; EventPropertyTable propertyTable;
private XComponent lastAffectedCreator;
EventPropertyDesignerAdapter(EventPropertyTable eventTable) { EventPropertyDesignerAdapter(EventPropertyTable eventTable) {
this.propertyTable = eventTable; this.propertyTable = eventTable;
@ -321,8 +316,14 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
@Override @Override
public void fireCreatorModified(DesignerEvent evt) { public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) {
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { propertyTable.refresh();
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
// 防止多次触发
if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) {
return;
}
lastAffectedCreator = evt.getAffectedCreator();
propertyTable.refresh(); propertyTable.refresh();
} }
} }

Loading…
Cancel
Save