本文整理汇总了Java中org.eclipse.swt.dnd.DragSourceEvent类的典型用法代码示例。如果您正苦于以下问题:Java DragSourceEvent类的具体用法?Java DragSourceEvent怎么用?Java DragSourceEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DragSourceEvent类属于org.eclipse.swt.dnd包,在下文中一共展示了DragSourceEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDragSupport
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
private void addDragSupport(final List sourcePackageList, final Combo comboJarList) {
DragSource dragSource = ExpressionEditorUtil.INSTANCE.getDragSource(sourcePackageList);
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
event.data = formatDataToTransfer(sourcePackageList.getSelection());
}
private Object formatDataToTransfer(String[] selection) {
StringBuffer buffer = new StringBuffer();
for (String field : selection) {
buffer.append(field + Constants.DOT + Constants.ASTERISK + SWT.SPACE + Constants.DASH + SWT.SPACE
+ comboJarList.getItem(comboJarList.getSelectionIndex())
+ Constants.FIELD_SEPRATOR_FOR_DRAG_DROP);
}
return buffer.toString();
}
});
}
示例2: setItemUriData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
protected static void setItemUriData ( final DragSourceEvent event, final Collection<Item> items )
{
final StringBuilder sb = new StringBuilder ();
int cnt = 0;
for ( final Item item : items )
{
if ( cnt > 0 )
{
sb.append ( "\n" ); //$NON-NLS-1$
}
sb.append ( item.getConnectionString () );
sb.append ( "#" ); //$NON-NLS-1$
sb.append ( item.getId () );
cnt++;
}
event.data = sb.toString ();
}
示例3: dragSetData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的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.swt.dnd.DragSourceEvent; //导入依赖的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: setItemStringData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
protected void setItemStringData ( final DragSourceEvent event, final IStructuredSelection selection )
{
final StringBuilder sb = new StringBuilder ();
int cnt = 0;
for ( final Iterator<?> i = selection.iterator (); i.hasNext (); )
{
final ListEntry entry = (ListEntry)i.next ();
if ( cnt > 0 )
{
sb.append ( "\n" ); //$NON-NLS-1$
}
sb.append ( entry.getDataItem ().getItem ().getId () );
cnt++;
}
event.data = sb.toString ();
}
示例6: createXhtmlTree
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的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());
}
});
}
示例7: dragSetData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
@Override
public void dragSetData(DragSourceEvent event) {
ProjectExplorerView explorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
if (explorerView != null) {
try {
String sXml = ClipboardAction.dnd.copy(explorerView);
if (sXml != null) {
event.data = sXml;
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Cannot drag");
} catch (ParserConfigurationException ee) {
ConvertigoPlugin.logException(ee, "Cannot drag");
}
}
}
示例8: applyDragFromTableViewer
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的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());
}
});
}
示例9: dragSetData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
public void dragSetData(final DragSourceEvent event) {
final IStructuredSelection selection = (IStructuredSelection) viewer
.getSelection();
if (selection.getFirstElement() instanceof PwsEntryBean) {
final PwsEntryBean firstElement = (PwsEntryBean) selection.getFirstElement();
if (PwsEntryBeanTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = firstElement.getStoreIndex();
}
} else if (selection.getFirstElement() instanceof PasswordTreeContentProvider.TreeGroup) {
event.doit = false; // disable for now
final PasswordTreeContentProvider.TreeGroup group =
(PasswordTreeContentProvider.TreeGroup) selection.getFirstElement();
if (PwsEntryBeanTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = group.getGroupPath();
}
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
event.data = group.getGroupPath();
}
} else {
log.warn("Unknown type: " + selection.getFirstElement().getClass());
}
}
示例10: dragStart
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
/**
* Validate the drag start. Dragging is denied if:
*
* - outline is not uptodate
* - source is preamble
*
* @param event the drag event
* @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
*/
public void dragStart(DragSourceEvent event) {
event.doit = false;
// deny if outline is dirty
if (this.outline.isModelDirty()) {
return;
}
// get the selected node
OutlineNode node = this.getSelection();
if (node == null) {
return;
}
// deny dragging of certain elements
if (node.getType() == OutlineNode.TYPE_PREAMBLE) {
return;
}
// proceed
this.dragSource = node;
event.doit = true;
}
示例11: dragSetData
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
/**
* Set the text data into TextTransfer.
*
* @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
*/
public void dragSetData(DragSourceEvent event) {
// check that requested data type is supported
if (!TextTransfer.getInstance().isSupportedType(event.dataType)) {
return;
}
// get the source text
int sourceOffset = this.dragSource.getPosition().getOffset();
int sourceLength = this.dragSource.getPosition().getLength();
Position sourcePosition = dragSource.getPosition();
String sourceText = "";
try {
sourceText = getDocument().get(sourcePosition.getOffset(), sourcePosition.getLength());
} catch (BadLocationException e) {
TexlipsePlugin.log("Could not set drag data.", e);
return;
}
// set the data
event.data = sourceText;
}
示例12: dragFinished
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
/**
* Finish the drag by removing the source text if the operation
* was MOVE.
*
* Trigger updating of TexlipseModel and outline when done.
*
* @param event the dragEvent
* @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
*/
public void dragFinished(DragSourceEvent event) {
// remove MOVE source
if (event.detail == DND.DROP_MOVE) {
int sourceLength = this.dragSource.getPosition().getLength();
try {
getDocument().replace(removeOffset, sourceLength, "");
} catch (BadLocationException e) {
TexlipsePlugin.log("Could not remove drag'n'drop source.", e);
}
}
// trigger parsing
this.outline.getEditor().updateModelNow();
}
示例13: getTargetModel
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
private Object getTargetModel(final DragSourceEvent event) {
final List editParts = dragSourceViewer.getSelectedEditParts();
if (editParts.size() != 1) {
// ドラッグアンドドロップは選択されているオブジェクトが1つのときのみ可能とする
return null;
}
final EditPart editPart = (EditPart) editParts.get(0);
final Object model = editPart.getModel();
if (model instanceof NormalColumn || model instanceof ColumnGroup || model instanceof Word) {
return model;
}
return null;
}
示例14: initDragAndDrop
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的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));
}
示例15: dragStart
import org.eclipse.swt.dnd.DragSourceEvent; //导入依赖的package包/类
@Override
public void dragStart(DragSourceEvent dragsourceevent) {
super.dragStart(dragsourceevent);
Object target = this.getTargetModel(dragsourceevent);
if (target != null
&& target == this.dragSourceViewer.findObjectAt(
new Point(dragsourceevent.x, dragsourceevent.y))
.getModel()) {
TemplateTransfer transfer = (TemplateTransfer) this.getTransfer();
transfer.setObject(this.createTransferData(dragsourceevent));
} else {
dragsourceevent.doit = false;
}
}