本文整理汇总了Java中org.eclipse.jface.viewers.ViewerDropAdapter类的典型用法代码示例。如果您正苦于以下问题:Java ViewerDropAdapter类的具体用法?Java ViewerDropAdapter怎么用?Java ViewerDropAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewerDropAdapter类属于org.eclipse.jface.viewers包,在下文中一共展示了ViewerDropAdapter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDropOn
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的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()));
}
示例2: drop
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的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);
}
示例3: configureDropSupport
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的package包/类
/**
* @param listener
*/
public void configureDropSupport(final DropListener listener) {
modelViewer.treeViewer.addDropSupport(DND.DROP_MOVE,
new Transfer[] {LocalSelectionTransfer.getTransfer()},
new ViewerDropAdapter(modelViewer.treeViewer) {
@Override
public boolean performDrop(final Object data) {
try {
listener.drop(((IStructuredSelection) LocalSelectionTransfer
.getTransfer()
.getSelection()).getFirstElement(),
(Model) getCurrentTarget());
return true;
} catch (final Exception e) {
Activator.error(e);
return false;
}
}
@Override
public boolean validateDrop(final Object target,
final int operation,
final TransferData transferType) {
return getCurrentLocation() == ViewerDropAdapter.LOCATION_ON;
}
});
}
示例4: run
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的package包/类
public void run( )
{
DNDService.getInstance( ).performDrop( TYPE,
( (IStructuredSelection) getSelection( ) ).getFirstElement( ),
DND.DROP_DEFAULT,
new DNDLocation( ViewerDropAdapter.LOCATION_ON ) );
}
示例5: calculateEnabled
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的package包/类
protected boolean calculateEnabled( )
{
if ( getSelection( ) instanceof IStructuredSelection )
return DNDService.getInstance( )
.validDrop( TYPE,
( (IStructuredSelection) getSelection( ) ).getFirstElement( ),
DND.DROP_DEFAULT,
new DNDLocation( ViewerDropAdapter.LOCATION_ON ) );
return false;
}
示例6: performProfileDrop
import org.eclipse.jface.viewers.ViewerDropAdapter; //导入依赖的package包/类
private boolean performProfileDrop(Profile draggedProfile) {
Profile targetProfile = (Profile) getCurrentTarget();
ProfilesContentProvider contentProvider = getContentProvider();
List<Profile> profiles = contentProvider.getProfiles();
if (profiles.remove(draggedProfile)) {
int index = profiles.indexOf(targetProfile) + 1;
switch (getCurrentLocation()) {
case ViewerDropAdapter.LOCATION_AFTER:
++index;
break;
case ViewerDropAdapter.LOCATION_BEFORE:
--index;
break;
default:
break;
}
if (index >= profiles.size()) {
profiles.add(draggedProfile);
}
else {
profiles.add(index, draggedProfile);
}
viewer.refresh();
return true;
}
return false;
}