@Override protected boolean isEnabledFor(Object element) { return DebugPlugin.getAdapter(element, IExpression.class) != null; } }
/** * Returns an adapter of the specified type for the given object or <code>null</code> * if none. * * @param element element to retrieve adapter for * @param type adapter type * @return adapter or <code>null</code> */ private static Object getAdapter(Object element, Class<?> type) { return DebugPlugin.getAdapter(element, type); } }
/** * Convenience method to return an adapter of the specified type for the given object or <code>null</code> * if none. * * @param element element to retrieve adapter for * @param type adapter type * @return adapter or <code>null</code> */ protected Object getAdapter(Object element, Class<?> type) { return DebugPlugin.getAdapter(element, type); }
private IDebugCommandHandler getHandler(Object element, Class<?> handlerType) { return (IDebugCommandHandler)DebugPlugin.getAdapter(element, handlerType); }
/** * Finds the toggle breakpoints target for the active part and selection. * It first looks for the target using the factories registered using an * extension point. If not found it uses the <code>IAdaptable</code> * mechanism. * @param part The workbench part in which toggle target is to be used * @param element The selection element to retrieve the toggle adapter from * @return The toggle breakpoints target, or <code>null</code> if not found. */ private IToggleBreakpointsTarget getToggleBreakpointsTarget(IWorkbenchPart part, Object element) { IToggleBreakpointsTarget target = null; if (element != null) { target = (IToggleBreakpointsTarget) DebugPlugin.getAdapter(element, IToggleBreakpointsTarget.class); } if (target == null) { target = (IToggleBreakpointsTarget) DebugPlugin.getAdapter(part, IToggleBreakpointsTarget.class); } return target; }
private IAdaptable[] selectBreakpoints(IAdaptable[] elements) { List<IBreakpoint> breakpoints = new ArrayList<>(elements.length); for (int i = 0; i < elements.length; i++) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(elements[i], IBreakpoint.class); if (breakpoint != null) { breakpoints.add(breakpoint); } } return breakpoints.toArray(new IAdaptable[breakpoints.size()]); }
@Override public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) { for (int i = 0; i < elements.length; i++) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(elements[i], IBreakpoint.class); if (breakpoint != null) { return selectBreakpoints(elements); } } return elements; }
@Override public int compare(Object arg0, Object arg1) { IBreakpoint bp0 = (IBreakpoint)DebugPlugin.getAdapter(arg0, IBreakpoint.class); IBreakpoint bp1 = (IBreakpoint)DebugPlugin.getAdapter(arg1, IBreakpoint.class); if (bp0 != null && bp1 != null) { return doCompare(bp0, bp1); } else if (arg0 instanceof IBreakpointContainer && arg1 instanceof IBreakpointContainer) { return doCompare((IBreakpointContainer) arg0, (IBreakpointContainer) arg1); } else { return -1; // just return -1 if the two objects are not IBreakpoint type } }
@Override protected boolean isEnabledFor(Object element) { if (element instanceof IBreakpointContainer) { if(((IBreakpointContainer)element).getCategory() instanceof WorkingSetCategory) { return true; } return ((IBreakpointContainer)element).getBreakpoints().length > 0; } return DebugPlugin.getAdapter(element, IBreakpoint.class) != null; } }
/** * Determines if the specified element can be dropped into the specified target * <p> * Scheme: * <ul> * <li>Breakpoints can be dropped into working sets</li> * <li>Breakpoints can be dropped into breakpoints, provided there is a drop-able parent of the target breakpoint</li> * </ul> * </p> * @param target the target for the drop * @param selection the selection to see if we can drop * @return true if the specified element can be dropped into the specified target, false otherwise * @since 3.3 */ boolean canDrop(TreePath target, ITreeSelection selection) { if (selection == null || target == null) { return false; } for (Iterator<?> iter = selection.iterator(); iter.hasNext();) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(iter.next(), IBreakpoint.class); if (breakpoint == null || !checkAddableParentContainers(target, breakpoint)){ return false; } } return true; } }
@Override public void run(IProgressMonitor monitor) { while (itr.hasNext()) { Object element= itr.next(); try { IBreakpoint[] breakpoints= null; IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(element, IBreakpoint.class); if (breakpoint != null) { breakpoints= new IBreakpoint[] { breakpoint }; } else if (element instanceof IBreakpointContainer) { breakpoints= ((IBreakpointContainer) element).getBreakpoints(); } if (breakpoints != null) { setEnabled(breakpoints); } } catch (CoreException e) { ms.merge(e.getStatus()); } } } public void setEnabled(IBreakpoint[] breakpoints) throws CoreException {
protected void contextActivated(ISelection selection) { fTargetElement = null; if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); } } update(); }
/** * Return the ILaunch associated with a model element, or null if there is * no such association. * * @param element the model element * @return the ILaunch associated with the element, or null. * @since 3.6 */ public static ILaunch getLaunch(Object element) { // support for custom models ILaunch launch= (ILaunch)DebugPlugin.getAdapter(element, ILaunch.class); if (launch == null) { // support for standard debug model if (element instanceof IDebugElement) { launch= ((IDebugElement)element).getLaunch(); } else if (element instanceof ILaunch) { launch= ((ILaunch)element); } else if (element instanceof IProcess) { launch= ((IProcess)element).getLaunch(); } } return launch; }
protected void contextActivated(ISelection selection) { fTargetElement = null; if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); } } update(); }
@Override public void finish() { String workingSetName = fWorkingSetName.getText(); Object[] adaptable = fTViewer.getCheckedElements().toArray(); ArrayList<IBreakpoint> elements = new ArrayList<>(); //weed out non-breakpoint elements since 3.2 for(int i = 0; i < adaptable.length; i++) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(adaptable[i], IBreakpoint.class); if(breakpoint != null) { elements.add(breakpoint); }//end if }//end for if (fWorkingSet == null) { IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager(); fWorkingSet = workingSetManager.createWorkingSet(workingSetName, elements.toArray(new IAdaptable[elements.size()])); } else { fWorkingSet.setName(workingSetName); fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()])); } }
/** * Performs the initialization of the viewer from a selection */ private void initViewerState() { Object[] items = fSelection.toArray(); fViewer.setGrayedElements(new Object[] {}); fViewer.setCheckedElements(new Object[] {}); ArrayList<IBreakpoint> list = new ArrayList<>(); for(int i = 0; i < items.length; i++) { Object item = items[i]; IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(item, IBreakpoint.class); if(breakpoint != null) { list.add(breakpoint); } else if (item instanceof IBreakpointContainer) { getBreakpointsFromContainers((IBreakpointContainer)item, list); } } for(int i = 0; i < list.size(); i++) { updateCheckedState(list.get(i), true); } }
private IAction getOverrideAction(String actionID) { Viewer viewer = getViewer(); if (viewer != null) { IViewActionProvider actionProvider = (IViewActionProvider) DebugPlugin.getAdapter( viewer.getInput(), IViewActionProvider.class); if (actionProvider != null) { IAction action = actionProvider.getAction(getPresentationContext(), actionID); if (action != null) { return action; } } } return null; }
protected void contextActivated(ISelection selection) { fTargetElement = null; if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); } } IAction action = getAction(); if (action != null) { action.setEnabled(fTargetElement != null && isTargetEnabled()); } }
/** * Pastes the selection into the given target * * @param target target of the paste, either a IBreakpointContainer, * or a Breakpoint within a IBreakpointContainer * @param selection breakpoints * @return whether successful * * TODO remove in favor of using <code>TreeItem</code> as paste target */ public boolean performPaste(Object target, ISelection selection) { if (target instanceof IBreakpointContainer && selection instanceof IStructuredSelection) { IBreakpointContainer container = (IBreakpointContainer) target; Object[] objects = ((IStructuredSelection)selection).toArray(); for (int i = 0; i < objects.length; i++) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(objects[i], IBreakpoint.class); if (breakpoint != null) { container.getOrganizer().addBreakpoint(breakpoint, container.getCategory()); } } return true; } return false; }
@Override public void selectionChanged(IStructuredSelection sel) { if (sel.size() == 1) { breakpoint = (IBreakpoint)DebugPlugin.getAdapter(sel.getFirstElement(), IBreakpoint.class); if (breakpoint != null) { input= fgPresentation.getEditorInput(breakpoint); if (input != null) { setEnabled(true); return; } } } else { breakpoint = null; input = null; } setEnabled(false); } }