Browse Source

Merge pull request #1240 in BA/design from ~KERRY/design:release/9.0 to release/9.0

* commit '491bfeb12297a45cab1389cce4fd65229cdaf387':
  REPORT-4372 日期控件自定义日期格式
master
superman 7 years ago
parent
commit
a7fc515ac0
  1. 5
      designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java
  2. 116
      designer_base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java
  3. 5
      designer_form/src/com/fr/design/widget/ui/designer/DateEditorDefinePane.java

5
designer/src/com/fr/design/widget/ui/DateEditorDefinePane.java

@ -10,6 +10,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.component.DateValuePane; import com.fr.design.widget.component.DateValuePane;
import com.fr.design.widget.component.UIComboBoxNoArrow;
import com.fr.form.ui.DateEditor; import com.fr.form.ui.DateEditor;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
@ -92,8 +93,8 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private JPanel createFormatHead(){ private JPanel createFormatHead(){
String[] dateArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.DATE); String[] dateArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.DATE);
String[] timeArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.TIME); String[] timeArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.TIME);
final UIComboBox dateFormatComboBox = new UIComboBox(dateArray); final UIComboBox dateFormatComboBox = new UIComboBoxNoArrow(dateArray);
final UIComboBox timeFormatComboBox = new UIComboBox(timeArray); final UIComboBox timeFormatComboBox = new UIComboBoxNoArrow(timeArray);
dateFormatComboBox.addActionListener(new ActionListener(){ dateFormatComboBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){
refreshPreviewLabel(); refreshPreviewLabel();

116
designer_base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java

@ -0,0 +1,116 @@
package com.fr.design.widget.component;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.stable.StringUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicComboBoxUI;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* Created by kerry on 2017/9/14.
*/
public class UIComboBoxNoArrow extends UIComboBox {
public UIComboBoxNoArrow(Object[] items) {
super(items);
init();
}
public UIComboBoxNoArrow() {
}
public void init() {
this.setEditable(true);
this.setEditor(new ComboBoxNoArrowEditor(this));
this.setUI(new ComboBoxNoArrowUI());
}
public class ComboBoxNoArrowUI extends BasicComboBoxUI {
@Override
protected UIButton createArrowButton() {
arrowButton = new UIButton(UIConstants.ARROW_DOWN_ICON) {
@Override
public boolean shouldResponseChangeListener() {
return false;
}
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
};
squareButton = false;
arrowButton.setPreferredSize(new Dimension(0, 0));
arrowButton.setVisible(false);
return (UIButton) arrowButton;
}
}
public class ComboBoxNoArrowEditor extends UIComboBoxEditor implements DocumentListener {
private volatile boolean setting = false;
private UIComboBoxNoArrow comboBox;
private Object item;
public ComboBoxNoArrowEditor(UIComboBoxNoArrow comboBox) {
super();
this.comboBox = comboBox;
textField.getDocument().addDocumentListener(this);
textField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
changeHandler();
}
@Override
public void focusLost(FocusEvent e) {
}
});
}
public void setItem(Object item) {
this.item = item;
this.setting = true;
textField.setText((item == null) ? StringUtils.EMPTY : item.toString());
this.setting = false;
}
public Object getItem() {
return this.item;
}
public void insertUpdate(DocumentEvent e) {
changeHandler();
}
public void removeUpdate(DocumentEvent e) {
changeHandler();
}
public void changedUpdate(DocumentEvent e) {
changeHandler();
}
protected void changeHandler() {
if (setting) {
return;
}
comboBox.setPopupVisible(true);
this.item = textField.getText();
this.getEditorComponent().requestFocus();
}
}
}

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

@ -11,6 +11,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.widget.component.DateValuePane; import com.fr.design.widget.component.DateValuePane;
import com.fr.design.widget.component.UIComboBoxNoArrow;
import com.fr.design.widget.ui.designer.component.FormWidgetValuePane; import com.fr.design.widget.ui.designer.component.FormWidgetValuePane;
import com.fr.form.ui.DateEditor; import com.fr.form.ui.DateEditor;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
@ -101,8 +102,8 @@ public class DateEditorDefinePane extends DirectWriteEditorDefinePane<DateEditor
private JPanel createFormatHead(){ private JPanel createFormatHead(){
String[] dateArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.DATE); String[] dateArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.DATE);
String[] timeArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.TIME); String[] timeArray = FormatField.getInstance().getFormatArray(FormatField.FormatContents.TIME);
final UIComboBox dateFormatComboBox = new UIComboBox(dateArray); final UIComboBox dateFormatComboBox = new UIComboBoxNoArrow(dateArray);
final UIComboBox timeFormatComboBox = new UIComboBox(timeArray); final UIComboBox timeFormatComboBox = new UIComboBoxNoArrow(timeArray);
dateFormatComboBox.addActionListener(new ActionListener(){ dateFormatComboBox.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){
refreshPreviewLabel(); refreshPreviewLabel();

Loading…
Cancel
Save