From 9b4b062e81685b147fb3f57c0ec323eb407742da Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 21 Aug 2018 17:13:47 +0200 Subject: [PATCH 01/19] Clean up errors for testing --- .../bisq/desktop/components/AutoTooltipButton.java | 3 +-- .../bisq/desktop/components/AutoTooltipCheckBox.java | 3 +-- .../bisq/desktop/components/AutoTooltipLabel.java | 3 +-- .../desktop/components/AutoTooltipRadioButton.java | 3 +-- .../desktop/components/AutoTooltipToggleButton.java | 3 +-- .../components/indicator/TxConfidenceIndicator.java | 8 ++------ .../src/main/java/bisq/desktop/util/ImageUtil.java | 12 ++++++------ 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/AutoTooltipButton.java b/desktop/src/main/java/bisq/desktop/components/AutoTooltipButton.java index 02c45ce6bf2..438bf1791f7 100644 --- a/desktop/src/main/java/bisq/desktop/components/AutoTooltipButton.java +++ b/desktop/src/main/java/bisq/desktop/components/AutoTooltipButton.java @@ -20,8 +20,7 @@ import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.Skin; - -import com.sun.javafx.scene.control.skin.ButtonSkin; +import javafx.scene.control.skin.ButtonSkin; import static bisq.desktop.components.TooltipUtil.showTooltipIfTruncated; diff --git a/desktop/src/main/java/bisq/desktop/components/AutoTooltipCheckBox.java b/desktop/src/main/java/bisq/desktop/components/AutoTooltipCheckBox.java index 7a980974985..e39b694bf62 100644 --- a/desktop/src/main/java/bisq/desktop/components/AutoTooltipCheckBox.java +++ b/desktop/src/main/java/bisq/desktop/components/AutoTooltipCheckBox.java @@ -19,8 +19,7 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.Skin; - -import com.sun.javafx.scene.control.skin.CheckBoxSkin; +import javafx.scene.control.skin.CheckBoxSkin; import static bisq.desktop.components.TooltipUtil.showTooltipIfTruncated; diff --git a/desktop/src/main/java/bisq/desktop/components/AutoTooltipLabel.java b/desktop/src/main/java/bisq/desktop/components/AutoTooltipLabel.java index 1f939ac4cd8..96681d4aa68 100644 --- a/desktop/src/main/java/bisq/desktop/components/AutoTooltipLabel.java +++ b/desktop/src/main/java/bisq/desktop/components/AutoTooltipLabel.java @@ -19,8 +19,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Skin; - -import com.sun.javafx.scene.control.skin.LabelSkin; +import javafx.scene.control.skin.LabelSkin; import static bisq.desktop.components.TooltipUtil.showTooltipIfTruncated; diff --git a/desktop/src/main/java/bisq/desktop/components/AutoTooltipRadioButton.java b/desktop/src/main/java/bisq/desktop/components/AutoTooltipRadioButton.java index 1aeef854c3b..4b6f3ec89b8 100644 --- a/desktop/src/main/java/bisq/desktop/components/AutoTooltipRadioButton.java +++ b/desktop/src/main/java/bisq/desktop/components/AutoTooltipRadioButton.java @@ -19,8 +19,7 @@ import javafx.scene.control.RadioButton; import javafx.scene.control.Skin; - -import com.sun.javafx.scene.control.skin.RadioButtonSkin; +import javafx.scene.control.skin.RadioButtonSkin; import static bisq.desktop.components.TooltipUtil.showTooltipIfTruncated; diff --git a/desktop/src/main/java/bisq/desktop/components/AutoTooltipToggleButton.java b/desktop/src/main/java/bisq/desktop/components/AutoTooltipToggleButton.java index 6a165773708..a530599c8ff 100644 --- a/desktop/src/main/java/bisq/desktop/components/AutoTooltipToggleButton.java +++ b/desktop/src/main/java/bisq/desktop/components/AutoTooltipToggleButton.java @@ -20,8 +20,7 @@ import javafx.scene.Node; import javafx.scene.control.Skin; import javafx.scene.control.ToggleButton; - -import com.sun.javafx.scene.control.skin.ToggleButtonSkin; +import javafx.scene.control.skin.ToggleButtonSkin; import static bisq.desktop.components.TooltipUtil.showTooltipIfTruncated; diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java b/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java index 94c7ee60d8c..bc1f3b932aa 100644 --- a/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java +++ b/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java @@ -42,10 +42,7 @@ package bisq.desktop.components.indicator; -import bisq.desktop.components.indicator.skin.StaticProgressIndicatorSkin; - import javafx.scene.control.Control; -import javafx.scene.control.Skin; import javafx.css.PseudoClass; import javafx.css.StyleableProperty; @@ -254,10 +251,10 @@ public String getName() { * {@inheritDoc} */ - @Override + /*@Override protected Skin createDefaultSkin() { return new StaticProgressIndicatorSkin(this); - } + }*/ /** * Most Controls return true for focusTraversable, so Control overrides @@ -266,7 +263,6 @@ protected Skin createDefaultSkin() { * This method is called from CSS code to get the correct initial value. */ @Deprecated - @Override @SuppressWarnings("deprecation") protected /*do not make final*/ Boolean impl_cssGetFocusTraversableInitialValue() { return Boolean.FALSE; diff --git a/desktop/src/main/java/bisq/desktop/util/ImageUtil.java b/desktop/src/main/java/bisq/desktop/util/ImageUtil.java index 200dc0b2136..45114e26418 100644 --- a/desktop/src/main/java/bisq/desktop/util/ImageUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/ImageUtil.java @@ -22,7 +22,9 @@ import javafx.scene.image.Image; import javafx.scene.image.ImageView; -import com.sun.javafx.tk.quantum.QuantumToolkit; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.geom.AffineTransform; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,10 +59,8 @@ public static ImageView getCountryIconImageView(Country country) { } public static boolean isRetina() { - float maxRenderScale = ((QuantumToolkit) QuantumToolkit.getToolkit()).getMaxRenderScale(); - @SuppressWarnings("UnnecessaryLocalVariable") - boolean isRetina = maxRenderScale > 1.9f; - //log.debug("isRetina=" + isRetina + " / maxRenderScale=" + maxRenderScale); - return isRetina; + final GraphicsConfiguration gfxConfig = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); + final AffineTransform transform = gfxConfig.getDefaultTransform(); + return !transform.isIdentity(); } } From 47251914ca64b0608c891ca534b0b6f5db703c15 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 5 Sep 2018 18:48:29 +0200 Subject: [PATCH 02/19] Remove files that use classes that can't be accessed anymore --- .../StaticProgressIndicatorBehavior.java | 70 -- .../skin/StaticProgressIndicatorSkin.java | 775 ------------------ 2 files changed, 845 deletions(-) delete mode 100644 desktop/src/main/java/bisq/desktop/components/indicator/behavior/StaticProgressIndicatorBehavior.java delete mode 100644 desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/behavior/StaticProgressIndicatorBehavior.java b/desktop/src/main/java/bisq/desktop/components/indicator/behavior/StaticProgressIndicatorBehavior.java deleted file mode 100644 index cbd2c83d3f8..00000000000 --- a/desktop/src/main/java/bisq/desktop/components/indicator/behavior/StaticProgressIndicatorBehavior.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package bisq.desktop.components.indicator.behavior; - -import bisq.desktop.components.indicator.TxConfidenceIndicator; - -import com.sun.javafx.scene.control.behavior.BehaviorBase; - -import java.util.Collections; - -// TODO Copied form OpenJFX, check license issues and way how we integrated it -// We changed behaviour which was not exposed via APIs - -/** - * @param - */ -public class StaticProgressIndicatorBehavior extends BehaviorBase { - - /** - * ************************************************************************ - * * - * Constructors * - * * - * ************************************************************************ - */ - - public StaticProgressIndicatorBehavior(final C progress) { - super(progress, Collections.emptyList()); - } -} diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java b/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java deleted file mode 100644 index 38b28e0961d..00000000000 --- a/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java +++ /dev/null @@ -1,775 +0,0 @@ -/* - * This file is part of Bisq. - * - * Bisq is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Bisq is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Bisq. If not, see . - */ - -/* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package bisq.desktop.components.indicator.skin; - -import bisq.desktop.components.indicator.TxConfidenceIndicator; -import bisq.desktop.components.indicator.behavior.StaticProgressIndicatorBehavior; - -import javafx.scene.Node; -import javafx.scene.control.SkinBase; -import javafx.scene.layout.Pane; -import javafx.scene.layout.Region; -import javafx.scene.layout.StackPane; -import javafx.scene.paint.Color; -import javafx.scene.paint.Paint; -import javafx.scene.shape.Arc; -import javafx.scene.shape.ArcType; -import javafx.scene.shape.Circle; -import javafx.scene.transform.Scale; - -import com.sun.javafx.scene.control.skin.BehaviorSkinBase; - -import javafx.css.CssMetaData; -import javafx.css.StyleOrigin; -import javafx.css.Styleable; -import javafx.css.StyleableBooleanProperty; -import javafx.css.StyleableIntegerProperty; -import javafx.css.StyleableObjectProperty; -import javafx.css.StyleableProperty; - -import com.sun.javafx.css.converters.BooleanConverter; -import com.sun.javafx.css.converters.PaintConverter; -import com.sun.javafx.css.converters.SizeConverter; - -import javafx.geometry.Insets; -import javafx.geometry.NodeOrientation; - -import javafx.beans.InvalidationListener; -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.ObjectProperty; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -// TODO Copied form OpenJFX, check license issues and way how we integrated it -// We changed behaviour which was not exposed via APIs - -public class StaticProgressIndicatorSkin extends BehaviorSkinBase> { - - /** - * ************************************************************************ - * * - * UI SubComponents * - * * - * ************************************************************************ - */ - - private IndeterminateSpinner spinner; - /** - * The number of segments in the spinner. - */ - - private final IntegerProperty indeterminateSegmentCount = new StyleableIntegerProperty(8) { - - @Override - protected void invalidated() { - if (spinner != null) { - spinner.rebuild(); - } - } - - - @Override - public Object getBean() { - return StaticProgressIndicatorSkin.this; - } - - - @Override - public String getName() { - return "indeterminateSegmentCount"; - } - - - @Override - public CssMetaData getCssMetaData() { - return StyleableProperties.INDETERMINATE_SEGMENT_COUNT; - } - }; - /** - * True if the progress indicator should rotate as well as animate opacity. - */ - - private final BooleanProperty spinEnabled = new StyleableBooleanProperty(false) { - @Override - protected void invalidated() { - if (spinner != null) { - spinner.setSpinEnabled(get()); - } - } - - - @Override - public CssMetaData getCssMetaData() { - return StyleableProperties.SPIN_ENABLED; - } - - - @Override - public Object getBean() { - return StaticProgressIndicatorSkin.this; - } - - - @Override - public String getName() { - return "spinEnabled"; - } - }; - - private DeterminateIndicator determinateIndicator; - /** - * The colour of the progress segment. - */ - - private final ObjectProperty progressColor = new StyleableObjectProperty(null) { - - @Override - public void set(Paint newProgressColor) { - final Paint color = (newProgressColor instanceof Color) ? newProgressColor : null; - super.set(color); - } - - @Override - protected void invalidated() { - if (spinner != null) { - spinner.setFillOverride(get()); - } - if (determinateIndicator != null) { - determinateIndicator.setFillOverride(get()); - } - } - - - @Override - public Object getBean() { - return StaticProgressIndicatorSkin.this; - } - - - @Override - public String getName() { - return "progressColorProperty"; - } - - - @Override - public CssMetaData getCssMetaData() { - return StyleableProperties.PROGRESS_COLOR; - } - }; - private boolean timeLineNulled = false; - - /** - * ************************************************************************ - * * - * Constructors * - * * - * ************************************************************************ - */ - @SuppressWarnings("deprecation") - public StaticProgressIndicatorSkin(TxConfidenceIndicator control) { - super(control, new StaticProgressIndicatorBehavior<>(control)); - - InvalidationListener indeterminateListener = valueModel -> initialize(); - control.indeterminateProperty().addListener(indeterminateListener); - - InvalidationListener visibilityListener = valueModel -> { - if (getSkinnable().isIndeterminate() && timeLineNulled && spinner == null) { - timeLineNulled = false; - spinner = new IndeterminateSpinner( - getSkinnable(), StaticProgressIndicatorSkin.this, - spinEnabled.get(), progressColor.get()); - getChildren().add(spinner); - } - - if (spinner != null) { - if (!(getSkinnable().impl_isTreeVisible() && getSkinnable().getScene() != null)) { - getChildren().remove(spinner); - spinner = null; - timeLineNulled = true; - } - } - }; - control.visibleProperty().addListener(visibilityListener); - control.parentProperty().addListener(visibilityListener); - - InvalidationListener sceneListener = valueModel -> { - if (spinner != null) { - if (getSkinnable().getScene() == null) { - getChildren().remove(spinner); - spinner = null; - timeLineNulled = true; - } - } else { - if (getSkinnable().getScene() != null && getSkinnable().isIndeterminate()) { - timeLineNulled = false; - spinner = new IndeterminateSpinner( - getSkinnable(), StaticProgressIndicatorSkin.this, - spinEnabled.get(), progressColor.get()); - getChildren().add(spinner); - getSkinnable().requestLayout(); - } - } - }; - control.sceneProperty().addListener(sceneListener); - - initialize(); - getSkinnable().requestLayout(); - } - - /** - * @return The CssMetaData associated with this class, which may include the - * CssMetaData of its super classes. - */ - @SuppressWarnings("SameReturnValue") - public static List> getClassCssMetaData() { - return StyleableProperties.STYLEABLES; - } - - @SuppressWarnings("deprecation") - private void initialize() { - TxConfidenceIndicator control = getSkinnable(); - boolean isIndeterminate = control.isIndeterminate(); - if (isIndeterminate) { - // clean up determinateIndicator - determinateIndicator = null; - // create spinner - spinner = new IndeterminateSpinner(control, this, spinEnabled.get(), progressColor.get()); - getChildren().clear(); - getChildren().add(spinner); - } else { - // clean up after spinner - if (spinner != null) { - spinner = null; - } - // create determinateIndicator - determinateIndicator = - new StaticProgressIndicatorSkin.DeterminateIndicator(control, this, progressColor.get()); - getChildren().clear(); - getChildren().add(determinateIndicator); - } - } - - @Override - public void dispose() { - super.dispose(); - if (spinner != null) { - spinner = null; - } - } - - @Override - protected void layoutChildren(final double x, final double y, final double w, final double h) { - if (spinner != null && getSkinnable().isIndeterminate()) { - spinner.layoutChildren(); - spinner.resizeRelocate(0, 0, w, h); - } else if (determinateIndicator != null) { - determinateIndicator.layoutChildren(); - determinateIndicator.resizeRelocate(0, 0, w, h); - } - } - - public Paint getProgressColor() { - return progressColor.get(); - } - - /** - * {@inheritDoc} - */ - @Override - public List> getCssMetaData() { - return getClassCssMetaData(); - } - - // *********** Stylesheet Handling ***************************************** - - /** - * ************************************************************************ - * * - * DeterminateIndicator * - * * - * ************************************************************************ - */ - - @SuppressWarnings({"SameReturnValue", "UnusedParameters"}) - static class DeterminateIndicator extends Region { - //private double textGap = 2.0F; - - - private final TxConfidenceIndicator control; - //private Text text; - - private final StackPane indicator; - - private final StackPane progress; - - private final StackPane tick; - - private final Arc arcShape; - - private final Circle indicatorCircle; - // only update progress text on whole percentages - private int intProgress; - // only update pie arc to nearest degree - private int degProgress; - - public DeterminateIndicator(TxConfidenceIndicator control, StaticProgressIndicatorSkin s, - Paint fillOverride) { - this.control = control; - - getStyleClass().add("determinate-indicator"); - - intProgress = (int) Math.round(control.getProgress() * 100.0); - degProgress = (int) (360 * control.getProgress()); - - InvalidationListener progressListener = valueModel -> updateProgress(); - control.progressProperty().addListener(progressListener); - - getChildren().clear(); - - // The circular background for the progress pie piece - indicator = new StackPane(); - indicator.setScaleShape(false); - indicator.setCenterShape(false); - indicator.getStyleClass().setAll("indicator"); - indicatorCircle = new Circle(); - indicator.setShape(indicatorCircle); - - // The shape for our progress pie piece - arcShape = new Arc(); - arcShape.setType(ArcType.ROUND); - arcShape.setStartAngle(90.0F); - - // Our progress pie piece - progress = new StackPane(); - progress.getStyleClass().setAll("progress"); - progress.setScaleShape(false); - progress.setCenterShape(false); - progress.setShape(arcShape); - progress.getChildren().clear(); - setFillOverride(fillOverride); - - // The check mark that's drawn at 100% - tick = new StackPane(); - tick.getStyleClass().setAll("tick"); - - getChildren().setAll(indicator, progress, /*text,*/ tick); - updateProgress(); - } - - private void setFillOverride(Paint fillOverride) { - if (fillOverride instanceof Color) { - Color c = (Color) fillOverride; - progress.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + - "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + - "" + c.getOpacity() + ");"); - } else { - progress.setStyle(null); - } - } - - //@Override - public boolean isAutomaticallyMirrored() { - // This is used instead of setting NodeOrientation, - // allowing the Text node to inherit the current - // orientation. - return false; - } - - private void updateProgress() { - intProgress = (int) Math.round(control.getProgress() * 100.0); - // text.setText((control.getProgress() >= 1) ? (DONE) : ("" + intProgress + "%")); - - degProgress = (int) (360 * control.getProgress()); - arcShape.setLength(-degProgress); - indicator.setOpacity(control.getProgress() == 0 ? 0 : 1); - requestLayout(); - } - - @Override - protected void layoutChildren() { - // Position and size the circular background - //double doneTextHeight = doneText.getLayoutBounds().getHeight(); - final Insets controlInsets = control.getInsets(); - final double left = snapSize(controlInsets.getLeft()); - final double right = snapSize(controlInsets.getRight()); - final double top = snapSize(controlInsets.getTop()); - final double bottom = snapSize(controlInsets.getBottom()); - - /* - ** use the min of width, or height, keep it a circle - */ - final double areaW = control.getWidth() - left - right; - final double areaH = control.getHeight() - top - bottom /*- textGap - doneTextHeight*/; - final double radiusW = areaW / 2; - final double radiusH = areaH / 2; - final double radius = Math.round(Math.min(radiusW, radiusH)); // use round instead of floor - final double centerX = snapPosition(left + radiusW); - final double centerY = snapPosition(top + radius); - - // find radius that fits inside radius - insetsPadding - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); - final double progressRadius = snapSize(Math.min(Math.min(radius - iLeft, radius - iRight), - Math.min(radius - iTop, radius - iBottom))); - - indicatorCircle.setRadius(radius); - indicator.setLayoutX(centerX); - indicator.setLayoutY(centerY); - - arcShape.setRadiusX(progressRadius); - arcShape.setRadiusY(progressRadius); - progress.setLayoutX(centerX); - progress.setLayoutY(centerY); - - // find radius that fits inside progressRadius - progressInsets - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); - final double indicatorRadius = snapSize(Math.min(Math.min(progressRadius - pLeft, - progressRadius - pRight), Math.min(progressRadius - pTop, progressRadius - pBottom))); - - // find size of spare box that fits inside indicator radius - double squareBoxHalfWidth = Math.ceil(Math.sqrt((indicatorRadius * indicatorRadius) / 2)); - // double squareBoxHalfWidth2 = indicatorRadius * (Math.sqrt(2) / 2); - - tick.setLayoutX(centerX - squareBoxHalfWidth); - tick.setLayoutY(centerY - squareBoxHalfWidth); - tick.resize(squareBoxHalfWidth + squareBoxHalfWidth, squareBoxHalfWidth + squareBoxHalfWidth); - tick.setVisible(control.getProgress() >= 1); - } - - @Override - protected double computePrefWidth(double height) { - final Insets controlInsets = control.getInsets(); - final double left = snapSize(controlInsets.getLeft()); - final double right = snapSize(controlInsets.getRight()); - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); - final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); - final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); - final Insets tickInsets = tick.getInsets(); - final double tLeft = snapSize(tickInsets.getLeft()); - final double tRight = snapSize(tickInsets.getRight()); - final double indicatorWidth = indicatorMax + progressMax + tLeft + tRight + progressMax + indicatorMax; - return left + indicatorWidth + /*Math.max(indicatorWidth, doneText.getLayoutBounds().getWidth()) + */right; - } - - @Override - protected double computePrefHeight(double width) { - final Insets controlInsets = control.getInsets(); - final double top = snapSize(controlInsets.getTop()); - final double bottom = snapSize(controlInsets.getBottom()); - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); - final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); - final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); - final Insets tickInsets = tick.getInsets(); - final double tTop = snapSize(tickInsets.getTop()); - final double tBottom = snapSize(tickInsets.getBottom()); - final double indicatorHeight = indicatorMax + progressMax + tTop + tBottom + progressMax + indicatorMax; - return top + indicatorHeight /*+ textGap + doneText.getLayoutBounds().getHeight()*/ + bottom; - } - - @Override - protected double computeMaxWidth(double height) { - return computePrefWidth(height); - } - - @Override - protected double computeMaxHeight(double width) { - return computePrefHeight(width); - } - } - - /** - * ************************************************************************ - * * - * IndeterminateSpinner * - * * - * ************************************************************************ - */ - - @SuppressWarnings({"ConstantConditions", "MismatchedQueryAndUpdateOfCollection"}) - static class IndeterminateSpinner extends Region { - private final TxConfidenceIndicator control; - private final StaticProgressIndicatorSkin skin; - - private final IndicatorPaths pathsG; - - private final List opacities = new ArrayList<>(); - private boolean spinEnabled = false; - - private Paint fillOverride = null; - - public IndeterminateSpinner(TxConfidenceIndicator control, StaticProgressIndicatorSkin s, - boolean spinEnabled, Paint fillOverride) { - this.control = control; - this.skin = s; - this.spinEnabled = spinEnabled; - this.fillOverride = fillOverride; - - setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT); - getStyleClass().setAll("spinner"); - - pathsG = new IndicatorPaths(this); - getChildren().add(pathsG); - - rebuild(); - } - - public void setFillOverride(Paint fillOverride) { - this.fillOverride = fillOverride; - rebuild(); - } - - public void setSpinEnabled(boolean spinEnabled) { - this.spinEnabled = spinEnabled; - } - - @Override - protected void layoutChildren() { - Insets controlInsets = control.getInsets(); - final double w = control.getWidth() - controlInsets.getLeft() - controlInsets.getRight(); - final double h = control.getHeight() - controlInsets.getTop() - controlInsets.getBottom(); - final double prefW = pathsG.prefWidth(-1); - final double prefH = pathsG.prefHeight(-1); - double scaleX = w / prefW; - double scale = scaleX; - if ((scaleX * prefH) > h) { - scale = h / prefH; - } - double indicatorW = prefW * scale - 3; - double indicatorH = prefH * scale - 3; - pathsG.resizeRelocate((w - indicatorW) / 2, (h - indicatorH) / 2, indicatorW, indicatorH); - } - - private void rebuild() { - // update indeterminate indicator - final int segments = skin.indeterminateSegmentCount.get(); - opacities.clear(); - pathsG.getChildren().clear(); - final double step = 0.8 / (segments - 1); - for (int i = 0; i < segments; i++) { - Region region = new Region(); - region.setScaleShape(false); - region.setCenterShape(false); - region.getStyleClass().addAll("segment", "segment" + i); - if (fillOverride instanceof Color) { - Color c = (Color) fillOverride; - region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + - "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + - "" + c.getOpacity() + ");"); - } else { - region.setStyle(null); - } - double opacity = Math.min(1, i * step); - opacities.add(opacity); - region.setOpacity(opacity); - pathsG.getChildren().add(region); - } - } - - @SuppressWarnings("deprecation") - private class IndicatorPaths extends Pane { - final IndeterminateSpinner piSkin; - - IndicatorPaths(IndeterminateSpinner pi) { - super(); - piSkin = pi; - } - - @Override - protected double computePrefWidth(double height) { - double w = 0; - for (Node child : getChildren()) { - if (child instanceof Region) { - Region region = (Region) child; - if (region.getShape() != null) { - w = Math.max(w, region.getShape().getLayoutBounds().getMaxX()); - } else { - w = Math.max(w, region.prefWidth(height)); - } - } - } - return w; - } - - @Override - protected double computePrefHeight(double width) { - double h = 0; - for (Node child : getChildren()) { - if (child instanceof Region) { - Region region = (Region) child; - if (region.getShape() != null) { - h = Math.max(h, region.getShape().getLayoutBounds().getMaxY()); - } else { - h = Math.max(h, region.prefHeight(width)); - } - } - } - return h; - } - - @Override - protected void layoutChildren() { - // calculate scale - double scale = getWidth() / computePrefWidth(-1); - getChildren().stream().filter(child -> child instanceof Region).forEach(child -> { - Region region = (Region) child; - if (region.getShape() != null) { - region.resize(region.getShape().getLayoutBounds().getMaxX(), - region.getShape().getLayoutBounds().getMaxY()); - region.getTransforms().setAll(new Scale(scale, scale, 0, 0)); - } else { - region.autosize(); - } - }); - } - } - } - - /** - * Super-lazy instantiation pattern from Bill Pugh. - */ - @SuppressWarnings({"deprecation", "unchecked", "ConstantConditions"}) - private static class StyleableProperties { - public static final List> STYLEABLES; - - private static final CssMetaData PROGRESS_COLOR = - new CssMetaData( - "-fx-progress-color", PaintConverter.getInstance(), null) { - - @Override - public boolean isSettable(TxConfidenceIndicator n) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); - return skin.progressColor == null || !skin.progressColor.isBound(); - } - - - @Override - public StyleableProperty getStyleableProperty(TxConfidenceIndicator n) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); - return (StyleableProperty) skin.progressColor; - } - }; - - - private static final CssMetaData INDETERMINATE_SEGMENT_COUNT = - new CssMetaData( - "-fx-indeterminate-segment-count", SizeConverter.getInstance(), 8) { - - @Override - public void set(TxConfidenceIndicator node, Number value, StyleOrigin origin) { - super.set(node, value.intValue(), origin); - } - - @Override - public boolean isSettable(TxConfidenceIndicator n) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); - return skin.indeterminateSegmentCount == null || !skin.indeterminateSegmentCount.isBound(); - } - - - @Override - public StyleableProperty getStyleableProperty(TxConfidenceIndicator n) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); - return (StyleableProperty) skin.indeterminateSegmentCount; - } - }; - - private static final CssMetaData SPIN_ENABLED = new - CssMetaData("-fx-spin-enabled", - BooleanConverter.getInstance(), - Boolean.FALSE) { - - @Override - public boolean isSettable(TxConfidenceIndicator node) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin(); - return skin.spinEnabled == null || !skin.spinEnabled.isBound(); - } - - - @Override - public StyleableProperty getStyleableProperty(TxConfidenceIndicator node) { - final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin(); - return (StyleableProperty) skin.spinEnabled; - } - }; - - static { - final List> styleables = - new ArrayList<>(SkinBase.getClassCssMetaData()); - styleables.add(PROGRESS_COLOR); - styleables.add(INDETERMINATE_SEGMENT_COUNT); - styleables.add(SPIN_ENABLED); - STYLEABLES = Collections.unmodifiableList(styleables); - } - } - -} From 73e4ee5f47555480c2b675e9c051ecfdfc4a6e34 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 5 Sep 2018 18:54:18 +0200 Subject: [PATCH 03/19] Update lombok library --- common/build.gradle | 4 ++-- core/build.gradle | 8 ++++---- desktop/build.gradle | 8 ++++---- p2p/build.gradle | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 18c400eb5eb..40e5d279982 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -56,7 +56,7 @@ dependencies { compile 'org.bouncycastle:bcpg-jdk15on:1.56' compile 'commons-io:commons-io:2.4' compile 'org.apache.commons:commons-lang3:3.4' - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' testCompile 'junit:junit:4.12' } diff --git a/core/build.gradle b/core/build.gradle index 7e93918d623..9ef8ea826f2 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -43,8 +43,8 @@ dependencies { compile('com.fasterxml.jackson.core:jackson-databind:2.8.10') { exclude(module: 'jackson-annotations') } - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' testCompile 'junit:junit:4.12' testCompile('org.mockito:mockito-core:2.8.9') { exclude(module: 'objenesis') @@ -55,6 +55,6 @@ dependencies { testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' - testCompileOnly 'org.projectlombok:lombok:1.16.16' - testAnnotationProcessor 'org.projectlombok:lombok:1.16.16' + testCompileOnly 'org.projectlombok:lombok:1.18.2' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } diff --git a/desktop/build.gradle b/desktop/build.gradle index 9385ab687b5..866e98788e0 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -55,8 +55,8 @@ dependencies { compile 'com.github.sarxos:webcam-capture:0.3.12' - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' testCompile('org.mockito:mockito-core:2.8.9') { exclude(module: 'objenesis') } @@ -65,8 +65,8 @@ dependencies { testCompile 'org.powermock:powermock-api-mockito2:1.7.1' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' - testCompileOnly 'org.projectlombok:lombok:1.16.16' - testAnnotationProcessor 'org.projectlombok:lombok:1.16.16' + testCompileOnly 'org.projectlombok:lombok:1.18.2' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } build.dependsOn installDist diff --git a/p2p/build.gradle b/p2p/build.gradle index 3ed28d2e47a..97459fb0341 100644 --- a/p2p/build.gradle +++ b/p2p/build.gradle @@ -24,10 +24,10 @@ dependencies { } compile 'net.sf.jopt-simple:jopt-simple:5.0.3' compile 'org.fxmisc.easybind:easybind:1.0.3' - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' testCompile 'junit:junit:4.12' testCompile 'org.jmockit:jmockit:1.30' - testCompileOnly 'org.projectlombok:lombok:1.16.16' - testAnnotationProcessor 'org.projectlombok:lombok:1.16.16' + testCompileOnly 'org.projectlombok:lombok:1.18.2' + testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } From bd9a2089777b48c6e21c0dd7245609e439a1f60d Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 7 Sep 2018 11:35:45 +0200 Subject: [PATCH 04/19] Update source compatibility to Java 10 --- assets/build.gradle | 2 +- common/build.gradle | 2 +- core/build.gradle | 2 +- desktop/build.gradle | 2 +- p2p/build.gradle | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assets/build.gradle b/assets/build.gradle index a2dd32af13b..28f6fc9940c 100644 --- a/assets/build.gradle +++ b/assets/build.gradle @@ -6,7 +6,7 @@ plugins { group 'network.bisq' version '-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' diff --git a/common/build.gradle b/common/build.gradle index 40e5d279982..9fe1ab739a3 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -11,7 +11,7 @@ ext { protobufVersion = '3.5.1' } -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' diff --git a/core/build.gradle b/core/build.gradle index 9ef8ea826f2..be9754349e6 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -6,7 +6,7 @@ plugins { group = 'network.bisq' version = '-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' diff --git a/desktop/build.gradle b/desktop/build.gradle index 866e98788e0..40e3b7f4bbb 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -17,7 +17,7 @@ apply plugin: 'com.github.johnrengelman.shadow' group = 'network.bisq' version = '0.8.0-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 mainClassName = 'bisq.desktop.app.BisqAppMain' diff --git a/p2p/build.gradle b/p2p/build.gradle index 97459fb0341..b7dd2275c3b 100644 --- a/p2p/build.gradle +++ b/p2p/build.gradle @@ -6,7 +6,7 @@ plugins { group = 'network.bisq' version = '-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 repositories { jcenter() From 5d239711da3498c517aa8ec787ce36ecf504c7ec Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 7 Sep 2018 13:04:15 +0200 Subject: [PATCH 05/19] Update travis Java version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ed2abf26c06..03ee8ff1623 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: java -jdk: oraclejdk8 +jdk: oraclejdk10 notifications: slack: on_success: change From e3194491861497764338aac149a6f4a23fb1033d Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 7 Sep 2018 14:02:22 +0200 Subject: [PATCH 06/19] Make power mock tests Java 10 compatibile --- core/build.gradle | 6 +++--- .../bisq/core/arbitration/ArbitratorManagerTest.java | 2 ++ .../bisq/core/btc/wallet/WalletSetupPreferencesTest.java | 2 ++ .../java/bisq/core/dao/state/SnapshotManagerTest.java | 2 ++ core/src/test/java/bisq/core/offer/OfferTest.java | 2 ++ .../test/java/bisq/core/offer/OpenOfferManagerTest.java | 2 ++ .../test/java/bisq/core/payment/PaymentAccountsTest.java | 2 ++ .../java/bisq/core/payment/ReceiptPredicatesTest.java | 2 ++ .../java/bisq/core/payment/ReceiptValidatorTest.java | 2 ++ core/src/test/java/bisq/core/user/PreferencesTest.java | 2 ++ desktop/build.gradle | 9 ++++++--- .../funds/transactions/TransactionAwareTradeTest.java | 2 ++ .../market/offerbook/OfferBookChartViewModelTest.java | 2 ++ .../desktop/main/market/spread/SpreadViewModelTest.java | 2 ++ .../main/offer/createoffer/CreateOfferViewModelTest.java | 2 ++ .../main/offer/offerbook/OfferBookViewModelTest.java | 2 ++ .../settings/preferences/PreferencesViewModelTest.java | 2 ++ .../src/test/java/bisq/desktop/util/BSFormatterTest.java | 2 ++ .../test/java/bisq/desktop/util/CurrencyListTest.java | 2 ++ 19 files changed, 43 insertions(+), 6 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index be9754349e6..caa6c7b8ec1 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -46,12 +46,12 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.2' annotationProcessor 'org.projectlombok:lombok:1.18.2' testCompile 'junit:junit:4.12' - testCompile('org.mockito:mockito-core:2.8.9') { + testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } - testCompile 'org.powermock:powermock-module-junit4:1.7.1' - testCompile 'org.powermock:powermock-api-mockito2:1.7.1' testCompile 'org.jmockit:jmockit:1.30' + testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' + testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' diff --git a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java index ff45952e14c..69a6bd77c05 100644 --- a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java +++ b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java @@ -27,6 +27,7 @@ import java.util.ArrayList; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -43,6 +44,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({User.class, ArbitratorService.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class ArbitratorManagerTest { @Before diff --git a/core/src/test/java/bisq/core/btc/wallet/WalletSetupPreferencesTest.java b/core/src/test/java/bisq/core/btc/wallet/WalletSetupPreferencesTest.java index 2c7317fd076..32cd0c2db95 100644 --- a/core/src/test/java/bisq/core/btc/wallet/WalletSetupPreferencesTest.java +++ b/core/src/test/java/bisq/core/btc/wallet/WalletSetupPreferencesTest.java @@ -23,6 +23,7 @@ import java.util.List; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -38,6 +39,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(Preferences.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class WalletSetupPreferencesTest { @Test public void testSelectPreferredNodesWhenPublicOption() { diff --git a/core/src/test/java/bisq/core/dao/state/SnapshotManagerTest.java b/core/src/test/java/bisq/core/dao/state/SnapshotManagerTest.java index 697cae5dd30..a1ab7f3ccf4 100644 --- a/core/src/test/java/bisq/core/dao/state/SnapshotManagerTest.java +++ b/core/src/test/java/bisq/core/dao/state/SnapshotManagerTest.java @@ -21,6 +21,7 @@ import java.io.File; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -35,6 +36,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({BsqState.class, BsqStateService.class, PersistenceProtoResolver.class, File.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class SnapshotManagerTest { private SnapshotManager snapshotManager; diff --git a/core/src/test/java/bisq/core/offer/OfferTest.java b/core/src/test/java/bisq/core/offer/OfferTest.java index 88a249fe66d..c8d64dc76cb 100644 --- a/core/src/test/java/bisq/core/offer/OfferTest.java +++ b/core/src/test/java/bisq/core/offer/OfferTest.java @@ -17,6 +17,7 @@ package bisq.core.offer; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -30,6 +31,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(OfferPayload.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class OfferTest { @Test diff --git a/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java b/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java index d26b502e983..d94d8ba5aba 100644 --- a/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java +++ b/core/src/test/java/bisq/core/offer/OpenOfferManagerTest.java @@ -9,6 +9,7 @@ import java.util.concurrent.atomic.AtomicBoolean; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -23,6 +24,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({P2PService.class, PeerManager.class, OfferBookService.class, Storage.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class OpenOfferManagerTest { @Test diff --git a/core/src/test/java/bisq/core/payment/PaymentAccountsTest.java b/core/src/test/java/bisq/core/payment/PaymentAccountsTest.java index b80a9aff399..871215967a0 100644 --- a/core/src/test/java/bisq/core/payment/PaymentAccountsTest.java +++ b/core/src/test/java/bisq/core/payment/PaymentAccountsTest.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.function.BiFunction; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -41,6 +42,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({PaymentAccount.class, AccountAgeWitness.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class PaymentAccountsTest { @Test public void testGetOldestPaymentAccountForOfferWhenNoValidAccounts() { diff --git a/core/src/test/java/bisq/core/payment/ReceiptPredicatesTest.java b/core/src/test/java/bisq/core/payment/ReceiptPredicatesTest.java index e6de2beb7cb..3ff6e92207c 100644 --- a/core/src/test/java/bisq/core/payment/ReceiptPredicatesTest.java +++ b/core/src/test/java/bisq/core/payment/ReceiptPredicatesTest.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -36,6 +37,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({NationalBankAccount.class, SepaAccount.class, SepaInstantAccount.class, PaymentMethod.class, SameBankAccount.class, SpecificBanksAccount.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class ReceiptPredicatesTest { private final ReceiptPredicates predicates = new ReceiptPredicates(); diff --git a/core/src/test/java/bisq/core/payment/ReceiptValidatorTest.java b/core/src/test/java/bisq/core/payment/ReceiptValidatorTest.java index 16f4cd236ef..c33adf62052 100644 --- a/core/src/test/java/bisq/core/payment/ReceiptValidatorTest.java +++ b/core/src/test/java/bisq/core/payment/ReceiptValidatorTest.java @@ -20,6 +20,7 @@ import bisq.core.offer.Offer; import bisq.core.payment.payload.PaymentMethod; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -36,6 +37,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({SpecificBanksAccount.class, SameBankAccount.class, NationalBankAccount.class, MoneyGramAccount.class, WesternUnionAccount.class, CashDepositAccount.class, PaymentMethod.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class ReceiptValidatorTest { private ReceiptValidator validator; private PaymentAccount account; diff --git a/core/src/test/java/bisq/core/user/PreferencesTest.java b/core/src/test/java/bisq/core/user/PreferencesTest.java index 40a52138265..a58aeab95b6 100644 --- a/core/src/test/java/bisq/core/user/PreferencesTest.java +++ b/core/src/test/java/bisq/core/user/PreferencesTest.java @@ -34,6 +34,7 @@ import java.util.List; import java.util.Locale; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -50,6 +51,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({Storage.class, PreferencesPayload.class, BisqEnvironment.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class PreferencesTest { private Preferences preferences; diff --git a/desktop/build.gradle b/desktop/build.gradle index 40e3b7f4bbb..ef645dedddc 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -57,18 +57,21 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.2' annotationProcessor 'org.projectlombok:lombok:1.18.2' - testCompile('org.mockito:mockito-core:2.8.9') { + testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } testCompile 'org.jmockit:jmockit:1.30' - testCompile 'org.powermock:powermock-module-junit4:1.7.1' - testCompile 'org.powermock:powermock-api-mockito2:1.7.1' + testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' + testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' testCompileOnly 'org.projectlombok:lombok:1.18.2' testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } +test { + systemProperty 'jdk.attach.allowAttachSelf', true +} build.dependsOn installDist installDist.destinationDir = file('build/app') diff --git a/desktop/src/test/java/bisq/desktop/main/funds/transactions/TransactionAwareTradeTest.java b/desktop/src/test/java/bisq/desktop/main/funds/transactions/TransactionAwareTradeTest.java index d91415102c4..8895a5749cf 100644 --- a/desktop/src/test/java/bisq/desktop/main/funds/transactions/TransactionAwareTradeTest.java +++ b/desktop/src/test/java/bisq/desktop/main/funds/transactions/TransactionAwareTradeTest.java @@ -27,6 +27,7 @@ import java.util.Collections; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -41,6 +42,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(Dispute.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) @SuppressWarnings("ConstantConditions") public class TransactionAwareTradeTest { private static final String XID = "123"; diff --git a/desktop/src/test/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModelTest.java index 5e7a303aabf..cec316e70fc 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModelTest.java @@ -30,6 +30,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -50,6 +51,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({OfferBook.class, PriceFeedService.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class OfferBookChartViewModelTest { @Before diff --git a/desktop/src/test/java/bisq/desktop/main/market/spread/SpreadViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/spread/SpreadViewModelTest.java index 47aa519fcce..a53683d3448 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/spread/SpreadViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/spread/SpreadViewModelTest.java @@ -28,6 +28,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -45,6 +46,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({OfferBook.class, PriceFeedService.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class SpreadViewModelTest { @Test diff --git a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java index 2caa9bfc294..61d10074230 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/createoffer/CreateOfferViewModelTest.java @@ -46,6 +46,7 @@ import java.time.Instant; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -66,6 +67,7 @@ @PrepareForTest({BtcWalletService.class, AddressEntry.class, PriceFeedService.class, User.class, FeeService.class, CreateOfferDataModel.class, PaymentAccount.class, BsqWalletService.class, SecurityDepositValidator.class, AccountAgeWitnessService.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class CreateOfferViewModelTest { private CreateOfferViewModel model; diff --git a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java index ea6e4734470..d92f87c1fea 100644 --- a/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/offer/offerbook/OfferBookViewModelTest.java @@ -60,6 +60,7 @@ import com.natpryce.makeiteasy.Maker; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -82,6 +83,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({OfferBook.class, OpenOfferManager.class, PriceFeedService.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class OfferBookViewModelTest { private static final Logger log = LoggerFactory.getLogger(OfferBookViewModelTest.class); diff --git a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java index 0e2ac430ed4..cd07a7adda7 100644 --- a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java @@ -33,6 +33,7 @@ import java.util.ArrayList; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -46,6 +47,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({ArbitratorManager.class, Preferences.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class PreferencesViewModelTest { @Before diff --git a/desktop/src/test/java/bisq/desktop/util/BSFormatterTest.java b/desktop/src/test/java/bisq/desktop/util/BSFormatterTest.java index 2996e76fdef..292435e4eb8 100644 --- a/desktop/src/test/java/bisq/desktop/util/BSFormatterTest.java +++ b/desktop/src/test/java/bisq/desktop/util/BSFormatterTest.java @@ -29,6 +29,7 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -53,6 +54,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest({Offer.class, OfferPayload.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class BSFormatterTest { private BSFormatter formatter; diff --git a/desktop/src/test/java/bisq/desktop/util/CurrencyListTest.java b/desktop/src/test/java/bisq/desktop/util/CurrencyListTest.java index dfa16ad992b..a73d5124c24 100644 --- a/desktop/src/test/java/bisq/desktop/util/CurrencyListTest.java +++ b/desktop/src/test/java/bisq/desktop/util/CurrencyListTest.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Locale; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -41,6 +42,7 @@ @RunWith(PowerMockRunner.class) @PrepareForTest(Preferences.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class CurrencyListTest { private static final TradeCurrency USD = new FiatCurrency("USD"); private static final TradeCurrency RUR = new FiatCurrency("RUR"); From 8ed7f4218f8019e83d14e396304ed184795f4497 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 7 Sep 2018 14:03:52 +0200 Subject: [PATCH 07/19] Add not working JMockit setup (help wanted) --- core/build.gradle | 11 ++++++++++- .../java/bisq/core/dao/node/full/BlockParserTest.java | 2 -- .../test/java/bisq/core/trade/TradableListTest.java | 10 +++++----- desktop/build.gradle | 8 +++++++- .../main/market/trades/TradesChartsViewModelTest.java | 8 +++----- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index caa6c7b8ec1..22b1603fe47 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -49,12 +49,21 @@ dependencies { testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } - testCompile 'org.jmockit:jmockit:1.30' testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' + testCompile 'org.jmockit:jmockit:1.42' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' testCompileOnly 'org.projectlombok:lombok:1.18.2' testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } + +/* +// not working JMockit setup +test { + useJUnitPlatform() + def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath + jvmArgs "-javaagent:$jmockit" +} +*/ diff --git a/core/src/test/java/bisq/core/dao/node/full/BlockParserTest.java b/core/src/test/java/bisq/core/dao/node/full/BlockParserTest.java index 6c2b9f8c7d8..51a1d087936 100644 --- a/core/src/test/java/bisq/core/dao/node/full/BlockParserTest.java +++ b/core/src/test/java/bisq/core/dao/node/full/BlockParserTest.java @@ -49,7 +49,6 @@ import mockit.Expectations; import mockit.Injectable; import mockit.Tested; -import mockit.integration.junit4.JMockit; import org.junit.Ignore; import org.junit.Test; @@ -62,7 +61,6 @@ // Intro to jmockit can be found at http://jmockit.github.io/tutorial/Mocking.html @Ignore -@RunWith(JMockit.class) public class BlockParserTest { // @Tested classes are instantiated automatically when needed in a test case, // using injection where possible, see http://jmockit.github.io/tutorial/Mocking.html#tested diff --git a/core/src/test/java/bisq/core/trade/TradableListTest.java b/core/src/test/java/bisq/core/trade/TradableListTest.java index 270b5c7cf92..892a14be12e 100644 --- a/core/src/test/java/bisq/core/trade/TradableListTest.java +++ b/core/src/test/java/bisq/core/trade/TradableListTest.java @@ -26,20 +26,20 @@ import io.bisq.generated.protobuffer.PB; import mockit.Mocked; -import mockit.integration.junit4.JMockit; +import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; import static io.bisq.generated.protobuffer.PB.PersistableEnvelope.MessageCase.TRADABLE_LIST; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(JMockit.class) public class TradableListTest { - @Test - public void protoTesting(@Mocked OfferPayload offerPayload) { + @Mocked OfferPayload offerPayload; + + @Ignore ("JMockit not configured properly for Java 10") + public void protoTesting() { Storage> storage = new Storage<>(null, null); TradableList openOfferTradableList = new TradableList<>(storage, "filename"); PB.PersistableEnvelope message = (PB.PersistableEnvelope) openOfferTradableList.toProtoMessage(); diff --git a/desktop/build.gradle b/desktop/build.gradle index ef645dedddc..45e998840e5 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -60,7 +60,7 @@ dependencies { testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } - testCompile 'org.jmockit:jmockit:1.30' + testCompile 'org.jmockit:jmockit:1.42' testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' @@ -71,6 +71,12 @@ dependencies { test { systemProperty 'jdk.attach.allowAttachSelf', true + /* + // not working JMockit setup + useJUnitPlatform() + def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath + jvmArgs "-javaagent:$jmockit" + */ } build.dependsOn installDist installDist.destinationDir = file('build/app') diff --git a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java index 17fbf0bdb8f..ce3319fb616 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java @@ -62,15 +62,13 @@ import mockit.Mock; import mockit.MockUp; import mockit.Tested; -import mockit.integration.junit4.JMockit; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; -@RunWith(JMockit.class) public class TradesChartsViewModelTest { @Tested TradesChartsViewModel model; @@ -141,7 +139,7 @@ public void setup() throws IOException { } @SuppressWarnings("ConstantConditions") - @Test + @Ignore("JMockit not configured properly for Java 10") public void testGetCandleData() { model.selectedTradeCurrencyProperty.setValue(new FiatCurrency("EUR")); @@ -173,7 +171,7 @@ public void testGetCandleData() { assertEquals(isBullish, candleData.isBullish); } - @Test + @Ignore ("JMockit not configured properly for Java 10") public void testItemLists() throws ParseException { // Helper class to add historic trades class Trade { From 13266b26da0dcb1e98a5ce2b45fc853e6678a10a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 7 Sep 2018 14:04:56 +0200 Subject: [PATCH 08/19] Use FXCollections instead of not existing ObservableListWrapper --- .../market/offerbook/OfferBookChartView.java | 4 ++-- .../offerbook/OfferBookChartViewModel.java | 4 ++-- .../market/trades/TradesChartsViewModel.java | 4 ++-- .../java/bisq/desktop/util/CurrencyList.java | 16 +++++++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java index 4e3acc5e8ff..fad9f8de312 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartView.java @@ -204,7 +204,7 @@ protected void activate() { } }); - model.currencyListItems.addListener(currencyListItemsListener); + model.currencyListItems.getObservableList().addListener(currencyListItemsListener); model.getOfferBookListItems().addListener(changeListener); tradeCurrencySubscriber = EasyBind.subscribe(model.selectedTradeCurrencyProperty, @@ -295,7 +295,7 @@ public Number fromString(String string) { protected void deactivate() { model.getOfferBookListItems().removeListener(changeListener); tabPaneSelectionModel.selectedIndexProperty().removeListener(selectedTabIndexListener); - model.currencyListItems.removeListener(currencyListItemsListener); + model.currencyListItems.getObservableList().removeListener(currencyListItemsListener); tradeCurrencySubscriber.unsubscribe(); currencyComboBox.setOnAction(null); buyOfferTableView.getSelectionModel().selectedItemProperty().removeListener(buyTableRowSelectionListener); diff --git a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java index 10458bb67d2..4b4c3b22ff5 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/market/offerbook/OfferBookChartViewModel.java @@ -234,11 +234,11 @@ public ObservableList getTopSellOfferList() { } public ObservableList getCurrencyListItems() { - return currencyListItems; + return currencyListItems.getObservableList(); } public Optional getSelectedCurrencyListItem() { - return currencyListItems.stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); + return currencyListItems.getObservableList().stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); } public int getMaxNumberOfPriceZeroDecimalsToColorize(Offer offer) { diff --git a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java index 1da1562dae1..fd835a17b6e 100644 --- a/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/market/trades/TradesChartsViewModel.java @@ -220,11 +220,11 @@ public String getCurrencyCode() { } public ObservableList getCurrencyListItems() { - return currencyListItems; + return currencyListItems.getObservableList(); } public Optional getSelectedCurrencyListItem() { - return currencyListItems.stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); + return currencyListItems.getObservableList().stream().filter(e -> e.tradeCurrency.equals(selectedTradeCurrencyProperty.get())).findAny(); } /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/desktop/src/main/java/bisq/desktop/util/CurrencyList.java b/desktop/src/main/java/bisq/desktop/util/CurrencyList.java index 7e8833062d3..209cd0cda4b 100644 --- a/desktop/src/main/java/bisq/desktop/util/CurrencyList.java +++ b/desktop/src/main/java/bisq/desktop/util/CurrencyList.java @@ -22,7 +22,8 @@ import com.google.common.collect.Lists; -import com.sun.javafx.collections.ObservableListWrapper; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import java.util.ArrayList; import java.util.Comparator; @@ -36,25 +37,30 @@ import javax.annotation.Nullable; -public class CurrencyList extends ObservableListWrapper { +public class CurrencyList { private final CurrencyPredicates predicates; private final Preferences preferences; + private final List delegate; public CurrencyList(Preferences preferences) { this(new ArrayList<>(), preferences, new CurrencyPredicates()); } - CurrencyList(List delegate, Preferences preferences, CurrencyPredicates predicates) { - super(delegate); + public CurrencyList(List delegate, Preferences preferences, CurrencyPredicates predicates) { + this.delegate = delegate; this.predicates = predicates; this.preferences = preferences; } + public ObservableList getObservableList() { + return FXCollections.observableList(delegate); + } + public void updateWithCurrencies(List currencies, @Nullable CurrencyListItem first) { List result = Lists.newLinkedList(); Optional.ofNullable(first).ifPresent(result::add); result.addAll(getPartitionedSortedItems(currencies)); - setAll(result); + delegate.addAll(result); } private List getPartitionedSortedItems(List currencies) { From dd6a37291f0a2f31fc6444ef1825750bbc20c13c Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 10 Sep 2018 15:00:03 +0200 Subject: [PATCH 09/19] Change progress indicator skin to work with Java 9+ --- .../indicator/TxConfidenceIndicator.java | 7 +- .../skin/StaticProgressIndicatorSkin.java | 770 ++++++++++++++++++ 2 files changed, 775 insertions(+), 2 deletions(-) create mode 100644 desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java b/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java index bc1f3b932aa..39484521a97 100644 --- a/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java +++ b/desktop/src/main/java/bisq/desktop/components/indicator/TxConfidenceIndicator.java @@ -42,7 +42,10 @@ package bisq.desktop.components.indicator; +import bisq.desktop.components.indicator.skin.StaticProgressIndicatorSkin; + import javafx.scene.control.Control; +import javafx.scene.control.Skin; import javafx.css.PseudoClass; import javafx.css.StyleableProperty; @@ -251,10 +254,10 @@ public String getName() { * {@inheritDoc} */ - /*@Override + @Override protected Skin createDefaultSkin() { return new StaticProgressIndicatorSkin(this); - }*/ + } /** * Most Controls return true for focusTraversable, so Control overrides diff --git a/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java b/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java new file mode 100644 index 00000000000..d994e28a9e0 --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/components/indicator/skin/StaticProgressIndicatorSkin.java @@ -0,0 +1,770 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package bisq.desktop.components.indicator.skin; + +import bisq.desktop.components.indicator.TxConfidenceIndicator; + +import javafx.scene.Node; +import javafx.scene.control.SkinBase; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.paint.Paint; +import javafx.scene.shape.Arc; +import javafx.scene.shape.ArcType; +import javafx.scene.shape.Circle; +import javafx.scene.transform.Scale; + +import javafx.css.CssMetaData; +import javafx.css.StyleOrigin; +import javafx.css.Styleable; +import javafx.css.StyleableBooleanProperty; +import javafx.css.StyleableIntegerProperty; +import javafx.css.StyleableObjectProperty; +import javafx.css.StyleableProperty; +import javafx.css.converter.BooleanConverter; +import javafx.css.converter.PaintConverter; +import javafx.css.converter.SizeConverter; + +import javafx.geometry.Insets; +import javafx.geometry.NodeOrientation; + +import javafx.beans.InvalidationListener; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.IntegerProperty; +import javafx.beans.property.ObjectProperty; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +// TODO Copied form OpenJFX, check license issues and way how we integrated it +// We changed behaviour which was not exposed via APIs + +public class StaticProgressIndicatorSkin extends SkinBase { + + /** + * ************************************************************************ + * * + * UI SubComponents * + * * + * ************************************************************************ + */ + + private IndeterminateSpinner spinner; + /** + * The number of segments in the spinner. + */ + + private final IntegerProperty indeterminateSegmentCount = new StyleableIntegerProperty(8) { + + @Override + protected void invalidated() { + if (spinner != null) { + spinner.rebuild(); + } + } + + + @Override + public Object getBean() { + return StaticProgressIndicatorSkin.this; + } + + + @Override + public String getName() { + return "indeterminateSegmentCount"; + } + + + @Override + public CssMetaData getCssMetaData() { + return StyleableProperties.INDETERMINATE_SEGMENT_COUNT; + } + }; + /** + * True if the progress indicator should rotate as well as animate opacity. + */ + + private final BooleanProperty spinEnabled = new StyleableBooleanProperty(false) { + @Override + protected void invalidated() { + if (spinner != null) { + spinner.setSpinEnabled(get()); + } + } + + + @Override + public CssMetaData getCssMetaData() { + return StyleableProperties.SPIN_ENABLED; + } + + + @Override + public Object getBean() { + return StaticProgressIndicatorSkin.this; + } + + + @Override + public String getName() { + return "spinEnabled"; + } + }; + + private DeterminateIndicator determinateIndicator; + /** + * The colour of the progress segment. + */ + + private final ObjectProperty progressColor = new StyleableObjectProperty(null) { + + @Override + public void set(Paint newProgressColor) { + final Paint color = (newProgressColor instanceof Color) ? newProgressColor : null; + super.set(color); + } + + @Override + protected void invalidated() { + if (spinner != null) { + spinner.setFillOverride(get()); + } + if (determinateIndicator != null) { + determinateIndicator.setFillOverride(get()); + } + } + + + @Override + public Object getBean() { + return StaticProgressIndicatorSkin.this; + } + + + @Override + public String getName() { + return "progressColorProperty"; + } + + + @Override + public CssMetaData getCssMetaData() { + return StyleableProperties.PROGRESS_COLOR; + } + }; + private boolean timeLineNulled = false; + + /** + * ************************************************************************ + * * + * Constructors * + * * + * ************************************************************************ + */ + @SuppressWarnings("deprecation") + public StaticProgressIndicatorSkin(TxConfidenceIndicator control) { + super(control); + + InvalidationListener indeterminateListener = valueModel -> initialize(); + control.indeterminateProperty().addListener(indeterminateListener); + + InvalidationListener visibilityListener = valueModel -> { + if (getSkinnable().isIndeterminate() && timeLineNulled && spinner == null) { + timeLineNulled = false; + spinner = new IndeterminateSpinner( + getSkinnable(), StaticProgressIndicatorSkin.this, + spinEnabled.get(), progressColor.get()); + getChildren().add(spinner); + } + + if (spinner != null) { + if (getSkinnable().getScene() != null) { + getChildren().remove(spinner); + spinner = null; + timeLineNulled = true; + } + } + }; + control.visibleProperty().addListener(visibilityListener); + control.parentProperty().addListener(visibilityListener); + + InvalidationListener sceneListener = valueModel -> { + if (spinner != null) { + if (getSkinnable().getScene() == null) { + getChildren().remove(spinner); + spinner = null; + timeLineNulled = true; + } + } else { + if (getSkinnable().getScene() != null && getSkinnable().isIndeterminate()) { + timeLineNulled = false; + spinner = new IndeterminateSpinner( + getSkinnable(), StaticProgressIndicatorSkin.this, + spinEnabled.get(), progressColor.get()); + getChildren().add(spinner); + getSkinnable().requestLayout(); + } + } + }; + control.sceneProperty().addListener(sceneListener); + + initialize(); + getSkinnable().requestLayout(); + } + + /** + * @return The CssMetaData associated with this class, which may include the + * CssMetaData of its super classes. + */ + @SuppressWarnings("SameReturnValue") + public static List> getClassCssMetaData() { + return StyleableProperties.STYLEABLES; + } + + @SuppressWarnings("deprecation") + private void initialize() { + TxConfidenceIndicator control = getSkinnable(); + boolean isIndeterminate = control.isIndeterminate(); + if (isIndeterminate) { + // clean up determinateIndicator + determinateIndicator = null; + // create spinner + spinner = new IndeterminateSpinner(control, this, spinEnabled.get(), progressColor.get()); + getChildren().clear(); + getChildren().add(spinner); + } else { + // clean up after spinner + if (spinner != null) { + spinner = null; + } + // create determinateIndicator + determinateIndicator = + new StaticProgressIndicatorSkin.DeterminateIndicator(control, this, progressColor.get()); + getChildren().clear(); + getChildren().add(determinateIndicator); + } + } + + @Override + public void dispose() { + super.dispose(); + if (spinner != null) { + spinner = null; + } + } + + @Override + protected void layoutChildren(final double x, final double y, final double w, final double h) { + if (spinner != null && getSkinnable().isIndeterminate()) { + spinner.layoutChildren(); + spinner.resizeRelocate(0, 0, w, h); + } else if (determinateIndicator != null) { + determinateIndicator.layoutChildren(); + determinateIndicator.resizeRelocate(0, 0, w, h); + } + } + + public Paint getProgressColor() { + return progressColor.get(); + } + + /** + * {@inheritDoc} + */ + @Override + public List> getCssMetaData() { + return getClassCssMetaData(); + } + + // *********** Stylesheet Handling ***************************************** + + /** + * ************************************************************************ + * * + * DeterminateIndicator * + * * + * ************************************************************************ + */ + + @SuppressWarnings({"SameReturnValue", "UnusedParameters"}) + static class DeterminateIndicator extends Region { + //private double textGap = 2.0F; + + + private final TxConfidenceIndicator control; + //private Text text; + + private final StackPane indicator; + + private final StackPane progress; + + private final StackPane tick; + + private final Arc arcShape; + + private final Circle indicatorCircle; + // only update progress text on whole percentages + private int intProgress; + // only update pie arc to nearest degree + private int degProgress; + + public DeterminateIndicator(TxConfidenceIndicator control, StaticProgressIndicatorSkin s, + Paint fillOverride) { + this.control = control; + + getStyleClass().add("determinate-indicator"); + + intProgress = (int) Math.round(control.getProgress() * 100.0); + degProgress = (int) (360 * control.getProgress()); + + InvalidationListener progressListener = valueModel -> updateProgress(); + control.progressProperty().addListener(progressListener); + + getChildren().clear(); + + // The circular background for the progress pie piece + indicator = new StackPane(); + indicator.setScaleShape(false); + indicator.setCenterShape(false); + indicator.getStyleClass().setAll("indicator"); + indicatorCircle = new Circle(); + indicator.setShape(indicatorCircle); + + // The shape for our progress pie piece + arcShape = new Arc(); + arcShape.setType(ArcType.ROUND); + arcShape.setStartAngle(90.0F); + + // Our progress pie piece + progress = new StackPane(); + progress.getStyleClass().setAll("progress"); + progress.setScaleShape(false); + progress.setCenterShape(false); + progress.setShape(arcShape); + progress.getChildren().clear(); + setFillOverride(fillOverride); + + // The check mark that's drawn at 100% + tick = new StackPane(); + tick.getStyleClass().setAll("tick"); + + getChildren().setAll(indicator, progress, /*text,*/ tick); + updateProgress(); + } + + private void setFillOverride(Paint fillOverride) { + if (fillOverride instanceof Color) { + Color c = (Color) fillOverride; + progress.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + + "" + c.getOpacity() + ");"); + } else { + progress.setStyle(null); + } + } + + //@Override + public boolean isAutomaticallyMirrored() { + // This is used instead of setting NodeOrientation, + // allowing the Text node to inherit the current + // orientation. + return false; + } + + private void updateProgress() { + intProgress = (int) Math.round(control.getProgress() * 100.0); + // text.setText((control.getProgress() >= 1) ? (DONE) : ("" + intProgress + "%")); + + degProgress = (int) (360 * control.getProgress()); + arcShape.setLength(-degProgress); + indicator.setOpacity(control.getProgress() == 0 ? 0 : 1); + requestLayout(); + } + + @Override + protected void layoutChildren() { + // Position and size the circular background + //double doneTextHeight = doneText.getLayoutBounds().getHeight(); + final Insets controlInsets = control.getInsets(); + final double left = snapSize(controlInsets.getLeft()); + final double right = snapSize(controlInsets.getRight()); + final double top = snapSize(controlInsets.getTop()); + final double bottom = snapSize(controlInsets.getBottom()); + + /* + ** use the min of width, or height, keep it a circle + */ + final double areaW = control.getWidth() - left - right; + final double areaH = control.getHeight() - top - bottom /*- textGap - doneTextHeight*/; + final double radiusW = areaW / 2; + final double radiusH = areaH / 2; + final double radius = Math.round(Math.min(radiusW, radiusH)); // use round instead of floor + final double centerX = snapPosition(left + radiusW); + final double centerY = snapPosition(top + radius); + + // find radius that fits inside radius - insetsPadding + final Insets indicatorInsets = indicator.getInsets(); + final double iLeft = snapSize(indicatorInsets.getLeft()); + final double iRight = snapSize(indicatorInsets.getRight()); + final double iTop = snapSize(indicatorInsets.getTop()); + final double iBottom = snapSize(indicatorInsets.getBottom()); + final double progressRadius = snapSize(Math.min(Math.min(radius - iLeft, radius - iRight), + Math.min(radius - iTop, radius - iBottom))); + + indicatorCircle.setRadius(radius); + indicator.setLayoutX(centerX); + indicator.setLayoutY(centerY); + + arcShape.setRadiusX(progressRadius); + arcShape.setRadiusY(progressRadius); + progress.setLayoutX(centerX); + progress.setLayoutY(centerY); + + // find radius that fits inside progressRadius - progressInsets + final Insets progressInsets = progress.getInsets(); + final double pLeft = snapSize(progressInsets.getLeft()); + final double pRight = snapSize(progressInsets.getRight()); + final double pTop = snapSize(progressInsets.getTop()); + final double pBottom = snapSize(progressInsets.getBottom()); + final double indicatorRadius = snapSize(Math.min(Math.min(progressRadius - pLeft, + progressRadius - pRight), Math.min(progressRadius - pTop, progressRadius - pBottom))); + + // find size of spare box that fits inside indicator radius + double squareBoxHalfWidth = Math.ceil(Math.sqrt((indicatorRadius * indicatorRadius) / 2)); + // double squareBoxHalfWidth2 = indicatorRadius * (Math.sqrt(2) / 2); + + tick.setLayoutX(centerX - squareBoxHalfWidth); + tick.setLayoutY(centerY - squareBoxHalfWidth); + tick.resize(squareBoxHalfWidth + squareBoxHalfWidth, squareBoxHalfWidth + squareBoxHalfWidth); + tick.setVisible(control.getProgress() >= 1); + } + + @Override + protected double computePrefWidth(double height) { + final Insets controlInsets = control.getInsets(); + final double left = snapSize(controlInsets.getLeft()); + final double right = snapSize(controlInsets.getRight()); + final Insets indicatorInsets = indicator.getInsets(); + final double iLeft = snapSize(indicatorInsets.getLeft()); + final double iRight = snapSize(indicatorInsets.getRight()); + final double iTop = snapSize(indicatorInsets.getTop()); + final double iBottom = snapSize(indicatorInsets.getBottom()); + final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); + final Insets progressInsets = progress.getInsets(); + final double pLeft = snapSize(progressInsets.getLeft()); + final double pRight = snapSize(progressInsets.getRight()); + final double pTop = snapSize(progressInsets.getTop()); + final double pBottom = snapSize(progressInsets.getBottom()); + final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); + final Insets tickInsets = tick.getInsets(); + final double tLeft = snapSize(tickInsets.getLeft()); + final double tRight = snapSize(tickInsets.getRight()); + final double indicatorWidth = indicatorMax + progressMax + tLeft + tRight + progressMax + indicatorMax; + return left + indicatorWidth + /*Math.max(indicatorWidth, doneText.getLayoutBounds().getWidth()) + */right; + } + + @Override + protected double computePrefHeight(double width) { + final Insets controlInsets = control.getInsets(); + final double top = snapSize(controlInsets.getTop()); + final double bottom = snapSize(controlInsets.getBottom()); + final Insets indicatorInsets = indicator.getInsets(); + final double iLeft = snapSize(indicatorInsets.getLeft()); + final double iRight = snapSize(indicatorInsets.getRight()); + final double iTop = snapSize(indicatorInsets.getTop()); + final double iBottom = snapSize(indicatorInsets.getBottom()); + final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); + final Insets progressInsets = progress.getInsets(); + final double pLeft = snapSize(progressInsets.getLeft()); + final double pRight = snapSize(progressInsets.getRight()); + final double pTop = snapSize(progressInsets.getTop()); + final double pBottom = snapSize(progressInsets.getBottom()); + final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); + final Insets tickInsets = tick.getInsets(); + final double tTop = snapSize(tickInsets.getTop()); + final double tBottom = snapSize(tickInsets.getBottom()); + final double indicatorHeight = indicatorMax + progressMax + tTop + tBottom + progressMax + indicatorMax; + return top + indicatorHeight /*+ textGap + doneText.getLayoutBounds().getHeight()*/ + bottom; + } + + @Override + protected double computeMaxWidth(double height) { + return computePrefWidth(height); + } + + @Override + protected double computeMaxHeight(double width) { + return computePrefHeight(width); + } + } + + /** + * ************************************************************************ + * * + * IndeterminateSpinner * + * * + * ************************************************************************ + */ + + @SuppressWarnings({"ConstantConditions", "MismatchedQueryAndUpdateOfCollection"}) + static class IndeterminateSpinner extends Region { + private final TxConfidenceIndicator control; + private final StaticProgressIndicatorSkin skin; + + private final IndicatorPaths pathsG; + + private final List opacities = new ArrayList<>(); + private boolean spinEnabled = false; + + private Paint fillOverride = null; + + public IndeterminateSpinner(TxConfidenceIndicator control, StaticProgressIndicatorSkin s, + boolean spinEnabled, Paint fillOverride) { + this.control = control; + this.skin = s; + this.spinEnabled = spinEnabled; + this.fillOverride = fillOverride; + + setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT); + getStyleClass().setAll("spinner"); + + pathsG = new IndicatorPaths(this); + getChildren().add(pathsG); + + rebuild(); + } + + public void setFillOverride(Paint fillOverride) { + this.fillOverride = fillOverride; + rebuild(); + } + + public void setSpinEnabled(boolean spinEnabled) { + this.spinEnabled = spinEnabled; + } + + @Override + protected void layoutChildren() { + Insets controlInsets = control.getInsets(); + final double w = control.getWidth() - controlInsets.getLeft() - controlInsets.getRight(); + final double h = control.getHeight() - controlInsets.getTop() - controlInsets.getBottom(); + final double prefW = pathsG.prefWidth(-1); + final double prefH = pathsG.prefHeight(-1); + double scaleX = w / prefW; + double scale = scaleX; + if ((scaleX * prefH) > h) { + scale = h / prefH; + } + double indicatorW = prefW * scale - 3; + double indicatorH = prefH * scale - 3; + pathsG.resizeRelocate((w - indicatorW) / 2, (h - indicatorH) / 2, indicatorW, indicatorH); + } + + private void rebuild() { + // update indeterminate indicator + final int segments = skin.indeterminateSegmentCount.get(); + opacities.clear(); + pathsG.getChildren().clear(); + final double step = 0.8 / (segments - 1); + for (int i = 0; i < segments; i++) { + Region region = new Region(); + region.setScaleShape(false); + region.setCenterShape(false); + region.getStyleClass().addAll("segment", "segment" + i); + if (fillOverride instanceof Color) { + Color c = (Color) fillOverride; + region.setStyle("-fx-background-color: rgba(" + ((int) (255 * c.getRed())) + "," + + "" + ((int) (255 * c.getGreen())) + "," + ((int) (255 * c.getBlue())) + "," + + "" + c.getOpacity() + ");"); + } else { + region.setStyle(null); + } + double opacity = Math.min(1, i * step); + opacities.add(opacity); + region.setOpacity(opacity); + pathsG.getChildren().add(region); + } + } + + @SuppressWarnings("deprecation") + private class IndicatorPaths extends Pane { + final IndeterminateSpinner piSkin; + + IndicatorPaths(IndeterminateSpinner pi) { + super(); + piSkin = pi; + } + + @Override + protected double computePrefWidth(double height) { + double w = 0; + for (Node child : getChildren()) { + if (child instanceof Region) { + Region region = (Region) child; + if (region.getShape() != null) { + w = Math.max(w, region.getShape().getLayoutBounds().getMaxX()); + } else { + w = Math.max(w, region.prefWidth(height)); + } + } + } + return w; + } + + @Override + protected double computePrefHeight(double width) { + double h = 0; + for (Node child : getChildren()) { + if (child instanceof Region) { + Region region = (Region) child; + if (region.getShape() != null) { + h = Math.max(h, region.getShape().getLayoutBounds().getMaxY()); + } else { + h = Math.max(h, region.prefHeight(width)); + } + } + } + return h; + } + + @Override + protected void layoutChildren() { + // calculate scale + double scale = getWidth() / computePrefWidth(-1); + getChildren().stream().filter(child -> child instanceof Region).forEach(child -> { + Region region = (Region) child; + if (region.getShape() != null) { + region.resize(region.getShape().getLayoutBounds().getMaxX(), + region.getShape().getLayoutBounds().getMaxY()); + region.getTransforms().setAll(new Scale(scale, scale, 0, 0)); + } else { + region.autosize(); + } + }); + } + } + } + + /** + * Super-lazy instantiation pattern from Bill Pugh. + */ + @SuppressWarnings({"deprecation", "unchecked", "ConstantConditions"}) + private static class StyleableProperties { + public static final List> STYLEABLES; + + private static final CssMetaData PROGRESS_COLOR = + new CssMetaData( + "-fx-progress-color", PaintConverter.getInstance(), null) { + + @Override + public boolean isSettable(TxConfidenceIndicator n) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); + return skin.progressColor == null || !skin.progressColor.isBound(); + } + + + @Override + public StyleableProperty getStyleableProperty(TxConfidenceIndicator n) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); + return (StyleableProperty) skin.progressColor; + } + }; + + + private static final CssMetaData INDETERMINATE_SEGMENT_COUNT = + new CssMetaData( + "-fx-indeterminate-segment-count", SizeConverter.getInstance(), 8) { + + @Override + public void set(TxConfidenceIndicator node, Number value, StyleOrigin origin) { + super.set(node, value.intValue(), origin); + } + + @Override + public boolean isSettable(TxConfidenceIndicator n) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); + return skin.indeterminateSegmentCount == null || !skin.indeterminateSegmentCount.isBound(); + } + + + @Override + public StyleableProperty getStyleableProperty(TxConfidenceIndicator n) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) n.getSkin(); + return (StyleableProperty) skin.indeterminateSegmentCount; + } + }; + + private static final CssMetaData SPIN_ENABLED = new + CssMetaData("-fx-spin-enabled", + BooleanConverter.getInstance(), + Boolean.FALSE) { + + @Override + public boolean isSettable(TxConfidenceIndicator node) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin(); + return skin.spinEnabled == null || !skin.spinEnabled.isBound(); + } + + + @Override + public StyleableProperty getStyleableProperty(TxConfidenceIndicator node) { + final StaticProgressIndicatorSkin skin = (StaticProgressIndicatorSkin) node.getSkin(); + return (StyleableProperty) skin.spinEnabled; + } + }; + + static { + final List> styleables = + new ArrayList<>(SkinBase.getClassCssMetaData()); + styleables.add(PROGRESS_COLOR); + styleables.add(INDETERMINATE_SEGMENT_COUNT); + styleables.add(SPIN_ENABLED); + STYLEABLES = Collections.unmodifiableList(styleables); + } + } + +} From 2efe20a63f035a85f2874220793b25d431b5d365 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 11 Sep 2018 19:00:45 +0200 Subject: [PATCH 10/19] Add temporary workaround for running desktop build --- desktop/package/osx/create_app.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/package/osx/create_app.sh b/desktop/package/osx/create_app.sh index 0de831e555c..2d959810cb4 100755 --- a/desktop/package/osx/create_app.sh +++ b/desktop/package/osx/create_app.sh @@ -8,7 +8,9 @@ set -e version="0.8.0" -../gradlew build -x test shadowJar +cd .. +./gradlew :desktop:build -x test shadowJar +cd desktop EXE_JAR=build/libs/desktop-$version-all.jar From 672e3622b6c825dce68df790001fb2890487371b Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 11 Sep 2018 20:09:22 +0200 Subject: [PATCH 11/19] Add -srcdir for Java 10 javapackager --- desktop/package/osx/create_app.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/package/osx/create_app.sh b/desktop/package/osx/create_app.sh index 2d959810cb4..25c3e0b537b 100755 --- a/desktop/package/osx/create_app.sh +++ b/desktop/package/osx/create_app.sh @@ -88,7 +88,8 @@ $JAVA_HOME/bin/javapackager \ -title Bisq \ -vendor Bisq \ -outdir deploy \ - -srcfiles "deploy/Bisq-$version.jar" \ + -srcdir deploy \ + -srcfiles "Bisq-$version.jar" \ -appclass bisq.desktop.app.BisqAppMain \ -outfile Bisq From 64370f7adb96b4ef0f2cb1c555f20e9e9a19f6b7 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 13 Sep 2018 10:46:07 +0200 Subject: [PATCH 12/19] Fix JMockit setup --- core/build.gradle | 14 +++++++++----- .../java/bisq/core/trade/TradableListTest.java | 7 ++----- desktop/build.gradle | 10 +++++----- .../market/trades/TradesChartsViewModelTest.java | 5 ++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 22b1603fe47..3c1c180bf24 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -12,6 +12,8 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } +def jmockitVersion = '1.42' + repositories { jcenter() maven { url 'https://jitpack.io' } @@ -45,13 +47,16 @@ dependencies { } compileOnly 'org.projectlombok:lombok:1.18.2' annotationProcessor 'org.projectlombok:lombok:1.18.2' + + testCompile "org.jmockit:jmockit:$jmockitVersion" testCompile 'junit:junit:4.12' testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' - testCompile 'org.jmockit:jmockit:1.42' + + testCompile 'org.springframework:spring-test:4.3.6.RELEASE' testCompile 'com.natpryce:make-it-easy:4.0.1' testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' @@ -59,11 +64,10 @@ dependencies { testAnnotationProcessor 'org.projectlombok:lombok:1.18.2' } -/* -// not working JMockit setup test { - useJUnitPlatform() + systemProperty 'jdk.attach.allowAttachSelf', true + def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath jvmArgs "-javaagent:$jmockit" } -*/ + diff --git a/core/src/test/java/bisq/core/trade/TradableListTest.java b/core/src/test/java/bisq/core/trade/TradableListTest.java index 892a14be12e..2de76604e47 100644 --- a/core/src/test/java/bisq/core/trade/TradableListTest.java +++ b/core/src/test/java/bisq/core/trade/TradableListTest.java @@ -27,7 +27,6 @@ import mockit.Mocked; -import org.junit.Ignore; import org.junit.Test; import static io.bisq.generated.protobuffer.PB.PersistableEnvelope.MessageCase.TRADABLE_LIST; @@ -36,10 +35,8 @@ public class TradableListTest { - @Mocked OfferPayload offerPayload; - - @Ignore ("JMockit not configured properly for Java 10") - public void protoTesting() { + @Test + public void protoTesting(@Mocked OfferPayload offerPayload) { Storage> storage = new Storage<>(null, null); TradableList openOfferTradableList = new TradableList<>(storage, "filename"); PB.PersistableEnvelope message = (PB.PersistableEnvelope) openOfferTradableList.toProtoMessage(); diff --git a/desktop/build.gradle b/desktop/build.gradle index 45e998840e5..ccec60bdcfa 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -21,6 +21,8 @@ sourceCompatibility = 1.10 mainClassName = 'bisq.desktop.app.BisqAppMain' +def jmockitVersion = '1.42' + tasks.withType(AbstractArchiveTask) { preserveFileTimestamps = false reproducibleFileOrder = true @@ -57,10 +59,11 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.2' annotationProcessor 'org.projectlombok:lombok:1.18.2' + + testCompile "org.jmockit:jmockit:$jmockitVersion" testCompile('org.mockito:mockito-core:2.21.0') { exclude(module: 'objenesis') } - testCompile 'org.jmockit:jmockit:1.42' testCompile 'org.powermock:powermock-module-junit4:2.0.0-beta.5' testCompile 'org.powermock:powermock-api-mockito2:2.0.0-beta.5' testCompile 'org.springframework:spring-test:4.3.6.RELEASE' @@ -71,12 +74,9 @@ dependencies { test { systemProperty 'jdk.attach.allowAttachSelf', true - /* - // not working JMockit setup - useJUnitPlatform() + def jmockit = configurations.testCompile.files.find { it.name.contains("jmockit") }.absolutePath jvmArgs "-javaagent:$jmockit" - */ } build.dependsOn installDist installDist.destinationDir = file('build/app') diff --git a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java index ce3319fb616..9bd5d1bc7e1 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java @@ -64,7 +64,6 @@ import mockit.Tested; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -139,7 +138,7 @@ public void setup() throws IOException { } @SuppressWarnings("ConstantConditions") - @Ignore("JMockit not configured properly for Java 10") + @Test public void testGetCandleData() { model.selectedTradeCurrencyProperty.setValue(new FiatCurrency("EUR")); @@ -171,7 +170,7 @@ public void testGetCandleData() { assertEquals(isBullish, candleData.isBullish); } - @Ignore ("JMockit not configured properly for Java 10") + @Test public void testItemLists() throws ParseException { // Helper class to add historic trades class Trade { From 1c783e436e3a2f8061fe58311da4e2d68ef790f1 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 14 Sep 2018 15:28:51 +0200 Subject: [PATCH 13/19] Update fontawesome library --- desktop/build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/build.gradle b/desktop/build.gradle index ccec60bdcfa..5480cb388ea 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -51,8 +51,8 @@ dependencies { compile 'org.reactfx:reactfx:2.0-M3' compile 'net.glxn:qrgen:1.3' compile 'de.jensd:fontawesomefx:8.0.0' - compile 'de.jensd:fontawesomefx-commons:8.15' - compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4' + compile 'de.jensd:fontawesomefx-commons:9.1.2' + compile 'de.jensd:fontawesomefx-materialdesignfont:2.0.26-9.1.2' compile 'com.googlecode.jcsv:jcsv:1.4.0' compile 'com.github.sarxos:webcam-capture:0.3.12' @@ -97,8 +97,8 @@ dependencyVerification { 'org.reactfx:reactfx:81ec8fe545d65661222735711114c2ce427e2187a65f1722e8ac4e4805beeca3', 'net.glxn:qrgen:c85d9d8512d91e8ad11fe56259a7825bd50ce0245447e236cf168d1b17591882', 'de.jensd:fontawesomefx:73bacc991a0a6f5cf0f911767c8db161e0949dbca61e8371eb4342e3da96887b', - 'de.jensd:fontawesomefx-materialdesignfont:8f700556bbfdc4a581224d3bd6ff869b8a03f6670bd7e0fc78884bd2f31fdb64', - 'de.jensd:fontawesomefx-commons:e1505a31433f1b2902478217651afc78dae5ab09670336afc46e582a1dea1e4d', + 'de.jensd:fontawesomefx-materialdesignfont:dbad8dfdd1c85e298d5bbae25b2399aec9e85064db57b2427d10f3815aa98752', + 'de.jensd:fontawesomefx-commons:5539bb3335ecb822dbf928546f57766eeb9f1516cc1417a064b5709629612149', 'com.googlecode.jcsv:jcsv:73ca7d715e90c8d2c2635cc284543b038245a34f70790660ed590e157b8714a2', 'com.github.sarxos:webcam-capture:d960b7ea8ec3ddf2df0725ef214c3fccc9699ea7772df37f544e1f8e4fd665f6', 'com.google.protobuf:protobuf-java:b5e2d91812d183c9f053ffeebcbcda034d4de6679521940a19064714966c2cd4', From 4c068af7b3ce1db8af1506f520a1f483674fdfda Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 14 Sep 2018 16:02:58 +0200 Subject: [PATCH 14/19] Use default security provider instead of Bouncy Castle --- .../java/bisq/common/crypto/Encryption.java | 31 ++++++++++++------- .../main/java/bisq/common/crypto/Hash.java | 5 ++- .../java/bisq/common/crypto/KeyStorage.java | 5 ++- .../src/main/java/bisq/common/crypto/Sig.java | 17 +++++----- .../java/bisq/common/setup/CommonSetup.java | 5 --- .../main/java/bisq/core/app/BisqSetup.java | 3 -- .../main/java/bisq/core/app/SetupUtils.java | 8 ----- .../arbitration/ArbitratorManagerTest.java | 5 +-- .../java/bisq/core/crypto/EncryptionTest.java | 2 +- .../test/java/bisq/core/crypto/SigTest.java | 2 +- .../p2p/seed/SeedNodeAddressLookupTest.java | 5 +-- .../p2p/seed/SeedNodeAddressesTest.java | 5 +-- .../trades/TradesChartsViewModelTest.java | 6 +--- .../preferences/PreferencesViewModelTest.java | 10 +----- .../validation/AccountNrValidatorTest.java | 1 - .../crypto/EncryptionServiceTests.java | 5 +-- .../p2p/network/LocalhostNetworkNodeTest.java | 10 +----- .../p2p/network/TorNetworkNodeTest.java | 10 +----- .../p2p/storage/P2PDataStorageTest.java | 5 +-- .../p2p/storage/ProtectedDataStorageTest.java | 5 +-- .../storage/messages/AddDataMessageTest.java | 5 +-- 21 files changed, 44 insertions(+), 106 deletions(-) diff --git a/common/src/main/java/bisq/common/crypto/Encryption.java b/common/src/main/java/bisq/common/crypto/Encryption.java index bfa3adf0203..a04ea2df34c 100644 --- a/common/src/main/java/bisq/common/crypto/Encryption.java +++ b/common/src/main/java/bisq/common/crypto/Encryption.java @@ -25,6 +25,8 @@ import javax.crypto.KeyGenerator; import javax.crypto.Mac; import javax.crypto.SecretKey; +import javax.crypto.spec.OAEPParameterSpec; +import javax.crypto.spec.PSource; import javax.crypto.spec.SecretKeySpec; import java.security.InvalidKeyException; @@ -36,6 +38,7 @@ import java.security.PrivateKey; import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; +import java.security.spec.MGF1ParameterSpec; import java.security.spec.X509EncodedKeySpec; import java.io.ByteArrayOutputStream; @@ -51,7 +54,7 @@ public class Encryption { private static final Logger log = LoggerFactory.getLogger(Encryption.class); public static final String ASYM_KEY_ALGO = "RSA"; - private static final String ASYM_CIPHER = "RSA/None/OAEPWithSHA256AndMGF1Padding"; + private static final String ASYM_CIPHER = "RSA/ECB/OAEPWithSHA-256AndMGF1PADDING"; private static final String SYM_KEY_ALGO = "AES"; private static final String SYM_CIPHER = "AES"; @@ -61,7 +64,7 @@ public class Encryption { public static KeyPair generateKeyPair() { long ts = System.currentTimeMillis(); try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO, "BC"); + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO); keyPairGenerator.initialize(2048); KeyPair keyPair = keyPairGenerator.genKeyPair(); log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts); @@ -80,7 +83,7 @@ public static KeyPair generateKeyPair() { public static byte[] encrypt(byte[] payload, SecretKey secretKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); + Cipher cipher = Cipher.getInstance(SYM_CIPHER); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher.doFinal(payload); } catch (Throwable e) { @@ -91,7 +94,7 @@ public static byte[] encrypt(byte[] payload, SecretKey secretKey) throws CryptoE public static byte[] decrypt(byte[] encryptedPayload, SecretKey secretKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); + Cipher cipher = Cipher.getInstance(SYM_CIPHER); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher.doFinal(encryptedPayload); } catch (Throwable e) { @@ -157,7 +160,7 @@ private static boolean verifyHmac(byte[] message, byte[] hmac, SecretKey secretK } private static byte[] getHmac(byte[] payload, SecretKey secretKey) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { - Mac mac = Mac.getInstance(HMAC, "BC"); + Mac mac = Mac.getInstance(HMAC); mac.init(secretKey); return mac.doFinal(payload); } @@ -195,8 +198,10 @@ public static byte[] decryptPayloadWithHmac(byte[] encryptedPayloadWithHmac, Sec public static byte[] encryptSecretKey(SecretKey secretKey, PublicKey publicKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); - cipher.init(Cipher.WRAP_MODE, publicKey); + Cipher cipher = Cipher.getInstance(ASYM_CIPHER); + OAEPParameterSpec oaepParameterSpec = new OAEPParameterSpec("SHA-256", "MGF1", + MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT); + cipher.init(Cipher.WRAP_MODE, publicKey, oaepParameterSpec); return cipher.wrap(secretKey); } catch (Throwable e) { e.printStackTrace(); @@ -206,8 +211,10 @@ public static byte[] encryptSecretKey(SecretKey secretKey, PublicKey publicKey) public static SecretKey decryptSecretKey(byte[] encryptedSecretKey, PrivateKey privateKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); - cipher.init(Cipher.UNWRAP_MODE, privateKey); + Cipher cipher = Cipher.getInstance(ASYM_CIPHER); + OAEPParameterSpec oaepParameterSpec = new OAEPParameterSpec("SHA-256", "MGF1", + MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT); + cipher.init(Cipher.UNWRAP_MODE, privateKey, oaepParameterSpec); return (SecretKey) cipher.unwrap(encryptedSecretKey, "AES", Cipher.SECRET_KEY); } catch (Throwable e) { // errors when trying to decrypt foreign network_messages are normal @@ -222,7 +229,7 @@ public static SecretKey decryptSecretKey(byte[] encryptedSecretKey, PrivateKey p public static SecretKey generateSecretKey(int bits) { try { - KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_KEY_ALGO, "BC"); + KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_KEY_ALGO); keyPairGenerator.init(bits); return keyPairGenerator.generateKey(); } catch (Throwable e) { @@ -242,8 +249,8 @@ public static byte[] getPublicKeyBytes(PublicKey encryptionPubKey) { */ public static PublicKey getPublicKeyFromBytes(byte[] encryptionPubKeyBytes) { try { - return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO, "BC").generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes)); - } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) { + return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO).generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes)); + } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(encryptionPubKeyBytes), e); e.printStackTrace(); throw new KeyConversionException(e); diff --git a/common/src/main/java/bisq/common/crypto/Hash.java b/common/src/main/java/bisq/common/crypto/Hash.java index 820d8a1aa62..078582266a9 100644 --- a/common/src/main/java/bisq/common/crypto/Hash.java +++ b/common/src/main/java/bisq/common/crypto/Hash.java @@ -25,7 +25,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.nio.ByteBuffer; @@ -40,10 +39,10 @@ public class Hash { */ public static byte[] getSha256Hash(byte[] data) { try { - MessageDigest digest = MessageDigest.getInstance("SHA-256", "BC"); + MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(data, 0, data.length); return digest.digest(); - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException e) { log.error("Could not create MessageDigest for hash. " + e.toString()); e.printStackTrace(); throw new RuntimeException(e); diff --git a/common/src/main/java/bisq/common/crypto/KeyStorage.java b/common/src/main/java/bisq/common/crypto/KeyStorage.java index 1320cf36ecb..1b1f00525da 100644 --- a/common/src/main/java/bisq/common/crypto/KeyStorage.java +++ b/common/src/main/java/bisq/common/crypto/KeyStorage.java @@ -28,7 +28,6 @@ import java.security.KeyFactory; import java.security.KeyPair; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.interfaces.DSAParams; @@ -121,7 +120,7 @@ public KeyPair loadKeyPair(KeyEntry keyEntry) { FileUtil.rollingBackup(storageDir, keyEntry.getFileName() + ".key", 20); // long now = System.currentTimeMillis(); try { - KeyFactory keyFactory = KeyFactory.getInstance(keyEntry.getAlgorithm(), "BC"); + KeyFactory keyFactory = KeyFactory.getInstance(keyEntry.getAlgorithm()); PublicKey publicKey; PrivateKey privateKey; @@ -158,7 +157,7 @@ public KeyPair loadKeyPair(KeyEntry keyEntry) { log.debug("load completed in {} msec", System.currentTimeMillis() - new Date().getTime()); return new KeyPair(publicKey, privateKey); - } catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { e.printStackTrace(); log.error(e.getMessage()); throw new RuntimeException("Could not load key " + keyEntry.toString(), e); diff --git a/common/src/main/java/bisq/common/crypto/Sig.java b/common/src/main/java/bisq/common/crypto/Sig.java index 6917bb9df0a..85e14838967 100644 --- a/common/src/main/java/bisq/common/crypto/Sig.java +++ b/common/src/main/java/bisq/common/crypto/Sig.java @@ -28,7 +28,6 @@ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Signature; @@ -60,12 +59,12 @@ public class Sig { public static KeyPair generateKeyPair() { long ts = System.currentTimeMillis(); try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO, "BC"); + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO); keyPairGenerator.initialize(1024); KeyPair keyPair = keyPairGenerator.genKeyPair(); log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts); return keyPair; - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException e) { e.printStackTrace(); log.error(e.toString()); throw new RuntimeException("Could not create key."); @@ -80,11 +79,11 @@ public static KeyPair generateKeyPair() { */ public static byte[] sign(PrivateKey privateKey, byte[] data) throws CryptoException { try { - Signature sig = Signature.getInstance(ALGO, "BC"); + Signature sig = Signature.getInstance(ALGO); sig.initSign(privateKey); sig.update(data); return sig.sign(); - } catch (SignatureException | NoSuchProviderException | InvalidKeyException | NoSuchAlgorithmException e) { + } catch (SignatureException | InvalidKeyException | NoSuchAlgorithmException e) { throw new CryptoException("Signing failed. " + e.getMessage()); } } @@ -107,11 +106,11 @@ public static String sign(PrivateKey privateKey, String message) throws CryptoEx */ public static boolean verify(PublicKey publicKey, byte[] data, byte[] signature) throws CryptoException { try { - Signature sig = Signature.getInstance(ALGO, "BC"); + Signature sig = Signature.getInstance(ALGO); sig.initVerify(publicKey); sig.update(data); return sig.verify(signature); - } catch (SignatureException | NoSuchProviderException | InvalidKeyException | NoSuchAlgorithmException e) { + } catch (SignatureException | InvalidKeyException | NoSuchAlgorithmException e) { throw new CryptoException("Signature verification failed. " + e.getMessage()); } } @@ -132,8 +131,8 @@ public static boolean verify(PublicKey publicKey, String message, String signatu */ public static PublicKey getPublicKeyFromBytes(byte[] sigPublicKeyBytes) { try { - return KeyFactory.getInstance(Sig.KEY_ALGO, "BC").generatePublic(new X509EncodedKeySpec(sigPublicKeyBytes)); - } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) { + return KeyFactory.getInstance(Sig.KEY_ALGO).generatePublic(new X509EncodedKeySpec(sigPublicKeyBytes)); + } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(sigPublicKeyBytes), e); e.printStackTrace(); throw new KeyConversionException(e); diff --git a/common/src/main/java/bisq/common/setup/CommonSetup.java b/common/src/main/java/bisq/common/setup/CommonSetup.java index 6e934cdd54e..c170c194c6e 100644 --- a/common/src/main/java/bisq/common/setup/CommonSetup.java +++ b/common/src/main/java/bisq/common/setup/CommonSetup.java @@ -25,10 +25,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.NoSuchAlgorithmException; -import java.security.Security; import lombok.extern.slf4j.Slf4j; @@ -38,8 +35,6 @@ public class CommonSetup { public static void setup(UncaughtExceptionHandler uncaughtExceptionHandler) { setupErrorHandler(uncaughtExceptionHandler); - Security.addProvider(new BouncyCastleProvider()); - if (Utilities.isLinux()) System.setProperty("prism.lcdtext", "false"); } diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 12dd7750788..1fbb63757d2 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -444,9 +444,6 @@ private void checkCryptoSetup() { ((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() && ((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) { log.debug("Crypto test succeeded"); - - if (Security.getProvider("BC") == null) - throw new CryptoException("Security provider BountyCastle is not available."); } else { throw new CryptoException("Payload not correct after decryption"); } diff --git a/core/src/main/java/bisq/core/app/SetupUtils.java b/core/src/main/java/bisq/core/app/SetupUtils.java index 779228bc82b..9bb28c553b1 100644 --- a/core/src/main/java/bisq/core/app/SetupUtils.java +++ b/core/src/main/java/bisq/core/app/SetupUtils.java @@ -34,8 +34,6 @@ import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; -import java.security.Security; - import java.util.Date; import java.util.function.Consumer; @@ -67,12 +65,6 @@ public void run() { ((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() && ((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) { log.debug("Crypto test succeeded"); - - if (Security.getProvider("BC") != null) { - UserThread.execute(resultHandler::handleResult); - } else { - errorHandler.accept(new CryptoException("Security provider BountyCastle is not available.")); - } } else { errorHandler.accept(new CryptoException("Payload not correct after decryption")); } diff --git a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java index 69a6bd77c05..a5ae6a713fc 100644 --- a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java +++ b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java @@ -47,10 +47,7 @@ @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class ArbitratorManagerTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testIsArbitratorAvailableForLanguage() { diff --git a/core/src/test/java/bisq/core/crypto/EncryptionTest.java b/core/src/test/java/bisq/core/crypto/EncryptionTest.java index 42859aca124..e06ef082754 100644 --- a/core/src/test/java/bisq/core/crypto/EncryptionTest.java +++ b/core/src/test/java/bisq/core/crypto/EncryptionTest.java @@ -45,7 +45,7 @@ public class EncryptionTest { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/core/src/test/java/bisq/core/crypto/SigTest.java b/core/src/test/java/bisq/core/crypto/SigTest.java index 349987f7469..a66e0b72f23 100644 --- a/core/src/test/java/bisq/core/crypto/SigTest.java +++ b/core/src/test/java/bisq/core/crypto/SigTest.java @@ -51,7 +51,7 @@ public class SigTest { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java index ca76150f594..8f63daefd82 100644 --- a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java +++ b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java @@ -36,10 +36,7 @@ import static org.mockito.Mockito.mock; public class SeedNodeAddressLookupTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testResolveNodeAddressesWhenLocalAddressSpecified() { diff --git a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java index 580c3393e11..b036f98faff 100644 --- a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java +++ b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java @@ -37,10 +37,7 @@ import static org.junit.Assert.assertTrue; public class SeedNodeAddressesTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testCollector() { diff --git a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java index 9bd5d1bc7e1..1b5e40005a4 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java @@ -38,10 +38,6 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableSet; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -128,7 +124,7 @@ public class TradesChartsViewModelTest { @Before public void setup() throws IOException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java index cd07a7adda7..42b368b1456 100644 --- a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java @@ -27,17 +27,12 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableMap; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.util.ArrayList; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -50,10 +45,7 @@ @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class PreferencesViewModelTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testGetArbitrationLanguages() { diff --git a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java index 75047bec165..4584d98cd0c 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java @@ -7,7 +7,6 @@ import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class AccountNrValidatorTest { diff --git a/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java b/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java index c3f92564ac2..dc7bf583832 100644 --- a/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java +++ b/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java @@ -26,11 +26,8 @@ import io.bisq.generated.protobuffer.PB; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.cert.CertificateException; import java.io.File; @@ -56,7 +53,7 @@ public class EncryptionServiceTests { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java b/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java index 1ec4f8b8c11..1a09281e0d6 100644 --- a/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java +++ b/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java @@ -19,10 +19,6 @@ import bisq.network.p2p.TestUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.io.IOException; import java.util.concurrent.CountDownLatch; @@ -30,7 +26,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -43,10 +38,7 @@ public class LocalhostNetworkNodeTest { private static final Logger log = LoggerFactory.getLogger(LocalhostNetworkNodeTest.class); - @Before - public void setup() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test diff --git a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java index bc4654d424d..2245a3ebd99 100644 --- a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java +++ b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java @@ -24,10 +24,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.io.File; import java.io.IOException; @@ -38,7 +34,6 @@ import org.jetbrains.annotations.NotNull; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -52,10 +47,7 @@ public class TorNetworkNodeTest { private static final Logger log = LoggerFactory.getLogger(TorNetworkNodeTest.class); private CountDownLatch latch; - @Before - public void setup() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testTorNodeBeforeSecondReady() throws InterruptedException, IOException { diff --git a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java index 06d70e8a3d6..b8cd84bea77 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java @@ -31,13 +31,10 @@ import bisq.common.proto.persistable.PersistenceProtoResolver; import bisq.common.storage.FileUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -84,7 +81,7 @@ public class P2PDataStorageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir1.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java index 3b01880ce5e..3a1bb64107a 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java @@ -34,14 +34,11 @@ import bisq.common.crypto.Sig; import bisq.common.storage.FileUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -84,7 +81,7 @@ public class ProtectedDataStorageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored,ResultOfMethodCallIgnored dir1.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java index 4c79f85682b..fd49b153ee5 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java @@ -32,12 +32,9 @@ import org.apache.commons.lang3.RandomUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -60,7 +57,7 @@ public class AddDataMessageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir1.delete(); From 68fb1163a37c2465224a3e396034476b1ee5cdce Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 17 Sep 2018 13:37:03 +0200 Subject: [PATCH 15/19] Add Java 10 configuration for merged repositories --- monitor/build.gradle | 6 +++--- pricenode/build.gradle | 4 ++-- relay/build.gradle | 8 ++++---- seednode/build.gradle | 6 +++--- statsnode/build.gradle | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/monitor/build.gradle b/monitor/build.gradle index b00b4f7b431..a4ac1b14d24 100644 --- a/monitor/build.gradle +++ b/monitor/build.gradle @@ -6,7 +6,7 @@ plugins { group = 'network.bisq' version = '0.8.0-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 mainClassName = 'bisq.monitor.MonitorMain' @@ -20,8 +20,8 @@ dependencies { compile project(':core') compile 'com.sparkjava:spark-core:2.5.2' compile 'net.gpedro.integrations.slack:slack-webhook:1.1.1' - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' } build.dependsOn installDist diff --git a/pricenode/build.gradle b/pricenode/build.gradle index c39959467cc..46912983bfd 100644 --- a/pricenode/build.gradle +++ b/pricenode/build.gradle @@ -3,8 +3,8 @@ plugins { id "org.springframework.boot" version "1.5.10.RELEASE" } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 1.10 +targetCompatibility = 1.10 version = file("src/main/resources/version.txt").text diff --git a/relay/build.gradle b/relay/build.gradle index 9006d27cba8..4893a113c87 100644 --- a/relay/build.gradle +++ b/relay/build.gradle @@ -3,8 +3,8 @@ plugins { id "org.springframework.boot" version "1.5.10.RELEASE" } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +sourceCompatibility = 1.10 +targetCompatibility = 1.10 version = file("src/main/resources/version.txt").text @@ -27,8 +27,8 @@ dependencies { compile("com.turo:pushy:0.13.2") compile("com.google.firebase:firebase-admin:6.2.0") - compileOnly 'org.projectlombok:lombok:1.16.16' - //annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + //annotationProcessor 'org.projectlombok:lombok:1.18.2' } task stage { diff --git a/seednode/build.gradle b/seednode/build.gradle index 9e054eb4da8..e7e597687fe 100644 --- a/seednode/build.gradle +++ b/seednode/build.gradle @@ -15,7 +15,7 @@ apply plugin: 'com.github.johnrengelman.shadow' group = 'network.bisq' version = '0.8.0-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 mainClassName = 'bisq.seednode.SeedNodeMain' @@ -30,8 +30,8 @@ repositories { dependencies { compile project(':core') runtime 'org.bouncycastle:bcprov-jdk15on:1.56' - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' } build.dependsOn installDist diff --git a/statsnode/build.gradle b/statsnode/build.gradle index 32d0e2786bf..7a3264f13f5 100644 --- a/statsnode/build.gradle +++ b/statsnode/build.gradle @@ -6,7 +6,7 @@ plugins { group = 'network.bisq' version = '0.8.0-SNAPSHOT' -sourceCompatibility = 1.8 +sourceCompatibility = 1.10 mainClassName = 'bisq.statistics.StatisticsMain' @@ -18,8 +18,8 @@ repositories { dependencies { compile project(':core') - compileOnly 'org.projectlombok:lombok:1.16.16' - annotationProcessor 'org.projectlombok:lombok:1.16.16' + compileOnly 'org.projectlombok:lombok:1.18.2' + annotationProcessor 'org.projectlombok:lombok:1.18.2' } build.dependsOn installDist From a8dd11c8d2f1543cc12671b4e2d28ee4b09a6c23 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 18 Sep 2018 13:54:20 +0200 Subject: [PATCH 16/19] Add workaround to prevent javapackager to fail because of module configuration of fontawesomefx library --- desktop/package/osx/create_app.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/desktop/package/osx/create_app.sh b/desktop/package/osx/create_app.sh index 25c3e0b537b..3bd54c848c8 100755 --- a/desktop/package/osx/create_app.sh +++ b/desktop/package/osx/create_app.sh @@ -14,6 +14,17 @@ cd desktop EXE_JAR=build/libs/desktop-$version-all.jar +# we need to strip out Java 9 module configuration used in the fontawesomefx library as it causes the javapackager to stop, +# because of this existing module information, although it is not used as a module. +echo Unzipping jar to delete module config +tmp=build/libs/tmp +unzip -o -q $EXE_JAR -d $tmp +rm $tmp/module-info.class +rm $EXE_JAR +echo Zipping jar again without module config +cd $tmp; zip -r -q -X "../desktop-$version-all.jar" * +cd ../../../; rm -rf $tmp + echo SHA 256 before stripping jar file: shasum -a256 $EXE_JAR | awk '{print $1}' From f7e4e5ae147da2a568b5abee17b8123b25cacd6a Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 18 Sep 2018 20:29:10 +0200 Subject: [PATCH 17/19] Add missing result handler execution --- core/src/main/java/bisq/core/app/SetupUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/main/java/bisq/core/app/SetupUtils.java b/core/src/main/java/bisq/core/app/SetupUtils.java index 9bb28c553b1..c7cf8cafa3c 100644 --- a/core/src/main/java/bisq/core/app/SetupUtils.java +++ b/core/src/main/java/bisq/core/app/SetupUtils.java @@ -65,6 +65,8 @@ public void run() { ((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() && ((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) { log.debug("Crypto test succeeded"); + + UserThread.execute(resultHandler::handleResult); } else { errorHandler.accept(new CryptoException("Payload not correct after decryption")); } From 064335716ad8d34b04f8aff6e21831d09f2a5b81 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 18 Sep 2018 20:38:18 +0200 Subject: [PATCH 18/19] Clear list before setting all currencies --- desktop/src/main/java/bisq/desktop/util/CurrencyList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/desktop/src/main/java/bisq/desktop/util/CurrencyList.java b/desktop/src/main/java/bisq/desktop/util/CurrencyList.java index 209cd0cda4b..b8f193a7638 100644 --- a/desktop/src/main/java/bisq/desktop/util/CurrencyList.java +++ b/desktop/src/main/java/bisq/desktop/util/CurrencyList.java @@ -60,6 +60,7 @@ public void updateWithCurrencies(List currencies, @Nullable Curre List result = Lists.newLinkedList(); Optional.ofNullable(first).ifPresent(result::add); result.addAll(getPartitionedSortedItems(currencies)); + delegate.clear(); delegate.addAll(result); } From db179914ada88a8e5378e28351ab77d510caa8c3 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Tue, 18 Sep 2018 20:50:01 +0200 Subject: [PATCH 19/19] Remove not thrown exceptions --- core/src/test/java/bisq/core/crypto/SigTest.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/core/src/test/java/bisq/core/crypto/SigTest.java b/core/src/test/java/bisq/core/crypto/SigTest.java index a66e0b72f23..5be2dcb61b1 100644 --- a/core/src/test/java/bisq/core/crypto/SigTest.java +++ b/core/src/test/java/bisq/core/crypto/SigTest.java @@ -23,13 +23,6 @@ import bisq.common.crypto.Sig; import bisq.common.storage.FileUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.Security; -import java.security.cert.CertificateException; - import java.io.File; import java.io.IOException; @@ -50,7 +43,7 @@ public class SigTest { private File dir; @Before - public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { + public void setup() throws IOException { dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored