Skip to content

Commit f8889fd

Browse files
committed
Change StatSheetProperties constructor to handle default location
There were several callers that had to check for a `null` location and replace it with the default of `BOTTOM_LEFT`. That is no longer necessary since the `StatSheetProperties` constructor will do so.
1 parent dd8d0e2 commit f8889fd

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

src/main/java/net/rptools/maptool/client/ui/campaignproperties/TokenPropertiesManagementPanel.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,7 @@ private void populateStatSheetComboBoxes(String propertyType) {
481481
if (statSheetProperty == null) {
482482
id = ssManager.getDefaultStatSheetId();
483483
tokenTypeStatSheetMap.put(
484-
propertyType,
485-
new StatSheetProperties(
486-
ssManager.getDefaultStatSheetId(), StatSheetLocation.BOTTOM_LEFT));
484+
propertyType, new StatSheetProperties(ssManager.getDefaultStatSheetId(), null));
487485
} else {
488486
id = statSheetProperty.id();
489487
}

src/main/java/net/rptools/maptool/client/ui/token/dialog/create/NewTokenDialog.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,6 @@ public boolean commit() {
170170
if (statSheet == null || (statSheet.name() == null && statSheet.namespace() == null)) {
171171
token.useDefaultStatSheet();
172172
} else {
173-
if (location == null) {
174-
location = StatSheetLocation.BOTTOM_LEFT;
175-
}
176173
token.setStatSheet(new StatSheetProperties(ssManager.getId(statSheet), location));
177174
}
178175

src/main/java/net/rptools/maptool/client/ui/token/dialog/edit/EditTokenDialog.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,6 @@ public boolean commit() {
910910
} else {
911911
var ssManager = new StatSheetManager();
912912
var location = (StatSheetLocation) getStatSheetLocationCombo().getSelectedItem();
913-
if (location == null) {
914-
location = StatSheetLocation.BOTTOM_LEFT;
915-
}
916913
token.setStatSheet(new StatSheetProperties(ssManager.getId(ss), location));
917914
}
918915

src/main/java/net/rptools/maptool/model/CampaignProperties.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
import net.rptools.maptool.client.ui.token.YieldTokenOverlay;
5151
import net.rptools.maptool.language.I18N;
5252
import net.rptools.maptool.model.drawing.DrawableColorPaint;
53-
import net.rptools.maptool.model.sheet.stats.StatSheetLocation;
5453
import net.rptools.maptool.model.sheet.stats.StatSheetManager;
5554
import net.rptools.maptool.model.sheet.stats.StatSheetProperties;
5655
import net.rptools.maptool.server.proto.CampaignPropertiesDto;
@@ -212,9 +211,7 @@ public Map<String, List<TokenProperty>> getTokenTypeMap() {
212211
*/
213212
public StatSheetProperties getTokenTypeDefaultStatSheet(String propertyType) {
214213
return tokenTypeStatSheetMap.getOrDefault(
215-
propertyType,
216-
new StatSheetProperties(
217-
StatSheetManager.LEGACY_STATSHEET_ID, StatSheetLocation.BOTTOM_LEFT));
214+
propertyType, new StatSheetProperties(StatSheetManager.LEGACY_STATSHEET_ID, null));
218215
}
219216

220217
/**

src/main/java/net/rptools/maptool/model/sheet/stats/StatSheetProperties.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package net.rptools.maptool.model.sheet.stats;
1616

1717
import java.util.Objects;
18+
import javax.annotation.Nullable;
1819
import net.rptools.maptool.server.proto.StatSheetPropertiesDto;
1920

2021
/**
@@ -33,11 +34,12 @@ public final class StatSheetProperties {
3334
* Creates a new instance of the class.
3435
*
3536
* @param id The id of the stat sheet.
36-
* @param location The location of the stat sheet.
37+
* @param location The location of the stat sheet, or {@code null} to use the default of {@link
38+
* StatSheetLocation#BOTTOM_LEFT}.
3739
*/
38-
public StatSheetProperties(String id, StatSheetLocation location) {
40+
public StatSheetProperties(String id, @Nullable StatSheetLocation location) {
3941
this.id = id;
40-
this.location = location;
42+
this.location = Objects.requireNonNullElse(location, StatSheetLocation.BOTTOM_LEFT);
4143
}
4244

4345
/**

0 commit comments

Comments
 (0)