From e83ea53ce116a7df078d0a1ae15e3c47a1b608b1 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 15:13:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-14835=20=E6=97=A5=E6=9C=9F=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/date/SingleObjectComboBoxModel.java | 4 +- .../com/fr/design/gui/date/UIDatePicker.java | 16 +++- .../design/mainframe/vcs/ui/ActionLabel.java | 79 +++++++++++++++++++ 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100755 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java diff --git a/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java b/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java index 788d1104e..62cf79347 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java +++ b/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) { diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java index aa9cabd49..a48f5a59d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java +++ b/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; @@ -156,8 +157,12 @@ public class UIDatePicker extends UIComboBox implements Serializable { /** * 设置当前选择的日期 */ - public void setSelectedDate(Date date) throws ParseException { - this.setSelectedItem(dateFormat.format(date)); + public void setSelectedDate(Date 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) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java new file mode 100755 index 000000000..973846bc5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java @@ -0,0 +1,79 @@ +package com.fr.design.mainframe.vcs.ui; + +import com.fr.design.gui.ilable.UILabel; + +import javax.swing.event.MouseInputAdapter; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; + +/** + * Action label + */ +public class ActionLabel extends UILabel { + private ActionListener actionListener; + private Color color; + + private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { + public void mouseClicked(MouseEvent e) { + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseReleased(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + //Action. + if (actionListener != null) { + ActionEvent actionEvent = new ActionEvent(source, 99, ""); + actionListener.actionPerformed(actionEvent); + } + } + } + + public void mouseEntered(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + } + + public void mouseExited(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + } + + public void mouseDragged(MouseEvent e) { + } + + public void mouseMoved(MouseEvent evt) { + Object source = evt.getSource(); + + if (source instanceof UILabel) { + ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + } + }; + + public ActionLabel(String text, Color color) { + super(text); + + this.color = color; + this.setForeground(color); + this.addMouseListener(mouseInputAdapter); + this.addMouseMotionListener(mouseInputAdapter); + } + + public void addActionListener(ActionListener actionListener) { + this.actionListener = actionListener; + } + +} \ No newline at end of file From 095c0745f1bad9a1bf8496ae7b14e00eab01c9d1 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 15:14:31 +0800 Subject: [PATCH 2/6] rt --- .../src/main/java/com/fr/design/gui/date/UIDatePicker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java index a48f5a59d..fb44f618f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java @@ -157,7 +157,7 @@ public class UIDatePicker extends UIComboBox implements Serializable { /** * 设置当前选择的日期 */ - public void setSelectedDate(Date date) { + public void setSelectedDate(Date date) throws ParseException { if (date == null) { this.setSelectedItem(null); } else { From 46f5da34b9e6e47c4587cbce3d4998f445894b27 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 15:19:50 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/editor/editor/DateEditor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java index 3b1abe6f0..c40161ba6 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java @@ -153,6 +153,10 @@ public class DateEditor extends Editor { this.uiDatePicker.setSelectedItem(new Date()); } + public UIDatePicker getUiDatePicker() { + return uiDatePicker; + } + /** * Request focus */ From 59cb8283b705161e915df771e6475c246c5e69cc Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 15:36:27 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-14835=20=E8=BF=87=E6=BB=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/vcs/ui/FileVersionDialog.java | 31 ++++++++++++---- .../mainframe/vcs/ui/VcsDateEditor.java | 37 +++++++++++++++++++ 2 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 33076a07f..96232b7bc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/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 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 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); } }); + ActionLabel resetLabel = new ActionLabel(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); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java new file mode 100644 index 000000000..74b65ecfe --- /dev/null +++ b/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); + } + } +} From e20989d81d11a4cca4122d41670f55ed4a57d769 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 15:38:44 +0800 Subject: [PATCH 5/6] rt --- .../java/com/fr/design/mainframe/vcs/ui/ActionLabel.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java index 973846bc5..eb9f2ddba 100755 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java @@ -10,7 +10,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; /** - * Action label + * Created by XiaXiang on 2019/5/15. */ public class ActionLabel extends UILabel { private ActionListener actionListener; @@ -76,4 +76,11 @@ public class ActionLabel extends UILabel { this.actionListener = actionListener; } + public Color getColor() { + return color; + } + + public void setColor(Color color) { + this.color = color; + } } \ No newline at end of file From bfb5abfc0db3684895511452123d9c991a8ae0e4 Mon Sep 17 00:00:00 2001 From: XiaXiang Date: Wed, 15 May 2019 16:01:13 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8Blabel=20?= =?UTF-8?q?=E7=BB=A7=E6=89=BF=20=E4=B8=8Bactionlabel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/vcs/ui/ActionLabel.java | 86 ------------------- .../mainframe/vcs/ui/FileVersionDialog.java | 2 +- .../fr/design/mainframe/vcs/ui/VcsLabel.java | 32 +++++++ 3 files changed, 33 insertions(+), 87 deletions(-) delete mode 100755 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java create mode 100755 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java deleted file mode 100755 index eb9f2ddba..000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ActionLabel.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.fr.design.mainframe.vcs.ui; - -import com.fr.design.gui.ilable.UILabel; - -import javax.swing.event.MouseInputAdapter; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; - -/** - * Created by XiaXiang on 2019/5/15. - */ -public class ActionLabel extends UILabel { - private ActionListener actionListener; - private Color color; - - private MouseInputAdapter mouseInputAdapter = new MouseInputAdapter() { - public void mouseClicked(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - //Action. - if (actionListener != null) { - ActionEvent actionEvent = new ActionEvent(source, 99, ""); - actionListener.actionPerformed(actionEvent); - } - } - } - - public void mouseEntered(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - - public void mouseExited(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - } - - public void mouseDragged(MouseEvent e) { - } - - public void mouseMoved(MouseEvent evt) { - Object source = evt.getSource(); - - if (source instanceof UILabel) { - ((UILabel) source).setCursor(new Cursor(Cursor.HAND_CURSOR)); - } - } - }; - - public ActionLabel(String text, Color color) { - super(text); - - this.color = color; - this.setForeground(color); - this.addMouseListener(mouseInputAdapter); - this.addMouseMotionListener(mouseInputAdapter); - } - - public void addActionListener(ActionListener actionListener) { - this.actionListener = actionListener; - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - this.color = color; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 96232b7bc..15d8bae63 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -78,7 +78,7 @@ public class FileVersionDialog extends UIDialog { FileVersionDialog.this.setVisible(false); } }); - ActionLabel resetLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR); + 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 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java new file mode 100755 index 000000000..a0180a137 --- /dev/null +++ b/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(); + } + } + } +} \ No newline at end of file