Add multi-config select sync between flight config tables
This commit is contained in:
parent
e13c4baf25
commit
a290666d11
@ -114,7 +114,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
this.add(duplicateConfButton, "wrap");
|
this.add(duplicateConfButton, "wrap");
|
||||||
|
|
||||||
tabs.addChangeListener(new ChangeListener() {
|
tabs.addChangeListener(new ChangeListener() {
|
||||||
private FlightConfigurablePanel<?> previousPanel = null;
|
private FlightConfigurablePanel<?> previousPanel = motorConfigurationPanel;
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
// Trigger a selection of the motor/recovery/configuration item
|
// Trigger a selection of the motor/recovery/configuration item
|
||||||
@ -308,6 +308,9 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronize the table row selection of a target panel with the selection in the source panel.
|
||||||
|
*/
|
||||||
private void synchronizePanelSelection(FlightConfigurablePanel<?> source, FlightConfigurablePanel<?> target) {
|
private void synchronizePanelSelection(FlightConfigurablePanel<?> source, FlightConfigurablePanel<?> target) {
|
||||||
if (source == null || target == null) return;
|
if (source == null || target == null) return;
|
||||||
List<FlightConfigurationId> fids = source.getSelectedConfigurationIds();
|
List<FlightConfigurationId> fids = source.getSelectedConfigurationIds();
|
||||||
|
@ -6,6 +6,7 @@ import java.awt.Font;
|
|||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@ -298,12 +299,16 @@ public abstract class FlightConfigurablePanel<T extends FlightConfigurableCompon
|
|||||||
public void setSelectedConfigurationIds(List<FlightConfigurationId> fids) {
|
public void setSelectedConfigurationIds(List<FlightConfigurationId> fids) {
|
||||||
if (fids == null || fids.isEmpty() || table.getColumnCount() == 0) return;
|
if (fids == null || fids.isEmpty() || table.getColumnCount() == 0) return;
|
||||||
|
|
||||||
|
if (new HashSet<>(getSelectedConfigurationIds()).containsAll(fids)) return;
|
||||||
|
|
||||||
|
table.clearSelection();
|
||||||
for (FlightConfigurationId id : fids) {
|
for (FlightConfigurationId id : fids) {
|
||||||
if (id == FlightConfigurationId.DEFAULT_VALUE_FCID) continue;
|
if (id == FlightConfigurationId.DEFAULT_VALUE_FCID) continue;
|
||||||
for (int rowNum = 0; rowNum < table.getRowCount(); rowNum++) {
|
for (int rowNum = 0; rowNum < table.getRowCount(); rowNum++) {
|
||||||
FlightConfigurationId rowFCID = rocket.getId(rowNum );
|
FlightConfigurationId rowFCID = rocket.getId(rowNum );
|
||||||
if (rowFCID.equals(id) && !table.isRowSelected(rowNum)) {
|
if (rowFCID.equals(id)) {
|
||||||
table.changeSelection(rowNum, 1, false, false);
|
table.changeSelection(rowNum, 1, true, false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user