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


Java DropTargetEvent類代碼示例

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


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

示例1: attachDropListener

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

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

示例2: getDragSource

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
protected Collection<?> getDragSource ( final DropTargetEvent event )
{
    final ItemTransfer itemTransfer = ItemTransfer.getInstance ();
    if ( itemTransfer.isSupportedType ( event.currentDataType ) )
    {
        if ( IS_MOTIF )
        {
            return null;
        }

        final Object object = itemTransfer.nativeToJava ( event.currentDataType );
        return object == null ? null : extractDragSource ( object );
    }
    else
    {
        return super.getDragSource ( event );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:DropAdapterExtension.java

示例3: getDragSource

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
protected Collection<?> getDragSource ( final DropTargetEvent event )
{
    // Check whether the current data type can be transfered locally.
    //
    final ItemTransfer itemTransfer = ItemTransfer.getInstance ();
    if ( itemTransfer.isSupportedType ( event.currentDataType ) )
    {
        // Motif kludge: we would get something random instead of null.
        //
        if ( IS_MOTIF )
        {
            return null;
        }

        // Transfer the data and, if non-null, extract it.
        //
        final Object object = itemTransfer.nativeToJava ( event.currentDataType );
        return object == null ? null : extractDragSource ( object );
    }
    else
    {
        return super.getDragSource ( event );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:26,代碼來源:DropAdapterExtension.java

示例4: drop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
public void drop(DropTargetEvent event) {
	
	IStructuredSelection structuredSelection = (IStructuredSelection) LocalSelectionTransfer
               .getTransfer().getSelection();
	
	if (structuredSelection.size() == 1) {

		AvroNode sourceNode = (AvroNode) structuredSelection.getFirstElement();
		TreeItem item = (TreeItem) event.item;
		if (item != null) {
			AvroNode targetNode = nodeConverter.convertToAvroNode(item.getData());
			dropPolicy.drop(sourceNode, targetNode, position);
		}
		
	}
	
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:19,代碼來源:DnDTargetListener.java

示例5: testDropOn

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Test
	@Ignore
	public void testDropOn() {
		// Given
		BookmarkFolder bookmarkFolderToMoved = getBookmarkFolder(bookmarkDatabase.getBookmarksTree(), 1, 1, 1);
		IStructuredSelection data = new StructuredSelection(bookmarkFolderToMoved);
		BookmarkFolder currentTarget = getBookmarkFolder(bookmarkDatabase.getBookmarksTree(), 1, 1);
		BookmarksViewerDropListener listener = getBookmarksViewerDropListener(ViewerDropAdapter.LOCATION_ON,
				currentTarget);

		// When
		DropTargetEvent dropTargetEvent = mock(DropTargetEvent.class);
		listener.dragEnter(dropTargetEvent);
		listener.dragOver(dropTargetEvent);
		listener.dropAccept(dropTargetEvent);
		listener.drop(dropTargetEvent);
//		assertTrue(listener.validateDrop(currentTarget, ViewerDropAdapter.LOCATION_ON, /* transferType */ null));
//		boolean result = listener.performDrop(data);

		// Then
//		assertTrue(result);
		assertEquals(1, bookmarksListener.getModifications().size());
		assertIsBookmarksMovedModification(bookmarksListener.getModifications().get(0), currentTarget.getId(),
				Lists.newArrayList(bookmarkFolderToMoved.getId()));
	}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:26,代碼來源:BookmarksViewerDropListenerTest.java

示例6: drop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
public void drop(DropTargetEvent event) {
	int location = this.determineLocation(event);
	
	source = getSelectedObject();
	target = determineTarget(event);
	
	String translatedLocation = "";
	switch (location) {
	case ViewerDropAdapter.LOCATION_BEFORE:
		translatedLocation = "Dropped before the target ";
		break;
	case ViewerDropAdapter.LOCATION_AFTER:
		translatedLocation = "Dropped after the target ";
		break;
	case ViewerDropAdapter.LOCATION_ON:
		translatedLocation = "Dropped on the target ";
		break;
	case ViewerDropAdapter.LOCATION_NONE:
		translatedLocation = "Dropped into nothing ";
		break;
	}
	System.out.println(translatedLocation);
	System.out.println("The drop was done on the element: " + target);
	super.drop(event);
}
 
開發者ID:aroog,項目名稱:code,代碼行數:27,代碼來源:ObjectTreeViewDropListener.java

示例7: getDropItems

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
/**
 * get the outline items being dropped, or null if there are none or if the event does not
 * qualify for a drop.
 */
@SuppressWarnings("unchecked")
private List<PagePart> getDropItems(DropTargetEvent event) {
	if (event.operations == DND.DROP_NONE || event.item == null) {
		return null;
	}
	Object targetData = event.item.getData();
	if (!(targetData instanceof PagePart)) {
		return null;
	}

	ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
	if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		List<?> list = structuredSelection.toList();
		if (!list.isEmpty()) {
			for (Object i : list) {
				if (!(i instanceof PagePart)) return null;
			}
			return (List<PagePart>) list;
		}
	}
	return null;
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:28,代碼來源:OutlineDropTargetListener.java

示例8: drop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
/**
 * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
 */
@Override
public void drop(DropTargetEvent event) {
	Object data = event.data;
	if (data instanceof String[]) {
		final String[] strings = (String[]) data;
		BusyIndicator.showWhile(null, new Runnable() {
			@Override
			public void run() {
				for (int i = 0; i < strings.length; i++) {
					processString(strings[i]);
				}
			}
		});
	}
}
 
開發者ID:angelozerr,項目名稱:jsbuild-eclipse,代碼行數:19,代碼來源:JSBuildFileViewDropAdapter.java

示例9: handleDrop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
/**
 * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter,
 *      org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
 */
@Override
public IStatus handleDrop(CommonDropAdapter dropAdapter, DropTargetEvent event, Object target) {

    switch (event.detail) {
        case DND.DROP_DEFAULT:
        case DND.DROP_MOVE:
            return handleDropMove(target, event);
        case DND.DROP_COPY:
            return handleDropCopy(target, event);
        default:
            break;
    }

    return Status.CANCEL_STATUS;
}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:20,代碼來源:ExplorerDropAdapterAssistant.java

示例10: dropCommandForNode

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
/**
 * @see nexcore.tool.uml.ui.core.diagram.editor.DiagramDropTargetListener#dropCommandForNode(org.eclipse.swt.dnd.DropTargetEvent,
 *      org.eclipse.gef.commands.CompoundCommand,
 *      nexcore.tool.uml.ui.core.project.ITreeNode, int)
 */
@Override
protected void dropCommandForNode(DropTargetEvent event, CompoundCommand commpoundCommand, ITreeNode next, int count) {

    Element treeElement = (Element) next.getEObject();
    int horizontalScrollPoint = 0;
    int verticalScrollPoint = 0;
    Point eventPoint = null;
    Command command = null;
    org.eclipse.draw2d.geometry.Point where = null;

    horizontalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getHorizontalBar()
        .getSelection();
    verticalScrollPoint = ((FigureCanvas) diagramEditor.getDiagramGraphicalViewer().getControl()).getVerticalBar()
        .getSelection();
    eventPoint = diagramEditor.getDiagramGraphicalViewer().getControl().toControl(event.x + horizontalScrollPoint,
        event.y + verticalScrollPoint);

    // y좌표에 +100은 여러개를 Dorp했을때 대각선 아래로 위치하도록 한다.
    where = new org.eclipse.draw2d.geometry.Point(eventPoint.x + (count * 160), eventPoint.y);//20);
    command = new DropLifeLineNotationCommand(UMLMessage.LABEL_ADD_DROP, diagramEditor, treeElement, where);
    ((DropLifeLineNotationCommand) command).setDiagram(this.diagramEditor.getDiagram());
    commpoundCommand.add(command);

}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:30,代碼來源:SequenceDiagramDropTargetListener.java

示例11: dropTargetIsValid

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
private boolean dropTargetIsValid(DropTargetEvent e, boolean isDrop) {
	if (URLTransfer.getInstance().isSupportedType(e.currentDataType)) {
		// on Windows, we get the URL already during drag operations...
		// FIXME find a way to check the URL early on other platforms,
		// too...
		if (isDrop || Util.isWindows()) {
			if (e.data == null && !extractEventData(e)) {
				// ... but if we don't, it's no problem, unless this is
				// already
				// the final drop event
				return !isDrop;
			}
			final String url = getUrl(e.data);
			if (!ExampleURLHandler.isValidExample(url)) {
				return false;
			}
		}
		return true;
	}
	return false;
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:22,代碼來源:ExampleDropTargetListener.java

示例12: drop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
public void drop(DropTargetEvent event) {
	if (!URLTransfer.getInstance().isSupportedType(event.currentDataType)) {
		return;
	}
	final String url = getUrl(event.data);

	if (ExampleURLHandler.isValidExample(url)) {
		DropTarget source = (DropTarget) event.getSource();
		Display display = source.getDisplay();
		display.asyncExec(new Runnable() {
			public void run() {
				proceedInstallation(url);
			}
		});
	}
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:18,代碼來源:ExampleDropTargetListener.java

示例13: getSelected

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
private TreeItem getSelected(DropTargetEvent event) {
	try {
		TreeItem selected = (TreeItem)event.item;
		if (! OSTool.isSystemWindows()) {
			// There is a bug in SWT under Linux :
			// If the Tree has been configured to display column headers ("setHeaderVisible(true)"), 
			// the "item" attribute of the DropTargetEvent references the TreeItem UNDER the actually selected item !
			// That's why we must "play" with the item's coordinates :(
			int x = selected.getBounds().x + 2;
			int y = selected.getBounds().y - selected.getBounds().height + 2;

			selected = treFilters.getItem(new Point(x, y));
		}
		return selected;
	} catch (RuntimeException e) {
		return null;
	}
}
 
開發者ID:chfoo,項目名稱:areca-backup-release-mirror,代碼行數:19,代碼來源:TargetEditionWindow.java

示例14: drop

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
public void drop(DropTargetEvent event) {
	if (!transfer.isSupportedType(event.currentDataType)){
		return;
	}
	IProject currProj = getProject();
	if (currProj == null){
		return;
	}
	IResource[] resa = (IResource[])event.data;
	StringBuilder sb = new StringBuilder(256);
	sb.append(_getText());
	int len = sb.length();
	if (len > 0 && sb.charAt(len-1) == '\n') {
		sb.setLength(len-1);
	}
	for (int i = 0; i < resa.length; i++) {
		IResource res = resa[i];
		if (res.getProject().equals(currProj)) {
			sb.append("\n").append(res.getProjectRelativePath());
		}
	}
	_setText(sb.toString());
}
 
開發者ID:BeckYang,項目名稱:TeamFileList,代碼行數:24,代碼來源:TeamFileListView.java

示例15: dragOver

import org.eclipse.swt.dnd.DropTargetEvent; //導入依賴的package包/類
@Override
public void dragOver(DropTargetEvent event)
{
  boolean match = false;
  for (CoreDropTargetListener listener : listeners)
  {
    if(listener.appliesTo(event))
    {
      match = true;
      listener.dragOver(event);
    }
    else
    {
      listener.reset();
    }
  }
  if(!match)
  {
    event.detail = DND.DROP_NONE;
  }

}
 
開發者ID:debrief,項目名稱:limpet,代碼行數:23,代碼來源:ProxyDropTargetListener.java


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