DatePickerCellEditor extends AbstractCellEditor implements
        TableCellEditor, TreeCellEditor { @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { ignoreAction = true; datePicker.setDate(getValueAsDate(value)); ignoreAction = false; return datePicker; } DatePickerCellEditor();  DatePickerCellEditor(DateFormat dateFormat); @Override Date getCellEditorValue(); @Override boolean isCellEditable(EventObject anEvent); @Override boolean stopCellEditing(); void setClickCountToStart(int count); int getClickCountToStart(); @Override Component getTableCellEditorComponent(JTable table, Object value,
            boolean isSelected, int row, int column); @Override Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row); DateFormat[] getFormats(); void setFormats(DateFormat... formats);  }
@Test public void testDateEditorFireStopMonthAccept() { DatePickerCellEditor editor = new DatePickerCellEditor(); final CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); JXDatePicker picker = (JXDatePicker) editor.getTableCellEditorComponent (null, new Date(), false, -1, -1); picker.getMonthView().commitSelection(); assertEquals(1, report.getEventCount()); assertEquals(1, report.getStoppedEventCount()); }
@Test public void testDateEditorFireStopMonthCancel() { DatePickerCellEditor editor = new DatePickerCellEditor(); final CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); JXDatePicker picker = (JXDatePicker) editor.getTableCellEditorComponent (null, new Date(), false, -1, -1); picker.getMonthView().cancelSelection(); assertEquals(1, report.getEventCount()); assertEquals(1, report.getCanceledEventCount()); }
@Test public void testDateEditorFireStopPickerCommit() throws ParseException { DatePickerCellEditor editor = new DatePickerCellEditor(); final CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); JXDatePicker picker = (JXDatePicker) editor.getTableCellEditorComponent (null, null, false, -1, -1); picker.commitEdit(); assertEquals(1, report.getEventCount()); assertEquals(1, report.getStoppedEventCount()); }
@Test public void testDateEditorFireCancelPickerCancel() throws ParseException { DatePickerCellEditor editor = new DatePickerCellEditor(); final CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); JXDatePicker picker = (JXDatePicker) editor .getTableCellEditorComponent(null, new Date(), false, -1, -1); picker.cancelEdit(); assertEquals(1, report.getEventCount()); assertEquals(1, report.getCanceledEventCount()); }
@Test public void testDateEditorFireCancel() { DatePickerCellEditor editor = new DatePickerCellEditor(); CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); editor.getTableCellEditorComponent(null, null, false, -1, -1); editor.cancelCellEditing(); assertEquals(1, report.getEventCount()); assertEquals(1, report.getCanceledEventCount()); }
@Test public void testDateEditorNotFire() { DatePickerCellEditor editor = new DatePickerCellEditor(); CellEditorReport report = new CellEditorReport(); editor.addCellEditorListener(report); editor.getTableCellEditorComponent(null, null, false, -1, -1); assertEquals(0, report.getEventCount()); }