1 11 package org.eclipse.debug.internal.ui.actions.breakpointGroups; 12 13 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; 14 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer; 15 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointSetOrganizer; 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.ui.IWorkingSet; 21 22 25 public class ToggleDefaultGroupAction extends AbstractBreakpointsViewAction { 26 27 private IWorkingSet fSelectedSet; 28 29 32 public void run(IAction action) { 33 IWorkingSet defaultWorkingSet = BreakpointSetOrganizer.getDefaultWorkingSet(); 34 IWorkingSet set = null; 35 if (!fSelectedSet.equals(defaultWorkingSet)) { 36 set = fSelectedSet; 37 } 38 BreakpointSetOrganizer.setDefaultWorkingSet(set); 39 } 40 41 44 public void selectionChanged(IAction action, ISelection sel) { 45 fSelectedSet = null; 46 if (sel instanceof IStructuredSelection) { 47 IStructuredSelection selection = (IStructuredSelection) sel; 48 if (selection.size() == 1) { 49 Object firstElement = selection.getFirstElement(); 50 if (firstElement instanceof BreakpointContainer) { 51 BreakpointContainer container = (BreakpointContainer) firstElement; 52 if (container.getCategory() instanceof WorkingSetCategory) { 53 WorkingSetCategory category = (WorkingSetCategory)container.getCategory(); 54 if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(category.getWorkingSet().getId())) { 55 IWorkingSet set = category.getWorkingSet(); 56 action.setEnabled(true); 57 boolean isDefault = set == BreakpointSetOrganizer.getDefaultWorkingSet(); 58 action.setChecked(isDefault); 59 fSelectedSet = set; 60 return; 61 } 62 } 63 } 64 } 65 } 66 action.setEnabled(false); 67 action.setChecked(false); 68 } 69 } 70 | Popular Tags |