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


Java DragSourceEvent类代码示例

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

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

示例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;
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:21,代码来源:ItemDragSourceListener.java

示例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;
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:ItemDragSourceListener.java

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

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

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

示例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());
		}
	});

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:17,代码来源:ELTSWTWidgets.java

示例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());
	}
}
 
开发者ID:nresare,项目名称:javapasswordsafe,代码行数:25,代码来源:TreeDragListener.java

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

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

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

示例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;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:17,代码来源:ERDiagramTransferDragSourceListener.java

示例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));
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:17,代码来源:StructureTreeWidget.java

示例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;
	}
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:18,代码来源:ERDiagramTransferDragSourceListener.java


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