package net.sf.openrocket.gui.configdialog;
-import java.awt.Point;
import java.awt.Window;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import javax.swing.JDialog;
import net.sf.openrocket.document.OpenRocketDocument;
+import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
import net.sf.openrocket.rocketcomponent.RocketComponent;
+import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.GUIUtil;
-import net.sf.openrocket.util.Prefs;
import net.sf.openrocket.util.Reflection;
/**
private RocketComponentConfig configurator = null;
private final Window parent;
+ private static final Translator trans = Application.getTranslator();
private ComponentConfigDialog(Window parent, OpenRocketDocument document,
RocketComponent component) {
setComponent(document, component);
GUIUtil.setDisposableDialogOptions(this, null);
-
- // Set window position according to preferences, and set prefs when moving
- Point position = Prefs.getWindowPosition(this.getClass());
- if (position != null) {
- this.setLocationByPlatform(false);
- this.setLocation(position);
- }
-
- this.addComponentListener(new ComponentAdapter() {
- @Override
- public void componentMoved(ComponentEvent e) {
- Prefs.setWindowPosition(ComponentConfigDialog.this.getClass(),
- ComponentConfigDialog.this.getLocation());
- }
- });
-
+ GUIUtil.rememberWindowPosition(this);
}
this.setContentPane(configurator);
configurator.updateFields();
- setTitle(component.getComponentName() + " configuration");
+ //// configuration
+ setTitle(trans.get("ComponentCfgDlg.configuration1") + " " + component.getComponentName() + " " + trans.get("ComponentCfgDlg.configuration"));
- // Dimension pref = getPreferredSize();
- // Dimension real = getSize();
- // if (pref.width > real.width || pref.height > real.height)
this.pack();
}
findDialogContentsConstructor(component);
if (c != null) {
try {
- return c.newInstance(component);
+ return c.newInstance(document, component);
} catch (InstantiationException e) {
throw new BugException("BUG in constructor reflection", e);
} catch (IllegalAccessException e) {
try {
configclass = Class.forName(configclassname);
c = (Constructor<? extends RocketComponentConfig>)
- configclass.getConstructor(RocketComponent.class);
+ configclass.getConstructor(OpenRocketDocument.class, RocketComponent.class);
return c;
} catch (Exception ignore) {
}
dialog = new ComponentConfigDialog(parent, document, component);
dialog.setVisible(true);
- document.addUndoPosition("Modify " + component.getComponentName());
+ ////Modify
+ document.addUndoPosition(trans.get("ComponentCfgDlg.Modify") + " " + component.getComponentName());
}
}
- /**
- * Add an undo position for the current document. This is intended for use only
- * by the currently open dialog.
- *
- * @param description Description of the undoable action
- */
- /*package*/static void addUndoPosition(String description) {
- if (dialog == null) {
- throw new IllegalStateException("Dialog not open, report bug!");
- }
- dialog.document.addUndoPosition(description);
- }
-
- /*package*/
- static String getUndoDescription() {
- if (dialog == null) {
- throw new IllegalStateException("Dialog not open, report bug!");
- }
- return dialog.document.getUndoDescription();
- }
-
/**
* Returns whether the singleton configuration dialog is currently visible or not.
*/