|
|
@ -19,15 +19,18 @@ import java.awt.dnd.DragGestureEvent; |
|
|
|
import java.awt.dnd.DragGestureListener; |
|
|
|
import java.awt.dnd.DragGestureListener; |
|
|
|
import java.awt.dnd.DragSource; |
|
|
|
import java.awt.dnd.DragSource; |
|
|
|
import java.awt.dnd.DragSourceAdapter; |
|
|
|
import java.awt.dnd.DragSourceAdapter; |
|
|
|
import java.awt.dnd.DragSourceDragEvent; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseListener; |
|
|
|
import java.awt.event.MouseMotionListener; |
|
|
|
import java.awt.event.MouseMotionListener; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.Serializable; |
|
|
|
import java.io.Serializable; |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/** |
|
|
|
*august: 控件按钮 |
|
|
|
* 控件按钮 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @author august |
|
|
|
|
|
|
|
* @since 7.0 |
|
|
|
|
|
|
|
* Created on 2008 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class ToolBarButton extends UIButton implements MouseListener, MouseMotionListener, Serializable { |
|
|
|
public class ToolBarButton extends UIButton implements MouseListener, MouseMotionListener, Serializable { |
|
|
|
|
|
|
|
|
|
|
@ -46,25 +49,36 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio |
|
|
|
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); |
|
|
|
new DragAndDropDragGestureListener(this, DnDConstants.ACTION_COPY_OR_MOVE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取控件配置 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return 控件配置 |
|
|
|
|
|
|
|
*/ |
|
|
|
public WidgetOption getNameOption() { |
|
|
|
public WidgetOption getNameOption() { |
|
|
|
return this.no; |
|
|
|
return this.no; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 设置控件配置 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param no 控件配置 |
|
|
|
|
|
|
|
*/ |
|
|
|
public void setNameOption(WidgetOption no) { |
|
|
|
public void setNameOption(WidgetOption no) { |
|
|
|
this.no = no; |
|
|
|
this.no = no; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
if (e.getClickCount() >= 2) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
lastPressEvent = e; |
|
|
|
lastPressEvent = e; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,7 +119,10 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class DragAndDropDragGestureListener extends DragSourceAdapter implements DragGestureListener { |
|
|
|
/** |
|
|
|
|
|
|
|
* 拖放拖动手势侦听器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static class DragAndDropDragGestureListener extends DragSourceAdapter implements DragGestureListener { |
|
|
|
private DragSource source; |
|
|
|
private DragSource source; |
|
|
|
|
|
|
|
|
|
|
|
public DragAndDropDragGestureListener(ToolBarButton tt, int actions) { |
|
|
|
public DragAndDropDragGestureListener(ToolBarButton tt, int actions) { |
|
|
@ -113,6 +130,7 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio |
|
|
|
source.createDefaultDragGestureRecognizer(tt, actions, this); |
|
|
|
source.createDefaultDragGestureRecognizer(tt, actions, this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void dragGestureRecognized(DragGestureEvent dge) { |
|
|
|
public void dragGestureRecognized(DragGestureEvent dge) { |
|
|
|
ToolBarButton toolBarButton = (ToolBarButton) dge.getComponent(); |
|
|
|
ToolBarButton toolBarButton = (ToolBarButton) dge.getComponent(); |
|
|
|
if (toolBarButton != null) { |
|
|
|
if (toolBarButton != null) { |
|
|
@ -122,13 +140,12 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void dragEnter(DragSourceDragEvent dragSourceDragEvent) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class DragAndDropTransferable implements Transferable { |
|
|
|
/** |
|
|
|
|
|
|
|
* 拖放转换器 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static class DragAndDropTransferable implements Transferable { |
|
|
|
private Widget widget; |
|
|
|
private Widget widget; |
|
|
|
|
|
|
|
|
|
|
|
public DragAndDropTransferable(Widget widget) { |
|
|
|
public DragAndDropTransferable(Widget widget) { |
|
|
@ -137,10 +154,12 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio |
|
|
|
|
|
|
|
|
|
|
|
DataFlavor[] flavors = {new DataFlavor(Widget.class, "Widget")}; |
|
|
|
DataFlavor[] flavors = {new DataFlavor(Widget.class, "Widget")}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public DataFlavor[] getTransferDataFlavors() { |
|
|
|
public DataFlavor[] getTransferDataFlavors() { |
|
|
|
return flavors; |
|
|
|
return flavors; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) { |
|
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) { |
|
|
|
for (DataFlavor df : flavors) { |
|
|
|
for (DataFlavor df : flavors) { |
|
|
|
if (ComparatorUtils.equals(df, flavor)) { |
|
|
|
if (ComparatorUtils.equals(df, flavor)) { |
|
|
|