Browse Source

REPORT-3163 合作开发9.0设计器=>控件设置事件编辑(表单)=>初步修改

master
plough 7 years ago
parent
commit
dd1bfadd21
  1. 4
      designer/src/com/fr/design/widget/WidgetEventPane.java
  2. 43
      designer_base/src/com/fr/design/widget/EventCreator.java
  3. 206
      designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java

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

@ -35,7 +35,7 @@ public class WidgetEventPane extends ObjectUIControlPane {
*/ */
public NameableCreator[] createNameableCreators() { public NameableCreator[] createNameableCreators() {
return new NameableCreator[]{ return new NameableCreator[]{
EventCreator.STATECHANGE new EventCreator(Widget.EVENT_STATECHANGE, WidgetEventListenerUpdatePane.class)
}; };
} }
@ -108,7 +108,7 @@ public class WidgetEventPane extends ObjectUIControlPane {
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;

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

@ -1,6 +1,7 @@
package com.fr.design.widget; package com.fr.design.widget;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.gui.controlpane.NameableSelfCreator;
import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.controlpane.UnrepeatedNameHelper;
import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ListModelElement;
@ -14,8 +15,8 @@ import com.fr.stable.Nameable;
public class EventCreator extends NameableSelfCreator { public class EventCreator extends NameableSelfCreator {
private String eventName; private String eventName;
public EventCreator(String eventName) { public EventCreator(String eventName, Class<? extends BasicBeanPane> updatePane) {
super(switchLang(eventName), Listener.class, WidgetEventPane.WidgetEventListenerUpdatePane.class); super(switchLang(eventName), Listener.class, updatePane);
this.eventName = eventName; this.eventName = eventName;
} }
@ -24,11 +25,11 @@ public class EventCreator extends NameableSelfCreator {
return new NameObject(helper.createUnrepeatedName(this.menuName()),new Listener(this.eventName)) ; return new NameObject(helper.createUnrepeatedName(this.menuName()),new Listener(this.eventName)) ;
} }
public static EventCreator[] createEventCreator(String[] supportedEvents) { public static EventCreator[] createEventCreator(String[] supportedEvents, Class<? extends BasicBeanPane> updatePane) {
EventCreator[] creators = new EventCreator[supportedEvents.length]; EventCreator[] creators = new EventCreator[supportedEvents.length];
for (int i = 0; i < supportedEvents.length; i++) { for (int i = 0; i < supportedEvents.length; i++) {
creators[i] = new EventCreator(supportedEvents[i]); creators[i] = new EventCreator(supportedEvents[i], updatePane);
} }
return creators; return creators;
@ -51,23 +52,23 @@ public class EventCreator extends NameableSelfCreator {
} }
public static final EventCreator BEFOREEDIT = new EventCreator(Widget.BEFOREEDIT); // public static final EventCreator BEFOREEDIT = new EventCreator(Widget.BEFOREEDIT);
//
public static final EventCreator AFTEREDIT = new EventCreator(Widget.AFTEREDIT); // public static final EventCreator AFTEREDIT = new EventCreator(Widget.AFTEREDIT);
//
public static final EventCreator CHANGE = new EventCreator(Widget.CHANGE); // public static final EventCreator CHANGE = new EventCreator(Widget.CHANGE);
//
public static final EventCreator CLICK = new EventCreator(Widget.EVENT_CLICK); // public static final EventCreator CLICK = new EventCreator(Widget.EVENT_CLICK);
//
public static final EventCreator SUCCESS = new EventCreator("success"); // public static final EventCreator SUCCESS = new EventCreator("success");
//
public static final EventCreator AFTERINIT = new EventCreator(Widget.AFTERINIT); // public static final EventCreator AFTERINIT = new EventCreator(Widget.AFTERINIT);
//
public static final EventCreator STOPEDIT = new EventCreator(Widget.STOPEDIT); // public static final EventCreator STOPEDIT = new EventCreator(Widget.STOPEDIT);
//
public static final EventCreator STATECHANGE = new EventCreator(Widget.EVENT_STATECHANGE); // public static final EventCreator STATECHANGE = new EventCreator(Widget.EVENT_STATECHANGE);
//
public static final EventCreator CALLBACK = new EventCreator(FileEditor.EVENT_UPLOAD_CALLBACK); // public static final EventCreator CALLBACK = new EventCreator(FileEditor.EVENT_UPLOAD_CALLBACK);
@Override @Override
public String createTooltip() { public String createTooltip() {

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

@ -3,6 +3,9 @@ package com.fr.design.designer.properties;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.controlpane.NameableCreator;
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.frpane.ListenerUpdatePane;
import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
@ -12,6 +15,7 @@ import com.fr.design.mainframe.FormDesigner;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.widget.EventCreator;
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.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -39,11 +43,11 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.io.IOException; import java.io.IOException;
public class EventPropertyTable extends BasicPane { public class EventPropertyTable extends UIListControlPane {
private ShortCut[] shorts; private ShortCut[] shorts;
private XCreator creator; private XCreator creator;
private JNameEdList nameableList; // private JNameEdList nameableList;
private ToolBarDef toolbarDef; private ToolBarDef toolbarDef;
private AddItemMenuDef itemMenu; private AddItemMenuDef itemMenu;
private ShortCut editItemAction; private ShortCut editItemAction;
@ -59,27 +63,22 @@ public class EventPropertyTable extends BasicPane {
this.initComponents(); this.initComponents();
} }
protected void initComponents() { @Override
this.setLayout(new BorderLayout()); protected void initComponentPane() {
nameableList = new JNameEdList(new DefaultListModel());
this.add(new JScrollPane(nameableList), BorderLayout.CENTER);
nameableList.setCellRenderer(new NameableListCellRenderer());
nameableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
nameableList.addMouseListener(listMouseListener);
nameableList.setTransferHandler(new DnDTransferHandler());
nameableList.setDropMode(DropMode.INSERT);
nameableList.setDragEnabled(true);
toolbarDef = new ToolBarDef(); toolbarDef = new ToolBarDef();
shorts = new ShortCut[] { itemMenu = new AddItemMenuDef(), editItemAction = new EditItemMenuDef(), // shorts = new ShortCut[] { itemMenu = new AddItemMenuDef(), editItemAction = new EditItemMenuDef(),
copyItemAction = new CopyItemAction(), removeItemAction = new RemoveItemAction() }; // copyItemAction = new CopyItemAction(), removeItemAction = new RemoveItemAction() };
shorts = new ShortCut[] { itemMenu = new AddItemMenuDef()};
for (ShortCut sj : shorts) { for (ShortCut sj : shorts) {
toolbarDef.addShortCut(sj); toolbarDef.addShortCut(sj);
} }
toolbar = ToolBarDef.createJToolBar(); toolbar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolbar); toolbarDef.updateToolBar(toolbar);
this.add(toolbar, BorderLayout.NORTH);
super.initComponentPane();
}
protected void initComponents() {
} }
/** /**
@ -110,74 +109,41 @@ public class EventPropertyTable extends BasicPane {
this.repaint(); this.repaint();
} }
private void checkButtonEnabled() { public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane {
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) { @Override
if (listenerPane == null) { protected DBManipulationPane createDBManipulationPane() {
listenerPane = new ListenerUpdatePane() { return new DBManipulationPane(ValueEditorPaneFactory.formEditors());
}
@Override @Override
protected JavaScriptActionPane createJavaScriptActionPane() { protected String title4PopupWindow() {
return new JavaScriptActionPane() { return Inter.getLocText("Set_Callback_Function");
@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 @Override
protected boolean supportCellAction() { protected EmailPane initEmaiPane() {
return false; return new FormEmailPane();
}
@Override
public boolean isForm() {
return true;
}
protected String[] getDefaultArgs() {
return new String[0];
} }
}; };
} }
listenerPane.populateBean((Listener) object.getObject());
BasicDialog dialog = listenerPane.showWindow(SwingUtilities.getWindowAncestor(this)); @Override
dialog.addDialogActionListener(new DialogActionAdapter() { protected boolean supportCellAction() {
@Override return false;
public void doOk() { }
object.setObject(listenerPane.updateBean());
updateWidgetListener(creator);
}
});
dialog.setVisible(true);
} }
private class NameableListCellRenderer extends DefaultListCellRenderer { private class NameableListCellRenderer extends DefaultListCellRenderer {
@ -227,20 +193,6 @@ public class EventPropertyTable extends BasicPane {
} }
} }
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) {
if (nameableList.getSelectedValue() instanceof NameObject) {
showEventPane((NameObject) nameableList.getSelectedValue());
}
}
}
private String switchLang(String eventName) { private String switchLang(String eventName) {
return Inter.getLocText("Event-" + eventName); return Inter.getLocText("Event-" + eventName);
} }
@ -261,7 +213,7 @@ 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(); ((DefaultListModel) nameableList.getModel()).removeAllElements();
for (int i = 0, size = widget.getListenerSize(); i < size; i++) { for (int i = 0, size = widget.getListenerSize(); i < size; i++) {
@ -288,81 +240,21 @@ public class EventPropertyTable extends BasicPane {
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) { @Override
return name_test; public void saveSettings() {
}
count++;
}
} }
private class DnDTransferHandler extends TransferHandler { private class DnDTransferHandler extends TransferHandler {

Loading…
Cancel
Save