Browse Source

Merge pull request #897 in DESIGN/design from ~XIAOXIA/design:release/10.0 to release/10.0

* commit 'bfb5abfc0db3684895511452123d9c991a8ae0e4':
  改一下label 继承 下actionlabel
  rt
  REPORT-14835 过滤逻辑修改
  修改editor
  rt
  REPORT-14835 日期控件自定义
bugfix/10.0
neil 5 years ago
parent
commit
c8f20b88b6
  1. 4
      designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java
  2. 4
      designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java
  3. 14
      designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java
  4. 31
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java
  5. 37
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java
  6. 32
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

4
designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java

@ -153,6 +153,10 @@ public class DateEditor extends Editor<Date> {
this.uiDatePicker.setSelectedItem(new Date());
}
public UIDatePicker getUiDatePicker() {
return uiDatePicker;
}
/**
* Request focus
*/

4
designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java

@ -1,6 +1,7 @@
package com.fr.design.gui.date;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
@ -9,7 +10,7 @@ import java.util.Date;
public class SingleObjectComboBoxModel extends AbstractListModel implements ComboBoxModel {
private SimpleDateFormat dateFormat;
private String selectedDate = "";
private String selectedDate = StringUtils.EMPTY;
public SingleObjectComboBoxModel() {
}
@ -28,6 +29,7 @@ public class SingleObjectComboBoxModel extends AbstractListModel implements Comb
public void setSelectedItem(Object anItem) {
if (anItem == null) {
selectedDate = StringUtils.EMPTY;
return;
}
if (anItem instanceof Date) {

14
designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java

@ -6,6 +6,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComboBox;
@ -157,7 +158,11 @@ public class UIDatePicker extends UIComboBox implements Serializable {
* 设置当前选择的日期
*/
public void setSelectedDate(Date date) throws ParseException {
this.setSelectedItem(dateFormat.format(date));
if (date == null) {
this.setSelectedItem(null);
} else {
this.setSelectedItem(dateFormat.format(date));
}
}
public void setSelectedItem(Object anObject) {
@ -215,8 +220,11 @@ public class UIDatePicker extends UIComboBox implements Serializable {
try {
String strDate = comboBox.getSelectedItem().toString();
synchronized (this) {
Date selectionDate = dateFormat.parse(strDate);
calendarPanel.setSelectedDate(selectionDate);
Date selectionDate = new Date();
if (StringUtils.isNotBlank(strDate)) {
selectionDate = dateFormat.parse(strDate);
}
calendarPanel.setSelectedDate(selectionDate);
calendarPanel.updateHMS();
}
} catch (Exception e) {

31
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.analysis.cloud.DateUtils;
import com.fr.design.dialog.UIDialog;
import com.fr.design.editor.editor.DateEditor;
import com.fr.design.gui.date.UIDatePicker;
@ -14,6 +15,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.server.vcs.VcsOperator;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JPanel;
import java.awt.BorderLayout;
@ -45,7 +47,7 @@ public class FileVersionDialog extends UIDialog {
upBox.setBorder(VcsHelper.EMPTY_BORDER);
upBox.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_buildTime") + " "));
upBox.add(Box.createHorizontalGlue());
dateEditor = new DateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1);
dateEditor = new VcsDateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1);
upBox.add(dateEditor);
Box downBox = Box.createHorizontalBox();
downBox.setBorder(VcsHelper.EMPTY_BORDER);
@ -62,8 +64,10 @@ public class FileVersionDialog extends UIDialog {
@Override
public void actionPerformed(ActionEvent e) {
FileVersionDialog.this.setVisible(false);
Date date = dateEditor.getValue();
List<VcsEntity> vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, date, new Date(date.getTime() + DELAY), textField.getText());
Date editorDate = dateEditor.getValue();
Date start = editorDate == null ? new Date(0) : editorDate;
Date end = editorDate == null ? DateUtils.getLastHour() : new Date(start.getTime() + DELAY);
List<VcsEntity> vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, start, end, textField.getText());
FileVersionTable.getInstance().updateModel(1, vcsEntities);
}
@ -74,16 +78,29 @@ public class FileVersionDialog extends UIDialog {
FileVersionDialog.this.setVisible(false);
}
});
VcsLabel resetLabel = new VcsLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR);
resetLabel.setBorder(BorderFactory.createEmptyBorder(10, 160, 0, 10));
resetLabel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dateEditor.setValue(null);
textField.setText(null);
FileVersionDialog.this.repaint();
}
});
panel.add(upBox, BorderLayout.NORTH);
panel.add(downBox, BorderLayout.CENTER);
panel.add(buttonPane, BorderLayout.SOUTH);
add(panel);
setSize(new Dimension(230, 105));
centerWindow(this);
JPanel filterPane = new JPanel(new BorderLayout());
filterPane.add(resetLabel, BorderLayout.NORTH);
filterPane.add(panel, BorderLayout.CENTER);
add(filterPane);
setSize(new Dimension(230, 125));
centerWindow(frame);
}
private void centerWindow(Window window) {
window.setLocation(0, 95);
this.setLocation(window.getX(), 95);
}

37
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java

@ -0,0 +1,37 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.editor.editor.DateEditor;
import com.fr.log.FineLoggerFactory;
import java.text.ParseException;
import java.util.Date;
/**
* Created by XiaXiang on 2019/5/14.
*/
public class VcsDateEditor extends DateEditor {
private Date tempValue;
public VcsDateEditor(Date value, boolean format, String name, int dateFormat) {
super(value, format, name, dateFormat);
this.tempValue = value;
}
@Override
public Date getValue() {
if (tempValue == null) {
return null;
}
return super.getValue();
}
@Override
public void setValue(Date value) {
this.tempValue = value;
try {
getUiDatePicker().setSelectedDate(value);
} catch (ParseException parseException) {
FineLoggerFactory.getLogger().error(parseException.getMessage(), parseException);
}
}
}

32
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel;
import java.awt.Color;
import java.awt.Graphics;
/**
* Created by XiaXiang on 2019/5/15.
*/
public class VcsLabel extends ActionLabel {
public VcsLabel(String text, Color color) {
super(text);
this.setForeground(color);
}
public void paintComponent(Graphics g) {
if (ui != null) {
Graphics scratchGraphics = (g == null) ? null : g.create();
try {
ui.update(scratchGraphics, this);
}
finally {
scratchGraphics.dispose();
}
}
}
}
Loading…
Cancel
Save