added Activity selector not working completely
This commit is contained in:
parent
d583187651
commit
1fae90780c
|
@ -3,16 +3,17 @@ package Calendar;
|
|||
import java.util.TreeSet;
|
||||
|
||||
public enum ActivityType {
|
||||
Empty,
|
||||
Retrieve,
|
||||
FirstRelease,
|
||||
Renew,
|
||||
Shipment,
|
||||
Lost,
|
||||
Ruined;
|
||||
public TreeSet<String> Names () {
|
||||
TreeSet<String> TMP = new TreeSet<>();
|
||||
public static TreeSet<ActivityType> Names () {
|
||||
TreeSet<ActivityType> TMP = new TreeSet<>();
|
||||
for (var name: ActivityType.values()) {
|
||||
TMP.add(name.toString());
|
||||
TMP.add(name);
|
||||
}
|
||||
return TMP;
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package Calendar;
|
||||
|
||||
public class Calendar {
|
||||
|
||||
}
|
|
@ -88,6 +88,17 @@ public class Date implements Comparable<Date> , Iterable<Date>{
|
|||
public String toString() {
|
||||
return day + "/" + month + "/" + year;
|
||||
}
|
||||
public Date getPrec() {
|
||||
if (day == 1) {
|
||||
if (month == 1) {
|
||||
return new Date(DaysInMonth[11],12,year-1);
|
||||
} else {
|
||||
return new Date(DaysInMonth[month-2],month-1,year);
|
||||
}
|
||||
} else {
|
||||
return new Date(day-1,month,year);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package Calendar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class Day implements Iterable<Day>,Comparable<Day> {
|
||||
|
@ -7,12 +8,17 @@ public class Day implements Iterable<Day>,Comparable<Day> {
|
|||
private Days Name;
|
||||
private int ordinal;
|
||||
private Date date;
|
||||
private ArrayList<Slot> Slots = new ArrayList<>();
|
||||
|
||||
|
||||
public Day (Date date, int ordinal) {
|
||||
this.ordinal = ordinal;
|
||||
this.Name = Days.values()[ordinal-1];
|
||||
this.date = date;
|
||||
for (int i = 0 ; i < 6 ; i++) {
|
||||
Slots.add(new Slot(ActivityType.Empty));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,5 +60,7 @@ public class Day implements Iterable<Day>,Comparable<Day> {
|
|||
public String toString() {
|
||||
return Name.toString() + ": " + date.toString();
|
||||
}
|
||||
|
||||
public ArrayList<Slot> getSlots() {
|
||||
return Slots;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package Calendar;
|
||||
|
||||
public class Slot {
|
||||
private ActivityType Activity;
|
||||
public Slot(ActivityType Activity) {
|
||||
this.Activity = Activity;
|
||||
}
|
||||
public void SetActivity(ActivityType Activity) {
|
||||
this.Activity = Activity;
|
||||
}
|
||||
public ActivityType getActivity() {
|
||||
return Activity;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ public class Year implements Comparable<Year>,Iterable<Year> {
|
|||
Month tmpMonth = new Month(year,1,firstDay);
|
||||
YMonths.add(tmpMonth);
|
||||
while (tmpMonth.getName().ordinal() < Months.December.ordinal()) {
|
||||
System.out.println(tmpMonth);
|
||||
|
||||
tmpMonth = tmpMonth.iterator().next();
|
||||
YMonths.add(tmpMonth);
|
||||
}
|
||||
|
@ -59,6 +59,9 @@ public class Year implements Comparable<Year>,Iterable<Year> {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
public TreeSet<Month> getMonths() {
|
||||
return YMonths;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ import javafx.scene.text.Text;
|
|||
public abstract class AbstractAppPane implements AppPane {
|
||||
|
||||
protected GridPane pannello = new GridPane();
|
||||
protected Map<String,Text> Texts = new HashMap<>();
|
||||
protected Map<Text,Node> Fields = new HashMap<>();
|
||||
|
||||
protected Scene scena = new Scene(pannello);
|
||||
protected int heigth, width, insets;
|
||||
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
package ClientApp;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import Calendar.ActivityType;
|
||||
import Calendar.Date;
|
||||
import Calendar.Day;
|
||||
import Calendar.Month;
|
||||
import Calendar.Slot;
|
||||
import Calendar.Week;
|
||||
import Calendar.Year;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class ActivitySelector extends AbstractAppPane{
|
||||
private HBox Layout = new HBox();
|
||||
private Year year;
|
||||
private Date date;
|
||||
private Week week;
|
||||
private ObservableList<ActivityType> Activities = FXCollections.observableArrayList();
|
||||
private Map<Day,HashMap<Slot,ComboBox<ActivityType>>> WeekMap = new HashMap<>();
|
||||
|
||||
public ActivitySelector (Year year,Date date) {
|
||||
this.year = year;
|
||||
this.date = date;
|
||||
Layout.autosize();
|
||||
textFill();
|
||||
gridSetup();
|
||||
scena.setRoot(Layout);
|
||||
}
|
||||
public ActivitySelector (Year year,Date date, int Flag) {
|
||||
this.year = year;
|
||||
this.date = date;
|
||||
Layout.autosize();
|
||||
textFill();
|
||||
gridSetup();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridSetup() {
|
||||
Button prec = new Button("Previous");
|
||||
prec.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(ActionEvent arg0) {
|
||||
ActivitySelector prec = new ActivitySelector(year,week.getWeekDays().first().getDate().getPrec());
|
||||
scena.setRoot(prec.getLayout());
|
||||
}
|
||||
|
||||
});
|
||||
Layout.getChildren().add(prec);
|
||||
for (Day D : week.getWeekDays()) {
|
||||
VBox DBox = new VBox();
|
||||
DBox.autosize();
|
||||
DBox.getChildren().add(new Text(D.toString()));
|
||||
for (Slot S : D.getSlots()) {
|
||||
DBox.getChildren().add(WeekMap.get(D).get(S));
|
||||
WeekMap.get(D).get(S).setValue(ActivityType.Empty);
|
||||
WeekMap.get(D).get(S).setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(ActionEvent arg0) {
|
||||
S.SetActivity(WeekMap.get(D).get(S).getValue());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
Layout.getChildren().add(DBox);
|
||||
}
|
||||
Button next = new Button("Next");
|
||||
next.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(ActionEvent arg0) {
|
||||
ActivitySelector next = new ActivitySelector(year,week.getWeekDays().last().getDate().iterator().next(),1);
|
||||
scena.setRoot(next.getLayout());
|
||||
}
|
||||
|
||||
});
|
||||
Layout.getChildren().add(next);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textFill() {
|
||||
getWeek(date);
|
||||
WeekMap.clear();
|
||||
Activities.addAll(ActivityType.Names());
|
||||
for (Day D: week.getWeekDays()) {
|
||||
WeekMap.put(D,new HashMap<Slot,ComboBox<ActivityType>>());
|
||||
for (Slot S: D.getSlots()) {
|
||||
WeekMap.get(D).put(S, new ComboBox<ActivityType>(Activities));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void getWeek(Date Wdate) {
|
||||
for(Month M:year.getMonths()) {
|
||||
if (M.getName().ordinal() == date.getMonth()-1) {
|
||||
for(Week W:M.getWeeks()) {
|
||||
if((W.getWeekDays().first().getDate().compareTo(date) == -1 || W.getWeekDays().first().getDate().compareTo(date) == 0) && (W.getWeekDays().last().getDate().compareTo(date) == 1 || W.getWeekDays().last().getDate().compareTo(date) == 0)) {
|
||||
this.week = W;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public HBox getLayout() {
|
||||
return Layout;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
package ClientApp;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
|
@ -9,6 +13,8 @@ import javafx.stage.Stage;
|
|||
public class ErrorPane extends AbstractAppPane {
|
||||
private String ErrorMessage;
|
||||
private Stage ErrorStage = new Stage();
|
||||
private Map<String,Text> Texts = new HashMap<>();
|
||||
private Map<Text,Node> Fields = new HashMap<>();
|
||||
public ErrorPane(String ErrorMessage) {
|
||||
this.ErrorMessage = ErrorMessage;
|
||||
gridSetup();
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
package ClientApp;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
public class LoginPage extends AbstractAppPane {
|
||||
private Map<String,Text> Texts = new HashMap<>();
|
||||
private Map<Text,Node> Fields = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void gridSetup() {
|
||||
|
|
|
@ -4,6 +4,7 @@ package ClientApp;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -13,6 +14,7 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.DatePicker;
|
||||
|
@ -30,6 +32,8 @@ public class RegPane extends AbstractAppPane {
|
|||
private FileToMap FTM = new FileToMap();
|
||||
private ObservableList<String> CityItems = FXCollections.observableArrayList();
|
||||
private ComboBox<String> CityBox = new ComboBox<>(CityItems);
|
||||
private Map<String,Text> Texts = new HashMap<>();
|
||||
private Map<Text,Node> Fields = new HashMap<>();
|
||||
|
||||
private void fillCountries(Iterable<String> CountriesNames) {
|
||||
for (String Name: CountriesNames) {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package ClientApp;
|
||||
|
||||
public enum SlotsName {
|
||||
First,
|
||||
Second,
|
||||
Third,
|
||||
Fourth,
|
||||
Fifth,
|
||||
Sixth;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package ClientApp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Calendar.Date;
|
||||
import Calendar.Days;
|
||||
import Calendar.Year;
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
import java.util.function.*;
|
||||
public class TestMain extends Application{
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
@ -14,9 +14,9 @@ public class TestMain extends Application{
|
|||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
|
||||
AppPane Register = new RegPane(10, 500, 500,UserDataTypes.Names());
|
||||
AppPane Register = new ActivitySelector(new Year(2023,Days.Monday),new Date(3,3,2023));
|
||||
stage.setScene(Register.getScene());
|
||||
stage.show();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue