1 11 12 package org.eclipse.ui.internal.intro.impl.model.viewer; 13 14 import org.eclipse.jface.viewers.LabelProvider; 15 import org.eclipse.swt.graphics.Image; 16 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroElement; 17 import org.eclipse.ui.internal.intro.impl.model.AbstractIntroPage; 18 import org.eclipse.ui.internal.intro.impl.model.IntroContentProvider; 19 import org.eclipse.ui.internal.intro.impl.model.IntroExtensionContent; 20 import org.eclipse.ui.internal.intro.impl.model.IntroGroup; 21 import org.eclipse.ui.internal.intro.impl.model.IntroHTML; 22 import org.eclipse.ui.internal.intro.impl.model.IntroImage; 23 import org.eclipse.ui.internal.intro.impl.model.IntroInclude; 24 import org.eclipse.ui.internal.intro.impl.model.IntroLink; 25 import org.eclipse.ui.internal.intro.impl.model.IntroPartPresentation; 26 import org.eclipse.ui.internal.intro.impl.model.IntroSeparator; 27 import org.eclipse.ui.internal.intro.impl.model.IntroText; 28 import org.eclipse.ui.internal.intro.impl.util.ImageUtil; 29 30 public class IntroModelLabelProvider extends LabelProvider { 31 32 34 static { 35 ImageUtil.registerImage(ImageUtil.INTRO_MODEL_CONTAINER, 36 "container_obj.gif"); ImageUtil.registerImage(ImageUtil.INTRO_MODEL_LEAF, "topic.gif"); } 39 40 public IntroModelLabelProvider() { 41 super(); 42 } 43 44 public Image getImage(Object element) { 45 Image image = null; 46 AbstractIntroElement introElement = null; 47 if (element instanceof AbstractIntroElement) 48 introElement = (AbstractIntroElement) element; 50 if (introElement == null) 51 return null; 52 53 int elementType = introElement.getType(); 54 switch (elementType) { 55 case AbstractIntroElement.GROUP: 56 case AbstractIntroElement.PAGE: 57 case AbstractIntroElement.HOME_PAGE: 58 image = ImageUtil.getImage(ImageUtil.INTRO_MODEL_CONTAINER); 59 break; 60 default: 61 image = ImageUtil.getImage(ImageUtil.INTRO_MODEL_LEAF); 62 break; 63 } 64 return image; 65 } 66 67 public String getText(Object element) { 68 69 String label = null; 70 AbstractIntroElement introElement = null; 71 if (element instanceof AbstractIntroElement) 72 introElement = (AbstractIntroElement) element; 74 if (introElement == null) 75 return null; 76 77 int elementType = introElement.getType(); 78 switch (elementType) { 79 case AbstractIntroElement.GROUP: 80 label = "GROUP: " + ((IntroGroup) introElement).getLabel(); break; 82 case AbstractIntroElement.LINK: 83 label = "LINK: " + ((IntroLink) introElement).getLabel(); break; 85 case AbstractIntroElement.TEXT: 86 label = "TEXT: " + ((IntroText) introElement).getText(); break; 88 case AbstractIntroElement.IMAGE: 89 label = "IMAGE: " + ((IntroImage) introElement).getId(); break; 91 case AbstractIntroElement.HR: 92 label = "HR: " + ((IntroSeparator) introElement).getId(); break; 94 case AbstractIntroElement.HTML: 95 label = "HTML: " + ((IntroHTML) introElement).getId(); break; 97 case AbstractIntroElement.INCLUDE: 98 label = "Unresolved INCLUDE: " + ((IntroInclude) introElement).getPath(); 100 break; 101 case AbstractIntroElement.PAGE: 102 label = "PAGE: " + ((AbstractIntroPage) introElement).getId(); break; 104 case AbstractIntroElement.HOME_PAGE: 105 label = "HOME PAGE: " + ((AbstractIntroPage) introElement).getTitle(); 107 break; 108 case AbstractIntroElement.PRESENTATION: 109 label = "PRESENTATION: " + ((IntroPartPresentation) introElement) 111 .getImplementationKind(); 112 break; 113 case AbstractIntroElement.CONTENT_PROVIDER: 114 label = "CONTENT PROVIDER: " + ((IntroContentProvider) introElement).getClassName(); 116 break; 117 case AbstractIntroElement.CONTAINER_EXTENSION: 118 label = "Unresolved ConfigExtension: " + ((IntroExtensionContent) introElement).getPath(); 120 break; 121 default: 122 label = super.getText(element); 123 break; 124 } 125 return label; 126 } 127 128 } 129 | Popular Tags |