KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > SelectAllAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.debug.internal.ui.actions;
12
13 import org.eclipse.debug.ui.IDebugView;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.swt.widgets.Control;
17 import org.eclipse.swt.widgets.Tree;
18 import org.eclipse.ui.IViewPart;
19
20 public abstract class SelectAllAction extends AbstractRemoveAllActionDelegate {
21     
22     private IViewPart fView;
23
24     /* (non-Javadoc)
25      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractSelectionActionDelegate#init(org.eclipse.ui.IViewPart)
26      */

27     public void init(IViewPart view) {
28         fView = view;
29         IDebugView debugView = (IDebugView) getView().getAdapter(IDebugView.class);
30         if (debugView != null) {
31             debugView.setAction(getActionId(), getAction());
32         }
33         super.init(view);
34     }
35     
36     protected IViewPart getView() {
37         return fView;
38     }
39     
40     protected abstract String JavaDoc getActionId();
41     
42     /**
43      * @see IActionDelegate#run(IAction)
44      */

45     public void run(IAction action){
46         if (!(getView() instanceof IDebugView)) {
47             return;
48         }
49         Viewer viewer = ((IDebugView) getView()).getViewer();
50         Control control = viewer.getControl();
51         if (control instanceof Tree) {
52             ((Tree)control).selectAll();
53         }
54     }
55     
56 }
57
Popular Tags