Removed ExampleDesignDialog which was replaced by the Open Example
cascading menu.
This commit is contained in:
parent
31d6baffd4
commit
4ff2eb11ec
@ -1,112 +0,0 @@
|
|||||||
package net.sf.openrocket.gui.dialogs;
|
|
||||||
|
|
||||||
import java.awt.Dialog;
|
|
||||||
import java.awt.Window;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.ListSelectionModel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import net.sf.openrocket.gui.main.ExampleDesignFile;
|
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
|
||||||
import net.sf.openrocket.l10n.Translator;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
|
|
||||||
public class ExampleDesignDialog extends JDialog {
|
|
||||||
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
|
||||||
|
|
||||||
private boolean open = false;
|
|
||||||
private final JList designSelection;
|
|
||||||
|
|
||||||
private ExampleDesignDialog(ExampleDesignFile[] designs, Window parent) {
|
|
||||||
//// Open example design
|
|
||||||
super(parent, trans.get("exdesigndlg.lbl.Openexampledesign"), Dialog.ModalityType.APPLICATION_MODAL);
|
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
|
||||||
|
|
||||||
//// Select example designs to open:
|
|
||||||
panel.add(new JLabel(trans.get("exdesigndlg.lbl.Selectexample")), "wrap");
|
|
||||||
|
|
||||||
designSelection = new JList(designs);
|
|
||||||
designSelection.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
|
||||||
designSelection.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
if (e.getClickCount() >= 2) {
|
|
||||||
open = true;
|
|
||||||
ExampleDesignDialog.this.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(new JScrollPane(designSelection), "grow, wmin 300lp, wrap para");
|
|
||||||
|
|
||||||
//// Open button
|
|
||||||
JButton openButton = new JButton(trans.get("exdesigndlg.but.open"));
|
|
||||||
openButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
open = true;
|
|
||||||
ExampleDesignDialog.this.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(openButton, "split 2, sizegroup buttons, growx");
|
|
||||||
|
|
||||||
//// Cancel button
|
|
||||||
JButton cancelButton = new JButton(trans.get("dlg.but.cancel"));
|
|
||||||
cancelButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
open = false;
|
|
||||||
ExampleDesignDialog.this.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(cancelButton, "sizegroup buttons, growx");
|
|
||||||
|
|
||||||
this.add(panel);
|
|
||||||
this.pack();
|
|
||||||
this.setLocationByPlatform(true);
|
|
||||||
|
|
||||||
GUIUtil.setDisposableDialogOptions(this, openButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open a dialog to allow opening the example designs.
|
|
||||||
*
|
|
||||||
* @param parent the parent window of the dialog.
|
|
||||||
* @return an array of URL's to open, or <code>null</code> if the operation
|
|
||||||
* was cancelled.
|
|
||||||
*/
|
|
||||||
public static URL[] selectExampleDesigns(Window parent) {
|
|
||||||
|
|
||||||
ExampleDesignFile[] designs = ExampleDesignFile.getExampleDesigns();
|
|
||||||
|
|
||||||
ExampleDesignDialog dialog = new ExampleDesignDialog(designs, parent);
|
|
||||||
dialog.setVisible(true);
|
|
||||||
|
|
||||||
if (!dialog.open) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object[] selected = dialog.designSelection.getSelectedValues();
|
|
||||||
URL[] urls = new URL[selected.length];
|
|
||||||
int i = 0;
|
|
||||||
for (Object obj : selected) {
|
|
||||||
ExampleDesignFile file = (ExampleDesignFile) obj;
|
|
||||||
urls[i++] = file.getURL();
|
|
||||||
}
|
|
||||||
return urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -73,7 +73,6 @@ import net.sf.openrocket.gui.dialogs.BugReportDialog;
|
|||||||
import net.sf.openrocket.gui.dialogs.ComponentAnalysisDialog;
|
import net.sf.openrocket.gui.dialogs.ComponentAnalysisDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.DebugLogDialog;
|
import net.sf.openrocket.gui.dialogs.DebugLogDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.DetailDialog;
|
import net.sf.openrocket.gui.dialogs.DetailDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.ExampleDesignDialog;
|
|
||||||
import net.sf.openrocket.gui.dialogs.LicenseDialog;
|
import net.sf.openrocket.gui.dialogs.LicenseDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.PrintDialog;
|
import net.sf.openrocket.gui.dialogs.PrintDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.ScaleDialog;
|
import net.sf.openrocket.gui.dialogs.ScaleDialog;
|
||||||
@ -429,34 +428,12 @@ public class BasicFrame extends JFrame {
|
|||||||
item.setIcon(Icons.FILE_OPEN);
|
item.setIcon(Icons.FILE_OPEN);
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
// FIXME - one of these two example menu items needs to be removed.
|
|
||||||
//// Open example...
|
//// Open example...
|
||||||
item = new ExampleDesignFileAction(trans.get("main.menu.file.openExample"), this);
|
item = new ExampleDesignFileAction(trans.get("main.menu.file.openExample"), this);
|
||||||
item.getAccessibleContext().setAccessibleDescription(trans.get("BasicFrame.item.Openexamplerocketdesign"));
|
item.getAccessibleContext().setAccessibleDescription(trans.get("BasicFrame.item.Openexamplerocketdesign"));
|
||||||
item.setIcon(Icons.FILE_OPEN_EXAMPLE);
|
item.setIcon(Icons.FILE_OPEN_EXAMPLE);
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
||||||
//// Open example...
|
|
||||||
item = new JMenuItem(trans.get("main.menu.file.openExample"));
|
|
||||||
item.getAccessibleContext().setAccessibleDescription(trans.get("BasicFrame.item.Openexamplerocketdesign"));
|
|
||||||
item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
|
|
||||||
SHORTCUT_KEY | ActionEvent.SHIFT_MASK));
|
|
||||||
item.setIcon(Icons.FILE_OPEN_EXAMPLE);
|
|
||||||
item.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
log.user("Open example... selected");
|
|
||||||
URL[] urls = ExampleDesignDialog.selectExampleDesigns(BasicFrame.this);
|
|
||||||
if (urls != null) {
|
|
||||||
for (URL u : urls) {
|
|
||||||
log.user("Opening example " + u);
|
|
||||||
open(u, BasicFrame.this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(item);
|
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
//// Save
|
//// Save
|
||||||
|
Loading…
x
Reference in New Issue
Block a user