Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8096685

Polytonic displays incorrectly when typed in (via TextField)

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u60
    • Component/s: javafx
    • Labels:
    • Environment:

      testing on both win7,win8

      Description

      When editing a tableview if i try to add tonic in word it appears like this : kalim'era while the proper is the tonic to go above e

      Interesting is that i don't have that issue in textfield ....
      Providing a test :

      import javafx.application.Application;
      import static javafx.application.Application.launch;
      import javafx.application.Platform;
      import javafx.beans.property.SimpleIntegerProperty;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.event.Event;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.TableCell;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableColumn.CellEditEvent;
      import javafx.scene.control.TableView;
      import javafx.scene.control.TextField;
      //import javafx.scene.control.cell.CheckBoxTableCell;
      import javafx.scene.control.cell.PropertyValueFactory;
      import javafx.scene.input.KeyCode;
      import javafx.scene.input.KeyEvent;
      import javafx.stage.Stage;
      import javafx.util.Callback;


      /**
       * FXML Controller class
       *
       * @author balz
       */
      public class UploadTemplateController extends Application {

          @Override public void start(Stage primaryStage) throws Exception {
              init(primaryStage);
              primaryStage.show();
          }
          public static void main(String[] args) { launch(args); }

          private void init(Stage primaryStage) {
              Group root = new Group();
              primaryStage.setScene(new Scene(root));
              MasterUploadParameter objMasterUploadParameter=new MasterUploadParameter();
              MasterUploadParameter objMasterUploadParameter1=new MasterUploadParameter();
              MasterUploadParameter objMasterUploadParameter2=new MasterUploadParameter();

              final ObservableList<MasterUploadParameter> tableContent =
                  FXCollections.observableArrayList
                  (
                      objMasterUploadParameter,
                      objMasterUploadParameter1,
                      objMasterUploadParameter2
                  );

              Callback<TableColumn, TableCell> cellFactory = new Callback<TableColumn, TableCell>() {
                  public TableCell call(TableColumn p) {
                      return new EditingCell();
                  }
              };

              TableColumn ColumnID = new TableColumn();
              ColumnID.setText("columnId");
              ColumnID.setCellValueFactory(new PropertyValueFactory("columnId"));
              ColumnID.setCellFactory(cellFactory);
              ColumnID.setOnEditCommit(new EventHandler<CellEditEvent<MasterUploadParameter, String>>() {
                  @Override
                  public void handle(CellEditEvent<MasterUploadParameter, String> evt) {
                      try {
                          evt.getTableView().getItems().get(evt.getTablePosition().getRow())
                                  .columnId.set(Integer.parseInt(evt.getNewValue()));
                      } catch (NumberFormatException numberFormatException) {
                          //do whatever if a non int is entered
                      }
                  }
              });

              TableColumn columnDesc = new TableColumn("Desc");
              columnDesc.setCellValueFactory(new PropertyValueFactory("desc"));
              columnDesc.setCellFactory(cellFactory);
              columnDesc.setOnEditCommit(new EventHandler<CellEditEvent<MasterUploadParameter, String>>() {
                  @Override
                  public void handle(CellEditEvent<MasterUploadParameter, String> evt) {
                      evt.getTableView().getItems().get(evt.getTablePosition().getRow())
                              .desc.set(evt.getNewValue());
                  }
              });

              TableView tableView = new TableView();
              tableView.setItems(tableContent);
              //Enabling editing
              tableView.setEditable(true);
              tableView.getColumns().addAll(ColumnID, columnDesc);
              root.getChildren().add(tableView);
          }

          public static class MasterUploadParameter {
              private SimpleIntegerProperty columnId;
              public SimpleIntegerProperty columnIdProperty() {return columnId;}

              private StringProperty desc;
              public StringProperty descProperty() {return desc;}

              public MasterUploadParameter() {
                  this.columnId=new SimpleIntegerProperty(0);
                  this.desc = new SimpleStringProperty("hi");
              }
          }
          // EditingCell - for editing capability in a TableCell
          public static class EditingCell extends TableCell{
              private TextField textField;

              @Override public void startEdit() {
                  if (!isEmpty()) {
                      super.startEdit();
                      createTextField();
                      setText(null);
                      setGraphic(textField);
                      textField.selectAll();
                      Platform.runLater(new Runnable() {
                          @Override
                          public void run() {
                              textField.requestFocus();
                          }
                      });
                  }
              }

              @Override public void cancelEdit() {
                  super.cancelEdit();

                  try {
                      setText(getItem().toString());
                  } catch (Exception e) {
                  }
                  setGraphic(null);
              }

              @Override public void updateItem(Object item, boolean empty) {
                  System.out.println("find value of update: "+empty+item);
                  super.updateItem(item, empty);
                  if (empty) {
                      setText(null);
                      setGraphic(null);
                  } else {
                      if (isEditing()) {
                          if (textField != null) {
                              textField.setText(getString());
                          }
                          setText(null);
                          setGraphic(textField);
                      } else {
                          setText(getString());
                          setGraphic(null);
                      }
                  }
              }

              private void createTextField() {
                  textField = new TextField(getString());
                  textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
                  textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
                      @Override public void handle(KeyEvent t) {
                          if (t.getCode() == KeyCode.ENTER) {
                              commitEdit(textField.getText());
                          } else if (t.getCode() == KeyCode.ESCAPE) {
                              cancelEdit();
                          }
                      }
                  });
              }

              private String getString() {
                  return getItem() == null ? "" : getItem().toString();
              }

          }


      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                leifs Leif Samuelsson (Inactive)
                Reporter:
                gmoralisjfx George Moralis (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: