@Test public void testPluginRenamed() { NavTree tree = TEST_NAV_TREE.cloneTree(); List<NavItem> items = tree.searchItems(NavWorkbenchCtx.perspective(PERSPECTIVE_ID)); assertThat((items).get(0).getName()).isEqualTo("name1"); assertThat((items).get(0).getContext()).contains("resourceId=" + PERSPECTIVE_ID); when(navigationManager.getNavTree()).thenReturn(tree); testedPluginManager.onPlugInRenamed(pluginRenamedEvent); assertThat(tree.searchItems(NavWorkbenchCtx.perspective(PERSPECTIVE_ID))).isEmpty(); assertThat(tree.searchItems(NavWorkbenchCtx.perspective(perspectiveRenamedPlugin.getName())).get(0).getContext()).contains("resourceId=" + perspectiveRenamedPlugin.getName()); ArgumentCaptor<Command> argumentCaptor = ArgumentCaptor.forClass(Command.class); verify(navigationManager, times(1)).saveNavTree(anyObject(), argumentCaptor.capture()); verify(perspectiveChangedEvent).fire(anyObject()); }
public void onPlugInRenamed(@Observes final PluginRenamed event) { Plugin plugin = event.getPlugin(); if (isRuntimePerspective(plugin)) { pluginMap.remove(event.getOldPluginName()); pluginMap.put(plugin.getName(), plugin); NavWorkbenchCtx ctx = NavWorkbenchCtx.perspective(event.getOldPluginName()); NavWorkbenchCtx newCtx = NavWorkbenchCtx.perspective(event.getPlugin().getName()); List<NavItem> itemsToRename = navigationManager.getNavTree().searchItems(ctx); for (NavItem navItem : itemsToRename) { navItem.setContext(newCtx.toString()); } if (!itemsToRename.isEmpty()) { navigationManager.saveNavTree(navigationManager.getNavTree(), () -> {}); } perspectivesChangedEvent.fire(new PerspectivePluginsChangedEvent()); } }
PerspectivePluginManager { public void onPlugInRenamed(@Observes final PluginRenamed event) { Plugin plugin = event.getPlugin(); if (isRuntimePerspective(plugin)) { pluginMap.remove(event.getOldPluginName()); pluginMap.put(plugin.getName(), plugin); NavWorkbenchCtx ctx = NavWorkbenchCtx.perspective(event.getOldPluginName()); NavWorkbenchCtx newCtx = NavWorkbenchCtx.perspective(event.getPlugin().getName()); List<NavItem> itemsToRename = navigationManager.getNavTree().searchItems(ctx); for (NavItem navItem : itemsToRename) { navItem.setContext(newCtx.toString()); } if (!itemsToRename.isEmpty()) { navigationManager.saveNavTree(navigationManager.getNavTree(), () -> {}); } perspectivesChangedEvent.fire(new PerspectivePluginsChangedEvent()); } } }
PerspectivePluginManager { public void onPlugInRenamed(@Observes final PluginRenamed event) { Plugin plugin = event.getPlugin(); if (isRuntimePerspective(plugin)) { pluginMap.remove(event.getOldPluginName()); pluginMap.put(plugin.getName(), plugin); NavWorkbenchCtx ctx = NavWorkbenchCtx.perspective(event.getOldPluginName()); NavWorkbenchCtx newCtx = NavWorkbenchCtx.perspective(event.getPlugin().getName()); List<NavItem> itemsToRename = navigationManager.getNavTree().searchItems(ctx); for (NavItem navItem : itemsToRename) { navItem.setContext(newCtx.toString()); } if (!itemsToRename.isEmpty()) { navigationManager.saveNavTree(navigationManager.getNavTree(), () -> {}); } perspectivesChangedEvent.fire(new PerspectivePluginsChangedEvent()); } } @Inject  PerspectivePluginManager(ClientTypeRegistry clientTypeRegistry,
                                    LayoutGenerator layoutGenerator,
                                    NavigationManager navigationManager,
                                    Caller<PerspectivePluginServices> pluginServices,
                                    Event<PerspectivePluginsChangedEvent> perspectivesChangedEvent); }
PerspectivePluginManager { public void onPlugInRenamed(@Observes final PluginRenamed event) { Plugin plugin = event.getPlugin(); if (isRuntimePerspective(plugin)) { pluginMap.remove(event.getOldPluginName()); pluginMap.put(plugin.getName(), plugin); NavWorkbenchCtx ctx = NavWorkbenchCtx.perspective(event.getOldPluginName()); NavWorkbenchCtx newCtx = NavWorkbenchCtx.perspective(event.getPlugin().getName()); List<NavItem> itemsToRename = navigationManager.getNavTree().searchItems(ctx); for (NavItem navItem : itemsToRename) { navItem.setContext(newCtx.toString()); } if (!itemsToRename.isEmpty()) { navigationManager.saveNavTree(navigationManager.getNavTree(), () -> {}); } perspectivesChangedEvent.fire(new PerspectivePluginsChangedEvent()); } } @Inject  PerspectivePluginManager(ClientTypeRegistry clientTypeRegistry,
                                    LayoutGenerator layoutGenerator,
                                    NavigationManager navigationManager,
                                    Caller<PerspectivePluginServices> pluginServices,
                                    Event<PerspectivePluginsChangedEvent> perspectivesChangedEvent); void getPerspectivePlugins(ParameterizedCommand<Collection<Plugin>> callback); boolean isRuntimePerspective(Plugin plugin); boolean isRuntimePerspective(NavItem navItem); boolean isRuntimePerspective(String perspectiveId); String getRuntimePerspectiveId(NavItem navItem); boolean existsPerspectivePlugin(String perspectiveName); void buildPerspectiveWidget(String perspectiveName, ParameterizedCommand<IsWidget> afterBuild, ParameterizedCommand<LayoutRecursionIssue> onInfiniteRecursion); void getLayoutTemplateInfo(String perspectiveName, ParameterizedCommand<LayoutTemplateInfo> callback); void getLayoutTemplateInfo(LayoutTemplate layoutTemplate, ParameterizedCommand<LayoutTemplateInfo> callback); void buildPerspectiveWidget(String perspectiveName, LayoutTemplateContext layoutCtx, ParameterizedCommand<IsWidget> afterBuild, ParameterizedCommand<LayoutRecursionIssue> onInfiniteRecursion); NavGroup getLastBuildPerspectiveNavGroup(); void onPlugInAdded(@Observes final PluginAdded event); void onPlugInSaved(@Observes final PluginSaved event); void onPlugInRenamed(@Observes final PluginRenamed event); void onPlugInDeleted(@Observes final PluginDeleted event); }
PerspectivePluginManager { public void onPlugInRenamed(@Observes final PluginRenamed event) { Plugin plugin = event.getPlugin(); if (isRuntimePerspective(plugin)) { pluginMap.remove(event.getOldPluginName()); pluginMap.put(plugin.getName(), plugin); NavWorkbenchCtx ctx = NavWorkbenchCtx.perspective(event.getOldPluginName()); NavWorkbenchCtx newCtx = NavWorkbenchCtx.perspective(event.getPlugin().getName()); List<NavItem> itemsToRename = navigationManager.getNavTree().searchItems(ctx); for (NavItem navItem : itemsToRename) { navItem.setContext(newCtx.toString()); } if (!itemsToRename.isEmpty()) { navigationManager.saveNavTree(navigationManager.getNavTree(), () -> {}); } perspectivesChangedEvent.fire(new PerspectivePluginsChangedEvent()); } } @Inject  PerspectivePluginManager(ClientTypeRegistry clientTypeRegistry,
                                    LayoutGenerator layoutGenerator,
                                    NavigationManager navigationManager,
                                    Caller<PerspectivePluginServices> pluginServices,
                                    Event<PerspectivePluginsChangedEvent> perspectivesChangedEvent); void getPerspectivePlugins(ParameterizedCommand<Collection<Plugin>> callback); boolean isRuntimePerspective(Plugin plugin); boolean isRuntimePerspective(NavItem navItem); boolean isRuntimePerspective(String perspectiveId); String getRuntimePerspectiveId(NavItem navItem); boolean existsPerspectivePlugin(String perspectiveName); void buildPerspectiveWidget(String perspectiveName, ParameterizedCommand<IsWidget> afterBuild, ParameterizedCommand<LayoutRecursionIssue> onInfiniteRecursion); void getLayoutTemplateInfo(String perspectiveName, ParameterizedCommand<LayoutTemplateInfo> callback); void getLayoutTemplateInfo(LayoutTemplate layoutTemplate, ParameterizedCommand<LayoutTemplateInfo> callback); void buildPerspectiveWidget(String perspectiveName, LayoutTemplateContext layoutCtx, ParameterizedCommand<IsWidget> afterBuild, ParameterizedCommand<LayoutRecursionIssue> onInfiniteRecursion); NavGroup getLastBuildPerspectiveNavGroup(); void onPlugInAdded(@Observes final PluginAdded event); void onPlugInSaved(@Observes final PluginSaved event); void onPlugInRenamed(@Observes final PluginRenamed event); void onPlugInDeleted(@Observes final PluginDeleted event);  }