Fix merge conflict
This commit is contained in:
parent
595143f980
commit
13fa275ff9
@ -12,6 +12,7 @@ import javax.swing.JDialog;
|
|||||||
|
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
|
||||||
@ -39,8 +40,9 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
private OpenRocketDocument document = null;
|
private OpenRocketDocument document = null;
|
||||||
protected static RocketComponent component = null;
|
protected static RocketComponent component = null;
|
||||||
private RocketComponentConfig configurator = null;
|
private RocketComponentConfig configurator = null;
|
||||||
|
|
||||||
protected static boolean clearConfigListeners = true;
|
protected static boolean clearConfigListeners = true;
|
||||||
|
private static String previousSelectedTab = null; // Name of the previous selected tab
|
||||||
|
|
||||||
|
|
||||||
private final Window parent;
|
private final Window parent;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
@ -98,6 +100,9 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
this.setContentPane(configurator);
|
this.setContentPane(configurator);
|
||||||
configurator.updateFields();
|
configurator.updateFields();
|
||||||
|
|
||||||
|
// Set the selected tab
|
||||||
|
configurator.setSelectedTab(previousSelectedTab);
|
||||||
|
|
||||||
//// configuration
|
//// configuration
|
||||||
List<RocketComponent> listeners = component.getConfigListeners();
|
List<RocketComponent> listeners = component.getConfigListeners();
|
||||||
if (component.checkAllClassesEqual(listeners)) {
|
if (component.checkAllClassesEqual(listeners)) {
|
||||||
@ -212,10 +217,11 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
*
|
*
|
||||||
* @param document the document to configure.
|
* @param document the document to configure.
|
||||||
* @param component the component to configure.
|
* @param component the component to configure.
|
||||||
|
* @param rememberPreviousTab if true, the previous tab will be remembered and used for the new dialog
|
||||||
*/
|
*/
|
||||||
public static void showDialog(Window parent, OpenRocketDocument document,
|
public static void showDialog(Window parent, OpenRocketDocument document, RocketComponent component, boolean rememberPreviousTab) {
|
||||||
RocketComponent component) {
|
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
|
previousSelectedTab = dialog.getSelectedTabName();
|
||||||
// If the component is the same as the ComponentConfigDialog component, and the dialog is still visible,
|
// If the component is the same as the ComponentConfigDialog component, and the dialog is still visible,
|
||||||
// that means that the user did a ctr/cmd click on a new component => don't remove the config listeners of component
|
// that means that the user did a ctr/cmd click on a new component => don't remove the config listeners of component
|
||||||
if (component.equals(ComponentConfigDialog.component)) {
|
if (component.equals(ComponentConfigDialog.component)) {
|
||||||
@ -224,6 +230,11 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
|
||||||
|
if (preferences.isAlwaysOpenLeftmostTab() || !rememberPreviousTab) {
|
||||||
|
previousSelectedTab = null;
|
||||||
|
}
|
||||||
|
|
||||||
dialog = new ComponentConfigDialog(parent, document, component);
|
dialog = new ComponentConfigDialog(parent, document, component);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
@ -231,9 +242,26 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
document.addUndoPosition(trans.get("ComponentCfgDlg.Modify") + " " + component.getComponentName());
|
document.addUndoPosition(trans.get("ComponentCfgDlg.Modify") + " " + component.getComponentName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A singleton configuration dialog. Will create and show a new dialog if one has not
|
||||||
|
* previously been used, or update the dialog and show it if a previous one exists.
|
||||||
|
* By default, the previous tab is remembered.
|
||||||
|
*
|
||||||
|
* @param document the document to configure.
|
||||||
|
* @param component the component to configure.
|
||||||
|
*/
|
||||||
|
public static void showDialog(Window parent, OpenRocketDocument document, RocketComponent component) {
|
||||||
|
ComponentConfigDialog.showDialog(parent, document, component, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showDialog(RocketComponent component, boolean rememberPreviousTab) {
|
||||||
|
showDialog(dialog.parent, dialog.document, component, rememberPreviousTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* package */
|
/* package */
|
||||||
static void showDialog(RocketComponent component) {
|
static void showDialog(RocketComponent component) {
|
||||||
ComponentConfigDialog.showDialog(dialog.parent, dialog.document, component);
|
showDialog(dialog.parent, dialog.document, component, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -253,4 +281,12 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
|
|||||||
return (dialog != null) && (dialog.isVisible());
|
return (dialog != null) && (dialog.isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSelectedTabName() {
|
||||||
|
if (configurator != null) {
|
||||||
|
return configurator.getSelectedTabName();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user