Skip to content

Commit 56ca6b4

Browse files
committed
TitledPane's title text's wrapping fix.
1 parent bdd3ce2 commit 56ca6b4

File tree

9 files changed

+25
-15
lines changed

9 files changed

+25
-15
lines changed

src/main/java/ee/ut/similaritydetector/ui/SimilarityDetectorLauncher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private void showExitConfirmationAlert(WindowEvent windowEvent) {
6060
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
6161
alert.setTitle("");
6262
alert.setHeaderText("Are you sure you want to exit?");
63-
alert.setContentText("Results might not have been saved.");
63+
//alert.setContentText("Results might not have been saved.");
6464
ButtonType exitButton = new ButtonType("Exit");
6565
ButtonType cancelButton = ButtonType.CANCEL;
6666
alert.getButtonTypes().setAll(cancelButton, exitButton);

src/main/java/ee/ut/similaritydetector/ui/components/AccordionTableView.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package ee.ut.similaritydetector.ui.components;
22

3+
import javafx.application.Platform;
34
import javafx.beans.binding.Bindings;
45
import javafx.scene.control.*;
56
import javafx.scene.control.cell.PropertyValueFactory;
67
import javafx.scene.layout.AnchorPane;
78
import ee.ut.similaritydetector.backend.SimilarSolutionCluster;
89
import ee.ut.similaritydetector.backend.SimilarSolutionPair;
10+
import javafx.scene.text.Text;
911

1012
import java.util.Comparator;
1113
import java.util.stream.Collectors;
@@ -65,11 +67,29 @@ public AccordionTableView(SimilarSolutionCluster cluster) {
6567
tableView.minHeight(cellSize + 1);
6668

6769
// TitledPane header
68-
this.setText(cluster.getName());
70+
// If title text is too long then wrap text manually with line breaks
71+
// Couldn't find a better solution for this
72+
Platform.runLater(() -> {
73+
StringBuilder headerText = new StringBuilder();
74+
StringBuilder lineText = new StringBuilder();
75+
for (String word : cluster.getName().split(" ")) {
76+
lineText.append(word).append(" ");
77+
Text text = new Text(lineText.toString());
78+
if (text.getLayoutBounds().getWidth() > 400 - 50) {
79+
System.out.println(lineText);
80+
headerText.append(System.lineSeparator());
81+
lineText.delete(0, lineText.length());
82+
lineText.append(word);
83+
}
84+
headerText.append(word).append(" ");
85+
}
86+
this.setText(headerText.toString());
87+
});
6988

7089
// TitledPane's content
7190
this.setContent(anchorPane);
7291

92+
7393
// TitledPane restrictions
7494
this.setExpanded(false);
7595
this.setMinWidth(0);

src/main/java/ee/ut/similaritydetector/ui/controllers/CodeViewController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ private void initialize() {
9292
);
9393
closeAllTabsMenuItem.setVisible(true);
9494
closeAllTabsMenuItem.setOnAction(e -> closeAllCodeTabs());
95-
hideSideBarButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
9695
hideSideBarButton.setOnAction(event -> Platform.runLater(this::hideClusterPane));
9796
ImageView arrowImg = new ImageView(new Image(
9897
getClass().getResourceAsStream("/ee/ut/similaritydetector/img/hidearrow.png")));
9998
arrowImg.setFitHeight(13);
10099
arrowImg.setFitWidth(9);
101100
hideSideBarButton.setGraphic(arrowImg);
101+
hideSideBarButton.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
102102
}
103103

104104
/**

src/main/resources/ee/ut/similaritydetector/fxml/code_view.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<?import javafx.scene.layout.BorderPane?>
1010
<?import javafx.scene.layout.VBox?>
1111

12-
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="600.0" prefHeight="700.0" prefWidth="1000.0" stylesheets="/ee/ut/similaritydetector/style/style.scss, /ee/ut/similaritydetector/style/code_view_style.scss" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ee.ut.similaritydetector.ui.controllers.CodeViewController">
12+
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="400.0" minWidth="600.0" prefHeight="700.0" prefWidth="1000.0" stylesheets="/ee/ut/similaritydetector/style/style.scss, /ee/ut/similaritydetector/style/code_view_style.scss" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ee.ut.similaritydetector.ui.controllers.CodeViewController">
1313
<children>
1414
<BorderPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1515
<center>
@@ -34,7 +34,7 @@
3434
</BorderPane>
3535
</center>
3636
<left>
37-
<Button fx:id="hideSideBarButton" focusTraversable="false" mnemonicParsing="false" prefHeight="20.0" prefWidth="20.0" text="Button" BorderPane.alignment="CENTER">
37+
<Button fx:id="hideSideBarButton" focusTraversable="false" mnemonicParsing="false" prefHeight="20.0" prefWidth="20.0" BorderPane.alignment="CENTER">
3838
<BorderPane.margin>
3939
<Insets right="-25.0" />
4040
</BorderPane.margin>
637 Bytes
Loading
1.02 KB
Loading
1.33 KB
Loading
1.33 KB
Loading

src/main/resources/ee/ut/similaritydetector/style/code_view_style.scss

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@
2828
-fx-opacity: 0;
2929
}
3030

31-
.titledPane-multiline > .title {
32-
-fx-pref-height: 40; /* increase available area */
33-
-fx-alignment: top-center;
34-
-fx-padding: 4 4 4 30; /* increase left padding to align text */
35-
}
36-
37-
.titledPane-multiline > .title > .arrow-button {
38-
-fx-translate-x: -20; /* move back arrow, which is also subject to the padding */
39-
}
40-
4131
#hideSideBarButton {
4232
-fx-background-radius: 1000;
4333
-fx-opacity: 0.85;

0 commit comments

Comments
 (0)