1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import java.util.List ; 14 15 import org.eclipse.jface.viewers.IStructuredSelection; 16 17 21 public class DownAction extends SourceContainerAction { 22 23 public DownAction() { 24 super(SourceLookupUIMessages.sourceTab_downButton); 25 } 26 29 public void run() { 30 List targets = getOrderedSelection(); 31 if (targets.isEmpty()) { 32 return; 33 } 34 List list = getEntriesAsList(); 35 int bottom = list.size() - 1; 36 int index = 0; 37 for (int i = targets.size() - 1; i >= 0; i--) { 38 Object target = targets.get(i); 39 index = list.indexOf(target); 40 if (index < bottom) { 41 bottom = index + 1; 42 Object temp = list.get(bottom); 43 list.set(bottom, target); 44 list.set(index, temp); 45 } 46 bottom = index; 47 } 48 setEntries(list); 49 } 50 51 54 protected boolean updateSelection(IStructuredSelection selection) { 55 return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) && getViewer().getTree().getSelection()[0].getParentItem()==null; 56 } 57 58 } 59 | Popular Tags |