Skip to content

Commit

Permalink
Merge pull request #25 from dlsc-software-consulting-gmbh/master
Browse files Browse the repository at this point in the history
Misc
  • Loading branch information
dlemmermann authored Dec 1, 2023
2 parents ab5ebd4 + e7723be commit c9821f6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
6 changes: 3 additions & 3 deletions phonenumberfx-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<name>PhoneNumberFXDemo</name>

<version>1.6.0</version>
<version>1.9.0</version>

<parent>
<groupId>com.dlsc.phonenumberfx</groupId>
<artifactId>parent</artifactId>
<version>1.6.0</version>
<version>1.9.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -141,7 +141,7 @@
<dependency>
<groupId>com.dlsc.phonenumberfx</groupId>
<artifactId>phonenumberfx</artifactId>
<version>1.6.0</version>
<version>1.9.0</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
4 changes: 2 additions & 2 deletions phonenumberfx/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<parent>
<groupId>com.dlsc.phonenumberfx</groupId>
<artifactId>parent</artifactId>
<version>1.6.0</version>
<version>1.9.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>com.dlsc.phonenumberfx</groupId>
<artifactId>phonenumberfx</artifactId>
<version>1.6.0</version>
<version>1.9.0</version>
<packaging>jar</packaging>

<name>PhoneNumberFX</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ protected void layoutChildren(double x, double y, double w, double h) {
}
});

// Platform.runLater() is important or formatting will not work
ChangeListener<Object> updateFormattedPhoneNumberListener = (obs, oldV, newV) -> Platform.runLater(() -> formatter.setFormattedPhoneNumber(getRawPhoneNumber()));
rawPhoneNumberProperty().addListener(updateFormattedPhoneNumberListener);
countryCodeVisibleProperty().addListener(updateFormattedPhoneNumberListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class PhoneNumberLabel extends Label {

private final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();

private boolean updatingText;

/**
* Builds a new phone number field with the default settings. The available country
* calling codes are defined on {@link Country}.
Expand All @@ -42,8 +44,18 @@ public PhoneNumberLabel() {

validProperty().addListener((obs, oldV, newV) -> pseudoClassStateChanged(INVALID_PSEUDO_CLASS, !newV));

textProperty().addListener(it -> {
if (!updatingText) {
// somebody called setText(...) instead of setRawPhoneNumber(...)
setRawPhoneNumber(getText());
}
});

rawPhoneNumber.addListener((obs, oldRawPhoneNumber, newRawPhoneNumber) -> {
updatingText = true;

errorType.set(null);

try {
Phonenumber.PhoneNumber phoneNumber;

Expand Down Expand Up @@ -94,6 +106,8 @@ public PhoneNumberLabel() {
nationalPhoneNumber.set("");
setText(newRawPhoneNumber);
setValid(false);
} finally {
updatingText = false;
}
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dlsc.phonenumberfx;

import org.junit.Before;
import org.junit.Test;

public class PhoneNumberFieldTest {

@Before
public void setup() {
}

@Test
public void shouldDoThis() {
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<name>PhoneNumberFXParent</name>
<groupId>com.dlsc.phonenumberfx</groupId>
<artifactId>parent</artifactId>
<version>1.6.0</version>
<version>1.9.0</version>
<packaging>pom</packaging>

<parent>
Expand Down

0 comments on commit c9821f6

Please sign in to comment.