1 package net.sf.openrocket.gui.dialogs.preset;
4 import java.awt.Dialog;
5 import java.awt.Window;
6 import java.awt.event.ActionEvent;
7 import java.awt.event.ActionListener;
9 import javax.swing.JButton;
10 import javax.swing.JDialog;
11 import javax.swing.JPanel;
13 import net.miginfocom.swing.MigLayout;
14 import net.sf.openrocket.gui.util.GUIUtil;
15 import net.sf.openrocket.l10n.Translator;
16 import net.sf.openrocket.preset.ComponentPreset;
17 import net.sf.openrocket.startup.Application;
19 public class ComponentPresetChooserDialog extends JDialog {
21 // private final ThrustCurveMotorSelectionPanel selectionPanel;
23 private boolean okClicked = false;
24 private static final Translator trans = Application.getTranslator();
27 public ComponentPresetChooserDialog(Window owner) {
28 super(owner, trans.get("CompPresetChooser.title"), Dialog.ModalityType.APPLICATION_MODAL);
30 JPanel panel = new JPanel(new MigLayout("fill"));
32 //selectionPanel = new ThrustCurveMotorSelectionPanel((ThrustCurveMotor) current, delay, diameter);
34 //panel.add(selectionPanel, "grow, wrap para");
37 // OK / Cancel buttons
38 JButton okButton = new JButton(trans.get("dlg.but.ok"));
39 okButton.addActionListener(new ActionListener() {
41 public void actionPerformed(ActionEvent e) {
45 panel.add(okButton, "tag ok, spanx, split");
48 JButton cancelButton = new JButton(trans.get("dlg.but.cancel"));
49 cancelButton.addActionListener(new ActionListener() {
51 public void actionPerformed(ActionEvent e) {
55 panel.add(cancelButton, "tag cancel");
61 this.setLocationByPlatform(true);
62 GUIUtil.setDisposableDialogOptions(this, okButton);
64 //JComponent focus = selectionPanel.getDefaultFocus();
65 //if (focus != null) {
69 // Set the closeable dialog after all initialization
70 //selectionPanel.setCloseableDialog(this);
75 * Return the motor selected by this chooser dialog, or <code>null</code> if the selection has been aborted.
77 * @return the selected motor, or <code>null</code> if no motor has been selected or the selection was canceled.
79 public ComponentPreset getSelectedComponentPreset() {
82 //return selectionPanel.getSelectedMotor();
86 public void close(boolean ok) {
88 this.setVisible(false);
90 ComponentPreset preset = getSelectedComponentPreset();
91 if (okClicked && preset != null) {
92 //selectionPanel.selectedMotor(selected);