int index = ((Integer) tr.getTransferData(flavors[1])).intValue();
Action separator = DefaultToolBarModel.getInstance().getSeparatorAction();
Action glue = DefaultToolBarModel.getInstance().getGlueAction();
Action space = DefaultToolBarModel.getInstance().getSpaceAction();
JComponent target = (JComponent) ((DropTarget) e.getSource())
.getComponent();
if (target.equals(mButtonPanel)) {
if (index == -1 && !separator.getValue(Action.NAME).equals(name)
&& !glue.getValue(Action.NAME).equals(name)
&& !space.getValue(Action.NAME).equals(name)) {
for (Action a : mCurrentActions) {
if (a.getValue(Action.NAME).equals(name)) {
mCurrentActions.removeElement(a);
mAvailableActions.addElement(a);
break;
}
}
} else if (index != -1) {
Action a = mCurrentActions.elementAt(index);
mCurrentActions.removeElementAt(index);
if (!separator.getValue(Action.NAME).equals(name)
&& !glue.getValue(Action.NAME).equals(name)
&& !space.getValue(Action.NAME).equals(name)
) {
mAvailableActions.addElement(a);
}
}
saveSettings();
} else if (target.equals(MainFrame.getInstance().getToolbar())
|| ((DropTarget) e.getSource()).getComponent().equals(
MainFrame.getInstance().getToolBarPanel())) {
Point location = e.getLocation();
if (mWest) {
location.setLocation(10, location.y);
} else {
location.setLocation(location.x, MainFrame.getInstance().getToolbar()
.getHeight() / 2);
}
JComponent c = (JComponent) MainFrame.getInstance().getToolbar()
.getComponentAt(location);
if ((c == null || c instanceof JToolBar) && MainFrame.getInstance().getToolbar().getComponentCount() > 0) {
c = (JComponent) MainFrame.getInstance().getToolbar().getComponent(
MainFrame.getInstance().getToolbar().getComponentCount() - 1);
if (c != null) {
location.setLocation(c.getLocation().x + c.getWidth() - 1, c
.getLocation().y
+ c.getHeight() - 1);
}
}
int n = 0;
if (c != null) {
Point p = SwingUtilities.convertPoint(MainFrame.getInstance().getToolBarPanel(), location, c);
n = MainFrame.getInstance().getToolbar().getComponentIndex(c);
if (!((mWest && (p.y < c.getHeight() / 2)) || (!mWest && (p.x < c
.getWidth() / 2)))) {
n++;
}
}