Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matp 1118 #1117

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public quickfix.Message newMarketDataRequest(String inRequestId,
NoRelatedSym.FIELD);
instrumentFunction.set(instrument,
fixDictionary,
quickfix.field.MsgType.ORDER_SINGLE,
quickfix.field.MsgType.MARKET_DATA_REQUEST,
symbolGroup);
// some weirdness for currencies
symbolGroup.removeField(quickfix.field.Currency.FIELD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.google.common.collect.Maps;

import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ContextMenu;
Expand Down Expand Up @@ -171,6 +172,7 @@ private void updateViewProperties()
private void initializeAddSymbol()
{
addSymbolLayout = new HBox(5);
addSymbolLayout.setPadding(new Insets(10,30,10,10));
addSymbolTextField = new TextField();
addSymbolButton = new Button();
addSymbolButton.setGraphic(new ImageView(new Image("images/add.png")));
Expand Down Expand Up @@ -291,13 +293,13 @@ private void initializeContextMenu()
}
try {
marketdataClient.cancel(marketDataItem.marketDataRequestIdProperty().get());
synchronized(symbolsByRequestId) {
symbolsByRequestId.remove(marketDataItem.marketDataRequestIdProperty().get());
}
} catch (Exception e) {
SLF4JLoggerProxy.warn(this,
e);
}
synchronized(symbolsByRequestId) {
symbolsByRequestId.remove(marketDataItem.marketDataRequestIdProperty().get());
}
marketDataTable.getItems().remove(marketDataItem);
updateViewProperties();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ public void onLogin(LoginEvent inEvent)
"Received {}, retrieved display layout: {}",
inEvent,
displayLayout);
WindowRegistry windowRegistry = getCurrentUserRegistry();
final WindowRegistry windowRegistry = getCurrentUserRegistry();
windowRegistry.restoreLayout(displayLayout);
PhotonApp.getPrimaryStage().widthProperty().addListener((observableValue,oldValue,newValue) -> {
windowRegistry.updateDisplayLayout();
});
PhotonApp.getPrimaryStage().heightProperty().addListener((observableValue,oldValue,newValue) -> {
windowRegistry.updateDisplayLayout();
});
}
/**
* Receive new window events.
Expand Down Expand Up @@ -314,6 +320,15 @@ private double getWorkspaceBottom()
{
return getWorkspaceTop() + getWorkspaceHeight();
}
private Properties getWorkspaceProperties()
{
Properties workspaceProperties = new Properties();
workspaceProperties.setProperty(workspaceHeightProp,
Double.toString(PhotonApp.getPrimaryStage().getHeight()));
workspaceProperties.setProperty(workspaceWidthProp,
Double.toString(PhotonApp.getPrimaryStage().getWidth()));
return workspaceProperties;
}
/**
* Event used to open a new window on restart.
*
Expand Down Expand Up @@ -850,11 +865,11 @@ private void close()
*/
private void show()
{
getMainLayout().translateXProperty().set(getX());
getMainLayout().translateYProperty().set(getY());
setViewOrder(-1);
Platform.runLater(() -> {
windowLayout.autosize();
getMainLayout().translateXProperty().set(getX());
getMainLayout().translateYProperty().set(getY());
setViewOrder(-1);
PhotonApp.getWorkspace().getChildren().add(getMainLayout());
requestFocus();
});
Expand Down Expand Up @@ -1123,9 +1138,32 @@ private boolean isPerfectSquare(double inValue)
*/
private void restoreLayout(Properties inDisplayLayout)
{
String rawWorkspaceProperties = inDisplayLayout.getProperty(workspaceLayout);
if(rawWorkspaceProperties != null) {
Properties workspaceProperties = Util.propertiesFromString(rawWorkspaceProperties);
Double desiredHeight = PhotonApp.getPrimaryStage().getHeight();
Double desiredWidth = PhotonApp.getPrimaryStage().getWidth();
String rawValue = workspaceProperties.getProperty(workspaceHeightProp);
if(rawValue != null) {
desiredHeight = Double.parseDouble(rawValue);
}
rawValue = workspaceProperties.getProperty(workspaceWidthProp);
if(rawValue != null) {
desiredWidth = Double.parseDouble(rawValue);
}
final Double mainStageWidth = desiredWidth;
final Double mainStageHeight = desiredHeight;
Platform.runLater(() -> {
PhotonApp.getPrimaryStage().setWidth(mainStageWidth);
PhotonApp.getPrimaryStage().setHeight(mainStageHeight);
});
}
synchronized(activeWindows) {
for(Map.Entry<Object,Object> entry : inDisplayLayout.entrySet()) {
String windowUid = String.valueOf(entry.getKey());
if(windowUid.equals(workspaceLayout)) {
continue;
}
Properties windowProperties = Util.propertiesFromString(String.valueOf(entry.getValue()));
SLF4JLoggerProxy.debug(this,
"Restoring {} {}",
Expand Down Expand Up @@ -1324,6 +1362,9 @@ private Properties getDisplayLayout()
displayLayout.setProperty(windowKey,
windowValue);
}
Properties workspaceLayoutProperties = getWorkspaceProperties();
displayLayout.setProperty(workspaceLayout,
Util.propertiesToString(workspaceLayoutProperties));
return displayLayout;
}
}
Expand Down Expand Up @@ -1396,6 +1437,18 @@ private Properties getDisplayLayout()
* window horizontal scroll key name
*/
private static final String windowHorizontalScrollProp = propId + "_scrollH";
/**
* main workspace layout key name
*/
private static final String workspaceLayout = propId + "_wsLayout";
/**
* main workspace height key name
*/
private static final String workspaceHeightProp = propId + "_wsHeight";
/**
* main workspace width key name
*/
private static final String workspaceWidthProp = propId + "_wsWidth";
/**
* web message service value
*/
Expand Down
5 changes: 3 additions & 2 deletions photon/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
- add new permission for activate/deactivate users and use them in UserView context menu
- create common dialog/confirmation pattern for context menus in PhotonServices and use for all relevant context menu items
- add ActivateUser to AdminClient and use in UserView context menu
- if md client goes offline, mark all views as disabled
- md client comes back online, resubmit md requests
- window onClose not fired on app shutdown so nothing gets saved - can't rely on onClose to save important view info
- probably need to handle DELETE events in market data list view
- add chart to market data detail view

- if md client goes offline, mark all views as disabled
- md client comes back online, resubmit md requests

* Bugs *
========
- market data client returns no available capabilities
Expand Down