diff --git a/convex-gui/src/main/java/convex/gui/components/account/KeyPairCombo.java b/convex-gui/src/main/java/convex/gui/components/account/KeyPairCombo.java index eb11b8101..d077271d0 100644 --- a/convex-gui/src/main/java/convex/gui/components/account/KeyPairCombo.java +++ b/convex-gui/src/main/java/convex/gui/components/account/KeyPairCombo.java @@ -97,7 +97,7 @@ public Component getListCellRendererComponent(JList list AWalletEntry entry= (AWalletEntry)value; if (entry!=null) { AccountKey pubKey=entry.getPublicKey(); - setText(pubKey.toHexString(16)+"..."); + setText("0x"+pubKey.toChecksumHex().substring(0,16)+"..."); setIcon(Identicon.createIcon(entry.getIdenticonData(),21)); } else { setText(""); @@ -154,7 +154,7 @@ public static KeyPairCombo create(AKeyPair kp) { KeyPairModel model=new KeyPairModel(); if (kp!=null) { AccountKey publicKey=kp.getAccountKey(); - AWalletEntry we=Toolkit.getKeyRingEntry(publicKey); + AWalletEntry we=KeyRingPanel.getKeyRingEntry(publicKey); if (we==null) { we=new HotWalletEntry(kp); } diff --git a/convex-gui/src/main/java/convex/gui/keys/KeyGenPanel.java b/convex-gui/src/main/java/convex/gui/keys/KeyGenPanel.java index 0233afd32..0312c6d5e 100644 --- a/convex-gui/src/main/java/convex/gui/keys/KeyGenPanel.java +++ b/convex-gui/src/main/java/convex/gui/keys/KeyGenPanel.java @@ -331,7 +331,9 @@ public KeyGenPanel(PeerGUI manager) { numSpinner.setModel(new SpinnerNumberModel(12, 3, 30, 1)); actionPanel.add(numSpinner); - JButton btnNewButton = new ActionButton("Export...",0xebbe,e->{}); + JButton btnNewButton = new ActionButton("Export...",0xebbe,e->{ + + }); actionPanel.add(btnNewButton); { // Button to Normalise Mnemonic string @@ -343,7 +345,7 @@ public KeyGenPanel(PeerGUI manager) { actionPanel.add(btnNormalise); } - addWalletButton=new ActionButton("Add to keyring",e -> { + addWalletButton=new ActionButton("Add to keyring",0xe145,e -> { String pks = privateKeyArea.getText(); pks = Utils.stripWhiteSpace(pks); HotWalletEntry we = HotWalletEntry.create(AKeyPair.create(Utils.hexToBytes(pks))); diff --git a/convex-gui/src/main/java/convex/gui/keys/KeyRingPanel.java b/convex-gui/src/main/java/convex/gui/keys/KeyRingPanel.java index 7c01cca21..34cb7a3ef 100644 --- a/convex-gui/src/main/java/convex/gui/keys/KeyRingPanel.java +++ b/convex-gui/src/main/java/convex/gui/keys/KeyRingPanel.java @@ -1,6 +1,7 @@ package convex.gui.keys; import java.awt.Color; +import java.util.Iterator; import java.util.concurrent.CompletableFuture; import javax.swing.DefaultListModel; @@ -23,6 +24,7 @@ import convex.core.lang.RT; import convex.core.lang.Symbols; import convex.core.lang.ops.Special; +import convex.core.util.Utils; import convex.gui.components.ActionButton; import convex.gui.components.ActionPanel; import convex.gui.components.ScrollyList; @@ -114,11 +116,29 @@ public static AWalletEntry findWalletEntry(Convex convex) { try { CompletableFuture cf=convex.query(Special.forSymbol(Symbols.STAR_KEY)).thenApply(r->r.getValue()); key = RT.ensureAccountKey(cf.get()); - AWalletEntry we=Toolkit.getKeyRingEntry(key); + AWalletEntry we=KeyRingPanel.getKeyRingEntry(key); return we; } catch (Exception e) { e.printStackTrace(); return null; } } + + /** + * Gets an entry for the current keyring + * @param address + * @return Wallet Entry, or null if not found + */ + public static AWalletEntry getKeyRingEntry(AccountKey publicKey) { + if (publicKey==null) return null; + DefaultListModel list = getListModel(); + Iterator it=list.elements().asIterator(); + while (it.hasNext()) { + AWalletEntry we=it.next(); + if (Utils.equals(we.getPublicKey(), publicKey)) { + return we; + } + } + return null; + } } diff --git a/convex-gui/src/main/java/convex/gui/utils/Toolkit.java b/convex-gui/src/main/java/convex/gui/utils/Toolkit.java index 3c3612328..4afd035fd 100644 --- a/convex-gui/src/main/java/convex/gui/utils/Toolkit.java +++ b/convex-gui/src/main/java/convex/gui/utils/Toolkit.java @@ -21,11 +21,9 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.Iterator; import javax.swing.AbstractAction; import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.InputMap; @@ -49,13 +47,12 @@ import com.formdev.flatlaf.FlatDarculaLaf; import com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme; -import convex.core.crypto.wallet.AWalletEntry; -import convex.core.data.AccountKey; import convex.core.util.Utils; -import convex.gui.keys.KeyRingPanel; @SuppressWarnings("serial") public class Toolkit { + + private static Logger log = LoggerFactory.getLogger(Toolkit.class.getName()); public static final float SCALE=getUIScale(); @@ -64,7 +61,6 @@ public class Toolkit { public static final int SMALL_ICON_SIZE = (int) (16*SCALE); public static final int MAIN_ICON_SIZE = (int) (64*SCALE); - private static Logger log = LoggerFactory.getLogger(Toolkit.class.getName()); public static final float DEFAULT_FONT_SIZE=14; @@ -100,8 +96,10 @@ public class Toolkit { UIManager.setLookAndFeel(laf); FlatMaterialOceanicIJTheme.setup(); - UIManager.put( "Button.foreground", BUTTON_FG ); - System.out.println(UIManager.get("Label.foreground")); + + // Override button foreground, too dark by default + UIManager.put( "Button.foreground", UIManager.get("Label.foreground") ); + // System.out.println(UIManager.get("Label.foreground")); } catch (Exception e) { e.printStackTrace(); log.warn("Unable to set look and feel: {}", e); @@ -119,7 +117,7 @@ public static float getUIScale() { .getLocalGraphicsEnvironment() .getDefaultScreenDevice(); Double scale=screen.getDefaultConfiguration().getDefaultTransform().getScaleX(); - System.err.println("UI Scale: "+scale); + log.debug("UI Scale: "+scale); return (float)(scale.doubleValue()); } @@ -313,24 +311,6 @@ private void maybeDisplayPopupMenu(MouseEvent e) { }); } - /** - * Gets an entry for the current keyring - * @param address - * @return Wallet Entry, or null if not found - */ - public static AWalletEntry getKeyRingEntry(AccountKey publicKey) { - if (publicKey==null) return null; - DefaultListModel list = KeyRingPanel.getListModel(); - Iterator it=list.elements().asIterator(); - while (it.hasNext()) { - AWalletEntry we=it.next(); - if (Utils.equals(we.getPublicKey(), publicKey)) { - return we; - } - } - return null; - } - public static Border createDialogBorder() { return createEmptyBorder(20); }