Skip to content

Commit 1ed7a61

Browse files
css fix for borders
make swap and add/drop stage display shifts based on amount scheduled for corresponding oh schedule fix
1 parent d56abee commit 1ed7a61

File tree

4 files changed

+99
-23
lines changed

4 files changed

+99
-23
lines changed

src/Borders.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.newHour {
2+
-fx-border-style: solid;
3+
-fx-border-width: 5px 0px 0px 5px;
4+
-fx-border-color: "black" "black" #d3d3d3 "black";
5+
-fx-margin: 0px;
6+
-fx-padding: 0px;
7+
}
8+
9+
.notNewHour {
10+
-fx-border-style: solid;
11+
-fx-border-width: 5px 0px 0px 5px;
12+
-fx-border-color: #d3d3d3 "black" #d3d3d3 "black" ;
13+
-fx-margin: 0px;
14+
-fx-padding: 0px;
15+
}
16+
17+
.hourOne{
18+
-fx-border-width: 0px 5px 0px 5px;
19+
-fx-border-color: "black";
20+
-fx-margin: 0px;
21+
-fx-padding: 0px;
22+
}
23+
24+
.hourNotOne {
25+
-fx-border-width: 0px 5px 0px 0px;
26+
-fx-border-color: "black";
27+
-fx-margin: 0px;
28+
-fx-padding: 0px;
29+
}

src/ui/PerformSwapStage.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class PerformSwapStage extends KarenStage {
4646
private int _addDay;
4747
private int _addHour;
4848
private Employee _employeeToAddOrDrop;
49+
private Schedule _ohSchedule;
4950

5051
public PerformSwapStage(String title, Controller controller, UI ui) {
5152
super(title, controller, ui);
@@ -246,9 +247,12 @@ private void setupForDrop() {
246247
ListView<String> dayListView = new ListView<String>();
247248

248249
scheduleListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
250+
String ohSchedName = newValue.replaceAll("Tutoring", "OH");
251+
ohSchedName = ohSchedName .replaceAll("Grading", "OH");
249252
_dropSchedule = _ui.getScheduleByName(newValue);
253+
_ohSchedule = _ui.getScheduleByName(ohSchedName);
250254
javafx.collections.ObservableList<String> days = FXCollections
251-
.observableArrayList(_ui.getDaysList(_dropSchedule));
255+
.observableArrayList(_ui.getDaysList(_ohSchedule));
252256
dayListView.setItems(days);
253257
// dayListView.prefHeightProperty().bind(Bindings.size(days).multiply(24));
254258
_employeeToAddOrDrop = null;
@@ -259,7 +263,7 @@ private void setupForDrop() {
259263
dayListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
260264
_dropDay = Week.dayInt(newValue);
261265
javafx.collections.ObservableList<String> hours = FXCollections
262-
.observableArrayList(_ui.getHoursList(_dropSchedule, newValue));
266+
.observableArrayList(_ui.getHoursList(_ohSchedule, newValue));
263267
hourListView.setItems(hours);
264268
// hourListView.prefHeightProperty().bind(Bindings.size(hours).multiply(24));
265269
_employeeToAddOrDrop = null;
@@ -322,9 +326,13 @@ private void setupForAdd() {
322326
ListView<String> dayListView = new ListView<String>();
323327

324328
scheduleListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
329+
String ohSchedName = newValue.replaceAll("Tutoring", "OH");
325330
_addSchedule = _ui.getScheduleByName(newValue);
331+
ohSchedName = ohSchedName .replaceAll("Grading", "OH");
332+
333+
_ohSchedule = _ui.getScheduleByName(ohSchedName);
326334
javafx.collections.ObservableList<String> days = FXCollections
327-
.observableArrayList(_ui.getDaysList(_addSchedule));
335+
.observableArrayList(_ui.getDaysList(_ohSchedule));
328336
dayListView.setItems(days);
329337
dayListView.prefHeightProperty().bind(Bindings.size(days).multiply(24));
330338
_employeeToAddOrDrop = null;
@@ -334,9 +342,11 @@ private void setupForAdd() {
334342
ListView<String> hourListView = new ListView<String>();
335343

336344
dayListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
345+
String schedName = _addSchedule.getDatesValid().replaceAll("Tutoring", "OH");
346+
schedName = schedName.replaceAll("Grading", "OH");
337347
_addDay = Week.dayInt(newValue);
338348
javafx.collections.ObservableList<String> hours = FXCollections
339-
.observableArrayList(_ui.getHoursList(_addSchedule, newValue));
349+
.observableArrayList(_ui.getHoursList(_ohSchedule, newValue));
340350
hourListView.setItems(hours);
341351
hourListView.prefHeightProperty().bind(Bindings.size(hours).multiply(24));
342352
_employeeToAddOrDrop = null;

src/ui/ScheduleStage.java

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import comp110.Employee;
99
import comp110.Schedule;
1010
import comp110.Week;
11+
import javafx.collections.ObservableList;
1112
import javafx.geometry.Pos;
13+
import javafx.scene.Node;
1214
import javafx.scene.Scene;
1315
import javafx.scene.control.Label;
1416
import javafx.scene.control.ScrollPane;
@@ -18,8 +20,6 @@
1820
import javafx.scene.layout.GridPane;
1921
import javafx.scene.paint.Color;
2022
import javafx.scene.text.Font;
21-
import javafx.scene.text.FontPosture;
22-
import javafx.scene.text.FontWeight;
2323
import javafx.scene.text.Text;
2424
import javafx.scene.text.TextFlow;
2525

@@ -96,37 +96,58 @@ private void renderScheduleStage(List<Schedule> schedules) {
9696
}
9797

9898
Scene scene = new Scene(tabs);
99+
scene.getStylesheets().add("Borders.css");
99100
this.setScene(scene);
100101
this.sizeToScene();
101102
}
102103

103104
public GridPane writeSchedule(Schedule schedule) {
104105
GridPane schedulePane = new GridPane();
105-
schedulePane.setAlignment(Pos.CENTER);
106-
schedulePane.setGridLinesVisible(true);
107-
ArrayList<ArrayList<ArrayList<Employee>>> shifts = shiftsAsArray(schedule.getWeek());
108-
109-
for (int day = 0; day < 7; day++) {
110-
// +1 for hour column
111-
schedulePane.add(new Label(Week.dayString(day)), day + 1, 0);
112-
}
113-
106+
114107
//Load the fonts
115108
InputStream is = getClass().getResourceAsStream("segoeui.ttf");
116109
Font font = Font.loadFont(is, 12.0);
117110
InputStream is2 = getClass().getResourceAsStream("segoeuibold.ttf");
118111
Font boldFont = Font.loadFont(is2, 12.0);
119112

113+
schedulePane.setAlignment(Pos.CENTER);
114+
//schedulePane.setGridLinesVisible(true);
115+
ArrayList<ArrayList<ArrayList<Employee>>> shifts = shiftsAsArray(schedule.getWeek());
116+
TextFlow firstBlock = new TextFlow(new Text());
117+
firstBlock.getStyleClass().add("newHour");
118+
schedulePane.add(firstBlock, 0, 0);
119+
for (int day = 0; day < 7; day++) {
120+
// +1 for hour column
121+
Text test = new Text(Week.dayString(day));
122+
test.setFont(font);
123+
TextFlow h = new TextFlow(test);
124+
String style = "newHour";
125+
h.getStyleClass().add(style);
126+
schedulePane.add(h, day + 1, 0);
127+
}
120128

121129
int hourRow = 0;
130+
int prevHourRow = hourRow;
122131
for (int hour = getEarliestHour(schedule.getWeek()); hour < getLatestHour(schedule.getWeek()); hour++) {
123-
Label dayLabel = new Label(
132+
133+
Text dayLabel = new Text(
124134
(hour % 12 == 0 ? 12 : hour % 12) + " -- " + ((hour + 1) % 12 == 0 ? 12 : (hour + 1) % 12));
125-
dayLabel.setMaxWidth(Double.MAX_VALUE);
126-
dayLabel.setAlignment(Pos.CENTER);
135+
//dayLabel.setMaxWidth(Double.MAX_VALUE);
136+
//dayLabel.setAlignment(Pos.CENTER);
137+
dayLabel.setFont(font);
127138
// +1 to account for day row
128-
schedulePane.add(dayLabel, 0, hourRow + 1);
129-
139+
TextFlow dayLabelWrapper = new TextFlow(dayLabel);
140+
dayLabelWrapper.getStyleClass().add("newHour");
141+
schedulePane.add(dayLabelWrapper, 0, hourRow + 1);
142+
143+
for (int i = prevHourRow + 2; i < hourRow + 1; i++){
144+
Text test = new Text();
145+
TextFlow h = new TextFlow(test);
146+
h.getStyleClass().add("notNewHour");
147+
schedulePane.add(h, 0, i);
148+
}
149+
prevHourRow = hourRow;
150+
130151
int max = getMaxSize(hour, schedule.getWeek());
131152

132153
for (int i = 0; i < max; i++) {
@@ -146,12 +167,24 @@ public GridPane writeSchedule(Schedule schedule) {
146167
scheduledEmployee.setFill(Color.RED);
147168
}
148169
// +1 to account for day row
149-
schedulePane.add(new TextFlow(scheduledEmployee), day + 1, hourRow + i + 1);
170+
TextFlow x = new TextFlow(scheduledEmployee);
171+
if (i == 0) x.getStyleClass().add("newHour");
172+
173+
else x.getStyleClass().add("notNewHour");
174+
schedulePane.add(x, day + 1, hourRow + i + 1);
175+
}
176+
else {
177+
Text y = new Text();
178+
TextFlow x = new TextFlow(y);
179+
String style = i == 0 ? "newHour" : "notNewHour";
180+
x.getStyleClass().add(style);
181+
schedulePane.add(x, day + 1, hourRow + i + 1);
150182
}
151183
}
152184
}
153185
hourRow += max;
154186
}
187+
155188
return schedulePane;
156189
}
157190

src/ui/SwapBox.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class SwapBox extends HBox {
2222
private Employee _swapEmployee;
2323
private ListView<Label> _personListView;
2424
private UI _ui;
25+
private Schedule _ohSchedule;
2526

2627
public SwapBox(UI ui) {
2728
_ui = ui;
@@ -37,9 +38,12 @@ public SwapBox(UI ui) {
3738

3839

3940
scheduleListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
41+
String ohSchedName = newValue.replaceAll("Tutoring", "OH");
42+
ohSchedName = ohSchedName .replaceAll("Grading", "OH");
43+
_ohSchedule = _ui.getScheduleByName(ohSchedName);
4044
_swapSchedule = _ui.getScheduleByName(newValue); // newValue will be the dateValid property of the schedule
4145
javafx.collections.ObservableList<String> days = FXCollections
42-
.observableArrayList(_ui.getDaysList(_swapSchedule));
46+
.observableArrayList(_ui.getDaysList(_ohSchedule));
4347
// newValue is the new day
4448
dayListView.setItems(days);
4549
dayListView.prefHeightProperty().bind(Bindings.size(days).multiply(24));
@@ -54,7 +58,7 @@ public SwapBox(UI ui) {
5458
dayListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
5559
_swapDay = Week.dayInt(newValue);
5660
javafx.collections.ObservableList<String> hours = FXCollections
57-
.observableArrayList(_ui.getHoursList(_swapSchedule, newValue));
61+
.observableArrayList(_ui.getHoursList(_ohSchedule, newValue));
5862
// newValue is the new day
5963
hourListView.setItems(hours);
6064
hourListView.prefHeightProperty().bind(Bindings.size(hours).multiply(24));

0 commit comments

Comments
 (0)