[refactor] ComponentPresetChooserDialog now calls SymmetricComponent.get{Next|Prev}SymmetricComponent(...)

This commit is contained in:
Daniel_M_Williams 2020-05-03 15:30:43 -04:00
parent d8a8c14449
commit 7b9deff180

View File

@ -172,8 +172,6 @@ public class ComponentPresetChooserDialog extends JDialog {
private JPanel getFilterCheckboxes() { private JPanel getFilterCheckboxes() {
SymmetricComponent sc;
JPanel panel = new JPanel(new MigLayout("ins 0")); JPanel panel = new JPanel(new MigLayout("ins 0"));
/* /*
@ -197,37 +195,40 @@ public class ComponentPresetChooserDialog extends JDialog {
} }
}); });
} }
/* if(component instanceof SymmetricComponent) {
* Add filter by fore diameter final SymmetricComponent curSym = (SymmetricComponent) component;
*/ /*
foreDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter")); * Add filter by fore diameter
sc = getPreviousSymmetricComponent(); */
if (sc != null && foreDiameterColumnIndex >= 0) { foreDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterForeDiameter"));
foreDiameterFilter = new ComponentPresetRowFilter(sc.getAftRadius() * 2.0, foreDiameterColumnIndex); final SymmetricComponent prevSym = curSym.getPreviousSymmetricComponent();
panel.add(foreDiameterFilterCheckBox, "wrap"); if (prevSym != null && foreDiameterColumnIndex >= 0) {
foreDiameterFilterCheckBox.addItemListener(new ItemListener() { foreDiameterFilter = new ComponentPresetRowFilter(prevSym.getAftRadius() * 2.0, foreDiameterColumnIndex);
@Override panel.add(foreDiameterFilterCheckBox, "wrap");
public void itemStateChanged(ItemEvent e) { foreDiameterFilterCheckBox.addItemListener(new ItemListener() {
updateFilters(); @Override
} public void itemStateChanged(ItemEvent e) {
}); updateFilters();
} }
});
/* }
* Add filter by aft diameter
*/ /*
aftDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterAftDiameter")); * Add filter by aft diameter
sc = getNextSymmetricComponent(); */
if (sc != null && aftDiameterColumnIndex >= 0) { aftDiameterFilterCheckBox = new JCheckBox(trans.get("ComponentPresetChooserDialog.checkbox.filterAftDiameter"));
aftDiameterFilter = new ComponentPresetRowFilter(sc.getForeRadius() * 2.0, aftDiameterColumnIndex); final SymmetricComponent nextSym = curSym.getNextSymmetricComponent();
panel.add(aftDiameterFilterCheckBox, "wrap"); if (nextSym != null && aftDiameterColumnIndex >= 0) {
aftDiameterFilterCheckBox.addItemListener(new ItemListener() { aftDiameterFilter = new ComponentPresetRowFilter(nextSym.getForeRadius() * 2.0, aftDiameterColumnIndex);
@Override panel.add(aftDiameterFilterCheckBox, "wrap");
public void itemStateChanged(ItemEvent e) { aftDiameterFilterCheckBox.addItemListener(new ItemListener() {
updateFilters(); @Override
} public void itemStateChanged(ItemEvent e) {
}); updateFilters();
}
});
}
} }
return panel; return panel;
@ -275,28 +276,4 @@ public class ComponentPresetChooserDialog extends JDialog {
componentSelectionTable.setRowFilter(RowFilter.andFilter(filters)); componentSelectionTable.setRowFilter(RowFilter.andFilter(filters));
} }
private SymmetricComponent getPreviousSymmetricComponent() {
RocketComponent c = component;
while (c != null) {
c = c.getPreviousComponent();
if (c instanceof SymmetricComponent) {
return (SymmetricComponent) c;
}
}
return null;
}
private SymmetricComponent getNextSymmetricComponent() {
RocketComponent c = component;
while (c != null) {
c = c.getNextComponent();
if (c instanceof SymmetricComponent) {
return (SymmetricComponent) c;
}
}
return null;
}
} }