本文整理汇总了Java中org.eclipse.swt.dnd.DragSourceAdapter类的典型用法代码示例。如果您正苦于以下问题:Java DragSourceAdapter类的具体用法?Java DragSourceAdapter怎么用?Java DragSourceAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DragSourceAdapter类属于org.eclipse.swt.dnd包,在下文中一共展示了DragSourceAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDragSupport
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的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: createXhtmlTree
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的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());
}
});
}
示例3: applyDragFromTableViewer
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的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());
}
});
}
示例4: initDragAndDrop
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的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));
}
示例5: getDragSourceAdapter
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
protected DragSourceListener getDragSourceAdapter(
final TableViewer inViewer) {
return new DragSourceAdapter() {
@Override
public void dragSetData(final DragSourceEvent inEvent) {
final IStructuredSelection lSelected = (IStructuredSelection) inViewer
.getSelection();
if (!lSelected.isEmpty()) {
final Object[] lItems = lSelected.toArray();
final UniqueID[] lIDs = new UniqueID[lItems.length];
for (int i = 0; i < lItems.length; i++) {
final ILightWeightItem lItem = (ILightWeightItem) lItems[i];
lIDs[i] = new UniqueID(lItem.getItemType(),
lItem.getID());
}
inEvent.data = lIDs;
}
}
};
}
示例6: addDragSupport
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void addDragSupport() {
ExpressionEditorUtil.INSTANCE.getDragSource(methodList).addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
if (methodList.getItemCount() != 0
&& !StringUtils.startsWith(methodList.getItem(0),Messages.CANNOT_SEARCH_INPUT_STRING)) {
MethodDetails methodDetails = (MethodDetails) methodList.getData(String.valueOf(methodList
.getSelectionIndex()));
event.data = methodDetails.getPlaceHolder();
}else
event.data=StringUtils.EMPTY+"#"+StringUtils.EMPTY;
}
});
}
示例7: addDragSupport
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
public void addDragSupport(final Control widget) {
DragSource dragSource = getDragSource(widget);
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
if (widget instanceof Table) {
event.data = formatDataToTransfer(((Table) widget).getSelection());
}
if (widget instanceof List) {
event.data = formatDataToTransfer(((List) widget).getSelection());
}
}
});
}
示例8: attachDragListener
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void attachDragListener() {
dragSource = new DragSource(table_1, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = formatDataToTransfer(table_1.getSelection());
}
});
}
示例9: createSourceTable
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void createSourceTable(Composite composite_2) {
sourceTable = new Table(composite_2, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
sourceTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
if(sourceTable.getSelection().length==1){
addNewProperty(targetTableViewer, sourceTable.getSelection()[0].getText());
enableControlButtons();
}
}
});
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_table.widthHint = 221;
gd_table.heightHint = 407;
sourceTable.setLayoutData(gd_table);
sourceTable.setHeaderVisible(true);
sourceTable.setLinesVisible(true);
TableColumn sourceTableColumnFieldName = new TableColumn(sourceTable, SWT.LEFT);
if(OSValidator.isMac()){
sourceTableColumnFieldName.setWidth(212);
}else{
sourceTableColumnFieldName.setWidth(202);
}
sourceTableColumnFieldName.setText(Messages.AVAILABLE_FIELDS_HEADER);
getSourceFieldsFromPropagatedSchema(sourceTable);
dragSource = new DragSource(sourceTable, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[] { TextTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = formatDataToTransfer(sourceTable.getSelection());
}
});
}
示例10: addDoubleClickListener
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void addDoubleClickListener(TableViewer availableFieldtableViewer) {
DragSource dragSource = new DragSource(availableFieldsTable, DND.DROP_COPY);
dragSource.setTransfer(new Transfer[] { ObjectTransfer.getInstance() });
dragSource.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) { // Set the data to be the first selected item's text
List<Object> list=new ArrayList<Object>();
for(TableItem tableItem:availableFieldsTable.getSelection()){
list.add(tableItem.getData());
}
event.data=list.toArray(new Object[list.size()]);
}
});
}
示例11: addDragListener
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void addDragListener(Control control) {
LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
DragSourceAdapter dragAdapter = new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent event) {
transfer.setSelection(new StructuredSelection(control));
}
};
DragSource dragSource = new DragSource(control, DND.DROP_MOVE | DND.DROP_COPY);
dragSource.setTransfer(new Transfer[] { transfer });
dragSource.addDragListener(dragAdapter);
}
示例12: setupAsDragSource
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void setupAsDragSource()
{
DragSource source = new DragSource(_table, DND.DROP_MOVE);
source.setTransfer(new Transfer[] {TextTransfer.getInstance()});
source.addDragListener(new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent evt)
{
if (TextTransfer.getInstance().isSupportedType(evt.dataType))
evt.data = "drag";
}
});
}
示例13: setupAsDragSource
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void setupAsDragSource()
{
DragSource source = new DragSource(table, DND.DROP_MOVE);
source.setTransfer(new Transfer[] {TextTransfer.getInstance()});
source.addDragListener(new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent evt)
{
if (TextTransfer.getInstance().isSupportedType(evt.dataType))
evt.data = "drag";
}
});
}
示例14: addIn0InputFields
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void addIn0InputFields(Composite inputComposite2) {
List<FilterProperties> inputIn0PortFieldList = null;
if (lookupMappingGrid != null) {
if (lookupMappingGrid.getLookupInputProperties() != null
&& !lookupMappingGrid.getLookupInputProperties()
.isEmpty()) {
inputIn0PortFieldList = lookupMappingGrid
.getLookupInputProperties().get(0);
} else {
inputIn0PortFieldList = new ArrayList<>();
}
}
if (inputPorts != null) {
inputPorts.add(inputIn0PortFieldList);
if (inputIn0PortFieldList != null) {
for (FilterProperties inputField : inputIn0PortFieldList) {
allInputFields.add(IN0_PREFIX + inputField.getPropertyname());
}
}
}
TableViewer in0TableViewer = new TableViewer(inputComposite2, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
in0Table = in0TableViewer.getTable();
in0Table.setLinesVisible(true);
in0Table.setHeaderVisible(true);
in0Table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
in0TableViewer.setContentProvider(new ArrayContentProvider());
TableViewerColumn in0TableViewerColumn = new TableViewerColumn(
in0TableViewer, SWT.NONE);
TableColumn in0TblclmnInputFields = in0TableViewerColumn.getColumn();
in0TblclmnInputFields.setWidth(230);
in0TblclmnInputFields.setText(IN0_HEADER);
in0TableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
FilterProperties tableField = (FilterProperties) element;
return tableField.getPropertyname();
}
});
in0TableViewer.setInput(inputIn0PortFieldList);
Transfer[] in0Types = new Transfer[] { TextTransfer.getInstance() };
final String in0PortLabel = IN0_PREFIX;
int in0Operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
// final Table table = (Table) sourceControl;
DragSource in0Source = new DragSource(in0Table, in0Operations);
in0Source.setTransfer(in0Types);
in0Source.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = addDelimeter(in0PortLabel, in0Table.getSelection());
}
});
}
示例15: addIn1InputFields
import org.eclipse.swt.dnd.DragSourceAdapter; //导入依赖的package包/类
private void addIn1InputFields(Composite inputComposite2) {
List<FilterProperties> inputIn1PortFieldList = null;
if (lookupMappingGrid != null) {
if (lookupMappingGrid.getLookupInputProperties() != null
&& !lookupMappingGrid.getLookupInputProperties()
.isEmpty()) {
inputIn1PortFieldList = lookupMappingGrid
.getLookupInputProperties().get(1);
} else {
inputIn1PortFieldList = new ArrayList<>();
}
}
if (inputPorts != null) {
inputPorts.add(inputIn1PortFieldList);
for (FilterProperties inputField : inputIn1PortFieldList) {
allInputFields.add(IN1_PREFIX
+ inputField.getPropertyname());
}
}
TableViewer in1TableViewer = new TableViewer(inputComposite2, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
in1Table = in1TableViewer.getTable();
in1Table.setHeaderVisible(true);
in1Table.setLinesVisible(true);
in1Table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
in1TableViewer.setContentProvider(new ArrayContentProvider());
TableViewerColumn in1TableViewerColumn = new TableViewerColumn(
in1TableViewer, SWT.NONE);
TableColumn in1TblclmnInputFields = in1TableViewerColumn.getColumn();
in1TblclmnInputFields.setWidth(225);
in1TblclmnInputFields.setText(IN1_HEADER);
in1TableViewerColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
FilterProperties tableField = (FilterProperties) element;
return tableField.getPropertyname();
}
});
in1TableViewer.setInput(inputIn1PortFieldList);
Transfer[] in1Types = new Transfer[] { TextTransfer.getInstance() };
final String in1PortLabel = IN1_PREFIX;
int in1Operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
// final Table table = (Table) sourceControl;
DragSource in1Source = new DragSource(in1Table, in1Operations);
in1Source.setTransfer(in1Types);
in1Source.addDragListener(new DragSourceAdapter() {
public void dragSetData(DragSourceEvent event) {
// Set the data to be the first selected item's text
event.data = addDelimeter(in1PortLabel, in1Table.getSelection());
}
});
}