Skip to content

Commit

Permalink
Improve printing operations locomotive roster
Browse files Browse the repository at this point in the history
  • Loading branch information
danielboudreau authored and danielboudreau committed Aug 12, 2019
1 parent db6a5e0 commit 79afe06
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 100 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ load = load


BorderLayoutOptional = Optional BorderLayoutOptional = Optional
BorderLayoutBlockingOrder = Blocking Order BorderLayoutBlockingOrder = Blocking Order
BorderLayoutOrientation = Orientation
BorderLayoutFontSize = Font Size
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ BorderLayoutOptionalPickup = Optional Load Pick Up Car Message
BorderLayoutReturnWhenEmpty = Return When Empty BorderLayoutReturnWhenEmpty = Return When Empty


BorderLayoutLoadType = Load Type BorderLayoutLoadType = Load Type
BorderLayoutOrientation = Orientation

BorderLayoutFontSize = Font Size


# caboose, FRED, hazardous, utility abbreviations # caboose, FRED, hazardous, utility abbreviations
(C) = (C) (C) = (C)
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ public void initComponents() {
} }


private void loadSortByComboBox(JComboBox<String> box) { private void loadSortByComboBox(JComboBox<String> box) {
box.removeAllItems();
for (int i = panel.carsTableModel.SORTBY_NUMBER; i <= panel.carsTableModel.SORTBY_LAST; i++) { for (int i = panel.carsTableModel.SORTBY_NUMBER; i <= panel.carsTableModel.SORTBY_LAST; i++) {
box.addItem(panel.carsTableModel.getSortByName(i)); box.addItem(panel.carsTableModel.getSortByName(i));
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/ */
public class EnginesTableFrame extends OperationsFrame implements PropertyChangeListener { public class EnginesTableFrame extends OperationsFrame implements PropertyChangeListener {


EnginesTableModel enginesModel; public EnginesTableModel enginesModel;
javax.swing.JTable enginesTable; javax.swing.JTable enginesTable;
JScrollPane enginesPane; JScrollPane enginesPane;
EngineManager engineManager = InstanceManager.getDefault(EngineManager.class); EngineManager engineManager = InstanceManager.getDefault(EngineManager.class);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ public EnginesTableModel() {
updateList(); updateList();
} }


public final int SORTBY_NUMBER = 1; public final int SORTBY_NUMBER = 0;
public final int SORTBY_ROAD = 2; public final int SORTBY_ROAD = 1;
public final int SORTBY_MODEL = 3; public final int SORTBY_MODEL = 2;
public final int SORTBY_LOCATION = 4; public final int SORTBY_LOCATION = 3;
public final int SORTBY_DESTINATION = 5; public final int SORTBY_DESTINATION = 4;
public final int SORTBY_TRAIN = 6; public final int SORTBY_TRAIN = 5;
public final int SORTBY_MOVES = 7; public final int SORTBY_MOVES = 6;
public final int SORTBY_CONSIST = 8; public final int SORTBY_CONSIST = 7;
public final int SORTBY_BUILT = 9; public final int SORTBY_BUILT = 8;
public final int SORTBY_OWNER = 10; public final int SORTBY_OWNER = 9;
public final int SORTBY_VALUE = 11; public final int SORTBY_VALUE = 10;
public final int SORTBY_RFID = 12; public final int SORTBY_RFID = 11;
public final int SORTBY_LAST = 13; public final int SORTBY_LAST = 12;
public final int SORTBY_HP = 14; public final int SORTBY_HP = 13;
public final int SORTBY_DCC_ADDRESS = 15; public final int SORTBY_DCC_ADDRESS = 14;


private int _sort = SORTBY_NUMBER; private int _sort = SORTBY_NUMBER;


Expand Down Expand Up @@ -107,6 +107,47 @@ public void setSort(int sort) {
fireTableDataChanged(); fireTableDataChanged();
} }


public String getSortByName() {
return getSortByName(_sort);
}

public String getSortByName(int sort) {
switch (sort) {
case SORTBY_NUMBER:
return Bundle.getMessage("Number");
case SORTBY_ROAD:
return Bundle.getMessage("Road");
case SORTBY_MODEL:
return Bundle.getMessage("Model");
case SORTBY_LOCATION:
return Bundle.getMessage("Location");
case SORTBY_DESTINATION:
return Bundle.getMessage("Destination");
case SORTBY_TRAIN:
return Bundle.getMessage("Train");
case SORTBY_MOVES:
return Bundle.getMessage("Moves");
case SORTBY_CONSIST:
return Bundle.getMessage("Consist");
case SORTBY_BUILT:
return Bundle.getMessage("Built");
case SORTBY_OWNER:
return Bundle.getMessage("Owner");
case SORTBY_DCC_ADDRESS:
return Bundle.getMessage("DccAddress");
case SORTBY_HP:
return Bundle.getMessage("HP");
case SORTBY_VALUE:
return Setup.getValueLabel();
case SORTBY_RFID:
return Setup.getRfidLabel();
case SORTBY_LAST:
return Bundle.getMessage("Last");
default:
return "Error"; // NOI18N
}
}

String _roadNumber = ""; String _roadNumber = "";
int _index = 0; int _index = 0;


Expand Down Expand Up @@ -173,33 +214,53 @@ private void updateList() {
} }


public List<Engine> getSelectedEngineList() { public List<Engine> getSelectedEngineList() {
return getEngineList(_sort);
}

public List<Engine> getEngineList(int sort) {
List<Engine> list; List<Engine> list;
if (_sort == SORTBY_ROAD) { switch (sort) {
list = engineManager.getByRoadNameList(); case SORTBY_NUMBER:
} else if (_sort == SORTBY_MODEL) { list = engineManager.getByNumberList();
list = engineManager.getByModelList(); break;
} else if (_sort == SORTBY_LOCATION) { case SORTBY_ROAD:
list = engineManager.getByLocationList(); list = engineManager.getByRoadNameList();
} else if (_sort == SORTBY_DESTINATION) { break;
list = engineManager.getByDestinationList(); case SORTBY_MODEL:
} else if (_sort == SORTBY_TRAIN) { list = engineManager.getByModelList();
list = engineManager.getByTrainList(); break;
} else if (_sort == SORTBY_MOVES) { case SORTBY_LOCATION:
list = engineManager.getByMovesList(); list = engineManager.getByLocationList();
} else if (_sort == SORTBY_CONSIST) { break;
list = engineManager.getByConsistList(); case SORTBY_DESTINATION:
} else if (_sort == SORTBY_OWNER) { list = engineManager.getByDestinationList();
list = engineManager.getByOwnerList(); break;
} else if (_sort == SORTBY_BUILT) { case SORTBY_TRAIN:
list = engineManager.getByBuiltList(); list = engineManager.getByTrainList();
} else if (_sort == SORTBY_VALUE) { break;
list = engineManager.getByValueList(); case SORTBY_MOVES:
} else if (_sort == SORTBY_RFID) { list = engineManager.getByMovesList();
list = engineManager.getByRfidList(); break;
} else if (_sort == SORTBY_LAST) { case SORTBY_CONSIST:
list = engineManager.getByLastDateList(); list = engineManager.getByConsistList();
} else { break;
list = engineManager.getByNumberList(); case SORTBY_OWNER:
list = engineManager.getByOwnerList();
break;
case SORTBY_BUILT:
list = engineManager.getByBuiltList();
break;
case SORTBY_VALUE:
list = engineManager.getByValueList();
break;
case SORTBY_RFID:
list = engineManager.getByRfidList();
break;
case SORTBY_LAST:
list = engineManager.getByLastDateList();
break;
default:
list = engineManager.getByNumberList();
} }
return list; return list;
} }
Expand Down
Loading

0 comments on commit 79afe06

Please sign in to comment.