?? dndtable.java
字號:
/** * File and FTP Explorer * Copyright 2002 * BOESCH Vincent * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */package javaexplorer.gui.dnd;import java.awt.*;import java.awt.datatransfer.*;import java.awt.dnd.*;import java.awt.event.*;import java.io.IOException;import javaexplorer.Launcher;import javaexplorer.model.*;/** *@author BOESCH Vincent *@created 21 janvier 2002 *@version 3.3 */public class DNDTable extends XTable implements DragSourceListener, DragGestureListener, DropTargetListener { /** * enables this component to be a dropTarget */ DropTarget dropTarget = null; /** * constructor - initializes the DropTarget * and DragSource. * *@param launcher Description of the * Parameter */ public DNDTable(Launcher launcher) { super(launcher); dropTarget = new DropTarget(this, this); //dragSource.createDragGestureRecognizer( MouseRightDragGestureRecognizer.class, this, DnDConstants.ACTION_COPY_OR_MOVE, this); DragGestureRecognizer dgr = getLauncher().getDragSource() .createDragGestureRecognizer(MouseRightDragGestureRecognizer.class, this, DnDConstants.ACTION_COPY_OR_MOVE, this); if (dgr == null) { getLauncher().getDragSource().createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this); } this.addMouseListener(new MouseAdapter() { }); } /** * this message goes to DragSourceListener, * informing it that the dragging has * ended * *@param event Description of the Parameter */ public void dragDropEnd(DragSourceDropEvent event) { } /** * is invoked when you are dragging over * the DropSite * *@param event Description of the Parameter */ public void dragEnter(DropTargetDragEvent event) { event.acceptDrag(DnDConstants.ACTION_MOVE); } /** * this message goes to DragSourceListener, * informing it that the dragging has * entered the DropSite * *@param event Description of the Parameter */ public void dragEnter(DragSourceDragEvent event) { } /** * is invoked when you are exit the DropSite * without dropping * *@param event Description of the Parameter */ public void dragExit(DropTargetEvent event) { } /** * this message goes to DragSourceListener, * informing it that the dragging has * exited the DropSite * *@param event Description of the Parameter */ public void dragExit(DragSourceEvent event) { } /** * a drag gesture has been initiated * *@param event Description of the Parameter */ public void dragGestureRecognized(DragGestureEvent event) { XFile[] efs = null; int[] val = getSelectedRows(); if (val == null) { return; } efs = new XFile[val.length]; for (int i = 0; i < val.length; i++) { efs[i] = (XFile) this.getValueAt(val[i], 0); } XFTransferable xft = new XFTransferable(efs); // as the name suggests, starts the dragging getLauncher().getDragSource().startDrag(event, DragSource.DefaultMoveDrop, xft, this); } /** * is invoked when a drag operation is * going on * *@param event Description of the Parameter */ public void dragOver(DropTargetDragEvent event) { } /** * this message goes to DragSourceListener, * informing it that the dragging is currently * ocurring over the DropSite * *@param event Description of the Parameter */ public void dragOver(DragSourceDragEvent event) { } /** * is invoked when the user changes the * dropAction * *@param event Description of the Parameter */ public void dropActionChanged(DragSourceDragEvent event) { } public void dropActionChanged(DropTargetDragEvent dtde) { } public void drop(DropTargetDropEvent event) { XFile[] tbxf = null; XFile f = null; Point p = null; try { p = event.getLocation(); if (this.getModel().getRowCount() == 0) { f = this.getRoot(); } else { int index = this.rowAtPoint(p); if (index >= 0) { f = (XFile) this.getModel().getValueAt(index, 0); } else { f = this.getRoot(); } } if (f == null) { return; } if (!f.isDirectory()) { f = f.getXParent(); } Transferable transferable = event.getTransferable(); // we accept only Strings if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) { event.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); tbxf = (XFile[]) transferable.getTransferData(DataFlavor.stringFlavor); f.setLauncher(getLauncher()); //Fin du drop pour mise
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -