Skip to content

Commit

Permalink
Merge pull request #1150 from Marketcetera/MATP-1151
Browse files Browse the repository at this point in the history
MATP-1151 Provide a human-readable FIX Session status rendering
  • Loading branch information
colinduplantis committed Apr 11, 2023
2 parents 2ae6a4f + 6adf14b commit a7f25f3
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang3.StringUtils;

/* $License$ */

/**
Expand Down Expand Up @@ -95,12 +97,37 @@ public boolean isLoggedOn()
* @return a <code>String</code> value
*/
public String getHumanReadable()
{
return humanReadableName;
}
/**
* Generate a human readable version of the value.
*
* @return a <code>String</code> 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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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 <code>TableColumn&lt;DisplayFixSession,FixSessionStatus&gt;</code> value
* @return a <code>TableCell&lt;DisplayFixSession,FixSessionStatus&gt;</code> value
*/
protected TableCell<DisplayFixSession,FixSessionStatus> renderFixSessionStatusCell(TableColumn<DisplayFixSession,FixSessionStatus> inTableColumn)
{
TableCell<DisplayFixSession,FixSessionStatus> 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.
*
Expand Down

0 comments on commit a7f25f3

Please sign in to comment.