PerspectiveEditorPresenter extends BaseEditor<LayoutTemplate, DefaultMetadata> { @OnStartup public void onStartup(final ObservablePath path, final PlaceRequest place) { super.baseView = perspectiveEditorView; final String name = place.getParameter("name", ""); plugin = new Plugin(name, PluginType.PERSPECTIVE_LAYOUT, path); List<MenuItems> menuItems = new ArrayList<>(); addMenuItem(menuItems, SAVE, pluginController.canUpdate(plugin)); addMenuItem(menuItems, COPY, pluginController.canCreatePerspectives()); addMenuItem(menuItems, RENAME, pluginController.canUpdate(plugin)); addMenuItem(menuItems, DELETE, pluginController.canDelete(plugin)); init(path, place, resourceType, true, false, menuItems); initLayoutDragComponentGroups(); this.layoutEditorPlugin.init(name, org.uberfire.ext.plugin.client.resources.i18n.CommonConstants.INSTANCE.EmptyTitleText(), org.uberfire.ext.plugin.client.resources.i18n.CommonConstants.INSTANCE.EmptySubTitleText(), LayoutTemplate.Style.PAGE); this.layoutEditorPlugin.setPreviewEnabled(true); this.layoutEditorPlugin.setElementSelectionEnabled(true); this.perspectiveEditorView.setupLayoutEditor(layoutEditorPlugin.asWidget()); }  @OnStartup void onStartup(final ObservablePath path,
                          final PlaceRequest place); @OnFocus void onFocus(); @OnClose void onClose(); void initLayoutDragComponentGroups(); @OnMayClose boolean onMayClose(); @Override @WorkbenchPartTitleDecoration IsWidget getTitle(); @Override @WorkbenchPartTitle String getTitleText(); @WorkbenchMenu void getMenus(final Consumer<Menus> menusConsumer); @WorkbenchPartView UberView<PerspectiveEditorPresenter> getWidget(); int getCurrentModelHash(); @Override Validator getRenameValidator(); @Override Validator getCopyValidator(); void saveProperty(String key,
                             String value); String getLayoutProperty(String key); List<String> getAllTargetDivs(); static final String ID; }
@Test public void testInitLayoutEditor() { presenter.onStartup(observablePath, placeRequest); verify(layoutEditorPlugin).init(anyString(), anyString(), anyString(), eq(LayoutTemplate.Style.PAGE)); verify(layoutEditorPlugin).setPreviewEnabled(true); verify(layoutEditorPlugin).setElementSelectionEnabled(true); }
@Test public void testInitDragComponentGroups() { presenter.onStartup(observablePath, placeRequest); verify(layoutDragComponentPalette).clear(); verify(layoutDragComponentPalette).addDraggableGroups(providersCaptor.capture()); Collection<LayoutComponentPaletteGroupProvider> providers = providersCaptor.getValue(); Assertions.assertThat(providers) .hasSize(2) .containsExactly(perspectiveEditorGroupA, perspectiveEditorGroupB); }
@Test public void testTagsDisabledByDefault() { presenter.onStartup(observablePath, placeRequest); verify(menuBuilder).addSave(any(Command.class)); verify(menuBuilder).addCopy(any(Path.class), any(Validator.class), any(Caller.class)); verify(menuBuilder).addRename(any(Command.class)); verify(menuBuilder).addDelete(any(Path.class), any(Caller.class)); verify(menuBuilder).addDelete(any(Path.class), any(Caller.class)); verify(menuBuilder, never()).addNewTopLevelMenu(any()); }
@Test public void testTagsEnabled() { when(settings.isTagsEnabled()).thenReturn(true); presenter.onStartup(observablePath, placeRequest); verify(menuBuilder).addSave(any(Command.class)); verify(menuBuilder).addCopy(any(Path.class), any(Validator.class), any(Caller.class)); verify(menuBuilder).addRename(any(Command.class)); verify(menuBuilder).addDelete(any(Path.class), any(Caller.class)); verify(menuBuilder).addDelete(any(Path.class), any(Caller.class)); verify(menuBuilder).addNewTopLevelMenu(any()); }