Fix many DnD errors related to #462
This commit is contained in:
parent
def596a5e8
commit
f006a3a0e6
1 changed files with 18 additions and 3 deletions
|
@ -127,8 +127,11 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TabTransferData getTabTransferData(DropTargetDropEvent a_event) {
|
private TabTransferData getTabTransferData(DropTargetDropEvent a_event) {
|
||||||
|
Transferable t = a_event.getTransferable();
|
||||||
|
if (!t.isDataFlavorSupported(FLAVOR)) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (TabTransferData) a_event.getTransferable().getTransferData(FLAVOR);
|
return (TabTransferData) t.getTransferData(FLAVOR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -137,8 +140,11 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TabTransferData getTabTransferData(DropTargetDragEvent a_event) {
|
private TabTransferData getTabTransferData(DropTargetDragEvent a_event) {
|
||||||
|
Transferable t = a_event.getTransferable();
|
||||||
|
if (!t.isDataFlavorSupported(FLAVOR)) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (TabTransferData) a_event.getTransferable().getTransferData(FLAVOR);
|
return (TabTransferData) t.getTransferData(FLAVOR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -147,8 +153,11 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private TabTransferData getTabTransferData(DragSourceDragEvent a_event) {
|
private TabTransferData getTabTransferData(DragSourceDragEvent a_event) {
|
||||||
|
Transferable t = a_event.getDragSourceContext().getTransferable();
|
||||||
|
if (!t.isDataFlavorSupported(FLAVOR)) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return (TabTransferData) a_event.getDragSourceContext().getTransferable().getTransferData(FLAVOR);
|
return (TabTransferData) t.getTransferData(FLAVOR);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -266,6 +275,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
|
|
||||||
public void dragOver(final DropTargetDragEvent e) {
|
public void dragOver(final DropTargetDragEvent e) {
|
||||||
TabTransferData data = getTabTransferData(e);
|
TabTransferData data = getTabTransferData(e);
|
||||||
|
if (data == null) return;
|
||||||
|
|
||||||
if (getTabPlacement() == JTabbedPane.TOP
|
if (getTabPlacement() == JTabbedPane.TOP
|
||||||
|| getTabPlacement() == JTabbedPane.BOTTOM) {
|
|| getTabPlacement() == JTabbedPane.BOTTOM) {
|
||||||
|
@ -309,6 +319,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
} // if
|
} // if
|
||||||
|
|
||||||
TabTransferData data = getTabTransferData(e);
|
TabTransferData data = getTabTransferData(e);
|
||||||
|
if (data == null) return false;
|
||||||
|
|
||||||
if (DraggableTabbedPane.this == data.getTabbedPane()
|
if (DraggableTabbedPane.this == data.getTabbedPane()
|
||||||
&& data.getTabIndex() >= 0) {
|
&& data.getTabIndex() >= 0) {
|
||||||
|
@ -336,6 +347,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
} // if
|
} // if
|
||||||
|
|
||||||
TabTransferData data = getTabTransferData(e);
|
TabTransferData data = getTabTransferData(e);
|
||||||
|
if (data == null) return false;
|
||||||
|
|
||||||
if (DraggableTabbedPane.this == data.getTabbedPane()
|
if (DraggableTabbedPane.this == data.getTabbedPane()
|
||||||
&& data.getTabIndex() >= 0) {
|
&& data.getTabIndex() >= 0) {
|
||||||
|
@ -403,6 +415,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void convertTab(TabTransferData a_data, int a_targetIndex) {
|
private void convertTab(TabTransferData a_data, int a_targetIndex) {
|
||||||
|
if (a_data == null) return;
|
||||||
DraggableTabbedPane source = a_data.getTabbedPane();
|
DraggableTabbedPane source = a_data.getTabbedPane();
|
||||||
int sourceIndex = a_data.getTabIndex();
|
int sourceIndex = a_data.getTabIndex();
|
||||||
if (sourceIndex < 0) {
|
if (sourceIndex < 0) {
|
||||||
|
@ -459,6 +472,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
m_isDrawRect = false;
|
m_isDrawRect = false;
|
||||||
return;
|
return;
|
||||||
} // if
|
} // if
|
||||||
|
if (a_data == null) return;
|
||||||
|
|
||||||
if ((a_data.getTabbedPane() == this)
|
if ((a_data.getTabbedPane() == this)
|
||||||
&& (a_data.getTabIndex() == next
|
&& (a_data.getTabIndex() == next
|
||||||
|
@ -492,6 +506,7 @@ public class DraggableTabbedPane extends JTabbedPane {
|
||||||
m_isDrawRect = false;
|
m_isDrawRect = false;
|
||||||
return;
|
return;
|
||||||
} // if
|
} // if
|
||||||
|
if (a_data == null) return;
|
||||||
|
|
||||||
if ((a_data.getTabbedPane() == this)
|
if ((a_data.getTabbedPane() == this)
|
||||||
&& (a_data.getTabIndex() == next
|
&& (a_data.getTabIndex() == next
|
||||||
|
|
Loading…
Reference in a new issue