1 11 package org.eclipse.debug.internal.ui.sourcelookup; 12 13 import java.util.Iterator ; 14 import java.util.List ; 15 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 18 21 public class UpAction extends SourceContainerAction { 22 23 public UpAction() { 24 super(SourceLookupUIMessages.sourceTab_upButton); 25 } 26 31 public void run() { 32 List targets = getOrderedSelection(); 33 if (targets.isEmpty()) { 34 return; 35 } 36 int top = 0; 37 int index = 0; 38 List list = getEntriesAsList(); 39 Iterator entries = targets.iterator(); 40 while (entries.hasNext()) { 41 Object target = entries.next(); 42 index = list.indexOf(target); 43 if (index > top) { 44 top = index - 1; 45 Object temp = list.get(top); 46 list.set(top, target); 47 list.set(index, temp); 48 } 49 top = index; 50 } 51 setEntries(list); 52 } 53 54 57 protected boolean updateSelection(IStructuredSelection selection) { 58 return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null; 60 } 61 62 } 63 | Popular Tags |