Skip to content

Commit f948660

Browse files
KhureshiKhureshi
authored andcommitted
ui changes
1 parent 4840ac5 commit f948660

File tree

15 files changed

+397
-262
lines changed

15 files changed

+397
-262
lines changed

src/main/java/com/application/controller/CanvasController.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ public void setUp() {
7676

7777
private void setUpCenterLayout() {
7878
canvas = new Pane();
79-
// Group canvasContainer = new Group();
80-
// canvasContainer.getChildren().add(canvas);
8179
scrollPane = new ZoomableScrollPane(canvas);
8280
scrollPane.setFitToWidth(true);
8381
scrollPane.setFitToHeight(true);
@@ -95,7 +93,8 @@ private void setUpCenterLayout() {
9593
drawPlaceHolderLines();
9694
setListeners();
9795

98-
// canvas.setStyle("-fx-background-color: blue;");
96+
97+
scrollPane.setStyle("-fx-background: WHITE;");
9998
}
10099

101100

@@ -117,6 +116,9 @@ private void addCanvasComponentsFromDB() {
117116
}
118117

119118
private void addUIComponents() {
119+
if (ControllerLoader.centerLayoutController.getCurrentThreadId() == null) {
120+
return;
121+
}
120122
addCirclesToUI();
121123
addEdgesToUI();
122124
addHighlightsToUI();
@@ -131,6 +133,10 @@ private void removeUIComponents() {
131133
removeHighlightsFromUI();
132134
}
133135

136+
137+
/**
138+
* Determines all the element nodes that should be drawn in the current viewport and draws them if not already present.
139+
*/
134140
private void addCirclesToUI() {
135141
BoundingBox viewPort = getPrefetchViewPortDims();
136142

@@ -142,6 +148,11 @@ private void addCirclesToUI() {
142148
circleCells.forEach(this::addNewCellToUI);
143149
}
144150

151+
/**
152+
* Draws a new element node on UI if not already present.
153+
*
154+
* @param circleCell
155+
*/
145156
private void addNewCellToUI(CircleCell circleCell) {
146157
if (!circleCellsOnUI.containsKey(circleCell.getCellId())) {
147158
circleCellsOnUI.put(circleCell.getCellId(), circleCell);
@@ -532,6 +543,10 @@ private void removeListeners() {
532543

533544
private void drawPlaceHolderLines() {
534545
String currentThreadId = ControllerLoader.centerLayoutController.getCurrentThreadId();
546+
if (currentThreadId == null) {
547+
System.out.println("CanvasController.drawPlaceHolderLines. currentThreadId is null. Returning without loading.");
548+
return;
549+
}
535550
int height = graphLoaderModule.computePlaceHolderHeight(currentThreadId);
536551
int width = graphLoaderModule.computePlaceHolderWidth(currentThreadId);
537552

src/main/java/com/application/controller/CenterLayoutController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ private void initialize() {
7272

7373
private void setUpPaneButtonsActions() {
7474
threadsToggleButton.setSelected(false);
75+
threadsToggleButton.setStyle("-fx-focus-color: transparent; " +
76+
"-fx-background-color: -fx-outer-border, -fx-inner-border, -fx-body-color; " +
77+
"-fx-background-insets: 0, 1, 2; " +
78+
"-fx-background-radius: 5, 4, 3;");
7579
verticalSplitPanePosProperty = verticalSplitPane.getDividers().get(0).positionProperty();
7680
verticalSplitPanePosProperty.setValue(0);
7781

@@ -124,6 +128,9 @@ public void setUpThreadsListView() {
124128
threadListView.setItems(threadsObsList);
125129

126130
threadListView.setOnMouseClicked((e) -> {
131+
if (threadsObsList.size() == 0) {
132+
return;
133+
}
127134
String threadId = threadListView.getSelectionModel().getSelectedItem().split(" ")[1];
128135
switchCurrentThread(threadId);
129136
});

src/main/java/com/application/controller/InstructionsPaneController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void setMethodDefGraphics(boolean enabled) {
104104
methodDefInfoLabel.setGraphic(methodDefInfoGlyph);
105105

106106
} else {
107-
methodDefInfoGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.ARROW_RIGHT);
107+
methodDefInfoGlyph.setIcon(FontAwesome.Glyph.ARROW_RIGHT);
108108
methodDefInfoGlyph.setColor(ColorProp.GREY);
109109
}
110110
}
@@ -118,7 +118,7 @@ public void setCallTraceGraphics(boolean enabled) {
118118
+ LoadedFiles.getFile(FileNames.Call_Trace.getFileName()).getName());
119119

120120
} else {
121-
callTraceInfoGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.ARROW_RIGHT);
121+
callTraceInfoGlyph.setIcon(FontAwesome.Glyph.ARROW_RIGHT);
122122
callTraceInfoGlyph.setColor(ColorProp.BLACK);
123123
}
124124
}
@@ -141,7 +141,7 @@ public void setDBInfoGraphics(boolean enabled) {
141141
+ LoadedFiles.getFile(FileNames.DB.getFileName()).getName());
142142

143143
} else {
144-
dbInfoGlyph = new Glyph("FontAwesome", FontAwesome.Glyph.ARROW_RIGHT);
144+
dbInfoGlyph.setIcon(FontAwesome.Glyph.ARROW_RIGHT);
145145
dbInfoGlyph.setColor(ColorProp.BLACK);
146146
}
147147
}

src/main/java/com/application/controller/MainController.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
package com.application.controller;
22

3+
import com.application.db.DatabaseUtil;
4+
import javafx.application.Platform;
35
import javafx.fxml.FXML;
46
import javafx.fxml.FXMLLoader;
57
import javafx.scene.Node;
8+
import javafx.scene.control.Alert;
9+
import javafx.scene.control.ButtonType;
610
import javafx.scene.layout.BorderPane;
11+
import javafx.scene.layout.Region;
712

813
import java.io.IOException;
914

1015
public class MainController {
1116
@FXML private BorderPane borderPane;
1217

13-
// @FXML private CenterLayoutController centerLayoutController;
18+
public boolean alertShown = false;
1419

1520
@FXML protected void initialize() {
1621
ControllerLoader.register(this);
@@ -30,17 +35,41 @@ void showInstructionsPane() {
3035
}
3136

3237
void loadGraphPane() {
38+
if (!DatabaseUtil.isDBValid()) {
39+
System.out.println("MainController.loadGraphPane. db not valid.");
40+
return;
41+
}
42+
3343
try {
3444
FXMLLoader fxmlLoader = new FXMLLoader();
3545
fxmlLoader.setLocation(getClass().getResource("/fxml/centerLayout.fxml"));
3646
Node content = fxmlLoader.load();
3747
borderPane.setCenter(content);
38-
39-
// centerLayoutController = fxmlLoader.getController();
40-
4148
} catch (IOException e) {
4249
e.printStackTrace();
4350
}
4451
}
4552

53+
public void showErrorPopup(String title, String header, String message) {
54+
System.out.println("MainController.showErrorPopup.");
55+
56+
if (alertShown) {
57+
System.out.println("MainController.showErrorPopup. alert shown.");
58+
return;
59+
}
60+
alertShown = true;
61+
62+
Alert alert = new Alert(Alert.AlertType.ERROR);
63+
alert.setTitle(title);
64+
alert.setHeaderText(header);
65+
alert.setContentText(message);
66+
ButtonType resetButtonType = new ButtonType("Close");
67+
alert.getButtonTypes().setAll(resetButtonType);
68+
69+
alert.getDialogPane().setMinWidth(Region.USE_PREF_SIZE);
70+
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
71+
72+
alert.show();
73+
}
74+
4675
}

0 commit comments

Comments
 (0)