KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > nls > ExternalizeStringsLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.nls;
12
13 import org.eclipse.jface.resource.FontRegistry;
14 import org.eclipse.jface.resource.JFaceResources;
15 import org.eclipse.jface.viewers.IFontProvider;
16 import org.eclipse.jface.viewers.ITableLabelProvider;
17 import org.eclipse.jface.viewers.LabelProvider;
18 import org.eclipse.swt.graphics.Font;
19 import org.eclipse.swt.graphics.Image;
20
21 public class ExternalizeStringsLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
22
23     private FontRegistry fFontRegistry;
24     
25     public ExternalizeStringsLabelProvider() {
26         fFontRegistry = JFaceResources.getFontRegistry();
27     }
28
29     public String JavaDoc getColumnText(Object JavaDoc element, int columnIndex) {
30         if (element instanceof ModelChangeElement) {
31             ModelChangeElement changeElement = (ModelChangeElement)element;
32             if (columnIndex == ExternalizeStringsWizardPage.VALUE) {
33                 return StringHelper.unwindEscapeChars(changeElement.getValue());
34             } else if (columnIndex == ExternalizeStringsWizardPage.KEY) {
35                 return StringHelper.unwindEscapeChars(changeElement.getKey());
36             }
37         }
38         return ""; //$NON-NLS-1$
39
}
40
41     public Image getColumnImage(Object JavaDoc element, int columnIndex) {
42         return null;
43     }
44     
45     public Font getFont(Object JavaDoc element) {
46         if (element instanceof ModelChangeElement) {
47             ModelChangeElement changeElement = (ModelChangeElement) element;
48             if (changeElement.isExternalized()) {
49                 return fFontRegistry.getBold(JFaceResources.DIALOG_FONT);
50             }
51         }
52         return null;
53     }
54 }
55
Popular Tags