KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > breakpointGroups > EditBreakpointGroupAction


1 /*******************************************************************************
2  * Copyright (c) 2004, 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 implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.actions.breakpointGroups;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.debug.internal.ui.DebugUIPlugin;
15 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
16 import org.eclipse.debug.internal.ui.views.breakpoints.WorkingSetCategory;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.jface.wizard.WizardDialog;
21 import org.eclipse.ui.IWorkingSet;
22 import org.eclipse.ui.PlatformUI;
23 import org.eclipse.ui.dialogs.IWorkingSetEditWizard;
24
25 /**
26  * An action to edit a breakpoint working set.
27  */

28 public class EditBreakpointGroupAction extends AbstractBreakpointsViewAction {
29     
30     /**
31      * The currently selected breakpoints
32      */

33     private IWorkingSet fSet = null;
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
37      */

38     public void run(IAction action) {
39         IWorkingSetEditWizard editWizard = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetEditWizard(fSet);
40         WizardDialog dialog = new WizardDialog(DebugUIPlugin.getShell(), editWizard);
41         dialog.open();
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
46      */

47     public void selectionChanged(IAction action, ISelection sel) {
48         IStructuredSelection selection= (IStructuredSelection) sel;
49         fSet = null;
50         if (selection.size() == 1) {
51             Object JavaDoc element = selection.getFirstElement();
52             if (element instanceof BreakpointContainer) {
53                 BreakpointContainer container = (BreakpointContainer)element;
54                 IAdaptable category = container.getCategory();
55                 if (category instanceof WorkingSetCategory) {
56                     IWorkingSet set = ((WorkingSetCategory)category).getWorkingSet();
57                     action.setEnabled(true);
58                     fSet = set;
59                     return;
60                 }
61             }
62         }
63         action.setEnabled(false);
64     }
65
66 }
67
Popular Tags