Skip to content

Commit

Permalink
[GUI] Bugfixes: equations weren't saved properly because of poor sess…
Browse files Browse the repository at this point in the history
…ion management.
  • Loading branch information
SylvainBertrand committed Apr 2, 2024
1 parent 9f129e4 commit 318f551
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public void setInput(YoComposite input)
if (yoCompositeTextField != null)
yoCompositeTextField.setInput(input);
else
componentSearchTextFields[0].setText(input.getUniqueName());
componentSearchTextFields[0].setText(input.getUniqueShortName());
}

public void setInput(CompositeProperty input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import us.ihmc.scs2.definition.DefinitionIOTools;
import us.ihmc.scs2.definition.yoVariable.YoEquationDefinition;
import us.ihmc.scs2.definition.yoVariable.YoEquationListDefinition;
import us.ihmc.scs2.session.Session;
import us.ihmc.scs2.sessionVisualizer.jfx.SessionVisualizerIOTools;
import us.ihmc.scs2.sessionVisualizer.jfx.SessionVisualizerTopics;
import us.ihmc.scs2.sessionVisualizer.jfx.YoNameDisplay;
Expand Down Expand Up @@ -69,20 +68,19 @@ public class YoCompositeAndEquationEditorWindowController
private VBox equationEditorContainer;

private final Property<YoNameDisplay> yoVariableNameDisplay = new SimpleObjectProperty<>(this, "yoVariableNameDisplay", YoNameDisplay.SHORT_NAME);
private YoRegistry userRegistry;

private Stage window;
private SessionVisualizerToolkit toolkit;
private SessionVisualizerTopics topics;
private JavaFXMessager messager;
private YoManager yoManager;

public void initialize(SessionVisualizerToolkit toolkit)
{
this.toolkit = toolkit;
messager = toolkit.getMessager();
topics = toolkit.getTopics();
YoManager yoManager = toolkit.getYoManager();
userRegistry = yoManager.getUserRegistry();
yoManager = toolkit.getYoManager();

Property<Integer> numberPrecision = messager.createPropertyInput(topics.getControlsNumberPrecision(), 3);

Expand Down Expand Up @@ -178,6 +176,7 @@ public void newYoComposite()
FXMLLoader loader = new FXMLLoader(SessionVisualizerIOTools.YO_COMPOSITE_CREATOR_DIALOG_URL);
loader.load();
YoCompositeCreatorDialogController yoCompositeCreatorDialogController = loader.getController();
YoRegistry userRegistry = yoManager.getUserRegistry();
YoComposite yoComposite = yoCompositeCreatorDialogController.showAndWait(window, userRegistry);
if (yoComposite != null)
{
Expand All @@ -194,6 +193,9 @@ public void deleteYoComposite(YoComposite selectedComposite)
{
if (selectedComposite == null)
return;

yoCompositeListView.getItems().remove(selectedComposite);

for (YoVariable yoVariable : selectedComposite.getYoComponents())
{
yoVariable.destroy();
Expand All @@ -203,6 +205,7 @@ public void deleteYoComposite(YoComposite selectedComposite)
private void refreshYoCompositeListView()
{
yoCompositeListView.getItems().clear();
YoRegistry userRegistry = yoManager.getUserRegistry();
userRegistry.getVariables()
.forEach(yoVariable -> yoCompositeListView.getItems().add(new YoComposite(YoCompositeSearchManager.yoVariablePattern, yoVariable)));
}
Expand Down Expand Up @@ -286,14 +289,8 @@ public Stage getWindow()

public void closeAndDispose()
{
}

public void startSession(Session session)
{
}

public void stopSession()
{
window.close();
yoEquationEditorListView.getItems().clear();
}

@FXML
Expand Down Expand Up @@ -343,6 +340,7 @@ public void importYoEquations()
YoEquationListDefinition yoEquationListDefinition = DefinitionIOTools.loadYoEquationListDefinition(inputStream);
if (yoEquationListDefinition == null)
return;
YoRegistry userRegistry = yoManager.getUserRegistry();
for (YoEquationDefinition yoEquationDefinition : yoEquationListDefinition.getYoEquations())
{
YoEquationManager.ensureUserAliasesExist(yoEquationDefinition, userRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableMap;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public void stopSession()
yoGraphicEditor.setValue(null);
}

if (yoCompositeCreator.getValue() != null)
{
yoCompositeCreator.getValue().closeAndDispose();
yoCompositeCreator.setValue(null);
}

sliderboardManager.stopSession();

if (yoRegistryStatistics.getValue() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,6 @@ public void unloadSession()
{
enableVariableFilterToggleButton.setSelected(false);
variableFilterControllerProperty.set(null);

if (activeSessionProperty.get() != null)
{
activeSessionProperty.get().shutdownSession();
activeSessionProperty.set(null);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,6 @@ public void notifySessionLoaded()
@Override
public void unloadSession()
{
if (activeSessionProperty.get() != null)
{
activeSessionProperty.get().shutdownSession();
activeSessionProperty.set(null);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public RemoteSessionFactory()
}

@Override
public void start(YoVariableClientInterface yoVariableClientInterface, LogHandshake handshake, YoVariableHandshakeParser handshakeParser,
public void start(YoVariableClientInterface yoVariableClientInterface,
LogHandshake handshake,
YoVariableHandshakeParser handshakeParser,
DebugRegistry debugRegistry)
{
activeSessionProperty.set(new RemoteSession(yoVariableClientInterface, handshake, handshakeParser, debugRegistry));
Expand Down Expand Up @@ -56,7 +58,8 @@ public void unloadSession()

if (activeSession != null)
{
activeSession.shutdownSession();
// FIXME Session management is a mess, shouldn't be the responsibility of the factory
// activeSession.shutdownSession();
activeSessionProperty.set(null);
}
}
Expand Down

0 comments on commit 318f551

Please sign in to comment.