Skip to content

Commit

Permalink
Merge branch 'release/2.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kunstmusik committed Sep 24, 2017
2 parents 891c171 + 4e5a7a5 commit e1f80b8
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 41 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Expand Up @@ -12,6 +12,16 @@ information.

[CHANGE LOG]

> Notes for 2.7.1 <
[release 2017.09.24]

FIX

* BlueSynthBuilder - UI Editor would hang on OSX when setting Min/Max values on
widgets due to JavaFX/Swing UI threads interactions; replaced Swing code to
with JFX code in affected areas


> Notes for 2.7.0 <
[release 2017.09.22]

Expand Down
8 changes: 8 additions & 0 deletions blue-core/nbproject/project.xml
Expand Up @@ -6,6 +6,14 @@
<code-name-base>com.kunstmusik.blue</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>blue.jfx</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>blue.plugin</code-name-base>
<build-prerequisite/>
Expand Down
4 changes: 2 additions & 2 deletions blue-core/src/blue/blueConstants.properties
@@ -1,2 +1,2 @@
blueReleaseDate=2017.09.22.
blueVersion=2.7.0
blueReleaseDate=2017.09.24
blueVersion=2.7.1
42 changes: 33 additions & 9 deletions blue-core/src/blue/orchestra/blueSynthBuilder/ClampedValue.java
Expand Up @@ -20,13 +20,18 @@
package blue.orchestra.blueSynthBuilder;

import blue.components.lines.LineUtils;
import blue.jfx.BlueFX;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javafx.application.Platform;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.DoublePropertyBase;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javax.swing.JOptionPane;

/**
Expand Down Expand Up @@ -175,7 +180,7 @@ public final void setValue(double val) {
}
value.set(val);

notifyListeners(ClampedValueListener.PropertyType.VALUE,
notifyListeners(ClampedValueListener.PropertyType.VALUE,
ClampedValueListener.BoundaryType.NONE);
}

Expand All @@ -190,16 +195,25 @@ public final DoubleProperty valueProperty() {
public final void setMin(double value) {

if (value >= getMax()) {
JOptionPane.showMessageDialog(null, "Error: Min value "
+ "can not be set greater or equals to Max value.",
"Error", JOptionPane.ERROR_MESSAGE);
if (Platform.isFxApplicationThread()) {
Alert a = new Alert(AlertType.NONE,
"Error: Min value can not be set greater or equals to Max value.",
ButtonType.OK);
a.setTitle("Error");
BlueFX.style(a.getDialogPane());
a.showAndWait();
} else {
JOptionPane.showMessageDialog(null, "Error: Min value "
+ "can not be set greater or equals to Max value.",
"Error", JOptionPane.ERROR_MESSAGE);
}
return;
}

String retVal = LineBoundaryDialog.getLinePointMethod();
ClampedValueListener.BoundaryType bType;

if(retVal == null) {
if (retVal == null) {
return;
}

Expand Down Expand Up @@ -232,17 +246,27 @@ public final DoubleProperty minProperty() {
public final void setMax(double value) {

if (value <= getMin()) {
JOptionPane.showMessageDialog(null, "Error: Max value "
+ "can not be set less than or " + "equal to Min value.",
"Error", JOptionPane.ERROR_MESSAGE);

if (Platform.isFxApplicationThread()) {
Alert a = new Alert(AlertType.NONE,
"Error: Max value can not be set less than or "
+ "equal to Min value.",
ButtonType.OK);
a.setTitle("Error");
BlueFX.style(a.getDialogPane());
a.showAndWait();
} else {
JOptionPane.showMessageDialog(null, "Error: Max value "
+ "can not be set less than or " + "equal to Min value.",
"Error", JOptionPane.ERROR_MESSAGE);
}
return;
}

String retVal = LineBoundaryDialog.getLinePointMethod();
ClampedValueListener.BoundaryType bType;

if(retVal == null) {
if (retVal == null) {
return;
}

Expand Down
Expand Up @@ -19,13 +19,22 @@
*/
package blue.orchestra.blueSynthBuilder;

import blue.jfx.BlueFX;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

/**
* Copied from blue-ui-core to deal with having scaling options called when
* setting values using getter/setters and PropertySheet. This is definitely not
* ideal to have UI stuff like this in the blue-core package and requires a
* better solution. Using it for now...
* better solution. Using it for now...
*
* @author stevenyi
*/
Expand All @@ -36,19 +45,37 @@ public class LineBoundaryDialog {
public static final String TRUNCATE = "Truncate";

public static String getLinePointMethod() {
int retVal = JOptionPane.showOptionDialog(null,
"Choose method for handling line points:",
"Line Boundaries Changed", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null, new Object[]{RESCALE,
TRUNCATE}, RESCALE);

switch (retVal) {
case 0:
return RESCALE;
case 1:
return TRUNCATE;
String retVal = null;

if (Platform.isFxApplicationThread()) {
Alert alert =
new Alert(Alert.AlertType.NONE,
"Choose method for handling line points:", new ButtonType(
RESCALE), new ButtonType(TRUNCATE), ButtonType.CANCEL
);
alert.setTitle("Line Boundaries Changed");
BlueFX.style(alert.getDialogPane());
Optional<ButtonType> bType = alert.showAndWait();
if(bType.isPresent() && !bType.get().getButtonData().isCancelButton()) {
retVal = bType.get().getText();
}
} else {
int ret = JOptionPane.showOptionDialog(null,
"Choose method for handling line points:",
"Line Boundaries Changed", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE, null, new Object[]{RESCALE,
TRUNCATE}, RESCALE);

switch (ret) {
case 0:
retVal = RESCALE;
break;
case 1:
retVal = TRUNCATE;
break;
}
}

return null;
return retVal;
}
}
Expand Up @@ -38,15 +38,20 @@ public class NumberPropertyEditor extends TextField {

public NumberPropertyEditor(PropertySheet.Item item) {
this.item = item;
this.setOnAction(e -> updateTextFromTextField());
this.focusedProperty().addListener((obs, o, n) -> {
ChangeListener<Boolean> focusListener = (obs, o, n) -> {
if (o && !n) {
editing = false;
updateTextFromTextField();
} else {
editing = true;
}
};
this.setOnAction(e -> {
focusedProperty().removeListener(focusListener);
updateTextFromTextField();
focusedProperty().addListener(focusListener);
});
this.focusedProperty().addListener(focusListener);

ChangeListener<Object> listener = (obs, old, newVal) -> {
if (!editing) {
Expand All @@ -65,10 +70,10 @@ public NumberPropertyEditor(PropertySheet.Item item) {
});
}

private void updateTextFromTextField() {
private synchronized void updateTextFromTextField() {
String newValue = this.getText();
String old = item.getValue().toString();
if(old.equals(newValue)) {
if (old.equals(newValue)) {
return;
}
if (validator == null || validator.test(newValue)) {
Expand All @@ -88,22 +93,22 @@ public void setValidator(Predicate<String> validator) {

public Number getValueAsNumber() {
Class<?> type = item.getType();
if (type == byte.class || type == Byte.class){
return new Byte(getText());
}else if(type == short.class || type == Short.class){
if (type == byte.class || type == Byte.class) {
return new Byte(getText());
} else if (type == short.class || type == Short.class) {
return new Short(getText());
} else if(type == int.class || type == Integer.class){
} else if (type == int.class || type == Integer.class) {
return new Integer(getText());
} else if(type == long.class || type == Long.class){
} else if (type == long.class || type == Long.class) {
return new Long(getText());
} else if(type == BigInteger.class) {
return new BigInteger(getText());
} else if(type == BigDecimal.class) {
return new BigDecimal(getText());
} else if(type == float.class || type == Float.class) {
return new Float(getText());
} else if(type == double.class || type == Double.class) {
return new Double(getText());
} else if (type == BigInteger.class) {
return new BigInteger(getText());
} else if (type == BigDecimal.class) {
return new BigDecimal(getText());
} else if (type == float.class || type == Float.class) {
return new Float(getText());
} else if (type == double.class || type == Double.class) {
return new Double(getText());
}

return null;
Expand Down

0 comments on commit e1f80b8

Please sign in to comment.