refactor heavily
This commit is contained in:
parent
6ac0bec9b8
commit
c7a8d43aa8
|
@ -63,12 +63,7 @@ public class NewTodoItemStrategy extends VBox {
|
|||
}
|
||||
});
|
||||
|
||||
typeBox.setOnAction(e -> {
|
||||
NewItemBuilder.IFactory fac = typeBox.getValue();
|
||||
NewItemBuilder b = fac.construct(mNowParent);
|
||||
setBuilder(b);
|
||||
});
|
||||
|
||||
typeBox.setOnAction(e -> onClickTypeBox());
|
||||
closeBtn.setOnAction(e -> onClickClose());
|
||||
finishBtn.setOnAction(e -> onClickFinish());
|
||||
}
|
||||
|
@ -92,9 +87,11 @@ public class NewTodoItemStrategy extends VBox {
|
|||
}
|
||||
}
|
||||
|
||||
private void setBuilder(@NotNull NewItemBuilder builder) {
|
||||
private void setBuilder(@Nullable NewItemBuilder builder) {
|
||||
builderBox.getChildren().clear();
|
||||
builderBox.getChildren().add(builder);
|
||||
if (builder != null) {
|
||||
builderBox.getChildren().add(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +108,7 @@ public class NewTodoItemStrategy extends VBox {
|
|||
return;
|
||||
}
|
||||
|
||||
Object[] newItems = b.buildItem();
|
||||
Object[] newItems = b.buildItems();
|
||||
if (newItems.length <= 0) { // fail
|
||||
return;
|
||||
}
|
||||
|
@ -135,6 +132,26 @@ public class NewTodoItemStrategy extends VBox {
|
|||
onClickClose();
|
||||
}
|
||||
|
||||
private void onClickTypeBox() {
|
||||
if (typeBox.getSelectionModel().isEmpty()) {
|
||||
setBuilder(null);
|
||||
return;
|
||||
}
|
||||
|
||||
NewItemBuilder.IFactory fac = typeBox.getValue();
|
||||
if (mNowParent == null) {
|
||||
NewItemBuilder b = fac.construct();
|
||||
setBuilder(b);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fac.supportedConstructWithParent()) {
|
||||
NewItemBuilder b = fac.constructWithParent(mNowParent);
|
||||
setBuilder(b);
|
||||
} else {
|
||||
mPresenter.showAlert(0, "不支持添加子任务");
|
||||
}
|
||||
}
|
||||
|
||||
// region Presenter new to-do item
|
||||
|
||||
|
@ -148,9 +165,7 @@ public class NewTodoItemStrategy extends VBox {
|
|||
|
||||
public void showNewChildTodoItemStage(@Nullable TodoItem parent) {
|
||||
mNowParent = parent;
|
||||
if (!typeBox.getItems().isEmpty()) {
|
||||
typeBox.getSelectionModel().selectFirst();
|
||||
}
|
||||
typeBox.getSelectionModel().clearSelection();
|
||||
mNewItemStage.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package org.cutem.cutecalendar.presenter.autoset;
|
||||
|
||||
import javafx.beans.property.StringProperty;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface AutoSet {
|
||||
|
||||
void wholeDay(@NotNull StringProperty text);
|
||||
|
||||
void timeSegment(@NotNull StringProperty bgn, @NotNull StringProperty end);
|
||||
|
||||
void personnel(@NotNull StringProperty text);
|
||||
|
||||
void stringProperty(@NotNull String key, @NotNull StringProperty value, @NotNull String alertInfo);
|
||||
|
||||
void autoApply(@NotNull TodoItem item);
|
||||
|
||||
boolean autoCheck();
|
||||
|
||||
TodoItemFactory autoBuild();
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
package org.cutem.cutecalendar.presenter.autoset;
|
||||
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.scene.control.Alert;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.cutem.cutecalendar.model.TodoItemUtil;
|
||||
import org.cutem.cutecalendar.util.CalendarUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.cutem.cutecalendar.model.TodoItem.*;
|
||||
|
||||
public class AutoSetImpl implements AutoSet {
|
||||
|
||||
private static final int NOT_SET = 1;
|
||||
private static final int WHOLE_DAY_SET = 2;
|
||||
private static final int TIME_SEG_SET = 3;
|
||||
|
||||
private int lastSet = NOT_SET;
|
||||
private StringProperty mWholeDay;
|
||||
private StringProperty mBgnTime;
|
||||
private StringProperty mEndTime;
|
||||
|
||||
private StringProperty mPersonnel;
|
||||
|
||||
private HashMap<String, StringProperty> mProps = new HashMap<>();
|
||||
private HashMap<String, String> mAlertInfo = new HashMap<>();
|
||||
|
||||
|
||||
@Override
|
||||
public void wholeDay(@NotNull StringProperty text) {
|
||||
mWholeDay = text;
|
||||
lastSet = WHOLE_DAY_SET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeSegment(@NotNull StringProperty bgn, @NotNull StringProperty end) {
|
||||
mBgnTime = bgn;
|
||||
mEndTime = end;
|
||||
lastSet = TIME_SEG_SET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void personnel(@NotNull StringProperty text) {
|
||||
mPersonnel = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stringProperty(@NotNull String key, @NotNull StringProperty value, @NotNull String alertInfo) {
|
||||
mProps.put(key, value);
|
||||
mAlertInfo.put(key, alertInfo);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void autoApply(@NotNull TodoItem item) {
|
||||
throw new UnsupportedOperationException("autoApply not supported");
|
||||
}
|
||||
|
||||
|
||||
private boolean checkTimeSegment() {
|
||||
String b = mBgnTime.getValue();
|
||||
String e = mEndTime.getValue();
|
||||
|
||||
if (!CalendarUtil.isValidCalendarString(b) || !CalendarUtil.isValidCalendarString(e)) {
|
||||
showAlert("开始或是结束时间不合法");
|
||||
return false;
|
||||
}
|
||||
|
||||
Calendar c1 = CalendarUtil.constructCalendar(b);
|
||||
Calendar c2 = CalendarUtil.constructCalendar(e);
|
||||
|
||||
if (c2.before(c1)) {
|
||||
showAlert("开始时间在结束时间后");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkWholeDay() {
|
||||
String t = mWholeDay.getValue() + "/0:0";
|
||||
if (!CalendarUtil.isValidCalendarString(t)) {
|
||||
showAlert("时间格式不合法");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkTime() {
|
||||
if (lastSet == TIME_SEG_SET) {
|
||||
return checkTimeSegment();
|
||||
} else if (lastSet == WHOLE_DAY_SET) {
|
||||
return checkWholeDay();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkPersonnel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkFormation(@NotNull String key, @NotNull String value) {
|
||||
switch (key) {
|
||||
case ALARM_METHOD:
|
||||
return Objects.equals(value, "area")
|
||||
|| Objects.equals(value, "dialog")
|
||||
|| Objects.equals(value, "none");
|
||||
case ALARM_INTERVAL:
|
||||
return TodoItemUtil.isValidAlarmIntString(value);
|
||||
case ALARM_START:
|
||||
return CalendarUtil.isValidCalendarString(value);
|
||||
case REPEAT_WEEKS:
|
||||
return value.matches("\\d+");
|
||||
default:
|
||||
return !value.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkProps() {
|
||||
for (Map.Entry<String, StringProperty> e : mProps.entrySet()) {
|
||||
String key = e.getKey();
|
||||
String val = e.getValue().getValue();
|
||||
if (!checkFormation(key, val)) {
|
||||
String info = mAlertInfo.get(key);
|
||||
|
||||
showAlert(info);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean autoCheck() {
|
||||
return checkTime() && checkPersonnel() && checkProps();
|
||||
}
|
||||
|
||||
|
||||
private void buildTime(TodoItemFactory factory) {
|
||||
if (lastSet == WHOLE_DAY_SET) {
|
||||
String t = mWholeDay.getValue() + "/0:0";
|
||||
Calendar c = CalendarUtil.constructCalendar(t);
|
||||
factory.wholeDay(c);
|
||||
} else if (lastSet == TIME_SEG_SET) {
|
||||
String b = mBgnTime.getValue();
|
||||
String e = mEndTime.getValue();
|
||||
Calendar c1 = CalendarUtil.constructCalendar(b);
|
||||
Calendar c2 = CalendarUtil.constructCalendar(e);
|
||||
factory.beginTime(c1).endTime(c2);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildPersonnel(TodoItemFactory factory) {
|
||||
if (mPersonnel != null && !mPersonnel.getValue().isEmpty()) {
|
||||
String[] ps = mPersonnel.getValue().split("[;,]");
|
||||
factory.personnel(Arrays.asList(ps));
|
||||
}
|
||||
}
|
||||
|
||||
private void buildProps(TodoItemFactory factory) {
|
||||
for (Map.Entry<String, StringProperty> e : mProps.entrySet()) {
|
||||
String key = e.getKey();
|
||||
String val = e.getValue().getValue();
|
||||
factory.stringProperties(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TodoItemFactory autoBuild() {
|
||||
TodoItemFactory fac = new TodoItemFactory();
|
||||
buildTime(fac);
|
||||
buildPersonnel(fac);
|
||||
buildProps(fac);
|
||||
return fac;
|
||||
}
|
||||
|
||||
|
||||
private void showAlert(String text) {
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setContentText(text);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.cutem.cutecalendar.util.CalendarUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class AnniversaryTypeNewItemBuilder extends NewItemBuilder {
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new AnniversaryTypeNewItemBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ANNI_TYPE_LAYOUT = "fxml/newitem_layouts/anniversary_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.ANNIVERSARY;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField dateTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField typeText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
|
||||
protected AnniversaryTypeNewItemBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(ANNI_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
|
||||
addAutoSet(TodoItem.TITLE, titleText.textProperty(), "请填写描述");
|
||||
addAutoSet("type", typeText.textProperty(), "请填写纪念日类型");
|
||||
addAutoSet(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写描述");
|
||||
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
if (!autoCheck()) {
|
||||
return false;
|
||||
}
|
||||
String date = dateTimeText.getText() + "/0:0";
|
||||
if (!CalendarUtil.isValidCalendarString(date)) {
|
||||
showAlert("时间不合法");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String date = dateTimeText.getText() + "/0:0";
|
||||
Calendar c = CalendarUtil.constructCalendar(date);
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.wholeDay(c)
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ConferenceTypeNewItemBuilder extends NewItemBuilder {
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new ConferenceTypeNewItemBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CONFERENCE_TYPE_LAYOUT = "fxml/newitem_layouts/conference_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.CONFERENCE;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
|
||||
|
||||
protected ConferenceTypeNewItemBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(CONFERENCE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
addAutoCheckTime(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
|
||||
addAutoSet(TodoItem.TITLE, titleText.textProperty(), "请填写议题");
|
||||
addAutoSet(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
addAutoSet(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写会议内容");
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TodoItem make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CourseTypeBuilder extends NewItemBuilder {
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new CourseTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String COURSE_TYPE_LAYOUT = "fxml/newitem_layouts/course_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.COURSE;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField repeatText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField contentText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
|
||||
protected CourseTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(COURSE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
addAutoCheckTime(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
|
||||
addAutoSet(TodoItem.REPEAT_WEEKS, repeatText.textProperty(), "重复的周数不合法");
|
||||
addAutoSet(TodoItem.TITLE, titleText.textProperty(), "请填写课程名");
|
||||
addAutoSet("content", contentText.textProperty(), "请填写上课内容");
|
||||
addAutoSet(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
addAutoSet(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写备注");
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DateTypeBuilder extends NewItemBuilder {
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new DateTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String DATE_TYPE_LAYOUT = "fxml/newitem_layouts/date_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.DATE;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField personnelText;
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
|
||||
protected DateTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(DATE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
addAutoCheckTime(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
|
||||
addAutoSet(TodoItem.TITLE, titleText.textProperty(), "请填写内容");
|
||||
addAutoSet(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String personnel = personnelText.getText();
|
||||
String[] pSlices = personnel.split("[;,]");
|
||||
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.personnel(Arrays.asList(pSlices))
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemManager;
|
||||
import org.cutem.cutecalendar.model.TodoItemUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class GeneralBuilder extends NewItemBuilder {
|
||||
|
||||
private TodoItem mParent;
|
||||
|
||||
protected GeneralBuilder() {
|
||||
// empty
|
||||
}
|
||||
|
||||
protected GeneralBuilder(@Nullable TodoItem parent) {
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
|
||||
protected abstract boolean check();
|
||||
|
||||
protected abstract TodoItem make();
|
||||
|
||||
private boolean checkConflict(@NotNull TodoItem newItem) {
|
||||
if (mParent != null && !TodoItemUtil.canBind(mParent, newItem)) {
|
||||
return false;
|
||||
}
|
||||
Collection<TodoItem> items = TodoItemManager.getInstance().getItems();
|
||||
|
||||
for (TodoItem item : items) {
|
||||
if (!Objects.equals(item, mParent) &&
|
||||
TodoItemUtil.isIntersectedConflict(item, newItem)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Object[] buildFinal(@NotNull TodoItem item) {
|
||||
if (mParent != null) {
|
||||
TodoItem[] items = TodoItemUtil.bind(mParent, item);
|
||||
return new Object[]{items[0], items[1]};
|
||||
} else {
|
||||
return new Object[]{item};
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public final Object[] buildItems() {
|
||||
if (!check()) {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
TodoItem o = make();
|
||||
if (!checkConflict(o)) {
|
||||
showAlert("有冲突");
|
||||
return new Object[0];
|
||||
} else {
|
||||
return buildFinal(o);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InterviewTypeNewItemBuilder extends NewItemBuilder {
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new InterviewTypeNewItemBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final int TYPE = TodoItem.INTERVIEW;
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
private static final String INTERVIEW_TYPE_LAYOUT = "fxml/newitem_layouts/interview_type_layout.fxml";
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField companyText;
|
||||
@FXML
|
||||
private TextField jobText;
|
||||
@FXML
|
||||
private TextField remarkText;
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
protected InterviewTypeNewItemBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(INTERVIEW_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
addAutoCheckTime(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
addAutoSet(TodoItem.LOCATION, locationText.textProperty(), "请添加地点");
|
||||
addAutoSet(TodoItem.TITLE, remarkText.textProperty(), "请填写备注");
|
||||
addAutoSet("company", companyText.textProperty(), "请填写公司");
|
||||
addAutoSet("岗位", companyText.textProperty(), "请填写岗位");
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,186 +1,49 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.beans.property.ReadOnlyStringProperty;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.cutem.cutecalendar.model.TodoItemManager;
|
||||
import org.cutem.cutecalendar.model.TodoItemUtil;
|
||||
import org.cutem.cutecalendar.util.CalendarUtil;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSetImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static org.cutem.cutecalendar.model.TodoItem.*;
|
||||
|
||||
public abstract class NewItemBuilder extends VBox {
|
||||
|
||||
public interface IFactory {
|
||||
|
||||
int getType();
|
||||
String getTypeName();
|
||||
|
||||
NewItemBuilder construct(@Nullable TodoItem parent);
|
||||
}
|
||||
boolean supportedConstruct();
|
||||
|
||||
private ClassLoader mClassLoader = getClass().getClassLoader();
|
||||
NewItemBuilder construct();
|
||||
|
||||
private TodoItem mParent;
|
||||
boolean supportedConstructWithParent();
|
||||
|
||||
private HashMap<String, ReadOnlyStringProperty> mAutoSet = new HashMap<>();
|
||||
private HashMap<String, String> mAutoAlertInfo = new HashMap<>();
|
||||
private ReadOnlyStringProperty mBgnTime;
|
||||
private ReadOnlyStringProperty mEndTime;
|
||||
NewItemBuilder constructWithParent(@NotNull TodoItem parent);
|
||||
|
||||
boolean supportedConstructWithOldItem();
|
||||
|
||||
|
||||
protected NewItemBuilder(TodoItem parent) {
|
||||
mParent = parent;
|
||||
}
|
||||
|
||||
|
||||
public String getTypeName() {
|
||||
throw new UnsupportedOperationException("not supported");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Object[] buildItem() {
|
||||
if (!check()) {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
Object o = make();
|
||||
if (o instanceof TodoItem) {
|
||||
TodoItem item = (TodoItem) o;
|
||||
if (!checkConflict(item)) {
|
||||
showAlert("有冲突");
|
||||
return new Object[0];
|
||||
}
|
||||
return buildFinal(item);
|
||||
} else {
|
||||
return new Object[]{o};
|
||||
}
|
||||
NewItemBuilder constructWithOldItem(@NotNull TodoItem oldItem);
|
||||
|
||||
}
|
||||
|
||||
protected abstract boolean check();
|
||||
private AutoSetImpl mAutoSet;
|
||||
|
||||
protected abstract Object make();
|
||||
|
||||
private boolean checkConflict(@NotNull TodoItem newItem) {
|
||||
if (mParent != null && !TodoItemUtil.canBind(mParent, newItem)) {
|
||||
return false;
|
||||
}
|
||||
Collection<TodoItem> items = TodoItemManager.getInstance().getItems();
|
||||
// region tools part for subclasses
|
||||
|
||||
for (TodoItem item : items) {
|
||||
if (!Objects.equals(item, mParent) &&
|
||||
TodoItemUtil.isIntersectedConflict(item, newItem)) {
|
||||
return false;
|
||||
}
|
||||
protected final AutoSet getAutoSet() {
|
||||
if (mAutoSet == null) {
|
||||
mAutoSet = new AutoSetImpl();
|
||||
}
|
||||
|
||||
return true;
|
||||
return mAutoSet;
|
||||
}
|
||||
|
||||
private Object[] buildFinal(@NotNull TodoItem item) {
|
||||
if (mParent != null) {
|
||||
TodoItem[] items = TodoItemUtil.bind(mParent, item);
|
||||
return new Object[]{items[0], items[1]};
|
||||
} else {
|
||||
return new Object[]{item};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// region tools part
|
||||
|
||||
protected void addAutoCheckTime(@NotNull ReadOnlyStringProperty bgn, @NotNull ReadOnlyStringProperty end) {
|
||||
mBgnTime = bgn;
|
||||
mEndTime = end;
|
||||
}
|
||||
|
||||
protected void addAutoSet(@NotNull String key, @NotNull ReadOnlyStringProperty prop, @Nullable String alertInfo) {
|
||||
mAutoSet.put(key, prop);
|
||||
|
||||
if (alertInfo != null) {
|
||||
mAutoAlertInfo.put(key, alertInfo);
|
||||
} else {
|
||||
mAutoAlertInfo.put(key, "there is something wrong");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean autoCheck() {
|
||||
for (Map.Entry<String, ReadOnlyStringProperty> e : mAutoSet.entrySet()) {
|
||||
String key = e.getKey();
|
||||
String val = e.getValue().getValue();
|
||||
if (!checkFormation(key, val)) {
|
||||
String info = mAutoAlertInfo.get(key);
|
||||
showAlert(info);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mBgnTime != null && mEndTime != null) {
|
||||
String b = mBgnTime.getValue();
|
||||
String e = mEndTime.getValue();
|
||||
|
||||
if (!CalendarUtil.isValidCalendarString(b) || !CalendarUtil.isValidCalendarString(e)) {
|
||||
showAlert("开始或是结束时间不合法");
|
||||
return false;
|
||||
}
|
||||
Calendar c1 = CalendarUtil.constructCalendar(b);
|
||||
Calendar c2 = CalendarUtil.constructCalendar(e);
|
||||
if (c2.before(c1)) {
|
||||
showAlert("开始时间在结束时间后");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected TodoItemFactory autoBuild() {
|
||||
TodoItemFactory factory = new TodoItemFactory();
|
||||
|
||||
for (Map.Entry<String, ReadOnlyStringProperty> e : mAutoSet.entrySet()) {
|
||||
String key = e.getKey();
|
||||
String val = e.getValue().getValue();
|
||||
factory.stringProperties(key, val);
|
||||
}
|
||||
|
||||
if (mBgnTime != null && mEndTime != null) {
|
||||
String b = mBgnTime.getValue();
|
||||
String e = mEndTime.getValue();
|
||||
Calendar c1 = CalendarUtil.constructCalendar(b);
|
||||
Calendar c2 = CalendarUtil.constructCalendar(e);
|
||||
factory.beginTime(c1).endTime(c2);
|
||||
}
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
protected boolean checkFormation(@NotNull String key, @NotNull String value) {
|
||||
switch (key) {
|
||||
case ALARM_START:
|
||||
return CalendarUtil.isValidCalendarString(value);
|
||||
case REPEAT_WEEKS:
|
||||
return value.matches("\\d+");
|
||||
case ALARM_INTERVAL:
|
||||
return TodoItemUtil.isValidAlarmIntString(value);
|
||||
case ALARM_METHOD:
|
||||
return Objects.equals(value, "area")
|
||||
|| Objects.equals(value, "dialog")
|
||||
|| Objects.equals(value, "none");
|
||||
default:
|
||||
return !value.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected final void showAlert(@NotNull String text) {
|
||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||
alert.setContentText(text);
|
||||
|
@ -188,18 +51,22 @@ public abstract class NewItemBuilder extends VBox {
|
|||
}
|
||||
|
||||
protected final void loadLayout(@NotNull String location) {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setLocation(mClassLoader.getResource(location));
|
||||
loader.setLocation(classLoader.getResource(location));
|
||||
loader.setRoot(this);
|
||||
loader.setController(this);
|
||||
|
||||
try {
|
||||
loader.load();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("cannot load: " + location);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// endregion tools part
|
||||
// endregion tools part for subclasses
|
||||
|
||||
@NotNull
|
||||
public abstract Object[] buildItems();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class OtherTypeNewItemBuilder extends NewItemBuilder {
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new OtherTypeNewItemBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String OTHER_TYPE_LAYOUT = "fxml/newitem_layouts/other_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
private ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
private TextField alarmStartText;
|
||||
@FXML
|
||||
private TextField alarmIntervalText;
|
||||
|
||||
|
||||
protected OtherTypeNewItemBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(OTHER_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
addAutoCheckTime(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
|
||||
addAutoSet(TodoItem.TITLE, titleText.textProperty(), "请填写描述");
|
||||
addAutoSet(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒的开始时间不合法");
|
||||
addAutoSet(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒的间隔时间不合法");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TodoItem make() {
|
||||
TodoItemFactory fac = autoBuild();
|
||||
|
||||
String priority = priorityBox.getValue();
|
||||
String importance = importanceBox.getValue();
|
||||
String alarmMethod = alarmMethodBox.getValue();
|
||||
|
||||
return fac.type(TYPE)
|
||||
.stringProperties(TodoItem.PRIORITY, priority)
|
||||
.stringProperties(TodoItem.IMPORTANCE, importance)
|
||||
.stringProperties(TodoItem.ALARM_METHOD, alarmMethod)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TimelessTypeBuilder extends NewItemBuilder {
|
||||
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct(@Nullable TodoItem parent) {
|
||||
return new TimelessTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TIMELESS_LAYOUT = "fxml/newitem_layouts/timeless_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
|
||||
private static final String TYPE_NAME = "others without time";
|
||||
|
||||
private boolean mHaveParent;
|
||||
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
|
||||
|
||||
protected TimelessTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
mHaveParent = parent != null;
|
||||
loadLayout(TIMELESS_LAYOUT);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
|
||||
if (mHaveParent) {
|
||||
showAlert("不能添加子事件");
|
||||
return false;
|
||||
}
|
||||
|
||||
String title = titleText.getText().trim();
|
||||
|
||||
if (title.isEmpty()) {
|
||||
showAlert("描述还没有填");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String make() {
|
||||
return titleText.getText().trim();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class AnniversaryTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<AnniversaryTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnniversaryTypeBuilder construct() {
|
||||
return new AnniversaryTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnniversaryTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new AnniversaryTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ANNI_TYPE_LAYOUT = "fxml/newitem_layouts/anniversary_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.ANNIVERSARY;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField wholeDayText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField typeText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
|
||||
private AnniversaryTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(ANNI_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
AutoSet a = getAutoSet();
|
||||
a.wholeDay(wholeDayText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写纪念日名字");
|
||||
a.stringProperty("类型", typeText.textProperty(), "请填写类型");
|
||||
a.stringProperty(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写描述");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.model.TodoItemFactory;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.cutem.cutecalendar.presenter.newitems.GeneralBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
abstract class BaseTodoItemBuilder extends GeneralBuilder {
|
||||
|
||||
protected static abstract class BaseFactory<T extends BaseTodoItemBuilder> implements IFactory {
|
||||
@Override
|
||||
public boolean supportedConstruct() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T construct();
|
||||
|
||||
@Override
|
||||
public boolean supportedConstructWithParent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T constructWithParent(@NotNull TodoItem parent);
|
||||
|
||||
@Override
|
||||
public boolean supportedConstructWithOldItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T constructWithOldItem(@NotNull TodoItem oldItem) {
|
||||
throw new UnsupportedOperationException("constructWithOldItem not supported");
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected ChoiceBox<String> priorityBox;
|
||||
@FXML
|
||||
protected ChoiceBox<String> importanceBox;
|
||||
@FXML
|
||||
protected ChoiceBox<String> alarmMethodBox;
|
||||
@FXML
|
||||
protected TextField alarmStartText;
|
||||
@FXML
|
||||
protected TextField alarmIntervalText;
|
||||
|
||||
|
||||
protected BaseTodoItemBuilder(@Nullable TodoItem parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
||||
protected abstract int getType();
|
||||
|
||||
@FXML
|
||||
protected void initialize() {
|
||||
|
||||
StringProperty p = new SimpleStringProperty();
|
||||
p.bind(priorityBox.valueProperty());
|
||||
|
||||
StringProperty i = new SimpleStringProperty();
|
||||
i.bind(importanceBox.valueProperty());
|
||||
|
||||
StringProperty m = new SimpleStringProperty();
|
||||
m.bind(alarmMethodBox.valueProperty());
|
||||
|
||||
AutoSet s = getAutoSet();
|
||||
|
||||
s.stringProperty(TodoItem.PRIORITY, p, "优先级不合法");
|
||||
s.stringProperty(TodoItem.IMPORTANCE, i, "重要度不合法");
|
||||
s.stringProperty(TodoItem.ALARM_METHOD, m, "提醒方式不合法");
|
||||
s.stringProperty(TodoItem.ALARM_START, alarmStartText.textProperty(), "提醒时间不合法");
|
||||
s.stringProperty(TodoItem.ALARM_INTERVAL, alarmIntervalText.textProperty(), "提醒间隔不合法");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean check() {
|
||||
return getAutoSet().autoCheck();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TodoItem make() {
|
||||
TodoItemFactory fac = getAutoSet().autoBuild();
|
||||
return fac.type(getType()).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class ConferenceTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<ConferenceTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConferenceTypeBuilder construct() {
|
||||
return new ConferenceTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConferenceTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new ConferenceTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CONFERENCE_TYPE_LAYOUT = "fxml/newitem_layouts/conference_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.CONFERENCE;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
|
||||
private ConferenceTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(CONFERENCE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
AutoSet a = getAutoSet();
|
||||
a.timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写议题");
|
||||
a.stringProperty(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
a.stringProperty(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写会议内容");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class CourseTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<CourseTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseTypeBuilder construct() {
|
||||
return new CourseTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new CourseTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String COURSE_TYPE_LAYOUT = "fxml/newitem_layouts/course_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField repeatText;
|
||||
@FXML
|
||||
private TextField contentText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField teacherText;
|
||||
@FXML
|
||||
private TextField descriptionText;
|
||||
|
||||
private CourseTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(COURSE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
AutoSet a = getAutoSet();
|
||||
a.timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写课程名字");
|
||||
a.stringProperty(TodoItem.REPEAT_WEEKS, repeatText.textProperty(), "请填写重复周数");
|
||||
a.stringProperty("课程内容", contentText.textProperty(), "请填写课程内容");
|
||||
a.stringProperty(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
a.stringProperty("老师", teacherText.textProperty(), "请填写老师");
|
||||
a.stringProperty(TodoItem.DESCRIPTION, descriptionText.textProperty(), "请填写备注");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class DateTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<DateTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTypeBuilder construct() {
|
||||
return new DateTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new DateTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String DATE_TYPE_LAYOUT = "fxml/newitem_layouts/date_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.DATE;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField personnelText;
|
||||
|
||||
private DateTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(DATE_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
AutoSet a = getAutoSet();
|
||||
a.timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写内容");
|
||||
a.stringProperty(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
a.personnel(personnelText.textProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class InterviewTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<InterviewTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterviewTypeBuilder construct() {
|
||||
return new InterviewTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterviewTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new InterviewTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String INTERVIEW_TYPE_LAYOUT = "fxml/newitem_layouts/interview_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField companyText;
|
||||
@FXML
|
||||
private TextField jobText;
|
||||
|
||||
private InterviewTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(INTERVIEW_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
AutoSet a = getAutoSet();
|
||||
a.timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写备注");
|
||||
a.stringProperty(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
a.stringProperty("公司", companyText.textProperty(), "请填写公司");
|
||||
a.stringProperty("岗位", jobText.textProperty(), "请填写岗位");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class OtherTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<OtherTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OtherTypeBuilder construct() {
|
||||
return new OtherTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OtherTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new OtherTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String OTHER_TYPE_LAYOUT = "fxml/newitem_layouts/other_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
|
||||
private OtherTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(OTHER_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
getAutoSet().timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
getAutoSet().stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写描述");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.newitems.NewItemBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class TimelessTypeBuilder extends NewItemBuilder {
|
||||
|
||||
public static class Factory implements IFactory {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportedConstruct() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder construct() {
|
||||
return new TimelessTypeBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportedConstructWithParent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
throw new UnsupportedOperationException("connstructWithParent not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportedConstructWithOldItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewItemBuilder constructWithOldItem(@NotNull TodoItem oldItem) {
|
||||
throw new UnsupportedOperationException("connstructWithOldItem not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TIMELESS_LAYOUT = "fxml/newitem_layouts/timeless_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.OTHERS;
|
||||
private static final String TYPE_NAME = "others without time";
|
||||
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
|
||||
private TimelessTypeBuilder() {
|
||||
loadLayout(TIMELESS_LAYOUT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] buildItems() {
|
||||
String title = titleText.getText().trim();
|
||||
|
||||
if (title.isEmpty()) {
|
||||
showAlert("描述还没有填");
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
return new Object[]{title};
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package org.cutem.cutecalendar.presenter.newitems.lab5;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.autoset.AutoSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public final class TripTypeBuilder extends BaseTodoItemBuilder {
|
||||
|
||||
public static class Factory extends BaseFactory<TripTypeBuilder> {
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TYPE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TripTypeBuilder construct() {
|
||||
return new TripTypeBuilder(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TripTypeBuilder constructWithParent(@NotNull TodoItem parent) {
|
||||
return new TripTypeBuilder(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TRIP_TYPE_LAYOUT = "fxml/newitem_layouts/trip_type_layout.fxml";
|
||||
|
||||
private static final int TYPE = TodoItem.TRIP;
|
||||
|
||||
private static final String TYPE_NAME = TodoItem.typeName(TYPE);
|
||||
|
||||
|
||||
@FXML
|
||||
private TextField bgnTimeText;
|
||||
@FXML
|
||||
private TextField endTimeText;
|
||||
@FXML
|
||||
private TextField titleText;
|
||||
@FXML
|
||||
private TextField locationText;
|
||||
@FXML
|
||||
private TextField transportationText;
|
||||
@FXML
|
||||
private TextField transportationNumberText;
|
||||
|
||||
private TripTypeBuilder(TodoItem parent) {
|
||||
super(parent);
|
||||
loadLayout(TRIP_TYPE_LAYOUT);
|
||||
}
|
||||
|
||||
@FXML
|
||||
@Override
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
AutoSet a = getAutoSet();
|
||||
a.timeSegment(bgnTimeText.textProperty(), endTimeText.textProperty());
|
||||
a.stringProperty(TodoItem.TITLE, titleText.textProperty(), "请填写备注");
|
||||
a.stringProperty(TodoItem.LOCATION, locationText.textProperty(), "请填写地点");
|
||||
a.stringProperty("交通方式", transportationText.textProperty(), "请填写交通方式");
|
||||
a.stringProperty("航班号/车次/其他", transportationNumberText.textProperty(), "请填写航班号/车次/其他");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getType() {
|
||||
return TYPE;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,8 @@ import javafx.scene.Scene;
|
|||
import javafx.stage.Stage;
|
||||
import org.cutem.cutecalendar.model.TodoItem;
|
||||
import org.cutem.cutecalendar.presenter.*;
|
||||
import org.cutem.cutecalendar.presenter.newitems.*;
|
||||
import org.cutem.cutecalendar.presenter.newitems.lab5.OtherTypeBuilder;
|
||||
import org.cutem.cutecalendar.presenter.newitems.lab5.TimelessTypeBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -59,12 +60,12 @@ public class MainTest extends Application {
|
|||
|
||||
// add IoC
|
||||
newItemStrategy.addFactory(new TimelessTypeBuilder.Factory());
|
||||
newItemStrategy.addFactory(new OtherTypeNewItemBuilder.Factory());
|
||||
newItemStrategy.addFactory(new ConferenceTypeNewItemBuilder.Factory());
|
||||
newItemStrategy.addFactory(new InterviewTypeNewItemBuilder.Factory());
|
||||
newItemStrategy.addFactory(new AnniversaryTypeNewItemBuilder.Factory());
|
||||
newItemStrategy.addFactory(new CourseTypeBuilder.Factory());
|
||||
newItemStrategy.addFactory(new DateTypeBuilder.Factory());
|
||||
newItemStrategy.addFactory(new OtherTypeBuilder.Factory());
|
||||
// newItemStrategy.addFactory(new ConferenceTypeBuilder.Factory());
|
||||
// newItemStrategy.addFactory(new InterviewTypeBuilder.Factory());
|
||||
// newItemStrategy.addFactory(new AnniversaryTypeBuilder.Factory());
|
||||
// newItemStrategy.addFactory(new CourseTypeBuilder.Factory());
|
||||
// newItemStrategy.addFactory(new DateTypeBuilder.Factory());
|
||||
|
||||
mPresenter.goWork();
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"id": 0,
|
||||
"bgn": "2018-5-29/0:0",
|
||||
"end": "2018-5-29/23:59",
|
||||
"type": 1,
|
||||
"personnel": [],
|
||||
"props": {
|
||||
"alarm_method": "none",
|
||||
"finish": "finish",
|
||||
"title": "gg"
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue