01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal;
11:
12: import org.eclipse.jface.dialogs.IDialogConstants;
13: import org.eclipse.jface.dialogs.MessageDialog;
14: import org.eclipse.osgi.util.NLS;
15: import org.eclipse.ui.IPerspectiveDescriptor;
16: import org.eclipse.ui.IWorkbenchPage;
17: import org.eclipse.ui.IWorkbenchWindow;
18: import org.eclipse.ui.PlatformUI;
19:
20: /**
21: * Reset the layout within the active perspective.
22: */
23: public class ResetPerspectiveAction extends PerspectiveAction {
24:
25: /**
26: * This default constructor allows the the action to be called from the welcome page.
27: */
28: public ResetPerspectiveAction() {
29: this (PlatformUI.getWorkbench().getActiveWorkbenchWindow());
30: }
31:
32: /**
33: * Create an instance of this class
34: * @param window the window
35: */
36: public ResetPerspectiveAction(IWorkbenchWindow window) {
37: super (window);
38: setText(WorkbenchMessages.ResetPerspective_text);
39: setActionDefinitionId("org.eclipse.ui.window.resetPerspective"); //$NON-NLS-1$
40: // @issue missing action id
41: setToolTipText(WorkbenchMessages.ResetPerspective_toolTip);
42: window.getWorkbench().getHelpSystem().setHelp(this ,
43: IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION);
44: }
45:
46: /* (non-Javadoc)
47: * Method declared on PerspectiveAction.
48: */
49: protected void run(IWorkbenchPage page, IPerspectiveDescriptor persp) {
50: String message = NLS.bind(
51: WorkbenchMessages.ResetPerspective_message, persp
52: .getLabel());
53: String[] buttons = new String[] { IDialogConstants.OK_LABEL,
54: IDialogConstants.CANCEL_LABEL };
55: MessageDialog d = new MessageDialog(getWindow().getShell(),
56: WorkbenchMessages.ResetPerspective_title, null,
57: message, MessageDialog.QUESTION, buttons, 0);
58: if (d.open() == 0) {
59: page.resetPerspective();
60: }
61: }
62:
63: }
|