Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add icon, add address panel, reorg panels
- Loading branch information
1 parent
38a5412
commit 280b84c
Showing
12 changed files
with
399 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,9 @@ java_library( | |
"@duckutil//:duckutil_lib", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "resources", | ||
srcs = glob(["resources/*"]), | ||
) | ||
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package snowblossom.iceleaf; | ||
|
||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.JLabel; | ||
import javax.swing.JTextArea; | ||
import javax.swing.JTextField; | ||
import javax.swing.JProgressBar; | ||
import javax.swing.SwingUtilities; | ||
import java.awt.GridBagLayout; | ||
import java.awt.GridBagConstraints; | ||
import java.util.prefs.Preferences; | ||
import javax.swing.JComboBox; | ||
import javax.swing.ButtonGroup; | ||
import javax.swing.JRadioButton; | ||
import javax.swing.JButton; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.ActionEvent; | ||
|
||
import snowblossom.client.SnowBlossomClient; | ||
import snowblossom.lib.Globals; | ||
import snowblossom.lib.AddressSpecHash; | ||
import snowblossom.lib.AddressUtil; | ||
|
||
import duckutil.PeriodicThread; | ||
import java.util.TreeMap; | ||
import java.util.TreeSet; | ||
import java.util.Collection; | ||
|
||
import snowblossom.proto.SubmitReply; | ||
import snowblossom.proto.Transaction; | ||
import snowblossom.proto.TransactionInner; | ||
import snowblossom.proto.TransactionOutput; | ||
import snowblossom.util.proto.*; | ||
import snowblossom.client.TransactionFactory; | ||
import snowblossom.lib.TransactionUtil; | ||
import snowblossom.lib.ChainHash; | ||
import java.io.PrintStream; | ||
import java.io.ByteArrayOutputStream; | ||
import snowblossom.proto.AddressSpec; | ||
import snowblossom.proto.WalletDatabase; | ||
import snowblossom.proto.BalanceInfo; | ||
import javax.swing.JScrollPane; | ||
import javax.swing.JComponent; | ||
|
||
public class AddressPanel extends BasePanel | ||
{ | ||
protected WalletComboBox wallet_select_box; | ||
protected UpdateThread update_thread; | ||
|
||
public AddressPanel(IceLeaf ice_leaf) | ||
{ | ||
super(ice_leaf); | ||
} | ||
|
||
@Override | ||
public void setupPanel() | ||
{ | ||
|
||
GridBagConstraints c = new GridBagConstraints(); | ||
c.weightx = 0.0; | ||
c.weighty= 0.0; | ||
c.gridheight = 1; | ||
c.anchor = GridBagConstraints.NORTHWEST; | ||
|
||
c.gridwidth = 1; | ||
panel.add(new JLabel("Wallet to view addresses of:"), c); | ||
c.gridwidth = GridBagConstraints.REMAINDER; | ||
|
||
wallet_select_box = new WalletComboBox(ice_leaf); | ||
panel.add(wallet_select_box, c); | ||
|
||
update_thread = new UpdateThread(); | ||
update_thread.start(); | ||
|
||
wallet_select_box.addActionListener(new ActionListener(){ | ||
public void actionPerformed(ActionEvent e) | ||
{ | ||
update_thread.wake(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public class UpdateThread extends PeriodicThread | ||
{ | ||
public UpdateThread() | ||
{ | ||
super(15000); | ||
|
||
} | ||
public void runPass() | ||
{ | ||
try | ||
{ | ||
String wallet_name = (String)wallet_select_box.getSelectedItem(); | ||
if (wallet_name == null) | ||
{ | ||
setMessageBox("no wallet selected"); | ||
return; | ||
} | ||
|
||
SnowBlossomClient client = ice_leaf.getWalletPanel().getWallet( wallet_name ); | ||
if (client == null) | ||
{ | ||
setMessageBox("no wallet selected"); | ||
return; | ||
} | ||
ByteArrayOutputStream bout = new ByteArrayOutputStream(); | ||
PrintStream pout = new PrintStream(bout); | ||
pout.println(String.format("Wallet: %s", wallet_name)); | ||
|
||
WalletDatabase db = client.getPurse().getDB(); | ||
|
||
for(AddressSpec claim : db.getAddressesList()) | ||
{ | ||
String address = AddressUtil.getAddressString(claim, ice_leaf.getParams()); | ||
AddressSpecHash hash = AddressUtil.getHashForSpec(claim); | ||
boolean used = db.getUsedAddressesMap().containsKey(address); | ||
BalanceInfo bi = client.getBalance(hash); | ||
String bi_print = SnowBlossomClient.getBalanceInfoPrint(bi); | ||
|
||
pout.println(String.format(" %s - used:%s - %s", address, ""+used, bi_print)); | ||
|
||
} | ||
|
||
setStatusBox(new String(bout.toByteArray()).trim()); | ||
setMessageBox(""); | ||
|
||
} | ||
catch(Throwable t) | ||
{ | ||
setMessageBox(ErrorUtil.getThrowInfo(t)); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
package snowblossom.iceleaf; | ||
|
||
import javax.swing.JFrame; | ||
import javax.swing.JPanel; | ||
import javax.swing.JLabel; | ||
import javax.swing.JTextArea; | ||
import javax.swing.JTextField; | ||
import javax.swing.JProgressBar; | ||
import javax.swing.SwingUtilities; | ||
import java.awt.GridBagLayout; | ||
import java.awt.GridBagConstraints; | ||
import java.util.prefs.Preferences; | ||
import javax.swing.JComboBox; | ||
import javax.swing.ButtonGroup; | ||
import javax.swing.JRadioButton; | ||
import javax.swing.JButton; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.ActionEvent; | ||
|
||
import snowblossom.client.SnowBlossomClient; | ||
import snowblossom.lib.Globals; | ||
import snowblossom.lib.AddressSpecHash; | ||
import snowblossom.lib.AddressUtil; | ||
|
||
import duckutil.PeriodicThread; | ||
import java.util.TreeMap; | ||
import java.util.TreeSet; | ||
import java.util.Collection; | ||
|
||
import snowblossom.proto.SubmitReply; | ||
import snowblossom.proto.Transaction; | ||
import snowblossom.proto.TransactionInner; | ||
import snowblossom.proto.TransactionOutput; | ||
import snowblossom.util.proto.*; | ||
import snowblossom.client.TransactionFactory; | ||
import snowblossom.lib.TransactionUtil; | ||
import snowblossom.lib.ChainHash; | ||
import java.io.PrintStream; | ||
import java.io.ByteArrayOutputStream; | ||
import snowblossom.proto.AddressSpec; | ||
import snowblossom.proto.WalletDatabase; | ||
import snowblossom.proto.BalanceInfo; | ||
import javax.swing.JScrollPane; | ||
import javax.swing.JComponent; | ||
|
||
public abstract class BasePanel | ||
{ | ||
protected JScrollPane outer_panel; | ||
protected JPanel panel; | ||
protected Preferences ice_leaf_prefs; | ||
protected IceLeaf ice_leaf; | ||
|
||
protected JTextArea status_box; | ||
protected JTextArea message_box; | ||
|
||
|
||
public BasePanel(IceLeaf ice_leaf) | ||
{ | ||
this.ice_leaf = ice_leaf; | ||
ice_leaf_prefs = ice_leaf.getPrefs(); | ||
GridBagLayout grid_bag = new GridBagLayout(); | ||
panel = new JPanel(grid_bag); | ||
outer_panel = new JScrollPane(panel); | ||
|
||
panel.setBackground(ice_leaf.getBGColor()); | ||
status_box = new JTextArea(); | ||
message_box = new JTextArea(); | ||
|
||
} | ||
|
||
public abstract void setupPanel(); | ||
|
||
public void setup() | ||
{ | ||
setupPanel(); | ||
|
||
GridBagConstraints c = new GridBagConstraints(); | ||
c.gridheight = 1; | ||
c.gridwidth = GridBagConstraints.REMAINDER; | ||
c.anchor = GridBagConstraints.NORTHWEST; | ||
|
||
c.weightx=0.0; | ||
c.weighty=0.0; | ||
|
||
panel.add(new JLabel("Status:"),c); | ||
|
||
status_box.setEditable(false); | ||
panel.add(status_box,c); | ||
|
||
panel.add(new JLabel("Message:"),c); | ||
|
||
message_box.setEditable(false); | ||
panel.add(message_box,c); | ||
|
||
c.anchor = GridBagConstraints.SOUTHEAST; | ||
c.weightx=1.0; | ||
c.weighty=1.0; | ||
panel.add(new JLabel("Snowblossom"),c); | ||
} | ||
|
||
public JComponent getPanel(){return outer_panel;} | ||
|
||
public void setMessageBox(String text) | ||
{ | ||
SwingUtilities.invokeLater(new Runnable() { | ||
public void run() | ||
{ | ||
message_box.setText(text); | ||
} | ||
}); | ||
} | ||
|
||
public void setStatusBox(String text) | ||
{ | ||
SwingUtilities.invokeLater(new Runnable() { | ||
public void run() | ||
{ | ||
status_box.setText(text); | ||
} | ||
}); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.