1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import java.util.List ; 15 16 import org.eclipse.jdt.internal.debug.ui.launcher.IClasspathViewer; 17 import org.eclipse.jface.viewers.IStructuredSelection; 18 19 22 public class MoveDownAction extends RuntimeClasspathAction { 23 24 public MoveDownAction(IClasspathViewer viewer) { 25 super(ActionMessages.MoveDownAction_M_ove_Down_1, viewer); 26 } 27 30 public void run() { 31 List targets = getOrderedSelection(); 32 if (targets.isEmpty()) { 33 return; 34 } 35 List list = getEntriesAsList(); 36 int bottom = list.size() - 1; 37 int index = 0; 38 for (int i = targets.size() - 1; i >= 0; i--) { 39 Object target = targets.get(i); 40 index = list.indexOf(target); 41 if (index < bottom) { 42 bottom = index + 1; 43 Object temp = list.get(bottom); 44 list.set(bottom, target); 45 list.set(index, temp); 46 } 47 bottom = index; 48 } 49 setEntries(list); 50 } 51 52 55 protected boolean updateSelection(IStructuredSelection selection) { 56 if (selection.isEmpty()) { 57 return false; 58 } 59 return getViewer().updateSelection(getActionType(), selection) && !isIndexSelected(selection, getEntriesAsList().size() - 1); 60 } 61 62 protected int getActionType() { 63 return MOVE; 64 } 65 } 66 | Popular Tags |