本文整理汇总了Java中org.eclipse.swt.dnd.DND类的典型用法代码示例。如果您正苦于以下问题:Java DND类的具体用法?Java DND怎么用?Java DND使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DND类属于org.eclipse.swt.dnd包,在下文中一共展示了DND类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachDropListener
import org.eclipse.swt.dnd.DND; //导入依赖的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: setClipboard
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
/**
* Set the clipboard contents. Prompt to retry if clipboard is busy.
*
* @param resources
* the resources to copy to the clipboard
* @param fileNames
* file names of the resources to copy to the clipboard
* @param names
* string representation of all names
*/
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
try {
// set the clipboard contents
if (fileNames.length > 0) {
clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
} else {
clipboard.setContents(new Object[] { resources, names },
new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
}
} catch (final SWTError e) {
if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
// ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
"Problem with copy.")) { //$NON-NLS-1$
setClipboard(resources, fileNames, names);
}
}
}
示例3: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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 ) );
}
示例4: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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 ) );
}
示例5: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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 -->
*/
protected void createContextMenuFor ( final StructuredViewer viewer )
{
final MenuManager contextMenu = new MenuManager ( "#PopUp" );
contextMenu.add ( new Separator ( "additions" ) );
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 () };
viewer.addDragSupport ( dndOperations, transfers, new ViewerDragAdapter ( viewer ) );
viewer.addDropSupport ( dndOperations, transfers, new EditingDomainViewerDropAdapter ( this.editingDomain, viewer ) );
}
示例6: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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 ) );
}
示例7: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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 ) );
}
示例8: createXhtmlTree
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
private void createXhtmlTree() {
sourcePicker.createXhtmlTree(treesSashForm);
// DND support
int ops = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] {StepSourceTransfer.getInstance()};
DragSource source = new DragSource(sourcePicker.getTwsDomTree().getTree(), ops);
source.setTransfer(transfers);
source.addDragListener(new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
event.doit = true;
StepSourceTransfer.getInstance().setStepSource(sourcePicker.getDragData());
}
});
}
示例9: javaToNative
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
@Override
public void javaToNative (Object object, TransferData transferData) {
if (!checkCustom(object) || !isSupportedType(transferData)) {
DND.error(DND.ERROR_INVALID_DATA);
}
byte [] bytes = null;
if (object instanceof ByteBuffer) {
bytes = ((ByteBuffer)object).array();
} else {
if (object instanceof byte []) {
bytes = (byte []) object;
}
}
if (bytes == null) {
DND.error(DND.ERROR_INVALID_DATA);
}
super.javaToNative(bytes, transferData);
}
示例10: getTransferModes
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
Set<TransferMode> getTransferModes(int bits) {
Set<TransferMode> set = new HashSet<>();
if ((bits & DND.DROP_COPY) != 0) {
set.add(TransferMode.COPY);
}
if ((bits & DND.DROP_MOVE) != 0) {
set.add(TransferMode.MOVE);
}
if ((bits & DND.DROP_TARGET_MOVE) != 0) {
set.add(TransferMode.MOVE);
}
if ((bits & DND.DROP_LINK) != 0) {
set.add(TransferMode.LINK);
}
return set;
}
示例11: applyDragFromTableViewer
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
public void applyDragFromTableViewer(Control sourceControl, int index) {
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
final String portLabel = "in" + index + ".";
int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
final Table table = (Table) sourceControl;
DragSource source = new DragSource(table, operations);
source.setTransfer(types);
final String[] columnData = new String[1];
source.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = addDelimeter(portLabel, table.getSelection());
}
});
}
示例12: dragOver
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
@Override
public int dragOver(AvroNode draggedNode, AvroNode targetNode, TargetPosition position) {
int detail = DND.DROP_NONE;
AvroSchemaController schemaController = context.getService(AvroSchemaController.class);
if (schemaController.canDnDElement(DragAndDropPolicy.Action.MOVE, draggedNode, targetNode, position)) {
detail = DND.DROP_MOVE;
} else if (schemaController.canDnDElement(DragAndDropPolicy.Action.COPY, draggedNode, targetNode, position)) {
detail = DND.DROP_COPY;
} else if (schemaController.canDnDElement(DragAndDropPolicy.Action.REFERENCE, draggedNode, targetNode, position)) {
detail = DND.DROP_MOVE;
}
return detail;
}
示例13: configureDragAndDrop
import org.eclipse.swt.dnd.DND; //导入依赖的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);
}
示例14: createContextMenuFor
import org.eclipse.swt.dnd.DND; //导入依赖的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: addNewNote
import org.eclipse.swt.dnd.DND; //导入依赖的package包/类
/**
* Adds a new note to the notepad.
*/
public void addNewNote() {
String noteText = "";
if (preferences.getBoolean(PreferenceConstants.PREF_PASTE_CLIPBOARD_IN_NEW_NOTES,
PreferenceConstants.PREF_PASTE_CLIPBOARD_IN_NEW_NOTES_DEFAULT)) {
noteText = (String) clipboard.getContents(TextTransfer.getInstance(), DND.CLIPBOARD);
}
String noteTitle = preferences.get(PreferenceConstants.PREF_NAME_PREFIX,
PreferenceConstants.PREF_NAME_PREFIX_DEFAULT) + " " + (tabFolder.getItemCount() + 1);
// Add a new note tab with a number appended to its name (Note 1, Note 2, Note 3, etc.).
addNewNoteTab(noteTitle, noteText, null, true, null);
CTabItem previousSelectedTab = tabFolder.getSelection();
// Remove lock for currently selected tab.
if (previousSelectedTab != null && previousSelectedTab.getText().startsWith(LOCK_PREFIX)) {
previousSelectedTab.setText(previousSelectedTab.getText().substring(LOCK_PREFIX.length()));
}
tabFolder.setSelection(tabFolder.getItemCount() - 1);
}