public TemplatePerspectiveDefinitionImpl() { this.root = new PanelDefinitionImpl( PanelType.TEMPLATE ); }
private PerspectiveDefinition createPerspectiveDefinition() { PerspectiveDefinitionImpl perspectiveDefinition = new PerspectiveDefinitionImpl(); PanelDefinition root = perspectiveDefinition.getRoot(); partDefinitionsRoot.forEach(p -> root.addPart(p)); PanelDefinitionImpl rootChild1 = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild1.forEach(p -> rootChild1.addPart(p)); PanelDefinitionImpl rootChild2 = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild2.forEach(p -> rootChild2.addPart(p)); PanelDefinitionImpl rootChild2Child = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild2Child.forEach(p -> rootChild2Child.addPart(p)); root.insertChild(mock(Position.class), rootChild1); rootChild2.insertChild(mock(Position.class), rootChild2Child); root.insertChild(mock(Position.class), rootChild2); return perspectiveDefinition; }
@Test public void appendChildShouldAddPanelToChildren() { panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); assertEquals(panelDefinition, otherPanel.getParent()); }
@Override public PanelDefinition addWorkbenchPanel(final PanelDefinition targetPanel, final Position position, final Integer height, final Integer width, final Integer minHeight, final Integer minWidth) { final PanelDefinitionImpl childPanel = new PanelDefinitionImpl(PanelDefinition.PARENT_CHOOSES_TYPE); childPanel.setHeight(height); childPanel.setWidth(width); childPanel.setMinHeight(minHeight); childPanel.setMinWidth(minWidth); return addWorkbenchPanel(targetPanel, childPanel, position); }
public PerspectiveDefinitionImpl(final String panelType) { checkNotNull("type", panelType); PanelDefinitionImpl root = new PanelDefinitionImpl(panelType); root.setRoot(true); this.root = root; }
@Test public void appendChildToPanelTwiceShouldWork() { panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); } }
@SuppressWarnings("unchecked") @Test public void removingChildPanelShouldClearParentPointers() throws Exception { AbstractMultiPartWorkbenchPanelPresenter<?> presenter = getPresenterToTest(); PanelDefinitionImpl childPanelDef = new PanelDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName()); WorkbenchPanelPresenter childPanelPresenter = mock(WorkbenchPanelPresenter.class); WorkbenchPanelView<WorkbenchPanelPresenter> childPanelView = mock(WorkbenchPanelView.class); when(childPanelView.getPresenter()).thenReturn(childPanelPresenter); presenter.addPanel(childPanelPresenter, CompassPosition.NORTH); presenter.removePanel(childPanelPresenter); verify(childPanelPresenter).setParent(null); assertNull(childPanelDef.getParent()); }
@Test public void partShouldNotBePresentAfterRemoval() throws Exception { panelDefinition.addPart(part); assertNotNull(part.getParentPanel()); assertTrue(panelDefinition.getParts().contains(part)); panelDefinition.removePart(part); assertNull(part.getParentPanel()); assertFalse(panelDefinition.getParts().contains(part)); }
@Override public PartDefinition addPart(String partSpec) { PartDefinition pd = new PartDefinitionImpl(DefaultPlaceRequest.parse(partSpec)); addPart(pd); return pd; }
@Override public void appendChild( final Position position, final PanelDefinition panel ) { super.appendChild( position, panel ); }
@SuppressWarnings("unchecked") @Test public void removingChildPanelShouldClearParentPointers() throws Exception { AbstractMultiPartWorkbenchPanelPresenter<?> presenter = getPresenterToTest(); PanelDefinitionImpl childPanelDef = new PanelDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName()); WorkbenchPanelPresenter childPanelPresenter = mock(WorkbenchPanelPresenter.class); WorkbenchPanelView<WorkbenchPanelPresenter> childPanelView = mock(WorkbenchPanelView.class); when(childPanelView.getPresenter()).thenReturn(childPanelPresenter); presenter.addPanel(childPanelPresenter, CompassPosition.NORTH); presenter.removePanel(childPanelPresenter); verify(childPanelPresenter).setParent(null); assertNull(childPanelDef.getParent()); }
@Test public void partShouldNotBePresentAfterRemoval() throws Exception { panelDefinition.addPart(part); assertNotNull(part.getParentPanel()); assertTrue(panelDefinition.getParts().contains(part)); panelDefinition.removePart(part); assertNull(part.getParentPanel()); assertFalse(panelDefinition.getParts().contains(part)); }
@Test public void appendChildToPanelTwiceShouldWork() { panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); } }
PanelDefinition addWorkbenchPanelTo( Position position ) { return new PanelDefinitionImpl( PanelType.ROOT_SIMPLE ); }
@SuppressWarnings("unchecked") @Test public void addingChildPanelShouldUpdateParentPointers() throws Exception { AbstractMultiPartWorkbenchPanelPresenter<?> presenter = getPresenterToTest(); PanelDefinitionImpl childPanelDef = new PanelDefinitionImpl(MultiListWorkbenchPanelPresenter.class.getName()); WorkbenchPanelPresenter childPanelPresenter = mock(WorkbenchPanelPresenter.class); when(childPanelPresenter.getDefinition()).thenReturn(childPanelDef); WorkbenchPanelView<WorkbenchPanelPresenter> childPanelView = mock(WorkbenchPanelView.class); when(childPanelView.getPresenter()).thenReturn(childPanelPresenter); presenter.addPanel(childPanelPresenter, CompassPosition.NORTH); verify(childPanelPresenter).setParent(presenter); assertSame(presenter.getDefinition(), childPanelDef.getParent()); }
private PerspectiveDefinition createPerspectiveDefinition() { PerspectiveDefinitionImpl perspectiveDefinition = new PerspectiveDefinitionImpl(); PanelDefinition root = perspectiveDefinition.getRoot(); partDefinitionsRoot.forEach(p -> root.addPart(p)); PanelDefinitionImpl rootChild1 = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild1.forEach(p -> rootChild1.addPart(p)); PanelDefinitionImpl rootChild2 = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild2.forEach(p -> rootChild2.addPart(p)); PanelDefinitionImpl rootChild2Child = new PanelDefinitionImpl("org.uberfire.client.workbench.panels.impl.MultiTabWorkbenchPanelPresenter"); partDefinitionRootChild2Child.forEach(p -> rootChild2Child.addPart(p)); root.insertChild(mock(Position.class), rootChild1); rootChild2.insertChild(mock(Position.class), rootChild2Child); root.insertChild(mock(Position.class), rootChild2); return perspectiveDefinition; }
@Test public void appendChildShouldAddPanelToChildren() { panelDefinition.appendChild(otherPanel); assertTrue(panelDefinition.getChildren().contains(otherPanel)); assertEquals(panelDefinition, otherPanel.getParent()); }