Browse Source

将UIHeadGroup换成用UIButtonGroup

master
kerry 7 years ago
parent
commit
331d8a8b52
  1. 14
      designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java
  2. 31
      designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java
  3. 2
      designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java
  4. 23
      designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java
  5. 23
      designer_form/src/com/fr/design/widget/ui/designer/ComboCheckBoxDefinePane.java
  6. 9
      designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java
  7. 59
      designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java
  8. 2
      designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java

14
designer/src/com/fr/design/widget/ui/CheckBoxDictPane.java

@ -1,14 +1,11 @@
package com.fr.design.widget.ui;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JPanel;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.DictionaryComboBox;
import com.fr.design.gui.icombobox.DictionaryConstants;
import com.fr.design.layout.FRGUIPaneFactory;
@ -20,7 +17,7 @@ import com.fr.general.Inter;
public class CheckBoxDictPane extends JPanel {
private DictionaryComboBox delimiterComboBox;
private UIHeadGroup returnTypeComboBox;
private UIButtonGroup returnTypeComboBox;
private DictionaryComboBox startComboBox;
private DictionaryComboBox endComboBox;
@ -46,12 +43,7 @@ public class CheckBoxDictPane extends JPanel {
endPane.add(new UILabel(Inter.getLocText("ComboCheckBox-End_Symbol") + ":"), BorderLayout.WEST);
endPane.add(endComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays), BorderLayout.CENTER);
endComboBox.setEditable(true);
returnTypeComboBox = new UIHeadGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}){
protected void tabChanged(int newSelectedIndex) {
// checkVisible(newSelectedIndex);
//todo
}
};
returnTypeComboBox = new UIButtonGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")});
returnTypePane.add(returnTypeComboBox, BorderLayout.CENTER);
JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("Widget-Date_Selector_Return_Type") + ":"), returnTypePane}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7);
this.add(jPanel);

31
designer_base/src/com/fr/design/widget/component/BackgroundCompPane.java

@ -1,14 +1,13 @@
package com.fr.design.widget.component;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.ibutton.UIButtonGroup;
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.widget.accessibles.AccessibleBackgroundEditor;
import com.fr.form.ui.Widget;
import com.fr.general.Background;
import com.fr.general.Inter;
import javax.swing.*;
@ -18,11 +17,11 @@ import java.awt.*;
* Created by ibm on 2017/8/6.
*/
public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
protected UIHeadGroup backgroundHead;
protected UIButtonGroup backgroundHead;
protected AccessibleBackgroundEditor initalBackgroundEditor;
protected AccessibleBackgroundEditor overBackgroundEditor;
protected AccessibleBackgroundEditor clickBackgroundEditor;
private JPanel panel;
public BackgroundCompPane() {
initComponent();
@ -45,27 +44,23 @@ public abstract class BackgroundCompPane<T extends Widget> extends BasicPane {
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Over")), overBackgroundEditor},
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Click")), clickBackgroundEditor},
};
final JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 7, 7);
panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 7, 7);
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
backgroundHead = new UIHeadGroup(titles){
@Override
public void tabChanged(int index) {
//todo
if (index == 1) {
panel.setVisible(true);
}else{
panel.setVisible(false);
}
}
};
backgroundHead = new UIButtonGroup(titles);
this.add(backgroundHead, BorderLayout.NORTH);
this.add(panel, BorderLayout.CENTER);
}
public abstract void update(T e);
public void update(T e){
}
public void populate(T e){
}
public abstract void populate(T e);
public void switchCard(){
panel.setVisible(backgroundHead.getSelectedIndex() == 1);
}
}

2
designer_base/src/com/fr/design/widget/component/ButtonBackgroundPane.java

@ -25,6 +25,7 @@ public class ButtonBackgroundPane extends BackgroundCompPane<FreeButton> {
freeButton.setOverBackground((Background) overBackgroundEditor.getValue());
freeButton.setClickBackground((Background)clickBackgroundEditor.getValue());
}
switchCard();
}
public void populate(FreeButton freeButton){
@ -39,6 +40,7 @@ public class ButtonBackgroundPane extends BackgroundCompPane<FreeButton> {
overBackgroundEditor.setValue(freeButton.getOverBackground());
clickBackgroundEditor.setValue(freeButton.getClickBackground());
}
switchCard();
}
protected String title4PopupWindow() {

23
designer_form/src/com/fr/design/widget/ui/designer/CheckBoxGroupDefinePane.java

@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -17,7 +18,7 @@ import java.awt.*;
public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane<CheckBoxGroup> {
private DictionaryPane dictPane;
private UIHeadGroup returnType;
private UIButtonGroup returnType;
private UICheckBox checkbox;
public CheckBoxGroupDefinePane(XCreator xCreator) {
@ -42,18 +43,7 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane<CheckBoxGroup
checkbox = new UICheckBox(Inter.getLocText(new String[]{"Provide", "Choose_All"}));
checkbox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
final String[] tabTitles = new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")};
returnType = new UIHeadGroup(tabTitles) {
@Override
public void tabChanged(int index) {
CheckBoxGroup combo = (CheckBoxGroup) creator.toData();
//todo
if (index == 1) {
combo.setReturnString(true);
} else {
combo.setReturnString(false);
}
}
};
returnType = new UIButtonGroup(tabTitles);
double f = TableLayout.FILL;
@ -72,11 +62,7 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane<CheckBoxGroup
@Override
protected void populateSubButtonGroupBean(CheckBoxGroup ob) {
if (ob.isReturnString()) {
returnType.setSelectedIndex(1);
} else {
returnType.setSelectedIndex(0);
}
returnType.setSelectedIndex(ob.isReturnString() ? 1 : 0);
this.dictPane.populateBean(ob.getDictionary());
checkbox.setSelected(ob.isChooseAll());
}
@ -86,6 +72,7 @@ public class CheckBoxGroupDefinePane extends ButtonGroupDefinePane<CheckBoxGroup
@Override
protected CheckBoxGroup updateSubButtonGroupBean() {
CheckBoxGroup ob = (CheckBoxGroup) creator.toData();
ob.setReturnString(returnType.getSelectedIndex() == 1);
ob.setDictionary(this.dictPane.updateBean());
ob.setChooseAll(checkbox.isSelected());
return ob;

23
designer_form/src/com/fr/design/widget/ui/designer/ComboCheckBoxDefinePane.java

@ -2,6 +2,7 @@ package com.fr.design.widget.ui.designer;
import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -16,7 +17,7 @@ import java.awt.*;
public class ComboCheckBoxDefinePane extends DictEditorDefinePane<ComboCheckBox> {
private UICheckBox supportTagCheckBox;
private UIHeadGroup returnType;
private UIButtonGroup returnType;
private UITextField waterMarkDictPane;
private UICheckBox removeRepeatCheckBox;
@ -40,18 +41,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane<ComboCheckBox>
supportTagCheckBox = new UICheckBox(Inter.getLocText("Form-SupportTag"), true);
final String[] tabTitles = new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")};
returnType = new UIHeadGroup(tabTitles) {
@Override
public void tabChanged(int index) {
ComboCheckBox combo = (ComboCheckBox) creator.toData();
//todo
if (index == 1) {
combo.setReturnString(true);
} else {
combo.setReturnString(false);
}
}
};
returnType = new UIButtonGroup(tabTitles) ;
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
@ -68,11 +58,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane<ComboCheckBox>
}
protected void populateSubDictionaryEditorBean(ComboCheckBox ob){
if (ob.isReturnString()) {
returnType.setSelectedIndex(1);
} else {
returnType.setSelectedIndex(0);
}
returnType.setSelectedIndex(ob.isReturnString() ? 1 : 0);
waterMarkDictPane.setText(ob.getWaterMark());
formWidgetValuePane.populate(ob);
this.supportTagCheckBox.setSelected(ob.isSupportTag());
@ -81,6 +67,7 @@ public class ComboCheckBoxDefinePane extends DictEditorDefinePane<ComboCheckBox>
protected ComboCheckBox updateSubDictionaryEditorBean(){
ComboCheckBox combo = (ComboCheckBox) creator.toData();
combo.setReturnString(returnType.getSelectedIndex() == 1);
formWidgetValuePane.update(combo);
combo.setWaterMark(waterMarkDictPane.getText());
combo.setSupportTag(this.supportTagCheckBox.isSelected());

9
designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java

@ -4,6 +4,7 @@ import com.fr.base.FRContext;
import com.fr.base.Formula;
import com.fr.data.core.FormatField;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
@ -28,7 +29,7 @@ import java.text.SimpleDateFormat;
import java.util.Date;
public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor> {
private UIHeadGroup returnTypeComboBox;
private UIButtonGroup returnTypeComboBox;
private DateValuePane startDv;
private DateValuePane endDv;
private WaterMarkDictPane waterMarkDictPane;
@ -55,11 +56,7 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
fontSizePane = new UISpinner(0, 20, 1, 0);
JPanel returnTypePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
returnTypePane.add(new UILabel(Inter.getLocText("Widget-Date_Selector_Return_Type") + ":"), BorderLayout.WEST);
returnTypeComboBox = new UIHeadGroup(new String[] {Inter.getLocText("Date") , Inter.getLocText("String")}){
protected void tabChanged(int newSelectedIndex) {
//todo
}
};
returnTypeComboBox = new UIButtonGroup<>(new String[] {Inter.getLocText("Date") , Inter.getLocText("String")});
JPanel formatHead = createFormatHead();
startDv = new DateValuePane();

59
designer_form/src/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java

@ -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,46 +20,48 @@ 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);
final String [] tabTitles = new String[editor.length];
for(int i = 0; i < editor.length; i++){
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 type 类型
* @param onlyServer 是否是服务器
* @return 编辑器
*/
@ -73,7 +76,7 @@ public class FormWidgetValuePane extends JPanel {
case DataControl.TYPE_STRING:
return new com.fr.design.editor.editor.TextEditor();
case DataControl.TYPE_BOOLEAN:
return new BooleanEditor(false);
return new BooleanEditor(false);
case DataControl.TYPE_DATE:
return new DateEditor(true, Inter.getLocText("Date"));
case DataControl.TYPE_TABLEDATA:
@ -86,13 +89,14 @@ public class FormWidgetValuePane extends JPanel {
/**
* 用DataControl构建
* @param data 数据
*
* @param data 数据
* @param onlyServer 是否是服务器
* @return 编辑器
*/
public static Editor[] createWidgetValueEditor(DataControl data, boolean onlyServer) {
int types[] = data.getValueType();
Editor[] editor = new Editor[types.length ];
Editor[] editor = new Editor[types.length];
for (int i = 0; i < types.length; i++) {
editor[i] = createWidgetValueEditorByType(types[i], onlyServer);
@ -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,18 +114,18 @@ public class FormWidgetValuePane extends JPanel {
public void populate(DataControl ob) {
WidgetValue widgetValue = ob.getWidgetValue();
if(widgetValue == null){
return;
}
for (int i = 0; i < editor.length; i++) {
if (editor[i].accept(widgetValue.getValue())) {
setCardValue(i, widgetValue.getValue());
break;
if (widgetValue != null) {
for (int i = 0; i < editor.length; i++) {
if (editor[i].accept(widgetValue.getValue())) {
setCardValue(i, widgetValue.getValue());
break;
}
}
}
attributeChange();
}
private void setCardValue(int i, Object object){
private void setCardValue(int i, Object object) {
widgetValueHead.setSelectedIndex(i);
editor[i].setValue(object);
// kunsnat: bug7861 所有的Editor值都要跟随改变, 因为populate的editor 从""

2
designer_form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java

@ -26,6 +26,7 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane<WTabFitLayout
wTabFitLayout.setOverBackground((Background) overBackgroundEditor.getValue());
wTabFitLayout.setClickBackground((Background)clickBackgroundEditor.getValue());
}
switchCard();
}
public void populate(WTabFitLayout wTabFitLayout){
@ -40,6 +41,7 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane<WTabFitLayout
overBackgroundEditor.setValue(wTabFitLayout.getOverBackground());
clickBackgroundEditor.setValue(wTabFitLayout.getClickBackground());
}
switchCard();
}
protected String title4PopupWindow() {

Loading…
Cancel
Save