當前位置: 首頁>>代碼示例>>Java>>正文


Java DragSource類代碼示例

本文整理匯總了Java中org.eclipse.swt.dnd.DragSource的典型用法代碼示例。如果您正苦於以下問題:Java DragSource類的具體用法?Java DragSource怎麽用?Java DragSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DragSource類屬於org.eclipse.swt.dnd包,在下文中一共展示了DragSource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addDragSupport

import org.eclipse.swt.dnd.DragSource; //導入依賴的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: createXhtmlTree

import org.eclipse.swt.dnd.DragSource; //導入依賴的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

示例3: applyDragFromTableViewer

import org.eclipse.swt.dnd.DragSource; //導入依賴的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

示例4: getShell

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
 * Returns the shell for the given widget. If the widget doesn't represent a
 * SWT object that manage a shell, <code>null</code> is returned.
 * 
 * @param widget
 *            the widget
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
	if (widget instanceof Control)
		return ((Control) widget).getShell();
	if (widget instanceof Caret)
		return ((Caret) widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource) widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget) widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu) widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar) widget).getParent().getShell();

	return null;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:26,代碼來源:SWTUtil.java

示例5: getDragSelection

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
private List<MDataAdapter> getDragSelection(DragSourceEvent event){
	if(event.getSource() instanceof DragSource){
		List<MDataAdapter> dataAdapters = new ArrayList<MDataAdapter>();
		Control control = ((DragSource)event.getSource()).getControl();
		if(control instanceof Tree && 
				((Tree) control).getSelection().length>0){
			for(TreeItem tItem : ((Tree) control).getSelection()){
				Object data = tItem.getData();
				if(data instanceof MDataAdapter){
					dataAdapters.add((MDataAdapter) data);
				}
			}
			return dataAdapters;				
		}
	}
	return new ArrayList<MDataAdapter>(0);
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:18,代碼來源:DataAdapterDragSourceListener.java

示例6: getShell

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
 * Returns the shell for the given widget. If the widget doesn't represent a SWT object that manage a shell,
 * <code>null</code> is returned.
 * 
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget)
{
	if (widget instanceof Control)
		return ((Control) widget).getShell();
	if (widget instanceof Caret)
		return ((Caret) widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource) widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget) widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu) widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar) widget).getParent().getShell();

	return null;
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:24,代碼來源:SWTUtil.java

示例7: getTransferable

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
@Override
protected ITransferable getTransferable(DragSource source, long time) {
	ISelection selection = viewer.getSelection();
	if (!(selection instanceof StructuredSelection)) {
		return null;
	}

	List<ENumericResourceDef> nrdefs = getNumericResourceDefs(selection);
	
	List<EStateResourceDef> srdefs = getStateResourceDefs(selection);
	if (nrdefs.size() == 0 && srdefs.size() == 0) {
		return null;
	} else
	if (nrdefs.size() != 0 && srdefs.size() != 0) {
		return null;
	}
	
	// one is guranteed to have defs in it
	if (nrdefs.size() > 0) {
		return new NumericResourceDefTransferable(nrdefs);
	} // else...
	return new StateResourceDefTransferable(srdefs);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:24,代碼來源:ResourceTreeDragSourceListener.java

示例8: getShell

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
	if (widget instanceof Control)
		return ((Control)widget).getShell();
	if (widget instanceof Caret)
		return ((Caret)widget).getParent().getShell();
	if (widget instanceof DragSource)
		return ((DragSource)widget).getControl().getShell();
	if (widget instanceof DropTarget)
		return ((DropTarget)widget).getControl().getShell();
	if (widget instanceof Menu)
		return ((Menu)widget).getParent().getShell();
	if (widget instanceof ScrollBar)
		return ((ScrollBar)widget).getParent().getShell();

	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:24,代碼來源:SWTUtil.java

示例9: getShell

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
/**
 * Returns the shell for the given widget. If the widget doesn't represent
 * a SWT object that manage a shell, <code>null</code> is returned.
 * @param widget the widget
 *
 * @return the shell for the given widget
 */
public static Shell getShell(Widget widget) {
    if (widget instanceof Control) {
        return ((Control) widget).getShell();
    }
    if (widget instanceof Caret) {
        return ((Caret) widget).getParent().getShell();
    }
    if (widget instanceof DragSource) {
        return ((DragSource) widget).getControl().getShell();
    }
    if (widget instanceof DropTarget) {
        return ((DropTarget) widget).getControl().getShell();
    }
    if (widget instanceof Menu) {
        return ((Menu) widget).getParent().getShell();
    }
    if (widget instanceof ScrollBar) {
        return ((ScrollBar) widget).getParent().getShell();
    }

    return null;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:30,代碼來源:SWTUtil.java

示例10: setEmbeddedScene

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
@Override
public void setEmbeddedScene(EmbeddedSceneInterface embeddedScene) {
    scenePeer = embeddedScene;
    if (scenePeer == null) {
        return;
    }
    if (pWidth > 0 && pHeight > 0) {
        scenePeer.setSize(pWidth, pHeight);
    }
    double scaleFactor = getScaleFactor();
    resizePixelBuffer(scaleFactor);
    lastScaleFactor = scaleFactor;
    scenePeer.setPixelScaleFactor((float)scaleFactor);
    scenePeer.setDragStartListener((fxDragSource, dragAction) -> {
        Platform.runLater(() -> {
            DragSource dragSource = createDragSource(fxDragSource, dragAction);
            if (dragSource == null) {
                fxDragSource.dragDropEnd(null);
            } else {
                updateDropTarget();
                OldFXCanvas.this.notifyListeners(SWT.DragDetect, null);
            }
        });
    });
    //Force the old drop target to be disposed before creating a new one
    setDropTarget(null);
    setDropTarget(createDropTarget(embeddedScene));
}
 
開發者ID:TRUEJASONFANS,項目名稱:JavaFX-FrameRateMeter,代碼行數:29,代碼來源:OldFXCanvas.java

示例11: addDragSupport

import org.eclipse.swt.dnd.DragSource; //導入依賴的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());
			}
		}
	});
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:14,代碼來源:ExpressionEditorUtil.java

示例12: attachDragListener

import org.eclipse.swt.dnd.DragSource; //導入依賴的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());
		}

	});
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:12,代碼來源:ExcelFormattingDialog.java

示例13: createSourceTable

import org.eclipse.swt.dnd.DragSource; //導入依賴的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());
		}

	});
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:38,代碼來源:SecondaryColumnKeysDialog.java

示例14: addDoubleClickListener

import org.eclipse.swt.dnd.DragSource; //導入依賴的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()]);
		}
	});
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:15,代碼來源:AvailableFieldComposite.java

示例15: configure

import org.eclipse.swt.dnd.DragSource; //導入依賴的package包/類
public void configure(CommandManager commandManager, Control control, ISelectionProvider provider) {

		dragAdapter = new DelegatingDragAdapter();
		dragSource = new DragSource(control, DND.DROP_COPY | DND.DROP_MOVE);
		dragAdapter.addDragSourceListener(new OutlineDragSourceListener(provider));
		dragSource.addDragListener(dragAdapter);
		dragSource.setTransfer(dragAdapter.getTransfers());

		dropAdapter = new DelegatingDropAdapter();
		dropTarget = new DropTarget(control, DND.DROP_COPY | DND.DROP_MOVE);
		dropAdapter.addDropTargetListener(new OutlineDropTargetListener(commandManager));
		dropTarget.addDropListener(dropAdapter);
		dropTarget.setTransfer(dropAdapter.getTransfers());
	}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:15,代碼來源:DndConfigurationStrategy.java


注:本文中的org.eclipse.swt.dnd.DragSource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。