Commits

Eugene Ryzhikov  committed 5155047 Merge

Merged controlsfx/controlsfx into default

  • Participants
  • Parent commits 50dbbb3, a43850a

Comments (0)

Files changed (5)

File src/main/java/impl/org/controlsfx/spreadsheet/GridViewSkin.java

 
             y += tableHeaderRowHeight;
         } else {
-            // FIXME try to hide the columnHeader
+        	// This is now handle in the HorizontalHeader with Css
         	// FIXME tweak open in RT-32673
         }
 
     private final ListChangeListener<Integer> fixedRowsListener = new ListChangeListener<Integer>() {
         @Override
         public void onChanged(Change<? extends Integer> c) {
-           /* while (c.next()) {
-                for (final Integer remitem : c.getRemoved()) {
-                    getFlow().getFixedRows().remove(remitem);
-                }
-                for (final Integer additem : c.getAddedSubList()) {
-                    getFlow().getFixedRows().add(additem);
-                }
-            }*/
             // requestLayout() not responding immediately..
             getFlow().layoutTotal();
         }
                 }
             }
 
-            /*while (c.next()) {
-                for (final Integer remitem : c.getRemoved()) {
-                    getFlow().getFixedColumns().remove(remitem);
-                }
-                for (final Integer additem : c.getAddedSubList()) {
-                    getFlow().getFixedColumns().add(additem);
-                }
-            }*/
             // requestLayout() not responding immediately..
             getFlow().layoutTotal();
         }

File src/main/java/impl/org/controlsfx/spreadsheet/HorizontalHeader.java

         gridViewSkin = skin;
     }
     public void init() {
-    	final Runnable r = new Runnable() {
-			@Override
-			public void run() {
-		    	SpreadsheetView view = gridViewSkin.spreadsheetView;
-		        view.showRowHeaderProperty().addListener(rowHeaderListener);
-		        gridViewSkin.getSelectedColumns().addListener(selectionListener);
-		        
-		        view.getFixedColumns().addListener(fixedColumnsListener);
-				for(SpreadsheetColumn<?> column: view.getFixedColumns()){
-					fixColumn(column);
-				}
-		        gridViewSkin.getTableMenuButtonVisibleProperty()
-		                .addListener(new InvalidationListener() {
-		                    @Override
-		                    public void invalidated(Observable valueModel) {
-		                        if (working) {
-		                            requestLayout();
-		                        }
-		                    }
-		                });
-		
-		        /*****************************************************************
-		         * MODIFIED BY NELLARMONIA
-		         *****************************************************************/
-		        // We listen to the BooleanProperty linked with the CheckBox of
-		        // the columnHeader
-		        view.showColumnHeaderProperty()
-		                .addListener(new ChangeListener<Boolean>() {
-		                    @Override
-		                    public void changed(
-		                            ObservableValue<? extends Boolean> arg0,
-		                            Boolean arg1, Boolean arg2) {
-		                        working = arg2;
-		                        requestLayout();
-		                        getRootHeader().layoutFixedColumns();
-		                        updateHighlightSelection();
-		                    }
-		                });
-		        /*****************************************************************
-		         * END OF MODIFIED BY NELLARMONIA
-		         *****************************************************************/
-		        // We want to select when clicking on header
-		        for (final TableColumnHeader i : getRootHeader().getColumnHeaders()) {
-		            i.getChildrenUnmodifiable().get(0).setOnMousePressed(new EventHandler<MouseEvent>(){
-		    			@Override
-		    			public void handle(MouseEvent arg0) {
-		    				if(arg0.isPrimaryButtonDown()){
-		    					TableViewSelectionModel<ObservableList<SpreadsheetCell>> sm = gridViewSkin.handle.getView().getSelectionModel();
-		    					TableViewFocusModel<ObservableList<SpreadsheetCell>> fm = gridViewSkin.handle.getGridView().getFocusModel();
-		    					sm.clearAndSelect(fm.getFocusedCell().getRow(),i.getTableColumn() );
-		    				}
-		    			}
-		    		});
-		        }
+	    	SpreadsheetView view = gridViewSkin.spreadsheetView;
+	    	
+	    	//Visibility of vertical Header listener
+	        view.showRowHeaderProperty().addListener(verticalHeaderListener);
+	        
+	        //Visibility of horizontal Header listener
+	        view.showColumnHeaderProperty().addListener(horizontalHeaderVisibilityListener);
+	        
+	        //Selection listener to highlight header
+	        gridViewSkin.getSelectedColumns().addListener(selectionListener);
+	        
+	        //Fixed Column listener to change style of header
+	        view.getFixedColumns().addListener(fixedColumnsListener);
+	        
+	        //We are doing that because some columns may be already fixed.
+			for(SpreadsheetColumn<?> column: view.getFixedColumns()){
+				fixColumn(column);
 			}
-		};
-		Platform.runLater(r);
+			
+	        /**
+	         * Clicking on header select the cell situated in that column.
+	         * This may be replaced by selecting the entire Column/Row.
+	         */
+	        for (final TableColumnHeader i : getRootHeader().getColumnHeaders()) {
+	            i.getChildrenUnmodifiable().get(0).setOnMousePressed(new EventHandler<MouseEvent>(){
+	    			@Override
+	    			public void handle(MouseEvent arg0) {
+	    				if(arg0.isPrimaryButtonDown()){
+	    					TableViewSelectionModel<ObservableList<SpreadsheetCell>> sm = gridViewSkin.handle.getView().getSelectionModel();
+	    					TableViewFocusModel<ObservableList<SpreadsheetCell>> fm = gridViewSkin.handle.getGridView().getFocusModel();
+	    					sm.clearAndSelect(fm.getFocusedCell().getRow(),i.getTableColumn() );
+	    				}
+	    			}
+	    		});
+	        }
     }
 
+    @Override
     protected void updateTableWidth() {
         super.updateTableWidth();
         // snapping added for RT-19428
         double padding = 0;
-        /*****************************************************************
-         * MODIFIED BY NELLARMONIA
-         *****************************************************************/
-        if (gridViewSkin != null
+
+        if (working && gridViewSkin != null
                 && gridViewSkin.spreadsheetView != null
                 && gridViewSkin.spreadsheetView.showRowHeaderProperty().get()) {
             padding += gridViewSkin.getRowHeaderWidth();
         }
 
-        /*****************************************************************
-         * END OF MODIFIED BY NELLARMONIA
-         *****************************************************************/
         Rectangle clip = ((Rectangle) getClip());
         clip.setWidth(clip.getWidth() == 0 ? 0 : clip.getWidth() - padding);
     }
 
+    @Override
     protected void updateScrollX() {
         super.updateScrollX();
-        /*****************************************************************
-         * MODIFIED BY NELLARMONIA
-         *****************************************************************/
+
         if (working) {
             requestLayout();
             getRootHeader().layoutFixedColumns();
         }
-        /*****************************************************************
-         * END OF MODIFIED BY NELLARMONIA
-         *****************************************************************/
     }
 
 
     /**
-     * When the Rowheader is showing (or not anymore) we need to react
-     * accordingly
+     *Whether the Vertical Header is showing, we need to update the width because some
+     *space on the left will be available/used.
      */
-    private final ChangeListener<Boolean> rowHeaderListener = new ChangeListener<Boolean>() {
+    private final ChangeListener<Boolean> verticalHeaderListener = new ChangeListener<Boolean>() {
 		@Override
 		public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
 			 updateTableWidth();
     };
     
     /**
+     * Whether the Horizontal Header is showing, we need to toggle its visibility.
+     */
+    private final ChangeListener<Boolean> horizontalHeaderVisibilityListener = new ChangeListener<Boolean>() {
+        @Override
+        public void changed(ObservableValue<? extends Boolean> arg0,Boolean arg1, Boolean arg2) {
+        	working = arg2;
+        	setManaged(working);
+        	if(!arg2){
+        		getStyleClass().add("invisible");
+        	}else{
+        		getStyleClass().remove("invisible");
+                requestLayout();
+                getRootHeader().layoutFixedColumns();
+                updateHighlightSelection();
+        	}
+        }
+    };
+    
+    /**
      * When we fix/unfix some columns, we change the style of the Label header text
      */
     private final ListChangeListener<SpreadsheetColumn<?>> fixedColumnsListener = new ListChangeListener<SpreadsheetColumn<?>>() {
                     .getChildrenUnmodifiable().get(0).getStyleClass()
                     .addAll("fixed");
     }
-//    private TableViewSelectionModel<ObservableList<SpreadsheetCell<?>>> selectionModel;
-    
     
     /**
      * When we select some cells, we want the header to be highlighted
 
     }
 
+    @Override
     protected NestedTableColumnHeader createRootHeader() {
         return new HorizontalHeaderColumn(getTableSkin(), null);
     }
 
+    @Override
     public HorizontalHeaderColumn getRootHeader() {
         return (HorizontalHeaderColumn) super.getRootHeader();
     }

File src/main/java/org/controlsfx/control/spreadsheet/SpreadsheetView.java

         return grid;
     }
     
-    //Read only because this functionality is not yet supported, RT-32673
-    private final ReadOnlyBooleanProperty showColumnHeader = new SimpleBooleanProperty(true, "showColumnHeader",true);
+    private final BooleanProperty showColumnHeader = new SimpleBooleanProperty(true, "showColumnHeader",true);
     
     /**
      * Activate and deactivate the Column Header
      * @param b
      */
-//    public final void setShowColumnHeader(final boolean b){
-//        //TODO Need to do that again
-//        //flow.recreateCells(); // Because otherwise we have at the bottom
-//        showColumnHeader.setValue(b);
-//    }
+    public final void setShowColumnHeader(final boolean b){
+        showColumnHeader.setValue(b);
+    }
     
     /**
      * Return if the Column Header is showing.
-     * Always true because it cannot be switched off yet.
-     * @return a boolean telling if the column Header is being shown
+     * @return a boolean telling whether the column Header is shown
      */
     public final boolean isShowColumnHeader() {
         return showColumnHeader.get();
      * BooleanProperty associated with the column Header.
      * @return the BooleanProperty associated with the column Header.
      */
-    public final ReadOnlyBooleanProperty showColumnHeaderProperty() {
+    public final BooleanProperty showColumnHeaderProperty() {
         return showColumnHeader;
     }
 

File src/main/resources/org/controlsfx/control/spreadsheet/spreadsheet.css

 .text-field.error{
 	-fx-background-color: red;
 }
-    
 
+/* HORIZONTAL HEADER VISIBILITY */
+.column-header-background.invisible { visibility: hidden; -fx-padding: -1em; }
+

File src/samples/java/org/controlsfx/samples/HelloSpreadsheetView.java

 		final CheckBox columnHeader = new CheckBox("Column Header");
 		columnHeader.setSelected(true);
 		
-		/**
-		 * FIXME It's not working right now, see in SpreadsheetViewSkin in LayoutChildren
-		 */
-		columnHeader.setDisable(true);
-		
 		columnHeader.selectedProperty().addListener(new ChangeListener<Boolean>() {
 
 			@Override
 			public void changed(
 					ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
-//				spv.setShowColumnHeader(arg2);
+				spv.setShowColumnHeader(arg2);
 			}
 		});
 		//In order to change the span style more easily