Browse Source
* commit 'fb9a9fb59c2cd62381a3813201614fa1ba6ed450': 修改间距 代码修改 REPORT-3958&&REPORT-4373&&REPORT-4377&&REPORT-4372&&REPORT-4398&&REPORT-4393&&REPORT-4028&&REPORT-4192 修改PMD 注释修改 REPORT-4393 && REPORT-4028 && REPORT-4192 参数面板日期控件控件值联动失效 控件名无法修改 标签控件不自动换行设置无效master
superman
7 years ago
44 changed files with 1061 additions and 1054 deletions
@ -0,0 +1,22 @@ |
|||||||
|
package com.fr.design.designer; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/9/8. |
||||||
|
*/ |
||||||
|
public class IntervalConstants { |
||||||
|
|
||||||
|
public static final int INTERVAL_L1 = 10; |
||||||
|
|
||||||
|
public static final int INTERVAL_L2 = 15; |
||||||
|
|
||||||
|
public static final int INTERVAL_L3 = 155; |
||||||
|
|
||||||
|
public static final int INTERVAL_L4 = 10; |
||||||
|
|
||||||
|
public static final int INTERVAL_L5 = 12; |
||||||
|
|
||||||
|
public static final int INTERVAL_L6 = 5; |
||||||
|
|
||||||
|
public static final int INTERVAL_L7 = 8; |
||||||
|
|
||||||
|
} |
@ -1,35 +1,35 @@ |
|||||||
package com.fr.design.mainframe.widget.accessibles; |
package com.fr.design.mainframe.widget.accessibles; |
||||||
|
|
||||||
import java.awt.Dimension; |
import java.awt.Dimension; |
||||||
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
||||||
import com.fr.base.background.ColorBackground; |
import com.fr.base.background.ColorBackground; |
||||||
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; |
import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; |
||||||
import com.fr.design.dialog.BasicDialog; |
import com.fr.design.dialog.BasicDialog; |
||||||
import com.fr.design.dialog.DialogActionAdapter; |
import com.fr.design.dialog.DialogActionAdapter; |
||||||
import com.fr.design.style.background.BackgroundButtonPane; |
import com.fr.design.style.background.BackgroundButtonPane; |
||||||
import com.fr.general.Background; |
import com.fr.general.Background; |
||||||
|
|
||||||
public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { |
public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { |
||||||
private BackgroundButtonPane choosePane; |
private BackgroundButtonPane choosePane; |
||||||
|
|
||||||
public AccessibleImgBackgroundEditor() { |
public AccessibleImgBackgroundEditor() { |
||||||
super(new BackgroundWrapper()); |
super(new BackgroundWrapper()); |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
protected void showEditorPane() { |
protected void showEditorPane() { |
||||||
choosePane = new BackgroundButtonPane(); |
choosePane = new BackgroundButtonPane(); |
||||||
choosePane.setPreferredSize(new Dimension(600, 400)); |
choosePane.setPreferredSize(new Dimension(600, 400)); |
||||||
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||||
dlg.addDialogActionListener(new DialogActionAdapter() { |
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void doOk() { |
public void doOk() { |
||||||
setValue(choosePane.update()); |
setValue(choosePane.update()); |
||||||
fireStateChanged(); |
fireStateChanged(); |
||||||
} |
} |
||||||
}); |
}); |
||||||
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); |
choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); |
||||||
dlg.setVisible(true); |
dlg.setVisible(true); |
||||||
} |
} |
||||||
} |
} |
@ -1,84 +1,87 @@ |
|||||||
package com.fr.design.widget.ui; |
package com.fr.design.widget.component; |
||||||
|
|
||||||
import java.awt.*; |
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
import java.awt.event.ActionListener; |
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import javax.swing.JPanel; |
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.gui.icombobox.DictionaryConstants; |
import javax.swing.JPanel; |
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.design.layout.TableLayoutHelper; |
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||||
import com.fr.form.ui.CheckBoxGroup; |
import com.fr.design.gui.icombobox.DictionaryConstants; |
||||||
import com.fr.form.ui.ComboCheckBox; |
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
import com.fr.general.Inter; |
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.form.ui.CheckBoxGroup; |
||||||
public class CheckBoxDictPane extends JPanel { |
import com.fr.form.ui.ComboCheckBox; |
||||||
|
import com.fr.general.Inter; |
||||||
private DictionaryComboBox delimiterComboBox; |
|
||||||
private UIButtonGroup returnTypeComboBox; |
public class CheckBoxDictPane extends JPanel { |
||||||
private DictionaryComboBox startComboBox; |
|
||||||
private DictionaryComboBox endComboBox; |
private DictionaryComboBox delimiterComboBox; |
||||||
|
private UIButtonGroup returnTypeComboBox; |
||||||
private JPanel delimiterPane; |
private DictionaryComboBox startComboBox; |
||||||
private JPanel startPane; |
private DictionaryComboBox endComboBox; |
||||||
private JPanel endPane; |
private JPanel returnStringPane; |
||||||
|
|
||||||
public CheckBoxDictPane() { |
public CheckBoxDictPane() { |
||||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
JPanel returnTypePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
delimiterComboBox = new DictionaryComboBox(DictionaryConstants.delimiters, DictionaryConstants.delimiterDisplays); |
||||||
delimiterPane =FRGUIPaneFactory.createBorderLayout_S_Pane(); |
delimiterComboBox.setEditable(true); |
||||||
UILabel label = new UILabel(Inter.getLocText("Form-Delimiter") + ":"); |
startComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays); |
||||||
delimiterPane.add(label, BorderLayout.WEST); |
startComboBox.setEditable(true); |
||||||
delimiterPane.add(delimiterComboBox = new DictionaryComboBox(DictionaryConstants.delimiters, DictionaryConstants.delimiterDisplays), BorderLayout.CENTER); |
endComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays); |
||||||
delimiterComboBox.setEditable(true); |
endComboBox.setEditable(true); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
startPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
new Component[]{new UILabel(Inter.getLocText("Form-Delimiter") + ":"), delimiterComboBox}, |
||||||
startPane.add(new UILabel(Inter.getLocText("ComboCheckBox-Start_Symbol") + ":"), BorderLayout.WEST); |
new Component[]{new UILabel(Inter.getLocText("ComboCheckBox-Start_Symbol") + ":"),startComboBox}, |
||||||
startPane.add(startComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays), BorderLayout.CENTER); |
new Component[]{new UILabel(Inter.getLocText("ComboCheckBox-End_Symbol") + ":"),endComboBox} |
||||||
startComboBox.setEditable(true); |
}; |
||||||
|
returnStringPane = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1); |
||||||
endPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
endPane.add(new UILabel(Inter.getLocText("ComboCheckBox-End_Symbol") + ":"), BorderLayout.WEST); |
returnTypeComboBox = new UIButtonGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}); |
||||||
endPane.add(endComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays), BorderLayout.CENTER); |
returnTypeComboBox.addActionListener(new ActionListener() { |
||||||
endComboBox.setEditable(true); |
@Override |
||||||
returnTypeComboBox = new UIButtonGroup(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}); |
public void actionPerformed(ActionEvent e) { |
||||||
returnTypePane.add(returnTypeComboBox, BorderLayout.CENTER); |
checkVisible(returnTypeComboBox.getSelectedIndex()); |
||||||
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); |
}); |
||||||
} |
JPanel headPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("Widget-Date_Selector_Return_Type") + ":"), returnTypeComboBox}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
||||||
|
JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
private void checkVisible(int selectIndex){ |
jPanel.add(headPane, BorderLayout.NORTH); |
||||||
delimiterPane.setVisible(selectIndex == 1); |
jPanel.add(returnStringPane, BorderLayout.CENTER); |
||||||
startPane.setVisible(selectIndex == 1); |
this.add(jPanel); |
||||||
endPane.setVisible(selectIndex == 1); |
} |
||||||
} |
|
||||||
|
public void checkVisible(int selectIndex){ |
||||||
public void populate(ComboCheckBox comboCheckBox) { |
returnStringPane.setVisible(selectIndex == 1); |
||||||
this.delimiterComboBox.setSelectedItem(comboCheckBox.getDelimiter()); |
} |
||||||
this.returnTypeComboBox.setSelectedIndex(comboCheckBox.isReturnString() ? 1 : 0); |
|
||||||
this.startComboBox.setSelectedItem(comboCheckBox.getStartSymbol()); |
public void populate(ComboCheckBox comboCheckBox) { |
||||||
this.endComboBox.setSelectedItem(comboCheckBox.getEndSymbol()); |
this.delimiterComboBox.setSelectedItem(comboCheckBox.getDelimiter()); |
||||||
checkVisible(this.returnTypeComboBox.getSelectedIndex()); |
this.returnTypeComboBox.setSelectedIndex(comboCheckBox.isReturnString() ? 1 : 0); |
||||||
} |
this.startComboBox.setSelectedItem(comboCheckBox.getStartSymbol()); |
||||||
public void update(ComboCheckBox comboCheckBox) { |
this.endComboBox.setSelectedItem(comboCheckBox.getEndSymbol()); |
||||||
comboCheckBox.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
checkVisible(this.returnTypeComboBox.getSelectedIndex()); |
||||||
comboCheckBox.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
} |
||||||
comboCheckBox.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
public void update(ComboCheckBox comboCheckBox) { |
||||||
comboCheckBox.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
comboCheckBox.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
||||||
} |
comboCheckBox.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
||||||
public void populate(CheckBoxGroup checkBoxGroup) { |
comboCheckBox.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
||||||
this.delimiterComboBox.setSelectedItem(checkBoxGroup.getDelimiter()); |
comboCheckBox.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
||||||
this.returnTypeComboBox.setSelectedIndex(checkBoxGroup.isReturnString() ? 1 : 0); |
} |
||||||
this.startComboBox.setSelectedItem(checkBoxGroup.getStartSymbol()); |
public void populate(CheckBoxGroup checkBoxGroup) { |
||||||
this.endComboBox.setSelectedItem(checkBoxGroup.getEndSymbol()); |
this.delimiterComboBox.setSelectedItem(checkBoxGroup.getDelimiter()); |
||||||
checkVisible(this.returnTypeComboBox.getSelectedIndex()); |
this.returnTypeComboBox.setSelectedIndex(checkBoxGroup.isReturnString() ? 1 : 0); |
||||||
} |
this.startComboBox.setSelectedItem(checkBoxGroup.getStartSymbol()); |
||||||
public void update(CheckBoxGroup checkBoxGroup) { |
this.endComboBox.setSelectedItem(checkBoxGroup.getEndSymbol()); |
||||||
checkBoxGroup.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
checkVisible(this.returnTypeComboBox.getSelectedIndex()); |
||||||
checkBoxGroup.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
} |
||||||
checkBoxGroup.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
public void update(CheckBoxGroup checkBoxGroup) { |
||||||
checkBoxGroup.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
checkBoxGroup.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
||||||
} |
checkBoxGroup.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
||||||
|
checkBoxGroup.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
||||||
|
checkBoxGroup.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
||||||
|
} |
||||||
} |
} |
@ -0,0 +1,303 @@ |
|||||||
|
package com.fr.design.widget.component; |
||||||
|
|
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.ispinner.UIBasicSpinner; |
||||||
|
import com.fr.design.gui.ispinner.UISpinner; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayout; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.form.ui.NumberEditor; |
||||||
|
import com.fr.general.Inter; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import javax.swing.event.ChangeEvent; |
||||||
|
import javax.swing.event.ChangeListener; |
||||||
|
import javax.swing.text.DefaultFormatter; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/9/10. |
||||||
|
*/ |
||||||
|
public class NumberEditorValidatePane extends JPanel { |
||||||
|
private UICheckBox allowDecimalsCheckBox; |
||||||
|
private UICheckBox allowNegativeCheckBox; |
||||||
|
private UICheckBox setMaxValueCheckBox; |
||||||
|
private UICheckBox setMinValueCheckBox; |
||||||
|
private UIBasicSpinner maxValueSpinner; |
||||||
|
private SpinnerNumberModel maxValueModel; |
||||||
|
private UIBasicSpinner minValueSpinner; |
||||||
|
private SpinnerNumberModel minValueModel; |
||||||
|
private UISpinner decimalLength; |
||||||
|
private JPanel limitNumberPane; |
||||||
|
private UITextField maxValueErrorTextField; |
||||||
|
private UITextField minValueErrorTextField; |
||||||
|
private JPanel maxValueFieldPane; |
||||||
|
private JPanel minValueFieldPane; |
||||||
|
|
||||||
|
private ActionListener allowDecimalsListener; |
||||||
|
|
||||||
|
private ActionListener allowNegativeListener; |
||||||
|
|
||||||
|
public ActionListener setMaxListener; |
||||||
|
|
||||||
|
private ActionListener setMinListener; |
||||||
|
|
||||||
|
private ChangeListener maxValueChangeListener; |
||||||
|
|
||||||
|
private ChangeListener minValueChangeListener; |
||||||
|
|
||||||
|
public NumberEditorValidatePane() { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
initListeners(); |
||||||
|
this.allowDecimalsCheckBox = new UICheckBox(Inter.getLocText("Allow_Decimals")); |
||||||
|
allowDecimalsCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
this.allowDecimalsCheckBox.addActionListener(allowDecimalsListener); |
||||||
|
this.decimalLength = new UISpinner(0, Integer.MAX_VALUE, 1, 16); |
||||||
|
this.allowNegativeCheckBox = new UICheckBox(Inter.getLocText("Allow_Negative")); |
||||||
|
this.allowNegativeCheckBox.addActionListener(allowNegativeListener); |
||||||
|
allowNegativeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
this.setMaxValueCheckBox = new UICheckBox(Inter.getLocText("Need_Max_Value"), false); |
||||||
|
setMaxValueCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
this.maxValueSpinner = new UIBasicSpinner(maxValueModel = new SpinnerNumberModel(0D, -Double.MAX_VALUE, Double.MAX_VALUE, 1D)); |
||||||
|
setNotAllowsInvalid(this.maxValueSpinner); |
||||||
|
this.setMaxValueCheckBox.addActionListener(setMaxListener); |
||||||
|
this.maxValueSpinner.addChangeListener(maxValueChangeListener); |
||||||
|
this.setMinValueCheckBox = new UICheckBox(Inter.getLocText("Need_Min_Value"), false); |
||||||
|
this.minValueSpinner = new UIBasicSpinner(minValueModel = new SpinnerNumberModel(0D, -Double.MAX_VALUE, Double.MAX_VALUE, 1D)); |
||||||
|
setNotAllowsInvalid(this.minValueSpinner); |
||||||
|
minValueSpinner.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
this.setMinValueCheckBox.addActionListener(setMinListener); |
||||||
|
this.minValueSpinner.addChangeListener(minValueChangeListener); |
||||||
|
setMinValueCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
||||||
|
initMaxMinValueFieldPane(); |
||||||
|
JPanel maxValueBorderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
maxValueBorderPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0)); |
||||||
|
maxValueBorderPane.add(maxValueFieldPane, BorderLayout.CENTER); |
||||||
|
JPanel minValueBorderPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
minValueBorderPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, IntervalConstants.INTERVAL_L1, 0)); |
||||||
|
minValueBorderPane.add(minValueFieldPane, BorderLayout.CENTER); |
||||||
|
UILabel numberLabel = new UILabel(Inter.getLocText(new String[]{"FR-Designer_Double", "Numbers"})); |
||||||
|
limitNumberPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{numberLabel, decimalLength}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
||||||
|
limitNumberPane.setBorder(BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L5, 0, 0)); |
||||||
|
double f = TableLayout.FILL; |
||||||
|
double p = TableLayout.PREFERRED; |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
new Component[]{allowDecimalsCheckBox, null}, |
||||||
|
new Component[]{limitNumberPane, null}, |
||||||
|
new Component[]{allowNegativeCheckBox, null}, |
||||||
|
new Component[]{setMaxValueCheckBox, maxValueSpinner}, |
||||||
|
new Component[]{maxValueBorderPane, null}, |
||||||
|
new Component[]{setMinValueCheckBox, minValueSpinner}, |
||||||
|
new Component[]{minValueBorderPane, null}, |
||||||
|
}; |
||||||
|
double[] rowSize = {p, p, p, p, p, p, p}; |
||||||
|
double[] columnSize = {p, f}; |
||||||
|
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; |
||||||
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); |
||||||
|
this.add(panel); |
||||||
|
} |
||||||
|
|
||||||
|
private void initMaxMinValueFieldPane() { |
||||||
|
maxValueErrorTextField = new UITextField(); |
||||||
|
minValueErrorTextField = new UITextField(); |
||||||
|
|
||||||
|
maxValueFieldPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget_Error_Tip")), maxValueErrorTextField}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
||||||
|
setMaxValueCheckBox.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
maxValueFieldPane.setVisible(setMaxValueCheckBox.isSelected()); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
minValueFieldPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{new UILabel(Inter.getLocText("FR-Designer_Widget_Error_Tip")), minValueErrorTextField}}, TableLayoutHelper.FILL_LASTCOLUMN, 18, 7); |
||||||
|
setMinValueCheckBox.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
minValueFieldPane.setVisible(setMinValueCheckBox.isSelected()); |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private void initListeners() { |
||||||
|
allowDecimalsListener = new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (allowDecimalsCheckBox.isSelected()) { |
||||||
|
limitNumberPane.setVisible(true); |
||||||
|
limitNumberPane.setPreferredSize(new Dimension(215, 20)); |
||||||
|
} else { |
||||||
|
limitNumberPane.setVisible(false); |
||||||
|
limitNumberPane.setPreferredSize(new Dimension(0, 0)); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
allowNegativeListener = new ActionListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (allowNegativeCheckBox.isSelected()) { |
||||||
|
minValueModel.setMinimum(-Double.MAX_VALUE); |
||||||
|
if (!setMinValueCheckBox.isSelected()) { |
||||||
|
maxValueModel.setMinimum(-Double.MAX_VALUE); |
||||||
|
} |
||||||
|
} else { |
||||||
|
minValueModel.setMinimum(0.0); |
||||||
|
if (!setMinValueCheckBox.isSelected()) { |
||||||
|
maxValueModel.setMinimum(0.0); |
||||||
|
} |
||||||
|
Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
||||||
|
Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
||||||
|
if (minValue < 0.0) { |
||||||
|
minValueSpinner.setValue(0.0); |
||||||
|
} |
||||||
|
if (maxValue < 0.0) { |
||||||
|
maxValueSpinner.setValue(0.0); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
setMaxListener = new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (setMaxValueCheckBox.isSelected()) { |
||||||
|
maxValueSpinner.setEnabled(true); |
||||||
|
Double value = new Double(0); |
||||||
|
if (setMinValueCheckBox.isSelected()) { |
||||||
|
Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); |
||||||
|
if (minValue > value) { |
||||||
|
value = minValue; |
||||||
|
} |
||||||
|
} |
||||||
|
maxValueSpinner.setValue(value); |
||||||
|
} else { |
||||||
|
maxValueSpinner.setEnabled(false); |
||||||
|
minValueModel.setMaximum(Double.MAX_VALUE); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
|
||||||
|
setMinListener = new ActionListener() { |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
if (setMinValueCheckBox.isSelected()) { |
||||||
|
minValueSpinner.setEnabled(true); |
||||||
|
Double value = new Double(0); |
||||||
|
if (setMaxValueCheckBox.isSelected()) { |
||||||
|
Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); |
||||||
|
if (maxValue < value) { |
||||||
|
value = maxValue; |
||||||
|
} |
||||||
|
} |
||||||
|
minValueSpinner.setValue(value); |
||||||
|
} else { |
||||||
|
minValueSpinner.setEnabled(false); |
||||||
|
maxValueModel.setMinimum(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : new Double(0)); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
maxValueChangeListener = new ChangeListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
if (setMaxValueCheckBox.isSelected()) { |
||||||
|
if (setMinValueCheckBox.isSelected()) { |
||||||
|
minValueModel.setMaximum(Double.parseDouble("" + maxValueSpinner.getValue())); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
minValueChangeListener = new ChangeListener() { |
||||||
|
|
||||||
|
@Override |
||||||
|
public void stateChanged(ChangeEvent e) { |
||||||
|
if (setMinValueCheckBox.isSelected()) { |
||||||
|
if (setMaxValueCheckBox.isSelected()) { |
||||||
|
maxValueModel.setMinimum(Double.parseDouble("" + minValueSpinner.getValue())); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
private void setNotAllowsInvalid(UIBasicSpinner jspinner) { |
||||||
|
JComponent editor = jspinner.getEditor(); |
||||||
|
if (editor instanceof UIBasicSpinner.DefaultEditor) { |
||||||
|
JFormattedTextField ftf = ((UIBasicSpinner.DefaultEditor) editor).getTextField(); |
||||||
|
ftf.setColumns(10); |
||||||
|
JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter(); |
||||||
|
DefaultFormatter df = (DefaultFormatter) formatter; |
||||||
|
df.setAllowsInvalid(false); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void populate(NumberEditor e) { |
||||||
|
allowDecimalsCheckBox.setSelected(e.isAllowDecimals()); |
||||||
|
if (e.isAllowDecimals()) { |
||||||
|
this.decimalLength.setValue(e.getMaxDecimalLength()); |
||||||
|
} else { |
||||||
|
this.limitNumberPane.setVisible(false); |
||||||
|
} |
||||||
|
|
||||||
|
allowNegativeCheckBox.setSelected(e.isAllowNegative()); |
||||||
|
if (e.getMaxValue() == Double.MAX_VALUE) { |
||||||
|
setMaxValueCheckBox.setSelected(false); |
||||||
|
maxValueFieldPane.setVisible(false); |
||||||
|
maxValueSpinner.setValue(new Double(Double.MAX_VALUE)); |
||||||
|
maxValueSpinner.setEnabled(false); |
||||||
|
} else { |
||||||
|
setMaxValueCheckBox.setSelected(true); |
||||||
|
maxValueSpinner.setEnabled(true); |
||||||
|
maxValueFieldPane.setVisible(true); |
||||||
|
maxValueSpinner.setValue(new Double(e.getMaxValue())); |
||||||
|
} |
||||||
|
|
||||||
|
if (e.getMinValue() == -Double.MAX_VALUE) { |
||||||
|
setMinValueCheckBox.setSelected(false); |
||||||
|
minValueFieldPane.setVisible(false); |
||||||
|
minValueSpinner.setValue(new Double(-Double.MAX_VALUE)); |
||||||
|
minValueSpinner.setEnabled(false); |
||||||
|
|
||||||
|
} else { |
||||||
|
setMinValueCheckBox.setSelected(true); |
||||||
|
minValueFieldPane.setVisible(true); |
||||||
|
minValueSpinner.setEnabled(true); |
||||||
|
minValueSpinner.setValue(new Double(e.getMinValue())); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void update(NumberEditor ob) { |
||||||
|
ob.setAllowDecimals(allowDecimalsCheckBox.isSelected()); |
||||||
|
if (allowDecimalsCheckBox.isSelected()) { |
||||||
|
ob.setMaxDecimalLength((int) this.decimalLength.getValue()); |
||||||
|
} |
||||||
|
|
||||||
|
ob.setAllowNegative(allowNegativeCheckBox.isSelected()); |
||||||
|
if (setMaxValueCheckBox.isSelected()) { |
||||||
|
ob.setMaxValue(Double.parseDouble("" + maxValueSpinner.getValue())); |
||||||
|
} else { |
||||||
|
ob.setMaxValue(Double.MAX_VALUE); |
||||||
|
} |
||||||
|
|
||||||
|
if (setMinValueCheckBox.isSelected()) { |
||||||
|
ob.setMinValue(Double.parseDouble("" + minValueSpinner.getValue())); |
||||||
|
} else { |
||||||
|
ob.setMinValue(-Double.MAX_VALUE); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
package com.fr.design.designer.creator; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.gui.ilable.UILabel; |
||||||
|
import com.fr.design.gui.xtable.TableUtils; |
||||||
|
import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; |
||||||
|
import com.fr.design.mainframe.widget.editors.StringEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
import java.beans.PropertyChangeEvent; |
||||||
|
import java.beans.PropertyChangeListener; |
||||||
|
import java.beans.PropertyEditor; |
||||||
|
import java.lang.reflect.Method; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/9/6. |
||||||
|
*/ |
||||||
|
public class CRPropertyDescriptorPane { |
||||||
|
private CRPropertyDescriptor crPropertyDescriptor; |
||||||
|
private XCreator xCreator; |
||||||
|
private PropertyEditor propertyEditor; |
||||||
|
|
||||||
|
public CRPropertyDescriptorPane(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) { |
||||||
|
this.crPropertyDescriptor = crPropertyDescriptor; |
||||||
|
this.xCreator = xCreator; |
||||||
|
} |
||||||
|
|
||||||
|
public Component[] createTableLayoutComponent() { |
||||||
|
return new Component[]{new UILabel(crPropertyDescriptor.getDisplayName()), initEditorComponent(crPropertyDescriptor, xCreator)}; |
||||||
|
} |
||||||
|
|
||||||
|
private Component initEditorComponent(CRPropertyDescriptor crPropertyDescriptor, final XCreator xCreator) { |
||||||
|
Component component = null; |
||||||
|
try { |
||||||
|
// 如果已有的编辑器就生成对应的component
|
||||||
|
Class<?> editorClass = crPropertyDescriptor.getPropertyEditorClass(); |
||||||
|
if (editorClass != null) { |
||||||
|
propertyEditor = initExtendEditor(crPropertyDescriptor, xCreator); |
||||||
|
component = propertyEditor.getCustomEditor(); |
||||||
|
} else { |
||||||
|
Class propType = crPropertyDescriptor.getPropertyType(); |
||||||
|
Class<? extends PropertyEditor> defaultEditorClass = TableUtils.getPropertyEditorClass(propType); |
||||||
|
if (defaultEditorClass == null) { |
||||||
|
defaultEditorClass = StringEditor.class; |
||||||
|
} |
||||||
|
propertyEditor = defaultEditorClass.newInstance(); |
||||||
|
component = propertyEditor.getCustomEditor(); |
||||||
|
} |
||||||
|
propertyEditor.addPropertyChangeListener(new PropertyChangeListener() { |
||||||
|
@Override |
||||||
|
public void propertyChange(PropertyChangeEvent evt) { |
||||||
|
update(xCreator.toData()); |
||||||
|
} |
||||||
|
}); |
||||||
|
} catch (Exception e) { |
||||||
|
FRContext.getLogger().error(e.getMessage()); |
||||||
|
} |
||||||
|
return component; |
||||||
|
} |
||||||
|
|
||||||
|
private PropertyEditor initExtendEditor(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator) throws Exception { |
||||||
|
ExtendedPropertyEditor editor = (ExtendedPropertyEditor) crPropertyDescriptor.createPropertyEditor(xCreator.toData()); |
||||||
|
if (editor == null) { |
||||||
|
Class propType = crPropertyDescriptor.getPropertyType(); |
||||||
|
editor = TableUtils.getPropertyEditorClass(propType).newInstance(); |
||||||
|
} |
||||||
|
|
||||||
|
return editor; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Widget widget) { |
||||||
|
try { |
||||||
|
Method m = crPropertyDescriptor.getReadMethod(); |
||||||
|
Object value = m.invoke(widget); |
||||||
|
propertyEditor.setValue(value); |
||||||
|
} catch (Exception e) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void update(Widget widget) { |
||||||
|
try { |
||||||
|
Method m = crPropertyDescriptor.getWriteMethod(); |
||||||
|
m.invoke(widget, propertyEditor.getValue()); |
||||||
|
} catch (Exception e) { |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
package com.fr.design.designer.creator; |
||||||
|
|
||||||
|
import com.fr.base.FRContext; |
||||||
|
import com.fr.design.designer.IntervalConstants; |
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.layout.TableLayoutHelper; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2017/9/7. |
||||||
|
*/ |
||||||
|
public class PropertyGroupPane extends BasicPane { |
||||||
|
private CRPropertyDescriptor[] crPropertyDescriptors; |
||||||
|
private CRPropertyDescriptorPane[] crPropertyDescriptorPanes; |
||||||
|
private XCreator xCreator; |
||||||
|
|
||||||
|
public PropertyGroupPane(CRPropertyDescriptor[] crPropertyDescriptors, XCreator xCreator) { |
||||||
|
this.crPropertyDescriptors = crPropertyDescriptors; |
||||||
|
this.xCreator = xCreator; |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
public void initComponent() { |
||||||
|
int count = crPropertyDescriptors.length; |
||||||
|
crPropertyDescriptorPanes = new CRPropertyDescriptorPane[count]; |
||||||
|
Component[][] components = new Component[count][]; |
||||||
|
for (int i = 0; i < count; i++) { |
||||||
|
crPropertyDescriptorPanes[i] = new CRPropertyDescriptorPane(crPropertyDescriptors[i], xCreator); |
||||||
|
components[i] = crPropertyDescriptorPanes[i].createTableLayoutComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1); |
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 10, 0)); |
||||||
|
this.add(panel, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(Widget widget){ |
||||||
|
for(int i = 0; i< crPropertyDescriptorPanes.length; i++){ |
||||||
|
crPropertyDescriptorPanes[i].populate(widget); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "PropertyGroupPane"; |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
try{ |
||||||
|
XCreator xCreator = new XButton(new FreeButton(),new Dimension(100, 100)); |
||||||
|
PropertyGroupPane propertyGroupPane = new PropertyGroupPane(xCreator.supportedDescriptor(), xCreator); |
||||||
|
JFrame jf = new JFrame("jFrame"); |
||||||
|
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||||
|
JPanel content = (JPanel) jf.getContentPane(); |
||||||
|
content.setLayout(new BorderLayout()); |
||||||
|
content.add(propertyGroupPane, BorderLayout.CENTER); |
||||||
|
jf.setSize(439, 400); |
||||||
|
jf.setVisible(true); |
||||||
|
}catch (Exception e){ |
||||||
|
FRContext.getLogger().error(e.getMessage()); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,93 +0,0 @@ |
|||||||
package com.fr.design.widget.ui.designer; |
|
||||||
|
|
||||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
|
||||||
import com.fr.design.gui.icombobox.DictionaryConstants; |
|
||||||
import com.fr.design.gui.icombobox.UIComboBox; |
|
||||||
import com.fr.design.gui.ilable.UILabel; |
|
||||||
import com.fr.design.layout.FRGUIPaneFactory; |
|
||||||
import com.fr.form.ui.CheckBoxGroup; |
|
||||||
import com.fr.form.ui.ComboCheckBox; |
|
||||||
import com.fr.general.Inter; |
|
||||||
|
|
||||||
import javax.swing.*; |
|
||||||
import java.awt.*; |
|
||||||
import java.awt.event.ActionEvent; |
|
||||||
import java.awt.event.ActionListener; |
|
||||||
|
|
||||||
public class CheckBoxDictPane extends JPanel { |
|
||||||
|
|
||||||
private DictionaryComboBox delimiterComboBox; |
|
||||||
private UIComboBox returnTypeComboBox; |
|
||||||
private DictionaryComboBox startComboBox; |
|
||||||
private DictionaryComboBox endComboBox; |
|
||||||
|
|
||||||
private JPanel delimiterPane; |
|
||||||
private JPanel startPane; |
|
||||||
private JPanel endPane; |
|
||||||
|
|
||||||
public CheckBoxDictPane() { |
|
||||||
JPanel returnTypePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
||||||
returnTypePane.add(new UILabel(Inter.getLocText("Widget-Date_Selector_Return_Type") + ":"), BorderLayout.WEST); |
|
||||||
returnTypeComboBox = new UIComboBox(new String[]{Inter.getLocText("Widget-Array"), Inter.getLocText("String")}); |
|
||||||
returnTypePane.add(returnTypeComboBox, BorderLayout.CENTER); |
|
||||||
this.add(returnTypePane); |
|
||||||
|
|
||||||
delimiterPane =FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
UILabel label = new UILabel(Inter.getLocText("Form-Delimiter") + ":"); |
|
||||||
delimiterPane.add(label, BorderLayout.WEST); |
|
||||||
delimiterPane.add(delimiterComboBox = new DictionaryComboBox(DictionaryConstants.delimiters, DictionaryConstants.delimiterDisplays), BorderLayout.CENTER); |
|
||||||
delimiterComboBox.setEditable(true); |
|
||||||
this.add(delimiterPane); |
|
||||||
|
|
||||||
startPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
startPane.add(new UILabel(Inter.getLocText("ComboCheckBox-Start_Symbol") + ":"), BorderLayout.WEST); |
|
||||||
startPane.add(startComboBox = new DictionaryComboBox(DictionaryConstants.symbols, DictionaryConstants.symbolDisplays), BorderLayout.CENTER); |
|
||||||
startComboBox.setEditable(true); |
|
||||||
this.add(startPane); |
|
||||||
|
|
||||||
endPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
||||||
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); |
|
||||||
this.add(endPane); |
|
||||||
|
|
||||||
returnTypeComboBox.addActionListener(new ActionListener(){ |
|
||||||
public void actionPerformed(ActionEvent e) { |
|
||||||
checkVisible(); |
|
||||||
} |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
private void checkVisible(){ |
|
||||||
delimiterPane.setVisible(returnTypeComboBox.getSelectedIndex() == 1); |
|
||||||
startPane.setVisible(returnTypeComboBox.getSelectedIndex() == 1); |
|
||||||
endPane.setVisible(returnTypeComboBox.getSelectedIndex() == 1); |
|
||||||
} |
|
||||||
|
|
||||||
public void populate(ComboCheckBox comboCheckBox) { |
|
||||||
this.delimiterComboBox.setSelectedItem(comboCheckBox.getDelimiter()); |
|
||||||
this.returnTypeComboBox.setSelectedIndex(comboCheckBox.isReturnString() ? 1 : 0); |
|
||||||
this.startComboBox.setSelectedItem(comboCheckBox.getStartSymbol()); |
|
||||||
this.endComboBox.setSelectedItem(comboCheckBox.getEndSymbol()); |
|
||||||
checkVisible(); |
|
||||||
} |
|
||||||
public void update(ComboCheckBox comboCheckBox) { |
|
||||||
comboCheckBox.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
|
||||||
comboCheckBox.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
|
||||||
comboCheckBox.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
|
||||||
comboCheckBox.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
|
||||||
} |
|
||||||
public void populate(CheckBoxGroup checkBoxGroup) { |
|
||||||
this.delimiterComboBox.setSelectedItem(checkBoxGroup.getDelimiter()); |
|
||||||
this.returnTypeComboBox.setSelectedIndex(checkBoxGroup.isReturnString() ? 1 : 0); |
|
||||||
this.startComboBox.setSelectedItem(checkBoxGroup.getStartSymbol()); |
|
||||||
this.endComboBox.setSelectedItem(checkBoxGroup.getEndSymbol()); |
|
||||||
checkVisible(); |
|
||||||
} |
|
||||||
public void update(CheckBoxGroup checkBoxGroup) { |
|
||||||
checkBoxGroup.setDelimiter((String)this.delimiterComboBox.getSelectedItem()); |
|
||||||
checkBoxGroup.setReturnString(this.returnTypeComboBox.getSelectedIndex() != 0); |
|
||||||
checkBoxGroup.setStartSymbol((String)this.startComboBox.getSelectedItem()); |
|
||||||
checkBoxGroup.setEndSymbol((String)this.endComboBox.getSelectedItem()); |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue