Skip to content

Commit a01f021

Browse files
committed
GUI updates
1 parent f5f7e73 commit a01f021

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

convex-gui/src/main/java/convex/gui/MainGUI.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@ public MainGUI() {
3535
ActionPanel actionPanel=new ActionPanel();
3636
actionPanel.setLayout(new MigLayout("center,align center,fillx"));
3737

38-
JComponent wallet=createLaunchButton("Wallet",Toolkit.WALLET_ICON,this::launchWallet);
38+
JComponent wallet=createLaunchButton("Wallet",Toolkit.WALLET_ICON,this::launchWallet,"Open a Convex Wallet, connecting to any existing network");
3939
actionPanel.add(wallet);
4040

41-
JComponent testNet=createLaunchButton("Peer Manager",Toolkit.TESTNET_ICON,this::launchTestNet);
41+
JComponent testNet=createLaunchButton("Peer Manager",Toolkit.TESTNET_ICON,this::launchTestNet,"Launch a DevNet with the Peer Manager. This gives you a test network you can use freely for testing and development purposes.");
4242
actionPanel.add(testNet);
4343

44-
JComponent latticeFS=createLaunchButton("Lattice Filesystem",Toolkit.DLFS_ICON,this::launchDLFS);
44+
JComponent latticeFS=createLaunchButton("Lattice Filesystem",Toolkit.DLFS_ICON,this::launchDLFS,"Launch a DLFS file browser. EXPERIMENTAL.");
4545
actionPanel.add(latticeFS);
4646

47-
JComponent terminal=createLaunchButton("Client Terminal",Toolkit.TERMINAL_ICON,this::launchTerminalClient);
47+
JComponent terminal=createLaunchButton("Client Terminal",Toolkit.TERMINAL_ICON,this::launchTerminalClient,"Open a Convex REPL terminal, connecting to any existing network");
4848
actionPanel.add(terminal);
4949

50-
JComponent hacker=createLaunchButton("Hacker Tools",Toolkit.HACKER_ICON,this::launchTools);
50+
JComponent hacker=createLaunchButton("Hacker Tools",Toolkit.HACKER_ICON,this::launchTools,"Open a set of useful tools for hackers and power users.");
5151
actionPanel.add(hacker);
5252

53-
JComponent discord=createLaunchButton("Discord",Toolkit.ECOSYSTEM_ICON,this::launchDiscord);
53+
JComponent discord=createLaunchButton("Discord",Toolkit.ECOSYSTEM_ICON,this::launchDiscord,"Go to the Convex community Discord (opens web browser).");
5454
actionPanel.add(discord);
5555

56-
JComponent www=createLaunchButton("convex.world",Toolkit.WWW_ICON,this::launchWebsite);
56+
JComponent www=createLaunchButton("convex.world",Toolkit.WWW_ICON,this::launchWebsite,"Go to the Convex main website (opens web browser).");
5757
actionPanel.add(www);
5858

5959
add(actionPanel);
@@ -96,11 +96,12 @@ public void launchWebsite() {
9696
Toolkit.launchBrowser("https://convex.world");
9797
}
9898

99-
public JPanel createLaunchButton(String label, ImageIcon icon, Runnable cmd) {
99+
public JPanel createLaunchButton(String label, ImageIcon icon, Runnable cmd, String tooltip) {
100100
JButton butt=new JButton(icon);
101101
butt.addActionListener(e->{
102102
EventQueue.invokeLater(cmd);
103103
});
104+
butt.setToolTipText(tooltip);
104105

105106
JLabel lab = new JLabel(label);
106107
lab.setHorizontalAlignment(SwingConstants.CENTER);

convex-gui/src/main/java/convex/gui/components/DecimalAmountField.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@ public void setText(String text) {
114114
super.setText(text.trim());
115115
}
116116

117-
static AInteger parse(String text, int decimals, boolean exact) {
117+
/**
118+
* Parse a string as an integer amount with the specified number of decimals
119+
* @param text String to parse
120+
* @param decimals Number of decimals in result quantity
121+
* @param exact If true, conversion will require an exact conversion
122+
* @return Integer amount, or null if not convertible
123+
*/
124+
public static AInteger parse(String text, int decimals, boolean exact) {
118125
try {
119126
text=text.trim();
120127
BigDecimal dec=new BigDecimal(text);

convex-gui/src/main/java/convex/gui/components/account/AccountChooserPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AccountChooserPanel(Convex convex) {
6363
keyCombo.addItemListener(e->{
6464
if (e.getStateChange()==ItemEvent.DESELECTED) {
6565
// key pair was deselected and/or set to null
66-
convex.setKeyPair(null);
66+
setKeyPair(null);
6767
return;
6868
};
6969
AWalletEntry we=(AWalletEntry)e.getItem();

convex-gui/src/main/java/convex/gui/peer/stake/PeerStakePanel.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
import java.awt.BorderLayout;
44

5+
import javax.swing.JOptionPane;
56
import javax.swing.JPanel;
67
import javax.swing.JScrollPane;
8+
import javax.swing.SwingUtilities;
79

810
import convex.api.Convex;
11+
import convex.core.data.AccountKey;
12+
import convex.core.data.prim.AInteger;
913
import convex.gui.components.ActionButton;
1014
import convex.gui.components.ActionPanel;
15+
import convex.gui.components.DecimalAmountField;
16+
import convex.gui.utils.SymbolIcon;
1117

1218
@SuppressWarnings("serial")
1319
public class PeerStakePanel extends JPanel {
@@ -25,7 +31,38 @@ public PeerStakePanel(Convex convex) {
2531
add(ap,BorderLayout.SOUTH);
2632

2733
ap.add(new ActionButton("Refresh", 0xe5d5, e->peerTable.refresh()) );
28-
ap.add(new ActionButton("Set Stake...", 0xf5dc, e->peerTable.refresh()) );
34+
ap.add(new ActionButton("Set Stake...", 0xf5dc, e->{
35+
int row=peerTable.getSelectedRow();
36+
if (row<0) {
37+
JOptionPane.showMessageDialog(this,"Select a peer to set stake on");
38+
return;
39+
}
40+
Object val=peerTable.getValueAt(row, 0);
41+
AccountKey peerKey=AccountKey.parse(val);
42+
if (peerKey!=null) {
43+
Object stk=JOptionPane.showInputDialog(this,
44+
"Enter desired stake for peer "+peerKey,
45+
"Set Peer Stake...",
46+
JOptionPane.QUESTION_MESSAGE,
47+
SymbolIcon.get(0xf56e),
48+
null,
49+
"0.0");
50+
if (!(stk instanceof String)) return;
51+
AInteger amt=DecimalAmountField.parse((String) stk, 9, true);
52+
if (amt==null) {
53+
JOptionPane.showMessageDialog(this,"Input amount not valid. Must be a qantity in Convex Gold, e.g. '1000.01' ");
54+
return;
55+
}
56+
convex.transact("(set-stake "+peerKey+" "+amt+")").thenAcceptAsync(r->{
57+
if (r.isError()) {
58+
SwingUtilities.invokeLater(()->{
59+
JOptionPane.showMessageDialog(this,"Stake setting failed: "+r,"Staking problem",JOptionPane.ERROR_MESSAGE);
60+
});
61+
}
62+
peerTable.refresh();
63+
});
64+
}
65+
}));
2966
}
3067

3168
}

0 commit comments

Comments
 (0)