|
@ -1,17 +1,23 @@ |
|
|
package com.sparrowwallet.sparrow.control; |
|
|
package com.sparrowwallet.sparrow.control; |
|
|
|
|
|
|
|
|
import com.sparrowwallet.drongo.address.Address; |
|
|
import com.sparrowwallet.drongo.address.Address; |
|
|
|
|
|
import com.sparrowwallet.drongo.wallet.Status; |
|
|
|
|
|
import com.sparrowwallet.sparrow.EventManager; |
|
|
|
|
|
import com.sparrowwallet.sparrow.event.WalletUtxoStatusChangedEvent; |
|
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; |
|
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; |
|
|
import com.sparrowwallet.sparrow.wallet.Entry; |
|
|
import com.sparrowwallet.sparrow.wallet.Entry; |
|
|
import com.sparrowwallet.sparrow.wallet.NodeEntry; |
|
|
import com.sparrowwallet.sparrow.wallet.NodeEntry; |
|
|
import com.sparrowwallet.sparrow.wallet.UtxoEntry; |
|
|
import com.sparrowwallet.sparrow.wallet.UtxoEntry; |
|
|
import javafx.geometry.Pos; |
|
|
import javafx.geometry.Pos; |
|
|
import javafx.scene.control.ContentDisplay; |
|
|
import javafx.scene.control.ContentDisplay; |
|
|
|
|
|
import javafx.scene.control.Hyperlink; |
|
|
import javafx.scene.control.Tooltip; |
|
|
import javafx.scene.control.Tooltip; |
|
|
import javafx.scene.control.TreeTableCell; |
|
|
import javafx.scene.control.TreeTableCell; |
|
|
import javafx.util.Duration; |
|
|
import javafx.util.Duration; |
|
|
import org.controlsfx.glyphfont.Glyph; |
|
|
import org.controlsfx.glyphfont.Glyph; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
|
public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> { |
|
|
public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> { |
|
|
public AddressCell() { |
|
|
public AddressCell() { |
|
|
super(); |
|
|
super(); |
|
@ -40,10 +46,10 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> { |
|
|
tooltip.setText(getTooltipText(utxoEntry, addressStatus.isDuplicate(), addressStatus.isDustAttack())); |
|
|
tooltip.setText(getTooltipText(utxoEntry, addressStatus.isDuplicate(), addressStatus.isDustAttack())); |
|
|
setTooltip(tooltip); |
|
|
setTooltip(tooltip); |
|
|
|
|
|
|
|
|
if(addressStatus.isDuplicate()) { |
|
|
if(addressStatus.isDustAttack()) { |
|
|
|
|
|
setGraphic(getDustAttackHyperlink(utxoEntry)); |
|
|
|
|
|
} else if(addressStatus.isDuplicate()) { |
|
|
setGraphic(getDuplicateGlyph()); |
|
|
setGraphic(getDuplicateGlyph()); |
|
|
} else if(addressStatus.isDustAttack()) { |
|
|
|
|
|
setGraphic(getDustAttackGlyph()); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
setGraphic(null); |
|
|
setGraphic(null); |
|
|
} |
|
|
} |
|
@ -63,10 +69,21 @@ public class AddressCell extends TreeTableCell<Entry, UtxoEntry.AddressStatus> { |
|
|
return duplicateGlyph; |
|
|
return duplicateGlyph; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Glyph getDustAttackGlyph() { |
|
|
public static Hyperlink getDustAttackHyperlink(UtxoEntry utxoEntry) { |
|
|
Glyph dustAttackGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE); |
|
|
Glyph dustAttackGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EXCLAMATION_TRIANGLE); |
|
|
dustAttackGlyph.getStyleClass().add("dust-attack-warning"); |
|
|
dustAttackGlyph.getStyleClass().add("dust-attack-warning"); |
|
|
dustAttackGlyph.setFontSize(12); |
|
|
dustAttackGlyph.setFontSize(12); |
|
|
return dustAttackGlyph; |
|
|
|
|
|
|
|
|
Hyperlink hyperlink = new Hyperlink(utxoEntry.getHashIndex().getStatus() == Status.FROZEN ? "" : "Freeze?", dustAttackGlyph); |
|
|
|
|
|
hyperlink.getStyleClass().add("freeze-dust-utxo"); |
|
|
|
|
|
hyperlink.setOnAction(event -> { |
|
|
|
|
|
if(utxoEntry.getHashIndex().getStatus() != Status.FROZEN) { |
|
|
|
|
|
hyperlink.setText(""); |
|
|
|
|
|
utxoEntry.getHashIndex().setStatus(Status.FROZEN); |
|
|
|
|
|
EventManager.get().post(new WalletUtxoStatusChangedEvent(utxoEntry.getWallet(), Collections.singletonList(utxoEntry.getHashIndex()))); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return hyperlink; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|