当前位置: 首页>>代码示例>>Java>>正文


Java ViewerDropAdapter类代码示例

本文整理汇总了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()));
	}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:26,代码来源:BookmarksViewerDropListenerTest.java

示例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);
}
 
开发者ID:aroog,项目名称:code,代码行数:27,代码来源:ObjectTreeViewDropListener.java

示例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;
                }
            });
}
 
开发者ID:fabric8io,项目名称:data-mapper,代码行数:31,代码来源:ModelTabFolder.java

示例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 ) );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:8,代码来源:InsertAggregationAction.java

示例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;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:11,代码来源:InsertAggregationAction.java

示例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;
}
 
开发者ID:agusevas,项目名称:logan,代码行数:32,代码来源:ExpressionDropListener.java


注:本文中的org.eclipse.jface.viewers.ViewerDropAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。