|
|
|
@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer.component;
|
|
|
|
|
|
|
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
|
import com.fr.design.editor.editor.*; |
|
|
|
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
|
|
|
|
import com.fr.design.gui.ibutton.UIHeadGroup; |
|
|
|
|
import com.fr.design.mainframe.widget.editors.DataBindingEditor; |
|
|
|
|
import com.fr.design.mainframe.widget.editors.DataTableEditor; |
|
|
|
@ -19,45 +20,47 @@ import java.awt.*;
|
|
|
|
|
* Created by ibm on 2017/7/27. |
|
|
|
|
*/ |
|
|
|
|
public class FormWidgetValuePane extends JPanel { |
|
|
|
|
private UIHeadGroup widgetValueHead; |
|
|
|
|
private UIButtonGroup widgetValueHead; |
|
|
|
|
private Editor[] editor; |
|
|
|
|
private JPanel customPane; |
|
|
|
|
private CardLayout cardLayout; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public FormWidgetValuePane(Object o, boolean onlyServer) { |
|
|
|
|
DataControl widget = (DataControl) o; |
|
|
|
|
editor = createWidgetValueEditor(widget, onlyServer); |
|
|
|
|
this.setLayout(new BorderLayout(0, LayoutConstants.VGAP_SMALL)); |
|
|
|
|
final CardLayout cardLayout = new CardLayout(); |
|
|
|
|
final JPanel customPane = new JPanel(cardLayout); |
|
|
|
|
cardLayout = new CardLayout(); |
|
|
|
|
customPane = new JPanel(cardLayout); |
|
|
|
|
final String[] tabTitles = new String[editor.length]; |
|
|
|
|
for (int i = 0; i < editor.length; i++) { |
|
|
|
|
customPane.add(editor[i], editor[i].getName()); |
|
|
|
|
tabTitles[i] = editor[i].getName(); |
|
|
|
|
} |
|
|
|
|
widgetValueHead = new UIHeadGroup(tabTitles) { |
|
|
|
|
@Override |
|
|
|
|
public void tabChanged(int index) { |
|
|
|
|
//todo
|
|
|
|
|
attributeChange(index, customPane, cardLayout, tabTitles); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
widgetValueHead = new UIButtonGroup(tabTitles); |
|
|
|
|
this.add(widgetValueHead, BorderLayout.NORTH); |
|
|
|
|
this.add(customPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void attributeChange(int index, JPanel customPane, CardLayout cardLayout, String[] tabTitles){ |
|
|
|
|
if (ComparatorUtils.equals(tabTitles[index], Inter.getLocText("FR-Designer_Widget_Field"))) { |
|
|
|
|
public void attributeChange() { |
|
|
|
|
int index = widgetValueHead.getSelectedIndex(); |
|
|
|
|
if (index == -1) { |
|
|
|
|
index = 0; |
|
|
|
|
widgetValueHead.setSelectedIndex(index); |
|
|
|
|
} |
|
|
|
|
if (ComparatorUtils.equals(editor[index].getName(), Inter.getLocText("FR-Designer_Widget_Field"))) { |
|
|
|
|
customPane.setPreferredSize(new Dimension(100, 47)); |
|
|
|
|
} else { |
|
|
|
|
customPane.setPreferredSize(new Dimension(100, 20)); |
|
|
|
|
} |
|
|
|
|
cardLayout.show(customPane, tabTitles[index]); |
|
|
|
|
cardLayout.show(customPane, editor[index].getName()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据类型创建 |
|
|
|
|
* |
|
|
|
|
* @param type 类型 |
|
|
|
|
* @param onlyServer 是否是服务器 |
|
|
|
|
* @return 编辑器 |
|
|
|
@ -86,6 +89,7 @@ public class FormWidgetValuePane extends JPanel {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用DataControl构建 |
|
|
|
|
* |
|
|
|
|
* @param data 数据 |
|
|
|
|
* @param onlyServer 是否是服务器 |
|
|
|
|
* @return 编辑器 |
|
|
|
@ -101,6 +105,7 @@ public class FormWidgetValuePane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update(DataControl ob) { |
|
|
|
|
attributeChange(); |
|
|
|
|
int index = widgetValueHead.getSelectedIndex(); |
|
|
|
|
Editor e = editor[index]; |
|
|
|
|
Object value = e.getValue(); |
|
|
|
@ -109,9 +114,7 @@ public class FormWidgetValuePane extends JPanel {
|
|
|
|
|
|
|
|
|
|
public void populate(DataControl ob) { |
|
|
|
|
WidgetValue widgetValue = ob.getWidgetValue(); |
|
|
|
|
if(widgetValue == null){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (widgetValue != null) { |
|
|
|
|
for (int i = 0; i < editor.length; i++) { |
|
|
|
|
if (editor[i].accept(widgetValue.getValue())) { |
|
|
|
|
setCardValue(i, widgetValue.getValue()); |
|
|
|
@ -119,6 +122,8 @@ public class FormWidgetValuePane extends JPanel {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
attributeChange(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setCardValue(int i, Object object) { |
|
|
|
|
widgetValueHead.setSelectedIndex(i); |
|
|
|
|