KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > wizards > buildpaths > AccessRulesLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 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
12 package org.eclipse.jdt.internal.ui.wizards.buildpaths;
13
14 import org.eclipse.swt.graphics.Image;
15
16 import org.eclipse.jface.viewers.ITableLabelProvider;
17 import org.eclipse.jface.viewers.LabelProvider;
18
19 import org.eclipse.jdt.core.IAccessRule;
20
21 import org.eclipse.jdt.internal.ui.JavaPluginImages;
22 import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
23
24 public class AccessRulesLabelProvider extends LabelProvider implements ITableLabelProvider {
25     
26     public AccessRulesLabelProvider() {
27     }
28
29     /* (non-Javadoc)
30      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
31      */

32     public Image getColumnImage(Object JavaDoc element, int columnIndex) {
33         if (element instanceof IAccessRule) {
34             IAccessRule rule= (IAccessRule) element;
35             if (columnIndex == 0) {
36                 return getResolutionImage(rule.getKind());
37             }
38         }
39         return null;
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
44      */

45     public String JavaDoc getColumnText(Object JavaDoc element, int columnIndex) {
46         if (element instanceof IAccessRule) {
47             IAccessRule rule= (IAccessRule) element;
48             if (columnIndex == 0) {
49                 return getResolutionLabel(rule.getKind());
50             } else {
51                 return rule.getPattern().toString();
52             }
53         }
54         return element.toString();
55     }
56     
57     public static Image getResolutionImage(int kind) {
58         switch (kind) {
59             case IAccessRule.K_ACCESSIBLE:
60                 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_TRANSLATE);
61             case IAccessRule.K_DISCOURAGED:
62                 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING);
63             case IAccessRule.K_NON_ACCESSIBLE:
64                 return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_ERROR);
65         }
66         return null;
67     }
68     
69     
70     public static String JavaDoc getResolutionLabel(int kind) {
71         switch (kind) {
72             case IAccessRule.K_ACCESSIBLE:
73                 return NewWizardMessages.AccessRulesLabelProvider_kind_accessible;
74             case IAccessRule.K_DISCOURAGED:
75                 return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged;
76             case IAccessRule.K_NON_ACCESSIBLE:
77                 return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible;
78         }
79         return ""; //$NON-NLS-1$
80
}
81 }
82
Popular Tags