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+ private 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+ createHiDPISettingsGroup (comp );
138144 return comp ;
139145 }
140146
@@ -180,6 +186,8 @@ protected Control createContents(Composite parent) {
180186 createHideIconsForViewTabs (comp );
181187 createDependency (showFullTextForViewTabs , hideIconsForViewTabs );
182188
189+ createHiDPISettingsGroup (comp );
190+
183191 if (currentTheme != null ) {
184192 String colorsAndFontsThemeId = getColorAndFontThemeIdByThemeId (currentTheme .getId ());
185193 if (colorsAndFontsThemeId != null && !currentColorsAndFontsTheme .getId ().equals (colorsAndFontsThemeId )) {
@@ -192,6 +200,31 @@ protected Control createContents(Composite parent) {
192200 return comp ;
193201 }
194202
203+ private void createHiDPISettingsGroup (Composite parent ) {
204+ if (!OS .isWindows ()) {
205+ return ;
206+ }
207+ createLabel (parent , "" ); //$NON-NLS-1$
208+ Group group = new Group (parent , SWT .LEFT );
209+ group .setText ("HiDPI settings" ); //$NON-NLS-1$
210+
211+ GridData gridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
212+ gridData .horizontalSpan = ((GridLayout ) parent .getLayout ()).numColumns ;
213+ group .setLayoutData (gridData );
214+ group .setFont (parent .getFont ());
215+ GridLayout layout = new GridLayout (1 , false );
216+ group .setLayout (layout );
217+ Label infoLabel = new Label (group , SWT .WRAP );
218+ infoLabel .setText (WorkbenchMessages .UpdateUIZoomDesc );
219+ GridData labelGridData = new GridData (SWT .FILL , SWT .CENTER , true , false );
220+ labelGridData .widthHint = 400 ; // Adjust this value to control initial wrapping width
221+ infoLabel .setLayoutData (labelGridData );
222+ createLabel (group , "" ); //$NON-NLS-1$
223+
224+ updateOnRuntime = createCheckButton (group , WorkbenchMessages .UpdateUIZoomTitle ,
225+ initialStateUpdateOnRuntime );
226+ }
227+
195228 private void createThemeIndependentComposits (Composite comp ) {
196229 createUseRoundTabs (comp );
197230 createColoredLabelsPref (comp );
@@ -212,6 +245,9 @@ protected void createHideIconsForViewTabs(Composite composite) {
212245 CTabRendering .HIDE_ICONS_FOR_VIEW_TABS_DEFAULT );
213246 hideIconsForViewTabs = createCheckButton (composite , WorkbenchMessages .ViewsPreference_hideIconsForViewTabs ,
214247 actualValue );
248+ GridData gridData = new GridData ();
249+ gridData .horizontalIndent = 20 ;
250+ hideIconsForViewTabs .setLayoutData (gridData );
215251 }
216252
217253 private boolean getSwtRendererPreference (String prefName , boolean defaultValue ) {
@@ -224,10 +260,6 @@ private boolean getSwtRendererPreference(String prefName, boolean defaultValue)
224260 * @param hideIconsForViewTabs
225261 */
226262 private void createDependency (Button parent , Button dependent ) {
227- GridData gridData = new GridData ();
228- gridData .horizontalIndent = 20 ;
229- dependent .setLayoutData (gridData );
230-
231263 boolean parentState = parent .getSelection ();
232264 dependent .setEnabled (parentState );
233265
@@ -341,6 +373,11 @@ public boolean performOk() {
341373 .getSelection ();
342374 prefs .putBoolean (PartRenderingEngine .ENABLED_THEME_KEY , themingEnabled .getSelection ());
343375
376+ boolean isUpdateOnRuntimeChanged = (updateOnRuntime != null
377+ && initialStateUpdateOnRuntime != updateOnRuntime .getSelection ());
378+ apiStore .setValue (IWorkbenchPreferenceConstants .UPDATE_ON_RUNTIME_KEY ,
379+ updateOnRuntime == null ? false : updateOnRuntime .getSelection ());
380+
344381 prefs .putBoolean (CTabRendering .USE_ROUND_TABS , useRoundTabs .getSelection ());
345382 try {
346383 prefs .flush ();
@@ -373,13 +410,20 @@ public boolean performOk() {
373410 if (themingEnabledChanged ) {
374411 showRestartDialog ();
375412 }
413+ if (isUpdateOnRuntimeChanged ) {
414+ showRestartDialog (WorkbenchMessages .RuntimeSettingChangeWarningTitle ,
415+ WorkbenchMessages .RuntimeSettingChangeWarningDesc );
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