]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/jface/StringPairLabelProvider.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / jface / StringPairLabelProvider.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 /*
13  * Created on 15.12.2005
14  * 
15  */
16 package org.simantics.utils.ui.jface;
17
18 import java.util.Map;
19
20 import org.eclipse.jface.viewers.ILabelProvider;
21 import org.eclipse.jface.viewers.ILabelProviderListener;
22 import org.eclipse.jface.viewers.ITableLabelProvider;
23 import org.eclipse.swt.graphics.Image;
24
25
26
27 /**
28  * Label provider for Map<String, String>
29  *
30  */
31 public class StringPairLabelProvider implements ITableLabelProvider, ILabelProvider {
32     
33     private final Map<String, String> data;
34     
35     public StringPairLabelProvider(Map<String, String> data) {
36         this.data = data;
37     }
38     
39     public Image getColumnImage(Object element, int columnIndex) {
40         return null;
41     }
42
43     public String getColumnText(Object element, int columnIndex) {
44         if (columnIndex==0) return element.toString();
45         return data.get(element.toString());
46     }
47
48     public void addListener(ILabelProviderListener listener) {
49     }
50
51     public void dispose() {
52     }
53
54     public boolean isLabelProperty(Object element, String property) {
55         return false;
56     }
57
58     public void removeListener(ILabelProviderListener listener) {
59     }
60
61     public Image getImage(Object element) {
62         return null;
63     }
64
65     public String getText(Object element) {
66         return element.toString();
67     }
68 }
69