Skip to content

Commit

Permalink
Add unique id to ToolbarEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
georgweiss committed Oct 14, 2024
1 parent f33eeb3 commit 7d6ff4d
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ public Void call() throws Exception {
ApplicationService.createInstance(CredentialsManagementApp.name);
return null;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Credentials Management";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,34 @@
* @author Kay Kasemir
*/
@SuppressWarnings("nls")
public class OpenDataBrowser implements MenuEntry, ToolbarEntry
{
public class OpenDataBrowser implements MenuEntry, ToolbarEntry {
@Override
public String getName()
{
public String getName() {
return Messages.DataBrowser;
}

@Override
public String getMenuPath()
{
public String getMenuPath() {
return Messages.DataBrowserMenuPath;
}

@Override
public Image getIcon()
{
public Image getIcon() {
return ImageCache.getImage(getClass(), "/icons/databrowser.png");
}

@Override
public Void call() throws Exception
{
public Void call() throws Exception {
ApplicationService.createInstance(DataBrowserApp.NAME);
return null;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Data Browser";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ public Void call() throws Exception {
ApplicationService.createInstance(FileBrowserApp.Name);
return null;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "File Browser";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ public Void call() throws Exception {
ApplicationService.createInstance(LoggingConfigurationApplication.NAME);
return null;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Logging Config";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public Image getIcon()
{
return LogEntryTableApp.icon;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Log Entry Table";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ public Image getIcon()
{
return SendToLogBookApp.icon;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Send To Log Book";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@ public Image getIcon()
{
return SendToLogBookApp.icon;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Send To Log Book";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,13 @@ public Void call() throws Exception {
ApplicationService.createInstance(Probe.NAME);
return null;
}

/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Probe";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ public Void call() throws Exception
ApplicationService.createInstance(PVTreeApplication.NAME);
return null;
}


/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "PV Tree";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,14 @@ public Void call() throws Exception
ApplicationService.createInstance(ScanMonitorApplication.NAME);
return null;
}


/**
* DO NOT CHANGE RETURN VALUE!
* @return The unique id of this {@link ToolbarEntry}.
*/
@Override
public String getId(){
return "Scan Monitor";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private ToolbarEntryService() {
// Add specific 'desired' entry
ToolbarEntry found = null;
for (ToolbarEntry entry : available)
if (entry.getName().equalsIgnoreCase(desired))
if (entry.getId().equalsIgnoreCase(desired))
{
found = entry;
break;
Expand Down
8 changes: 8 additions & 0 deletions core/ui/src/main/java/org/phoebus/ui/spi/ToolbarEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ public default Image getIcon()
{
return null;
}

/**
* A unique id for the {@link ToolbarEntry}. Implementations <b>must</b> ensure that this
* is indeed unique and immutable. In particular, it should be insensitive to localization and
* customization of an app name.
* @return Unique id of the {@link ToolbarEntry}.
*/
String getId();
}
6 changes: 5 additions & 1 deletion core/ui/src/main/resources/phoebus_ui_preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ home_display=examples:/01_main.bob?app=display_runtime,Example Display
# An entry starting with "!" removes that item from the available entries.
# The order of the initial buttons "Home, Top Resources, Layouts"
# cannot be changed, but they can be suppressed by adding "!",
# for example "Home, !Top Resources, !Layouts"
# for example "Home, !Top Resources, !Layouts".
#
# The strings in the list of entries MUST match what is returned from
# ToolbarEntry#getId(). This allows for customization/localization of app name
# without the need to adjust the list.
#
# Examples:
#
Expand Down

0 comments on commit 7d6ff4d

Please sign in to comment.