]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2008 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.viewsupport.BasicElementLabels; | |
23 | import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; | |
24 | ||
25 | public class AccessRulesLabelProvider extends LabelProvider implements ITableLabelProvider { | |
26 | ||
27 | public AccessRulesLabelProvider() { | |
28 | } | |
29 | ||
30 | /* (non-Javadoc) | |
31 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) | |
32 | */ | |
33 | public Image getColumnImage(Object element, int columnIndex) { | |
34 | if (element instanceof IAccessRule) { | |
35 | IAccessRule rule= (IAccessRule) element; | |
36 | if (columnIndex == 0) { | |
37 | return getResolutionImage(rule.getKind()); | |
38 | } | |
39 | } | |
40 | return null; | |
41 | } | |
42 | ||
43 | /* (non-Javadoc) | |
44 | * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) | |
45 | */ | |
46 | public String getColumnText(Object element, int columnIndex) { | |
47 | if (element instanceof IAccessRule) { | |
48 | IAccessRule rule= (IAccessRule) element; | |
49 | if (columnIndex == 0) { | |
50 | return getResolutionLabel(rule.getKind()); | |
51 | } else { | |
52 | return BasicElementLabels.getPathLabel(rule.getPattern(), false); | |
53 | } | |
54 | } | |
55 | return element.toString(); | |
56 | } | |
57 | ||
58 | public static Image getResolutionImage(int kind) { | |
59 | switch (kind) { | |
60 | case IAccessRule.K_ACCESSIBLE: | |
61 | return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_TRANSLATE); | |
62 | case IAccessRule.K_DISCOURAGED: | |
63 | return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_WARNING); | |
64 | case IAccessRule.K_NON_ACCESSIBLE: | |
65 | return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_ERROR); | |
66 | } | |
67 | return null; | |
68 | } | |
69 | ||
70 | ||
71 | public static String getResolutionLabel(int kind) { | |
72 | switch (kind) { | |
73 | case IAccessRule.K_ACCESSIBLE: | |
74 | return NewWizardMessages.AccessRulesLabelProvider_kind_accessible; | |
75 | case IAccessRule.K_DISCOURAGED: | |
76 | return NewWizardMessages.AccessRulesLabelProvider_kind_discouraged; | |
77 | case IAccessRule.K_NON_ACCESSIBLE: | |
78 | return NewWizardMessages.AccessRulesLabelProvider_kind_non_accessible; | |
79 | } | |
80 | return ""; //$NON-NLS-1$ | |
81 | } | |
82 | } |