Final refactoring. Changed names of a few startup classes. Move
ComponentPresetEditor and RocksimComponentFileTranslator to utils. Made all the injected classes in GuiModule Singleton scope.
This commit is contained in:
parent
15ecef0bd7
commit
f1aee31b5f
@ -27,7 +27,7 @@
|
|||||||
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
|
<property name="dist.src" value="${jar.dir}/${pkgname}-src.zip"/>
|
||||||
|
|
||||||
<!-- The main class of the application -->
|
<!-- The main class of the application -->
|
||||||
<property name="main-class" value="net.sf.openrocket.startup.JiJStartup"/>
|
<property name="main-class" value="net.sf.openrocket.startup.Startup"/>
|
||||||
|
|
||||||
<property name="expanded-libs" value="${lib.dir}/miglayout15-swing.jar"/>
|
<property name="expanded-libs" value="${lib.dir}/miglayout15-swing.jar"/>
|
||||||
|
|
||||||
|
@ -83,7 +83,6 @@ import net.sf.openrocket.gui.dialogs.optimization.GeneralOptimizationDialog;
|
|||||||
import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
|
import net.sf.openrocket.gui.dialogs.preferences.PreferencesDialog;
|
||||||
import net.sf.openrocket.gui.help.tours.GuidedTourSelectionDialog;
|
import net.sf.openrocket.gui.help.tours.GuidedTourSelectionDialog;
|
||||||
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
||||||
import net.sf.openrocket.gui.preset.ComponentPresetEditor;
|
|
||||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||||
import net.sf.openrocket.gui.util.FileHelper;
|
import net.sf.openrocket.gui.util.FileHelper;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
@ -101,6 +100,7 @@ import net.sf.openrocket.startup.Application;
|
|||||||
import net.sf.openrocket.util.BugException;
|
import net.sf.openrocket.util.BugException;
|
||||||
import net.sf.openrocket.util.MemoryManagement;
|
import net.sf.openrocket.util.MemoryManagement;
|
||||||
import net.sf.openrocket.util.MemoryManagement.MemoryData;
|
import net.sf.openrocket.util.MemoryManagement.MemoryData;
|
||||||
|
import net.sf.openrocket.utils.ComponentPresetEditor;
|
||||||
import net.sf.openrocket.util.Reflection;
|
import net.sf.openrocket.util.Reflection;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
import net.sf.openrocket.util.TestRockets;
|
import net.sf.openrocket.util.TestRockets;
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
package net.sf.openrocket.gui.print;
|
|
||||||
|
|
||||||
import java.awt.Window;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
|
||||||
|
|
||||||
public class ConceptPrintDialog extends JDialog {
|
|
||||||
|
|
||||||
public ConceptPrintDialog() {
|
|
||||||
super((Window) null, "Print");
|
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
|
||||||
|
|
||||||
JList list = new JList(new Object[] {
|
|
||||||
"Model name",
|
|
||||||
"Parts detail",
|
|
||||||
"Fin templates",
|
|
||||||
"Design report"
|
|
||||||
});
|
|
||||||
panel.add(new JScrollPane(list), "spanx, growx, wrap");
|
|
||||||
|
|
||||||
JCheckBox checkbox = new JCheckBox("Show by stage");
|
|
||||||
panel.add(checkbox, "");
|
|
||||||
|
|
||||||
JButton button = new JButton("Settings");
|
|
||||||
panel.add(button, "right, wrap para");
|
|
||||||
|
|
||||||
JLabel label = new JLabel("<html>Printer: LaserJet 6L<br>Paper size: A4 Portrait");
|
|
||||||
panel.add(label);
|
|
||||||
|
|
||||||
button = new JButton("Change");
|
|
||||||
panel.add(button, "right, wrap 20lp");
|
|
||||||
|
|
||||||
panel.add(new JButton("Save as PDF"), "split, spanx, right");
|
|
||||||
panel.add(new JButton("Preview"), "right");
|
|
||||||
panel.add(new JButton("Print"), "right");
|
|
||||||
panel.add(new JButton("Close"), "right");
|
|
||||||
|
|
||||||
|
|
||||||
this.add(panel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
|
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
GUIUtil.setBestLAF();
|
|
||||||
JDialog dialog = new ConceptPrintDialog();
|
|
||||||
GUIUtil.setDisposableDialogOptions(dialog, null);
|
|
||||||
dialog.setSize(450, 350);
|
|
||||||
dialog.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -16,6 +16,7 @@ import net.sf.openrocket.startup.providers.BlockingMotorDatabaseProvider;
|
|||||||
import net.sf.openrocket.startup.providers.TranslatorProvider;
|
import net.sf.openrocket.startup.providers.TranslatorProvider;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GuiModule is the Guice Module for the OpenRocket Swing application.
|
* GuiModule is the Guice Module for the OpenRocket Swing application.
|
||||||
@ -26,7 +27,7 @@ import com.google.inject.AbstractModule;
|
|||||||
* <code>
|
* <code>
|
||||||
* GuiModule module = new GuiModule();
|
* GuiModule module = new GuiModule();
|
||||||
* Application.setInjector( Guice.createInjector(guiModule));
|
* Application.setInjector( Guice.createInjector(guiModule));
|
||||||
* module.startLoadin();
|
* module.startLoading();
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @author kruland
|
* @author kruland
|
||||||
@ -44,17 +45,17 @@ public class GuiModule extends AbstractModule {
|
|||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
|
||||||
bind(Preferences.class).to(SwingPreferences.class);
|
bind(Preferences.class).to(SwingPreferences.class).in(Scopes.SINGLETON);
|
||||||
bind(Translator.class).toProvider(TranslatorProvider.class);
|
bind(Translator.class).toProvider(TranslatorProvider.class).in(Scopes.SINGLETON);
|
||||||
bind(RocketDescriptor.class).to(RocketDescriptorImpl.class);
|
bind(RocketDescriptor.class).to(RocketDescriptorImpl.class).in(Scopes.SINGLETON);
|
||||||
bind(WatchService.class).to(WatchServiceImpl.class);
|
bind(WatchService.class).to(WatchServiceImpl.class).in(Scopes.SINGLETON);
|
||||||
|
|
||||||
BlockingComponentPresetDatabaseProvider componentDatabaseProvider = new BlockingComponentPresetDatabaseProvider(presetLoader);
|
BlockingComponentPresetDatabaseProvider componentDatabaseProvider = new BlockingComponentPresetDatabaseProvider(presetLoader);
|
||||||
bind(ComponentPresetDao.class).toProvider(componentDatabaseProvider);
|
bind(ComponentPresetDao.class).toProvider(componentDatabaseProvider).in(Scopes.SINGLETON);
|
||||||
|
|
||||||
BlockingMotorDatabaseProvider motorDatabaseProvider = new BlockingMotorDatabaseProvider(motorLoader);
|
BlockingMotorDatabaseProvider motorDatabaseProvider = new BlockingMotorDatabaseProvider(motorLoader);
|
||||||
bind(ThrustCurveMotorSetDatabase.class).toProvider(motorDatabaseProvider);
|
bind(ThrustCurveMotorSetDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON);
|
||||||
bind(MotorDatabase.class).toProvider(motorDatabaseProvider);
|
bind(MotorDatabase.class).toProvider(motorDatabaseProvider).in(Scopes.SINGLETON);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ import com.apple.eawt.AppEvent.QuitEvent;
|
|||||||
* @author Bill Kuker <bkuker@billkuker.com>
|
* @author Bill Kuker <bkuker@billkuker.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
final class OSXStartup {
|
final class OSXSetup {
|
||||||
private static final Logger log = LoggerFactory.getLogger(OSXStartup.class);
|
private static final Logger log = LoggerFactory.getLogger(OSXSetup.class);
|
||||||
|
|
||||||
// The name in the app menu
|
// The name in the app menu
|
||||||
private static final String APP_NAME = "OpenRocket";
|
private static final String APP_NAME = "OpenRocket";
|
||||||
@ -103,7 +103,7 @@ final class OSXStartup {
|
|||||||
|
|
||||||
// Set the dock icon to the largest icon
|
// Set the dock icon to the largest icon
|
||||||
final Image dockIcon = Toolkit.getDefaultToolkit().getImage(
|
final Image dockIcon = Toolkit.getDefaultToolkit().getImage(
|
||||||
SwingApplication.class.getResource(ICON_RSRC));
|
SwingStartup.class.getResource(ICON_RSRC));
|
||||||
osxApp.setDockIconImage(dockIcon);
|
osxApp.setDockIconImage(dockIcon);
|
||||||
|
|
||||||
} catch (final Throwable t) {
|
} catch (final Throwable t) {
|
@ -15,7 +15,7 @@ import net.sf.openrocket.startup.jij.PluginClasspathProvider;
|
|||||||
*
|
*
|
||||||
* The startup class sequence is the following:
|
* The startup class sequence is the following:
|
||||||
* 1. Startup
|
* 1. Startup
|
||||||
* 2. SwingApplication
|
* 2. SwingStartup
|
||||||
*
|
*
|
||||||
* This class changes the current classpath to contain the jar-in-jar
|
* This class changes the current classpath to contain the jar-in-jar
|
||||||
* library dependencies and plugins in the current classpath, and
|
* library dependencies and plugins in the current classpath, and
|
||||||
@ -23,9 +23,9 @@ import net.sf.openrocket.startup.jij.PluginClasspathProvider;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public class JiJStartup {
|
public class Startup {
|
||||||
|
|
||||||
private static final String STARTUP_CLASS = "net.sf.openrocket.startup.SwingApplication";
|
private static final String STARTUP_CLASS = "net.sf.openrocket.startup.SwingStartup";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
addClasspathUrlHandler();
|
addClasspathUrlHandler();
|
@ -39,9 +39,9 @@ import com.google.inject.Module;
|
|||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public class SwingApplication {
|
public class SwingStartup {
|
||||||
|
|
||||||
private final static Logger log = LoggerFactory.getLogger(SwingApplication.class);
|
private final static Logger log = LoggerFactory.getLogger(SwingStartup.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenRocket startup main method.
|
* OpenRocket startup main method.
|
||||||
@ -61,10 +61,10 @@ public class SwingApplication {
|
|||||||
|
|
||||||
// If running on a MAC set up OSX UI Elements.
|
// If running on a MAC set up OSX UI Elements.
|
||||||
if (SystemInfo.getPlatform() == Platform.MAC_OS) {
|
if (SystemInfo.getPlatform() == Platform.MAC_OS) {
|
||||||
OSXStartup.setupOSX();
|
OSXSetup.setupOSX();
|
||||||
}
|
}
|
||||||
|
|
||||||
final SwingApplication runner = new SwingApplication();
|
final SwingStartup runner = new SwingStartup();
|
||||||
|
|
||||||
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
||||||
log.info("Moving startup to EDT");
|
log.info("Moving startup to EDT");
|
@ -1,6 +1,7 @@
|
|||||||
package net.sf.openrocket.startup.providers;
|
package net.sf.openrocket.startup.providers;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
import net.sf.openrocket.l10n.DebugTranslator;
|
import net.sf.openrocket.l10n.DebugTranslator;
|
||||||
@ -17,9 +18,17 @@ public class TranslatorProvider implements Provider<Translator> {
|
|||||||
|
|
||||||
private final static Logger log = LoggerFactory.getLogger(TranslatorProvider.class);
|
private final static Logger log = LoggerFactory.getLogger(TranslatorProvider.class);
|
||||||
|
|
||||||
|
private AtomicReference<Translator> translator = new AtomicReference<Translator>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Translator get() {
|
public Translator get() {
|
||||||
|
|
||||||
|
Translator oldTranslator = translator.get();
|
||||||
|
|
||||||
|
if (oldTranslator != null) {
|
||||||
|
return oldTranslator;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for locale propery
|
// Check for locale propery
|
||||||
String langcode = System.getProperty("openrocket.locale");
|
String langcode = System.getProperty("openrocket.locale");
|
||||||
|
|
||||||
@ -43,16 +52,20 @@ public class TranslatorProvider implements Provider<Translator> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Setup the translator
|
// Setup the translator
|
||||||
Translator t;
|
Translator newTranslator;
|
||||||
t = new ResourceBundleTranslator("l10n.messages");
|
newTranslator = new ResourceBundleTranslator("l10n.messages");
|
||||||
if (Locale.getDefault().getLanguage().equals("xx")) {
|
if (Locale.getDefault().getLanguage().equals("xx")) {
|
||||||
t = new DebugTranslator(t);
|
newTranslator = new DebugTranslator(newTranslator);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("Set up translation for locale " + Locale.getDefault() +
|
log.info("Set up translation for locale " + Locale.getDefault() +
|
||||||
", debug.currentFile=" + t.get("debug.currentFile"));
|
", debug.currentFile=" + newTranslator.get("debug.currentFile"));
|
||||||
|
|
||||||
return t;
|
if (translator.compareAndSet(null, newTranslator)) {
|
||||||
|
return newTranslator;
|
||||||
|
} else {
|
||||||
|
return translator.get();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.sf.openrocket.gui.preset;
|
package net.sf.openrocket.utils;
|
||||||
|
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -31,6 +31,9 @@ import javax.swing.table.DefaultTableModel;
|
|||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.gui.preset.ButtonColumn;
|
||||||
|
import net.sf.openrocket.gui.preset.PresetEditorDialog;
|
||||||
|
import net.sf.openrocket.gui.preset.PresetResultListener;
|
||||||
import net.sf.openrocket.gui.util.FileHelper;
|
import net.sf.openrocket.gui.util.FileHelper;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
@ -38,11 +41,9 @@ import net.sf.openrocket.logging.Markers;
|
|||||||
import net.sf.openrocket.material.Material;
|
import net.sf.openrocket.material.Material;
|
||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
import net.sf.openrocket.preset.loader.MaterialHolder;
|
import net.sf.openrocket.preset.loader.MaterialHolder;
|
||||||
import net.sf.openrocket.preset.loader.RocksimComponentFileTranslator;
|
|
||||||
import net.sf.openrocket.preset.xml.OpenRocketComponentDTO;
|
import net.sf.openrocket.preset.xml.OpenRocketComponentDTO;
|
||||||
import net.sf.openrocket.preset.xml.OpenRocketComponentSaver;
|
import net.sf.openrocket.preset.xml.OpenRocketComponentSaver;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.utils.BasicApplication;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -1,4 +1,4 @@
|
|||||||
package net.sf.openrocket.preset.loader;
|
package net.sf.openrocket.utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
@ -8,9 +8,20 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sf.openrocket.material.Material;
|
import net.sf.openrocket.material.Material;
|
||||||
import net.sf.openrocket.preset.ComponentPreset;
|
import net.sf.openrocket.preset.ComponentPreset;
|
||||||
|
import net.sf.openrocket.preset.loader.BodyTubeLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.BulkHeadLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.CenteringRingLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.EngineBlockLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.LaunchLugLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.MaterialHolder;
|
||||||
|
import net.sf.openrocket.preset.loader.MaterialLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.NoseConeLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.ParachuteLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.StreamerLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.TransitionLoader;
|
||||||
|
import net.sf.openrocket.preset.loader.TubeCouplerLoader;
|
||||||
import net.sf.openrocket.preset.xml.OpenRocketComponentSaver;
|
import net.sf.openrocket.preset.xml.OpenRocketComponentSaver;
|
||||||
import net.sf.openrocket.util.ArrayList;
|
import net.sf.openrocket.util.ArrayList;
|
||||||
import net.sf.openrocket.utils.BasicApplication;
|
|
||||||
|
|
||||||
public class RocksimComponentFileTranslator {
|
public class RocksimComponentFileTranslator {
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user