private CommonDropAdapterAssistant[] pySortAssistants(CommonDropAdapterAssistant[] array) { Arrays.sort(array, new Comparator() { @Override public int compare(Object arg0, Object arg1) { CommonDropAdapterAssistant a = (CommonDropAdapterAssistant) arg0; CommonDropAdapterAssistant b = (CommonDropAdapterAssistant) arg1; // This is to ensure that the PyDev drop assistant will always // be chosen over non-PyDev ones, if a conflict ever occurs. String id = "org.python.pydev.navigator.actions"; //$NON-NLS-1$ if (a.getClass().getName().startsWith(id)) { return -1; } if (b.getClass().getName().startsWith(id)) { return 1; } return a.getClass().getName().compareTo(b.getClass().getName()); } }); return array; }
@Override public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants( Object aDropTarget, TransferData aTransferType) { CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager .getInstance().findCommonDropAdapterAssistants(aDropTarget, pyContentService); if (descriptors.length == 0) { return NO_ASSISTANTS; } if (LocalSelectionTransfer.getTransfer().isSupportedType(aTransferType) && LocalSelectionTransfer.getTransfer().getSelection() instanceof IStructuredSelection) { return pyGetAssistantsBySelection(descriptors, (IStructuredSelection) LocalSelectionTransfer .getTransfer().getSelection()); } return pyGetAssistantsByTransferData(descriptors, aTransferType); }
@Override public CommonDropAdapterAssistant[] findCommonDropAdapterAssistants( Object aDropTarget, IStructuredSelection theDragSelection) { CommonDropAdapterDescriptor[] descriptors = CommonDropDescriptorManager .getInstance().findCommonDropAdapterAssistants(aDropTarget, pyContentService); if (descriptors.length == 0) { return NO_ASSISTANTS; } return pyGetAssistantsBySelection(descriptors, theDragSelection); }
private CommonDropAdapterAssistant[] pyGetAssistantsByTransferData( CommonDropAdapterDescriptor[] descriptors, TransferData aTransferType) { Set assistants = new LinkedHashSet(); for (int i = 0; i < descriptors.length; i++) { CommonDropAdapterAssistant asst = pyGetAssistant(descriptors[i]); if (asst.isSupportedType(aTransferType)) { assistants.add(asst); } } return pySortAssistants((CommonDropAdapterAssistant[]) assistants .toArray(new CommonDropAdapterAssistant[assistants.size()])); }
private CommonDropAdapterAssistant[] pyGetAssistantsBySelection( CommonDropAdapterDescriptor[] descriptors, IStructuredSelection aSelection) { Set assistants = new LinkedHashSet(); for (int i = 0; i < descriptors.length; i++) { if (descriptors[i].areDragElementsSupported(aSelection)) { assistants.add(pyGetAssistant(descriptors[i])); } } return pySortAssistants((CommonDropAdapterAssistant[]) assistants .toArray(new CommonDropAdapterAssistant[assistants.size()])); }