Skip to content

Commit

Permalink
More GUI refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed May 1, 2024
1 parent f598a56 commit 24be670
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import convex.core.data.Cells;
import convex.core.lang.RT;
import convex.core.text.Text;
import convex.gui.components.models.StateModel;
import convex.gui.models.StateModel;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import convex.core.data.AccountStatus;
import convex.core.data.Address;
import convex.gui.components.AbstractGUI;
import convex.gui.components.models.StateModel;
import convex.gui.models.StateModel;
import convex.gui.peer.windows.state.StateTreePanel;
import net.miginfocom.swing.MigLayout;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import convex.core.data.Symbol;
import convex.gui.components.ScrollyList;
import convex.gui.components.account.AccountChooserPanel;
import convex.gui.components.models.StateModel;
import convex.gui.models.StateModel;
import net.miginfocom.swing.MigLayout;

@SuppressWarnings("serial")
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/actor/OraclePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import convex.gui.components.CodeLabel;
import convex.gui.components.DefaultReceiveAction;
import convex.gui.components.Toast;
import convex.gui.components.models.OracleTableModel;
import convex.gui.models.OracleTableModel;
import convex.gui.utils.Toolkit;

@SuppressWarnings("serial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
Expand Down Expand Up @@ -34,10 +35,13 @@
import convex.gui.components.ActionPanel;
import convex.gui.components.BalanceLabel;
import convex.gui.components.Identicon;
import convex.gui.components.models.AccountsTableModel;
import convex.gui.components.models.StateModel;
import convex.gui.models.AccountsTableModel;
import convex.gui.models.StateModel;
import convex.gui.utils.Toolkit;

/**
* Panel showing account information
*/
@SuppressWarnings({ "serial"})
public class AccountsPanel extends JPanel {
AccountsTableModel tableModel;
Expand Down Expand Up @@ -103,12 +107,13 @@ public AccountsPanel(Convex convex,StateModel<State> model) {
{
CellRenderer cr=new CellRenderer(JLabel.LEFT);
cr.setToolTipText("Address of the Convex account. This is the unique ID for the account");
cr.setForeground(Color.WHITE);
table.getColumnModel().getColumn(0).setCellRenderer(cr);
table.getColumnModel().getColumn(0).setPreferredWidth(80);
}

{
CellRenderer actorRenderer = new CellRenderer(JLabel.CENTER);
CellRenderer actorRenderer = new CellRenderer(JLabel.LEFT);
actorRenderer.setToolTipText("An Actor account is an autonomous agent or code library on the CVM. A User account can be controlled by a user with the correct key pair.");
table.getColumnModel().getColumn(1).setPreferredWidth(70);
table.getColumnModel().getColumn(1).setCellRenderer(actorRenderer);
Expand All @@ -125,7 +130,7 @@ public AccountsPanel(Convex convex,StateModel<State> model) {
BalanceRenderer cr=new BalanceRenderer();
cr.setToolTipText("Balance of the account in Convex Coins");
table.getColumnModel().getColumn(3).setCellRenderer(cr);
table.getColumnModel().getColumn(3).setPreferredWidth(200);
table.getColumnModel().getColumn(3).setPreferredWidth(180);
}

{
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/etch/EtchExplorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import convex.core.store.Stores;
import convex.gui.components.AbstractGUI;
import convex.gui.components.models.StateModel;
import convex.gui.models.StateModel;
import etch.EtchStore;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package convex.gui.components.models;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
package convex.gui.models;

import convex.core.State;
import convex.core.data.ACell;
Expand All @@ -14,7 +11,7 @@
import convex.core.util.Utils;

@SuppressWarnings("serial")
public class AccountsTableModel extends AbstractTableModel implements TableModel {
public class AccountsTableModel extends BaseTableModel {

private State state;

Expand Down Expand Up @@ -48,6 +45,7 @@ public boolean isCellEditable(int row, int col) {
@SuppressWarnings("unchecked")
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
// TODO: should probably be flexible columns rather than hardcoded
Address address = Address.create(rowIndex);
AccountStatus as = getEntry(rowIndex);
switch (columnIndex) {
Expand Down
5 changes: 5 additions & 0 deletions convex-gui/src/main/java/convex/gui/models/BaseColumn.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package convex.gui.models;

public class BaseColumn {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package convex.gui.models;

import javax.swing.table.AbstractTableModel;

@SuppressWarnings("serial")
public abstract class BaseTableModel extends AbstractTableModel {

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package convex.gui.components.models;
package convex.gui.models;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

import convex.core.State;
Expand All @@ -17,7 +16,7 @@
* Model for the Oracle table
*/
@SuppressWarnings("serial")
public class OracleTableModel extends AbstractTableModel implements TableModel {
public class OracleTableModel extends BaseTableModel implements TableModel {

private State state;
private Address oracle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package convex.gui.components.models;
package convex.gui.models;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package convex.gui.components.models;
package convex.gui.models;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import javax.swing.table.AbstractTableModel;

import convex.core.State;
import convex.core.data.ACell;
import convex.core.data.AMap;
Expand All @@ -17,7 +15,7 @@
import convex.core.lang.Reader;

@SuppressWarnings("serial")
public class TorusTableModel extends AbstractTableModel{
public class TorusTableModel extends BaseTableModel {

protected State state;
protected Address torus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import convex.gui.components.CodeLabel;
import convex.gui.components.DropdownMenu;
import convex.gui.components.Identicon;
import convex.gui.components.models.StateModel;
import convex.gui.etch.EtchWindow;
import convex.gui.models.StateModel;
import convex.gui.peer.windows.PeerWindow;
import convex.gui.peer.windows.state.StateExplorer;
import convex.gui.utils.Toolkit;
Expand Down
2 changes: 1 addition & 1 deletion convex-gui/src/main/java/convex/gui/peer/PeerGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
import convex.gui.components.Toast;
import convex.gui.components.account.AccountsPanel;
import convex.gui.components.account.KeyPairCombo;
import convex.gui.components.models.StateModel;
import convex.gui.keys.KeyGenPanel;
import convex.gui.keys.KeyRingPanel;
import convex.gui.models.StateModel;
import convex.gui.peer.mainpanels.AboutPanel;
import convex.gui.peer.mainpanels.MessageFormatPanel;
import convex.gui.peer.mainpanels.PeersListPanel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import convex.core.State;
import convex.gui.components.ActionButton;
import convex.gui.components.ActionPanel;
import convex.gui.components.models.TorusTableModel;
import convex.gui.models.TorusTableModel;
import convex.gui.peer.PeerGUI;
import convex.gui.utils.Toolkit;

Expand Down

0 comments on commit 24be670

Please sign in to comment.