Source:
<code>protected void doInit() { super.doInit(); myResourceTreeModel.updateResources(); getTable().getModel().addTableModelListener(new ModelListener()); getVerticalScrollBar().addAdjustmentListener(new VscrollAdjustmentListener(myUiFacade.getResourceChart(), false)); getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { int index = getTable().columnAtPoint(mouseEvent.getPoint()); if (index == -1){ return; } if (mouseEvent.isPopupTrigger() || mouseEvent.getButton() != MouseEvent.BUTTON1){ return; } if (mouseEvent.isAltDown() || mouseEvent.isShiftDown() || mouseEvent.isControlDown()){ return; } final TableHeaderUiFacadeImpl tableHeader = getTableHeaderUiFacade(); final ColumnImpl column = tableHeader.findColumnByViewIndex(index); final ResourceDefaultColumn resourceColumn = ResourceDefaultColumn.find(column.getID()); getUiFacade().getUndoManager().undoableEdit(GanttLanguage.getInstance().getText("task.sort"), new Runnable() { @Override public void run() { if (resourceColumn == ResourceDefaultColumn.NAME) { if (column.getSort() == SortOrder.ASCENDING) { column.setSort(SortOrder.DESCENDING); resourceColumn.setSortComparator(new DescendingNameComparator()); } else { column.setSort(SortOrder.ASCENDING); resourceColumn.setSortComparator(new AscendingNameComparator()); } ArrayList<HumanResource> sorted = new ArrayList<>(); getProject().getHumanResourceManager().getResources().forEach( h -> { sorted.add(h); }); sorted.sort((Comparator<HumanResource>) resourceColumn.getSortComparator()); <START> for(int j = sorted.size()-1; j>=0; j--){ <END> HumanResource h = sorted.get(j); int idxo = getProject().getHumanResourceManager().getResources().indexOf(h); int idxs = sorted.indexOf(h); int delta = idxs - idxo; for(int i = 0; i < Math.abs(delta) ; i++){ if (idxs < idxo) { myResourceTreeModel.moveUp(h); } else { myResourceTreeModel.moveDown(h); } } }; } } }); } }); }</code><technical_language>I need complex UI manipulation logic. Passing sorted argument updateResources method is enough populate table in sorted way. clear of course</technical_language>

Target:
protected void doInit() { super.doInit(); myResourceTreeModel.updateResources(); getTable().getModel().addTableModelListener(new ModelListener()); getVerticalScrollBar().addAdjustmentListener(new VscrollAdjustmentListener(myUiFacade.getResourceChart(), false)); getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (!mouseEventHandling(mouseEvent)) { return; } final TableHeaderUiFacadeImpl tableHeader = getTableHeaderUiFacade(); final ColumnImpl column = tableHeader.findColumnByViewIndex(getTable().columnAtPoint(mouseEvent.getPoint())); final ResourceDefaultColumn resourceColumn = ResourceDefaultColumn.find(column.getID()); getUiFacade().getUndoManager().undoableEdit(GanttLanguage.getInstance().getText("task.sort"), new Runnable() { @Override public void run() { if (resourceColumn == ResourceDefaultColumn.NAME) { Comparator<HumanResource> comparator; if (column.getSort() == SortOrder.ASCENDING) { column.setSort(SortOrder.DESCENDING); comparator = new AscendingNameComparator().reversed(); } else { column.setSort(SortOrder.ASCENDING); comparator = new AscendingNameComparator(); } List<HumanResource> sorted = new ArrayList<>(getProject().getHumanResourceManager().getResources()); sorted.sort(comparator); myResourceTreeModel.updateResources(sorted); } } }); } }); }