Fixing various issues

This commit is contained in:
Sampo Niskanen 2012-02-19 08:23:22 +00:00
parent b1891e1dc1
commit 88f359c25f
10 changed files with 337 additions and 289 deletions

View File

@ -1,3 +1,7 @@
2012-02-16 Sampo Niskanen
* [BUG] Freeze when dropping component on child component
2012-02-10 Sampo Niskanen
* Configurable stage separation events

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -36,4 +36,5 @@ The following file format versions exist:
1.4: Introduced with OpenRocket 1.1.10. Adds the launchrodvelocity and
deploymentvelocity attributes to <flightdata> element. The motor
digesting algorithm was changed.
digesting algorithm was changed. Adds <separationevent> and
<separationdelay> elements to stage components (except sustainer).

View File

@ -34,3 +34,4 @@ help-license.png
help-log.png
help-about.png
help-bug.png
help-tours.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

View File

@ -360,7 +360,6 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
if (!calculateCG) {
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
}
// FIXME: Should this use CG_SPECIFIC ???
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
final String digest = motorDigest.getDigest();

View File

@ -1,5 +1,62 @@
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.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
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.JComponent;
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.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import net.miginfocom.swing.MigLayout;
import net.sf.openrocket.aerodynamics.WarningSet;
import net.sf.openrocket.document.OpenRocketDocument;
@ -48,38 +105,6 @@ import net.sf.openrocket.util.MemoryManagement.MemoryData;
import net.sf.openrocket.util.Reflection;
import net.sf.openrocket.util.TestRockets;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutionException;
public class BasicFrame extends JFrame {
private static final LogHelper log = Application.getLogger();
@ -652,7 +677,7 @@ public class BasicFrame extends JFrame {
// Guided tours
item = new JMenuItem(trans.get("main.menu.help.tours"), KeyEvent.VK_L);
// TODO: Icon
item.setIcon(Icons.HELP_TOURS);
item.getAccessibleContext().setAccessibleDescription(trans.get("main.menu.help.tours.desc"));
item.addActionListener(new ActionListener() {
@Override
@ -666,22 +691,6 @@ public class BasicFrame extends JFrame {
menu.addSeparator();
//// 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"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
log.user("License selected");
new LicenseDialog(BasicFrame.this).setVisible(true);
}
});
menu.add(item);
menu.addSeparator();
//// Bug report
item = new JMenuItem(trans.get("main.menu.help.bugReport"), KeyEvent.VK_B);
item.setIcon(Icons.HELP_BUG_REPORT);
@ -710,6 +719,21 @@ public class BasicFrame extends JFrame {
menu.addSeparator();
//// 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"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
log.user("License selected");
new LicenseDialog(BasicFrame.this).setVisible(true);
}
});
menu.add(item);
//// About
item = new JMenuItem(trans.get("main.menu.help.about"), KeyEvent.VK_A);
item.setIcon(Icons.HELP_ABOUT);

View File

@ -32,6 +32,7 @@ public class ComponentTreeTransferHandler extends TransferHandler {
private final OpenRocketDocument document;
/**
* Sole constructor.
*
@ -89,6 +90,17 @@ public class ComponentTreeTransferHandler extends TransferHandler {
boolean allowed = data.destParent.isCompatible(data.child);
log.verbose("Checking validity of drag-drop " + data.toString() + " allowed:" + allowed);
// Ensure we're not dropping a component onto a child component
RocketComponent path = data.destParent;
while (path != null) {
if (path.equals(data.child)) {
log.verbose("Drop would cause cycle in tree, disallowing.");
allowed = false;
break;
}
path = path.getParent();
}
// If drag-dropping to another rocket always copy
if (support.getDropAction() == MOVE && data.srcParent.getRoot() != data.destParent.getRoot()) {
support.setDropAction(COPY);
@ -98,7 +110,6 @@ public class ComponentTreeTransferHandler extends TransferHandler {
}
@Override
public boolean importData(TransferHandler.TransferSupport support) {

View File

@ -62,9 +62,10 @@ public class Icons {
public static final Icon EDIT_SCALE = loadImageIcon("pix/icons/edit-scale.png", "Scale");
public static final Icon HELP_ABOUT = loadImageIcon("pix/icons/help-about.png", "About");
public static final Icon HELP_LICENSE = loadImageIcon("pix/icons/help-license.png", "License");
public static final Icon HELP_BUG_REPORT = loadImageIcon("pix/icons/help-bug.png", "Bug report");
public static final Icon HELP_DEBUG_LOG = loadImageIcon("pix/icons/help-log.png", "Debug log");
public static final Icon HELP_LICENSE = loadImageIcon("pix/icons/help-license.png", "License");
public static final Icon HELP_TOURS = loadImageIcon("pix/icons/help-tours.png", "Guided tours");
public static final Icon ZOOM_IN = loadImageIcon("pix/icons/zoom-in.png", "Zoom in");
public static final Icon ZOOM_OUT = loadImageIcon("pix/icons/zoom-out.png", "Zoom out");

View File

@ -1138,10 +1138,18 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
*/
public void addChild(RocketComponent component, int index) {
checkState();
if (component.parent != null) {
throw new IllegalArgumentException("component " + component.getComponentName() +
" is already in a tree");
}
// Ensure that the no loops are created in component tree [A -> X -> Y -> B, B.addChild(A)]
if (this.getRoot().equals(component)) {
throw new IllegalStateException("Component " + component.getComponentName() +
" is a parent of " + this.getComponentName() + ", attempting to create cycle in tree.");
}
if (!isCompatible(component)) {
throw new IllegalStateException("Component " + component.getComponentName() +
" not currently compatible with component " + getComponentName());
@ -1156,7 +1164,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
fireAddRemoveEvent(component);
}
/**
* Removes a child from the rocket component tree.
*