diff --git a/fix/fix-api/src/main/java/org/marketcetera/fix/FixSessionStatus.java b/fix/fix-api/src/main/java/org/marketcetera/fix/FixSessionStatus.java index ae6f534b18..d83bf2f6ef 100644 --- a/fix/fix-api/src/main/java/org/marketcetera/fix/FixSessionStatus.java +++ b/fix/fix-api/src/main/java/org/marketcetera/fix/FixSessionStatus.java @@ -5,6 +5,8 @@ import javax.xml.bind.annotation.XmlRootElement; +import org.apache.commons.lang3.StringUtils; + /* $License$ */ /** @@ -95,12 +97,37 @@ public boolean isLoggedOn() * @return a String value */ public String getHumanReadable() + { + return humanReadableName; + } + /** + * Generate a human readable version of the value. + * + * @return a String value + */ + private String generateHumanReadable() { String name = name(); name = name.toLowerCase(); name = name.replaceAll("_"," "); + StringBuilder output = new StringBuilder(); + for(String component : name.split(" ")) { + output.append(StringUtils.capitalize(component)).append(" "); + } + name = StringUtils.trim(output.toString()); return name; } + /** + * Create a new FixSessionStatus instance. + */ + private FixSessionStatus() + { + humanReadableName = generateHumanReadable(); + } + /** + * stored human-readable version of the status + */ + private final String humanReadableName; /** * contains the statuses that indicate if a session is started or not */ diff --git a/photon/src/main/java/org/marketcetera/ui/fix/view/FixSessionView.java b/photon/src/main/java/org/marketcetera/ui/fix/view/FixSessionView.java index eccb1f8bee..3801ee9244 100644 --- a/photon/src/main/java/org/marketcetera/ui/fix/view/FixSessionView.java +++ b/photon/src/main/java/org/marketcetera/ui/fix/view/FixSessionView.java @@ -73,6 +73,7 @@ import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.SelectionMode; +import javafx.scene.control.TableCell; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.Tooltip; @@ -277,6 +278,7 @@ private void initializeColumns() hostIdTableColumn.setCellValueFactory(new PropertyValueFactory<>("hostId")); statusTableColumn = new TableColumn<>("Status"); statusTableColumn.setCellValueFactory(new PropertyValueFactory<>("status")); + statusTableColumn.setCellFactory(tableColumn -> renderFixSessionStatusCell(tableColumn)); senderSequenceNumberTableColumn = new TableColumn<>("Sender Seq Num"); senderSequenceNumberTableColumn.setCellValueFactory(new PropertyValueFactory<>("senderSeqNum")); targetSequenceNumberTableColumn = new TableColumn<>("Target Seq Num"); @@ -288,6 +290,30 @@ private void initializeColumns() fixSessionsTable.getColumns().add(senderSequenceNumberTableColumn); fixSessionsTable.getColumns().add(targetSequenceNumberTableColumn); } + /** + * Render the given column as a FIX status cell. + * + * @param inTableColumn a TableColumn<DisplayFixSession,FixSessionStatus> value + * @return a TableCell<DisplayFixSession,FixSessionStatus> value + */ + protected TableCell renderFixSessionStatusCell(TableColumn inTableColumn) + { + TableCell tableCell = new TableCell<>() { + @Override + protected void updateItem(FixSessionStatus inItem, + boolean isEmpty) + { + super.updateItem(inItem, + isEmpty); + this.setText(null); + this.setGraphic(null); + if(!isEmpty && inItem != null){ + this.setText(inItem.getHumanReadable()); + } + } + }; + return tableCell; + } /** * Perform the context menu session action according to the given parameters. *