Skip to content

Commit

Permalink
Merge pull request #3227 from ControlSystemStudio/CSSTUDIO-2648
Browse files Browse the repository at this point in the history
CSSTUDIO-2648 "Add Layout" toolbar button and new "Add Layout" icon
  • Loading branch information
shroffk authored Jan 9, 2025
2 parents a0e3746 + 6287407 commit f12b02e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public class PhoebusApplication extends Application {
/**
* Menu to add a layout to the current layout
*/
private final Menu add_layout = new Menu(Messages.AddLayout, ImageCache.getImageView(ImageCache.class, "/icons/layouts.png"));
private final Menu add_layout = new Menu(Messages.AddLayout, ImageCache.getImageView(ImageCache.class, "/icons/add_layout.png"));

/**
* List of memento names
Expand All @@ -229,6 +229,11 @@ public class PhoebusApplication extends Application {
*/
private MenuButton layout_menu_button;

/**
* Toolbar button for adding past layouts
*/
private MenuButton add_layout_menu_button;

/**
* Last file used by 'File, Open' menu
* (the _directory_ is actually used by the file-open dialog)
Expand Down Expand Up @@ -759,6 +764,7 @@ void createLoadLayoutsMenu() {
final List<MenuItem> menuItemList = new ArrayList<>();
final List<MenuItem> toolbarMenuItemList = new ArrayList<>();
final List<MenuItem> addLayoutMenuItemList = new ArrayList<>();
final List<MenuItem> toolbarAddLayoutMenuItemList = new ArrayList<>();

final Map<String, File> layoutFiles = new HashMap<String, File>();

Expand Down Expand Up @@ -822,6 +828,12 @@ void createLoadLayoutsMenu() {
addLayoutMenuItem.setMnemonicParsing(false);
addLayoutMenuItem.setOnAction(event -> startAddingLayout(file));
addLayoutMenuItemList.add(addLayoutMenuItem);

// Repeat for the same menu in the toolbar. They can't share menu items.
final MenuItem toolbarAddLayoutMenuItem = new MenuItem(filename);
toolbarAddLayoutMenuItem.setMnemonicParsing(false);
toolbarAddLayoutMenuItem.setOnAction(event -> startAddingLayout(file));
toolbarAddLayoutMenuItemList.add(toolbarAddLayoutMenuItem);
}
});
}
Expand All @@ -832,6 +844,7 @@ void createLoadLayoutsMenu() {
load_layout.getItems().setAll(menuItemList);
add_layout.getItems().setAll(addLayoutMenuItemList);
layout_menu_button.getItems().setAll(toolbarMenuItemList);
add_layout_menu_button.getItems().setAll(toolbarAddLayoutMenuItemList);
delete_layouts.setDisable(memento_files.isEmpty());
});
});
Expand Down Expand Up @@ -965,6 +978,12 @@ private ToolBar createToolbar() {
if (! Preferences.toolbar_entries.contains("!Layouts"))
toolBar.getItems().add(layout_menu_button);

add_layout_menu_button = new MenuButton(null, ImageCache.getImageView(getClass(), "/icons/add_layout.png"));
add_layout_menu_button.setTooltip(new Tooltip(Messages.AddLayout));
if (Preferences.toolbar_entries.contains("Add Layouts") && !Preferences.toolbar_entries.contains("!Add Layouts")) {
toolBar.getItems().add(add_layout_menu_button);
}

// Contributed Entries
ToolbarEntryService.getInstance().listToolbarEntries().forEach((entry) -> {
final AtomicBoolean open_new = new AtomicBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private ToolbarEntryService() {
if (suppress)
desired = desired.substring(1);
// Skip entries handled in PhoebusApplication
if (desired.equals("Home") || desired.equals("Top Resources") || desired.equals("Layouts"))
if (desired.equals("Home") || desired.equals("Top Resources") || desired.equals("Layouts") || desired.equals("Add Layouts"))
continue;
// Add specific 'desired' entry
ToolbarEntry found = null;
Expand Down
Binary file added core/ui/src/main/resources/icons/add_layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions core/ui/src/main/resources/phoebus_ui_preferences.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ home_display=examples:/01_main.bob?app=display_runtime,Example Display
#
# The special entry "*" adds all remaining available toolbar entries.
# An entry starting with "!" removes that item from the available entries.
# The order of the initial buttons "Home, Top Resources, Layouts"
# The order of the initial buttons "Home, Top Resources, Layouts, Add Layouts"
# cannot be changed, but they can be suppressed by adding "!",
# for example "Home, !Top Resources, !Layouts".
# for example "Home, !Top Resources, !Layouts, !Add Layouts".
#
# The special entry "Add Layouts" is NOT added to the toolbar by default. It
# can be added to the toolbar by specifying "Add Layouts".
#
# The strings in the list of entries MUST match what is returned from
# ToolbarEntry#getId(). This allows for customization/localization of app name
Expand Down

0 comments on commit f12b02e

Please sign in to comment.