Browse Source
* commit '2dc0a0da7322aa73044bb2cff5558e7507188e5a': REPORT-8355 9.0之前开发的功能与bug patch到10.0(部分) REPORT-8355 9.0之前开发的功能与bug patch到10.0(部分)master
superman
7 years ago
27 changed files with 1752 additions and 320 deletions
@ -0,0 +1,483 @@
|
||||
package com.fr.design.gui.controlpane; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.actions.UpdateAction; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ilist.ListModelElement; |
||||
import com.fr.design.gui.ilist.UIList; |
||||
import com.fr.design.gui.itoolbar.UIToolBarUI; |
||||
import com.fr.design.gui.itoolbar.UIToolbar; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.menu.ShortCut; |
||||
import com.fr.design.menu.ToolBarDef; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.Inter; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.Nameable; |
||||
import com.fr.stable.StringUtils; |
||||
import sun.swing.DefaultLookup; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JComponent; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.ListCellRenderer; |
||||
import javax.swing.ListSelectionModel; |
||||
import javax.swing.border.Border; |
||||
import javax.swing.event.ListSelectionEvent; |
||||
import javax.swing.event.ListSelectionListener; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Point; |
||||
import java.awt.Toolkit; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.InputEvent; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.event.MouseListener; |
||||
import java.util.Arrays; |
||||
import java.util.Comparator; |
||||
|
||||
/** |
||||
* 简单列表面板 |
||||
* Created by plough on 2018/2/1. |
||||
*/ |
||||
public class UISimpleListControlPane extends BasicPane { |
||||
public static final String LIST_NAME = "UISimpleControl_List"; |
||||
|
||||
protected UIList nameList; |
||||
protected String selectedName; |
||||
private ShortCut4JControlPane[] shorts; |
||||
private ToolBarDef toolbarDef; |
||||
private UIToolbar toolBar; |
||||
|
||||
public UISimpleListControlPane() { |
||||
initComponentPane(); |
||||
} |
||||
|
||||
public ShortCut4JControlPane[] getShorts() { |
||||
return shorts; |
||||
} |
||||
|
||||
protected void initComponentPane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.add(getContentPane(), BorderLayout.CENTER); |
||||
this.checkButtonEnabled(); |
||||
} |
||||
|
||||
protected JPanel getContentPane() { |
||||
JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
|
||||
JPanel listPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
initListPane(listPane); |
||||
contentPane.add(listPane, BorderLayout.CENTER); |
||||
|
||||
shorts = this.createShortcuts(); |
||||
if (ArrayUtils.isEmpty(shorts)) { |
||||
return contentPane; |
||||
} |
||||
|
||||
toolbarDef = new ToolBarDef(); |
||||
for (ShortCut4JControlPane sj : shorts) { |
||||
toolbarDef.addShortCut(sj.getShortCut()); |
||||
} |
||||
toolBar = ToolBarDef.createJToolBar(); |
||||
toolBar.setUI(new UIToolBarUI(){ |
||||
@Override |
||||
public void paint(Graphics g, JComponent c) { |
||||
Graphics2D g2 = (Graphics2D) g; |
||||
g2.setColor(Color.WHITE); |
||||
g2.fillRect(0, 0, c.getWidth(), c.getHeight()); |
||||
} |
||||
}); |
||||
toolbarDef.updateToolBar(toolBar); |
||||
// 封装一层,加边框
|
||||
JPanel toolBarPane = new JPanel(new BorderLayout()); |
||||
toolBarPane.add(toolBar, BorderLayout.CENTER); |
||||
toolBarPane.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, UIConstants.RULER_LINE_COLOR)); |
||||
|
||||
listPane.add(toolBarPane, BorderLayout.NORTH); |
||||
|
||||
return contentPane; |
||||
} |
||||
|
||||
protected ShortCut4JControlPane[] createShortcuts() { |
||||
return new ShortCut4JControlPane[]{ |
||||
moveUpItemShortCut(), |
||||
moveDownItemShortCut(), |
||||
sortItemShortCut(), |
||||
}; |
||||
} |
||||
|
||||
protected void initListPane(JPanel listPane) { |
||||
nameList = createJNameList(); |
||||
nameList.setName(LIST_NAME); |
||||
nameList.setSelectionBackground(UIConstants.ATTRIBUTE_PRESS); |
||||
listPane.add(new UIScrollPane(nameList), BorderLayout.CENTER); |
||||
|
||||
|
||||
nameList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||||
nameList.addMouseListener(listMouseListener); |
||||
nameList.addListSelectionListener(new ListSelectionListener() { |
||||
public void valueChanged(ListSelectionEvent evt) { |
||||
// richie:避免多次update和populate大大降低效率
|
||||
if (!evt.getValueIsAdjusting()) { |
||||
UISimpleListControlPane.this.checkButtonEnabled(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public UIList createJNameList() { |
||||
UIList nameList = new UIList(new DefaultListModel()) { |
||||
@Override |
||||
public int locationToIndex(Point location) { |
||||
int index = super.locationToIndex(location); |
||||
if (index != -1 && !getCellBounds(index, index).contains(location)) { |
||||
return -1; |
||||
} |
||||
else { |
||||
return index; |
||||
} |
||||
} |
||||
}; |
||||
nameList.setCellRenderer(new NameableListCellRenderer(this)); |
||||
return nameList; |
||||
} |
||||
|
||||
protected ShortCut4JControlPane moveUpItemShortCut() { |
||||
return new NormalEnableShortCut(new MoveUpItemAction()); |
||||
} |
||||
|
||||
protected ShortCut4JControlPane moveDownItemShortCut() { |
||||
return new NormalEnableShortCut(new MoveDownItemAction()); |
||||
} |
||||
|
||||
protected ShortCut4JControlPane sortItemShortCut() { |
||||
return new NormalEnableShortCut(new SortItemAction()); |
||||
} |
||||
|
||||
public Nameable[] update() { |
||||
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>(); |
||||
DefaultListModel listModel = (DefaultListModel) this.nameList.getModel(); |
||||
for (int i = 0, len = listModel.getSize(); i < len; i++) { |
||||
res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); |
||||
} |
||||
|
||||
return res.toArray(new Nameable[res.size()]); |
||||
} |
||||
|
||||
public void populate(Nameable[] nameableArray) { |
||||
DefaultListModel listModel = (DefaultListModel) this.nameList.getModel(); |
||||
listModel.removeAllElements(); |
||||
if (ArrayUtils.isEmpty(nameableArray)) { |
||||
return; |
||||
} |
||||
|
||||
listModel.setSize(nameableArray.length); |
||||
for (int i = 0; i < nameableArray.length; i++) { |
||||
listModel.set(i, new ListModelElement(nameableArray[i])); |
||||
} |
||||
if (listModel.size() > 0 || this.nameList.getSelectedIndex() != 0) { |
||||
this.nameList.setSelectedIndex(0); |
||||
} |
||||
this.checkButtonEnabled(); |
||||
} |
||||
|
||||
/** |
||||
* 根据name,选中UINameEdList中的item |
||||
*/ |
||||
public void setSelectedName(String name) { |
||||
DefaultListModel listModel = (DefaultListModel) this.nameList.getModel(); |
||||
for (int i = 0, len = listModel.getSize(); i < len; i++) { |
||||
Nameable item = ((ListModelElement) listModel.getElementAt(i)).wrapper; |
||||
if (ComparatorUtils.equals(name, item.getName())) { |
||||
this.nameList.setSelectedIndex(i); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取选中的名字 |
||||
*/ |
||||
public String getSelectedName() { |
||||
ListModelElement el = (ListModelElement) this.nameList.getSelectedValue(); |
||||
|
||||
return el == null ? null : el.wrapper.getName(); |
||||
} |
||||
|
||||
protected DefaultListModel getModel() { |
||||
return (DefaultListModel) this.nameList.getModel(); |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
/* |
||||
* 上移Item |
||||
*/ |
||||
private class MoveUpItemAction extends UpdateAction { |
||||
public MoveUpItemAction() { |
||||
this.setName(Inter.getLocText("Utils-Move_Up")); |
||||
this.setMnemonic('U'); |
||||
this.setSmallIcon(BaseUtils |
||||
.readIcon("/com/fr/design/images/control/up.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent evt) { |
||||
int selectedIndex = nameList.getSelectedIndex(); |
||||
if (selectedIndex == -1) { |
||||
return; |
||||
} |
||||
|
||||
// 上移
|
||||
if (selectedIndex > 0) { |
||||
DefaultListModel listModel = (DefaultListModel) nameList.getModel(); |
||||
|
||||
Object prevObj = listModel.get(selectedIndex - 1); |
||||
Object currentObj = listModel.get(selectedIndex); |
||||
listModel.set(selectedIndex - 1, currentObj); |
||||
listModel.set(selectedIndex, prevObj); |
||||
|
||||
nameList.setSelectedIndex(selectedIndex - 1); |
||||
nameList.ensureIndexIsVisible(selectedIndex - 1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* 下移Item |
||||
*/ |
||||
private class MoveDownItemAction extends UpdateAction { |
||||
public MoveDownItemAction() { |
||||
this.setName(Inter.getLocText("Utils-Move_Down")); |
||||
this.setMnemonic('D'); |
||||
this.setSmallIcon(BaseUtils |
||||
.readIcon("/com/fr/design/images/control/down.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent evt) { |
||||
int selectedIndex = nameList.getSelectedIndex(); |
||||
if (selectedIndex == -1) { |
||||
return; |
||||
} |
||||
|
||||
if (selectedIndex < nameList.getModel().getSize() - 1) { |
||||
DefaultListModel listModel = (DefaultListModel) nameList.getModel(); |
||||
|
||||
Object nextObj = listModel.get(selectedIndex + 1); |
||||
Object currentObj = listModel.get(selectedIndex); |
||||
listModel.set(selectedIndex + 1, currentObj); |
||||
listModel.set(selectedIndex, nextObj); |
||||
|
||||
nameList.setSelectedIndex(selectedIndex + 1); |
||||
nameList.ensureIndexIsVisible(selectedIndex + 1); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private class SortItemAction extends UpdateAction { |
||||
private boolean isAtoZ = false; |
||||
|
||||
public SortItemAction() { |
||||
this.setName(Inter.getLocText("FR-Action_Sort")); |
||||
this.setMnemonic('S'); |
||||
this.setSmallIcon(BaseUtils |
||||
.readIcon("/com/fr/design/images/control/sortAsc.png")); |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent evt) { |
||||
// p:选中的值.
|
||||
Object selectedValue = nameList.getSelectedValue(); |
||||
|
||||
DefaultListModel listModel = (DefaultListModel) nameList.getModel(); |
||||
if (listModel.getSize() <= 0) { |
||||
return; |
||||
} |
||||
Nameable[] nameableArray = new Nameable[listModel.getSize()]; |
||||
|
||||
for (int i = 0; i < listModel.getSize(); i++) { |
||||
nameableArray[i] = ((ListModelElement) listModel.getElementAt(i)).wrapper; |
||||
} |
||||
|
||||
// p:排序.
|
||||
if (isAtoZ) { // 升序
|
||||
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() { |
||||
@Override |
||||
public int compare(Nameable o1, Nameable o2) { |
||||
return ComparatorUtils.compare(o2.getName(), o1.getName()); |
||||
} |
||||
}; |
||||
isAtoZ = !isAtoZ; |
||||
Arrays.sort(nameableArray, nameableComparator); |
||||
} else { // 降序
|
||||
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() { |
||||
@Override |
||||
public int compare(Nameable o1, Nameable o2) { |
||||
return ComparatorUtils.compare(o1.getName(), o2 |
||||
.getName()); |
||||
} |
||||
}; |
||||
isAtoZ = !isAtoZ; |
||||
Arrays.sort(nameableArray, nameableComparator); |
||||
} |
||||
|
||||
for (int i = 0; i < nameableArray.length; i++) { |
||||
listModel.set(i, new ListModelElement(nameableArray[i])); |
||||
} |
||||
|
||||
// p:需要选中以前的那个值.
|
||||
if (selectedValue != null) { |
||||
nameList.setSelectedValue(selectedValue, true); |
||||
} |
||||
|
||||
checkButtonEnabled(); |
||||
// p:需要repaint.
|
||||
nameList.repaint(); |
||||
} |
||||
} |
||||
|
||||
/* |
||||
* UIList的鼠标事件 |
||||
*/ |
||||
private MouseListener listMouseListener = new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
JList list = (JList) e.getSource(); |
||||
if (list.locationToIndex(e.getPoint()) == -1 && !e.isShiftDown() |
||||
&& !isMenuShortcutKeyDown(e)) { |
||||
list.clearSelection(); |
||||
} |
||||
} |
||||
|
||||
private boolean isMenuShortcutKeyDown(InputEvent event) { |
||||
return (event.getModifiers() & Toolkit.getDefaultToolkit() |
||||
.getMenuShortcutKeyMask()) != 0; |
||||
} |
||||
}; |
||||
|
||||
/** |
||||
* 检查按钮可用状态 Check button enabled. |
||||
*/ |
||||
public void checkButtonEnabled() { |
||||
for (ShortCut4JControlPane sj : getShorts()) { |
||||
sj.checkEnable(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置选中项 |
||||
* |
||||
* @param index 选中项的序列号 |
||||
*/ |
||||
public void setSelectedIndex(int index) { |
||||
nameList.setSelectedIndex(index); |
||||
} |
||||
|
||||
|
||||
public class NormalEnableShortCut extends ShortCut4JControlPane { |
||||
public NormalEnableShortCut(ShortCut shortCut) { |
||||
this.shortCut = shortCut; |
||||
} |
||||
|
||||
/** |
||||
* 检查是否可用 |
||||
*/ |
||||
@Override |
||||
public void checkEnable() { |
||||
this.shortCut.setEnabled(getModel() |
||||
.getSize() > 0 |
||||
&& UISimpleListControlPane.this.nameList.getSelectedIndex() != -1); |
||||
} |
||||
} |
||||
|
||||
|
||||
private class NameableListCellRenderer extends |
||||
JPanel implements ListCellRenderer { |
||||
|
||||
private UILabel label; |
||||
private UISimpleListControlPane listControlPane; |
||||
private Color initialLabelForeground; |
||||
|
||||
public NameableListCellRenderer(UISimpleListControlPane listControlPane) { |
||||
super(); |
||||
this.listControlPane = listControlPane; |
||||
initComponents(); |
||||
setOpaque(true); |
||||
setBorder(getNoFocusBorder()); |
||||
setName("List.cellRenderer"); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
label = new UILabel(); |
||||
label.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 0)); |
||||
initialLabelForeground = label.getForeground(); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(label, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private Border getNoFocusBorder() { |
||||
return BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LIST_ITEM_SPLIT_LINE); |
||||
} |
||||
|
||||
private void setText(String t) { |
||||
label.setText(t); |
||||
} |
||||
|
||||
@Override |
||||
public Component getListCellRendererComponent(JList list, Object value, |
||||
int index, boolean isSelected, boolean cellHasFocus) { |
||||
setComponentOrientation(list.getComponentOrientation()); |
||||
|
||||
Color bg = null; |
||||
Color fg = null; |
||||
|
||||
JList.DropLocation dropLocation = list.getDropLocation(); |
||||
if (dropLocation != null |
||||
&& !dropLocation.isInsert() |
||||
&& dropLocation.getIndex() == index) { |
||||
|
||||
bg = DefaultLookup.getColor(this, ui, "List.dropCellBackground"); |
||||
fg = DefaultLookup.getColor(this, ui, "List.dropCellForeground"); |
||||
|
||||
isSelected = true; |
||||
} |
||||
|
||||
if (isSelected) { |
||||
setBackground(bg == null ? list.getSelectionBackground() : bg); |
||||
setForeground(fg == null ? list.getSelectionForeground() : fg); |
||||
label.setForeground(Color.WHITE); |
||||
} |
||||
else { |
||||
setBackground(list.getBackground()); |
||||
setForeground(list.getForeground()); |
||||
label.setForeground(initialLabelForeground); |
||||
} |
||||
|
||||
setText((value == null) ? StringUtils.EMPTY : value.toString()); |
||||
|
||||
setEnabled(list.isEnabled()); |
||||
setFont(list.getFont()); |
||||
|
||||
if (value instanceof ListModelElement) { |
||||
Nameable wrappee = ((ListModelElement) value).wrapper; |
||||
this.setText(wrappee.getName()); |
||||
} |
||||
|
||||
return this; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.fr.design.widget.mobile; |
||||
|
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
|
||||
/** |
||||
* 单元格控件的"移动端"面板。默认显示"无可用配置项",在子类中扩展 |
||||
* Created by plough on 2018/4/25. |
||||
*/ |
||||
public class WidgetMobilePane extends JPanel { |
||||
public static WidgetMobilePane DEFAULT_PANE = new WidgetMobilePane(); |
||||
|
||||
public WidgetMobilePane() { |
||||
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); |
||||
init(); |
||||
} |
||||
|
||||
protected void init() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
UILabel label = new UILabel(Inter.getLocText("FR-Designer_No_Settings_Available")); |
||||
label.setHorizontalAlignment(SwingConstants.CENTER); |
||||
this.add(label); |
||||
} |
||||
|
||||
/** |
||||
* 从 widget 中提取数据展示在属性面板中 |
||||
* |
||||
* @param widget |
||||
*/ |
||||
public void populate(Widget widget) { |
||||
// do nothing
|
||||
} |
||||
|
||||
/** |
||||
* 从属性面板把数据保存到 widget 中 |
||||
* @param widget |
||||
*/ |
||||
public void update(Widget widget) { |
||||
// do nothing
|
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XChartEditor; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.ChartEditorDefinePane; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by plough on 2018/1/18. |
||||
*/ |
||||
public class ChartEditorPropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public ChartEditorPropertyUI(XChartEditor xChartEditor) { |
||||
this.xCreator = xChartEditor; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new ChartEditorDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return Inter.getLocText("FR-Designer_Mobile-Attr"); |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XWParameterLayout; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.ParaMobileDefinePane; |
||||
import com.fr.general.Inter; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/5/16/0016. |
||||
*/ |
||||
public class ParaMobilePropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public ParaMobilePropertyUI(XWParameterLayout xwParameterLayout) { |
||||
this.xCreator = xwParameterLayout; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new ParaMobileDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return Inter.getLocText("FR-Designer_Mobile-Attr"); |
||||
} |
||||
} |
@ -0,0 +1,71 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.gui.controlpane.UISimpleListControlPane; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.general.NameObject; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.Nameable; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by plough on 2018/1/31. |
||||
*/ |
||||
public class MobileWidgetListPane extends UISimpleListControlPane { |
||||
public static final String LIST_NAME = "Widget_List"; |
||||
|
||||
private FormDesigner designer; |
||||
private WSortLayout wSortLayout; |
||||
private String[] widgetNameList; |
||||
|
||||
public MobileWidgetListPane(FormDesigner designer, WSortLayout wSortLayout) { |
||||
super(); |
||||
this.designer = designer; |
||||
this.wSortLayout = wSortLayout; |
||||
widgetNameList = getData(); |
||||
|
||||
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
||||
for (String name : widgetNameList) { |
||||
nameObjectList.add(new NameObject(name, null)); |
||||
} |
||||
populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); |
||||
} |
||||
|
||||
/** |
||||
* 保存移动端控件列表顺序 |
||||
*/ |
||||
public void updateToDesigner() { |
||||
Nameable[] nameableList = update(); |
||||
List<String> newMobileWidgetList = new ArrayList<>(); |
||||
for (Nameable nameable : nameableList) { |
||||
newMobileWidgetList.add(nameable.getName()); |
||||
} |
||||
wSortLayout.updateSortedMobileWidgetList(newMobileWidgetList); |
||||
} |
||||
|
||||
/** |
||||
* 获取选中控件的控件列表 |
||||
* |
||||
* @return List<String> widgetNameList |
||||
*/ |
||||
private String[] getData() { |
||||
//选择的控件
|
||||
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
||||
Widget selectedModel = selectedCreator != null ? selectedCreator.toData() : null; |
||||
|
||||
if (selectedModel == null || !selectedModel.acceptType(WSortLayout.class)) { |
||||
return ArrayUtils.EMPTY_STRING_ARRAY; |
||||
} |
||||
|
||||
// 选择的控件有两种类型,一种是WLayout,代表容器,一种是Widget,代表控件
|
||||
List<String> mobileWidgetList = ((WSortLayout) selectedModel).getOrderedMobileWidgetList(); |
||||
String[] widgetNames = new String[mobileWidgetList.size()]; |
||||
for (int i = 0; i < mobileWidgetList.size(); i++) { |
||||
widgetNames[i] = mobileWidgetList.get(i); |
||||
} |
||||
return widgetNames; |
||||
} |
||||
} |
@ -0,0 +1,124 @@
|
||||
package com.fr.design.widget.ui.designer.mobile; |
||||
|
||||
import com.fr.design.designer.beans.events.DesignerEvent; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.MobileWidgetListPane; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.lang.reflect.Method; |
||||
|
||||
/** |
||||
* Created by plough on 2018/2/1. |
||||
*/ |
||||
public class BodyMobileDefinePane extends MobileWidgetDefinePane { |
||||
private XCreator bodyCreator; |
||||
private FormDesigner designer; |
||||
private AttributeChangeListener changeListener; |
||||
private UICheckBox appRelayoutCheck; |
||||
private MobileWidgetListPane mobileWidgetListPane; |
||||
|
||||
public BodyMobileDefinePane(XCreator xCreator) { |
||||
this.bodyCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
this.add(getMobilePropertyPane(), BorderLayout.NORTH); |
||||
this.add(getMobileWidgetListPane(), BorderLayout.CENTER); |
||||
this.repaint(); |
||||
} |
||||
|
||||
// 手机属性
|
||||
private UIExpandablePane getMobilePropertyPane() { |
||||
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
appRelayoutCheck = new UICheckBox(Inter.getLocText("FR-Designer-App_ReLayout"), true); |
||||
appRelayoutCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
panel.add(appRelayoutCheck); |
||||
|
||||
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(panel, BorderLayout.NORTH); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_Properties_Mobile"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
// 控件顺序
|
||||
private UIExpandablePane getMobileWidgetListPane() { |
||||
mobileWidgetListPane = new MobileWidgetListPane(designer, (WSortLayout) bodyCreator.toData()); |
||||
mobileWidgetListPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0)); |
||||
JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(mobileWidgetListPane, BorderLayout.CENTER); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_WidgetOrder"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
private void bindListeners2Widgets() { |
||||
reInitAllListeners(); |
||||
this.changeListener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
update(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 后台初始化所有事件. |
||||
*/ |
||||
private void reInitAllListeners() { |
||||
initListener(this); |
||||
} |
||||
|
||||
// body是否开启手机重布局
|
||||
private boolean isAppRelayout() { |
||||
boolean result = false; |
||||
try { |
||||
Method m = bodyCreator.toData().getClass().getMethod("isAppRelayout"); |
||||
result = (boolean)m.invoke(bodyCreator.toData()); |
||||
} catch (Exception e) { |
||||
// do nothing
|
||||
} |
||||
return result; |
||||
} |
||||
|
||||
private void setAppRelayout(boolean appRelayoutSeleted) { |
||||
if (appRelayoutSeleted == isAppRelayout()) { |
||||
return; |
||||
} |
||||
try { |
||||
Method m = bodyCreator.toData().getClass().getMethod("setAppRelayout", boolean.class); |
||||
m.invoke(bodyCreator.toData(), appRelayoutSeleted); |
||||
} catch (Exception e) { |
||||
// do nothing
|
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void populate(FormDesigner designer) { |
||||
this.designer = designer; |
||||
appRelayoutCheck.setSelected(isAppRelayout()); |
||||
|
||||
// 数据 populate 完成后,再设置监听
|
||||
this.bindListeners2Widgets(); |
||||
this.addAttributeChangeListener(changeListener); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
setAppRelayout(appRelayoutCheck.isSelected()); |
||||
mobileWidgetListPane.updateToDesigner(); |
||||
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); |
||||
} |
||||
} |
@ -0,0 +1,196 @@
|
||||
package com.fr.design.widget.ui.designer.mobile; |
||||
|
||||
import com.fr.base.mobile.ChartMobileAttrProvider; |
||||
import com.fr.base.mobile.ChartMobileFitAttrState; |
||||
import com.fr.base.mobile.ChartMobileFitAttrStateProvider; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XWAbsoluteBodyLayout; |
||||
import com.fr.design.designer.creator.XWAbsoluteLayout; |
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.form.FormFunctionProcessor; |
||||
import com.fr.form.ui.BaseChartEditor; |
||||
import com.fr.form.ui.container.WFitLayout; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.ExtraClassManager; |
||||
import com.fr.stable.fun.FunctionProcessor; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Container; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* Created by plough on 2018/1/18. |
||||
*/ |
||||
public class ChartEditorDefinePane extends MobileWidgetDefinePane { |
||||
private static final Item[] ITEMS = { |
||||
new Item(ChartMobileFitAttrState.AUTO.description(), ChartMobileFitAttrState.AUTO), |
||||
new Item(ChartMobileFitAttrState.AREA.description(), ChartMobileFitAttrState.AREA), |
||||
new Item(ChartMobileFitAttrState.PROPORTION.description(), ChartMobileFitAttrState.PROPORTION) |
||||
}; |
||||
|
||||
private XCreator xCreator; // 当前选中控件的xCreator
|
||||
private FormDesigner designer; // 当前设计器
|
||||
private UIComboBox zoomOutComboBox;// 缩小逻辑下拉框
|
||||
private AttributeChangeListener changeListener; |
||||
private UILabel tipLabel; |
||||
|
||||
public ChartEditorDefinePane(XCreator xCreator) { |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
JPanel mobileSettingsPane; |
||||
if (isInAbsoluteLayout()) { |
||||
mobileSettingsPane = getUnavailableTipPane(Inter.getLocText("FR-Designer_Tip_Chart_Adaptivity_Unavailable_In_Absolute_Layout")); |
||||
} else if (!isAppRelayout()) { |
||||
mobileSettingsPane = getUnavailableTipPane(Inter.getLocText("FR-Designer_Tip_Chart_Adaptivity_Unavailable")); |
||||
} else { |
||||
mobileSettingsPane = getMobileSettingsPane(); |
||||
} |
||||
this.add(mobileSettingsPane, BorderLayout.NORTH); |
||||
this.repaint(); |
||||
} |
||||
|
||||
private boolean isInAbsoluteLayout() { |
||||
Container parent = xCreator.getParent(); |
||||
while (parent != null) { |
||||
if (parent instanceof XWAbsoluteLayout && !(parent instanceof XWAbsoluteBodyLayout)) { |
||||
return true; |
||||
} |
||||
parent = parent.getParent(); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
// body是否开启手机重布局
|
||||
private boolean isAppRelayout() { |
||||
return ((WFitLayout)designer.getRootComponent().toData()).isAppRelayout(); |
||||
} |
||||
|
||||
private JPanel getUnavailableTipPane(String tipText) { |
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
UILabel unavailableTipLabel = new UILabel(); |
||||
unavailableTipLabel.setText("<html>" + tipText + "<html>"); |
||||
unavailableTipLabel.setForeground(Color.gray); |
||||
panel.add(unavailableTipLabel, BorderLayout.NORTH); |
||||
return panel; |
||||
} |
||||
|
||||
private UIExpandablePane getMobileSettingsPane() { |
||||
initZoomOutComboBox(); |
||||
|
||||
tipLabel = new UILabel(); |
||||
tipLabel.setForeground(Color.gray); |
||||
updateTipLabel(); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[] {new UILabel(Inter.getLocText("FR-Designer_Zoom_In_Logic"), SwingConstants.LEFT), new UILabel(ChartMobileFitAttrState.PROPORTION.description())}, |
||||
new Component[] {new UILabel(Inter.getLocText("FR-Designer_Zoom_Out_Logic"), SwingConstants.LEFT), zoomOutComboBox}, |
||||
new Component[] {tipLabel, null} |
||||
}; |
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p, p}; |
||||
double[] columnSize = {p,f}; |
||||
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; |
||||
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(panel, BorderLayout.NORTH); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_Chart_Adaptivity"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
private void initZoomOutComboBox() { |
||||
this.zoomOutComboBox = new UIComboBox(ITEMS); |
||||
} |
||||
|
||||
|
||||
private void updateTipLabel() { |
||||
ChartMobileFitAttrState fitAttrState = (ChartMobileFitAttrState) ((Item)zoomOutComboBox.getSelectedItem()).getValue(); |
||||
// 使用 html,可以自动换行
|
||||
tipLabel.setText("<html>" + fitAttrState.tip() + "</html>"); |
||||
} |
||||
|
||||
private void bindListeners2Widgets() { |
||||
reInitAllListeners(); |
||||
this.changeListener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
update(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 后台初始化所有事件. |
||||
*/ |
||||
private void reInitAllListeners() { |
||||
initListener(this); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(FormDesigner designer) { |
||||
this.designer = designer; |
||||
|
||||
if (!isAppRelayout() || isInAbsoluteLayout()) { |
||||
return; |
||||
} |
||||
|
||||
BaseChartEditor chartEditor = (BaseChartEditor)xCreator.toData(); |
||||
ChartMobileFitAttrStateProvider zoomOutAttr = chartEditor.getMobileAttr().getZoomOutAttr(); |
||||
this.zoomOutComboBox.setSelectedItem(new Item(zoomOutAttr.description(), zoomOutAttr)); |
||||
updateTipLabel(); |
||||
|
||||
// 数据 populate 完成后,再设置监听
|
||||
this.bindListeners2Widgets(); |
||||
this.zoomOutComboBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
// 只响应选中事件
|
||||
if (e.getStateChange() != ItemEvent.SELECTED) { |
||||
return; |
||||
} |
||||
updateTipLabel(); |
||||
ChartMobileFitAttrState selectedAttr = (ChartMobileFitAttrState)((Item)e.getItem()).getValue(); |
||||
if (selectedAttr.getState() != ChartMobileFitAttrState.AUTO.getState()) { |
||||
// 功能埋点
|
||||
FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); |
||||
if (processor != null) { |
||||
processor.recordFunction(FormFunctionProcessor.MOBILE_CHART_ADAPTIVITY); |
||||
} |
||||
} |
||||
} |
||||
}); |
||||
this.addAttributeChangeListener(changeListener); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
ChartMobileAttrProvider mobileAttr = ((BaseChartEditor)xCreator.toData()).getMobileAttr(); |
||||
mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION); |
||||
mobileAttr.setZoomOutAttr((ChartMobileFitAttrState)((Item)zoomOutComboBox.getSelectedItem()).getValue()); |
||||
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
|
||||
} |
||||
} |
@ -0,0 +1,110 @@
|
||||
package com.fr.design.widget.ui.designer.mobile; |
||||
|
||||
import com.fr.base.mobile.FileUploadModeState; |
||||
import com.fr.base.mobile.MultiFileUploaderMobileAttr; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.form.ui.MultiFileEditor; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by plough on 2018/4/19. |
||||
*/ |
||||
public class MultiFileUploaderDefinePane extends MobileWidgetDefinePane { |
||||
private static final Item[] ITEMS = { |
||||
new Item(Inter.getLocText("FR-Designer_Take_Photos_And_Choose_From_Album"), FileUploadModeState.TAKE_PHOTOS_AND_CHOOSE_FROM_ALBUM), |
||||
new Item(Inter.getLocText("FR-Designer_Only_Take_Photos"), FileUploadModeState.ONLY_TAKE_PHOTOS) |
||||
}; |
||||
|
||||
private XCreator xCreator; // 当前选中控件的xCreator
|
||||
private UIComboBox uploadModeComboBox;// 上传方式下拉框
|
||||
|
||||
public MultiFileUploaderDefinePane(XCreator xCreator) { |
||||
this.xCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
JPanel mobileSettingsPane; |
||||
mobileSettingsPane = getMobileSettingsPane(); |
||||
|
||||
this.add(mobileSettingsPane, BorderLayout.NORTH); |
||||
this.repaint(); |
||||
} |
||||
|
||||
private UIExpandablePane getMobileSettingsPane() { |
||||
initUploadModeComboBox(); |
||||
|
||||
// 以后可能会扩展,还是用 TableLayout 吧
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[] {new UILabel(Inter.getLocText("FR-Designer_Upload_Mode"), SwingConstants.LEFT), uploadModeComboBox} |
||||
}; |
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p,f}; |
||||
int[][] rowCount = {{1, 1}}; |
||||
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(panel, BorderLayout.NORTH); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_Terminal"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
private void initUploadModeComboBox() { |
||||
this.uploadModeComboBox = new UIComboBox(ITEMS); |
||||
} |
||||
|
||||
private void bindListeners2Widgets() { |
||||
reInitAllListeners(); |
||||
AttributeChangeListener changeListener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
update(); |
||||
} |
||||
}; |
||||
this.addAttributeChangeListener(changeListener); |
||||
} |
||||
|
||||
/** |
||||
* 后台初始化所有事件. |
||||
*/ |
||||
private void reInitAllListeners() { |
||||
initListener(this); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(FormDesigner designer) { |
||||
MultiFileUploaderMobileAttr mobileAttr = ((MultiFileEditor)xCreator.toData()).getMobileAttr(); |
||||
FileUploadModeState fileUploadModeState = mobileAttr.getFileUploadModeState(); |
||||
uploadModeComboBox.setSelectedIndex(fileUploadModeState.getState()); |
||||
// 数据 populate 完成后,再设置监听
|
||||
this.bindListeners2Widgets(); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
MultiFileUploaderMobileAttr mobileAttr = ((MultiFileEditor)xCreator.toData()).getMobileAttr(); |
||||
mobileAttr.setFileUploadModeState((FileUploadModeState) ((Item)uploadModeComboBox.getSelectedItem()).getValue()); |
||||
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
|
||||
} |
||||
} |
@ -0,0 +1,81 @@
|
||||
package com.fr.design.widget.ui.designer.mobile; |
||||
|
||||
import com.fr.design.designer.beans.events.DesignerEvent; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.frpane.AttributeChangeListener; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.MobileWidgetListPane; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.form.ui.container.WSortLayout; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
|
||||
/** |
||||
* Created by plough on 2018/2/5. |
||||
*/ |
||||
public class ParaMobileDefinePane extends MobileWidgetDefinePane { |
||||
private XCreator paraCreator; |
||||
private FormDesigner designer; |
||||
private AttributeChangeListener changeListener; |
||||
private MobileWidgetListPane mobileWidgetListPane; |
||||
|
||||
public ParaMobileDefinePane(XCreator xCreator) { |
||||
this.paraCreator = xCreator; |
||||
} |
||||
|
||||
@Override |
||||
public void initPropertyGroups(Object source) { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
this.add(getMobileWidgetListPane(), BorderLayout.CENTER); |
||||
this.repaint(); |
||||
} |
||||
|
||||
// 控件顺序
|
||||
private UIExpandablePane getMobileWidgetListPane() { |
||||
mobileWidgetListPane = new MobileWidgetListPane(designer, (WSortLayout) paraCreator.toData()); |
||||
mobileWidgetListPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0)); |
||||
JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(mobileWidgetListPane, BorderLayout.CENTER); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_WidgetOrder"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
private void bindListeners2Widgets() { |
||||
reInitAllListeners(); |
||||
this.changeListener = new AttributeChangeListener() { |
||||
@Override |
||||
public void attributeChange() { |
||||
update(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 后台初始化所有事件. |
||||
*/ |
||||
private void reInitAllListeners() { |
||||
initListener(this); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void populate(FormDesigner designer) { |
||||
this.designer = designer; |
||||
|
||||
// 设置监听
|
||||
this.bindListeners2Widgets(); |
||||
this.addAttributeChangeListener(changeListener); |
||||
} |
||||
|
||||
@Override |
||||
public void update() { |
||||
mobileWidgetListPane.updateToDesigner(); |
||||
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.widget; |
||||
|
||||
import com.fr.base.FRContext; |
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.widget.mobile.WidgetMobilePane; |
||||
import com.fr.design.widget.ui.mobile.MultiFileEditorMobilePane; |
||||
import com.fr.form.ui.MultiFileEditor; |
||||
import com.fr.form.ui.Widget; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by plough on 2018/4/25. |
||||
*/ |
||||
public class WidgetMobilePaneFactory { |
||||
private static Map<Class<? extends Widget>, Class<? extends WidgetMobilePane>> mobilePaneMap = new HashMap<>(); |
||||
|
||||
static { |
||||
mobilePaneMap.put(MultiFileEditor.class, MultiFileEditorMobilePane.class); |
||||
mobilePaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); |
||||
} |
||||
|
||||
private WidgetMobilePaneFactory() { |
||||
} |
||||
|
||||
public static WidgetMobilePane createWidgetMobilePane(Widget widget) { |
||||
WidgetMobilePane mobilePane = WidgetMobilePane.DEFAULT_PANE; |
||||
try { |
||||
if (mobilePaneMap.containsKey(widget.getClass())) { |
||||
mobilePane = mobilePaneMap.get(widget.getClass()).newInstance(); |
||||
mobilePane.populate(widget); |
||||
} |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return mobilePane; |
||||
} |
||||
} |
@ -0,0 +1,84 @@
|
||||
package com.fr.design.widget.ui.mobile; |
||||
|
||||
import com.fr.base.mobile.FileUploadModeState; |
||||
import com.fr.base.mobile.MultiFileUploaderMobileAttr; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.design.foldablepane.UIExpandablePane; |
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.widget.mobile.WidgetMobilePane; |
||||
import com.fr.form.ui.MultiFileEditor; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.Inter; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* Created by plough on 2018/4/25. |
||||
*/ |
||||
public class MultiFileEditorMobilePane extends WidgetMobilePane { |
||||
private static final Item[] ITEMS = { |
||||
new Item(Inter.getLocText("FR-Designer_Take_Photos_And_Choose_From_Album"), FileUploadModeState.TAKE_PHOTOS_AND_CHOOSE_FROM_ALBUM), |
||||
new Item(Inter.getLocText("FR-Designer_Only_Take_Photos"), FileUploadModeState.ONLY_TAKE_PHOTOS) |
||||
}; |
||||
|
||||
private UIComboBox uploadModeComboBox;// 上传方式下拉框
|
||||
|
||||
protected void init() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
this.add(getMobileSettingsPane(), BorderLayout.NORTH); |
||||
} |
||||
|
||||
/** |
||||
* 从 widget 中提取数据展示在属性面板中 |
||||
* |
||||
* @param widget |
||||
*/ |
||||
public void populate(Widget widget) { |
||||
MultiFileUploaderMobileAttr mobileAttr = ((MultiFileEditor)widget).getMobileAttr(); |
||||
FileUploadModeState fileUploadModeState = mobileAttr.getFileUploadModeState(); |
||||
uploadModeComboBox.setSelectedIndex(fileUploadModeState.getState()); |
||||
} |
||||
|
||||
/** |
||||
* 从属性面板把数据保存到 widget 中 |
||||
* @param widget |
||||
*/ |
||||
public void update(Widget widget) { |
||||
MultiFileUploaderMobileAttr mobileAttr = ((MultiFileEditor)widget).getMobileAttr(); |
||||
mobileAttr.setFileUploadModeState((FileUploadModeState) ((Item)uploadModeComboBox.getSelectedItem()).getValue()); |
||||
} |
||||
|
||||
private UIExpandablePane getMobileSettingsPane() { |
||||
initUploadModeComboBox(); |
||||
|
||||
// 以后可能会扩展
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[] {new UILabel(Inter.getLocText("FR-Designer_Upload_Mode"), SwingConstants.LEFT), uploadModeComboBox} |
||||
}; |
||||
|
||||
double f = TableLayout.FILL; |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p,f}; |
||||
int[][] rowCount = {{1, 1}}; |
||||
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 30, LayoutConstants.VGAP_LARGE); |
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); |
||||
final JPanel panelWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||
panelWrapper.add(panel, BorderLayout.NORTH); |
||||
|
||||
return new UIExpandablePane(Inter.getLocText("FR-Designer_Terminal"), 280, 20, panelWrapper); |
||||
} |
||||
|
||||
private void initUploadModeComboBox() { |
||||
this.uploadModeComboBox = new UIComboBox(ITEMS); |
||||
} |
||||
} |
Loading…
Reference in new issue