Fix component selection resetting after updating plots
This commit is contained in:
parent
f392760c0e
commit
a52f16bd7c
@ -71,7 +71,7 @@ public class CAPlotPanel extends PlotPanel<CADataType, CADataBranch, CADataTypeG
|
|||||||
@Override
|
@Override
|
||||||
protected CAPlotTypeSelector createSelector(int i, CADataType type, Unit unit, int axis) {
|
protected CAPlotTypeSelector createSelector(int i, CADataType type, Unit unit, int axis) {
|
||||||
return new CAPlotTypeSelector(parent, i, type, unit, axis, List.of(typesY),
|
return new CAPlotTypeSelector(parent, i, type, unit, axis, List.of(typesY),
|
||||||
parent.getComponentsForType(type), configuration);
|
parent.getComponentsForType(type), configuration, configuration.getComponent(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXAxis(CADomainDataType type) {
|
public void setXAxis(CADomainDataType type) {
|
||||||
|
@ -18,7 +18,8 @@ public class CAPlotTypeSelector extends PlotTypeSelector<CADataType, CADataTypeG
|
|||||||
|
|
||||||
public CAPlotTypeSelector(final ComponentAnalysisPlotExportPanel parent, int plotIndex,
|
public CAPlotTypeSelector(final ComponentAnalysisPlotExportPanel parent, int plotIndex,
|
||||||
CADataType type, Unit unit, int position, List<CADataType> availableTypes,
|
CADataType type, Unit unit, int position, List<CADataType> availableTypes,
|
||||||
List<RocketComponent> componentsForType, CAPlotConfiguration configuration) {
|
List<RocketComponent> componentsForType, CAPlotConfiguration configuration,
|
||||||
|
RocketComponent selectedComponent) {
|
||||||
super(plotIndex, type, unit, position, availableTypes, false);
|
super(plotIndex, type, unit, position, availableTypes, false);
|
||||||
|
|
||||||
if (componentsForType.isEmpty()) {
|
if (componentsForType.isEmpty()) {
|
||||||
@ -26,9 +27,11 @@ public class CAPlotTypeSelector extends PlotTypeSelector<CADataType, CADataTypeG
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Component selector
|
// Component selector
|
||||||
|
selectedComponent = selectedComponent != null ? selectedComponent : componentsForType.get(0);
|
||||||
this.add(new JLabel(trans.get("CAPlotTypeSelector.lbl.component")));
|
this.add(new JLabel(trans.get("CAPlotTypeSelector.lbl.component")));
|
||||||
componentSelector = new JComboBox<>(componentsForType.toArray(new RocketComponent[0]));
|
componentSelector = new JComboBox<>(componentsForType.toArray(new RocketComponent[0]));
|
||||||
configuration.setPlotDataComponent(plotIndex, componentsForType.get(0));
|
componentSelector.setSelectedItem(selectedComponent);
|
||||||
|
configuration.setPlotDataComponent(plotIndex, selectedComponent);
|
||||||
this.add(componentSelector, "gapright para");
|
this.add(componentSelector, "gapright para");
|
||||||
|
|
||||||
addRemoveButton();
|
addRemoveButton();
|
||||||
@ -48,6 +51,12 @@ public class CAPlotTypeSelector extends PlotTypeSelector<CADataType, CADataTypeG
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CAPlotTypeSelector(final ComponentAnalysisPlotExportPanel parent, int plotIndex,
|
||||||
|
CADataType type, Unit unit, int position, List<CADataType> availableTypes,
|
||||||
|
List<RocketComponent> componentsForType, CAPlotConfiguration configuration) {
|
||||||
|
this(parent, plotIndex, type, unit, position, availableTypes, componentsForType, configuration, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void addComponentSelectionListener(ItemListener listener) {
|
public void addComponentSelectionListener(ItemListener listener) {
|
||||||
componentSelector.addItemListener(listener);
|
componentSelector.addItemListener(listener);
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,6 @@ public class PlotPanel<T extends DataType & Groupable<G>,
|
|||||||
// Select new type smartly
|
// Select new type smartly
|
||||||
T type = null;
|
T type = null;
|
||||||
for (T t : typesY) {
|
for (T t : typesY) {
|
||||||
|
|
||||||
boolean used = false;
|
boolean used = false;
|
||||||
if (configuration.getDomainAxisType().equals(t)) {
|
if (configuration.getDomainAxisType().equals(t)) {
|
||||||
used = true;
|
used = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user