void end(EventObject e, boolean clear) {
Point pt = (e instanceof MouseEvent) ? ((MouseEvent)e).getPoint() : ((DropTargetDropEvent)e).getLocation();
started = false;
currentItem = null;
if(dragComponent == null) return;
if ((e instanceof DropTargetDropEvent)
|| ((e instanceof MouseEvent) && !((MouseEvent) e).isShiftDown())) {// #195795: Do not deselect the dropTarget when Shift is pressed
menuEditLayer.layers.remove(dragComponent);
menuEditLayer.dropTargetLayer.clearDropTarget();
}
switch (op) {
case PICK_AND_PLOP_FROM_PALETTE: completePickAndPlopFromPalette(pt, clear); break;
case INTER_MENU_DRAG: completeInterMenuDrag(pt); break ;
case NO_MENUBAR: /* do nothing */ break;
}
menuEditLayer.glassLayer.requestFocusInWindow();
if ((e instanceof DropTargetDropEvent)
|| ((e instanceof MouseEvent) && !((MouseEvent) e).isShiftDown())) {// #195795: Do not deselect the dropTarget when Shift is pressed
payloadComponent = null;
targetComponent = null;
}
menuEditLayer.repaint();
}
java类java.awt.dnd.DropTargetDropEvent的实例源码
DragOperation.java 文件源码
项目:incubator-netbeans
阅读 27
收藏 0
点赞 0
评论 0
QuietEditorPane.java 文件源码
项目:incubator-netbeans
阅读 34
收藏 0
点赞 0
评论 0
@Override
public void drop(DropTargetDropEvent e) {
Collection<? extends ExternalDropHandler> handlers = Lookup.getDefault().lookupAll(ExternalDropHandler.class);
for (ExternalDropHandler handler : handlers) {
if (handler.canDrop(e)) {
e.acceptDrop(DnDConstants.ACTION_COPY);
boolean dropped = handler.handleDrop(e);
if(!dropped) {
continue; //try next ExternalDropHandler
}
e.dropComplete(true);
isDragging = false;
return;
}
}
orig.drop(e);
isDragging = false;
}
DnDSupport.java 文件源码
项目:incubator-netbeans
阅读 23
收藏 0
点赞 0
评论 0
public void drop(DropTargetDropEvent dtde) {
boolean res = false;
try {
if( isButtonDrag ) {
if( validateDropPosition() ) {
res = handleDrop( dtde.getTransferable() );
}
} else if( isToolbarDrag ) {
res = true;
//taken care of in dragDropEnd()
}
} finally {
dtde.dropComplete(res);
}
resetDropGesture();
}
SubtitleDownloaderUI.java 文件源码
项目:SubtitleDownloader
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void drop(DropTargetDropEvent dtde) {
dtde.acceptDrop(DnDConstants.ACTION_COPY);
try {
Transferable t = dtde.getTransferable();
DataFlavor[] dataFlavors = t.getTransferDataFlavors();
for (DataFlavor df : dataFlavors) {
if (df.isFlavorJavaFileListType()) {
File[] filesArray = (File[]) ((List<File>) t.getTransferData(df)).toArray();
pathNameTextField.setText(getFilesName(filesArray));
}
}
} catch (UnsupportedFlavorException e2) {
} catch (IOException ex) {
Logger.getLogger(SubtitleDownloaderUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
Map.java 文件源码
项目:VASSAL-src
阅读 26
收藏 0
点赞 0
评论 0
public void drop(DropTargetDropEvent dtde) {
if (dtde.getDropTargetContext().getComponent() == theMap) {
final MouseEvent evt = new MouseEvent(
theMap,
MouseEvent.MOUSE_RELEASED,
System.currentTimeMillis(),
0,
dtde.getLocation().x,
dtde.getLocation().y,
1,
false
);
theMap.dispatchEvent(evt);
dtde.dropComplete(true);
}
if (scroller.isRunning()) scroller.stop();
}
UploadAction.java 文件源码
项目:Equella
阅读 22
收藏 0
点赞 0
评论 0
@Override
public boolean handleDrop(DropTargetDropEvent e) throws Exception
{
List<File> files = DnDUtils.getDroppedNativeFiles(e.getTransferable());
try
{
FileInfo dir = fileList.getFileUnderMouseCursor();
if( dir == null || !dir.isDirectory() )
{
dir = fileList.getCurrentDirectory();
}
uploadFiles(dir, files.toArray(new File[files.size()]));
return true;
}
catch( Exception ex )
{
ex.printStackTrace();
return false;
}
}
mxGraphHandler.java 文件源码
项目:TrabalhoFinalEDA2
阅读 23
收藏 0
点赞 0
评论 0
/**
*
* @param e
*/
public void drop(DropTargetDropEvent e)
{
if (canImport)
{
mxGraphTransferHandler handler = getGraphTransferHandler(e);
MouseEvent event = createEvent(e);
// Ignores the event in mouseReleased if it is
// handled by the transfer handler as a drop
if (handler != null && !handler.isLocalDrag())
{
event.consume();
}
mouseReleased(event);
}
}
JTableRenderer.java 文件源码
项目:Tarski
阅读 24
收藏 0
点赞 0
评论 0
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();
}
}
JTableRenderer.java 文件源码
项目:Tarski
阅读 25
收藏 0
点赞 0
评论 0
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();
}
}
DraggableTree.java 文件源码
项目:KATscans
阅读 19
收藏 0
点赞 0
评论 0
@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();
}
JTableRenderer.java 文件源码
项目:OWLAx
阅读 27
收藏 0
点赞 0
评论 0
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();
}
}
mxGraphHandler.java 文件源码
项目:OWLAx
阅读 21
收藏 0
点赞 0
评论 0
/**
*
* @param e
*/
public void drop(DropTargetDropEvent e)
{
if (canImport)
{
mxGraphTransferHandler handler = getGraphTransferHandler(e);
MouseEvent event = createEvent(e);
// Ignores the event in mouseReleased if it is
// handled by the transfer handler as a drop
if (handler != null && !handler.isLocalDrag())
{
event.consume();
}
mouseReleased(event);
}
}
AdvancedFileChooser.java 文件源码
项目:SporeModder
阅读 20
收藏 0
点赞 0
评论 0
@Override
public synchronized void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY);
try {
@SuppressWarnings("unchecked")
List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
int count = droppedFiles.size();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < droppedFiles.size(); i++) {
sb.append(droppedFiles.get(i));
if (i != count-1) {
sb.append("|");
}
}
target.setText(sb.toString());
} catch (UnsupportedFlavorException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
DropTargetTextField.java 文件源码
项目:SporeModder
阅读 19
收藏 0
点赞 0
评论 0
public synchronized void drop(DropTargetDropEvent event) {
event.acceptDrop(DnDConstants.ACTION_COPY);
try {
@SuppressWarnings("unchecked")
List<File> droppedFiles = (List<File>) event.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
int count = droppedFiles.size();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < droppedFiles.size(); i++) {
sb.append(droppedFiles.get(i));
if (i != count-1) {
sb.append("|");
}
}
target.setText(sb.toString());
} catch (UnsupportedFlavorException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
RecentFilesController.java 文件源码
项目:bigtable-sql
阅读 24
收藏 0
点赞 0
评论 0
private void initDnD()
{
TreeDnDHandlerCallback treeDnDHandlerCallback = new TreeDnDHandlerCallback()
{
@Override
public boolean nodeAcceptsKids(DefaultMutableTreeNode selNode)
{
return onNodeAcceptsKids(selNode);
}
@Override
public void dndExecuted()
{
onDndExecuted();
}
@Override
public ArrayList<DefaultMutableTreeNode> createPasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
{
return onCreatePasteTreeNodesFromExternalTransfer(dtde, targetPath);
}
};
new TreeDnDHandler(_dialog.treFiles, treeDnDHandlerCallback, true);
}
RecentFilesController.java 文件源码
项目:bigtable-sql
阅读 23
收藏 0
点赞 0
评论 0
private ArrayList<DefaultMutableTreeNode> onCreatePasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
{
List<File> files = DropedFileExtractor.getFiles(dtde, _app);
ArrayList<DefaultMutableTreeNode> ret = new ArrayList<DefaultMutableTreeNode>();
DefaultMutableTreeNode parent = findParent(targetPath);
for (File file : files)
{
if (false == parentContainsFile(parent, file))
{
ret.add(new DefaultMutableTreeNode(file));
}
}
return ret;
}
FileEditorDropTargetListener.java 文件源码
项目:bigtable-sql
阅读 20
收藏 0
点赞 0
评论 0
/**
* @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
*/
public void drop(DropTargetDropEvent dtde) {
try {
File fileToOpen = DropedFileExtractor.getFile(dtde, _session.getApplication());
if (fileToOpen != null) {
if (s_log.isInfoEnabled()) {
s_log.info("drop: path="+fileToOpen.getAbsolutePath());
}
ISQLPanelAPI api =
_session.getSQLPanelAPIOfActiveSessionWindow();
api.fileOpen(fileToOpen);
}
} catch (Exception e) {
s_log.error("drop: Unexpected exception "+e.getMessage(),e);
}
}
JTreeAliasesListImpl.java 文件源码
项目:bigtable-sql
阅读 19
收藏 0
点赞 0
评论 0
private void initDnD()
{
TreeDnDHandlerCallback treeDnDHandlerCallback = new TreeDnDHandlerCallback()
{
@Override
public boolean nodeAcceptsKids(DefaultMutableTreeNode selNode)
{
return onNodeAcceptsKids(selNode);
}
@Override
public void dndExecuted() {}
@Override
public ArrayList<DefaultMutableTreeNode> createPasteTreeNodesFromExternalTransfer(DropTargetDropEvent dtde, TreePath targetPath)
{
return null;
}
};
_treeDnDHandler = new TreeDnDHandler(_tree, treeDnDHandlerCallback);
}
TextArea.java 文件源码
项目:CentipeTextEditor
阅读 24
收藏 0
点赞 0
评论 0
public synchronized void drop(DropTargetDropEvent evt) {
try {
evt.acceptDrop(DnDConstants.ACTION_COPY);
@SuppressWarnings("unchecked")
List<File> droppedFiles = (List<File>)
evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
for (File file : droppedFiles) {
textWindow.getDocumentManager().startOpenFile( file.getAbsolutePath() );
}
} catch (Exception ex) {
AlertDialog.showErrorDialog( textWindow.getFrame(), "File naming error!", AlertDialog.ERROR );
//e.printStackTrace();
}
}
AbstractDSWorkbenchFrame.java 文件源码
项目:dsworkbench
阅读 24
收藏 0
点赞 0
评论 0
@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) {
}
}
DnDUtils.java 文件源码
项目:netbeans-mmd-plugin
阅读 20
收藏 0
点赞 0
评论 0
@Nullable
public static String extractDropLink(@Nonnull final DropTargetDropEvent dtde) throws Exception {
String foundHtmlLink = null;
String foundMozLink = null;
for (final DataFlavor df : dtde.getCurrentDataFlavors()) {
if (df.getRepresentationClass() == String.class) {
if (foundHtmlLink == null && df.isMimeTypeEqual(MIME_TEXT_HTML)) {
final String link = extractHtmlLink(true, (String) dtde.getTransferable().getTransferData(df));
if (link != null) {
foundHtmlLink = link;
}
}
} else if (df.getRepresentationClass() == InputStream.class && df.isMimeTypeEqual(MIME_MOZ_URL)) {
if (foundMozLink == null) {
final InputStream in = ((InputStream) dtde.getTransferable().getTransferData(df));
final StringWriter string = new StringWriter();
IOUtils.copy(in, string);
IOUtils.closeQuietly(in);
foundMozLink = removeZeroChars(string.toString().split("\\n")[0]).trim();
}
}
}
return foundMozLink == null ? foundHtmlLink : foundMozLink;
}
DnDTree.java 文件源码
项目:netbeans-mmd-plugin
阅读 21
收藏 0
点赞 0
评论 0
@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();
}
}
MMDEditor.java 文件源码
项目:netbeans-mmd-plugin
阅读 21
收藏 0
点赞 0
评论 0
@Nullable
private File extractDropFile(@Nonnull final DropTargetDropEvent dtde) throws Exception {
File result = null;
for (final DataFlavor df : dtde.getCurrentDataFlavors()) {
final Class<?> representation = df.getRepresentationClass();
if (FileTransferable.class.isAssignableFrom(representation)) {
final FileTransferable t = (FileTransferable) dtde.getTransferable();
final List<File> listOfFiles = t.getFiles();
result = listOfFiles.isEmpty() ? null : listOfFiles.get(0);
break;
} else if (df.isFlavorJavaFileListType()) {
try {
final List list = (List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
if (list != null && !list.isEmpty()) {
result = (File) list.get(0);
}
break;
}
catch (final Exception ex) {
LOGGER.error("Can't extract file from DnD", ex); //NOI18N
}
}
}
return result;
}
JTableRenderer.java 文件源码
项目:BioPano
阅读 22
收藏 0
点赞 0
评论 0
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();
}
}
MainFrameDropTargetListener.java 文件源码
项目:ORS
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void drop(DropTargetDropEvent arg0) {
Transferable tr = arg0.getTransferable();
arg0.acceptDrop(DnDConstants.ACTION_REFERENCE);
if(arg0.isDataFlavorSupported(DataFlavor.javaFileListFlavor)){
try {
@SuppressWarnings("unchecked")
List<File> fileList = (List<File>)tr.getTransferData(DataFlavor.javaFileListFlavor);
for(File file: fileList){
AttackResultFrame resultFrame = new AttackResultFrame();
if (resultFrame.loadResult(file) == true){
resultFrame.setVisible(true);
resultFrame.invalidate();
}else{
resultFrame = null;
}
}
} catch (UnsupportedFlavorException | IOException e) {
logger.debug(e);
}
}
}
ThingsClient.java 文件源码
项目:thingweb-gui
阅读 22
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
protected void doDragAndDropFile(final JButton button) {
button.setDropTarget(new DropTarget() {
private static final long serialVersionUID = 1L;
public synchronized void drop(DropTargetDropEvent evt) {
try {
evt.acceptDrop(DnDConstants.ACTION_COPY);
List<File> droppedFiles = (List<File>) evt.getTransferable()
.getTransferData(DataFlavor.javaFileListFlavor);
for (File f : droppedFiles) {
// process file(s)
addThingPanelFile(f.getAbsolutePath());
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null,
"Errors while creating panels for dropped files: " + ex.getMessage(), "Drop Error",
JOptionPane.ERROR_MESSAGE);
}
}
});
}
JhromeTabbedPaneUI.java 文件源码
项目:Desktop
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
Map.java 文件源码
项目:vassal
阅读 39
收藏 0
点赞 0
评论 0
public void drop(DropTargetDropEvent dtde) {
if (dtde.getDropTargetContext().getComponent() == theMap) {
final MouseEvent evt = new MouseEvent(
theMap,
MouseEvent.MOUSE_RELEASED,
System.currentTimeMillis(),
0,
dtde.getLocation().x,
dtde.getLocation().y,
1,
false
);
theMap.dispatchEvent(evt);
dtde.dropComplete(true);
}
if (scroller.isRunning()) scroller.stop();
}
GenericDialogPlus.java 文件源码
项目:ij-ridgedetection
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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;
}
SessionPanel.java 文件源码
项目:arget
阅读 17
收藏 0
点赞 0
评论 0
@Override
public synchronized void drop (DropTargetDropEvent evt) {
try {
evt.acceptDrop(DnDConstants.ACTION_COPY);
// nothing we can do about it, casting to generic list will be unsafe
@SuppressWarnings("unchecked")
List<File> droppedFiles = (List<File>)evt.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
if (droppedFiles.size() > 1) return;
File file = droppedFiles.get(0);
listener.sendFile(instance, file);
} catch (IOException | UnsupportedFlavorException e) {
Log.exception(e);
}
}