|
|
|
@ -1,13 +1,9 @@
|
|
|
|
|
package com.fr.design.designer.properties; |
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
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.ilist.JNameEdList; |
|
|
|
|
import com.fr.design.gui.ilist.ListModelElement; |
|
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
|
import com.fr.design.javascript.EmailPane; |
|
|
|
@ -18,59 +14,42 @@ import com.fr.design.menu.ShortCut;
|
|
|
|
|
import com.fr.design.menu.ToolBarDef; |
|
|
|
|
import com.fr.design.widget.EventCreator; |
|
|
|
|
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.designer.creator.XCreator; |
|
|
|
|
import com.fr.form.event.Listener; |
|
|
|
|
import com.fr.design.form.javascript.FormEmailPane; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.Inter; |
|
|
|
|
import com.fr.general.NameObject; |
|
|
|
|
import com.fr.js.JavaScriptImpl; |
|
|
|
|
import com.fr.stable.Nameable; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
|
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; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
public class EventPropertyTable extends UIListControlPane { |
|
|
|
|
|
|
|
|
|
private ShortCut[] shorts; |
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
public EventPropertyTable(FormDesigner designer) { |
|
|
|
|
super(); |
|
|
|
|
this.designer = designer; |
|
|
|
|
this.initComponents(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getAddItemText() { |
|
|
|
|
return Inter.getLocText("FR-Designer_Add_Event"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initComponentPane() { |
|
|
|
|
toolbarDef = new ToolBarDef(); |
|
|
|
|
// shorts = new ShortCut[] { itemMenu = new AddItemMenuDef(), editItemAction = new EditItemMenuDef(),
|
|
|
|
|
// copyItemAction = new CopyItemAction(), removeItemAction = new RemoveItemAction() };
|
|
|
|
|
shorts = new ShortCut[] { itemMenu = new AddItemMenuDef()}; |
|
|
|
|
shorts = new ShortCut[] {new AddItemMenuDef()}; |
|
|
|
|
for (ShortCut sj : shorts) { |
|
|
|
|
toolbarDef.addShortCut(sj); |
|
|
|
|
} |
|
|
|
@ -80,9 +59,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
super.initComponentPane(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initComponents() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 指定索引添加对象 |
|
|
|
|
* @param nameObject 对象名 |
|
|
|
@ -91,7 +67,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
public void addNameObject(NameObject nameObject, int index) { |
|
|
|
|
DefaultListModel model = (DefaultListModel) nameableList.getModel(); |
|
|
|
|
|
|
|
|
|
// model.add(index, nameObject);
|
|
|
|
|
model.add(index, new ListModelElement(nameObject)); |
|
|
|
|
nameableList.setSelectedIndex(index); |
|
|
|
|
nameableList.ensureIndexIsVisible(index); |
|
|
|
@ -99,19 +74,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
nameableList.repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新控件 |
|
|
|
|
* @param strings 字符数组 |
|
|
|
|
*/ |
|
|
|
|
public void refreshNameableCreator(String[] strings) { |
|
|
|
|
itemMenu.populate(strings); |
|
|
|
|
|
|
|
|
|
toolbarDef.updateToolBar(toolbar); |
|
|
|
|
toolbar.validate(); |
|
|
|
|
toolbar.repaint(); |
|
|
|
|
this.repaint(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -149,20 +111,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
*/ |
|
|
|
@ -204,8 +152,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
* 刷新 |
|
|
|
|
*/ |
|
|
|
|
public void refresh() { |
|
|
|
|
// isPopulating = true;
|
|
|
|
|
System.out.println("in refresh..."); |
|
|
|
|
int selectionSize = designer.getSelectionModel().getSelection().size(); |
|
|
|
|
if (selectionSize == 0 || selectionSize == 1) { |
|
|
|
|
this.creator = selectionSize == 0 ? designer.getRootComponent() : designer.getSelectionModel() |
|
|
|
@ -220,35 +166,23 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
|
|
|
|
|
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++) { |
|
|
|
|
Listener listener = widget.getListener(i); |
|
|
|
|
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(); |
|
|
|
|
this.repaint(); |
|
|
|
|
// isPopulating = false;
|
|
|
|
|
System.out.println("out refresh..."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 更新控件事件 |
|
|
|
|
* @param 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++) {
|
|
|
|
|
// NameObject nameObject = isSaving ? (NameObject)((ListModelElement) listModel.getElementAt(i)).wrapper : (NameObject)(listModel.getElementAt(i));
|
|
|
|
|
// (creator.toData()).addListener((Listener) nameObject.getObject());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public void updateWidgetListener(XCreator creator) { |
|
|
|
|
(creator.toData()).clearListeners(); |
|
|
|
|
Nameable[] res = this.update(); |
|
|
|
|
for (int i = 0; i < res.length; i++) { |
|
|
|
@ -260,10 +194,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
checkButtonEnabled(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void updateWidgetListener(XCreator creator) { |
|
|
|
|
updateWidgetListener(creator, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return "Event"; |
|
|
|
@ -281,121 +211,6 @@ public class EventPropertyTable extends UIListControlPane {
|
|
|
|
|
if (isPopulating) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
updateWidgetListener(creator, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 { |
|
|
|
|
private NameObject no; |
|
|
|
|
public static final DataFlavor FLAVOR = new DataFlavor(DnDListItem.class, "DnDListItem.class"); |
|
|
|
|
|
|
|
|
|
public DnDListItem(NameObject no) { |
|
|
|
|
this.no = no; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |