// initial layout
VBox lMenuVBox = new VBox(padding);
lBorderPane.setCenter(lMenuVBox);
// time
lMenuVBox.getChildren().add(new Text("Time:"));
// start
final CalendarTextField lStartCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
lStartCalendarTextField.setLocale(getSkinnable().getLocale());
lStartCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getStartTime());
lMenuVBox.getChildren().add(lStartCalendarTextField);
// end
final CalendarTextField lEndCalendarTextField = new CalendarTextField().withDateFormat(SimpleDateFormat.getDateTimeInstance());
lEndCalendarTextField.setLocale(getSkinnable().getLocale());
lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
lMenuVBox.getChildren().add(lEndCalendarTextField);
lEndCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
{
@Override
public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
{
abstractAppointmentPane.appointment.setEndTime(newValue);
// refresh is done upon popup close
}
});
lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
// wholeday
if ((abstractAppointmentPane.appointment.isWholeDay() != null && abstractAppointmentPane.appointment.isWholeDay() == true) || abstractAppointmentPane.appointment.getEndTime() != null)
{
final CheckBox lWholedayCheckBox = new CheckBox("Wholeday");
lWholedayCheckBox.setId("wholeday-checkbox");
lWholedayCheckBox.selectedProperty().set(abstractAppointmentPane.appointment.isWholeDay());
lMenuVBox.getChildren().add(lWholedayCheckBox);
lWholedayCheckBox.selectedProperty().addListener(new ChangeListener<Boolean>()
{
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldValue, Boolean newValue)
{
abstractAppointmentPane.appointment.setWholeDay(newValue);
if (newValue == true)
{
abstractAppointmentPane.appointment.setEndTime(null);
}
else
{
Calendar lEndTime = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
lEndTime.add(Calendar.MINUTE, 30);
abstractAppointmentPane.appointment.setEndTime(lEndTime);
lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
}
lEndCalendarTextField.setVisible(abstractAppointmentPane.appointment.getEndTime() != null);
// refresh is done upon popup close
}
});
}
// event handling
lStartCalendarTextField.calendarProperty().addListener(new ChangeListener<Calendar>()
{
@Override
public void changed(ObservableValue<? extends Calendar> arg0, Calendar oldValue, Calendar newValue)
{
// enddate
if (abstractAppointmentPane.appointment.isWholeDay())
{
abstractAppointmentPane.appointment.setStartTime(newValue);
}
else
{
// remember
Calendar lOldStart = abstractAppointmentPane.appointment.getStartTime();
// set
abstractAppointmentPane.appointment.setStartTime(newValue);
// end date
if (abstractAppointmentPane.appointment.getEndTime() != null)
{
long lDurationInMS = abstractAppointmentPane.appointment.getEndTime().getTimeInMillis() - lOldStart.getTimeInMillis();
Calendar lEndCalendar = (Calendar)abstractAppointmentPane.appointment.getStartTime().clone();
lEndCalendar.add(Calendar.MILLISECOND, (int)lDurationInMS);
abstractAppointmentPane.appointment.setEndTime(lEndCalendar);
// update field
lEndCalendarTextField.setCalendar(abstractAppointmentPane.appointment.getEndTime());
}
// refresh is done upon popup close
}
}
});
// summary
lMenuVBox.getChildren().add(new Text("Summary:"));
TextField lSummaryTextField = new TextField();
lSummaryTextField.setText(abstractAppointmentPane.appointment.getSummary());
lSummaryTextField.textProperty().addListener(new ChangeListener<String>()
{
@Override
public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
{
abstractAppointmentPane.appointment.setSummary(newValue);
// refresh is done upon popup close
}
});
lMenuVBox.getChildren().add(lSummaryTextField);
// location
lMenuVBox.getChildren().add(new Text("Location:"));
TextField lLocationTextField = new TextField();
lLocationTextField.setText( abstractAppointmentPane.appointment.getLocation() == null ? "" : abstractAppointmentPane.appointment.getLocation());
lLocationTextField.textProperty().addListener(new ChangeListener<String>()
{
@Override
public void changed(ObservableValue<? extends String> arg0, String oldValue, String newValue)
{
abstractAppointmentPane.appointment.setLocation(newValue);
// refresh is done upon popup close
}
});
lMenuVBox.getChildren().add(lLocationTextField);
// actions
lMenuVBox.getChildren().add(new Text("Actions:")); // TODO: internationalize
HBox lHBox = new HBox();
lMenuVBox.getChildren().add(lHBox);
// delete
{
// close icon
ImageViewButton lImageView = new ImageViewButton();
lImageView.getStyleClass().add("delete-icon");
lImageView.setPickOnBounds(true);
lImageView.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override public void handle(MouseEvent evt)
{
lPopup.hide();
getSkinnable().appointments().remove(abstractAppointmentPane.appointment);
// refresh is done via the collection events
}
});
Tooltip.install(lImageView, new Tooltip("Delete")); // TODO: internationalize
lHBox.getChildren().add(lImageView);
}
// construct a area of appointment groups
lMenuVBox.getChildren().add(new Text("Group:"));
GridPane lAppointmentGroupGridPane = new GridPane();
lMenuVBox.getChildren().add(lAppointmentGroupGridPane);
lAppointmentGroupGridPane.getStyleClass().add("AppointmentGroups");
lAppointmentGroupGridPane.setHgap(2);
lAppointmentGroupGridPane.setVgap(2);