Merge branch 'master' of https://github.com/openrocket/openrocket into parallel_staging
Conflicts: swing/src/net/sf/openrocket/gui/main/BasicFrame.java (resolved)
This commit is contained in:
commit
238726f371
@ -258,6 +258,7 @@ pref.dlg.tab.Design = Design
|
||||
pref.dlg.tab.Simulation = Simulation
|
||||
pref.dlg.tab.Launch = Launch
|
||||
pref.dlg.tab.Miscellaneousoptions = Miscellaneous options
|
||||
pref.dlg.lbl.RockSimWarning = Show warning when saving in RockSim format
|
||||
|
||||
pref.dlg.tab.Graphics = Graphics
|
||||
pref.dlg.lbl.DecalEditor = Graphics Editor
|
||||
@ -1158,6 +1159,13 @@ FinsetCfg.ttip.Finfillets1 = <HTML>Adds the predicted mass of fin fillets to the
|
||||
FinsetCfg.ttip.Finfillets2 = Assumes the fillet is concave and tangent to the body tube and fin.<br>
|
||||
FinsetCfg.ttip.Finfillets3 = Zero radius will give no fillet.
|
||||
|
||||
! Save RKT Warning Dialog
|
||||
SaveRktWarningDialog.txt1=Exporting to RockSim file format does not support all features of OpenRocket.
|
||||
SaveRktWarningDialog.donotshow=Do not show this dialog again
|
||||
|
||||
saveAs.openrocket.title=Save as OpenRocket ork file
|
||||
saveAs.rocksim.title=Export as RockSim rkt file
|
||||
|
||||
! StorageOptionChooser
|
||||
StorageOptChooser.lbl.Simdatatostore = Simulated data to store:
|
||||
StorageOptChooser.rdbut.Allsimdata = All simulated data
|
||||
@ -1225,26 +1233,30 @@ 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...
|
||||
BasicFrame.item.Openrocketdesign = Open a rocket design
|
||||
main.menu.file.open.desc = Open a rocket design
|
||||
main.menu.file.openRecent = Open Recent...
|
||||
BasicFrame.item.Openrecentrocketdesign = Open a recent rocket design
|
||||
main.menu.file.openExample = Open example...
|
||||
BasicFrame.item.Openexamplerocketdesign = Open an example rocket design
|
||||
main.menu.file.openRecent.desc = Open a recent rocket design
|
||||
main.menu.file.openExample = Open Example...
|
||||
main.menu.file.openExample.desc = Open an example rocket design
|
||||
main.menu.file.save = Save
|
||||
BasicFrame.item.SavecurRocketdesign = Save the current rocket design
|
||||
main.menu.file.save.desc = Save the current rocket design
|
||||
main.menu.file.saveAs = Save as...
|
||||
BasicFrame.item.SavecurRocketdesnewfile = Save the current rocket design to a new file
|
||||
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
|
||||
BasicFrame.item.Closedesign = Close the current rocket design
|
||||
main.menu.file.close.desc = Close the current rocket design
|
||||
main.menu.file.quit = Quit
|
||||
BasicFrame.item.Quitprogram = Quit the program
|
||||
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.edit = Edit
|
||||
BasicFrame.menu.Rocketedt = Rocket editing
|
||||
main.menu.edit.desc = Rocket editing
|
||||
main.menu.edit.undo = Undo
|
||||
main.menu.edit.undo.desc = Undo the previous operation
|
||||
main.menu.edit.redo = Redo
|
||||
|
@ -12,6 +12,7 @@ import org.xml.sax.SAXException;
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.Simulation;
|
||||
import net.sf.openrocket.document.StorageOptions;
|
||||
import net.sf.openrocket.document.StorageOptions.FileType;
|
||||
import net.sf.openrocket.file.AbstractRocketLoader;
|
||||
import net.sf.openrocket.file.DocumentLoadingContext;
|
||||
import net.sf.openrocket.file.RocketLoadException;
|
||||
@ -70,7 +71,7 @@ public class OpenRocketLoader extends AbstractRocketLoader {
|
||||
List<Double> list = branch.get(FlightDataType.TYPE_TIME);
|
||||
if (list == null)
|
||||
continue;
|
||||
|
||||
|
||||
double previousTime = Double.NaN;
|
||||
for (double time : list) {
|
||||
if (time - previousTime < timeSkip)
|
||||
@ -81,6 +82,7 @@ public class OpenRocketLoader extends AbstractRocketLoader {
|
||||
timeSkip = Math.rint(timeSkip * 100) / 100;
|
||||
doc.getDefaultStorageOptions().setSimulationTimeSkip(timeSkip);
|
||||
doc.getDefaultStorageOptions().setExplicitlySet(false);
|
||||
doc.getDefaultStorageOptions().setFileType(FileType.OPENROCKET);
|
||||
|
||||
// Call simulation extensions
|
||||
for (Simulation sim : doc.getSimulations()) {
|
||||
|
@ -6,14 +6,15 @@ package net.sf.openrocket.file.rocksim.importt;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import net.sf.openrocket.document.StorageOptions.FileType;
|
||||
import net.sf.openrocket.file.AbstractRocketLoader;
|
||||
import net.sf.openrocket.file.DocumentLoadingContext;
|
||||
import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.file.simplesax.SimpleSAX;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* This class is the main entry point for Rocksim design file imported to OpenRocket. Currently only Rocksim v9
|
||||
* file formats are supported, although it is possible that v8 formats will work for most components.
|
||||
@ -52,5 +53,6 @@ public class RocksimLoader extends AbstractRocketLoader {
|
||||
|
||||
context.getOpenRocketDocument().setFile(null);
|
||||
context.getOpenRocketDocument().clearUndo();
|
||||
context.getOpenRocketDocument().getDefaultStorageOptions().setFileType(FileType.ROCKSIM);
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
// Node names
|
||||
public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
|
||||
private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN";
|
||||
private static final String SHOW_ROCKSIM_FORMAT_WARNING = "SHOW_ROCKSIM_FORMAT_WARNING";
|
||||
|
||||
//Preferences related to 3D graphics
|
||||
public static final String OPENGL_ENABLED = "OpenGL_Is_Enabled";
|
||||
@ -163,6 +164,14 @@ public abstract class Preferences implements ChangeSource {
|
||||
this.putBoolean(LAUNCH_INTO_WIND, check);
|
||||
}
|
||||
|
||||
public final boolean getShowRockSimFormatWarning() {
|
||||
return this.getBoolean(SHOW_ROCKSIM_FORMAT_WARNING, true);
|
||||
}
|
||||
|
||||
public final void setShowRockSimFormatWarning(boolean check) {
|
||||
this.putBoolean(SHOW_ROCKSIM_FORMAT_WARNING, check);
|
||||
}
|
||||
|
||||
public final double getDefaultMach() {
|
||||
return Application.getPreferences().getChoice(Preferences.DEFAULT_MACH_NUMBER, 0.9, 0.3);
|
||||
}
|
||||
@ -534,7 +543,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
String color = get("componentColors", c, StaticFieldHolder.DEFAULT_COLORS);
|
||||
if (color == null)
|
||||
return Color.BLACK;
|
||||
|
||||
|
||||
Color clr = parseColor(color);
|
||||
if (clr != null) {
|
||||
return clr;
|
||||
@ -585,7 +594,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
public Material getDefaultComponentMaterial(
|
||||
Class<? extends RocketComponent> componentClass,
|
||||
Material.Type type) {
|
||||
|
||||
|
||||
String material = get("componentMaterials", componentClass, null);
|
||||
if (material != null) {
|
||||
try {
|
||||
@ -614,7 +623,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
*/
|
||||
public void setDefaultComponentMaterial(
|
||||
Class<? extends RocketComponent> componentClass, Material material) {
|
||||
|
||||
|
||||
putString("componentMaterials", componentClass.getSimpleName(),
|
||||
material == null ? null : material.toStorableString());
|
||||
}
|
||||
@ -690,7 +699,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
protected String get(String directory,
|
||||
Class<? extends RocketComponent> componentClass,
|
||||
Map<Class<?>, String> defaultMap) {
|
||||
|
||||
|
||||
// Search preferences
|
||||
Class<?> c = componentClass;
|
||||
while (c != null && RocketComponent.class.isAssignableFrom(c)) {
|
||||
@ -702,7 +711,7 @@ public abstract class Preferences implements ChangeSource {
|
||||
|
||||
if (defaultMap == null)
|
||||
return null;
|
||||
|
||||
|
||||
// Search defaults
|
||||
c = componentClass;
|
||||
while (RocketComponent.class.isAssignableFrom(c)) {
|
||||
@ -737,12 +746,14 @@ public abstract class Preferences implements ChangeSource {
|
||||
*/
|
||||
|
||||
private static final HashMap<Class<?>, String> DEFAULT_LINE_STYLES = new HashMap<Class<?>, String>();
|
||||
|
||||
static {
|
||||
DEFAULT_LINE_STYLES.put(RocketComponent.class, LineStyle.SOLID.name());
|
||||
DEFAULT_LINE_STYLES.put(MassObject.class, LineStyle.DASHED.name());
|
||||
}
|
||||
|
||||
private static final HashMap<Class<?>, String> DEFAULT_COLORS = new HashMap<Class<?>, String>();
|
||||
|
||||
static {
|
||||
DEFAULT_COLORS.put(BodyComponent.class, "0,0,240");
|
||||
DEFAULT_COLORS.put(TubeFinSet.class, "0,0,200");
|
||||
|
@ -208,6 +208,30 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
||||
}
|
||||
});
|
||||
this.add(button, "right, wrap");
|
||||
|
||||
//// Open most recent file on startup
|
||||
final JCheckBox openRecentOnStartupBox = new JCheckBox(trans.get("pref.dlg.but.openlast"));
|
||||
openRecentOnStartupBox.setSelected(preferences.isAutoOpenLastDesignOnStartupEnabled());
|
||||
openRecentOnStartupBox.addActionListener( new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
preferences.setAutoOpenLastDesignOnStartup(openRecentOnStartupBox.isSelected());
|
||||
}
|
||||
});
|
||||
this.add(openRecentOnStartupBox,"spanx, wrap");
|
||||
|
||||
//// Save RockSim Format warning dialog
|
||||
final JCheckBox rocksimWarningDialogBox = new JCheckBox(trans.get("pref.dlg.lbl.RockSimWarning"));
|
||||
rocksimWarningDialogBox.setSelected(preferences.getShowRockSimFormatWarning());
|
||||
rocksimWarningDialogBox.addActionListener( new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
preferences.setShowRockSimFormatWarning(rocksimWarningDialogBox.isSelected());
|
||||
}
|
||||
});
|
||||
this.add(rocksimWarningDialogBox,"spanx, wrap");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
package net.sf.openrocket.gui;
|
||||
package net.sf.openrocket.gui.main;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
113
swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java
Normal file
113
swing/src/net/sf/openrocket/gui/main/SaveAsFileChooser.java
Normal file
@ -0,0 +1,113 @@
|
||||
package net.sf.openrocket.gui.main;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
|
||||
import net.sf.openrocket.document.OpenRocketDocument;
|
||||
import net.sf.openrocket.document.StorageOptions;
|
||||
import net.sf.openrocket.document.StorageOptions.FileType;
|
||||
import net.sf.openrocket.gui.util.FileHelper;
|
||||
import net.sf.openrocket.gui.util.SimpleFileFilter;
|
||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
|
||||
public class SaveAsFileChooser extends JFileChooser {
|
||||
|
||||
private final FileType type;
|
||||
private final OpenRocketDocument document;
|
||||
private final StorageOptionChooser storageChooser;
|
||||
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
public static SaveAsFileChooser build( OpenRocketDocument document, FileType type ) {
|
||||
return new SaveAsFileChooser(document,type);
|
||||
}
|
||||
|
||||
private SaveAsFileChooser( OpenRocketDocument document, FileType type ) {
|
||||
this.document = document;
|
||||
this.type = type;
|
||||
|
||||
this.setAcceptAllFileFilterUsed(true);
|
||||
|
||||
File defaultFilename = document.getFile();
|
||||
|
||||
switch( type ) {
|
||||
default:
|
||||
case OPENROCKET:
|
||||
defaultFilename = FileHelper.forceExtension(defaultFilename,"ork");
|
||||
this.setDialogTitle(trans.get("saveAs.openrocket.title"));
|
||||
storageChooser = new StorageOptionChooser(document, document.getDefaultStorageOptions());
|
||||
this.setAccessory(storageChooser);
|
||||
this.addChoosableFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||
this.setFileFilter(FileHelper.OPENROCKET_DESIGN_FILTER);
|
||||
break;
|
||||
case ROCKSIM:
|
||||
defaultFilename = FileHelper.forceExtension(defaultFilename,"rkt");
|
||||
this.setDialogTitle(trans.get("saveAs.rocksim.title"));
|
||||
storageChooser = null;
|
||||
this.addChoosableFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
||||
this.setFileFilter(FileHelper.ROCKSIM_DESIGN_FILTER);
|
||||
break;
|
||||
}
|
||||
|
||||
final RememberFilenamePropertyListener listner = new RememberFilenamePropertyListener();
|
||||
this.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, listner);
|
||||
this.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, listner);
|
||||
this.addPropertyChangeListener(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY, listner);
|
||||
|
||||
this.setCurrentDirectory(((SwingPreferences) Application.getPreferences()).getDefaultDirectory());
|
||||
|
||||
if (defaultFilename != null) {
|
||||
this.setSelectedFile(defaultFilename);
|
||||
}
|
||||
}
|
||||
|
||||
public void storeOptions(StorageOptions opts) {
|
||||
if ( storageChooser != null ) {
|
||||
storageChooser.storeOptions(opts);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RememberFilenamePropertyListener implements PropertyChangeListener {
|
||||
private String oldFileName=null;
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event){
|
||||
if( JFileChooser.SELECTED_FILE_CHANGED_PROPERTY == event.getPropertyName()){
|
||||
if(null != event.getOldValue()){
|
||||
this.oldFileName = ((File)event.getOldValue()).getName();
|
||||
}
|
||||
return;
|
||||
}else if(JFileChooser.FILE_FILTER_CHANGED_PROPERTY == event.getPropertyName()){
|
||||
JFileChooser chooser = (JFileChooser)event.getSource();
|
||||
SimpleFileFilter filter = (SimpleFileFilter)(chooser.getFileFilter());
|
||||
String desiredExtension = filter.getExtensions()[0];
|
||||
|
||||
if( null == this.oldFileName){
|
||||
return;
|
||||
}
|
||||
String thisFileName = this.oldFileName;
|
||||
|
||||
if ( filter.accept( new File(thisFileName))){
|
||||
// nop
|
||||
return;
|
||||
}else{
|
||||
String[] splitResults = thisFileName.split("\\.");
|
||||
if(0 < splitResults.length){
|
||||
thisFileName = splitResults[0];
|
||||
}
|
||||
chooser.setSelectedFile(new File( thisFileName+desiredExtension));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.sf.openrocket.gui;
|
||||
package net.sf.openrocket.gui.main;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
@ -117,7 +117,9 @@ public final class FileHelper {
|
||||
* @return the resulting file
|
||||
*/
|
||||
public static File forceExtension(File original, String extension) {
|
||||
|
||||
if ( original == null ) {
|
||||
return null;
|
||||
}
|
||||
if (!original.getName().toLowerCase(Locale.ENGLISH).endsWith(extension.toLowerCase(Locale.ENGLISH))) {
|
||||
log.debug("File name does not contain extension, adding '" + extension + "'");
|
||||
String name = original.getAbsolutePath();
|
||||
|
Loading…
x
Reference in New Issue
Block a user