diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 0b0465672..05e740f1b 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -314,7 +314,7 @@ pref.dlg.lbl.Pressure = Pressure: pref.dlg.lbl.Stability = Stability: pref.dlg.lbl.FlightTime = Flight time: pref.dlg.lbl.effect1 = The effects will take place the next time you open a window. -pref.dlg.lbl.Checkingupdates = Checking for updates... +pref.dlg.lbl.Checkingupdates = Checking for updates\u2026 pref.dlg.PrefChoiseSelector1 = Always ask pref.dlg.PrefChoiseSelector2 = Insert in middle pref.dlg.PrefChoiseSelector3 = Add to end @@ -512,8 +512,8 @@ simpanel.ttip.noWarnings = No warnings. simpanel.ttip.warnings = Warnings: ! SimulationRunDialog -SimuRunDlg.title.RunSim = Running simulations... -SimuRunDlg.lbl.Running = Running ... +SimuRunDlg.title.RunSim = Running simulations\u2026 +SimuRunDlg.lbl.Running = Running\u2026 SimuRunDlg.lbl.Simutime = Simulation time: SimuRunDlg.lbl.Altitude = Altitude: SimuRunDlg.lbl.Velocity = Velocity: @@ -818,7 +818,7 @@ MotorDbLoaderDlg.message2 = You can try replacing, deleting or manually editing ! MotorDatabaseLoadingDialog MotorDbLoadDlg.title = Loading motors -MotorDbLoadDlg.Loadingmotors = Loading motors... +MotorDbLoadDlg.Loadingmotors = Loading motors\u2026 ! AppearanceConfig AppearanceCfg.lbl.Appearance = Appearance @@ -1286,28 +1286,30 @@ main.menu.file = File main.menu.file.desc = File-handling related tasks main.menu.file.new = New main.menu.file.new.desc = Create a new rocket design -main.menu.file.open = Open... +main.menu.file.open = Open\u2026 main.menu.file.open.desc = Open a rocket design -main.menu.file.openRecent = Open Recent... +main.menu.file.openRecent = Open recent main.menu.file.openRecent.desc = Open a recent rocket design -main.menu.file.openExample = Open Example... +main.menu.file.openExample = Open example main.menu.file.openExample.desc = Open an example rocket design main.menu.file.save = Save main.menu.file.save.desc = Save the current rocket design -main.menu.file.saveAs = Save as... +main.menu.file.saveAs = Save as\u2026 main.menu.file.saveAs.desc = Save the current rocket design to a new file -main.menu.file.import = Import... -main.menu.file.import.desc = Import model from RockSim rkt file -main.menu.file.export = Export... -main.menu.file.export.desc = Export model to RockSim rkt file -main.menu.file.print = Print / Export PDF... -main.menu.file.print.desc = Print or save as PDF the parts list and fin templates -main.menu.file.close = Close +! main.menu.file.import = Import\u2026 +! main.menu.file.import.desc = Import design from RockSim rkt file +main.menu.file.export_as = Export as +main.menu.file.export_as.desc = Export design as selected file format +main.menu.file.encode_3d = Encode 3D +main.menu.file.encode_3d.desc = Encode design to selected 3D file format +main.menu.file.print = Print specs\u2026 +main.menu.file.print.desc = Print design specifications, including the parts list and fin templates, print or save as PDF +main.menu.file.close = Close design main.menu.file.close.desc = Close the current rocket design main.menu.file.quit = Quit main.menu.file.quit.desc = Quit the program -main.menu.file.exportDecal = Export Decal -main.menu.file.exportDecal.desc = Export a decal from the current rocket design to a file for editing. +main.menu.file.exportDecal = Save decal image\u2026 +main.menu.file.exportDecal.desc = Save a decal from the current rocket design to a file for editing. main.menu.edit = Edit main.menu.edit.desc = Rocket editing @@ -1319,7 +1321,7 @@ main.menu.edit.cut = Cut main.menu.edit.copy = Copy main.menu.edit.paste = Paste main.menu.edit.delete = Delete -main.menu.edit.resize = Scale... +main.menu.edit.resize = Scale\u2026 main.menu.edit.resize.desc = Scale parts of the rocket design main.menu.edit.editpreset= Edit Component Preset File main.menu.edit.preferences = Preferences @@ -1653,7 +1655,7 @@ RocketInfo.cpText = CP: RocketInfo.stabText = Stability: RocketInfo.Warning = Warning: RocketInfo.Warning.TubeFinExperimental = Tube fin support is experimental -RocketInfo.Calculating = Calculating... +RocketInfo.Calculating = Calculating\u2026 RocketInfo.Apogee = Apogee: RocketInfo.Maxvelocity = Max. velocity: RocketInfo.Maxacceleration = Max. acceleration: @@ -2026,10 +2028,10 @@ CustomFinImport.description = The image will be converted internally to black an PresetModel.lbl.select = Select preset -PresetModel.lbl.database = From database... +PresetModel.lbl.database = From database\u2026 DecalModel.lbl.select = -DecalModel.lbl.choose = From file... +DecalModel.lbl.choose = From file\u2026 ! Export Decal Dialog ExportDecalDialog.title = Export Decal @@ -2125,7 +2127,7 @@ MotorDescriptionSubstitutor.description = Motors in the configuration !Photo Panel PhotoFrame.title = Photo Studio PhotoFrame.desc = Create realistic 3D images of the rocket -PhotoFrame.menu.file.save = Save Image... +PhotoFrame.menu.file.save = Save Image\u2026 PhotoFrame.fileFilter.png = PNG Image PhotoFrame.menu.edit.copy = Copy Image PhotoFrame.menu.edit.copy.desc = Copy image to clipboard diff --git a/core/resources/pix/icons/Painting-Transparent-PNG_16.png b/core/resources/pix/icons/Painting-Transparent-PNG_16.png new file mode 100644 index 000000000..884436f7a Binary files /dev/null and b/core/resources/pix/icons/Painting-Transparent-PNG_16.png differ diff --git a/core/resources/pix/icons/RASAero_16.png b/core/resources/pix/icons/RASAero_16.png new file mode 100644 index 000000000..c9fc75446 Binary files /dev/null and b/core/resources/pix/icons/RASAero_16.png differ diff --git a/core/resources/pix/icons/Rocksim_16.png b/core/resources/pix/icons/Rocksim_16.png new file mode 100644 index 000000000..4c33313ac Binary files /dev/null and b/core/resources/pix/icons/Rocksim_16.png differ diff --git a/core/resources/pix/icons/document-print-Specs.png b/core/resources/pix/icons/document-print-Specs.png new file mode 100644 index 000000000..d5929b690 Binary files /dev/null and b/core/resources/pix/icons/document-print-Specs.png differ diff --git a/core/resources/pix/icons/model_encode3d.png b/core/resources/pix/icons/model_encode3d.png new file mode 100644 index 000000000..f4aee1785 Binary files /dev/null and b/core/resources/pix/icons/model_encode3d.png differ diff --git a/core/resources/pix/icons/model_export.png b/core/resources/pix/icons/model_export.png new file mode 100644 index 000000000..db03e2b90 Binary files /dev/null and b/core/resources/pix/icons/model_export.png differ diff --git a/core/resources/pix/icons/model_import.png b/core/resources/pix/icons/model_import.png new file mode 100644 index 000000000..3b3e528c8 Binary files /dev/null and b/core/resources/pix/icons/model_import.png differ diff --git a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java index 9dc121f6c..ac607b8bd 100644 --- a/swing/src/net/sf/openrocket/gui/main/BasicFrame.java +++ b/swing/src/net/sf/openrocket/gui/main/BasicFrame.java @@ -1,9 +1,6 @@ package net.sf.openrocket.gui.main; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Toolkit; -import java.awt.Window; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -22,35 +19,10 @@ import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; -import java.util.EventObject; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ExecutionException; - -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.InputMap; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JScrollPane; -import javax.swing.JSpinner; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextField; -import javax.swing.KeyStroke; -import javax.swing.ListSelectionModel; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingUtilities; +import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; @@ -59,17 +31,9 @@ import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreePath; import javax.swing.tree.TreeSelectionModel; - -import net.sf.openrocket.appearance.DecalImage; -import net.sf.openrocket.gui.dialogs.DecalNotFoundDialog; -import net.sf.openrocket.gui.widgets.SelectColorButton; -import net.sf.openrocket.rocketcomponent.AxialStage; -import net.sf.openrocket.util.DecalNotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import net.miginfocom.swing.MigLayout; import net.sf.openrocket.aerodynamics.WarningSet; +import net.sf.openrocket.appearance.DecalImage; import net.sf.openrocket.document.OpenRocketDocument; import net.sf.openrocket.document.OpenRocketDocumentFactory; import net.sf.openrocket.document.StorageOptions; @@ -83,6 +47,7 @@ import net.sf.openrocket.gui.dialogs.AboutDialog; import net.sf.openrocket.gui.dialogs.BugReportDialog; import net.sf.openrocket.gui.dialogs.ComponentAnalysisDialog; import net.sf.openrocket.gui.dialogs.DebugLogDialog; +import net.sf.openrocket.gui.dialogs.DecalNotFoundDialog; import net.sf.openrocket.gui.dialogs.DetailDialog; import net.sf.openrocket.gui.dialogs.LicenseDialog; import net.sf.openrocket.gui.dialogs.PrintDialog; @@ -102,8 +67,10 @@ import net.sf.openrocket.gui.util.Icons; import net.sf.openrocket.gui.util.OpenFileWorker; import net.sf.openrocket.gui.util.SaveFileWorker; import net.sf.openrocket.gui.util.SwingPreferences; +import net.sf.openrocket.gui.widgets.SelectColorButton; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.logging.Markers; +import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.ComponentChangeListener; import net.sf.openrocket.rocketcomponent.Rocket; @@ -111,12 +78,14 @@ import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.startup.Application; import net.sf.openrocket.startup.Preferences; import net.sf.openrocket.util.BugException; +import net.sf.openrocket.util.DecalNotFoundException; import net.sf.openrocket.util.MemoryManagement; import net.sf.openrocket.util.MemoryManagement.MemoryData; import net.sf.openrocket.util.Reflection; -import net.sf.openrocket.util.StateChangeListener; import net.sf.openrocket.util.TestRockets; import net.sf.openrocket.utils.ComponentPresetEditor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class BasicFrame extends JFrame { @@ -179,23 +148,21 @@ public class BasicFrame extends JFrame { this.rocket = document.getRocket(); this.rocket.getSelectedConfiguration().setAllStages(); - // Create the component tree selection model that will be used + // Create the component tree selection model that will be used componentSelectionModel = new DefaultTreeSelectionModel(); componentSelectionModel.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); - // Obtain the simulation selection model that will be used + // Obtain the simulation selection model that will be used simulationPanel = new SimulationPanel(document); simulationSelectionModel = simulationPanel.getSimulationListSelectionModel(); - // Combine into a DocumentSelectionModel + // Combine into a DocumentSelectionModel selectionModel = new DocumentSelectionModel(document); selectionModel.attachComponentTreeSelectionModel(componentSelectionModel); selectionModel.attachSimulationListSelectionModel(simulationSelectionModel); - actions = new RocketActions(document, selectionModel, this); - log.debug("Constructing the BasicFrame UI"); // The main vertical split pane @@ -203,8 +170,7 @@ public class BasicFrame extends JFrame { vertical.setResizeWeight(0.5); this.add(vertical); - - // The top tabbed pane + // The top tabbed pane tabbedPane = new JTabbedPane(); //// Rocket design tabbedPane.addTab(trans.get("BasicFrame.tab.Rocketdesign"), null, designTab()); @@ -213,15 +179,12 @@ public class BasicFrame extends JFrame { //// Flight simulations tabbedPane.addTab(trans.get("BasicFrame.tab.Flightsim"), null, simulationPanel); - // Add change listener to catch when the tabs are changed. This is to run simulations - // automagically when the simulation tab is selected. + // Add change listener to catch when the tabs are changed. This is to run simulations + // automatically when the simulation tab is selected. tabbedPane.addChangeListener(new BasicFrame_changeAdapter(this)); - vertical.setTopComponent(tabbedPane); - - // Bottom segment, rocket figure rocketpanel = new RocketPanel(document, this); @@ -229,7 +192,6 @@ public class BasicFrame extends JFrame { rocketpanel.setSelectionModel(tree.getSelectionModel()); - createMenu(); @@ -283,6 +245,7 @@ public class BasicFrame extends JFrame { log.debug("BasicFrame instantiation complete"); } + /** * Construct the "Rocket design" tab. This contains a horizontal split pane * with the left component the design tree and the right component buttons @@ -404,7 +367,6 @@ public class BasicFrame extends JFrame { } - /** * Return the currently selected rocket component, or null if none selected. */ @@ -417,6 +379,7 @@ public class BasicFrame extends JFrame { return (RocketComponent) path.getLastPathComponent(); } + /** * Return the currently selected rocket component, or null if none selected. */ @@ -435,7 +398,6 @@ public class BasicFrame extends JFrame { return result; } - /** * Creates the menu for the window. */ @@ -528,34 +490,53 @@ public class BasicFrame extends JFrame { }); menu.add(item); + //// BEGIN CREATE and implement File > "Export as" menu and submenu + + // // INITIALIZE "Export as" submenu with options list + JMenu exportSubMenu = new JMenu(); + JMenuItem exportMenu = new JMenuItem(), + RASAero= new JMenuItem("RASAero (Unavailable)"), + Rocksim = new JMenuItem("Rocksim"), + Print3D = new JMenuItem("Exterior airframe"); + + // // CREATE File > "Export as" menu line with icon, and "Export as" submenu + exportSubMenu = new JMenu(trans.get("main.menu.file.export_as")); + exportSubMenu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.export_as.desc")); + exportSubMenu.setIcon(Icons.FILE_EXPORT_AS); + +/* // // PENDING Future development + // // ADD RASAero to "Export as" exportSubMenu options + exportSubMenu.add(RASAero); + RASAero.setForeground(Color.lightGray); + + // // PENDING Future development + // // CREATE RASAero listener + RASAero.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exportRASAeroAction();}}); +*/ + // // ADD Rocksim to "Export as" exportSubMenu options + exportSubMenu.add(Rocksim); + + // // CREATE Rocksim listener + Rocksim.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + exportRocksimAction();}}); + + // // ADD Export options in exportSubMenu to "Export as" menu + menu.add(exportSubMenu); + + // // END CREATE and implement File > "Export as" menu and submenu + + //// BEGIN CREATE na implement File > "Save decal image. . . menu and submenu + menu.addSeparator(); - //// Import Rocksim - item = new JMenuItem(trans.get("main.menu.file.import")); - item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.import.desc")); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - log.info(Markers.USER_MARKER, "Import... selected"); - importAction(); - } - }); - menu.add(item); - - //// Export Rocksim - item = new JMenuItem(trans.get("main.menu.file.export")); - item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.export.desc")); - item.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - log.info(Markers.USER_MARKER, "Export... selected"); - exportAction(); - } - }); - menu.add(item); - - //// Export decal... + //// Save decal image... item = new JMenuItem(trans.get("main.menu.file.exportDecal")); + item.setIcon(Icons.SAVE_DECAL); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.exportDecal.desc")); item.addActionListener(new ActionListener() { @Override @@ -565,21 +546,24 @@ public class BasicFrame extends JFrame { }); item.setEnabled(document.getDecalList().size() > 0); final JMenuItem exportMenuItem = item; +/** document.getRocket().addChangeListener(new StateChangeListener() { - @Override - public void stateChanged(EventObject e) { - exportMenuItem.setEnabled(document.getDecalList().size() > 0); - } - + @Override + public void stateChanged(EventObject e) { + exportMenuItem.setEnabled(document.getDecalList().size() > 0); + } }); + */ menu.add(item); + //// END CREATE na implement File > "Save decal image. . . menu and submenu + + //// BEGIN PRINT Design specifications, including parts list and templates - //// Print... item = new JMenuItem(trans.get("main.menu.file.print"), KeyEvent.VK_P); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, SHORTCUT_KEY)); - //// Print parts list and fin template + //// Print specifications, including parts list and fin template item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.print.desc")); item.setIcon(Icons.FILE_PRINT); item.addActionListener(new ActionListener() { @@ -591,10 +575,58 @@ public class BasicFrame extends JFrame { }); menu.add(item); + //// END PRINT Design specifications, including parts list and templates + +/* //// THE IMPORT ROCKSIM .RKT FEATURE IS FULLY WITHIN THE SCOPE OF THE "OPEN" FEATURE + //// THIS FEATURE IS BEING DEACTIVATED PENDING REMOVAL menu.addSeparator(); - //// Close + //// BEGIN IMPORT Rocksim RKT design file + JMenuItem importMenu; + item = new JMenuItem(trans.get("main.menu.file.import")); + item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.import.desc")); + item.setIcon(Icons.FILE_IMPORT); + item.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + log.info(Markers.USER_MARKER, "Import... selected"); + importAction(); + } + }); + menu.add(item); + //// END IMPORT Rocksim RKT design file +*/ + +/* //// PENDING Future development + //// BEGIN CREATE and implement File > "Encode 3D" menu and submenu + + // // INITIALIZE "Encode 3D" submenu with options list + JMenu encode3dSubmenu = new JMenu(); + JMenuItem encodeMenu = new JMenuItem(), + External_Airframe = new JMenuItem("External airframe (unavailable)"), + Single_Component = new JMenuItem("Component (unavailable)"); + + // // CREATE File > "Encode 3D" menu line with icon + JMenuItem encode3dSubMenu = new JMenu(trans.get("main.menu.file.encode_3d")); + encode3dSubMenu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.file.encode_3d.desc")); + encode3dSubMenu.setForeground(Color.lightGray); + encode3dSubMenu.setIcon(Icons.ENCODE_3D); + + // // CREATE "Encode 3D" submenu + // // ADD Encode 3D option items to submenu + encode3dSubMenu.add(External_Airframe); + External_Airframe.setForeground(Color.lightGray); + encode3dSubMenu.add(Single_Component); + Single_Component.setForeground(Color.lightGray); + + // // ADD Listeners + + //// END CREATE and implement File > "Encode 3D" menu and submenu +*/ + menu.addSeparator(); + + //// Close item = new JMenuItem(trans.get("main.menu.file.close"), KeyEvent.VK_C); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, SHORTCUT_KEY)); //// Close the current rocket design @@ -607,11 +639,12 @@ public class BasicFrame extends JFrame { closeAction(); } }); + menu.add(item); menu.addSeparator(); - //// Quit + //// Quit item = new JMenuItem(trans.get("main.menu.file.quit"), KeyEvent.VK_Q); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, SHORTCUT_KEY)); //// Quit the program @@ -626,21 +659,20 @@ public class BasicFrame extends JFrame { }); menu.add(item); - - - //// Edit + //// Edit menu = new JMenu(trans.get("main.menu.edit")); menu.setMnemonic(KeyEvent.VK_E); - //// Rocket editing + + //// Rocket editing menu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.edit.desc")); menubar.add(menu); - Action action = UndoRedoAction.newUndoAction(document); item = new JMenuItem(action); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, SHORTCUT_KEY)); item.setMnemonic(KeyEvent.VK_U); - //// Undo the previous operation + + //// Undo the previous operation item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.edit.undo.desc")); menu.add(item); @@ -649,7 +681,8 @@ public class BasicFrame extends JFrame { item = new JMenuItem(action); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, SHORTCUT_KEY)); item.setMnemonic(KeyEvent.VK_R); - //// Redo the previously undone operation + + //// Redo the previously undone operation item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.edit.redo.desc")); menu.add(item); @@ -671,7 +704,6 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - item = new JMenuItem(trans.get("main.menu.edit.resize")); item.setIcon(Icons.EDIT_SCALE); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.edit.resize.desc")); @@ -687,11 +719,11 @@ public class BasicFrame extends JFrame { menu.add(item); - - //// Preferences + //// Preferences item = new JMenuItem(trans.get("main.menu.edit.preferences")); item.setIcon(Icons.PREFERENCES); - //// Setup the application preferences + + //// Setup the application preferences item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.edit.preferences.desc")); item.addActionListener(new ActionListener() { @Override @@ -702,7 +734,7 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Edit Component Preset File + //// Edit Component Preset File if (System.getProperty("openrocket.preseteditor.menu") != null) { item = new JMenuItem(trans.get("main.menu.edit.editpreset")); item.addActionListener(new ActionListener() { @@ -719,17 +751,18 @@ public class BasicFrame extends JFrame { } - //// Analyze + //// Analyze menu = new JMenu(trans.get("main.menu.analyze")); menu.setMnemonic(KeyEvent.VK_A); - //// Analyzing the rocket + + //// Analyzing the rocket menu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.desc")); menubar.add(menu); - - //// Component analysis + //// Component analysis item = new JMenuItem(trans.get("main.menu.analyze.componentAnalysis"), KeyEvent.VK_C); - //// Analyze the rocket components separately + + //// Analyze the rocket components separately item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.componentAnalysis.desc")); item.addActionListener(new ActionListener() { @Override @@ -740,7 +773,7 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Optimize + //// Optimize item = new JMenuItem(trans.get("main.menu.analyze.optimization"), KeyEvent.VK_O); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.optimization.desc")); item.addActionListener(new ActionListener() { @@ -756,7 +789,7 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Custom expressions + //// Custom expressions item = new JMenuItem(trans.get("main.menu.analyze.customExpressions"), KeyEvent.VK_E); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.analyze.customExpressions.desc")); item.addActionListener(new ActionListener() { @@ -780,24 +813,19 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Debug - // (shown if openrocket.debug.menu is defined) + //// Debug + // // (shown if openrocket.debug.menu is defined) if (System.getProperty("openrocket.debug.menu") != null) { menubar.add(makeDebugMenu()); } - - - //// Help - + //// Help menu = new JMenu(trans.get("main.menu.help")); menu.setMnemonic(KeyEvent.VK_H); menu.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.desc")); menubar.add(menu); - - // Guided tours - + //// Guided tours item = new JMenuItem(trans.get("main.menu.help.tours"), KeyEvent.VK_L); item.setIcon(Icons.HELP_TOURS); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.tours.desc")); @@ -812,7 +840,7 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - //// Bug report + //// Bug report item = new JMenuItem(trans.get("main.menu.help.bugReport"), KeyEvent.VK_B); item.setIcon(Icons.HELP_BUG_REPORT); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.bugReport.desc")); @@ -825,9 +853,9 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Debug log + //// Debug log item = new JMenuItem(trans.get("main.menu.help.debugLog"), KeyEvent.VK_D); - item.setIcon(Icons.HELP_DEBUG_LOG); + item.setIcon(Icons.HELP_DEBUG_LOG); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, SHORTCUT_KEY)); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.debugLog.desc")); item.addActionListener(new ActionListener() { @@ -841,8 +869,7 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - - //// License + //// License item = new JMenuItem(trans.get("main.menu.help.license"), KeyEvent.VK_L); item.setIcon(Icons.HELP_LICENSE); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.license.desc")); @@ -855,8 +882,7 @@ public class BasicFrame extends JFrame { }); menu.add(item); - - //// About + //// About item = new JMenuItem(trans.get("main.menu.help.about"), KeyEvent.VK_A); item.setIcon(Icons.HELP_ABOUT); item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.about.desc")); @@ -869,7 +895,6 @@ public class BasicFrame extends JFrame { }); menu.add(item); - this.setJMenuBar(menubar); } @@ -881,12 +906,13 @@ public class BasicFrame extends JFrame { * This menu is intentionally left untranslated. */ - //// Debug menu + //// Debug menu menu = new JMenu("Debug"); - //// OpenRocket debugging tasks + + //// OpenRocket debugging tasks menu.getAccessibleContext().setAccessibleDescription("OpenRocket debugging tasks"); - //// What is this menu? + //// What is this menu? item = new JMenuItem("What is this menu?"); item.addActionListener(new ActionListener() { @Override @@ -906,7 +932,7 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - //// Create test rocket + //// Create test rocket item = new JMenuItem("Create test rocket"); item.addActionListener(new ActionListener() { @Override @@ -939,7 +965,6 @@ public class BasicFrame extends JFrame { menu.add(item); - item = new JMenuItem("Create 'Iso-Haisu'"); item.addActionListener(new ActionListener() { @Override @@ -954,7 +979,6 @@ public class BasicFrame extends JFrame { }); menu.add(item); - item = new JMenuItem("Create 'Big Blue'"); item.addActionListener(new ActionListener() { @Override @@ -971,14 +995,13 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - item = new JMenuItem("Memory statistics"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { log.info(Markers.USER_MARKER, "Memory statistics selected"); - // Get discarded but remaining objects (this also runs System.gc multiple times) + // // Get discarded but remaining objects (this also runs System.gc multiple times) List objects = MemoryManagement.getRemainingCollectableObjects(); StringBuilder sb = new StringBuilder(); sb.append("Objects that should have been garbage-collected but have not been:\n"); @@ -990,7 +1013,7 @@ public class BasicFrame extends JFrame { sb.append("Age ").append(System.currentTimeMillis() - data.getRegistrationTime()) .append(" ms: ").append(o).append('\n'); count++; - // Explicitly null the strong reference to avoid possibility of invisible references + // // Explicitly null the strong reference to avoid possibility of invisible references o = null; } sb.append("Total: " + count); @@ -1013,7 +1036,7 @@ public class BasicFrame extends JFrame { }); menu.add(item); - //// Exhaust memory + //// Exhaust memory item = new JMenuItem("Exhaust memory"); item.addActionListener(new ActionListener() { @Override @@ -1043,10 +1066,9 @@ public class BasicFrame extends JFrame { }); menu.add(item); - menu.addSeparator(); - //// Exception here + //// Exception here item = new JMenuItem("Exception here"); item.addActionListener(new ActionListener() { @Override @@ -1101,7 +1123,6 @@ public class BasicFrame extends JFrame { menu.addSeparator(); - item = new JMenuItem("Test popup"); item.addActionListener(new ActionListener() { @Override @@ -1118,9 +1139,6 @@ public class BasicFrame extends JFrame { }); menu.add(item); - - - return menu; } @@ -1169,7 +1187,7 @@ public class BasicFrame extends JFrame { } } - private void importAction() { + public void importAction() { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(FileHelper.ALL_DESIGNS_FILTER); @@ -1213,6 +1231,7 @@ public class BasicFrame extends JFrame { } + /** * Open a file based on a URL. * @param url the file to open. @@ -1247,8 +1266,7 @@ public class BasicFrame extends JFrame { displayName = displayName.substring(displayName.lastIndexOf('/') + 1); } - - // Open the file + //// Open the file log.info("Opening file from url=" + url + " filename=" + displayName); OpenFileWorker worker = new OpenFileWorker(url); @@ -1281,16 +1299,15 @@ public class BasicFrame extends JFrame { * @return */ private static boolean open(OpenFileWorker worker, String displayName, Window parent, boolean openRocketConfigDialog) { - // Open the file in a Swing worker thread + //// Open the file in a Swing worker thread log.info("Starting OpenFileWorker"); if (!SwingWorkerDialog.runWorker(parent, "Opening file", "Reading " + displayName + "...", worker)) { - // User cancelled the operation + // // User cancelled the operation log.info("User cancelled the OpenFileWorker"); return false; } - - // Handle the document + //// Handle the document OpenRocketDocument doc = null; try { @@ -1332,22 +1349,22 @@ public class BasicFrame extends JFrame { } - // Show warnings + //// Show warnings WarningSet warnings = worker.getRocketLoader().getWarnings(); if (!warnings.isEmpty()) { log.info("Warnings while reading file: " + warnings); WarningDialog.showWarnings(parent, new Object[] { - //// The following problems were encountered while opening + // // The following problems were encountered while opening trans.get("BasicFrame.WarningDialog.txt1") + " " + displayName + ".", - //// Some design features may not have been loaded correctly. + // // Some design features may not have been loaded correctly. trans.get("BasicFrame.WarningDialog.txt2") }, - //// Warnings while opening file + // // Warnings while opening file trans.get("BasicFrame.WarningDialog.title"), warnings); } - // Open the frame + //// Open the frame log.debug("Opening new frame with the document"); BasicFrame frame = new BasicFrame(doc); frame.setVisible(true); @@ -1362,6 +1379,7 @@ public class BasicFrame extends JFrame { return true; } + /** * "Save" action. If the design is new, then this is identical to "Save As", with a default file filter for .ork. * If the rocket being edited previously was opened from a .ork file, then it will be saved immediately to the same @@ -1376,20 +1394,40 @@ public class BasicFrame extends JFrame { log.info("Document does not contain file, opening save as dialog instead"); return saveAsAction(); } - log.info("Saving document to " + file); - return saveAsOpenRocket(file); } - /** - * "Export" action. + //// BEGIN RASAERO Export Action *** UNDER CONSTRUCTION -- CURRENTLY FOR TESTING ONLY *** + /** + * MODEL "Export as" RASAero file format * - * @return true if the file was saved, false otherwise + * @return true if the file was saved, false otherwise */ - private boolean exportAction() { - File file = null; + + /* + public boolean exportRASAeroAction() { + Object exportRASAeroAction = ExportFileTranslator_RASAero.exportRASAeroAction; + return false; + } + */ + //// END RASAERO Export Action + + public void actionPerformed(ActionEvent e) { + log.info(Markers.USER_MARKER, "Import... selected"); + importAction(); + } + + + //// BEGIN ROCKSIM Export Action + /** + * MODEL "Export as" RASAero file format + * + * @return true if the file was saved, false otherwise + */ + public boolean exportRocksimAction() { + File file; final SaveAsFileChooser chooser = SaveAsFileChooser.build(document, FileType.ROCKSIM); @@ -1414,6 +1452,8 @@ public class BasicFrame extends JFrame { } return false; } + // END ROCKSIM Export Action + /** * Perform the writing of the design to the given file in Rocksim format. @@ -1454,6 +1494,7 @@ public class BasicFrame extends JFrame { return saveRocksimFile(file, options); } + /** * Perform the actual saving of the Rocksim file * @param file file to be stored @@ -1473,10 +1514,11 @@ public class BasicFrame extends JFrame { if (!DecalNotFoundDialog.showDialog(null, decex) && decal != null) { decal.setIgnored(true); } - return saveRocksimFile(file, options); // Resave + return saveRocksimFile(file, options); // Re-save } } + /** * "Save As" action. * @@ -1512,6 +1554,7 @@ public class BasicFrame extends JFrame { return result; } + /** * Perform the writing of the design to the given file in OpenRocket format. * @@ -1565,7 +1608,7 @@ public class BasicFrame extends JFrame { if (!DecalNotFoundDialog.showDialog(null, decex) && decal != null) { decal.setIgnored(true); } - return saveAsOpenRocket(file); // Resave + return saveAsOpenRocket(file); // Re-save } else { Reflection.handleWrappedException(e); @@ -1631,6 +1674,7 @@ public class BasicFrame extends JFrame { new PrintDialog(this, document, rotation).setVisible(true); } + /** * Open a new design window with a basic rocket+stage. */ @@ -1644,6 +1688,7 @@ public class BasicFrame extends JFrame { frame.setVisible(true); } + /** * Quit the application. Confirms saving unsaved designs. The action of File->Quit. */ @@ -1683,7 +1728,6 @@ public class BasicFrame extends JFrame { } - /** * Find a currently open BasicFrame containing the specified rocket. This method * can be used to map a Rocket to a BasicFrame from GUI methods. @@ -1734,8 +1778,10 @@ public class BasicFrame extends JFrame { simulationPanel.activating(); } } -} + public void open() { + } +} class BasicFrame_changeAdapter implements javax.swing.event.ChangeListener { BasicFrame adaptee; @@ -1747,4 +1793,3 @@ class BasicFrame_changeAdapter implements javax.swing.event.ChangeListener { adaptee.stateChanged(e); } } - diff --git a/swing/src/net/sf/openrocket/gui/util/ExportFileTranslator_RASAero.java b/swing/src/net/sf/openrocket/gui/util/ExportFileTranslator_RASAero.java new file mode 100644 index 000000000..18d8c6f93 --- /dev/null +++ b/swing/src/net/sf/openrocket/gui/util/ExportFileTranslator_RASAero.java @@ -0,0 +1,10 @@ +package net.sf.openrocket.gui.util; + +public interface ExportFileTranslator_RASAero { + /* + Utility that translates OpenRocket models to RASAero .CDX1 file format. + + @author H. Craig Miller + */ +// Object exportRASAeroAction = ; +} diff --git a/swing/src/net/sf/openrocket/gui/util/Icons.java b/swing/src/net/sf/openrocket/gui/util/Icons.java index 76ed87fdd..b3814e98e 100644 --- a/swing/src/net/sf/openrocket/gui/util/Icons.java +++ b/swing/src/net/sf/openrocket/gui/util/Icons.java @@ -1,20 +1,17 @@ package net.sf.openrocket.gui.util; -import java.net.URL; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import javax.swing.Icon; -import javax.swing.ImageIcon; - import net.sf.openrocket.document.Simulation; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.startup.Application; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.swing.*; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + public class Icons { private static final Logger log = LoggerFactory.getLogger(Icons.class); @@ -52,10 +49,13 @@ public class Icons { public static final Icon FILE_OPEN_EXAMPLE = loadImageIcon("pix/icons/document-open-example.png", "Open example document"); public static final Icon FILE_SAVE = loadImageIcon("pix/icons/document-save.png", "Save document"); public static final Icon FILE_SAVE_AS = loadImageIcon("pix/icons/document-save-as.png", "Save document as"); - public static final Icon FILE_PRINT = loadImageIcon("pix/icons/document-print.png", "Print document"); + public static final Icon SAVE_DECAL = loadImageIcon("pix/icons/Painting-Transparent-PNG_16.png", "Save decal image"); + public static final Icon FILE_PRINT = loadImageIcon("pix/icons/document-print-specs.png", "Print specifications"); +// public static final Icon FILE_IMPORT = loadImageIcon("pix/icons/model_import.png", "Import"); + public static final Icon FILE_EXPORT_AS = loadImageIcon("pix/icons/model_export.png", "Export model as"); + public static final Icon ENCODE_3D = loadImageIcon("pix/icons/model_encode3d.png", "Encode 3D"); public static final Icon FILE_CLOSE = loadImageIcon("pix/icons/document-close.png", "Close document"); public static final Icon FILE_QUIT = loadImageIcon("pix/icons/application-exit.png", "Quit OpenRocket"); - public static final Icon EDIT_UNDO = loadImageIcon("pix/icons/edit-undo.png", trans.get("Icons.Undo")); public static final Icon EDIT_REDO = loadImageIcon("pix/icons/edit-redo.png", trans.get("Icons.Redo")); public static final Icon EDIT_CUT = loadImageIcon("pix/icons/edit-cut.png", "Cut"); @@ -88,8 +88,12 @@ public class Icons { public static final Icon CG_OVERRIDE = loadImageIcon("pix/icons/cg-override.png", "CG Override"); public static final Icon MASS_OVERRIDE = loadImageIcon("pix/icons/mass-override.png", "Mass Override"); - - + +// MANUFACTURERS ICONS + public static final Icon RASAERO_ICON = loadImageIcon("pix/icons/RASAero_16.png", "RASAero Icon"); + public static final Icon ROCKSIM_ICON = loadImageIcon("pix/icons/Rocksim_16.png", "Rocksim Icon"); + + static { log.debug("Icons loaded"); } @@ -101,7 +105,7 @@ public class Icons { * * @param file the file to load. * @param name the description of the icon. - * @return the ImageIcon, or null if could not be loaded (after the user closes the dialog) + * @return the ImageIcon, or null if the ImageIcon could not be loaded (after the user closes the dialog) */ public static ImageIcon loadImageIcon(String file, String name) { if (System.getProperty("openrocket.unittest") != null) {