diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index aef08a6e0..0f129b2c2 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -47,6 +47,8 @@ RocketActions.MoveUpAct.Moveup = Move up RocketActions.MoveUpAct.ttip.Moveup = Move this component upwards. RocketActions.MoveDownAct.Movedown = Move down RocketActions.MoveDownAct.ttip.Movedown = Move this component downwards. +RocketActions.ExportOBJAct.ExportOBJ = Export as OBJ (.obj) +RocketActions.ExportOBJAct.ttip.ExportOBJ = Export the selected components as a Wavefront OBJ 3D file. ! RocketPanel RocketPanel.FigTypeAct.SideView = Side view diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index fb60df716..508a9a3c5 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -255,6 +255,9 @@ public class BasicFrame extends JFrame { popupMenu.addSeparator(); popupMenu.add(actions.getScaleAction()); + + popupMenu.addSeparator(); + popupMenu.add(actions.getExportOBJAction()); } createMenu(); @@ -1647,7 +1650,7 @@ public class BasicFrame extends JFrame { * * @return true if the file was saved, false otherwise */ - private boolean exportWavefrontOBJAction() { + public boolean exportWavefrontOBJAction() { File file = openFileSaveAsDialog(FileType.WAVEFRONT_OBJ, getSelectedComponents()); if (file == null) { return false; diff --git a/swing/src/net/sf/openrocket/gui/main/RocketActions.java b/swing/src/net/sf/openrocket/gui/main/RocketActions.java index aa90f9eaf..5ee3324c1 100644 --- a/swing/src/net/sf/openrocket/gui/main/RocketActions.java +++ b/swing/src/net/sf/openrocket/gui/main/RocketActions.java @@ -77,6 +77,7 @@ public class RocketActions { private final RocketAction scaleAction; private final RocketAction moveUpAction; private final RocketAction moveDownAction; + private final RocketAction exportOBJAction; private static final Translator trans = Application.getTranslator(); private static final Logger log = LoggerFactory.getLogger(RocketActions.class); @@ -101,6 +102,7 @@ public class RocketActions { this.scaleAction = new ScaleAction(); this.moveUpAction = new MoveUpAction(); this.moveDownAction = new MoveDownAction(); + this.exportOBJAction = new ExportOBJAction(); OpenRocketClipboard.addClipboardListener(new ClipboardListener() { @Override @@ -148,6 +150,7 @@ public class RocketActions { scaleAction.clipboardChanged(); moveUpAction.clipboardChanged(); moveDownAction.clipboardChanged(); + exportOBJAction.clipboardChanged(); } @@ -197,6 +200,10 @@ public class RocketActions { return moveDownAction; } + public Action getExportOBJAction() { + return exportOBJAction; + } + /** * Tie an action to a JButton, without using the icon or text of the action for the button. * @@ -1205,5 +1212,32 @@ public class RocketActions { } + private class ExportOBJAction extends RocketAction { + private static final long serialVersionUID = 1L; + + public ExportOBJAction() { + this.putValue(NAME, trans.get("RocketActions.ExportOBJAct.ExportOBJ")); + this.putValue(SMALL_ICON, Icons.EXPORT_3D); + this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.ExportOBJAct.ttip.ExportOBJ")); + clipboardChanged(); + } + + @Override + public void actionPerformed(ActionEvent e) { + List components = selectionModel.getSelectedComponents(); + if (components.isEmpty()) { + return; + } + + ComponentConfigDialog.disposeDialog(); + parentFrame.exportWavefrontOBJAction(); + } + + @Override + public void clipboardChanged() { + List components = selectionModel.getSelectedComponents(); + this.setEnabled(!components.isEmpty()); + } + } }