本文整理匯總了Java中org.eclipse.jface.util.LocalSelectionTransfer類的典型用法代碼示例。如果您正苦於以下問題:Java LocalSelectionTransfer類的具體用法?Java LocalSelectionTransfer怎麽用?Java LocalSelectionTransfer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LocalSelectionTransfer類屬於org.eclipse.jface.util包,在下文中一共展示了LocalSelectionTransfer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createContextMenuFor ( StructuredViewer viewer )
{
MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
contextMenu.setRemoveAllWhenShown ( true );
contextMenu.addMenuListener ( this );
Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
viewer.getControl ().setMenu ( menu );
getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
示例2: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well
* registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
protected void createContextMenuFor ( final StructuredViewer viewer )
{
final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
contextMenu.setRemoveAllWhenShown ( true );
contextMenu.addMenuListener ( this );
final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
viewer.getControl ().setMenu ( menu );
getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );
final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
final Transfer[] transfers = new Transfer[] {
LocalTransfer.getInstance (),
LocalSelectionTransfer.getTransfer (),
FileTransfer.getInstance (),
ItemTransfer.getInstance ()
};
viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
示例3: dragSetData
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
@Override
public void dragSetData ( final DragSourceEvent event )
{
try
{
if ( ItemTransfer.getInstance ().isSupportedType ( event.dataType ) )
{
final IStructuredSelection selection = (IStructuredSelection)LocalSelectionTransfer.getTransfer ().getSelection ();
final Collection<Item> items = ItemSelectionHelper.getSelection ( selection );
event.data = items.toArray ( new Item[items.size ()] );
event.doit = true;
}
}
catch ( final Exception e )
{
logger.warn ( "Failed to set drag data", e );
event.doit = false;
}
}
示例4: dragStart
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
@Override
public void dragStart ( final DragSourceEvent event )
{
event.doit = false;
if ( ! ( this.viewer.getSelection () instanceof IStructuredSelection ) )
{
return;
}
final Collection<Item> items = ItemSelectionHelper.getSelection ( this.viewer.getSelection () );
if ( !items.isEmpty () )
{
LocalSelectionTransfer.getTransfer ().setSelection ( this.viewer.getSelection () );
event.doit = true;
}
}
示例5: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createContextMenuFor ( StructuredViewer viewer )
{
MenuManager contextMenu = new MenuManager ( "#PopUp" );
contextMenu.add ( new Separator ( "additions" ) );
contextMenu.setRemoveAllWhenShown ( true );
contextMenu.addMenuListener ( this );
Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
viewer.getControl ().setMenu ( menu );
getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance () };
viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( editingDomain, viewer ) );
}
示例6: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well
* registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated NOT
*/
protected void createContextMenuFor ( final StructuredViewer viewer )
{
final MenuManager contextMenu = new MenuManager ( "#PopUp" ); //$NON-NLS-1$
contextMenu.add ( new Separator ( "additions" ) ); //$NON-NLS-1$
contextMenu.setRemoveAllWhenShown ( true );
contextMenu.addMenuListener ( this );
final Menu menu = contextMenu.createContextMenu ( viewer.getControl () );
viewer.getControl ().setMenu ( menu );
getSite ().registerContextMenu ( contextMenu, new UnwrappingSelectionProvider ( viewer ) );
final int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
final Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance (), LocalSelectionTransfer.getTransfer (), FileTransfer.getInstance (), ItemTransfer.getInstance () };
viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
viewer.addDropSupport ( dndOperations, transfers, new DropAdapterExtension ( this.editingDomain, viewer ) );
}
示例7: drop
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的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);
}
}
}
示例8: configureDragAndDrop
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
protected void configureDragAndDrop(DragAndDropConfiguration dragAndDropConfiguration, TreeViewer treeViewer) {
// drop
Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
int operations = dragAndDropConfiguration.getSupportedDropOperations(this);
DropTarget target = new DropTarget(treeViewer.getControl(), operations);
target.setTransfer(transferTypes);
// Drop listeners pour le drop des elements sur l'arbre
SchemaViewerDropPolicy dropPolicy = dragAndDropConfiguration.getDropPolicy(this);
DnDTargetListener targetListener = new DnDTargetListener(this, nodeConverter, dropPolicy);
target.addDropListener(targetListener);
// Drag listener pour le drag des elements de l'arbre
DragSourceListener sourceListener = new DnDSourceListener(this);
operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT;
transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer() };
treeViewer.addDragSupport(operations, transferTypes, sourceListener);
}
示例9: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected void createContextMenuFor(StructuredViewer viewer) {
MenuManager contextMenu = new MenuManager("#PopUp");
contextMenu.add(new Separator("additions"));
contextMenu.setRemoveAllWhenShown(true);
contextMenu.addMenuListener(this);
Menu menu = contextMenu.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(),
FileTransfer.getInstance()};
viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
示例10: initDragAndDrop
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
void initDragAndDrop() {
int operations = DND.DROP_MOVE;
Transfer[] transferTypes = new Transfer[]{ LocalSelectionTransfer.getTransfer() };
treeViewer.addDragSupport(operations, transferTypes, new DragSourceAdapter() {
@Override public void dragStart(DragSourceEvent event) {
LocalSelectionTransfer.getTransfer().setSelection(treeViewer.getSelection()); // not really needed since we can get selection from member variable
}
// @Override public void dragSetData(DragSourceEvent event) {
// }
// @Override public void dragFinished(DragSourceEvent event) {
// }
});
treeViewer.addDropSupport(operations, transferTypes, new StructureTreeDropAdapter(treeViewer));
}
示例11: getStructuredSelection
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
private IStructuredSelection getStructuredSelection(Object data, TransferData currentDataType) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(currentDataType)) {
return (IStructuredSelection) data;
}
if (URLTransfer.getInstance().isSupportedType(currentDataType)) {
try {
return new StructuredSelection(new URL((String) data));
} catch (MalformedURLException e) {
// ignore
}
}
if (FileTransfer.getInstance().isSupportedType(currentDataType)) {
return new StructuredSelection(Arrays.stream((String[]) data).map(Path::new).collect(Collectors.toList()));
}
return new StructuredSelection();
}
示例12: getDropItems
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的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;
}
示例13: validateDrop
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
@Override
public boolean validateDrop(Object target, int operation, TransferData type) {
overrideOperation(DND.DROP_COPY);
// if (application == null)
// return false;
if (operation == DND.DROP_COPY || operation == DND.DROP_DEFAULT) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(type)) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer()
.getSelection();
Object[] objects = selection.toArray();
for (Object obj : objects) {
if (obj instanceof CFServiceInstance) {
return true;
}
}
}
}
return false;
}
示例14: createContextMenuFor
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
/**
* This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void createContextMenuFor(StructuredViewer viewer)
{
MenuManager contextMenu = new MenuManager("#PopUp");
contextMenu.add(new Separator("additions"));
contextMenu.setRemoveAllWhenShown(true);
contextMenu.addMenuListener(this);
Menu menu= contextMenu.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() };
viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
}
示例15: validateDrop
import org.eclipse.jface.util.LocalSelectionTransfer; //導入依賴的package包/類
@Override
public boolean validateDrop(Object target, int operation, TransferData type) {
overrideOperation(DND.DROP_COPY);
// if (application == null)
// return false;
if (operation == DND.DROP_COPY || operation == DND.DROP_DEFAULT) {
if (LocalSelectionTransfer.getTransfer().isSupportedType(type)) {
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer()
.getSelection();
Object[] objects = selection.toArray();
for (Object obj : objects) {
if (obj instanceof CloudService) {
return true;
}
}
}
}
return false;
}