Skip to content
Snippets Groups Projects
Commit 3a406e06 authored by Danni Otterbach's avatar Danni Otterbach
Browse files

Merge branch 'dev-group3-qdigest' of...

Merge branch 'dev-group3-qdigest' of https://git.imp.fu-berlin.de/DistributedSystems4Students/FUCoin into dev-group3-qdigest

Conflicts:
	src/main/java/fucoin/gui/WalletGuiControlImpl.java
parents d2fa98d7 4b926432
No related branches found
No related tags found
No related merge requests found
...@@ -181,10 +181,40 @@ public abstract class AbstractNode extends UntypedActor implements Serializable ...@@ -181,10 +181,40 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
* @return Array[snapshot folder name, path to snapshot include filename] * @return Array[snapshot folder name, path to snapshot include filename]
*/ */
private String[] getSnapshotDirAndFilename(String name, LocalDateTime time) { private String[] getSnapshotDirAndFilename(String name, LocalDateTime time) {
String folder = time.getYear() + "-" + time.getMonthValue() + "-" + time.getDayOfMonth() + " " + String folder = getFolderName(time);
time.getHour() + "." + time.getMinute() + "." + time.getSecond();
return new String[]{folder, "snapshots/" + folder + "/" + name + ".json"}; return new String[]{folder, "snapshots/" + folder + "/" + name + ".json"};
} }
private String getFolderName(LocalDateTime time) {
String result = "";
String year = String.valueOf(time.getYear());
String month = String.valueOf(time.getMonthValue());
if(month.length()==1) {
month = "0" + month;
}
String day = String.valueOf(time.getDayOfMonth());
if(day.length()==1) {
day = "0" + day;
}
String hour = String.valueOf(time.getHour());
if(hour.length()==1) {
hour = "0" + day;
}
String minute = String.valueOf(time.getMinute());
if(minute.length()==1) {
minute = "0" + minute;
}
String second = String.valueOf(time.getSecond());
if(second.length()==1) {
second = "0" + second;
}
result = year + "-" + month + "-" + day + "_"
+ hour + "-" + minute + "-" + second;
return result;
}
private Statistics statistics = new Statistics(); private Statistics statistics = new Statistics();
......
...@@ -12,6 +12,7 @@ import java.time.LocalDate; ...@@ -12,6 +12,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Set; import java.util.Set;
import java.text.NumberFormat;
public class WalletGuiControlImpl implements WalletGuiControl { public class WalletGuiControlImpl implements WalletGuiControl {
...@@ -27,7 +28,7 @@ public class WalletGuiControlImpl implements WalletGuiControl { ...@@ -27,7 +28,7 @@ public class WalletGuiControlImpl implements WalletGuiControl {
private JLabel lblSendTo = new JLabel("Send to:"); private JLabel lblSendTo = new JLabel("Send to:");
private JComboBox<String> txtSendTo = new JComboBox<>(); private JComboBox<String> txtSendTo = new JComboBox<>();
private JLabel lblSendAmount = new JLabel("Amount:"); private JLabel lblSendAmount = new JLabel("Amount:");
private JTextField txtSendAmount = new JTextField(""); private JTextField txtSendAmount = new JFormattedTextField(NumberFormat.getNumberInstance());
private JButton btnSend = new JButton("Send"); private JButton btnSend = new JButton("Send");
private JButton btnSearch = new JButton("Search"); private JButton btnSearch = new JButton("Search");
private JButton btnStore = new JButton("Store"); private JButton btnStore = new JButton("Store");
...@@ -146,8 +147,13 @@ public class WalletGuiControlImpl implements WalletGuiControl { ...@@ -146,8 +147,13 @@ public class WalletGuiControlImpl implements WalletGuiControl {
window.setVisible(true); window.setVisible(true);
btnSend.addActionListener(e -> { btnSend.addActionListener(e -> {
wallet.send(txtSendTo.getSelectedItem().toString(), String sendAmount = txtSendAmount.getText();
Integer.parseInt(txtSendAmount.getText())); if(sendAmount.trim().equalsIgnoreCase("")) {
JOptionPane.showMessageDialog(new JFrame("Warning"), "You need to type a number of coins to send.");
} else {
wallet.send(txtSendTo.getSelectedItem().toString(),
Integer.parseInt(sendAmount));
}
}); });
btnStore.addActionListener(e -> { btnStore.addActionListener(e -> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment