Container implements LayoutEditorElement { protected void swapRows(@Observes RowDnDEvent rowDndEvent) { List<Row> newRows = new ArrayList<>(); Row beginRow = lookForBeginningRow(rowDndEvent); if (beginRow != null) { for (Row row : rows) { if (row.getId() == rowDndEvent.getRowIdEnd()) { if (rowDndEvent.getOrientation() == RowDrop.Orientation.AFTER) { newRows.add(row); newRows.add(beginRow); } else { newRows.add(beginRow); newRows.add(row); } } else { if (row.getId() != beginRow.getId()) { newRows.add(row); } } } this.rows = newRows; } updateView(); } @Inject  Container(final View view,
                     LayoutEditorCssHelper layoutCssHelper,
                     Instance<Row> rowInstance,
                     Instance<EmptyDropRow> emptyDropRowInstance,
                     Event<ComponentDropEvent> componentDropEvent,
                     Event<LayoutEditorElementSelectEvent> containerSelectEvent,
                     Event<LayoutEditorElementUnselectEvent> containerUnselectEvent,
                     Event<LockRequiredEvent> lockRequiredEvent,
                     DnDManager dndManager,
                     LayoutEditorFocusController layoutEditorFocusController); @PostConstruct void setup(); @PreDestroy void preDestroy(); void setLockSupplier(Supplier<Boolean> lockSupplier); @Override String getId(); @Override LayoutEditorElementType geElementType(); @Override LayoutEditorElement getParentElement(); @Override void setSelectable(boolean selectable); boolean isSelectable(); @Override boolean isSelected(); @Override void setSelected(boolean status); void loadEmptyLayout(String layoutName,
                                LayoutTemplate.Style pageStyle,
                                String emptyTitleText,
                                String emptySubTitleText); void load(LayoutTemplate layoutTemplate,
                     String emptyTitleText,
                     String emptySubTitleText); void reset(); ParameterizedCommand<RowDrop> createEmptyDropCommand(); Supplier<Boolean> getLockSupplier(); ParameterizedCommand<RowDrop> createRowDropCommand(); String getLayoutName(); void addProperty(String key,
                            String value); String getProperty(String key); @Override Map<String, String> getProperties(); @Override void setProperty(String property, String value); @Override void removeProperty(String property); @Override void clearProperties(); @Override List<PropertyEditorCategory> getPropertyCategories(); LayoutTemplate toLayoutTemplate(); List<Row> getRows(); View getView(); void resizeRows(@Observes RowResizeEvent resize); LayoutTemplate.Style getPageStyle(); void onSelected(); List<Row> getChildElements();  }
@Test public void swapRows() throws Exception { loadLayout(SAMPLE_FULL_FLUID_LAYOUT); Row row1 = getRowByIndex(FIRST_ROW); Row row2 = getRowByIndex(SECOND_ROW); container.swapRows(new RowDnDEvent(row1.getId(), row2.getId(), RowDrop.Orientation.AFTER)); assertEquals(row2, getRowByIndex(FIRST_ROW)); assertEquals(row1, getRowByIndex(SECOND_ROW)); }