38fd25c8eadbfcb8bc1a4f7f7e492eba598fe3dd
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / outline / XMLOutlineLabelProvider.java
1 /*
2  * Copyright (c) 2004 Christopher Lenz and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API and implementation
10  * 
11  * $Id: XMLOutlineLabelProvider.java,v 1.3 2006-10-21 23:14:14 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.ui.internal.outline;
15
16 import net.sourceforge.phpeclipse.xml.core.model.IXMLElement;
17 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
18
19 import org.eclipse.jface.viewers.LabelProvider;
20 import org.eclipse.swt.graphics.Image;
21
22 /**
23  * Label provider for the XML outline page.
24  */
25 public class XMLOutlineLabelProvider extends LabelProvider {
26
27         // LabelProvider Implementation --------------------------------------------
28
29         /**
30          * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
31          */
32         public Image getImage(Object element) {
33                 if (element instanceof IXMLElement) {
34                         return XMLPlugin.getDefault().getImageRegistry().get(
35                                         XMLPlugin.ICON_ELEMENT);
36                 }
37                 return null;
38         }
39
40         /**
41          * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
42          */
43         public String getText(Object element) {
44                 if (element instanceof IXMLElement) {
45                         IXMLElement xmlElement = (IXMLElement) element;
46                         StringBuffer buf = new StringBuffer();
47                         if (xmlElement.getPrefix() != null) {
48                                 buf.append(xmlElement.getPrefix());
49                                 buf.append(':');
50                         }
51                         buf.append(xmlElement.getLocalName());
52                         return buf.toString();
53                 }
54                 return null;
55         }
56
57 }