Skip to content

Commit

Permalink
GUI general updates and interface improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed May 1, 2024
1 parent 4fd3558 commit 620f385
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.core.data.Symbol;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ScrollyList;
import convex.gui.components.account.AccountChooserPanel;
import convex.gui.components.models.StateModel;
import net.miginfocom.swing.MigLayout;

Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/actor/DeployPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import javax.swing.JLabel;
import javax.swing.JPanel;

import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ActionPanel;
import convex.gui.components.account.AccountChooserPanel;

@SuppressWarnings("serial")
public class DeployPanel extends JPanel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import convex.api.ConvexLocal;
import convex.core.State;
import convex.core.data.Address;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ActionPanel;
import convex.gui.components.ScrollyList;
import convex.gui.components.account.AccountChooserPanel;

/**
* Panel displaying current prediction markets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import convex.core.lang.impl.Fn;
import convex.core.transactions.ATransaction;
import convex.core.transactions.Invoke;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.BaseListComponent;
import convex.gui.components.CodeLabel;
import convex.gui.components.Toast;
import convex.gui.components.account.AccountChooserPanel;
import convex.gui.utils.Toolkit;
import net.miginfocom.swing.MigLayout;

Expand Down
7 changes: 2 additions & 5 deletions convex-gui/src/main/java/convex/gui/client/ConvexClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.concurrent.TimeoutException;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

Expand All @@ -17,6 +16,7 @@

import convex.api.Convex;
import convex.core.util.Utils;
import convex.gui.components.ConnectPanel;
import convex.gui.peer.windows.REPLPanel;
import convex.gui.utils.Toolkit;

Expand Down Expand Up @@ -51,10 +51,7 @@ public static void main(String[] args) throws IOException, TimeoutException {
// call to set up Look and Feel
Toolkit.init();

String DEFAULT="localhost:18888";
String hostAddress=JOptionPane.showInputDialog("Enter Peer Address (default to "+DEFAULT+")");
if (hostAddress.isBlank()) hostAddress=DEFAULT;
Convex convex=Convex.connect(Utils.toInetSocketAddress(hostAddress));
Convex convex=ConnectPanel.tryConnect(null,"Connect to Convex");
EventQueue.invokeLater(()->launch(convex));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@
import net.miginfocom.swing.MigLayout;

@SuppressWarnings("serial")
public class QRCodePanel extends JPanel {
public class QRCode extends JPanel {

protected final String data;
protected BufferedImage image;

public QRCodePanel(String data, int scale) {
public QRCode(String data, int scale) {
this.data=data;

image=createQR(data,scale);

this.setLayout(new MigLayout());
this.setMinimumSize(new Dimension(image.getWidth(),image.getHeight()));
this.setToolTipText(data);
}

public static BufferedImage createQR(String data,int scale) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
import javax.swing.JPopupMenu;
import javax.swing.text.JTextComponent;

import convex.gui.utils.SymbolIcon;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
public class RightCopyMenu extends JPopupMenu implements ActionListener {

JMenuItem copyMenuItem = new JMenuItem("Copy",SymbolIcon.get(0xe14d,Toolkit.SMALL_ICON_SIZE));
JMenuItem cutMenuItem = new JMenuItem("Cut",SymbolIcon.get(0xf08b,Toolkit.SMALL_ICON_SIZE));
JMenuItem pasteMenuItem = new JMenuItem("Paste",SymbolIcon.get(0xe14f,Toolkit.SMALL_ICON_SIZE));
JMenuItem copyMenuItem = new JMenuItem("Copy",Toolkit.menuIcon(0xe14d));
JMenuItem cutMenuItem = new JMenuItem("Cut",Toolkit.menuIcon(0xf08bE));
JMenuItem pasteMenuItem = new JMenuItem("Paste",Toolkit.menuIcon(0xe14f));

JTextComponent comp;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.gui.components;
package convex.gui.components.account;

import java.awt.event.ItemEvent;

Expand All @@ -12,8 +12,7 @@
import convex.core.crypto.wallet.AWalletEntry;
import convex.core.data.Address;
import convex.core.lang.ops.Special;
import convex.gui.components.account.AddressCombo;
import convex.gui.components.account.KeyPairCombo;
import convex.gui.components.BalanceLabel;
import net.miginfocom.swing.MigLayout;

/**
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/etch/EtchWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import convex.api.Convex;
import convex.api.ConvexLocal;
import convex.gui.components.AbstractGUI;
import convex.gui.components.PeerComponent;
import convex.gui.peer.PeerComponent;
import etch.EtchStore;
import net.miginfocom.swing.MigLayout;

Expand Down
8 changes: 4 additions & 4 deletions convex-gui/src/main/java/convex/gui/keys/KeyGenPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@SuppressWarnings("serial")
public class KeyGenPanel extends JPanel {

private static final String NOTE_CONSTRAINT = "align 50%,span 2,width 100:500:700";
private static final String NOTE_CONSTRAINT = "align 50%,span 2,width 100:600:1000";
private static final String TEXTAREA_CONSTRAINT = "grow,width 10:500:800";
JTextArea mnemonicArea;
JPasswordField passArea;
Expand Down Expand Up @@ -245,7 +245,7 @@ public KeyGenPanel(PeerGUI manager) {
}));
}

addNote("NOTE: Once the BIP39 seed is generated, we use SLIP-10 to create a derivation path to an Ed25519 private key. Instead of a BIP39 seed, you can also use another good secret source of random entropy, e.g. SLIP-0039.");
addNote("Once the BIP39 seed is generated, we use SLIP-10 to create a derivation path to an Ed25519 private key. Instead of a BIP39 seed, you can also use another good secret source of random entropy, e.g. SLIP-0039.");

{
addLabel("SLIP-10 Master Key");
Expand Down Expand Up @@ -284,7 +284,7 @@ public KeyGenPanel(PeerGUI manager) {
derivedKeyArea.setText("(not ready)");
}

addNote("NOTE: The first 32 bytes of the SLIP-10 extended private key are used as the Ed25519 seed. This is all you strictly need to sign transactions in Convex. Any 32-byte hex value will work: you can enter this directly if you obtained a good secret random seed from another source.");
addNote("The first 32 bytes of the SLIP-10 extended private key are used as the Ed25519 seed. This is all you strictly need to sign transactions in Convex. Any 32-byte hex value will work: you can enter this directly if you obtained a good secret random seed from another source.");


{
Expand Down Expand Up @@ -358,7 +358,7 @@ public KeyGenPanel(PeerGUI manager) {
}

private void addNote(String s) {
JTextArea ta = Toolkit.makeNote(s);
JTextArea ta = Toolkit.makeNote("NOTE",s);
formPanel.add(ta,NOTE_CONSTRAINT);
}

Expand Down
4 changes: 4 additions & 0 deletions convex-gui/src/main/java/convex/gui/keys/KeyRingPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -44,6 +45,9 @@ public static void addWalletEntry(AWalletEntry we) {
*/
public KeyRingPanel() {
setLayout(new MigLayout());

JTextArea note=Toolkit.makeNote("This is a list of currentltly loaded crytographic keys. Locked keys cannot be used until unlocked.");
add(note,"dock north");

// Scrollable list of wallet entries
walletList = new ScrollyList<AWalletEntry>(listModel, we -> new WalletComponent(we));
Expand Down
5 changes: 3 additions & 2 deletions convex-gui/src/main/java/convex/gui/keys/WalletComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ public WalletComponent(AWalletEntry initialWalletEntry) {
JPanel panel=new JPanel();
panel.setLayout(new MigLayout("wrap 1","[200]"));
panel.add(new Identicon(kp.getAccountKey()),"align center");
panel.add(new CodeLabel(kp.getSeed().toString()),"span,grow");
panel.add(Toolkit.makeNote("WARNING: keep this private, it can be used to control your account(s)"),"span,grow");

panel.add(Toolkit.withTitledBorder("Ed25519 Private Seed",new CodeLabel(kp.getSeed().toString())));
panel.add(Toolkit.makeNote("WARNING: keep this private, it can be used to control your account(s)"),"grow");
panel.setBorder(Toolkit.createDialogBorder());
JOptionPane.showMessageDialog(WalletComponent.this, panel,"Ed25519 Private Seed",JOptionPane.INFORMATION_MESSAGE);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.gui.components;
package convex.gui.peer;

import java.awt.Color;
import java.awt.Dimension;
Expand All @@ -16,7 +16,6 @@
import convex.core.data.SignedData;
import convex.core.store.AStore;
import convex.core.store.Stores;
import convex.gui.peer.PeerGUI;
import convex.peer.Server;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.gui.components;
package convex.gui.peer;

import java.io.IOException;
import java.util.concurrent.TimeoutException;
Expand All @@ -21,12 +21,17 @@
import convex.core.data.PeerStatus;
import convex.core.text.Text;
import convex.gui.client.ConvexClient;
import convex.gui.components.BaseImageButton;
import convex.gui.components.BaseListComponent;
import convex.gui.components.CodeLabel;
import convex.gui.components.DropdownMenu;
import convex.gui.components.Identicon;
import convex.gui.components.models.StateModel;
import convex.gui.etch.EtchWindow;
import convex.gui.peer.PeerGUI;
import convex.gui.peer.windows.PeerWindow;
import convex.gui.peer.windows.state.StateExplorer;
import convex.gui.utils.Toolkit;
import convex.gui.wallet.WalletApp;
import convex.peer.ConnectionManager;
import convex.peer.Server;
import etch.EtchStore;
Expand Down Expand Up @@ -97,7 +102,7 @@ public PeerComponent(ConvexLocal value) {
// Setup popup menu for peer
JPopupMenu popupMenu = new JPopupMenu();

JMenuItem closeButton = new JMenuItem("Shutdown Peer");
JMenuItem closeButton = new JMenuItem("Shutdown Peer",Toolkit.menuIcon(0xe8ac));
closeButton.addActionListener(e -> {
try {
server.shutdown();
Expand All @@ -107,33 +112,36 @@ public PeerComponent(ConvexLocal value) {
});
popupMenu.add(closeButton);

JMenuItem exploreButton = new JMenuItem("Explore state");
JMenuItem exploreButton = new JMenuItem("Explore state",Toolkit.menuIcon(0xe97a));
exploreButton.addActionListener(e -> {
launchExploreWindow(convex);
});
popupMenu.add(exploreButton);

if (server.getStore() instanceof EtchStore) {
JMenuItem storeButton = new JMenuItem("Explore Etch store");
JMenuItem storeButton = new JMenuItem("Explore Etch store",Toolkit.menuIcon(0xf80e));
storeButton.addActionListener(e -> {
launchEtchWindow(convex);
});
popupMenu.add(storeButton);
}

JMenuItem killConn = new JMenuItem("Kill Connections");
JMenuItem killConn = new JMenuItem("Kill Connections",Toolkit.menuIcon(0xe16f));
killConn.addActionListener(e -> {
server.getConnectionManager().closeAllConnections();
});
popupMenu.add(killConn);

JMenuItem replButton = new JMenuItem("Launch REPL");
JMenuItem replButton = new JMenuItem("Launch REPL",Toolkit.menuIcon(0xeb8e));
replButton.addActionListener(e -> launchPeerWindow(this.convex));
popupMenu.add(replButton);

JMenuItem clientButton = new JMenuItem("Connect Client");
clientButton.addActionListener(e -> launchClientWindow(convex));
popupMenu.add(clientButton);
JMenuItem walletButton = new JMenuItem("Open Wallet",Toolkit.menuIcon(0xe850));
walletButton.addActionListener(e -> {
new WalletApp(convex).run();
});
popupMenu.add(walletButton);



DropdownMenu dm = new DropdownMenu(popupMenu);
Expand Down Expand Up @@ -168,7 +176,7 @@ protected void updateDescription() {
description.select(ss, se);
}

private void launchClientWindow(Convex peer) {
protected void launchClientWindow(Convex peer) {
try {
Convex convex = ConvexRemote.connect(peer.getHostAddress());
Address addr=peer.getAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import convex.core.exceptions.TODOException;
import convex.core.util.Utils;
import convex.gui.components.ActionPanel;
import convex.gui.components.PeerComponent;
import convex.gui.components.ScrollyList;
import convex.gui.keys.KeyRingPanel;
import convex.gui.peer.PeerComponent;
import convex.gui.peer.PeerGUI;
import convex.peer.API;
import convex.peer.Server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import convex.api.Convex;
import convex.api.ConvexLocal;
import convex.gui.components.AbstractGUI;
import convex.gui.components.PeerComponent;
import convex.gui.peer.PeerComponent;
import convex.peer.Server;
import net.miginfocom.swing.MigLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
import convex.core.transactions.ATransaction;
import convex.core.transactions.Invoke;
import convex.core.util.Utils;
import convex.gui.components.AccountChooserPanel;
import convex.gui.components.ActionPanel;
import convex.gui.components.BaseTextPane;
import convex.gui.components.CodePane;
import convex.gui.components.account.AccountChooserPanel;
import convex.gui.utils.CVXHighlighter;
import net.miginfocom.swing.MigLayout;

Expand Down
8 changes: 5 additions & 3 deletions convex-gui/src/main/java/convex/gui/utils/SymbolIcon.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public SymbolIcon(BufferedImage image) {
super(image);
}

private static final float SCALE_FACTOR=1.3f;

private static SymbolIcon create(int codePoint, int size, int colour) {
BufferedImage image =new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);

Expand All @@ -29,11 +31,11 @@ private static SymbolIcon create(int codePoint, int size, int colour) {
label.setForeground(new Color(colour&0xffffff));

// set font size so we get the correct pixel size
float fontSize= 72.0f * size / Toolkit.SCREEN_RES;
float fontSize= SCALE_FACTOR* 72.0f * size / Toolkit.SCREEN_RES;
label.setFont(Toolkit.SYMBOL_FONT.deriveFont(fontSize));

label.setHorizontalTextPosition(JLabel.CENTER);
label.setVerticalTextPosition(JLabel.CENTER);
label.setHorizontalAlignment(JLabel.CENTER);
label.setVerticalAlignment(JLabel.CENTER);

label.setSize(size, size);

Expand Down
Loading

0 comments on commit 620f385

Please sign in to comment.