本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.rejectDrop方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.rejectDrop方法的具体用法?Java DropTargetDropEvent.rejectDrop怎么用?Java DropTargetDropEvent.rejectDrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DropTargetDropEvent
的用法示例。
在下文中一共展示了DropTargetDropEvent.rejectDrop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e)
{
if (dragSource != null)
{
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null,
dragSource.cell, JTableRenderer.this.cell, "sourceRow="
+ sourceRow + ";targetRow=" + targetRow);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
}
else
{
e.rejectDrop();
}
}
示例2: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e) {
if (dragSource != null) {
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null, dragSource.cell, JTableRenderer.this.cell,
"sourceRow=" + sourceRow + ";targetRow=" + targetRow);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
} else {
e.rejectDrop();
}
}
示例3: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
if (checkDropValid()) {
int action = dtde.getDropAction();
ProjectHandler project = ProjectHandler.getInstance();
if (action == DnDConstants.ACTION_MOVE) {
project.removeNodeFromParent(incomingNode);
} else if (action == DnDConstants.ACTION_COPY) {
incomingNode = incomingNode.copy();
}
project.insertNodeInto(incomingNode, targetNode, 0);
expandPath(path);
selectionModel.setSelectionPath(path.pathByAddingChild(incomingNode));
dtde.acceptDrop(action);
} else {
dtde.rejectDrop();
}
finishDnD();
}
示例4: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e)
{
if (dragSource != null)
{
e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
Point p = e.getLocation();
int targetRow = rowAtPoint(p);
Object edge = graph.insertEdge(null, null, null,
dragSource.cell, JTableRenderer.this.cell, "sourceRow="
+ sourceRow + ";targetRow=" + targetRow, null);
graph.setSelectionCell(edge);
// System.out.println("clearing drag source");
dragSource = null;
e.dropComplete(true);
}
else
{
e.rejectDrop();
}
}
示例5: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
} else {
dtde.rejectDrop();
return;
}
Transferable t = dtde.getTransferable();
List<Village> v;
MapPanel.getSingleton().setCurrentCursor(MapPanel.getSingleton().getCurrentCursor());
try {
v = (List<Village>) t.getTransferData(VillageTransferable.villageDataFlavor);
fireVillagesDraggedEvent(v, dtde.getLocation());
} catch (Exception ignored) {
}
}
示例6: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(@Nonnull final DropTargetDropEvent dtde) {
if (this.dragAcceptableType) {
final Point dragPoint = dtde.getLocation();
final TreePath path = getPathForLocation(dragPoint.x, dragPoint.y);
if (path != null) {
final Object dropTargetNode = path.getLastPathComponent();
if (dropTargetNode instanceof NodeFileOrFolder) {
final NodeFileOrFolder node = (NodeFileOrFolder) dropTargetNode;
if (!node.isLeaf()) {
//TODO processing of file drag in tree
System.out.println("Not implemented yet!"); //NOI18N
} else {
dtde.rejectDrop();
}
}
}
repaint();
}
}
示例7: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
setDragState(null, 0, 0);
TabDragInfo dragInfo = getDragInfo(dtde.getTransferable());
if (dragInfo != null) {
if (dragInfo.tab != null && Utils.contains(dropZone, dtde.getLocation()) && isSnapInAllowed(dragInfo.tab)) {
dtde.acceptDrop(dtde.getDropAction());
} else {
dtde.rejectDrop();
}
} else {
dtde.rejectDrop();
}
dtde.dropComplete(true);
}
示例8: getString
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
* Gets the string.
*
* @param event
* the event
* @return the string
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws UnsupportedFlavorException
* the unsupported flavor exception
*/
@SuppressWarnings("unchecked")
static String getString(DropTargetDropEvent event) throws IOException, UnsupportedFlavorException {
String text = null;
DataFlavor fileList = DataFlavor.javaFileListFlavor;
if (event.isDataFlavorSupported(fileList)) {
event.acceptDrop(DnDConstants.ACTION_COPY);
List<File> list = (List<File>) event.getTransferable().getTransferData(fileList);
text = list.get(0).getAbsolutePath();
} else if (event.isDataFlavorSupported(DataFlavor.stringFlavor)) {
event.acceptDrop(DnDConstants.ACTION_COPY);
text = (String) event.getTransferable().getTransferData(DataFlavor.stringFlavor);
if (text.startsWith("file://"))
text = text.substring(7);
text = stripSuffix(stripSuffix(text, "\n"), "\r").replaceAll("%20", " ");
} else {
event.rejectDrop();
return null;
}
event.dropComplete(text != null);
return text;
}
示例9: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
try {
final Transferable transferable = dtde.getTransferable();
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
final List<File> fileList = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
if (fileList.size() > 0) {
final OpenProductAction open = new OpenProductAction();
open.setFiles(fileList.toArray(new File[fileList.size()]));
dtde.dropComplete(Boolean.TRUE.equals(open.execute()));
}
} else {
dtde.rejectDrop();
}
} catch (UnsupportedFlavorException | IOException ignored) {
dtde.rejectDrop();
}
}
示例10: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
//System.out.println("drop(DropTargetDragEvent)");
if (dtde.getSource() != dropTarget) {
dtde.rejectDrop();
panel.setDropLocation(-1, null);
return;
}
Point dropPoint = dtde.getLocation();
int index = list.locationToIndex(dropPoint);
boolean dropped = false;
if (index == -1 || index == draggedIndex) {
//System.out.println("dropped onto self");
dtde.rejectDrop();
panel.setDropLocation(-1, null);
return;
}
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
//System.out.println("accepted: " + draggedIndex + "/" + index);
panel.setDropLocation(-1, null);
panel.moveStep(draggedIndex, index);
dropped = true;
dtde.dropComplete(dropped);
}
示例11: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent event) {
int dropAction = event.getDropAction();
JComponent c = (JComponent) event.getDropTargetContext().getComponent();
DataObjectTransferHandler transferHandler = (DataObjectTransferHandler) c.getTransferHandler();
if (canImport && (transferHandler != null) && actionSupported(dropAction)) {
event.acceptDrop(dropAction);
try {
Transferable transferable = event.getTransferable();
transferHandler.setDropPoint(event.getLocation());
transferHandler.setDropComponent(c);
event.dropComplete(transferHandler.importData(c, transferable));
} catch (RuntimeException e) {
event.dropComplete(false);
}
} else {
event.rejectDrop();
}
}
示例12: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void drop(DropTargetDropEvent dtde) {
if (!dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.rejectDrop();
return;
}
dtde.acceptDrop(dtde.getDropAction());
try {
Transferable transferable = dtde.getTransferable();
List<File> transferData = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
if (transferData != null && transferData.size() > 0) {
dtde.dropComplete(true);
// load first file
mainWindow.openFile(transferData.get(0));
}
} catch (Exception e) {
LOG.error("File drop operation failed", e);
}
}
示例13: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
try {
Transferable tr = dtde.getTransferable();
if (tr.isDataFlavorSupported(DataFlavor.stringFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
String data = (String) tr.getTransferData(DataFlavor.stringFlavor);
// create the new TreeTable containing the selected dragged path
this.addSelectedTestdirectoryToMetaCampaign(data);
dtde.getDropTargetContext().dropComplete(true);
} else {
System.err.println("Rejected");
dtde.rejectDrop();
}
} catch (IOException | UnsupportedFlavorException io) {
logger.error(io);
dtde.rejectDrop();
}
}
示例14: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) {
try {
final Transferable transferable = dropTargetDropEvent.getTransferable();
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dropTargetDropEvent.acceptDrop(DnDConstants.ACTION_COPY);
dropTargetDropEvent.getDropTargetContext().dropComplete(true);
}
else {
dropTargetDropEvent.rejectDrop();
}
}
catch (Exception ex) {
Log.error(ex);
dropTargetDropEvent.rejectDrop();
}
}
示例15: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
try {
Transferable t = dtde.getTransferable();
List<File> files = null;
if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
files = (List<File>) t
.getTransferData(DataFlavor.javaFileListFlavor);
} else if (uriFlavor != null && t.isDataFlavorSupported(uriFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_REFERENCE);
files = textURIListToFileList((String) t
.getTransferData(uriFlavor));
} else
dtde.rejectDrop();
if (files != null && files.size() == 1) {
openFile(files.get(0));
dtde.dropComplete(true);
} else
dtde.dropComplete(false);
} catch (UnsupportedFlavorException ex) {
dtde.rejectDrop();
} catch (IOException e) {
dtde.rejectDrop();
}
}