Skip to content

Commit

Permalink
minor layout cleanup, add @overrride, no intended functional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bobjacobsen committed Jan 29, 2019
1 parent ff27c57 commit 897aa9f
Showing 1 changed file with 79 additions and 99 deletions.
178 changes: 79 additions & 99 deletions java/src/jmri/jmrix/cmri/serial/serialmon/SerialFilterFrame.java
Expand Up @@ -110,13 +110,14 @@ public SerialFilterFrame(CMRISystemConnectionMemo memo) {
/**
* {@inheritDoc}
*/
@Override
public void initComponents() {
initializeNodes();

// For the class
setLayout(new FlowLayout(FlowLayout.LEFT));
setPreferredSize(new Dimension(620,375));
// setBackground(Color.LIGHT_GRAY);
// setBackground(Color.LIGHT_GRAY);

// Set up the node filter enable table
//------------------------------------
Expand Down Expand Up @@ -216,22 +217,22 @@ public void initComponents() {
enableSelectButtons.add(nodeMonitorAll);
nodeMonitorAll.setVisible(true);
nodeMonitorAll.setToolTipText(Bundle.getMessage("AllButtonTip") );
nodeMonitorAll.addActionListener(new java.awt.event.ActionListener()
{
nodeMonitorAll.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
nodeMonitorAllButtonActionPerformed();
}
nodeMonitorAllButtonActionPerformed();
}
});

enableSelectButtons.add(nodeMonitorNone);
nodeMonitorNone.setVisible(true);
nodeMonitorNone.setToolTipText(Bundle.getMessage("NoneButtonTip") );
nodeMonitorNone.addActionListener(new java.awt.event.ActionListener()
{
nodeMonitorNone.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
nodeMonitorNoneButtonActionPerformed();
}
});
});

add(enableSelectButtons);

Expand All @@ -247,22 +248,22 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
packetSelectButtons.add(packetMonitorAll);
packetMonitorAll.setVisible(true);
packetMonitorAll.setToolTipText(Bundle.getMessage("AllButtonTip") );
packetMonitorAll.addActionListener(new java.awt.event.ActionListener()
{
packetMonitorAll.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
packetMonitorAllButtonActionPerformed();
}
});
});

packetSelectButtons.add(packetMonitorNone);
packetMonitorNone.setVisible(true);
packetMonitorNone.setToolTipText(Bundle.getMessage("NoneButtonTip") );
packetMonitorNone.addActionListener(new java.awt.event.ActionListener()
{
packetMonitorNone.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
packetMonitorNoneButtonActionPerformed();
}
});
});

add(packetSelectButtons);

Expand All @@ -274,25 +275,25 @@ public void actionPerformed(java.awt.event.ActionEvent e) {

haltPollButton.setVisible(true);
haltPollButton.setToolTipText(Bundle.getMessage("HaltPollButtonTip") );
haltPollButton.addActionListener(new java.awt.event.ActionListener()
{
haltPollButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
haltpollButtonActionPerformed(e);
}
});
mainButtons.add(haltPollButton);
mainButtons.add(haltPollButton);

mainButtons.add(Box.createRigidArea(new Dimension(30,0)));

doneButton.setVisible(true);
doneButton.setToolTipText(Bundle.getMessage("DoneButtonTip") );
doneButton.addActionListener(new java.awt.event.ActionListener()
{
doneButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
doneButtonActionPerformed();
}
});
mainButtons.add(doneButton);
mainButtons.add(doneButton);
mainButtons.setVisible(true);
add(mainButtons);

Expand All @@ -307,57 +308,44 @@ public void actionPerformed(java.awt.event.ActionEvent e) {
/**
* Method to initialize configured nodes and set up the node select combo box
*/
public void initializeNodes() //c2
{
// get all configured nodes
// SerialNode aNode = (SerialNode) SerialTrafficController.instance().getNode(0);
public void initializeNodes() {
// get all configured nodes
SerialNode node = (SerialNode) _memo.getTrafficController().getNode(0);
int index = 1;
while (node != null)
{
while (node != null) {
monitorNode.add(node);
// aNode = (SerialNode) SerialTrafficController.instance().getNode(index);
node = (SerialNode) _memo.getTrafficController().getNode(index);
index ++;

}
}
}

/**setMonitorNodePackets
*
*/
public void nodeMonitorAllButtonActionPerformed()
{
for(int i=0; i<monitorNode.size(); i++)
{
monitorNode.get(i).setMonitorNodePackets(false);
nodeTableModel.setValueAt(monitorNode.get(i).getMonitorNodePackets(), i, NodeTableModel.ENABLED_COLUMN);
}
public void nodeMonitorAllButtonActionPerformed() {
for(int i=0; i<monitorNode.size(); i++) {
monitorNode.get(i).setMonitorNodePackets(false);
nodeTableModel.setValueAt(monitorNode.get(i).getMonitorNodePackets(), i, NodeTableModel.ENABLED_COLUMN);
}
}

public void nodeMonitorNoneButtonActionPerformed()
{
for(int i=0; i<monitorNode.size(); i++)
{
monitorNode.get(i).setMonitorNodePackets(true);
nodeTableModel.setValueAt(monitorNode.get(i).getMonitorNodePackets(), i, NodeTableModel.ENABLED_COLUMN);
}
public void nodeMonitorNoneButtonActionPerformed() {
for(int i=0; i<monitorNode.size(); i++) {
monitorNode.get(i).setMonitorNodePackets(true);
nodeTableModel.setValueAt(monitorNode.get(i).getMonitorNodePackets(), i, NodeTableModel.ENABLED_COLUMN);
}
}

public void packetMonitorAllButtonActionPerformed()
{
for (int i=0; i<lastStdPkt; i++)
{
packetChkBoxes.get(i).setSelected(true);
}
public void packetMonitorAllButtonActionPerformed() {
for (int i=0; i<lastStdPkt; i++) {
packetChkBoxes.get(i).setSelected(true);
}
}

public void packetMonitorNoneButtonActionPerformed()
{
for (int i=0; i<lastStdPkt; i++)
{
packetChkBoxes.get(i).setSelected(false);
}
public void packetMonitorNoneButtonActionPerformed() {
for (int i=0; i<lastStdPkt; i++) {
packetChkBoxes.get(i).setSelected(false);
}
}

public void doneButtonActionPerformed() {
Expand All @@ -369,17 +357,13 @@ public void doneButtonActionPerformed() {
/* Halt Poll button handler */
/* ---------------------------- */
public void haltpollButtonActionPerformed(ActionEvent e) {
SerialTrafficController stc = _memo.getTrafficController();
// SerialTrafficController stc = SerialTrafficController._memo();
stc.setPollNetwork(!stc.getPollNetwork());
if (stc.getPollNetwork())
{
haltPollButton.setText(Bundle.getMessage("HaltPollingText"));
}
else
{
haltPollButton.setText(Bundle.getMessage("StartPollingText"));
}
SerialTrafficController stc = _memo.getTrafficController();
stc.setPollNetwork(!stc.getPollNetwork());
if (stc.getPollNetwork()) {
haltPollButton.setText(Bundle.getMessage("HaltPollingText"));
} else {
haltPollButton.setText(Bundle.getMessage("StartPollingText"));
}
}

// -------------------------------
Expand All @@ -388,33 +372,31 @@ public void haltpollButtonActionPerformed(ActionEvent e) {
private class HandlerClass implements ItemListener{
public void itemStateChanged(ItemEvent e){
JCheckBox pktTypeChkBox = (JCheckBox) e.getSource();
int pktTypeIndex = 0;
int pktTypeIndex = 0;
SerialNode aNode = null;
do
{
if (pktTypeChkBox == packetChkBoxes.get(pktTypeIndex))
{
for (int i=0; i < monitorNode.size(); i++)
{
aNode = monitorNode.get(i);
if (aNode != null)
{
aNode.setMonitorPacketBit(pktTypeIndex,(packetChkBoxes.get(pktTypeIndex).isSelected() ? true : false));
}
do {
if (pktTypeChkBox == packetChkBoxes.get(pktTypeIndex)) {
for (int i=0; i < monitorNode.size(); i++) {
aNode = monitorNode.get(i);
if (aNode != null) {
aNode.setMonitorPacketBit(pktTypeIndex,(packetChkBoxes.get(pktTypeIndex).isSelected() ? true : false));
}
}
return;
}
return;
}
pktTypeIndex++;
}
while ( pktTypeIndex < numMonPkts);
pktTypeIndex++;
} while ( pktTypeIndex < numMonPkts);
}
}
/**
* Set up table for displaying bit assignments
*/
public class NodeTableModel extends AbstractTableModel
{
public String getColumnName(int c) {return nodeEnableColumnsNames[c];}
public class NodeTableModel extends AbstractTableModel {
@Override
public String getColumnName(int c) {
return nodeEnableColumnsNames[c];
}
@Override
public Class<?> getColumnClass(int c) {
switch (c) {
case NODEADDR_COLUMN:
Expand All @@ -423,33 +405,31 @@ public Class<?> getColumnClass(int c) {
return Boolean.class;
}
}
public boolean isCellEditable(int r,int c) {
if(c!=NODEADDR_COLUMN) return true;

@Override
public boolean isCellEditable(int r,int c) {
if (c!=NODEADDR_COLUMN) return true;
else return false;
}
public int getColumnCount () {return NUMCOLUMNS;}
public int getRowCount () {return monitorNode.size();}
public Object getValueAt (int r,int c)
{

if (c==NODEADDR_COLUMN)
{
if (c==NODEADDR_COLUMN) {
return monitorNode.get(r).getNodeAddress();
}
else if (c==ENABLED_COLUMN)
{
} else if (c==ENABLED_COLUMN) {
if (monitorNode.get(r).getMonitorNodePackets())
return true;
else
return false;
}
else
{
return true;
} else {
return true;
}
}

public void setValueAt(Object value, int r, int c) {
@Override
public void setValueAt(Object value, int r, int c) {
if (c==NODEADDR_COLUMN) {
monitorNode.get(r).setPollListPosition((Integer)value);
}
Expand All @@ -462,7 +442,7 @@ else if (c == ENABLED_COLUMN) {
public static final int NODEADDR_COLUMN = 0;
public static final int ENABLED_COLUMN = 1;
public static final int NUMCOLUMNS = ENABLED_COLUMN+1;
}
}

private String[] nodeEnableColumnsNames = {"Node","Monitor"};

Expand Down

0 comments on commit 897aa9f

Please sign in to comment.