本文整理汇总了Java中java.awt.dnd.DropTargetDropEvent.getDropAction方法的典型用法代码示例。如果您正苦于以下问题:Java DropTargetDropEvent.getDropAction方法的具体用法?Java DropTargetDropEvent.getDropAction怎么用?Java DropTargetDropEvent.getDropAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.dnd.DropTargetDropEvent
的用法示例。
在下文中一共展示了DropTargetDropEvent.getDropAction方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 0) {
// Accept the drop and get the transfer data
dtde.acceptDrop(dtde.getDropAction());
Transferable transferable = dtde.getTransferable();
boolean dropSucceeded = false;
try {
window
.setCursor(Cursor
.getPredefinedCursor(Cursor.WAIT_CURSOR));
dropSucceeded = dropFile(dtde.getDropAction(), transferable,
dtde.getLocation());
} catch (Exception e) {
e.printStackTrace();
} finally {
window.setCursor(Cursor.getDefaultCursor());
dtde.dropComplete(dropSucceeded);
}
} else {
dtde.dropComplete(false);
}
}
示例3: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
gestureStarted = false;
if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
Transferable t = dtde.getTransferable();
try {
DBTableInternalFrame iFrame = (DBTableInternalFrame) t
.getTransferData(InternalFrameTransferable.DATA_FLAVOR);
if (iFrame != DBTableInternalFrame.this) {
JoinLine joinLine = new JoinLine(iFrame, iFrame
.getSelectedRow(), DBTableInternalFrame.this,
columnsListBox.getSelectedIndex());
desktop.addJoinLine(joinLine);
desktop.repaint();
}
} catch (Exception e) {
e.printStackTrace();
}
dtde.dropComplete(true);
}
}
示例4: 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();
}
}
示例5: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public final void drop(DropTargetDropEvent dtde) {
try {
if (drawImage) {
clearImage();
}
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
Point pt = dtde.getLocation();
if (transferable.isDataFlavorSupported(NODE_FLAVOR)
&& controller.canPerformAction(tree, draggedNode, action, pt)) {
TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
Object node = transferable.getTransferData(NODE_FLAVOR);
Object newParentNode = pathTarget.getLastPathComponent();
if (controller.executeDrop(tree, node, newParentNode, action)) {
dtde.acceptDrop(action);
dtde.dropComplete(true);
return;
}
}
dtde.rejectDrop();
dtde.dropComplete(false);
} catch (Exception e) {
dtde.rejectDrop();
dtde.dropComplete(false);
}
}
示例6: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public final void drop(DropTargetDropEvent dtde) {
try {
if (drawImage) {
clearImage();
}
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
Point pt = dtde.getLocation();
if (transferable.isDataFlavorSupported(NODE_FLAVOR)
&& controller.canPerformAction(tree, draggedNode,
action, pt)) {
TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
Object node = transferable.getTransferData(NODE_FLAVOR);
Object newParentNode = pathTarget.getLastPathComponent();
if (controller.executeDrop(tree, node, newParentNode,
action)) {
dtde.acceptDrop(action);
dtde.dropComplete(true);
return;
}
}
dtde.rejectDrop();
dtde.dropComplete(false);
} catch (Exception e) {
dtde.rejectDrop();
dtde.dropComplete(false);
}
}
示例7: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public final void drop(DropTargetDropEvent dtde) {
try {
if (drawImage) {
clearImage();
}
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
Point pt = dtde.getLocation();
if (transferable
.isDataFlavorSupported(NODE_FLAVOR)
&& controller.canPerformAction(tree, draggedNode, action, pt)) {
TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
Object node = transferable.getTransferData(NODE_FLAVOR);
Object newParentNode = pathTarget.getLastPathComponent();
if (controller.executeDrop(tree, node, newParentNode, action)) {
dtde.acceptDrop(action);
dtde.dropComplete(true);
return;
}
}
dtde.rejectDrop();
dtde.dropComplete(false);
} catch (Exception e) {
dtde.rejectDrop();
dtde.dropComplete(false);
}
}
示例8: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void drop(DropTargetDropEvent dtde) {
for (DataFlavor dataFlover : dtde.getCurrentDataFlavors()) {
if (dataFlover.isFlavorJavaFileListType()) {
try {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
List<String> fileNames = new ArrayList<String>();
for (File file : (List<File>)dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor))
if (file.exists())
fileNames.add(file.getCanonicalPath());
else
LOG.warn("Failed to drop from clipboard: '" + file.getAbsolutePath() + "' is not a file.");
if (!fileNames.isEmpty()) {
if (dtde.getDropAction() != DnDConstants.ACTION_COPY)
fileListModel.clear();
addFileNames(fileNames);
}
dtde.getDropTargetContext().dropComplete(true);
} catch (UnsupportedFlavorException e1) {
//
} catch (IOException e2) {
//
}
}
}
}
示例9: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
@Override
public void drop(DropTargetDropEvent dtde) {
if (getComponentCount() == 0) {
dtde.rejectDrop();
return;
}
try {
Transferable tr = dtde.getTransferable();
if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
List<?> fileList = (List<?>) tr.getTransferData(DataFlavor.javaFileListFlavor);
File parent = new File(Assistant.getNodePath((EticetableTreeNode) Client.currentClient.frame.catalog.getSelectionPath().getLastPathComponent()));
new FileMover(Client.currentClient.frame, false, dtde.getDropAction() == DnDConstants.ACTION_COPY, parent, fileList.toArray(new File[] {}));
Client.currentClient.frame.directoryLoader.fireUpdate();
dtde.getDropTargetContext().dropComplete(true);
} else {
CFG.p("Rejected");
dtde.rejectDrop();
}
} catch (IOException io) {
io.printStackTrace();
dtde.rejectDrop();
} catch (UnsupportedFlavorException ufe) {
ufe.printStackTrace();
dtde.rejectDrop();
}
}
示例10: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent e)
{
try {
int dropaction = e.getDropAction(); // 1=copy, 2=move
if ( dropaction == 0 || dropaction > 2)
{
e.rejectDrop();
return;
}
e.acceptDrop(dropaction);
Transferable tr = e.getTransferable();
DataFlavor[] df = tr.getTransferDataFlavors();
List li = (List) tr.getTransferData(df[0]); // see note about mac os x
Object[] val = li.toArray();
if (val.length > 0)
loadCutList(val[0].toString());
e.dropComplete(true);
} catch (Exception eee) {
e.dropComplete(false);
Common.setExceptionMessage(eee);
}
}
示例11: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public final void drop(DropTargetDropEvent dtde) {
try {
if (drawImage) {
clearImage();
}
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
Point pt = dtde.getLocation();
if (transferable.isDataFlavorSupported(TransferableNode.NODE_FLAVOR) && canPerformAction(tree, draggedNode, action, pt)) {
TreePath pathTarget = tree.getPathForLocation(pt.x, pt.y);
DefaultMutableTreeNode node = (DefaultMutableTreeNode) transferable.getTransferData(TransferableNode.NODE_FLAVOR);
DefaultMutableTreeNode newParentNode = (DefaultMutableTreeNode)pathTarget.getLastPathComponent();
if (executeDrop(tree, node, newParentNode, action)) {
dtde.acceptDrop(action);
dtde.dropComplete(true);
return;
}
}
dtde.rejectDrop();
dtde.dropComplete(false);
}
catch (Exception e) {
System.out.println(e);
dtde.rejectDrop();
dtde.dropComplete(false);
}
}
示例12: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde)
{
// currently this method does all the work when a drop is performed
try
{
Transferable data = dtde.getTransferable();
DropTargetContext dtc = dtde.getDropTargetContext();
Component comp = dtc.getComponent();
int action = dtde.getDropAction();
// check dataFlavor
/* if (t.isDataFlavorSupported (DataFlavor.javaFileListFlavor))
{
// Handle Java File List
dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
java.util.List fileList = (java.util.List)
t.getTransferData(DataFlavor.javaFileListFlavor);
Iterator iterator = fileList.iterator();
int len=fileList.size();
VRL sourceLocs[]=new VRL[len];
int index=0;
dtde.getDropTargetContext().dropComplete(true);
if (len<=0)
return;
while (iterator.hasNext())
{
java.io.File file = (File)iterator.next();
Debug("name="+file.getName());
Debug("url="+file.toURL().toString());
Debug("path="+file.getAbsolutePath());
sourceLocs[index++]=new VRL("file",null,file.getAbsolutePath());
}
viewerController.handleDropEvent(comp,sourceLocs[0].toString());
boolean isMove=(action==DnDConstants.ACTION_MOVE);
}
else*/
// String types for now:
if (VTransferData.canConvertToVRLs(data))
{
dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
VRL vrls[]=VTransferData.getVRLsFrom(data);
controller.handleDrop(vrls[0]);
}
else if (data.isDataFlavorSupported (DataFlavor.stringFlavor))
{
dtde.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
String txt= (String)
data.getTransferData(DataFlavor.stringFlavor);
dtde.getDropTargetContext().dropComplete(true);
controller.setContents(txt);
}
}
catch (Exception e)
{
UILogger.logException(this,ClassLogger.ERROR,e,"Exception:%s\n",e);
}
}
示例13: drop
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
public void drop(DropTargetDropEvent dtde) {
if ((dtde.getDropAction() & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE) {
dtde.acceptDrop(DnDConstants.ACTION_MOVE);
Transferable t = dtde.getTransferable();
Point point = dtde.getLocation();
try {
DBProcedure proc = (DBProcedure) t.getTransferData(DBProcTransferable.DATA_FLAVOR);
List<DBProcedureColumn> columns = Globals.getDBViewer().getProcedureColumns(proc.getSchema(), proc.getCatalog(), proc.getName());
if (!Globals.getDBViewer().isValidProcedure(columns)) {
Show.info(I18NSupport.getString("procedure.invalid"));
return;
} else {
StringBuilder sb = new StringBuilder("call ");
boolean order = Globals.getDialect().schemaBeforeCatalog();
if (!order) {
if (proc.getCatalog() != null) {
sb.append(proc.getCatalog()).append(".");
}
}
if (!"%".equals(proc.getSchema())) {
sb.append(proc.getSchema()).append(".");
}
if (order) {
if (proc.getCatalog() != null) {
sb.append(proc.getCatalog()).append(".");
}
}
sb.append(proc.getName());
sb.append("(");
int index = 1;
for (int i = 0, size = columns.size(); i < size; i++) {
DBProcedureColumn col = columns.get(i);
if (ProcUtil.IN.equals(col.getReturnType())) {
sb.append("${P").append(index).append("}");
index++;
if (i < size - 1) {
sb.append(", ");
}
} else if (ProcUtil.OUT.equals(col.getReturnType())) {
if (ProcUtil.REF_CURSOR.equals(col.getDataType())) {
sb.append("?");
if (i < size - 1) {
sb.append(" , ");
}
}
}
}
sb.append(")");
sqlView.setQueryString(sb.toString());
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
e.printStackTrace();
}
dtde.dropComplete(true);
}
}
示例14: setDropData
import java.awt.dnd.DropTargetDropEvent; //导入方法依赖的package包/类
/**
* Called by the DropTargetAdapter in drop
* return true if add action succeeded
* otherwise return false
*/
public boolean setDropData(Object transferredData, DropTargetDropEvent e, DataFlavor chosen)
{
boolean isSuccess = false;
Point p = e.getLocation();
TreePath path = this.getTree().getPathForLocation(p.x, p.y);
if (path == null)
{
Log.logInfo(this, this.getClass() + " path is null. cannot find the exact path. Going to find closest path.");
path = this.getTree().getClosestPathForLocation(p.x, p.y);
if (path == null)
{
Log.logInfo(this, this.getClass() + " path is null. Even cannot find the closest path. setDropData() will reject drop.");
return false;
}
}
DefaultMutableTreeNode targetNode = (DefaultMutableTreeNode) path.getLastPathComponent();
try
{
TransferableNode dragSourceObjectSelection = (TransferableNode) transferredData;
java.util.List dragSourceObjectList = dragSourceObjectSelection.getSelectionList();
if (dragSourceObjectList == null || dragSourceObjectList.size() < 1)
{
return false;
}
TreeModel tempModel = mTree.getModel();
if (!(tempModel instanceof CSVMetadataTreeModel))
{
System.err.println("I am expecting CSVMetadataTreeModel, but I received '" + tempModel == null ? "null" : tempModel.getClass().getName() + "'");
return false;
}
int dropAction = e.getDropAction();
CSVMetadataTreeModel treeModel = (CSVMetadataTreeModel) tempModel;
isSuccess = treeModel.addChildren(targetNode, dragSourceObjectList, dropAction==DnDConstants.ACTION_COPY);
}
catch (Exception exp)
{
Log.logInfo(this, "Exception Caught by '" + this.getClass().getName() + "': " + exp.getClass().getName() + ";" + exp.getMessage());
Log.logException(this, exp);
isSuccess = false;
}
finally
{
return isSuccess;
}
}