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 ;
7374import org .eclipse .swt .widgets .Composite ;
7475import org .eclipse .swt .widgets .Control ;
7576import org .eclipse .swt .widgets .Display ;
77+ import org .eclipse .swt .widgets .Group ;
7678import org .eclipse .swt .widgets .Label ;
7779import org .eclipse .ui .IWorkbench ;
7880import org .eclipse .ui .IWorkbenchPreferenceConstants ;
@@ -114,6 +116,9 @@ public class ViewsPreferencePage extends PreferencePage implements IWorkbenchPre
114116 private boolean highContrastMode ;
115117
116118 private Button themingEnabled ;
119+ private Button updateOnRunTime ;
120+ boolean initialStateUpdateOnRuntime = PrefUtil .getAPIPreferenceStore ()
121+ .getBoolean (IWorkbenchPreferenceConstants .UPDATE_ON_RUNTIME_KEY );
117122
118123 private Button hideIconsForViewTabs ;
119124 private Button showFullTextForViewTabs ;
@@ -135,6 +140,7 @@ protected Control createContents(Composite parent) {
135140 layout .horizontalSpacing = 10 ;
136141 comp .setLayout (layout );
137142 createThemeIndependentComposits (comp );
143+ createUpdateOnRuntimeButton (comp );
138144 return comp ;
139145 }
140146
@@ -180,6 +186,8 @@ protected Control createContents(Composite parent) {
180186 createHideIconsForViewTabs (comp );
181187 createDependency (showFullTextForViewTabs , hideIconsForViewTabs );
182188
189+ createUpdateOnRuntimeButton (comp );
190+
183191 if (currentTheme != null ) {
184192 String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId (currentTheme .getId ());
185193 if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme .getId ().equals (colorsAndFontsThemeId )) {
@@ -192,6 +200,32 @@ protected Control createContents(Composite parent) {
192200 return comp ;
193201 }
194202
203+ private void createUpdateOnRuntimeButton (Composite composite ) {
204+ if (!OS .isWindows ()) {
205+ return ;
206+ }
207+ createLabel (composite , "" ); //$NON-NLS-1$
208+ Group buttonComposite = new Group (composite , SWT .LEFT );
209+ buttonComposite .setText ("HiDPI settings" ); //$NON-NLS-1$
210+
211+ GridData gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
212+ gridData .horizontalSpan = ((GridLayout ) composite .getLayout ()).numColumns ;
213+ buttonComposite .setLayoutData (gridData );
214+ buttonComposite .setFont (composite .getFont ());
215+ GridLayout layout = new GridLayout (1 , false );
216+ buttonComposite .setLayout (layout );
217+ Label infoLabel = new Label (buttonComposite , SWT .WRAP );
218+ infoLabel .setText (
219+ "This preference is Windows only. Activating it will change the DPI awareness of the IDE to PerMonitorV2 and dynamically scale all windows according to the monitor it is currently assigned to. An additional effect of this preference is to set the default browser to Edge to provide the appropriate scaling of content displayed in a browser. This feature is still in development and therefore marked as experimental." ); //$NON-NLS-1$
220+ GridData labelGridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
221+ labelGridData .widthHint = 400 ; // Adjust this value to control initial wrapping width
222+ infoLabel .setLayoutData (labelGridData );
223+ createLabel (buttonComposite , "" ); //$NON-NLS-1$
224+
225+ updateOnRunTime = createCheckButton (buttonComposite , WorkbenchMessages .UpdateUIZoomTitle ,
226+ initialStateUpdateOnRuntime );
227+ }
228+
195229 private void createThemeIndependentComposits (Composite comp ) {
196230 createUseRoundTabs (comp );
197231 createColoredLabelsPref (comp );
@@ -212,6 +246,9 @@ protected void createHideIconsForViewTabs(Composite composite) {
212246 CTabRendering .HIDE_ICONS_FOR_VIEW_TABS_DEFAULT );
213247 hideIconsForViewTabs = createCheckButton (composite , WorkbenchMessages .ViewsPreference_hideIconsForViewTabs ,
214248 actualValue );
249+ GridData gridData = new GridData ();
250+ gridData .horizontalIndent = 20 ;
251+ hideIconsForViewTabs .setLayoutData (gridData );
215252 }
216253
217254 private boolean getSwtRendererPreference (String prefName , boolean defaultValue ) {
@@ -224,10 +261,6 @@ private boolean getSwtRendererPreference(String prefName, boolean defaultValue)
224261 * @param hideIconsForViewTabs
225262 */
226263 private void createDependency (Button parent , Button dependent ) {
227- GridData gridData = new GridData ();
228- gridData .horizontalIndent = 20 ;
229- dependent .setLayoutData (gridData );
230-
231264 boolean parentState = parent .getSelection ();
232265 dependent .setEnabled (parentState );
233266
@@ -341,6 +374,11 @@ public boolean performOk() {
341374 .getSelection ();
342375 prefs .putBoolean (PartRenderingEngine .ENABLED_THEME_KEY , themingEnabled .getSelection ());
343376
377+ boolean isUpdateOnRuntTmeChanged = (updateOnRunTime != null
378+ && initialStateUpdateOnRuntime != updateOnRunTime .getSelection ());
379+ apiStore .setValue (IWorkbenchPreferenceConstants .UPDATE_ON_RUNTIME_KEY ,
380+ updateOnRunTime == null ? false : updateOnRunTime .getSelection ());
381+
344382 prefs .putBoolean (CTabRendering .USE_ROUND_TABS , useRoundTabs .getSelection ());
345383 try {
346384 prefs .flush ();
@@ -373,13 +411,19 @@ public boolean performOk() {
373411 if (themingEnabledChanged ) {
374412 showRestartDialog ();
375413 }
414+ if (isUpdateOnRuntTmeChanged ) {
415+ showRestartDialog ("DPI Setting Changed" , "Restart for the effect to take place" ); //$NON-NLS-1$ //$NON-NLS-2$
416+ }
376417
377418 return super .performOk ();
378419 }
379420
380421 private void showRestartDialog () {
381- if (new MessageDialog (null , WorkbenchMessages .ThemeChangeWarningTitle , null ,
382- WorkbenchMessages .ThemeChangeWarningText , MessageDialog .NONE , 2 ,
422+ showRestartDialog (WorkbenchMessages .ThemeChangeWarningTitle , WorkbenchMessages .ThemeChangeWarningText );
423+ }
424+
425+ private void showRestartDialog (String title , String warningText ) {
426+ if (new MessageDialog (null , title , null , warningText , MessageDialog .NONE , 2 ,
383427 WorkbenchMessages .Workbench_RestartButton , WorkbenchMessages .Workbench_DontRestartButton )
384428 .open () == Window .OK ) {
385429 Display .getDefault ().asyncExec (() -> PlatformUI .getWorkbench ().restart ());
0 commit comments