KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ResetPerspectiveAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
22  * Reset the layout within the active perspective.
23  */

24 public class ResetPerspectiveAction extends PerspectiveAction {
25
26     /**
27      * This default constructor allows the the action to be called from the welcome page.
28      */

29     public ResetPerspectiveAction() {
30         this(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
31     }
32
33     /**
34      * Create an instance of this class
35      * @param window the window
36      */

37     public ResetPerspectiveAction(IWorkbenchWindow window) {
38         super(window);
39         setText(WorkbenchMessages.ResetPerspective_text);
40         setActionDefinitionId("org.eclipse.ui.window.resetPerspective"); //$NON-NLS-1$
41
// @issue missing action id
42
setToolTipText(WorkbenchMessages.ResetPerspective_toolTip);
43         window.getWorkbench().getHelpSystem().setHelp(this,
44                 IWorkbenchHelpContextIds.RESET_PERSPECTIVE_ACTION);
45     }
46
47     /* (non-Javadoc)
48      * Method declared on PerspectiveAction.
49      */

50     protected void run(IWorkbenchPage page, IPerspectiveDescriptor persp) {
51         String JavaDoc message = NLS.bind(WorkbenchMessages.ResetPerspective_message, persp.getLabel() );
52         String JavaDoc[] buttons = new String JavaDoc[] { 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