1 11 package org.eclipse.ant.internal.ui.preferences; 12 13 import org.eclipse.ant.core.Property; 14 import org.eclipse.ant.core.Task; 15 import org.eclipse.ant.internal.core.AntObject; 16 import org.eclipse.ant.internal.ui.AntUIImages; 17 import org.eclipse.ant.internal.ui.IAntUIConstants; 18 import org.eclipse.jface.viewers.IColorProvider; 19 import org.eclipse.jface.viewers.ITableLabelProvider; 20 import org.eclipse.jface.viewers.LabelProvider; 21 import org.eclipse.swt.SWT; 22 import org.eclipse.swt.graphics.Color; 23 import org.eclipse.swt.graphics.Image; 24 import org.eclipse.swt.widgets.Display; 25 import org.eclipse.ui.ISharedImages; 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.ide.IDE; 28 29 30 33 public class AntObjectLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider { 34 35 38 public void dispose() { 39 } 40 41 44 public Image getColumnImage(Object element, int columnIndex) { 45 if (columnIndex != 0) { 46 return null; 47 } 48 if (element instanceof Property) { 49 Property prop= (Property) element; 50 if (prop.isDefault() && prop.isEclipseRuntimeRequired()) { 51 return AntUIImages.getImage(IAntUIConstants.IMG_ANT_ECLIPSE_RUNTIME_OBJECT); 52 } 53 return getPropertyImage(); 54 } else if (element instanceof AntObject){ 55 AntObject object= (AntObject) element; 56 if (object.isDefault() && object.isEclipseRuntimeRequired()) { 57 return AntUIImages.getImage(IAntUIConstants.IMG_ANT_ECLIPSE_RUNTIME_OBJECT); 58 } 59 if (element instanceof Task) { 60 return getTaskImage(); 61 } 62 return getTypeImage(); 63 } 64 return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); 65 } 66 67 70 public String getColumnText(Object element, int columnIndex) { 71 if (element instanceof Property) { 72 return getPropertyText((Property) element, columnIndex); 73 } else if (element instanceof AntObject) { 74 AntObject object = (AntObject) element; 75 switch (columnIndex) { 76 case 0: 77 return object.toString(); 78 case 1: 79 return object.getClassName(); 80 case 2: 81 return object.getLibraryEntry().getLabel(); 82 case 3: 83 return object.getPluginLabel(); 84 } 85 } 86 87 return element.toString(); 88 } 89 90 public String getPropertyText(Property property, int columnIndex) { 91 switch (columnIndex) { 92 case 0: 93 return property.getName(); 94 case 1: 95 return property.getValue(false); 96 case 2: 97 if (property.isDefault()) { 98 return property.getPluginLabel(); 99 } 100 } 101 return ""; } 103 104 public static Image getTypeImage() { 105 return AntUIImages.getImage(IAntUIConstants.IMG_ANT_TYPE); 106 } 107 108 public static Image getTaskImage() { 109 return PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJS_TASK_TSK); 110 } 111 112 public static Image getPropertyImage() { 113 return AntUIImages.getImage(IAntUIConstants.IMG_PROPERTY); 114 } 115 116 119 public Color getForeground(Object element) { 120 return null; 121 } 122 123 126 public Color getBackground(Object element) { 127 if (element instanceof AntObject) { 128 if (((AntObject) element).isDefault()) { 129 Display display= Display.getCurrent(); 130 return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); 131 } 132 } else if (element instanceof Property) { 133 if (((Property) element).isDefault()) { 134 Display display= Display.getCurrent(); 135 return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); 136 } 137 } 138 return null; 139 } 140 } | Popular Tags |