Skip to content

Commit 514ee6f

Browse files
committed
Set proper default for monitor-specific scaling preference
When restoring the default values for the "Appearance" preference page, the Windows-specific preference for enabling/disabling monitor-specific scaling is not updated. The default value for this preference is currently defined at every place accessing the preference redundantly. With this change, a proper default value in the default preference scope is defined for the monitor-specific scaling preference. This value is used by all consumers of the preference via a ScopedPreferenceStore. The defaults restoration of the "Appearance" preference page is extended with a restore of the monitor-specific scaling preference.
1 parent 8cb6e80 commit 514ee6f

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/Workbench.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@
254254
import org.eclipse.ui.menus.IMenuService;
255255
import org.eclipse.ui.model.IContributionService;
256256
import org.eclipse.ui.operations.IWorkbenchOperationSupport;
257+
import org.eclipse.ui.preferences.ScopedPreferenceStore;
257258
import org.eclipse.ui.progress.IProgressService;
258259
import org.eclipse.ui.progress.WorkbenchJob;
259260
import org.eclipse.ui.services.IDisposable;
@@ -3690,8 +3691,8 @@ public void setRescaleAtRuntimePropertyFromPreference() {
36903691
+ " is configured (e.g., via the INI), but the according preference should be preferred instead." //$NON-NLS-1$
36913692
));
36923693
} else {
3693-
boolean rescaleAtRuntime = ConfigurationScope.INSTANCE.getNode(WorkbenchPlugin.PI_WORKBENCH)
3694-
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
3694+
boolean rescaleAtRuntime = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,
3695+
WorkbenchPlugin.PI_WORKBENCH).getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
36953696
System.setProperty(SWT_RESCALE_AT_RUNTIME_PROPERTY, Boolean.toString(rescaleAtRuntime));
36963697
}
36973698

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/dialogs/ViewsPreferencePage.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import static org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants.ATT_THEME_ASSOCIATION;
2727
import static org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants.ATT_THEME_ID;
2828

29+
import java.io.IOException;
2930
import java.util.ArrayList;
3031
import java.util.HashMap;
3132
import java.util.List;
@@ -58,6 +59,7 @@
5859
import org.eclipse.jface.fieldassist.ControlDecoration;
5960
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
6061
import org.eclipse.jface.layout.GridDataFactory;
62+
import org.eclipse.jface.preference.IPersistentPreferenceStore;
6163
import org.eclipse.jface.preference.IPreferenceStore;
6264
import org.eclipse.jface.preference.PreferencePage;
6365
import org.eclipse.jface.viewers.ArrayContentProvider;
@@ -88,6 +90,7 @@
8890
import org.eclipse.ui.internal.WorkbenchPlugin;
8991
import org.eclipse.ui.internal.themes.IThemeDescriptor;
9092
import org.eclipse.ui.internal.util.PrefUtil;
93+
import org.eclipse.ui.preferences.ScopedPreferenceStore;
9194
import org.eclipse.ui.themes.IThemeManager;
9295
import org.osgi.service.prefs.BackingStoreException;
9396

@@ -238,8 +241,8 @@ private void createRescaleAtRuntimeCheckButton(Composite parent) {
238241
}
239242
createLabel(parent, ""); //$NON-NLS-1$
240243

241-
boolean initialStateRescaleAtRuntime = ConfigurationScope.INSTANCE.getNode(WorkbenchPlugin.PI_WORKBENCH)
242-
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
244+
boolean initialStateRescaleAtRuntime = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,
245+
WorkbenchPlugin.PI_WORKBENCH).getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
243246
rescaleAtRuntime = createCheckButton(parent, WorkbenchMessages.RescaleAtRuntimeEnabled,
244247
initialStateRescaleAtRuntime);
245248
if (!DPIUtil.isSetupCompatibleToMonitorSpecificScaling()) {
@@ -486,16 +489,17 @@ public boolean performOk() {
486489

487490
boolean isRescaleAtRuntimeChanged = false;
488491
if (rescaleAtRuntime != null) {
489-
IEclipsePreferences configurationScopeNode = ConfigurationScope.INSTANCE
490-
.getNode(WorkbenchPlugin.PI_WORKBENCH);
492+
IPersistentPreferenceStore configurationScopeNode = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,
493+
WorkbenchPlugin.PI_WORKBENCH);
491494
boolean initialStateRescaleAtRuntime = configurationScopeNode
492-
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
495+
.getBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME);
493496
isRescaleAtRuntimeChanged = initialStateRescaleAtRuntime != rescaleAtRuntime.getSelection();
494-
configurationScopeNode.putBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME,
495-
rescaleAtRuntime.getSelection());
497+
configurationScopeNode.setValue(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME,
498+
Boolean.toString(rescaleAtRuntime.getSelection()));
496499
try {
497-
configurationScopeNode.flush();
498-
} catch (BackingStoreException e) {
500+
configurationScopeNode.save();
501+
} catch (IOException e) {
502+
WorkbenchPlugin.log("Failed to set monitor-specific scaling preference", e); //$NON-NLS-1$
499503
}
500504
}
501505

@@ -626,6 +630,12 @@ protected void performDefaults() {
626630
IPreferenceStore apiStore = PrefUtil.getAPIPreferenceStore();
627631
useColoredLabels.setSelection(apiStore.getDefaultBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
628632

633+
if (rescaleAtRuntime != null) {
634+
IPreferenceStore configurationStore = new ScopedPreferenceStore(ConfigurationScope.INSTANCE,
635+
WorkbenchPlugin.PI_WORKBENCH);
636+
rescaleAtRuntime.setSelection(
637+
configurationStore.getDefaultBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME));
638+
}
629639
enableMru.setSelection(defaultPrefs.getBoolean(StackRenderer.MRU_KEY_DEFAULT, StackRenderer.MRU_DEFAULT));
630640
super.performDefaults();
631641
}

bundles/org.eclipse.ui/src/org/eclipse/ui/internal/UIPreferenceInitializer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public void initializeDefaultPreferences() {
6161
node.putBoolean(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR,
6262
false);
6363

64+
node.putBoolean(IWorkbenchPreferenceConstants.RESCALING_AT_RUNTIME, true);
6465
node.putBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS, true);
6566
node.putBoolean(
6667
IWorkbenchPreferenceConstants.SHOW_TEXT_ON_PERSPECTIVE_BAR,

0 commit comments

Comments
 (0)