本文整理汇总了Java中org.eclipse.swt.dnd.DropTargetEvent类的典型用法代码示例。如果您正苦于以下问题:Java DropTargetEvent类的具体用法?Java DropTargetEvent怎么用?Java DropTargetEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DropTargetEvent类属于org.eclipse.swt.dnd包,在下文中一共展示了DropTargetEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachDropListener
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
private void attachDropListener() {
dropTarget = new DropTarget(targetTable, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dropTarget.addDropListener(new DropTargetAdapter() {
public void drop(DropTargetEvent event) {
for (String fieldName : getformatedData((String) event.data)) {
if(isPropertyAlreadyExists(fieldName)){
return;
}else{
ExcelConfigurationDataStructure excelConfigurationDataStructure = new ExcelConfigurationDataStructure();
excelConfigurationDataStructure.setFieldName(fieldName);
listOfExcelConfiguration.add(excelConfigurationDataStructure);
targetTableViewer.refresh();
draggedFields.add(fieldName);
enableDeleteButton();
}
}
combo.setItems(convertToArray(draggedFields));
combo.select(0);
top_composite.layout();
top_composite.getParent().layout();
highlightDropFields();
}
});
}
示例2: getDragSource
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
protected Collection<?> getDragSource ( final DropTargetEvent event )
{
final ItemTransfer itemTransfer = ItemTransfer.getInstance ();
if ( itemTransfer.isSupportedType ( event.currentDataType ) )
{
if ( IS_MOTIF )
{
return null;
}
final Object object = itemTransfer.nativeToJava ( event.currentDataType );
return object == null ? null : extractDragSource ( object );
}
else
{
return super.getDragSource ( event );
}
}
示例3: getDragSource
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
protected Collection<?> getDragSource ( final DropTargetEvent event )
{
// Check whether the current data type can be transfered locally.
//
final ItemTransfer itemTransfer = ItemTransfer.getInstance ();
if ( itemTransfer.isSupportedType ( event.currentDataType ) )
{
// Motif kludge: we would get something random instead of null.
//
if ( IS_MOTIF )
{
return null;
}
// Transfer the data and, if non-null, extract it.
//
final Object object = itemTransfer.nativeToJava ( event.currentDataType );
return object == null ? null : extractDragSource ( object );
}
else
{
return super.getDragSource ( event );
}
}
示例4: drop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
public void drop(DropTargetEvent event) {
IStructuredSelection structuredSelection = (IStructuredSelection) LocalSelectionTransfer
.getTransfer().getSelection();
if (structuredSelection.size() == 1) {
AvroNode sourceNode = (AvroNode) structuredSelection.getFirstElement();
TreeItem item = (TreeItem) event.item;
if (item != null) {
AvroNode targetNode = nodeConverter.convertToAvroNode(item.getData());
dropPolicy.drop(sourceNode, targetNode, position);
}
}
}
示例5: testDropOn
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Test
@Ignore
public void testDropOn() {
// Given
BookmarkFolder bookmarkFolderToMoved = getBookmarkFolder(bookmarkDatabase.getBookmarksTree(), 1, 1, 1);
IStructuredSelection data = new StructuredSelection(bookmarkFolderToMoved);
BookmarkFolder currentTarget = getBookmarkFolder(bookmarkDatabase.getBookmarksTree(), 1, 1);
BookmarksViewerDropListener listener = getBookmarksViewerDropListener(ViewerDropAdapter.LOCATION_ON,
currentTarget);
// When
DropTargetEvent dropTargetEvent = mock(DropTargetEvent.class);
listener.dragEnter(dropTargetEvent);
listener.dragOver(dropTargetEvent);
listener.dropAccept(dropTargetEvent);
listener.drop(dropTargetEvent);
// assertTrue(listener.validateDrop(currentTarget, ViewerDropAdapter.LOCATION_ON, /* transferType */ null));
// boolean result = listener.performDrop(data);
// Then
// assertTrue(result);
assertEquals(1, bookmarksListener.getModifications().size());
assertIsBookmarksMovedModification(bookmarksListener.getModifications().get(0), currentTarget.getId(),
Lists.newArrayList(bookmarkFolderToMoved.getId()));
}
示例6: drop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
public void drop(DropTargetEvent event) {
int location = this.determineLocation(event);
source = getSelectedObject();
target = determineTarget(event);
String translatedLocation = "";
switch (location) {
case ViewerDropAdapter.LOCATION_BEFORE:
translatedLocation = "Dropped before the target ";
break;
case ViewerDropAdapter.LOCATION_AFTER:
translatedLocation = "Dropped after the target ";
break;
case ViewerDropAdapter.LOCATION_ON:
translatedLocation = "Dropped on the target ";
break;
case ViewerDropAdapter.LOCATION_NONE:
translatedLocation = "Dropped into nothing ";
break;
}
System.out.println(translatedLocation);
System.out.println("The drop was done on the element: " + target);
super.drop(event);
}
示例7: getDropItems
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
/**
* get the outline items being dropped, or null if there are none or if the event does not
* qualify for a drop.
*/
@SuppressWarnings("unchecked")
private List<PagePart> getDropItems(DropTargetEvent event) {
if (event.operations == DND.DROP_NONE || event.item == null) {
return null;
}
Object targetData = event.item.getData();
if (!(targetData instanceof PagePart)) {
return null;
}
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<?> list = structuredSelection.toList();
if (!list.isEmpty()) {
for (Object i : list) {
if (!(i instanceof PagePart)) return null;
}
return (List<PagePart>) list;
}
}
return null;
}
示例8: drop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
/**
* @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
*/
@Override
public void drop(DropTargetEvent event) {
Object data = event.data;
if (data instanceof String[]) {
final String[] strings = (String[]) data;
BusyIndicator.showWhile(null, new Runnable() {
@Override
public void run() {
for (int i = 0; i < strings.length; i++) {
processString(strings[i]);
}
}
});
}
}
示例9: handleDrop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
/**
* @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter,
* org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
*/
@Override
public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent event, Object target) {
switch (event.detail) {
case DND.DROP_DEFAULT:
case DND.DROP_MOVE:
return handleDropMove(target, event);
case DND.DROP_COPY:
return handleDropCopy(target, event);
default:
break;
}
return Status.CANCEL_STATUS;
}
示例10: dropCommandForNode
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.editor.DiagramDropTargetListener#dropCommandForNode(org.eclipse.swt.dnd.DropTargetEvent,
* org.eclipse.gef.commands.CompoundCommand,
* nexcore.tool.uml.ui.core.project.ITreeNode, int)
*/
@Override
protected void dropCommandForNode(DropTargetEvent event, CompoundCommand commpoundCommand, ITreeNode next, int count) {
Element treeElement = (Element) next.getEObject();
int horizontalScrollPoint = 0;
int verticalScrollPoint = 0;
Point eventPoint = null;
Command command = null;
org.eclipse.draw2d.geometry.Point where = null;
horizontalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getHorizontalBar()
.getSelection();
verticalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getVerticalBar()
.getSelection();
eventPoint = diagramEditor.getDiagramGraphicalViewer().getControl().toControl(event.x + horizontalScrollPoint,
event.y + verticalScrollPoint);
// y좌표에 +100은 여러개를 Dorp했을때 대각선 아래로 위치하도록 한다.
where = new org.eclipse.draw2d.geometry.Point(eventPoint.x + (count * 160), eventPoint.y);//20);
command = new DropLifeLineNotationCommand(UMLMessage.LABEL_ADD_DROP, diagramEditor, treeElement, where);
((DropLifeLineNotationCommand) command).setDiagram(this.diagramEditor.getDiagram());
commpoundCommand.add(command);
}
示例11: dropTargetIsValid
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
private boolean dropTargetIsValid(DropTargetEvent e, boolean isDrop) {
if (URLTransfer.getInstance().isSupportedType(e.currentDataType)) {
// on Windows, we get the URL already during drag operations...
// FIXME find a way to check the URL early on other platforms,
// too...
if (isDrop || Util.isWindows()) {
if (e.data == null && !extractEventData(e)) {
// ... but if we don't, it's no problem, unless this is
// already
// the final drop event
return !isDrop;
}
final String url = getUrl(e.data);
if (!ExampleURLHandler.isValidExample(url)) {
return false;
}
}
return true;
}
return false;
}
示例12: drop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
public void drop(DropTargetEvent event) {
if (!URLTransfer.getInstance().isSupportedType(event.currentDataType)) {
return;
}
final String url = getUrl(event.data);
if (ExampleURLHandler.isValidExample(url)) {
DropTarget source = (DropTarget) event.getSource();
Display display = source.getDisplay();
display.asyncExec(new Runnable() {
public void run() {
proceedInstallation(url);
}
});
}
}
示例13: getSelected
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
private TreeItem getSelected(DropTargetEvent event) {
try {
TreeItem selected = (TreeItem)event.item;
if (! OSTool.isSystemWindows()) {
// There is a bug in SWT under Linux :
// If the Tree has been configured to display column headers ("setHeaderVisible(true)"),
// the "item" attribute of the DropTargetEvent references the TreeItem UNDER the actually selected item !
// That's why we must "play" with the item's coordinates :(
int x = selected.getBounds().x + 2;
int y = selected.getBounds().y - selected.getBounds().height + 2;
selected = treFilters.getItem(new Point(x, y));
}
return selected;
} catch (RuntimeException e) {
return null;
}
}
示例14: drop
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
public void drop(DropTargetEvent event) {
if (!transfer.isSupportedType(event.currentDataType)){
return;
}
IProject currProj = getProject();
if (currProj == null){
return;
}
IResource[] resa = (IResource[])event.data;
StringBuilder sb = new StringBuilder(256);
sb.append(_getText());
int len = sb.length();
if (len > 0 && sb.charAt(len-1) == '\n') {
sb.setLength(len-1);
}
for (int i = 0; i < resa.length; i++) {
IResource res = resa[i];
if (res.getProject().equals(currProj)) {
sb.append("\n").append(res.getProjectRelativePath());
}
}
_setText(sb.toString());
}
示例15: dragOver
import org.eclipse.swt.dnd.DropTargetEvent; //导入依赖的package包/类
@Override
public void dragOver(DropTargetEvent event)
{
boolean match = false;
for (CoreDropTargetListener listener : listeners)
{
if(listener.appliesTo(event))
{
match = true;
listener.dragOver(event);
}
else
{
listener.reset();
}
}
if(!match)
{
event.detail = DND.DROP_NONE;
}
}