1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.preference.PreferenceDialog; 15 import org.eclipse.ui.IWorkbenchWindow; 16 import org.eclipse.ui.PlatformUI; 17 import org.eclipse.ui.actions.ActionFactory; 18 import org.eclipse.ui.dialogs.PreferencesUtil; 19 20 23 public class OpenPreferencesAction extends Action implements ActionFactory.IWorkbenchAction { 24 25 29 private IWorkbenchWindow workbenchWindow; 30 31 35 public OpenPreferencesAction() { 36 this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); 37 } 38 39 44 public OpenPreferencesAction(IWorkbenchWindow window) { 45 super(WorkbenchMessages.OpenPreferences_text); 46 if (window == null) { 47 throw new IllegalArgumentException (); 48 } 49 this.workbenchWindow = window; 50 setToolTipText(WorkbenchMessages.OpenPreferences_toolTip); 52 window.getWorkbench().getHelpSystem().setHelp(this, 53 IWorkbenchHelpContextIds.OPEN_PREFERENCES_ACTION); 54 } 55 56 59 public void run() { 60 if (workbenchWindow == null) { 61 return; 63 } 64 PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, null, null, null); 65 dialog.open(); 66 } 67 68 71 public void dispose() { 72 workbenchWindow = null; 73 } 74 75 } 76 | Popular Tags |