Disable export children when components don't have children
This commit is contained in:
parent
ba8a50278d
commit
46505b0986
@ -1491,7 +1491,8 @@ OBJOptionChooser.lbl.component = <html>Component: %s</html>
|
|||||||
OBJOptionChooser.lbl.multipleComponents = <i>Multiple components</i>
|
OBJOptionChooser.lbl.multipleComponents = <i>Multiple components</i>
|
||||||
OBJOptionChooser.checkbox.exportChildren = Export children
|
OBJOptionChooser.checkbox.exportChildren = Export children
|
||||||
OBJOptionChooser.checkbox.exportChildren.ttip = If true, export children of the selected components as well.
|
OBJOptionChooser.checkbox.exportChildren.ttip = If true, export children of the selected components as well.
|
||||||
OBJOptionChooser.checkbox.exportChildren.assemblies.ttip = Component assemblies always export their children
|
OBJOptionChooser.checkbox.exportChildren.assemblies.ttip = Component assemblies always export their children.
|
||||||
|
OBJOptionChooser.checkbox.exportChildren.noChildren.ttip = Selected components don't have children.
|
||||||
OBJOptionChooser.checkbox.exportAppearance = Export appearance
|
OBJOptionChooser.checkbox.exportAppearance = Export appearance
|
||||||
OBJOptionChooser.checkbox.exportAppearance.ttip = If true, export the component appearances to an MTL file.
|
OBJOptionChooser.checkbox.exportAppearance.ttip = If true, export the component appearances to an MTL file.
|
||||||
OBJOptionChooser.checkbox.exportAsSeparateFiles = Export as separate files
|
OBJOptionChooser.checkbox.exportAsSeparateFiles = Export as separate files
|
||||||
|
@ -11,6 +11,7 @@ import net.sf.openrocket.rocketcomponent.Rocket;
|
|||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
@ -226,10 +227,15 @@ public class OBJOptionChooser extends JPanel {
|
|||||||
|
|
||||||
public void loadOptions(OBJExportOptions opts) {
|
public void loadOptions(OBJExportOptions opts) {
|
||||||
boolean onlyComponentAssemblies = isOnlyComponentAssembliesSelected(selectedComponents);
|
boolean onlyComponentAssemblies = isOnlyComponentAssembliesSelected(selectedComponents);
|
||||||
if (onlyComponentAssemblies) {
|
boolean hasChildren = isComponentsHaveChildren(selectedComponents);
|
||||||
|
if (onlyComponentAssemblies || !hasChildren) {
|
||||||
exportChildren.setEnabled(false);
|
exportChildren.setEnabled(false);
|
||||||
exportChildren.setSelected(true);
|
exportChildren.setSelected(true);
|
||||||
|
if (onlyComponentAssemblies) {
|
||||||
exportChildren.setToolTipText(trans.get("OBJOptionChooser.checkbox.exportChildren.assemblies.ttip"));
|
exportChildren.setToolTipText(trans.get("OBJOptionChooser.checkbox.exportChildren.assemblies.ttip"));
|
||||||
|
} else {
|
||||||
|
exportChildren.setToolTipText(trans.get("OBJOptionChooser.checkbox.exportChildren.noChildren.ttip"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
exportChildren.setEnabled(true);
|
exportChildren.setEnabled(true);
|
||||||
exportChildren.setSelected(opts.isExportChildren());
|
exportChildren.setSelected(opts.isExportChildren());
|
||||||
@ -278,14 +284,21 @@ public class OBJOptionChooser extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isOnlyComponentAssembliesSelected(List<RocketComponent> selectedComponents) {
|
private static boolean isOnlyComponentAssembliesSelected(List<RocketComponent> selectedComponents) {
|
||||||
boolean onlyComponentAssemblies = true;
|
|
||||||
for (RocketComponent component : selectedComponents) {
|
for (RocketComponent component : selectedComponents) {
|
||||||
if (!(component instanceof ComponentAssembly)) {
|
if (!(component instanceof ComponentAssembly)) {
|
||||||
onlyComponentAssemblies = false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return onlyComponentAssemblies;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isComponentsHaveChildren(List<RocketComponent> selectedComponents) {
|
||||||
|
for (RocketComponent component : selectedComponents) {
|
||||||
|
if (component.getChildCount() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void coordTransComboAction(ItemEvent e, JComboBox<Axis> otherCombo) {
|
private void coordTransComboAction(ItemEvent e, JComboBox<Axis> otherCombo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user