1 11 package org.eclipse.ui.dialogs; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.jface.preference.IPreferencePage; 15 import org.eclipse.jface.preference.PreferenceDialog; 16 import org.eclipse.jface.preference.PreferenceManager; 17 import org.eclipse.jface.preference.PreferencePage; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog; 20 import org.eclipse.ui.internal.dialogs.PropertyDialog; 21 import org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog; 22 23 28 public final class PreferencesUtil { 29 30 36 private static void applyOptions(Object data, String [] displayedIds, 37 FilteredPreferenceDialog dialog) { 38 if (data != null) { 39 dialog.setPageData(data); 40 IPreferencePage page = dialog.getCurrentPage(); 41 if (page instanceof PreferencePage) { 42 ((PreferencePage) page).applyData(data); 43 } 44 } 45 46 if (displayedIds != null) { 47 dialog.showOnly(displayedIds); 48 } 49 } 50 51 83 public static final PreferenceDialog createPreferenceDialogOn(Shell shell, 84 String preferencePageId, String [] displayedIds, Object data) { 85 FilteredPreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(shell, 86 preferencePageId); 87 88 applyOptions(data, displayedIds, dialog); 89 90 return dialog; 91 } 92 93 123 public static final PreferenceDialog createPropertyDialogOn(Shell shell, 124 final IAdaptable element, String propertyPageId, String [] displayedIds, Object data) { 125 126 FilteredPreferenceDialog dialog = PropertyDialog.createDialogOn(shell, propertyPageId, 127 element); 128 129 if (dialog == null) { 130 return null; 131 } 132 133 applyOptions(data, displayedIds, dialog); 134 135 return dialog; 136 137 } 138 139 } 140 | Popular Tags |