3737import org .eclipse .core .runtime .IExtensionPoint ;
3838import org .eclipse .core .runtime .IExtensionRegistry ;
3939import org .eclipse .core .runtime .Platform ;
40+ import org .eclipse .core .runtime .Platform .OS ;
4041import org .eclipse .core .runtime .RegistryFactory ;
4142import org .eclipse .core .runtime .preferences .DefaultScope ;
4243import org .eclipse .core .runtime .preferences .IEclipsePreferences ;
5354import org .eclipse .jface .dialogs .MessageDialog ;
5455import org .eclipse .jface .fieldassist .ControlDecoration ;
5556import org .eclipse .jface .fieldassist .FieldDecorationRegistry ;
57+ import org .eclipse .jface .layout .GridDataFactory ;
5658import org .eclipse .jface .preference .IPreferenceStore ;
5759import org .eclipse .jface .preference .PreferencePage ;
5860import org .eclipse .jface .util .Util ;
7375import org .eclipse .swt .widgets .Composite ;
7476import org .eclipse .swt .widgets .Control ;
7577import org .eclipse .swt .widgets .Display ;
78+ import org .eclipse .swt .widgets .Group ;
7679import org .eclipse .swt .widgets .Label ;
7780import org .eclipse .ui .IWorkbench ;
7881import org .eclipse .ui .IWorkbenchPreferenceConstants ;
@@ -114,6 +117,8 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
114117 private boolean highContrastMode ;
115118
116119 private Button themingEnabled ;
120+ private Button updateOnRuntime ;
121+ private boolean initialStateUpdateOnRuntime ;
117122
118123 private Button hideIconsForViewTabs ;
119124 private Button showFullTextForViewTabs ;
@@ -127,6 +132,8 @@ protected Control createContents(Composite parent) {
127132 Composite comp = new Composite (parent , SWT .NONE );
128133
129134 themingEnabled = createCheckButton (comp , WorkbenchMessages .ThemingEnabled , engine != null );
135+ initialStateUpdateOnRuntime = PrefUtil .getAPIPreferenceStore ()
136+ .getBoolean (IWorkbenchPreferenceConstants .RESCALING_AT_RUNTIME );
130137
131138 // if started with "-cssTheme none", CSS settings should be disabled
132139 // but other appearance settings should be *not* disabled
@@ -135,6 +142,7 @@ protected Control createContents(Composite parent) {
135142 layout .horizontalSpacing = 10 ;
136143 comp .setLayout (layout );
137144 createThemeIndependentComposits (comp );
145+ createHiDPISettingsGroup (comp );
138146 return comp ;
139147 }
140148
@@ -180,6 +188,8 @@ protected Control createContents(Composite parent) {
180188 createHideIconsForViewTabs (comp );
181189 createDependency (showFullTextForViewTabs , hideIconsForViewTabs );
182190
191+ createHiDPISettingsGroup (comp );
192+
183193 if (currentTheme != null ) {
184194 String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId (currentTheme .getId ());
185195 if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme .getId ().equals (colorsAndFontsThemeId )) {
@@ -192,6 +202,28 @@ protected Control createContents(Composite parent) {
192202 return comp ;
193203 }
194204
205+ private void createHiDPISettingsGroup (Composite parent ) {
206+ if (!OS .isWindows () || true ) {
207+ return ;
208+ }
209+ createLabel (parent , "" ); //$NON-NLS-1$
210+ Group group = new Group (parent , SWT .LEFT );
211+ group .setText (WorkbenchMessages .UpdateUIZoomGroupTitle );
212+
213+ GridData gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
214+ gridData .horizontalSpan = ((GridLayout ) parent .getLayout ()).numColumns ;
215+ group .setLayoutData (gridData );
216+ group .setFont (parent .getFont ());
217+ GridLayout layout = new GridLayout (1 , false );
218+ group .setLayout (layout );
219+ Label infoLabel = new Label (group , SWT .WRAP );
220+ infoLabel .setText (WorkbenchMessages .UpdateUIZoomDesc );
221+ infoLabel .setLayoutData (GridDataFactory .defaultsFor (infoLabel ).create ());
222+ createLabel (group , "" ); //$NON-NLS-1$
223+
224+ updateOnRuntime = createCheckButton (group , WorkbenchMessages .UpdateUIZoomTitle , initialStateUpdateOnRuntime );
225+ }
226+
195227 private void createThemeIndependentComposits (Composite comp ) {
196228 createUseRoundTabs (comp );
197229 createColoredLabelsPref (comp );
@@ -227,7 +259,6 @@ private void createDependency(Button parent, Button dependent) {
227259 GridData gridData = new GridData ();
228260 gridData .horizontalIndent = 20 ;
229261 dependent .setLayoutData (gridData );
230-
231262 boolean parentState = parent .getSelection ();
232263 dependent .setEnabled (parentState );
233264
@@ -341,6 +372,12 @@ public boolean performOk() {
341372 .getSelection ();
342373 prefs .putBoolean (PartRenderingEngine .ENABLED_THEME_KEY , themingEnabled .getSelection ());
343374
375+ boolean isUpdateOnRuntimeChanged = false ;
376+ if (updateOnRuntime != null ) {
377+ isUpdateOnRuntimeChanged = initialStateUpdateOnRuntime != updateOnRuntime .getSelection ();
378+ apiStore .setValue (IWorkbenchPreferenceConstants .RESCALING_AT_RUNTIME , updateOnRuntime .getSelection ());
379+ }
380+
344381 prefs .putBoolean (CTabRendering .USE_ROUND_TABS , useRoundTabs .getSelection ());
345382 try {
346383 prefs .flush ();
@@ -367,19 +404,22 @@ public boolean performOk() {
367404 colorFontsDecorator .hide ();
368405
369406 if (themeChanged || colorsAndFontsThemeChanged ) {
370- showRestartDialog ();
407+ showRestartDialog (WorkbenchMessages . ThemeChangeWarningTitle , WorkbenchMessages . ThemeChangeWarningText );
371408 }
372409 }
373410 if (themingEnabledChanged ) {
374- showRestartDialog ();
411+ showRestartDialog (WorkbenchMessages .ThemeChangeWarningTitle , WorkbenchMessages .ThemeChangeWarningText );
412+ }
413+ if (isUpdateOnRuntimeChanged ) {
414+ showRestartDialog (WorkbenchMessages .RescaleAtRuntimeSettingChangeWarningTitle ,
415+ WorkbenchMessages .RescaleAtRuntimeSettingChangeWarningDesc );
375416 }
376417
377418 return super .performOk ();
378419 }
379420
380- private void showRestartDialog () {
381- if (new MessageDialog (null , WorkbenchMessages .ThemeChangeWarningTitle , null ,
382- WorkbenchMessages .ThemeChangeWarningText , MessageDialog .NONE , 2 ,
421+ private void showRestartDialog (String title , String warningText ) {
422+ if (new MessageDialog (null , title , null , warningText , MessageDialog .NONE , 2 ,
383423 WorkbenchMessages .Workbench_RestartButton , WorkbenchMessages .Workbench_DontRestartButton )
384424 .open () == Window .OK ) {
385425 Display .getDefault ().asyncExec (() -> PlatformUI .getWorkbench ().restart ());
0 commit comments