1 11 12 package org.eclipse.ui.internal.handlers; 13 14 import org.eclipse.core.commands.AbstractHandler; 15 import org.eclipse.core.commands.ExecutionEvent; 16 import org.eclipse.core.commands.ExecutionException; 17 import org.eclipse.jface.preference.PreferenceDialog; 18 import org.eclipse.swt.widgets.Shell; 19 import org.eclipse.ui.IWorkbenchWindow; 20 import org.eclipse.ui.dialogs.PreferencesUtil; 21 import org.eclipse.ui.handlers.HandlerUtil; 22 23 36 public final class ShowPreferencePageHandler extends AbstractHandler { 37 38 41 private static final String PARAMETER_ID_PREFERENCE_PAGE_ID = "preferencePageId"; 43 public final Object execute(final ExecutionEvent event) 44 throws ExecutionException { 45 final String preferencePageId = event 46 .getParameter(PARAMETER_ID_PREFERENCE_PAGE_ID); 47 final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil 48 .getActiveWorkbenchWindowChecked(event); 49 50 final Shell shell = activeWorkbenchWindow.getShell(); 51 if (shell == null) { 52 throw new ExecutionException("no shell for active workbench window"); } 54 55 final PreferenceDialog dialog = PreferencesUtil 56 .createPreferenceDialogOn(shell, preferencePageId, null, null); 57 dialog.open(); 58 59 return null; 60 } 61 62 } 63 | Popular Tags |