Test fixes

This commit is contained in:
dragonmacher 2025-09-02 14:33:46 -04:00
parent 48a7542e47
commit f7c1714bb1
3 changed files with 37 additions and 21 deletions

View file

@ -41,8 +41,8 @@ public class BookmarkEditCmd implements Command<Program> {
private String presentationName;
/**
* Edit a Bookmark. When editing a bookmark, all fields are used except the address
* which is determined by the first address within each range of the set.
* Constructor
*
* @param set list of bookmark addresses.
* @param type the bookmark type.
* @param category the bookmark category.
@ -53,14 +53,15 @@ public class BookmarkEditCmd implements Command<Program> {
this.category = category;
this.comment = comment;
this.set = set;
if (set == null || set.isEmpty() || type == null || type.length() == 0)
if (set == null || set.isEmpty() || type == null || type.length() == 0) {
throw new IllegalArgumentException();
}
presentationName = "Add " + type + " Bookmark(s)";
}
/**
* Edit a Bookmark. When editing a bookmark, all fields are used except the address
* which is provided by the addrs parameter.
* Constructor
*
* @param addr the bookmark address.
* @param type the bookmark type.
* @param category the bookmark category.
@ -71,8 +72,9 @@ public class BookmarkEditCmd implements Command<Program> {
this.category = category;
this.comment = comment;
this.addr = addr;
if (addr == null || type == null || type.length() == 0)
if (addr == null || type == null || type.length() == 0) {
throw new IllegalArgumentException();
}
presentationName = "Add " + type + " Bookmark";
}
@ -80,13 +82,14 @@ public class BookmarkEditCmd implements Command<Program> {
this.bookmark = bookmark;
this.category = category;
this.comment = comment;
if (bookmark == null)
if (bookmark == null) {
throw new IllegalArgumentException();
}
presentationName = "Edit " + bookmark.getTypeString() + " Bookmark";
}
/**
* The name of the edit action.
* {@return The name of the edit action.}
*/
public String getPresentationName() {
return presentationName;

View file

@ -82,7 +82,11 @@ public class BookmarkNavigator {
Icon icon = bmt.getIcon();
if (icon == null) {
icon = DEFAULT_ICON;
if (bookmarkManager.isDefinedType(type)) {
// This implies the client defined a type, but did not pass a valid icon. In this
// case we will show a special icon.
icon = DEFAULT_ICON;
}
}
Color color = bmt.getMarkerColor();
@ -90,8 +94,23 @@ public class BookmarkNavigator {
color = DEFAULT_COLOR;
}
markerSet = markerService.createPointMarker(type + " Bookmarks", type + " Bookmarks",
bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
//
// Be default, bookmarks appear with an icon on the left side of the Listing. If there is
// no icon, then skip the icon and instead add a color marker on the right side of the
// Listing so the user can see the bookmark. As long as clients call BookmarkManager's
// defineType() method with a valid icon, then we will show the icon, which is the expected
// behavior.
//
String markerName = type + " Bookmarks";
if (icon != null) {
markerSet = markerService.createPointMarker(markerName, markerName,
bookmarkMgr.getProgram(), priority, true, true, false, color, icon);
}
else {
markerSet =
markerService.createAreaMarker(markerName, markerName, bookmarkMgr.getProgram(),
priority, false, true, false, color);
}
markerSet.setMarkerDescriptor(new MarkerDescriptor() {

View file

@ -306,12 +306,6 @@ public class BookmarkPlugin extends ProgramPlugin implements PopupActionProvider
}
BookmarkManager bookmarkManager = currentProgram.getBookmarkManager();
if (!bookmarkManager.isDefinedType(typeString)) {
// This implies the bookmark was created by a plugin that is no longer available in
// the current tool.
return null;
}
nav = new BookmarkNavigator(markerService, bookmarkManager, type);
bookmarkNavigators.put(typeString, nav);
return nav;