use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.
the class CommonDropAdapter method validateDrop.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object,
* int, org.eclipse.swt.dnd.TransferData)
*/
public boolean validateDrop(final Object aDropTarget, final int theDropOperation, final TransferData theTransferData) {
if (Policy.DEBUG_DND) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("CommonDropAdapter.validateDrop (begin) operation: " + theDropOperation + " target: " + aDropTarget);
// new Exception().printStackTrace(System.out);
}
boolean result = false;
final IStatus[] valid = new IStatus[1];
if (super.validateDrop(aDropTarget, theDropOperation, theTransferData)) {
result = true;
if (Policy.DEBUG_DND) {
// $NON-NLS-1$
System.out.println("CommonDropAdapter.validateDrop valid for plugin transfer");
}
} else {
final Object target = aDropTarget != null ? aDropTarget : getViewer().getInput();
if (Policy.DEBUG_DND) {
// $NON-NLS-1$
System.out.println("CommonDropAdapter.validateDrop target: " + target);
System.out.println(// $NON-NLS-1$
"CommonDropAdapter.validateDrop local selection: " + LocalSelectionTransfer.getTransfer().getSelection());
}
CommonDropAdapterAssistant[] assistants = dndService.findCommonDropAdapterAssistants(target, theTransferData);
for (int i = 0; i < assistants.length; i++) {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDropAdapter.validateDrop checking assistant: \"" + assistants[i]);
}
final CommonDropAdapterAssistant assistantLocal = assistants[i];
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
assistantLocal.setCurrentEvent(getCurrentEvent());
valid[0] = assistantLocal.validateDrop(target, theDropOperation, theTransferData);
}
});
if (valid[0] != null && valid[0].isOK()) {
result = true;
if (Policy.DEBUG_DND) {
// $NON-NLS-1$
System.out.println("CommonDropAdapter.validateDrop VALID");
}
break;
}
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"CommonDropAdapter.validateDrop NOT valid: " + (valid[0] != null ? (valid[0].getSeverity() + ": " + valid[0].getMessage()) : ""));
}
}
}
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"CommonDropAdapter.validateDrop (returning " + (valid[0] != null ? valid[0].getSeverity() + ": " + valid[0].getMessage() : "" + result) + ")");
}
setScrollExpandEnabled(true);
return result;
}
use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.
the class CommonSorterDescriptor method createSorter.
/**
* @return An instance of the ViewerSorter defined by the extension. Callers
* of this method are responsible for managing the instantiated
* filter.
*/
public ViewerSorter createSorter() {
final ViewerSorter[] sorter = new ViewerSorter[1];
SafeRunner.run(new NavigatorSafeRunnable(element) {
public void run() throws Exception {
sorter[0] = (ViewerSorter) element.createExecutableExtension(ATT_CLASS);
}
});
if (sorter[0] != null)
return sorter[0];
return SkeletonViewerSorter.INSTANCE;
}
use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.
the class CommonDragAdapter method dragSetData.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.dnd.DragSourceAdapter#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
*/
public void dragSetData(final DragSourceEvent event) {
final ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$ //$NON-NLS-2$
"CommonDragAdapter.dragSetData: event" + event + " selection=" + selection);
}
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
event.data = selection;
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set LocalSelectionTransfer: " + event.data);
}
} else if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = NavigatorPluginDropAction.createTransferData(contentService);
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set PluginTransfer: " + event.data);
}
} else if (selection instanceof IStructuredSelection) {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData looking for assistants");
}
for (int i = 0, len = assistantsToUse.size(); i < len; i++) {
final CommonDragAdapterAssistant assistant = (CommonDragAdapterAssistant) assistantsToUse.get(i);
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData assistant: " + assistant);
}
Transfer[] supportedTransferTypes = assistant.getSupportedTransferTypes();
final boolean[] getOut = new boolean[1];
for (int j = 0; j < supportedTransferTypes.length; j++) {
if (supportedTransferTypes[j].isSupportedType(event.dataType)) {
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData supported xfer type");
}
if (assistant.setDragData(event, (IStructuredSelection) selection)) {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData set data " + event.data);
}
setDataAssistant = assistant;
getOut[0] = true;
}
}
});
if (getOut[0])
return;
}
}
}
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData FAILED no assistant handled it");
}
event.doit = false;
} else {
if (Policy.DEBUG_DND) {
System.out.println(// $NON-NLS-1$
"CommonDragAdapter.dragSetData FAILED can't identify transfer type");
}
event.doit = false;
}
}
use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.
the class StructuredViewerManager method safeRefresh.
/**
*/
public void safeRefresh() {
final Viewer localViewer = viewer;
if (localViewer == null || localViewer.getControl().isDisposed())
return;
Display display = localViewer.getControl().getDisplay();
if (display.isDisposed())
return;
display.syncExec(new Runnable() {
public void run() {
if (localViewer.getControl().isDisposed())
return;
SafeRunner.run(new NavigatorSafeRunnable() {
public void run() throws Exception {
localViewer.getControl().setRedraw(false);
localViewer.refresh();
}
});
localViewer.getControl().setRedraw(true);
}
});
}
use of org.eclipse.ui.internal.navigator.NavigatorSafeRunnable in project polymap4-core by Polymap4.
the class CommonDragAssistantDescriptor method createDragAssistant.
/**
* Create an instance of the {@link CommonDragAdapterAssistant} defined by
* this descriptor.
*
* @return an instance of the {@link CommonDragAdapterAssistant} or
* {@link SkeletonCommonDragAssistant} if a problem occurs with the
* instantiation.
*/
public CommonDragAdapterAssistant createDragAssistant() {
final CommonDragAdapterAssistant[] da = new CommonDragAdapterAssistant[1];
SafeRunner.run(new NavigatorSafeRunnable(element) {
public void run() throws Exception {
da[0] = (CommonDragAdapterAssistant) element.createExecutableExtension(ATT_CLASS);
}
});
if (da[0] != null)
return da[0];
return SkeletonCommonDragAssistant.INSTANCE;
}
Aggregations