1 11 package org.eclipse.ui.views.navigator; 12 13 import org.eclipse.ui.PlatformUI; 14 import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; 15 16 20 public class SortViewAction extends ResourceNavigatorAction { 21 private int sortCriteria; 22 23 29 public SortViewAction(IResourceNavigator navigator, boolean sortByType) { 30 super( 31 navigator, 32 sortByType ? ResourceNavigatorMessages.SortView_byType : ResourceNavigatorMessages.SortView_byName); 33 if (sortByType) { 34 setToolTipText(ResourceNavigatorMessages.SortView_toolTipByType); 35 } else { 36 setToolTipText(ResourceNavigatorMessages.SortView_toolTipByName); 37 } 38 setEnabled(true); 39 sortCriteria = sortByType ? ResourceComparator.TYPE : ResourceComparator.NAME; 40 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 41 INavigatorHelpContextIds.SORT_VIEW_ACTION); 42 } 43 44 public void run() { 45 IResourceNavigator navigator = getNavigator(); 46 ResourceComparator comparator = navigator.getComparator(); 47 48 if (comparator == null) { 49 navigator.setComparator(new ResourceComparator(sortCriteria)); 50 } else { 51 comparator.setCriteria(sortCriteria); 52 navigator.setComparator(comparator); 53 } 54 55 } 56 } 57 | Popular Tags |