Skip to content

Commit

Permalink
Merge pull request #209 from semuxgo/issue-206
Browse files Browse the repository at this point in the history
GUI: display gas price in transaction dialog
  • Loading branch information
semuxgo authored Jul 6, 2019
2 parents 70af338 + b050fd8 commit 57e3649
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 245 deletions.
2 changes: 0 additions & 2 deletions src/main/java/org/semux/config/DevnetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
package org.semux.config;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.collections4.MapUtils;
import org.semux.Network;
import org.semux.core.Fork;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/semux/gui/dialog/ConsoleDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import org.semux.gui.SemuxGui;
import org.semux.message.GuiMessages;
import org.semux.util.CircularFixedSizeList;
import org.semux.util.CommandParser;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import io.swagger.annotations.ApiOperation;
import org.semux.util.CommandParser;

public class ConsoleDialog extends JDialog implements ActionListener {

Expand Down
22 changes: 16 additions & 6 deletions src/main/java/org/semux/gui/dialog/TransactionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public TransactionDialog(JFrame parent, Transaction tx, TransactionResult result
JLabel lblData = new JLabel(GuiMessages.get("Data") + ":");

JLabel lblSucceeded = new JLabel(GuiMessages.get("Success"));
JLabel lblGasPrice = new JLabel(GuiMessages.get("GasPrice"));
JLabel lblGasProvided = new JLabel(GuiMessages.get("GasProvided"));
JLabel lblGasUsed = new JLabel(GuiMessages.get("GasUsed"));
JLabel lblOutput = new JLabel(GuiMessages.get("Output"));
Expand Down Expand Up @@ -70,6 +71,9 @@ public TransactionDialog(JFrame parent, Transaction tx, TransactionResult result
JLabel timestamp = new JLabel(SwingUtil.formatTimestamp(tx.getTimestamp()));
timestamp.setName("timestampText");

JLabel gasPrice = new JLabel(SwingUtil.formatAmount(tx.getGasPrice()));
gasPrice.setName("gasPriceText");

JLabel gasProvided = new JLabel(SwingUtil.formatNumber(tx.getGas()));
gasProvided.setName("gasProvidedText");

Expand Down Expand Up @@ -99,8 +103,9 @@ public TransactionDialog(JFrame parent, Transaction tx, TransactionResult result
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(lblOutput)
.addComponent(lblGasUsed)
.addComponent(lblGasProvided)
.addComponent(lblSucceeded)
.addComponent(lblGasProvided)
.addComponent(lblGasPrice)
.addComponent(lblData)
.addComponent(lblTimestamp)
.addComponent(lblNonce)
Expand All @@ -121,8 +126,9 @@ public TransactionDialog(JFrame parent, Transaction tx, TransactionResult result
.addComponent(nonce)
.addComponent(timestamp)
.addComponent(dataScroll, GroupLayout.PREFERRED_SIZE, 450, GroupLayout.PREFERRED_SIZE)
.addComponent(success)
.addComponent(gasPrice)
.addComponent(gasProvided)
.addComponent(success)
.addComponent(gasUsed)
.addComponent(outputScroll, GroupLayout.PREFERRED_SIZE, 450, GroupLayout.PREFERRED_SIZE))
.addContainerGap(19, Short.MAX_VALUE))
Expand Down Expand Up @@ -168,12 +174,16 @@ public TransactionDialog(JFrame parent, Transaction tx, TransactionResult result
.addComponent(dataScroll, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblSucceeded)
.addComponent(success))
.addComponent(lblGasPrice)
.addComponent(gasPrice))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblGasProvided)
.addComponent(gasProvided))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblGasProvided)
.addComponent(gasProvided))
.addComponent(lblSucceeded)
.addComponent(success))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblGasUsed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -200,7 +201,7 @@ public void setSelectedItem(Object anObject) {
T existing = getSelectedValue();
@SuppressWarnings("unchecked")
T newValue = (T) (anObject instanceof ComboBoxItem ? ((ComboBoxItem<T>) anObject).getValue() : anObject);
if (existing != newValue && (existing == null || !existing.equals(newValue))) {
if (!Objects.equals(existing, newValue)) {
super.setSelectedItem(anObject);
List<TransactionsPanel.StatusTransaction> filteredTransactions = getFilteredTransactions();
tableModel.setData(filteredTransactions);
Expand Down
Loading

0 comments on commit 57e3649

Please sign in to comment.