Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug trying to implement an editable table field #49

Closed
amiracam opened this issue May 31, 2013 · 3 comments
Closed

bug trying to implement an editable table field #49

amiracam opened this issue May 31, 2013 · 3 comments

Comments

@amiracam
Copy link

following the oracle javafx tutorials , here:

http://docs.oracle.com/javafx/2/ui_controls/table-view.htm

I setup the following code in jruby:

@entity_type_col.setCellFactory(TextFieldTableCell.forTableColumn())

where @entity_type_col is the fxid for a column in a table control

and yes I have the appropriate import statements and I have confirmed via the debugger that I have the appropriate Java entity

I have confirmed that just doing the same in Java i.e. not specifying the setOnEditCommit handler will not cause a crash in Java

unfortunately it does in jrubyfx ie. just setting the the cell factory with the pre-existing Java construct will cause an error, I get the following:

SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: TableRow[id=null, styleClass=cell indexed-cell table-row-cell], name: skinClassName, value: com.sun.javafx.scene.control.skin.TableRowSkin]' for control TableRow[id=null, styleClass=cell indexed-cell table-row-cell]
java.lang.ClassCastException: org.jruby.RubyString cannot be cast to java.lang.String
at javafx.util.converter.DefaultStringConverter.toString(DefaultStringConverter.java:33)
at javafx.scene.control.cell.CellUtils.getItemText(CellUtils.java:94)
at javafx.scene.control.cell.CellUtils.updateItem(CellUtils.java:163)
at javafx.scene.control.cell.TextFieldTableCell.updateItem(TextFieldTableCell.java:200)
at javafx.scene.control.TableCell.updateItem(TableCell.java:549)
at javafx.scene.control.TableCell.indexChanged(TableCell.java:105)
at javafx.scene.control.TableCell$1.invalidated(TableCell.java:93)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)

etc ....

@byteit101
Copy link
Member

Hmm, I can't seem to repro. Adding the following code to the following files works for me and text fields pop up as expected:

diff --git a/samples/contrib/fxmltableview/FXMLTableViewController.rb b/samples/contrib/fxmltableview/FXMLTableViewController.rb
index b6e0ffc..2856164 100644
--- a/samples/contrib/fxmltableview/FXMLTableViewController.rb
+++ b/samples/contrib/fxmltableview/FXMLTableViewController.rb
@@ -37,13 +37,17 @@ require_relative 'Person'
 class FXMLTableViewController
   include JRubyFX::Controller
   fxml "fxml_tableview.fxml"
-
+
+  def initialize
+            @firstNameColumn.setCellFactory(Java::javafx.scene.control.cell.TextFieldTableCell.forTableColumn());
+  end
+
   def addPerson
     data = @tableView.items
     data.add(Person.new(@firstNameField.text,
         @lastNameField.text,
         @emailField.text))
-
+
     @firstNameField.text = ""
     @lastNameField.text = ""
     @emailField.text = ""
diff --git a/samples/contrib/fxmltableview/fxml_tableview.fxml b/samples/contrib/fxmltableview/fxml_tableview.fxml
index 81c9e5f..97ddbe3 100644
--- a/samples/contrib/fxmltableview/fxml_tableview.fxml
+++ b/samples/contrib/fxmltableview/fxml_tableview.fxml
@@ -49,7 +49,7 @@
     <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
   </padding>
   <Label style="-fx-font: NORMAL 20 Tahoma;" text="Address Book" GridPane.columnIndex="0" GridPane.rowIndex="0" />
-  <TableView fx:id="tableView" GridPane.columnIndex="0" GridPane.rowIndex="1">
+  <TableView fx:id="tableView" GridPane.columnIndex="0" GridPane.rowIndex="1" editable="true">
     <columns>
       <TableColumn prefWidth="100.0" text="First Name" fx:id="firstNameColumn">
         <cellFactory>

Also provide OS, JRuby version (1.7.3 has jrubyfx bugs, use 1.7.4) and java version (ruby -v will tell you this)

@amiracam
Copy link
Author

amiracam commented Jun 3, 2013

Patrick

Gem versions aside, I did an import of the java class I.e I did not use
the fully qualified name, probably of no impact but disclosed just in case

-Charles
On May 31, 2013 5:46 PM, "Patrick Plenefisch" notifications@github.com
wrote:

Hmm, I can't seem to repro. Adding the following code to the following
files works for me and text fields pop up as expected:

diff --git a/samples/contrib/fxmltableview/FXMLTableViewController.rb b/samples/contrib/fxmltableview/FXMLTableViewController.rbindex b6e0ffc..2856164 100644--- a/samples/contrib/fxmltableview/FXMLTableViewController.rb+++ b/samples/contrib/fxmltableview/FXMLTableViewController.rb@@ -37,13 +37,17 @@ require_relative 'Person'
class FXMLTableViewController
include JRubyFX::Controller
fxml "fxml_tableview.fxml"-++ def initialize+ @firstNameColumn.setCellFactory(Java::javafx.scene.control.cell.TextFieldTableCell.forTableColumn());+ end+
def addPerson
data = @tableView.items
data.add(Person.new(@firstNameField.text,
@lastNameField.text,
@emailField.text))-+
@firstNameField.text = ""
@lastNameField.text = ""
@emailField.text = ""diff --git a/samples/contrib/fxmltableview/fxml_tableview.fxml b/samples/contrib/fxmltableview/fxml_tableview.fxmlindex 81c9e5f..97ddbe3 100644--- a/samples/contrib/fxmltableview/fxml_tableview.fxml+++ b/samples/contrib/fxmltableview/fxml_tableview.fxml@@ -49,7 +49,7 @@


- +


Also provide OS, JRuby version (1.7.3 has jrubyfx bugs, use 1.7.4) and
java version (ruby -v will tell you this)


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-18773334
.

@amiracam amiracam closed this as completed Jun 3, 2013
@amiracam
Copy link
Author

amiracam commented Jun 3, 2013

Ok. loaded all code and also made changes to accommodate new usage , and I can now get the fields to open for editing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants