Apply code inspection

This commit is contained in:
Manfred Karrer 2016-02-17 18:12:49 +01:00
parent 17c780639f
commit 60a027e00d
45 changed files with 176 additions and 132 deletions

View file

@ -7,7 +7,7 @@ new blue: 0f87c3
new grey: 666666
00abff
orange webpage quotes : ff7f00
orange web page quotes : ff7f00
main bg grey: dddddd
@ -679,7 +679,7 @@ textfield */
}
/* copied form modena.css text-input */
#flowpane-checkboxes-bg {
#flow-pane-checkboxes-bg {
-fx-text-fill: -fx-text-inner-color;
-fx-highlight-fill: derive(-fx-control-inner-background, -20%);
-fx-highlight-text-fill: -fx-text-inner-color;
@ -691,7 +691,7 @@ textfield */
-fx-padding: 0.333333em 0.583em 0.333333em 0.583em; /* 4 7 4 7 */
}
#flowpane-checkboxes-non-editable-bg {
#flow-pane-checkboxes-non-editable-bg {
-fx-text-fill: -fx-text-inner-color;
-fx-highlight-fill: derive(-fx-control-inner-background, -20%);
-fx-highlight-text-fill: -fx-text-inner-color;

View file

@ -0,0 +1,33 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare 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.
*
* Bitsquare 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.common;
import static java.lang.String.format;
public class ViewFxException1 extends RuntimeException {
private static final long serialVersionUID = -6266047448442595372L;
public ViewFxException1(Throwable cause, String format, Object... args) {
super(format(format, args), cause);
}
public ViewFxException1(String format, Object... args) {
super(format(format, args));
}
}

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.common.fxml;
import io.bitsquare.gui.common.ViewfxException;
import io.bitsquare.gui.common.ViewFxException;
import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.common.view.View;
import io.bitsquare.gui.common.view.ViewFactory;
@ -76,13 +76,13 @@ public class FxmlViewLoader implements ViewLoader {
URL fxmlUrl = viewClass.getClassLoader().getResource(resolvedLocation);
if (fxmlUrl == null)
throw new ViewfxException(
throw new ViewFxException(
"Failed to load view class [%s] because FXML file at [%s] could not be loaded " +
"as a classpath resource. Does it exist?", viewClass, specifiedLocation);
return loadFromFxml(fxmlUrl);
} catch (InstantiationException | IllegalAccessException ex) {
throw new ViewfxException(ex, "Failed to load view from class %s", viewClass);
throw new ViewFxException(ex, "Failed to load view from class %s", viewClass);
}
}
@ -94,14 +94,14 @@ public class FxmlViewLoader implements ViewLoader {
loader.load();
Object controller = loader.getController();
if (controller == null)
throw new ViewfxException("Failed to load view from FXML file at [%s]. " +
throw new ViewFxException("Failed to load view from FXML file at [%s]. " +
"Does it declare an fx:controller attribute?", fxmlUrl);
if (!(controller instanceof View))
throw new ViewfxException("Controller of type [%s] loaded from FXML file at [%s] " +
throw new ViewFxException("Controller of type [%s] loaded from FXML file at [%s] " +
"does not implement [%s] as expected.", controller.getClass(), fxmlUrl, View.class);
return (View) controller;
} catch (IOException ex) {
throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl);
throw new ViewFxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl);
}
}

View file

@ -24,7 +24,7 @@ public interface Activatable {
void _deactivate();
Activatable NOOP_INSTANCE = new Activatable() {
Activatable NO_OP_INSTANCE = new Activatable() {
@Override
public void _activate() {
}

View file

@ -29,7 +29,7 @@ public abstract class ActivatableViewAndModel<R extends Node, M extends Activata
}
public ActivatableViewAndModel() {
this((M) Activatable.NOOP_INSTANCE);
this((M) Activatable.NO_OP_INSTANCE);
}
@Override

View file

@ -126,7 +126,7 @@ public class InfoDisplay extends Parent {
sceneProperty().addListener((ov, oldValue, newValue) -> {
if (oldValue == null && newValue != null && newValue.getWindow() != null) {
newValue.getWindow().widthProperty().addListener(listener);
// localToScene does deliver 0 instead of the correct x position when scene propery gets set,
// localToScene does deliver 0 instead of the correct x position when scene property gets set,
// so we delay for 1 render cycle
UserThread.execute(() -> {
label.setVisible(true);

View file

@ -64,7 +64,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
/**
* ************************************************************************
* *
* UI Subcomponents *
* UI SubComponents *
* *
* ************************************************************************
*/
@ -173,7 +173,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
return StyleableProperties.PROGRESS_COLOR;
}
};
private boolean timelineNulled = false;
private boolean timeLineNulled = false;
/**
* ************************************************************************
@ -192,8 +192,8 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
InvalidationListener visibilityListener = new InvalidationListener() {
@Override
public void invalidated(Observable valueModel) {
if (getSkinnable().isIndeterminate() && timelineNulled && spinner == null) {
timelineNulled = false;
if (getSkinnable().isIndeterminate() && timeLineNulled && spinner == null) {
timeLineNulled = false;
spinner = new IndeterminateSpinner(
getSkinnable(), ConfidenceProgressIndicatorSkin.this,
spinEnabled.get(), progressColor.get());
@ -204,7 +204,7 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (!(getSkinnable().impl_isTreeVisible() && getSkinnable().getScene() != null)) {
getChildren().remove(spinner);
spinner = null;
timelineNulled = true;
timeLineNulled = true;
}
}
}
@ -219,11 +219,11 @@ public class ConfidenceProgressIndicatorSkin extends BehaviorSkinBase<Confidence
if (getSkinnable().getScene() == null) {
getChildren().remove(spinner);
spinner = null;
timelineNulled = true;
timeLineNulled = true;
}
} else {
if (getSkinnable().getScene() != null && getSkinnable().isIndeterminate()) {
timelineNulled = false;
timeLineNulled = false;
spinner = new IndeterminateSpinner(
getSkinnable(), ConfidenceProgressIndicatorSkin.this,
spinEnabled.get(), progressColor.get());

View file

@ -50,8 +50,7 @@ public class BlockChainForm extends PaymentMethodForm {
public static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Cryptocurrency address:", ((BlockChainAccountContractData) paymentAccountContractData).getAddress());
if (paymentAccountContractData instanceof BlockChainAccountContractData &&
((BlockChainAccountContractData) paymentAccountContractData).getPaymentId() != null)
if (((BlockChainAccountContractData) paymentAccountContractData).getPaymentId() != null)
addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, "Payment ID:", ((BlockChainAccountContractData) paymentAccountContractData).getPaymentId());
return gridRow;

View file

@ -84,9 +84,9 @@ public class OKPayForm extends PaymentMethodForm {
flowPane.setHgap(10);
if (isEditable)
flowPane.setId("flowpane-checkboxes-bg");
flowPane.setId("flow-pane-checkboxes-bg");
else
flowPane.setId("flowpane-checkboxes-non-editable-bg");
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
CurrencyUtil.getAllOKPayCurrencies().stream().forEach(e ->
{

View file

@ -164,9 +164,9 @@ public class SepaForm extends PaymentMethodForm {
flowPane.setHgap(10);
if (isEditable)
flowPane.setId("flowpane-checkboxes-bg");
flowPane.setId("flow-pane-checkboxes-bg");
else
flowPane.setId("flowpane-checkboxes-non-editable-bg");
flowPane.setId("flow-pane-checkboxes-non-editable-bg");
dataProvider.stream().forEach(country ->
{
@ -255,7 +255,8 @@ public class SepaForm extends PaymentMethodForm {
ibanField.setMouseTransparent(false);
TextField bicField = addLabelTextField(gridPane, ++gridRow, "BIC/SWIFT:", sepaAccount.getBic()).second;
bicField.setMouseTransparent(false);
addLabelTextField(gridPane, ++gridRow, "Location of Bank:", sepaAccount.getCountry().name);
addLabelTextField(gridPane, ++gridRow, "Location of Bank:",
sepaAccount.getCountry() != null ? sepaAccount.getCountry().name : "");
addLabelTextField(gridPane, ++gridRow, "Currency:", sepaAccount.getSingleTradeCurrency().getNameAndCode());
String countries;
Tooltip tooltip = null;

View file

@ -154,6 +154,7 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
}
public void open() {
//noinspection SuspiciousNameCombination,SuspiciousNameCombination
BorderStroke borderStroke = new BorderStroke(Colors.LIGHT_GREY, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke));
@ -161,6 +162,7 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
}
public void current() {
//noinspection SuspiciousNameCombination,SuspiciousNameCombination
BorderStroke borderStroke = new BorderStroke(Colors.GREEN, BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke));
@ -168,6 +170,7 @@ class ProcessStepBarSkin<T> extends BehaviorSkinBase<ProcessStepBar<T>, Behavior
}
public void past() {
//noinspection SuspiciousNameCombination,SuspiciousNameCombination
BorderStroke borderStroke = new BorderStroke(Color.valueOf("#444444"), BorderStrokeStyle.SOLID, null,
new BorderWidths(borderWidth, borderWidth, borderWidth, borderWidth), Insets.EMPTY);
this.setBorder(new Border(borderStroke));

View file

@ -464,13 +464,11 @@ public class MainView extends InitializableView<StackPane, MainViewModel> {
p2PNetworkIcon.setOpacity(1);
});
AnchorPane footerContainer = new AnchorPane(separator, blockchainSyncBox, versionLabel, p2PNetworkLabel, p2PNetworkIcon) {{
return new AnchorPane(separator, blockchainSyncBox, versionLabel, p2PNetworkLabel, p2PNetworkIcon) {{
setId("footer-pane");
setMinHeight(30);
setMaxHeight(30);
}};
return footerContainer;
}
private void setupNotificationIcon(Pane buttonHolder) {

View file

@ -91,9 +91,9 @@ public class MainViewModel implements ViewModel {
private final Preferences preferences;
private final AlertManager alertManager;
private final WalletPasswordPopup walletPasswordPopup;
private NotificationCenter notificationCenter;
private TacPopup tacPopup;
private Navigation navigation;
private final NotificationCenter notificationCenter;
private final TacPopup tacPopup;
private final Navigation navigation;
private final BSFormatter formatter;
// BTC network
@ -129,13 +129,13 @@ public class MainViewModel implements ViewModel {
final StringProperty p2PNetworkLabelId = new SimpleStringProperty("footer-pane");
private MonadicBinding<Boolean> allServicesDone, tradesAndUIReady;
private MarketPriceFeed marketPriceFeed;
private final MarketPriceFeed marketPriceFeed;
private final User user;
private int numBTCPeers = 0;
private Timer checkForBtcSyncStateTimer;
private ChangeListener<Number> numConnectedPeersListener, btcNumPeersListener;
private java.util.Timer numberofBtcPeersTimer;
private java.util.Timer numberofP2PNetworkPeersTimer;
private java.util.Timer numberOfBtcPeersTimer;
private java.util.Timer numberOfP2PNetworkPeersTimer;
private Timer startupTimeout;
private final Map<String, Subscription> disputeIsClosedSubscriptionsMap = new HashMap<>();
@ -325,9 +325,9 @@ public class MainViewModel implements ViewModel {
btcNumPeersListener = (observable, oldValue, newValue) -> {
if ((int) oldValue > 0 && (int) newValue == 0) {
// give a bit of tolerance
if (numberofBtcPeersTimer != null)
numberofBtcPeersTimer.cancel();
numberofBtcPeersTimer = UserThread.runAfter(() -> {
if (numberOfBtcPeersTimer != null)
numberOfBtcPeersTimer.cancel();
numberOfBtcPeersTimer = UserThread.runAfter(() -> {
if (walletService.numPeersProperty().get() == 0) {
walletServiceErrorMsg.set("You lost the connection to all bitcoin network peers.\n" +
"Maybe you lost your internet connection or your computer was in hibernate/sleep mode.");
@ -517,9 +517,9 @@ public class MainViewModel implements ViewModel {
numConnectedPeersListener = (observable, oldValue, newValue) -> {
if ((int) oldValue > 0 && (int) newValue == 0) {
// give a bit of tolerance
if (numberofP2PNetworkPeersTimer != null)
numberofP2PNetworkPeersTimer.cancel();
numberofP2PNetworkPeersTimer = UserThread.runAfter(() -> {
if (numberOfP2PNetworkPeersTimer != null)
numberOfP2PNetworkPeersTimer.cancel();
numberOfP2PNetworkPeersTimer = UserThread.runAfter(() -> {
if (p2PService.getNumConnectedPeers().get() == 0) {
p2PNetworkWarnMsg.set("You lost the connection to all P2P network peers.\n" +
"Maybe you lost your internet connection or your computer was in hibernate/sleep mode.");

View file

@ -79,7 +79,7 @@ class ArbitratorRegistrationViewModel extends ActivatableViewModel {
Arbitrator myRegisteredArbitrator = user.getRegisteredArbitrator();
myArbitratorProperty.set(myRegisteredArbitrator);
// We don't reset the languages in case of revokation, as its likely that the arbitrator will use the same again when he re-activate
// We don't reset the languages in case of revocation, as its likely that the arbitrator will use the same again when he re-activate
// registration later
if (myRegisteredArbitrator != null)
languageCodes.setAll(myRegisteredArbitrator.getLanguageCodes());

View file

@ -130,8 +130,12 @@ public class SeedWordsView extends ActivatableView<GridPane, Void> {
Wallet wallet = walletService.getWallet();
KeyCrypter keyCrypter = wallet.getKeyCrypter();
keyChainSeed = wallet.getKeyChainSeed();
DeterministicSeed decryptedSeed = keyChainSeed.decrypt(keyCrypter, "", aesKey);
showSeedScreen(decryptedSeed);
if (keyCrypter != null) {
DeterministicSeed decryptedSeed = keyChainSeed.decrypt(keyCrypter, "", aesKey);
showSeedScreen(decryptedSeed);
} else {
log.warn("keyCrypter is null");
}
}).show();
}

View file

@ -56,7 +56,7 @@ public class AccountSettingsView extends ActivatableViewAndModel {
@FXML
private AnchorPane content;
private Class<? extends View> selecteedViewClass;
private Class<? extends View> selectedViewClass;
@Inject
private AccountSettingsView(CachingViewLoader viewLoader, Navigation navigation) {
@ -97,8 +97,8 @@ public class AccountSettingsView extends ActivatableViewAndModel {
viewPath.size() == 2 && viewPath.indexOf(AccountView.class) == 1) {
navigation.navigateTo(MainView.class, AccountView.class, AccountSettingsView.class, PaymentAccountView.class);
} else if (viewPath.size() == 4 && viewPath.indexOf(AccountSettingsView.class) == 2) {
selecteedViewClass = viewPath.get(3);
loadView(selecteedViewClass);
selectedViewClass = viewPath.get(3);
loadView(selectedViewClass);
}
}
@ -125,7 +125,7 @@ public class AccountSettingsView extends ActivatableViewAndModel {
}
public Class<? extends View> getSelectedViewClass() {
return selecteedViewClass;
return selectedViewClass;
}
}
@ -135,8 +135,8 @@ class MenuItem extends ToggleButton {
private final ChangeListener<Boolean> selectedPropertyChangeListener;
private final ChangeListener<Boolean> disablePropertyChangeListener;
private Navigation navigation;
private Class<? extends View> viewClass;
private final Navigation navigation;
private final Class<? extends View> viewClass;
MenuItem(Navigation navigation, ToggleGroup toggleGroup, String title, Class<? extends View> viewClass, AwesomeIcon awesomeIcon) {
this.navigation = navigation;

View file

@ -65,7 +65,7 @@ public class DebugView extends InitializableView {
OfferAvailabilityProtocol.class,
SendOfferAvailabilityRequest.class,
ProcessOfferAvailabilityResponse.class,
Boolean.class, /* used as seperator*/
Boolean.class, /* used as separator*/
/*---- Protocol ----*/
@ -74,7 +74,7 @@ public class DebugView extends InitializableView {
CreateOfferFeeTx.class,
AddOfferToRemoteOfferBook.class,
BroadcastCreateOfferFeeTx.class,
Boolean.class, /* used as seperator*/
Boolean.class, /* used as separator*/
/*---- Protocol ----*/
@ -98,7 +98,7 @@ public class DebugView extends InitializableView {
SignAndFinalizePayoutTx.class,
SendPayoutTxFinalizedMessage.class,
BroadcastAfterLockTime.class,
Boolean.class, /* used as seperator*/
Boolean.class, /* used as separator*/
/*---- Protocol ----*/
@ -123,7 +123,7 @@ public class DebugView extends InitializableView {
ProcessPayoutTxFinalizedMessage.class,
BroadcastAfterLockTime.class,
Boolean.class /* used as seperator*/
Boolean.class /* used as separator*/
)
);
final ObservableList<Class> items2 = FXCollections.observableArrayList(Arrays.asList(
@ -149,7 +149,7 @@ public class DebugView extends InitializableView {
SignAndFinalizePayoutTx.class,
SendPayoutTxFinalizedMessage.class,
BroadcastAfterLockTime.class,
Boolean.class, /* used as seperator*/
Boolean.class, /* used as separator*/
/*---- Protocol ----*/
@ -173,7 +173,7 @@ public class DebugView extends InitializableView {
ProcessPayoutTxFinalizedMessage.class,
BroadcastAfterLockTime.class,
Boolean.class /* used as seperator*/
Boolean.class /* used as separator*/
)
);

View file

@ -26,6 +26,6 @@
AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml">
<Tab fx:id="tradersDisputesTab" text="Support tickets" closable="false"></Tab>
<Tab fx:id="tradersDisputesTab" text="Support tickets" closable="false"/>
</TabPane>

View file

@ -228,7 +228,8 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
hideSendMsgInfo(timer);
}
};
disputeDirectMessage.arrivedProperty().addListener(arrivedPropertyListener);
if (disputeDirectMessage.arrivedProperty() != null)
disputeDirectMessage.arrivedProperty().addListener(arrivedPropertyListener);
storedInMailboxPropertyListener = (observable, oldValue, newValue) -> {
if (newValue) {
sendMsgInfoLabel.setVisible(true);

View file

@ -24,7 +24,7 @@
AnchorPane.topAnchor="0.0"
xmlns:fx="http://javafx.com/fxml">
<Tab fx:id="reservedTab" text="Reserved/Locked funds" closable="false"></Tab>
<Tab fx:id="reservedTab" text="Reserved/Locked funds" closable="false"/>
<Tab fx:id="withdrawalTab" text="Available for withdrawal" closable="false"/>
<Tab fx:id="transactionsTab" text="Transactions" closable="false"/>

View file

@ -55,7 +55,7 @@ public class MarketsChartsView extends ActivatableViewAndModel<VBox, MarketsChar
private NumberAxis xAxis, yAxis;
XYChart.Series seriesBuy, seriesSell;
private final ListChangeListener<OfferBookListItem> changeListener;
private Navigation navigation;
private final Navigation navigation;
private final BSFormatter formatter;
private TableView<Offer> buyOfferTableView;
private TableView<Offer> sellOfferTableView;

View file

@ -42,7 +42,7 @@ class MarketsChartsViewModel extends ActivatableViewModel {
private final OfferBook offerBook;
private final Preferences preferences;
private MarketPriceFeed marketPriceFeed;
private final MarketPriceFeed marketPriceFeed;
final ObjectProperty<TradeCurrency> tradeCurrency = new SimpleObjectProperty<>(CurrencyUtil.getDefaultTradeCurrency());
private final List<XYChart.Data> buyData = new ArrayList();

View file

@ -48,10 +48,10 @@ public class NotificationCenter {
// Instance fields
///////////////////////////////////////////////////////////////////////////////////////////
private TradeManager tradeManager;
private DisputeManager disputeManager;
private Preferences preferences;
private Navigation navigation;
private final TradeManager tradeManager;
private final DisputeManager disputeManager;
private final Preferences preferences;
private final Navigation navigation;
private final Map<String, Subscription> disputeStateSubscriptionsMap = new HashMap<>();
private final Map<String, Subscription> tradeStateSubscriptionsMap = new HashMap<>();
@ -126,6 +126,7 @@ public class NotificationCenter {
// Setter/Getter
///////////////////////////////////////////////////////////////////////////////////////////
@org.jetbrains.annotations.Nullable
public String getSelectedTradeId() {
return selectedTradeId;
}

View file

@ -52,7 +52,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
private final ViewLoader viewLoader;
private final Navigation navigation;
private MarketPriceFeed marketPriceFeed;
private final MarketPriceFeed marketPriceFeed;
private final Offer.Direction direction;
private Tab takeOfferTab, createOfferTab, offerBookTab;
private TradeCurrency tradeCurrency;
@ -94,7 +94,7 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
}
}
};
tabListChangeListener = (ListChangeListener<Tab>) change -> {
tabListChangeListener = change -> {
change.next();
List<? extends Tab> removedTabs = change.getRemoved();
if (removedTabs.size() == 1) {

View file

@ -70,9 +70,9 @@ class CreateOfferDataModel extends ActivatableDataModel {
private final User user;
private final KeyRing keyRing;
private final P2PService p2PService;
private MarketPriceFeed marketPriceFeed;
private final MarketPriceFeed marketPriceFeed;
private final WalletPasswordPopup walletPasswordPopup;
private BlockchainService blockchainService;
private final BlockchainService blockchainService;
private final BSFormatter formatter;
private final String offerId;
private final AddressEntry addressEntry;

View file

@ -110,7 +110,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
private EventHandler<ActionEvent> currencyComboBoxSelectionHandler;
private int gridRow = 0;
private Preferences preferences;
private final Preferences preferences;
///////////////////////////////////////////////////////////////////////////////////////////
@ -213,7 +213,7 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
private void onPlaceOffer() {
if (model.isBootstrapped()) {
Offer offer = model.createAndGetOffer();
String id = "CreatOfferConfirmation";
String id = "CreateOfferConfirmation";
if (preferences.showAgain(id)) {
offerDetailsPopup.onPlaceOffer(model::onPlaceOffer)
.dontShowAgainId(id)

View file

@ -118,7 +118,7 @@ class CreateOfferViewModel extends ActivatableWithDataModel<CreateOfferDataModel
paymentLabel = BSResources.get("createOffer.fundsBox.paymentLabel", dataModel.getOfferId());
if (dataModel.getAddressEntry() != null) {
addressAsString = dataModel.getAddressEntry().getAddress().toString();
addressAsString = dataModel.getAddressEntry().getAddressString();
address.set(dataModel.getAddressEntry().getAddress());
}
createListeners();

View file

@ -53,7 +53,7 @@ class OfferBookViewModel extends ActivatableViewModel {
private final OfferBook offerBook;
private final Preferences preferences;
private final P2PService p2PService;
private MarketPriceFeed marketPriceFeed;
private final MarketPriceFeed marketPriceFeed;
final BSFormatter formatter;
private final FilteredList<OfferBookListItem> filteredItems;
@ -168,8 +168,7 @@ class OfferBookViewModel extends ActivatableViewModel {
}
public ObservableList<TradeCurrency> getTradeCurrencies() {
ObservableList<TradeCurrency> list = preferences.getTradeCurrenciesAsObservable();
return list;
return preferences.getTradeCurrenciesAsObservable();
}
boolean isBootstrapped() {

View file

@ -68,9 +68,9 @@ class TakeOfferDataModel extends ActivatableDataModel {
private final User user;
private final WalletPasswordPopup walletPasswordPopup;
private final Preferences preferences;
private MarketPriceFeed marketPriceFeed;
private BlockchainService blockchainService;
private BSFormatter formatter;
private final MarketPriceFeed marketPriceFeed;
private final BlockchainService blockchainService;
private final BSFormatter formatter;
private final Coin offerFeeAsCoin;
private final Coin networkFeeAsCoin;
@ -305,7 +305,6 @@ class TakeOfferDataModel extends ActivatableDataModel {
void calculateVolume() {
if (offer != null &&
offer.getPrice() != null &&
amountAsCoin.get() != null &&
!amountAsCoin.get().isZero()) {
volumeAsFiat.set(new ExchangeRate(offer.getPrice()).coinToFiat(amountAsCoin.get()));
@ -330,7 +329,7 @@ class TakeOfferDataModel extends ActivatableDataModel {
boolean isMinAmountLessOrEqualAmount() {
//noinspection SimplifiableIfStatement
if (offer != null && offer.getMinAmount() != null && amountAsCoin.get() != null)
if (offer != null && amountAsCoin.get() != null)
return !offer.getMinAmount().isGreaterThan(amountAsCoin.get());
return true;
}

View file

@ -72,7 +72,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
private final Navigation navigation;
private final BSFormatter formatter;
private final OfferDetailsPopup offerDetailsPopup;
private Preferences preferences;
private final Preferences preferences;
private ScrollPane scrollPane;
private GridPane gridPane;
private ImageView imageView;

View file

@ -48,7 +48,7 @@ import static javafx.beans.binding.Bindings.createStringBinding;
class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> implements ViewModel {
private final BtcValidator btcValidator;
private P2PService p2PService;
private final P2PService p2PService;
final BSFormatter formatter;
private String amountRange;
@ -161,7 +161,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
checkNotNull(dataModel.getAddressEntry(), "dataModel.getAddressEntry() must not be null");
addressAsString = dataModel.getAddressEntry().getAddress().toString();
addressAsString = dataModel.getAddressEntry().getAddressString();
address.set(dataModel.getAddressEntry().getAddress());
offerErrorListener = (observable, oldValue, newValue) -> {

View file

@ -52,7 +52,7 @@ public class OfferDetailsPopup extends Popup {
private final BSFormatter formatter;
protected final Preferences preferences;
private final User user;
private KeyRing keyRing;
private final KeyRing keyRing;
private final Navigation navigation;
private Offer offer;
private Coin tradeAmount;

View file

@ -8,7 +8,7 @@ import java.util.concurrent.LinkedBlockingQueue;
class PopupManager {
private static final Logger log = LoggerFactory.getLogger(PopupManager.class);
private static Queue<Popup> popups = new LinkedBlockingQueue<>(3);
private static final Queue<Popup> popups = new LinkedBlockingQueue<>(3);
private static Popup displayedPopup;
static void queueForDisplay(Popup popup) {

View file

@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit;
public class TacPopup extends Popup {
private static final Logger log = LoggerFactory.getLogger(TacPopup.class);
private Preferences preferences;
private final Preferences preferences;
@Inject
public TacPopup(Preferences preferences) {

View file

@ -45,7 +45,7 @@ public class TradeDetailsPopup extends Popup {
protected static final Logger log = LoggerFactory.getLogger(TradeDetailsPopup.class);
private final BSFormatter formatter;
private DisputeManager disputeManager;
private final DisputeManager disputeManager;
private Trade trade;
private ChangeListener<Number> changeListener;
private TextArea textArea;

View file

@ -44,7 +44,7 @@ class FailedTradesViewModel extends ActivatableWithDataModel<FailedTradesDataMod
}
String getAmount(FailedTradesListItem item) {
if (item != null && item.getTrade() instanceof Trade)
if (item != null && item.getTrade() != null)
return formatter.formatCoinWithCode(item.getTrade().getTradeAmount());
else
return "";
@ -55,7 +55,7 @@ class FailedTradesViewModel extends ActivatableWithDataModel<FailedTradesDataMod
}
String getVolume(FailedTradesListItem item) {
if (item != null && item.getTrade() instanceof Trade)
if (item != null && item.getTrade() != null)
return formatter.formatFiatWithCode(item.getTrade().getTradeVolume());
else
return "";

View file

@ -72,7 +72,7 @@ public class PendingTradesDataModel extends ActivatableDataModel {
public final DisputeManager disputeManager;
private final Navigation navigation;
private final WalletPasswordPopup walletPasswordPopup;
private NotificationCenter notificationCenter;
private final NotificationCenter notificationCenter;
final ObservableList<PendingTradesListItem> list = FXCollections.observableArrayList();
private final ListChangeListener<Trade> tradesListChangeListener;
@ -351,36 +351,42 @@ public class PendingTradesDataModel extends ActivatableDataModel {
} else {
log.warn("depositTx is null");
}
Transaction payoutTx = getTrade().getPayoutTx();
if (payoutTx != null) {
payoutTxSerialized = payoutTx.bitcoinSerialize();
payoutTxHashAsString = payoutTx.getHashAsString();
}
Trade trade = getTrade();
Dispute dispute = new Dispute(disputeManager.getDisputeStorage(),
trade.getId(),
keyRing.getPubKeyRing().hashCode(), // traderId
trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer,
isOfferer,
keyRing.getPubKeyRing(),
trade.getDate(),
trade.getContract(),
trade.getContractHash(),
depositTxSerialized,
payoutTxSerialized,
depositTxHashAsString,
payoutTxHashAsString,
trade.getContractAsJson(),
trade.getOffererContractSignature(),
trade.getTakerContractSignature(),
user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress()).getPubKeyRing(),
isSupportTicket
);
if (trade != null) {
Transaction payoutTx = trade.getPayoutTx();
if (payoutTx != null) {
payoutTxSerialized = payoutTx.bitcoinSerialize();
payoutTxHashAsString = payoutTx.getHashAsString();
} else {
log.warn("payoutTx is null at doOpenDispute");
}
trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
disputeManager.sendOpenNewDisputeMessage(dispute);
navigation.navigateTo(MainView.class, DisputesView.class);
Dispute dispute = new Dispute(disputeManager.getDisputeStorage(),
trade.getId(),
keyRing.getPubKeyRing().hashCode(), // traderId
trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer,
isOfferer,
keyRing.getPubKeyRing(),
trade.getDate(),
trade.getContract(),
trade.getContractHash(),
depositTxSerialized,
payoutTxSerialized,
depositTxHashAsString,
payoutTxHashAsString,
trade.getContractAsJson(),
trade.getOffererContractSignature(),
trade.getTakerContractSignature(),
user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress()).getPubKeyRing(),
isSupportTicket
);
trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
disputeManager.sendOpenNewDisputeMessage(dispute);
navigation.navigateTo(MainView.class, DisputesView.class);
} else {
log.warn("trade is null at doOpenDispute");
}
}
}

View file

@ -50,7 +50,7 @@ import javax.inject.Inject;
public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTradesViewModel> {
private final TradeDetailsPopup tradeDetailsPopup;
private BSFormatter formatter;
private final BSFormatter formatter;
@FXML
TableView<PendingTradesListItem> table;
@FXML

View file

@ -68,7 +68,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
private final BtcAddressValidator btcAddressValidator;
public final P2PService p2PService;
public User user;
public final User user;
private final ObjectProperty<BuyerState> buyerState = new SimpleObjectProperty<>();
private final ObjectProperty<SellerState> sellerState = new SimpleObjectProperty<>();

View file

@ -166,7 +166,7 @@ public abstract class TradeSubView extends HBox {
private void addLeftBox() {
leftVBox = new VBox();
leftVBox.setSpacing(Layout.SPACING_VBOX);
leftVBox.setSpacing(Layout.SPACING_V_BOX);
leftVBox.setMinWidth(290);
getChildren().add(leftVBox);
}

View file

@ -119,7 +119,7 @@ public class BuyerStep2View extends TradeStepView {
addTradeInfoBlock();
PaymentAccountContractData paymentAccountContractData = model.dataModel.getSellersPaymentAccountContractData();
String paymentMethodName = paymentAccountContractData.getPaymentMethodName();
String paymentMethodName = paymentAccountContractData != null ? paymentAccountContractData.getPaymentMethodName() : "";
TitledGroupBg accountTitledGroupBg = addTitledGroupBg(gridPane, ++gridRow, 1,
"Start payment using " + BSResources.get(paymentAccountContractData.getPaymentMethodName()),
Layout.GROUP_DISTANCE);

View file

@ -98,9 +98,9 @@ public class BuyerStep5View extends TradeStepView {
Tuple2<Label, TextField> fiatTradeAmountPair = addLabelTextField(gridPane, ++gridRow, getFiatTradeAmountLabel(), model.getFiatVolume());
fiatTradeAmountLabel = fiatTradeAmountPair.first;
Tuple2<Label, TextField> feesPair = addLabelTextField(gridPane, ++gridRow, "Total fees paid:", model.getTotalFees());
addLabelTextField(gridPane, ++gridRow, "Total fees paid:", model.getTotalFees());
Tuple2<Label, TextField> securityDepositPair = addLabelTextField(gridPane, ++gridRow, "Refunded security deposit:", model.getSecurityDeposit());
addLabelTextField(gridPane, ++gridRow, "Refunded security deposit:", model.getSecurityDeposit());
addTitledGroupBg(gridPane, ++gridRow, 2, "Withdraw your bitcoins", Layout.GROUP_DISTANCE);
addLabelTextField(gridPane, gridRow, "Amount to withdraw:", model.getPayoutAmount(), Layout.FIRST_ROW_AND_GROUP_DISTANCE);

View file

@ -48,7 +48,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private int gridRow = 0;
//private InputTextField transactionFeeInputTextField;
private ChangeListener<Boolean> transactionFeeFocusedListener;
private Preferences preferences;
private final Preferences preferences;
@Inject
public PreferencesView(PreferencesViewModel model, Preferences preferences) {

View file

@ -23,8 +23,8 @@ public class Layout {
public static final double FIRST_ROW_AND_GROUP_DISTANCE = GROUP_DISTANCE + FIRST_ROW_DISTANCE;
public static final double PADDING_WINDOW = 20d;
public static double PADDING = 10d;
public static double SPACING_HBOX = 10d;
public static final double SPACING_VBOX = 5d;
public static double SPACING_H_BOX = 10d;
public static final double SPACING_V_BOX = 5d;
public static final double GRID_GAP = 5d;
public static final double LIST_ROW_HEIGHT = 34;

View file

@ -17,7 +17,7 @@
package io.bitsquare.common.fxml;
import io.bitsquare.gui.common.ViewfxException;
import io.bitsquare.gui.common.ViewFxException;
import io.bitsquare.gui.common.fxml.FxmlViewLoader;
import io.bitsquare.gui.common.view.*;
import javafx.fxml.LoadException;
@ -70,7 +70,7 @@ public class FxmlViewLoaderTests {
@Test
public void fxmlFileMissingFxControllerAttributeShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expect(ViewFxException.class);
thrown.expectMessage("Does it declare an fx:controller attribute?");
viewLoader.load(MissingFxController.class);
}
@ -93,7 +93,7 @@ public class FxmlViewLoaderTests {
@Test
public void malformedFxmlFileShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expect(ViewFxException.class);
thrown.expectMessage("Failed to load view from FXML file");
thrown.expectCause(instanceOf(LoadException.class));
viewLoader.load(Malformed.class);
@ -106,7 +106,7 @@ public class FxmlViewLoaderTests {
@Test
public void missingFxmlFileShouldThrow() {
thrown.expect(ViewfxException.class);
thrown.expect(ViewFxException.class);
thrown.expectMessage("Does it exist?");
viewLoader.load(MissingFxmlFile.class);
}
@ -118,7 +118,7 @@ public class FxmlViewLoaderTests {
@Test
public void customFxmlFileLocationShouldOverrideDefaultConvention() {
thrown.expect(ViewfxException.class);
thrown.expect(ViewFxException.class);
thrown.expectMessage("Failed to load view class");
thrown.expectMessage("CustomLocation");
thrown.expectMessage("[unconventionally/located.fxml] could not be loaded");