int insertPosition = source.getInsertPosition();
Object[] guidesI = object.getItems();
if (insertPosition >= 0 && guidesI.length > 0)
{
IGuide currentSelection = GlobalModel.SINGLETON.getSelectedGuide();
int oldSelectionIndex = currentSelection == null
? -1 : model.indexOf(currentSelection);
boolean selectedGuideMoved = false;
// We need to translate insert position into guide set coordinates
if (insertPosition < guidesListModel.getSize())
{
IGuide after = (IGuide)guidesListModel.getElementAt(insertPosition);
insertPosition = model.indexOf(after);
} else if (guidesListModel.getSize() > 0)
{
IGuide before = (IGuide)guidesListModel.getElementAt(insertPosition - 1);
insertPosition = model.indexOf(before) + 1;
} else insertPosition = 0;
// Move selected guides now
int index = insertPosition;
for (int i = 0; i < guidesI.length; i++)
{
IGuide guide = (IGuide)guidesI[guidesI.length - i - 1];
int currentIndex = model.indexOf(guide);
if (currentIndex < index) index--;
selectedGuideMoved |= currentIndex == oldSelectionIndex;