1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.jface.dialogs.IDialogConstants; 14 import org.eclipse.jface.dialogs.MessageDialog; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.ui.IPerspectiveDescriptor; 17 import org.eclipse.ui.IWorkbenchPage; 18 import org.eclipse.ui.IWorkbenchWindow; 19 import org.eclipse.ui.PlatformUI; 20 21 24 public class ResetPerspectiveAction extends PerspectiveAction { 25 26 29 public ResetPerspectiveAction() { 30 this(PlatformUI.getWorkbench().getActiveWorkbenchWindow()); 31 } 32 33 37 public ResetPerspectiveAction(IWorkbenchWindow window) { 38 super(window); 39 setText(WorkbenchMessages.ResetPerspective_text); 40 setActionDefinitionId("org.eclipse.ui.window.resetPerspective"); setToolTipText(WorkbenchMessages.ResetPerspective_toolTip); 43 window.getWorkbench().getHelpSystem().setHelp(this, 44 IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION); 45 } 46 47 50 protected void run(IWorkbenchPage page, IPerspectiveDescriptor persp) { 51 String message = NLS.bind(WorkbenchMessages.ResetPerspective_message, persp.getLabel() ); 52 String [] buttons = new String [] { IDialogConstants.OK_LABEL, 53 IDialogConstants.CANCEL_LABEL }; 54 MessageDialog d = new MessageDialog(getWindow().getShell(), 55 WorkbenchMessages.ResetPerspective_title, 56 null, message, MessageDialog.QUESTION, buttons, 0); 57 if (d.open() == 0) { 58 page.resetPerspective(); 59 } 60 } 61 62 } 63 | Popular Tags |