Add always open leftmost tab in preferences
This commit is contained in:
		
							parent
							
								
									b7d65b9e9c
								
							
						
					
					
						commit
						eeb9773e59
					
				@ -289,6 +289,8 @@ pref.dlg.lbl.PositiontoinsertStages = Position to insert new stages:
 | 
			
		||||
pref.dlg.lbl.Confirmdeletion = Confirm deletion of simulations.
 | 
			
		||||
pref.dlg.checkbox.Runsimulations = Run out-dated simulations when you open the simulation tab.
 | 
			
		||||
pref.dlg.checkbox.Updateestimates = Update estimated flight parameters in design window
 | 
			
		||||
pref.dlg.checkbox.AlwaysOpenLeftmost = Always open leftmost tab when opening a component edit dialog
 | 
			
		||||
pref.dlg.checkbox.AlwaysOpenLeftmost.ttip = <html>If checked, a component edit dialog will almost pop up with the first tab selected.<br>If unchecked, the previous selected tab will be used.</html>
 | 
			
		||||
pref.dlg.lbl.User-definedthrust = User-defined thrust curves:
 | 
			
		||||
pref.dlg.lbl.Windspeed = Wind speed
 | 
			
		||||
pref.dlg.Allthrustcurvefiles = All thrust curve files (*.eng; *.rse; *.zip; directories)
 | 
			
		||||
 | 
			
		||||
@ -67,6 +67,7 @@ public abstract class Preferences implements ChangeSource {
 | 
			
		||||
	// Node names
 | 
			
		||||
	public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
 | 
			
		||||
	private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN";
 | 
			
		||||
	private static final String OPEN_LEFTMOST_DESIGN_TAB = "OPEN_LEFTMOST_DESIGN_TAB";
 | 
			
		||||
	private static final String SHOW_ROCKSIM_FORMAT_WARNING = "SHOW_ROCKSIM_FORMAT_WARNING";
 | 
			
		||||
	
 | 
			
		||||
	//Preferences related to 3D graphics
 | 
			
		||||
@ -453,6 +454,22 @@ public abstract class Preferences implements ChangeSource {
 | 
			
		||||
		return this.getBoolean(AUTO_OPEN_LAST_DESIGN, false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Enable/Disable the opening the leftmost tab on the component design panel, or using the tab that was opened last time.
 | 
			
		||||
	 */
 | 
			
		||||
	public final void setAlwaysOpenLeftmostTab(boolean enabled) {
 | 
			
		||||
		this.putBoolean(OPEN_LEFTMOST_DESIGN_TAB, enabled);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Answer if the always open leftmost tab is enabled.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return true if the application should always open the leftmost tab in the component design panel.
 | 
			
		||||
	 */
 | 
			
		||||
	public final boolean isAlwaysOpenLeftmostTab() {
 | 
			
		||||
		return this.getBoolean(OPEN_LEFTMOST_DESIGN_TAB, false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Return the OpenRocket unique ID.
 | 
			
		||||
	 *
 | 
			
		||||
 | 
			
		||||
@ -12,6 +12,7 @@ import javax.swing.JDialog;
 | 
			
		||||
 | 
			
		||||
import net.sf.openrocket.document.OpenRocketDocument;
 | 
			
		||||
import net.sf.openrocket.gui.util.GUIUtil;
 | 
			
		||||
import net.sf.openrocket.gui.util.SwingPreferences;
 | 
			
		||||
import net.sf.openrocket.l10n.Translator;
 | 
			
		||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
 | 
			
		||||
import net.sf.openrocket.rocketcomponent.ComponentChangeListener;
 | 
			
		||||
@ -217,7 +218,8 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
 | 
			
		||||
			previousSelectedTab = dialog.getSelectedTabName();
 | 
			
		||||
			dialog.dispose();
 | 
			
		||||
		}
 | 
			
		||||
		if (!rememberPreviousTab) {
 | 
			
		||||
		final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
 | 
			
		||||
		if (preferences.isAlwaysOpenLeftmostTab() || !rememberPreviousTab) {
 | 
			
		||||
			previousSelectedTab = null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -90,6 +90,21 @@ public class DesignPreferencesPanel extends PreferencesPanel {
 | 
			
		||||
		});
 | 
			
		||||
		this.add(autoOpenDesignFile, "wrap, growx, span 2");
 | 
			
		||||
 | 
			
		||||
		// // Always open leftmost tab when opening a component edit dialog
 | 
			
		||||
		final JCheckBox alwaysOpenLeftmostTab = new JCheckBox(
 | 
			
		||||
				trans.get("pref.dlg.checkbox.AlwaysOpenLeftmost"));
 | 
			
		||||
 | 
			
		||||
		alwaysOpenLeftmostTab.setSelected(preferences.isAlwaysOpenLeftmostTab());
 | 
			
		||||
		alwaysOpenLeftmostTab.setToolTipText(trans.get("pref.dlg.checkbox.AlwaysOpenLeftmost.ttip"));
 | 
			
		||||
		alwaysOpenLeftmostTab.addActionListener(new ActionListener() {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void actionPerformed(ActionEvent e) {
 | 
			
		||||
				preferences.setAlwaysOpenLeftmostTab(alwaysOpenLeftmostTab
 | 
			
		||||
						.isSelected());
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		this.add(alwaysOpenLeftmostTab, "wrap, growx, span 2");
 | 
			
		||||
 | 
			
		||||
		// // Update flight estimates in the design window
 | 
			
		||||
		final JCheckBox updateEstimates = new JCheckBox(
 | 
			
		||||
				trans.get("pref.dlg.checkbox.Updateestimates"));
 | 
			
		||||
@ -102,6 +117,5 @@ public class DesignPreferencesPanel extends PreferencesPanel {
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		this.add(updateEstimates, "wrap, growx, sg combos ");
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user