Browse Source

REPORT-3163 合作开发9.0设计器=>控件设置事件编辑=>国际化;整理代码

master
plough 8 years ago
parent
commit
1281a70691
  1. 5
      designer/src/com/fr/design/widget/WidgetEventPane.java
  2. 1
      designer_base/src/com/fr/design/locale/designer.properties
  3. 1
      designer_base/src/com/fr/design/locale/designer_en_US.properties
  4. 1
      designer_base/src/com/fr/design/locale/designer_ja_JP.properties
  5. 1
      designer_base/src/com/fr/design/locale/designer_ko_KR.properties
  6. 1
      designer_base/src/com/fr/design/locale/designer_zh_CN.properties
  7. 1
      designer_base/src/com/fr/design/locale/designer_zh_TW.properties
  8. 201
      designer_form/src/com/fr/design/designer/properties/EventPropertyTable.java

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

@ -41,6 +41,11 @@ public class WidgetEventPane extends ObjectUIControlPane {
this.setNameListEditable(false);
}
@Override
public String getAddItemText() {
return Inter.getLocText("FR-Designer_Add_Event");
}
/**
* 生成添加按钮的NameableCreator
* @return 按钮的NameableCreator

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_Text=
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-Text=
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-Text=
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_Insert-Chart=
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_Text=\u63D2\u5165\u666E\u901A\u6587\u672C
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_Insert-Chart=
FR-Designer_Insert-Text=
FR-Designer_Add_Event=

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

@ -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);
updateWidgetListener(creator);
}
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;
}
}
}
Loading…
Cancel
Save