/* (non-Javadoc) * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @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 public void selectionChanged(IStructuredSelection sel) { if (sel.size() == 1) { breakpoint = (IBreakpoint) DebugPlugin.getAdapter(sel.getFirstElement(), IBreakpoint.class); } else { breakpoint = null; } setEnabled(breakpoint != null); }
private ICastToType[] getCastToType(Object evaluationContext) { List<ICastToType> castableItems = new ArrayList<ICastToType>(); if (evaluationContext instanceof IEvaluationContext) { Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof IStructuredSelection) { Iterator<?> iter = ((IStructuredSelection) s).iterator(); while (iter.hasNext()) { Object element = DebugPlugin.getAdapter(iter.next(), ICastToType.class); if (element instanceof ICastToType) { if (((ICastToType) element).canCast()) { castableItems.add((ICastToType) element); } } } } } return castableItems.toArray(new ICastToType[castableItems.size()]); }
/** * 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); }