}
}
@Override
public void drop(DropTargetEvent event) {
ComponentInserter inserter = null;
boolean selectRange = false;
IStructuredSelection structuredSelection = (IStructuredSelection) event.data;
if (structuredSelection != null && !structuredSelection.isEmpty()) {
IResource resource = (IResource) structuredSelection.getFirstElement();
if (resource instanceof IFolder) {
IFolder folder = (IFolder) resource;
String name = folder.getName();
if (name.endsWith(".wo")) {
String componentName = name.substring(0, name.lastIndexOf('.'));
boolean inline = true;
inserter = new ComponentInserter(_componentEditor, componentName, inline);
Wo wo = inserter.getWo();
if (wo != null) {
selectRange = wo.isComponentContent();
}
}
}
}
if (inserter == null) {
event.detail = DND.DROP_NONE;
return;
}
IRewriteTarget target = (IRewriteTarget) _componentEditor.getAdapter(IRewriteTarget.class);
if (target != null) {
target.beginCompoundChange();
}
if (!getTemplateEditor().getSourceEditor().validateEditorInputState()) {
event.detail = DND.DROP_NONE;
return;
}
if (selectRange) {
getTemplateEditor().getSelectionProvider().setSelection(new TextSelection(_selection.getOffset(), _selection.getLength()));
} else {
getTemplateEditor().getSelectionProvider().setSelection(new TextSelection(_selection.getOffset(), 0));
}
inserter.insert();
}