cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject [14/50] cayenne-modeler git commit: Added Optimistic Locking and found a better way to wire up table cells to properties.
Date Thu, 05 Jan 2017 22:09:22 GMT
Added Optimistic Locking and found a better way to wire up table cells to properties.


Project: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/commit/79cc830d
Tree: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/tree/79cc830d
Diff: http://git-wip-us.apache.org/repos/asf/cayenne-modeler/diff/79cc830d

Branch: refs/heads/master
Commit: 79cc830d47e5c894e249f56f23feafcf74fb379c
Parents: ffa3dce
Author: mrg <blacknext@gmail.com>
Authored: Tue Sep 27 08:43:48 2016 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Tue Sep 27 08:43:48 2016 -0400

----------------------------------------------------------------------
 .../layout/ObjectEntityAttributesTabLayout.java | 43 ++++++++++++++++++--
 .../ObjectEntityAttributesTabLayout.fxml        |  2 +-
 2 files changed, 40 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/79cc830d/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
b/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
index 3a2b3df..c4a42b8 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/ObjectEntityAttributesTabLayout.java
@@ -32,8 +32,11 @@ import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
 import javafx.beans.value.ChangeListener;
 import javafx.event.Event;
 import javafx.fxml.FXML;
+import javafx.geometry.Pos;
+import javafx.scene.control.CheckBox;
 import javafx.scene.control.ComboBox;
 import javafx.scene.control.Label;
+import javafx.scene.control.TableCell;
 import javafx.scene.control.TableColumn;
 import javafx.scene.control.TableView;
 import javafx.scene.control.TextField;
@@ -47,10 +50,14 @@ public class ObjectEntityAttributesTabLayout
 
     @FXML
     private TextField javaAttributeNameTextField;
+
     @FXML
     private ComboBox<String> javaTypeComboBox;
 
     @FXML
+    private CheckBox optimisticLockingCheckBox;
+
+    @FXML
     private TableView<ObjectAttributeAdapter> attributesTableView;
 
     @FXML
@@ -99,11 +106,32 @@ public class ObjectEntityAttributesTabLayout
         attributeUsedForLockingColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK,
"16px"));
         attributeIsInheritedColumn.setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LEVEL_UP,
"16px"));
 
-        attributeNameColumn.setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter,String>("name"));
-        attributeTypeColumn.setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter,String>("javaType"));
-        attributeDatabasePathColumn.setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter,String>("databaseAttributePath"));
+        attributeNameColumn.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
+        attributeTypeColumn.setCellValueFactory(cellData -> cellData.getValue().javaTypeProperty());
+        attributeDatabasePathColumn.setCellValueFactory(cellData -> cellData.getValue().databaseAttributePathProperty());
         attributeDatabaseTypeColumn.setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter,String>("databaseType"));
-        attributeUsedForLockingColumn.setCellValueFactory(new PropertyValueFactory<ObjectAttributeAdapter,Boolean>("usedForLocking"));
+
+        attributeUsedForLockingColumn.setCellValueFactory(cellData -> cellData.getValue().usedForLockingProperty());
+        attributeUsedForLockingColumn.setCellFactory((column) ->
+            {
+                return new TableCell<ObjectAttributeAdapter,Boolean>()
+                    {
+                        @Override
+                        protected void updateItem(Boolean item, boolean empty)
+                        {
+                            super.updateItem(item, empty);
+
+                            setAlignment(Pos.CENTER);
+                            setStyle("-fx-padding: 0;");
+                            setText("");
+
+                            if (item == null || empty || item == false)
+                                setGraphic(null);
+                            else
+                                setGraphic(GlyphsDude.createIcon(FontAwesomeIcon.LOCK, "16px"));
+                        }
+                     };
+            });
 
 //        Callback<TableColumn<ObjAttribute, String>, TableCell<ObjAttribute,
String>> comboBoxCellFactory
 //        = (TableColumn<ObjAttribute, String> param) -> new ComboBoxEditingCell();
@@ -180,6 +208,7 @@ public class ObjectEntityAttributesTabLayout
             {
                 javaAttributeNameTextField.textProperty().unbindBidirectional(oldSelection.nameProperty());
                 javaTypeComboBox.valueProperty().unbindBidirectional(oldSelection.javaTypeProperty());
+                optimisticLockingCheckBox.selectedProperty().unbindBidirectional(oldSelection.usedForLockingProperty());
             }
 
             javaTypeComboBox.getItems().clear();
@@ -190,11 +219,13 @@ public class ObjectEntityAttributesTabLayout
 
                 javaAttributeNameTextField.textProperty().bindBidirectional(newSelection.nameProperty());
                 javaTypeComboBox.valueProperty().bindBidirectional(newSelection.javaTypeProperty());
+                optimisticLockingCheckBox.selectedProperty().bindBidirectional(newSelection.usedForLockingProperty());
                 databaseTypeLabel.setText(newSelection.getDatabaseType());
             }
 
             javaAttributeNameTextField.setDisable(newSelection == null);
             javaTypeComboBox.setDisable(newSelection == null);
+            optimisticLockingCheckBox.setDisable(newSelection == null);
         };
 
     @Override
@@ -207,6 +238,9 @@ public class ObjectEntityAttributesTabLayout
         javaTypeComboBox.getItems().clear();
         javaTypeComboBox.setValue(null);
 
+        optimisticLockingCheckBox.setSelected(false);
+        optimisticLockingCheckBox.setDisable(true);
+
         databaseTypeLabel.setText("N/A");
 
         attributesTableView.setItems(objectEntityAdapter.getAttributes());
@@ -226,6 +260,7 @@ public class ObjectEntityAttributesTabLayout
         {
             javaAttributeNameTextField.textProperty().unbindBidirectional(currentObjectAttributeAdapter.nameProperty());
             javaTypeComboBox.valueProperty().unbindBidirectional(currentObjectAttributeAdapter.javaTypeProperty());
+            optimisticLockingCheckBox.selectedProperty().unbindBidirectional(currentObjectAttributeAdapter.usedForLockingProperty());
         }
 
         attributesTableView.getSelectionModel().selectedItemProperty().removeListener(attributesTableViewSelectionListener);

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/79cc830d/src/main/resources/layouts/ObjectEntityAttributesTabLayout.fxml
----------------------------------------------------------------------
diff --git a/src/main/resources/layouts/ObjectEntityAttributesTabLayout.fxml b/src/main/resources/layouts/ObjectEntityAttributesTabLayout.fxml
index 4e60fc2..25f2d7d 100644
--- a/src/main/resources/layouts/ObjectEntityAttributesTabLayout.fxml
+++ b/src/main/resources/layouts/ObjectEntityAttributesTabLayout.fxml
@@ -69,7 +69,7 @@
                   <TextField fx:id="javaAttributeNameTextField" maxWidth="-Infinity" minWidth="-Infinity"
prefWidth="200.0" GridPane.columnIndex="1" />
                   <Label fx:id="databaseTypeLabel" text="type name here" GridPane.columnIndex="3"
GridPane.rowIndex="1" />
                   <ComboBox fx:id="javaTypeComboBox" editable="true" maxWidth="-Infinity"
minWidth="-Infinity" prefWidth="200.0" promptText="Enter or Choose..." GridPane.columnIndex="3"
/>
-                  <CheckBox mnemonicParsing="false" text="Optimistic Locking" GridPane.columnIndex="4"
/>
+                  <CheckBox fx:id="optimisticLockingCheckBox" mnemonicParsing="false"
text="Optimistic Locking" GridPane.columnIndex="4" />
                   <ComboBox maxWidth="-Infinity" minWidth="-Infinity" prefWidth="200.0"
GridPane.columnIndex="1" GridPane.rowIndex="1" />
                </children>
                <padding>


Mime
View raw message