1 11 12 package org.eclipse.jdt.internal.ui.wizards.buildpaths; 13 14 import org.eclipse.swt.graphics.Image; 15 16 import org.eclipse.jface.viewers.ITableLabelProvider; 17 import org.eclipse.jface.viewers.LabelProvider; 18 19 import org.eclipse.jdt.core.IAccessRule; 20 21 import org.eclipse.jdt.internal.ui.JavaPluginImages; 22 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; 23 24 public class AccessRulesLabelProvider extends LabelProvider implements ITableLabelProvider { 25 26 public AccessRulesLabelProvider() { 27 } 28 29 32 public Image getColumnImage(Object element, int columnIndex) { 33 if (element instanceof IAccessRule) { 34 IAccessRule rule= (IAccessRule) element; 35 if (columnIndex == 0) { 36 return getResolutionImage(rule.getKind()); 37 } 38 } 39 return null; 40 } 41 42 45 public String getColumnText(Object element, int columnIndex) { 46 if (element instanceof IAccessRule) { 47 IAccessRule rule= (IAccessRule) element; 48 if (columnIndex == 0) { 49 return getResolutionLabel(rule.getKind()); 50 } else { 51 return rule.getPattern().toString(); 52 } 53 } 54 return element.toString(); 55 } 56 57 public static Image getResolutionImage(int kind) { 58 switch (kind) { 59 case IAccessRule.K_ACCESSIBLE: 60 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_TRANSLATE); 61 case IAccessRule.K_DISCOURAGED: 62 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING); 63 case IAccessRule.K_NON_ACCESSIBLE: 64 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_ERROR); 65 } 66 return null; 67 } 68 69 70 public static String getResolutionLabel(int kind) { 71 switch (kind) { 72 case IAccessRule.K_ACCESSIBLE: 73 return NewWizardMessages.AccessRulesLabelProvider_kind_accessible; 74 case IAccessRule.K_DISCOURAGED: 75 return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged; 76 case IAccessRule.K_NON_ACCESSIBLE: 77 return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible; 78 } 79 return ""; } 81 } 82 | Popular Tags |