Fixed padding of status icon and implemented Tooltip
Additionally added commentary in MessageListCell.
This commit is contained in:
		| @@ -4,12 +4,11 @@ import java.time.format.DateTimeFormatter; | ||||
| import java.util.Map; | ||||
|  | ||||
| import javafx.geometry.Insets; | ||||
| import javafx.scene.control.Label; | ||||
| import javafx.scene.control.ListCell; | ||||
| import javafx.scene.control.ListView; | ||||
| import javafx.scene.control.*; | ||||
| import javafx.scene.image.Image; | ||||
| import javafx.scene.image.ImageView; | ||||
| import javafx.scene.layout.VBox; | ||||
| import javafx.stage.PopupWindow.AnchorLocation; | ||||
|  | ||||
| import envoy.data.Message; | ||||
| import envoy.data.Message.MessageStatus; | ||||
| @@ -51,16 +50,26 @@ public class MessageListCell extends ListCell<Message> { | ||||
| 			setText(null); | ||||
| 			setGraphic(null); | ||||
| 		} else { | ||||
| 			// Creating the underlying VBox, the dateLabel and the textLabel | ||||
| 			final var	cell		= new VBox(new Label(dateFormat.format(message.getCreationDate()))); | ||||
| 			final var	textLabel	= new Label(message.getText()); | ||||
| 			textLabel.setWrapText(true); | ||||
| 			cell.getChildren().add(textLabel); | ||||
| 			// Setting the message status icon and background color | ||||
| 			if (message.getRecipientID() != client.getID()) { | ||||
| 				cell.getChildren().add(new Label("", new ImageView(statusImages.get(message.getStatus())))); | ||||
| 				final var statusIcon = new Label("", new ImageView(statusImages.get(message.getStatus()))); | ||||
| 				statusIcon.setPadding(new Insets(1, 0, 5, 5)); | ||||
| 				cell.getChildren().add(statusIcon); | ||||
| 				cell.getStyleClass().add("own-message"); | ||||
| 			} else cell.getStyleClass().add("received-message"); | ||||
| 			// Adjusting height and weight of the cell to the corresponding ListView | ||||
| 			cell.paddingProperty().setValue(new Insets(5, 20, 5, 20)); | ||||
| 			cell.prefWidthProperty().bind(listView.widthProperty().subtract(40)); | ||||
| 			// Creating the Tooltip to deselect a message | ||||
| 			final var tooltip = new Tooltip("You can select a message by clicking on it \nand deselect it by pressing \"ctrl\" and clicking on it"); | ||||
| 			tooltip.setWrapText(true); | ||||
| 			tooltip.setAnchorLocation(AnchorLocation.WINDOW_TOP_LEFT); | ||||
| 			setTooltip(tooltip); | ||||
| 			setGraphic(cell); | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 delvh
					delvh