Skip to content
Snippets Groups Projects
Unverified Commit d681cea7 authored by David Bohn's avatar David Bohn
Browse files

Prettified server GUI

parent e7eba789
Branches
No related tags found
1 merge request!3Preliminary result of the software
......@@ -15,6 +15,5 @@ public class ActionJoin extends ClientAction {
aja.someNeighbors.putAll(node.getKnownNeighbors());
System.out.println("Answer to " + sender.path().name());
sender.tell(aja, self);
//node.addKnownNeighbor(sender.path().name(), sender);
}
}
......@@ -32,12 +32,6 @@ public class ActionPrepareDistributedCommittedTransfer extends Transaction {
//sender have enough money
&& wallet.amounts.getOrDefault(source, 0) >= amount));
if (granted) {
wallet.log("I do grant transaction.");
} else {
wallet.log("I do not grant.");
}
sender.tell(new ActionPrepareDistributedCommittedTransferAnswer(source, target, amount, timestamp, granted, id), self);
}
......
......@@ -11,6 +11,10 @@ public class SuperVisorGuiControlImpl implements SuperVisorGuiControl {
private SuperVisorImpl superVisor;
private JFrame frame;
private DefaultListModel<String> log = new DefaultListModel<>();
private JList<String> txtLog = new JList<>(log);
private JScrollPane logPane = new JScrollPane(txtLog);
public SuperVisorGuiControlImpl(SuperVisorImpl sv) {
superVisor = sv;
init();
......@@ -19,31 +23,27 @@ public class SuperVisorGuiControlImpl implements SuperVisorGuiControl {
private void init() {
//Show AWT window for runtime information
frame = new JFrame("Server");
frame.setLayout(new GridLayout(3, 2));
frame.add(new Label("All Amounts:"));
JPanel contentPanel = new JPanel();
contentPanel.setLayout(new GridLayout(2, 1));
//Init Amount Table and SuperVisorImpl
JTable amountListView = new JTable(superVisor.getAmountTableModel());
Label averageAmountLbl = new Label("Average Amounts:");
frame.add(new JScrollPane(amountListView));
frame.add(new Label("Average Amounts:"));
frame.add(averageAmountLbl);
contentPanel.add(new JScrollPane(amountListView));
contentPanel.add(logPane);
//Call update on supervisor
JButton updateBtn = new JButton("Update");
updateBtn.addActionListener(e -> superVisor.updateValues());
frame.add(updateBtn);
frame.add(contentPanel, BorderLayout.CENTER);
//Exit Button and shutdown supervisor
JButton exitBtn = new JButton("exit");
JButton exitBtn = new JButton("Stop Supervisor");
exitBtn.addActionListener(e -> {
superVisor.exit();
frame.setVisible(false);
frame.dispose();
});
frame.add(exitBtn);
frame.setSize(200, 400);
frame.add(exitBtn, BorderLayout.PAGE_END);
frame.setSize(800, 600);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() {
......@@ -64,6 +64,12 @@ public class SuperVisorGuiControlImpl implements SuperVisorGuiControl {
public void log(String message) {
// One day, we may have a server log GUI as well..
// Until then, we just print it to the console
System.out.println(message);
//System.out.println(message);
SwingUtilities.invokeLater(() -> {
log.addElement(message);
// auto scroll to the bottom
txtLog.ensureIndexIsVisible(log.size() - 1);
});
}
}
......@@ -36,12 +36,10 @@ public class WalletImpl extends AbstractWallet {
this.remoteSuperVisorActor = remoteSuperVisorActor;
if(remoteSuperVisorActor == null){
String path = JOptionPane.showInputDialog(null, "Enter a supervisor address: ");
String path = JOptionPane.showInputDialog(null, "Enter a neighbour node address: ");
System.out.println(path);
ActorSelection selection = getContext().actorSelection(path);
//this.setRemoteSuperVisorActor(selection.anchor());
selection.tell(new ActionJoin(), self());
//selection.tell("Hallo!", self());
}
}
......@@ -73,10 +71,6 @@ public class WalletImpl extends AbstractWallet {
((ClientAction) message).doAction(this);
}
/*if (message instanceof ActionJoin){
((ActionJoin) message).doAction(this);
}*/
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment