Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make almost all of MacroButtonProperties fields non-null #4052

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public Object getMacroButtonProps(Token token, int index, String delim) throws P
props.addProperty("playerEditable", mbp.getAllowPlayerEdits());
props.addProperty("command", mbp.getCommand());
props.addProperty("maxWidth", mbp.getMaxWidth());
props.addProperty("tooltip", mbp.getToolTip() == null ? "" : mbp.getToolTip());
props.addProperty("tooltip", mbp.getToolTip());
props.addProperty("applyToSelected", mbp.getApplyToTokens());

JsonArray compare = new JsonArray();
Expand Down Expand Up @@ -223,7 +223,7 @@ public Object getMacroButtonProps(Token token, int index, String delim) throws P
sb.append("minWidth=").append(mbp.getMinWidth()).append(delim);
sb.append("playerEditable=").append(mbp.getAllowPlayerEdits()).append(delim);
sb.append("maxWidth=").append(mbp.getMaxWidth()).append(delim);
sb.append("tooltip=").append(mbp.getToolTip() == null ? "" : mbp.getToolTip()).append(delim);
sb.append("tooltip=").append(mbp.getToolTip()).append(delim);
sb.append("applyToSelected=").append(mbp.getApplyToTokens()).append(delim);
return sb.toString();
}
Expand Down Expand Up @@ -419,8 +419,7 @@ private String getMacroCommand(int index, Token token) throws ParserException {
throw new ParserException(
I18N.getText(KEY_OUT_OF_RANGE, "getMacroCommand", index, token.getName()));
}
String cmd = mbp.getCommand();
return cmd != null ? cmd : "";
return mbp.getCommand();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ protected JMenu createMacroMenu() {
Map<String, JMenu> groups = new TreeMap<String, JMenu>();
for (MacroButtonProperties macro : macroList) {
group = macro.getGroup();
group =
(group == null || group.isEmpty()
? " General"
: group); // leading space makes it come first
group = (group.isEmpty() ? " General" : group); // leading space makes it come first
JMenu submenu = groups.get(group);
if (submenu == null) {
submenu = new JMenu(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public List<MacroButtonProperties> getPropertiesList() {
}

public void setPropertiesList(List<MacroButtonProperties> propertiesList) {
MacroButtonProperties.fixOldMacroSetCompare(propertiesList);
this.propertiesList = propertiesList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public MacroButton(MacroButtonProperties properties, ButtonGroup buttonGroup, To
}
this.properties.setTokenId(this.tokenId);
this.properties.setSaveLocation(this.panelClass);
this.properties.setButton(this);
// we have to call setColor() and setText() here since properties only hold "dumb" data.
setColor(properties.getColorKey());
setText(getButtonText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void show(MacroButton button) {

if (properties != null) {
oldHashCode = properties.hashCodeForComparison();
Boolean playerCanEdit = !MapTool.getPlayer().isGM() && properties.getAllowPlayerEdits();
boolean playerCanEdit = !MapTool.getPlayer().isGM() && properties.getAllowPlayerEdits();
boolean onGlobalPanel = properties.getSaveLocation().equals("Global");
boolean allowEdits = onGlobalPanel || MapTool.getPlayer().isGM() || playerCanEdit;
boolean isCommonMacro =
Expand Down
Loading