Samir Hadzic avatar Samir Hadzic committed 77d9de0

Editors fit right in cells.

Comments (0)

Files changed (4)

src/main/java/impl/org/controlsfx/spreadsheet/CellViewSkin.java

 
 public class CellViewSkin extends TableCellSkin<ObservableList<SpreadsheetCell>, SpreadsheetCell>{
 
+	private static final  int TRIANGLE_SIZE = 6;
 	private Region commentTriangle = null;
 	
 	public CellViewSkin(
 				if(!getChildren().contains(commentTriangle)){
 					getChildren().add(commentTriangle);
 				}
-				commentTriangle.resize(6,6);
+				commentTriangle.resize(TRIANGLE_SIZE,TRIANGLE_SIZE);
 				commentTriangle.getStyleClass().add("comment");
-				commentTriangle.relocate(getSkinnable().getWidth()-6, snappedTopInset()-1);
+				commentTriangle.relocate(getSkinnable().getWidth()-TRIANGLE_SIZE, snappedTopInset()-1);
 			}else if(commentTriangle != null){
 				getChildren().remove(commentTriangle);
 				commentTriangle = null;

src/main/java/impl/org/controlsfx/spreadsheet/GridCellEditor.java

 	private boolean editing = false;
 	private SpreadsheetCellEditor<?> spreadsheetCellEditor;
     private CellView lastHover = null;
+    private static final double MAX_EDITOR_HEIGHT = 50.0;
 
 	/***************************************************************************
 	 * * Constructor * *
 		
 		//Then we call the user editor in order for it to be ready
 		Object value = modelCell.getItem();
+		Double maxHeight = Math.max(handle.getView().getGrid().getRowHeight(viewCell.getIndex()), MAX_EDITOR_HEIGHT);
+		spreadsheetCellEditor.getEditor().setMaxHeight(maxHeight);
 		spreadsheetCellEditor.startEdit(value);
 	}
 

src/main/java/org/controlsfx/control/spreadsheet/SpreadsheetCellEditor.java

 		public ObjectEditor(SpreadsheetView view) {
 			super(view);
 			tf = new TextField();
-			tf.setPrefHeight(20);
 		}
 
 		/***************************************************************************
 			if (value instanceof String) {
 				tf.setText(value.toString());
 			}
-			tf.setMaxHeight(20);
 			attachEnterEscapeEventHandler();
 
 			tf.requestFocus();
 		public StringEditor(SpreadsheetView view) {
 			super(view);
 			tf = new TextField();
-			tf.setPrefHeight(20);
 		}
 
 		/***************************************************************************
 			if (value instanceof String) {
 				tf.setText((String) value);
 			}
-			tf.setMaxHeight(20);
 			attachEnterEscapeEventHandler();
 
 			tf.requestFocus();
 		public DoubleEditor(SpreadsheetView view) {
 			super(view);
 			tf = new TextField();
-			tf.setPrefHeight(20);
 		}
 
 		/***************************************************************************
 				tf.setText(((Double) value).isNaN() ? "" : value.toString());
 			}
 			tf.getStyleClass().removeAll("error");
-			tf.setMaxHeight(20);
 			attachEnterEscapeEventHandler();
 
 			tf.requestFocus();

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

 	-fx-background-color: red;
 	-fx-shape : "M 0 0 L -1 0 L 0 1 z";
 }
+
+/* TextField must squeeze tight, so no padding
+on top and bottom */
+.spreadsheet-cell TextField{
+	-fx-padding : 0 7 0 7 ;
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.