Lines 166-176
Link Here
|
166 |
|
166 |
|
167 |
popupButton = createPopupButton(); |
167 |
popupButton = createPopupButton(); |
168 |
if (popupButton != null) { |
168 |
if (popupButton != null) { |
169 |
// this is a trick to get hold of the client prop which |
169 |
popupButton.putClientProperty("doNotCancelPopup", |
170 |
// prevents closing of the popup |
170 |
createDoNotCancelPopupClientProperty()); |
171 |
JComboBox box = new JComboBox(); |
|
|
172 |
Object preventHide = box.getClientProperty("doNotCancelPopup"); |
173 |
popupButton.putClientProperty("doNotCancelPopup", preventHide); |
174 |
datePicker.add(popupButton); |
171 |
datePicker.add(popupButton); |
175 |
} |
172 |
} |
176 |
updateChildLocale(datePicker.getLocale()); |
173 |
updateChildLocale(datePicker.getLocale()); |
Lines 252-259
Link Here
|
252 |
* PRE: keybindings installed on picker. |
249 |
* PRE: keybindings installed on picker. |
253 |
*/ |
250 |
*/ |
254 |
protected void installLinkPanelKeyboardActions() { |
251 |
protected void installLinkPanelKeyboardActions() { |
255 |
if (datePicker.getLinkPanel() == null) |
252 |
if (datePicker.getLinkPanel() == null) { |
256 |
return; |
253 |
return; |
|
|
254 |
} |
257 |
ActionMap map = datePicker.getLinkPanel().getActionMap(); |
255 |
ActionMap map = datePicker.getLinkPanel().getActionMap(); |
258 |
map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get( |
256 |
map.put(JXDateTimePicker.HOME_COMMIT_KEY, datePicker.getActionMap().get( |
259 |
JXDateTimePicker.HOME_COMMIT_KEY)); |
257 |
JXDateTimePicker.HOME_COMMIT_KEY)); |
Lines 277-283
Link Here
|
277 |
* |
275 |
* |
278 |
*/ |
276 |
*/ |
279 |
protected void uninstallLinkPanelKeyboardActions(JComponent panel) { |
277 |
protected void uninstallLinkPanelKeyboardActions(JComponent panel) { |
280 |
if (panel == null) return; |
278 |
if (panel == null) { |
|
|
279 |
return; |
280 |
} |
281 |
ActionMap map = panel.getActionMap(); |
281 |
ActionMap map = panel.getActionMap(); |
282 |
map.remove(JXDateTimePicker.HOME_COMMIT_KEY); |
282 |
map.remove(JXDateTimePicker.HOME_COMMIT_KEY); |
283 |
map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); |
283 |
map.remove(JXDateTimePicker.HOME_NAVIGATE_KEY); |
Lines 705-711
Link Here
|
705 |
* is intermediate |
705 |
* is intermediate |
706 |
*/ |
706 |
*/ |
707 |
protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) { |
707 |
protected void updateFromSelectionChanged(EventType eventType, boolean adjusting) { |
708 |
if (adjusting) return; |
708 |
if (adjusting) { |
|
|
709 |
return; |
710 |
} |
709 |
updateEditorValue(); |
711 |
updateEditorValue(); |
710 |
} |
712 |
} |
711 |
|
713 |
|
Lines 755-765
Link Here
|
755 |
oldEditor.putClientProperty("doNotCancelPopup", null); |
757 |
oldEditor.putClientProperty("doNotCancelPopup", null); |
756 |
} |
758 |
} |
757 |
datePicker.add(datePicker.getEditor()); |
759 |
datePicker.add(datePicker.getEditor()); |
758 |
// this is a trick to get hold of the client prop which |
760 |
datePicker.getEditor().putClientProperty("doNotCancelPopup", |
759 |
// prevents closing of the popup |
761 |
createDoNotCancelPopupClientProperty()); |
760 |
JComboBox box = new JComboBox(); |
|
|
761 |
Object preventHide = box.getClientProperty("doNotCancelPopup"); |
762 |
datePicker.getEditor().putClientProperty("doNotCancelPopup", preventHide); |
763 |
|
762 |
|
764 |
updateEditorValue(); |
763 |
updateEditorValue(); |
765 |
if (updateListeners) { |
764 |
if (updateListeners) { |
Lines 942-948
Link Here
|
942 |
* control popup visibility? |
941 |
* control popup visibility? |
943 |
*/ |
942 |
*/ |
944 |
public void hidePopup() { |
943 |
public void hidePopup() { |
945 |
if (popup != null) popup.setVisible(false); |
944 |
if (popup != null) { |
|
|
945 |
popup.setVisible(false); |
946 |
} |
946 |
} |
947 |
} |
947 |
|
948 |
|
948 |
public boolean isPopupVisible() { |
949 |
public boolean isPopupVisible() { |
Lines 980-986
Link Here
|
980 |
*/ |
981 |
*/ |
981 |
private Action createCommitAction() { |
982 |
private Action createCommitAction() { |
982 |
Action action = new AbstractAction() { |
983 |
Action action = new AbstractAction() { |
983 |
|
984 |
@Override |
984 |
public void actionPerformed(ActionEvent e) { |
985 |
public void actionPerformed(ActionEvent e) { |
985 |
commit(); |
986 |
commit(); |
986 |
} |
987 |
} |
Lines 997-1003
Link Here
|
997 |
*/ |
998 |
*/ |
998 |
private Action createCancelAction() { |
999 |
private Action createCancelAction() { |
999 |
Action action = new AbstractAction() { |
1000 |
Action action = new AbstractAction() { |
1000 |
|
1001 |
@Override |
1001 |
public void actionPerformed(ActionEvent e) { |
1002 |
public void actionPerformed(ActionEvent e) { |
1002 |
cancel(); |
1003 |
cancel(); |
1003 |
} |
1004 |
} |
Lines 1008-1014
Link Here
|
1008 |
|
1009 |
|
1009 |
private Action createHomeAction(final boolean commit) { |
1010 |
private Action createHomeAction(final boolean commit) { |
1010 |
Action action = new AbstractAction( ) { |
1011 |
Action action = new AbstractAction( ) { |
1011 |
|
1012 |
@Override |
1012 |
public void actionPerformed(ActionEvent e) { |
1013 |
public void actionPerformed(ActionEvent e) { |
1013 |
home(commit); |
1014 |
home(commit); |
1014 |
|
1015 |
|
Lines 1054-1059
Link Here
|
1054 |
editor.getActionMap().put(TEXT_CANCEL_KEY, this); |
1055 |
editor.getActionMap().put(TEXT_CANCEL_KEY, this); |
1055 |
} |
1056 |
} |
1056 |
|
1057 |
|
|
|
1058 |
@Override |
1057 |
public void actionPerformed(ActionEvent e) { |
1059 |
public void actionPerformed(ActionEvent e) { |
1058 |
cancelAction.actionPerformed(null); |
1060 |
cancelAction.actionPerformed(null); |
1059 |
cancel(); |
1061 |
cancel(); |
Lines 1088-1093
Link Here
|
1088 |
datePicker.getEditor().requestFocusInWindow(); |
1090 |
datePicker.getEditor().requestFocusInWindow(); |
1089 |
// datePicker.requestFocusInWindow(); |
1091 |
// datePicker.requestFocusInWindow(); |
1090 |
SwingUtilities.invokeLater(new Runnable() { |
1092 |
SwingUtilities.invokeLater(new Runnable() { |
|
|
1093 |
@Override |
1091 |
public void run() { |
1094 |
public void run() { |
1092 |
popup.show(datePicker, |
1095 |
popup.show(datePicker, |
1093 |
0, datePicker.getHeight()); |
1096 |
0, datePicker.getHeight()); |
Lines 1114-1119
Link Here
|
1114 |
super("TogglePopup"); |
1117 |
super("TogglePopup"); |
1115 |
} |
1118 |
} |
1116 |
|
1119 |
|
|
|
1120 |
@Override |
1117 |
public void actionPerformed(ActionEvent ev) { |
1121 |
public void actionPerformed(ActionEvent ev) { |
1118 |
toggleShowPopup(); |
1122 |
toggleShowPopup(); |
1119 |
} |
1123 |
} |
Lines 1165-1173
Link Here
|
1165 |
//------------- implement Mouse/MotionListener |
1169 |
//------------- implement Mouse/MotionListener |
1166 |
private boolean _forwardReleaseEvent = false; |
1170 |
private boolean _forwardReleaseEvent = false; |
1167 |
|
1171 |
|
|
|
1172 |
@Override |
1168 |
public void mouseClicked(MouseEvent ev) { |
1173 |
public void mouseClicked(MouseEvent ev) { |
1169 |
} |
1174 |
} |
1170 |
|
1175 |
|
|
|
1176 |
@Override |
1171 |
public void mousePressed(MouseEvent ev) { |
1177 |
public void mousePressed(MouseEvent ev) { |
1172 |
if (!datePicker.isEnabled()) { |
1178 |
if (!datePicker.isEnabled()) { |
1173 |
return; |
1179 |
return; |
Lines 1181-1186
Link Here
|
1181 |
toggleShowPopup(); |
1187 |
toggleShowPopup(); |
1182 |
} |
1188 |
} |
1183 |
|
1189 |
|
|
|
1190 |
@Override |
1184 |
public void mouseReleased(MouseEvent ev) { |
1191 |
public void mouseReleased(MouseEvent ev) { |
1185 |
if (!datePicker.isEnabled() || !datePicker.isEditable()) { |
1192 |
if (!datePicker.isEnabled() || !datePicker.isEditable()) { |
1186 |
return; |
1193 |
return; |
Lines 1196-1207
Link Here
|
1196 |
} |
1203 |
} |
1197 |
} |
1204 |
} |
1198 |
|
1205 |
|
|
|
1206 |
@Override |
1199 |
public void mouseEntered(MouseEvent ev) { |
1207 |
public void mouseEntered(MouseEvent ev) { |
1200 |
} |
1208 |
} |
1201 |
|
1209 |
|
|
|
1210 |
@Override |
1202 |
public void mouseExited(MouseEvent ev) { |
1211 |
public void mouseExited(MouseEvent ev) { |
1203 |
} |
1212 |
} |
1204 |
|
1213 |
|
|
|
1214 |
@Override |
1205 |
public void mouseDragged(MouseEvent ev) { |
1215 |
public void mouseDragged(MouseEvent ev) { |
1206 |
if (!datePicker.isEnabled() || !datePicker.isEditable()) { |
1216 |
if (!datePicker.isEnabled() || !datePicker.isEditable()) { |
1207 |
return; |
1217 |
return; |
Lines 1219-1228
Link Here
|
1219 |
monthView.dispatchEvent(ev); |
1229 |
monthView.dispatchEvent(ev); |
1220 |
} |
1230 |
} |
1221 |
|
1231 |
|
|
|
1232 |
@Override |
1222 |
public void mouseMoved(MouseEvent ev) { |
1233 |
public void mouseMoved(MouseEvent ev) { |
1223 |
} |
1234 |
} |
1224 |
//------------------ implement DateSelectionListener |
1235 |
//------------------ implement DateSelectionListener |
1225 |
|
1236 |
@Override |
1226 |
public void valueChanged(DateSelectionEvent ev) { |
1237 |
public void valueChanged(DateSelectionEvent ev) { |
1227 |
updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting()); |
1238 |
updateFromSelectionChanged(ev.getEventType(), ev.isAdjusting()); |
1228 |
} |
1239 |
} |
Lines 1231-1236
Link Here
|
1231 |
/** |
1242 |
/** |
1232 |
* {@inheritDoc} |
1243 |
* {@inheritDoc} |
1233 |
*/ |
1244 |
*/ |
|
|
1245 |
@Override |
1234 |
public void propertyChange(PropertyChangeEvent e) { |
1246 |
public void propertyChange(PropertyChangeEvent e) { |
1235 |
if (e.getSource() == datePicker) { |
1247 |
if (e.getSource() == datePicker) { |
1236 |
datePickerPropertyChange(e); |
1248 |
datePickerPropertyChange(e); |
Lines 1259-1266
Link Here
|
1259 |
*/ |
1271 |
*/ |
1260 |
private void editorPropertyChange(PropertyChangeEvent evt) { |
1272 |
private void editorPropertyChange(PropertyChangeEvent evt) { |
1261 |
if ("value".equals(evt.getPropertyName())) { |
1273 |
if ("value".equals(evt.getPropertyName())) { |
1262 |
; |
1274 |
|
1263 |
|
|
|
1264 |
Object oldVal = evt.getOldValue(); |
1275 |
Object oldVal = evt.getOldValue(); |
1265 |
Object newVal = evt.getNewValue(); |
1276 |
Object newVal = evt.getNewValue(); |
1266 |
|
1277 |
|
Lines 1353-1371
Link Here
|
1353 |
} |
1364 |
} |
1354 |
|
1365 |
|
1355 |
//-------------- implement LayoutManager |
1366 |
//-------------- implement LayoutManager |
1356 |
|
1367 |
@Override |
1357 |
public void addLayoutComponent(String name, Component comp) { } |
1368 |
public void addLayoutComponent(String name, Component comp) { } |
1358 |
|
1369 |
|
|
|
1370 |
@Override |
1359 |
public void removeLayoutComponent(Component comp) { } |
1371 |
public void removeLayoutComponent(Component comp) { } |
1360 |
|
1372 |
|
|
|
1373 |
@Override |
1361 |
public Dimension preferredLayoutSize(Container parent) { |
1374 |
public Dimension preferredLayoutSize(Container parent) { |
1362 |
return parent.getPreferredSize(); |
1375 |
return parent.getPreferredSize(); |
1363 |
} |
1376 |
} |
1364 |
|
1377 |
|
|
|
1378 |
@Override |
1365 |
public Dimension minimumLayoutSize(Container parent) { |
1379 |
public Dimension minimumLayoutSize(Container parent) { |
1366 |
return parent.getMinimumSize(); |
1380 |
return parent.getMinimumSize(); |
1367 |
} |
1381 |
} |
1368 |
|
1382 |
|
|
|
1383 |
@Override |
1369 |
public void layoutContainer(Container parent) { |
1384 |
public void layoutContainer(Container parent) { |
1370 |
Insets insets = datePicker.getInsets(); |
1385 |
Insets insets = datePicker.getInsets(); |
1371 |
int width = datePicker.getWidth() - insets.left - insets.right; |
1386 |
int width = datePicker.getWidth() - insets.left - insets.right; |
Lines 1389-1397
Link Here
|
1389 |
} |
1404 |
} |
1390 |
|
1405 |
|
1391 |
// ------------- implement actionListener (listening to monthView actionEvent) |
1406 |
// ------------- implement actionListener (listening to monthView actionEvent) |
1392 |
|
1407 |
@Override |
1393 |
public void actionPerformed(ActionEvent e) { |
1408 |
public void actionPerformed(ActionEvent e) { |
1394 |
if (e == null) return; |
1409 |
if (e == null) { |
|
|
1410 |
return; |
1411 |
} |
1395 |
if (e.getSource() == datePicker.getMonthView()) { |
1412 |
if (e.getSource() == datePicker.getMonthView()) { |
1396 |
monthViewActionPerformed(e); |
1413 |
monthViewActionPerformed(e); |
1397 |
} else if (e.getSource() == datePicker.getEditor()) { |
1414 |
} else if (e.getSource() == datePicker.getEditor()) { |
Lines 1430-1437
Link Here
|
1430 |
* Do the same as combo: manually pass-on the focus to the editor. |
1447 |
* Do the same as combo: manually pass-on the focus to the editor. |
1431 |
* |
1448 |
* |
1432 |
*/ |
1449 |
*/ |
|
|
1450 |
@Override |
1433 |
public void focusGained(FocusEvent e) { |
1451 |
public void focusGained(FocusEvent e) { |
1434 |
if (e.isTemporary()) return; |
1452 |
if (e.isTemporary()) { |
|
|
1453 |
return; |
1454 |
} |
1435 |
popupRemover.load(); |
1455 |
popupRemover.load(); |
1436 |
if (e.getSource() == datePicker) { |
1456 |
if (e.getSource() == datePicker) { |
1437 |
datePicker.getEditor().requestFocusInWindow(); |
1457 |
datePicker.getEditor().requestFocusInWindow(); |
Lines 1460-1465
Link Here
|
1460 |
* |
1480 |
* |
1461 |
* listen to keyboardFocusManager? |
1481 |
* listen to keyboardFocusManager? |
1462 |
*/ |
1482 |
*/ |
|
|
1483 |
@Override |
1463 |
public void focusLost(FocusEvent e) { |
1484 |
public void focusLost(FocusEvent e) { |
1464 |
|
1485 |
|
1465 |
} |
1486 |
} |
Lines 1498-1503
Link Here
|
1498 |
unload(true); |
1519 |
unload(true); |
1499 |
} |
1520 |
} |
1500 |
|
1521 |
|
|
|
1522 |
@Override |
1501 |
public void propertyChange(PropertyChangeEvent evt) { |
1523 |
public void propertyChange(PropertyChangeEvent evt) { |
1502 |
if (!isPopupVisible()) { |
1524 |
if (!isPopupVisible()) { |
1503 |
unload(false); |
1525 |
unload(false); |
Lines 1606-1610
Link Here
|
1606 |
|
1628 |
|
1607 |
//------------ utility methods |
1629 |
//------------ utility methods |
1608 |
|
1630 |
|
1609 |
|
1631 |
private Object createDoNotCancelPopupClientProperty() { |
|
|
1632 |
// this is a trick to get hold of the client prop which |
1633 |
// prevents closing of the popup |
1634 |
JComboBox box = new JComboBox(); |
1635 |
return box.getClientProperty("doNotCancelPopup"); |
1610 |
} |
1636 |
} |
|
|
1637 |
} |