Revision 2548 org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.dynform/org.gvsig.tools.dynform.services/src/main/java/org/gvsig/tools/dynform/services/dynformfield/Timestamp/JDynFormFieldTimestamp.java
JDynFormFieldTimestamp.java | ||
---|---|---|
26 | 26 |
import java.awt.BorderLayout; |
27 | 27 |
import java.awt.Cursor; |
28 | 28 |
import java.awt.event.ActionEvent; |
29 |
import java.awt.event.ActionListener; |
|
30 | 29 |
import java.awt.event.FocusEvent; |
31 | 30 |
import java.awt.event.FocusListener; |
32 | 31 |
import java.sql.Timestamp; |
33 | 32 |
import java.util.Date; |
34 |
import javax.swing.Action; |
|
35 |
import javax.swing.ImageIcon; |
|
36 |
|
|
33 |
import java.util.Objects; |
|
37 | 34 |
import javax.swing.JButton; |
38 |
import javax.swing.JCheckBox; |
|
39 | 35 |
import javax.swing.JComponent; |
40 | 36 |
import javax.swing.JPanel; |
41 | 37 |
import javax.swing.JPopupMenu; |
42 | 38 |
import javax.swing.text.JTextComponent; |
43 | 39 |
import org.apache.commons.lang3.StringUtils; |
44 |
|
|
45 | 40 |
import org.freixas.jcalendar.DateEvent; |
46 | 41 |
import org.freixas.jcalendar.JCalendar; |
47 | 42 |
import org.gvsig.tools.dynform.DynFormFieldDefinition; |
48 | 43 |
import org.gvsig.tools.dynform.JDynFormField; |
49 | 44 |
import org.gvsig.tools.dynform.spi.DynFormSPIManager; |
45 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField; |
|
50 | 46 |
import org.gvsig.tools.dynform.spi.dynformfield.JDynFormFieldFactory; |
51 |
import org.gvsig.tools.dynform.spi.dynformfield.AbstractJDynFormField; |
|
52 | 47 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
53 | 48 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
54 | 49 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
55 | 50 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
56 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
57 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
|
58 | 51 |
|
59 | 52 |
public class JDynFormFieldTimestamp extends AbstractJDynFormField implements JDynFormField, FocusListener { |
60 | 53 |
|
... | ... | |
103 | 96 |
this.jcalendar = new JCalendar(); |
104 | 97 |
this.jcalendar.addDateListener((DateEvent arg0) -> { |
105 | 98 |
Timestamp currentDate = (Timestamp) getValue(); |
99 |
if(currentDate == null){ |
|
100 |
currentDate = new Timestamp(new Date().getTime()); |
|
101 |
} |
|
106 | 102 |
Date newDate = getJCalendar().getDate(); |
107 | 103 |
|
108 | 104 |
currentDate.setDate(newDate.getDate()); |
... | ... | |
211 | 207 |
fireFieldExitEvent(); |
212 | 208 |
} |
213 | 209 |
|
210 |
@Override |
|
211 |
public boolean isModified() { |
|
212 |
|
|
213 |
Timestamp assigned = (Timestamp) getAssignedValue(); |
|
214 |
String ss = this.txtTimestamp.getText(); |
|
215 |
if (StringUtils.isBlank(ss)) { |
|
216 |
return assigned != null; |
|
217 |
} |
|
218 |
|
|
219 |
try { |
|
220 |
Timestamp value = Timestamp.valueOf(ss); |
|
221 |
return !Objects.equals(value, assigned); |
|
222 |
} catch (Exception ex) { |
|
223 |
return false; |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
|
|
214 | 228 |
} |
Also available in: Unified diff