/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jmc.jfxxlsdiff.util;

import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.control.ScrollBar;
import javafx.scene.control.TableView;

/**
 *
 * @author Justo_Casablanca
 */
public class TableViewUtil {

	private static final Logger logger = Logger.getLogger( TableViewUtil.class.getName() );

	public static void syncScrolling( TableView table1, TableView table2 ) {
		logger.log( Level.INFO, "syncScrolling( TableView, TableView )" );

		syncScrolling( findScrollBar( table1, Orientation.HORIZONTAL ),
					   findScrollBar( table2, Orientation.HORIZONTAL ) );

		syncScrolling( findScrollBar( table1, Orientation.VERTICAL ),
					   findScrollBar( table2, Orientation.VERTICAL ) );
	}

	public static void syncScrolling( ScrollBar scroll1, ScrollBar scroll2 ) {
		logger.log( Level.INFO, "syncScrolling( ScrollBar, ScrollBar )" );

		if( ( scroll1 == null ) || ( scroll2 == null ) ) {
			logger.log(
				Level.WARNING,
				"calling syncScrolling( ScrollBar[{0}], ScrollBar[{1}] ) too early ?",
				new Object[] { scroll1, scroll2 }
			);
		} else {
			scroll1.valueProperty().bindBidirectional( scroll2.valueProperty() );
			//scroll1.valueProperty().addListener( new ScrollSync( scroll2 ) );
			//scroll2.valueProperty().addListener( new ScrollSync( scroll1 ) );
		}
	}

	private static ScrollBar findScrollBar( TableView tv, Orientation or ) {
		ScrollBar sb = null;

		for( Node n : tv.lookupAll( ".scroll-bar" ) ) {
			if( n instanceof ScrollBar ) {
				ScrollBar bar = (ScrollBar) n;
				if( bar.getOrientation() == or ) {
					sb = bar;
					break;
				}
			}
		}

		return sb;
	}

	/*private static class ScrollSync implements ChangeListener<Number> {
		private ScrollBar targetSB = null;

		private ScrollSync( ScrollBar targetSB ) {
			this.targetSB = targetSB;
		}

		@Override
		public void changed( ObservableValue<? extends Number> ov, Number oldVal, Number newVal ) {
			targetSB.valueProperty().setValue( newVal );
		}
	};*/
}

@@ -1604,24 +1604,821 @@
 %0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A
+%09/*%0D%0A%09public static void configureRowHeaders( TableView table ) %7B%0D%0A%09%09logger.log( Level.INFO, %22lockRowHeaders( TableView )%22 );%0D%0A%0D%0A%09%09TableView rowHeaders = new TableView();%0D%0A%09%09rowHeaders.getColumns().add( new TableColumn( %22#%22 ) );%0D%0A%0D%0A%09%09SplitPane g = findSplitPane( table );%0D%0A%0D%0A%09%09g.getItems().get( 0 ).getChildren().add( 0, rowHeaders );%0D%0A%0D%0A%09%09table.setItems( FXCollections.observableArrayList( %22Tom%22, %22Dick%22, %22Harry%22 ) );%0D%0A%09%09rowHeaders.setItems( FXCollections.observableArrayList( %221%22, %222%22, %223%22 ) );%0D%0A%09%7D%0D%0A%0D%0A%09private static SplitPane findSplitPane( Parent n ) %7B%0D%0A%09%09SplitPane g = null;%0D%0A%09%09Parent p = n;%0D%0A%0D%0A%09%09while( p != null ) %7B%0D%0A%09%09%09if( p instanceof SplitPane ) %7B%0D%0A%09%09%09%09break;%0D%0A%09%09%09%7D else %7B%0D%0A%09%09%09%09p = p.getParent();%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%0D%0A%09%09if( p != null ) %7B%0D%0A%09%09%09g = (SplitPane) p;%0D%0A%09%09%7D%0D%0A%0D%0A%09%09return g;%0D%0A%09%7D%0D%0A%09*/%0D%0A%0D%0A
 %09private sta

Comment out method: public static void configureRowHeaders( TableView table )