added owner string to cell

This commit is contained in:
frosch95
2013-09-29 18:29:56 +02:00
parent c0a64e2627
commit 6d28263f63

View File

@@ -26,7 +26,6 @@
package de.frosch95.geofrogger.fx.components; package de.frosch95.geofrogger.fx.components;
import de.frosch95.geofrogger.model.Cache; import de.frosch95.geofrogger.model.Cache;
import de.frosch95.geofrogger.model.CacheUtils;
import javafx.geometry.Insets; import javafx.geometry.Insets;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
@@ -54,8 +53,8 @@ public class CacheListCell extends ListCell<Cache> {
private final ImageView icon = new ImageView(); private final ImageView icon = new ImageView();
private final Label name = new Label(); private final Label name = new Label();
private final Label dt = new Label(); private final Label dt = new Label();
private final Label owner = new Label();
private final ImageView foundIcon = new ImageView(); private final ImageView foundIcon = new ImageView();
private final ImageView favoriteIcon = new ImageView();
public CacheListCell() { public CacheListCell() {
configureGrid(); configureGrid();
@@ -83,8 +82,10 @@ public class CacheListCell extends ListCell<Cache> {
ColumnConstraints column1 = new ColumnConstraints(32); ColumnConstraints column1 = new ColumnConstraints(32);
ColumnConstraints column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE); ColumnConstraints column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE);
column2.setHgrow(Priority.ALWAYS); column2.setHgrow(Priority.ALWAYS);
ColumnConstraints column3 = new ColumnConstraints(32); ColumnConstraints column3 = new ColumnConstraints(100, 100, 200);
grid.getColumnConstraints().addAll(column1, column2, column3); column3.setHgrow(Priority.SOMETIMES);
ColumnConstraints column4 = new ColumnConstraints(32);
grid.getColumnConstraints().addAll(column1, column2, column3, column4);
} }
private void configureIcon() { private void configureIcon() {
@@ -101,10 +102,10 @@ public class CacheListCell extends ListCell<Cache> {
private void addControlsToGrid() { private void addControlsToGrid() {
grid.add(icon, 0, 0, 1, 2); grid.add(icon, 0, 0, 1, 2);
grid.add(name, 1, 0); grid.add(name, 1, 0, 2, 1);
grid.add(dt, 1, 1); grid.add(dt, 2, 1);
grid.add(foundIcon, 2, 0); grid.add(owner, 1, 1);
grid.add(favoriteIcon, 2, 1); grid.add(foundIcon, 3, 0);
} }
private void clearContent() { private void clearContent() {
@@ -118,6 +119,9 @@ public class CacheListCell extends ListCell<Cache> {
name.setText(cache.getName()); name.setText(cache.getName());
dt.setText("D: " + cache.getDifficulty() + " / T:" + cache.getTerrain()); dt.setText("D: " + cache.getDifficulty() + " / T:" + cache.getTerrain());
String ownerText = cache.getPlacedBy().equals(cache.getOwner().getName()) ? cache.getPlacedBy() : cache.getPlacedBy() + " (" + cache.getOwner().getName() + ")";
owner.setText(ownerText);
if (cache.isFound()) { if (cache.isFound()) {
foundIcon.setImage(IconManager.getIcon("/icons/iconmonstr-check-mark-11-icon.png", IconManager.IconSize.SMALL)); foundIcon.setImage(IconManager.getIcon("/icons/iconmonstr-check-mark-11-icon.png", IconManager.IconSize.SMALL));
} else { } else {