private void moveSelectedEntryEditor( MoveEntryEditorDirectionEnum direction )
{
StructuredSelection selection = ( StructuredSelection ) entryEditorsTableViewer.getSelection();
if ( selection.size() == 1 )
{
EntryEditorExtension entryEditor = ( EntryEditorExtension ) selection.getFirstElement();
if ( sortedEntryEditorsList.contains( entryEditor ) )
{
int oldIndex = sortedEntryEditorsList.indexOf( entryEditor );
int newIndex = 0;
// Determining the new index number
switch ( direction )
{
case UP:
newIndex = oldIndex - 1;
break;
case DOWN:
newIndex = oldIndex + 1;
break;
}
// Checking bounds
if ( ( newIndex >= 0 ) && ( newIndex < sortedEntryEditorsList.size() ) )
{
// Switching the two entry editors
EntryEditorExtension newIndexEntryEditorBackup = sortedEntryEditorsList.set( newIndex, entryEditor );
sortedEntryEditorsList.set( oldIndex, newIndexEntryEditorBackup );
// Reloading the viewer
entryEditorsTableViewer.refresh();