]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2012 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.jdt.internal.ui.wizards.buildpaths; | |
12 | ||
13 | import org.eclipse.swt.graphics.Image; | |
14 | ||
15 | import org.eclipse.core.runtime.IPath; | |
16 | ||
17 | import org.eclipse.jface.resource.ImageDescriptor; | |
18 | import org.eclipse.jface.viewers.LabelProvider; | |
19 | ||
20 | import org.eclipse.ui.IWorkbench; | |
21 | import org.eclipse.ui.ide.IDE; | |
22 | ||
23 | import org.eclipse.jdt.core.IAccessRule; | |
24 | import org.eclipse.jdt.core.JavaCore; | |
25 | ||
26 | import org.eclipse.jdt.internal.corext.util.Messages; | |
27 | ||
28 | import org.eclipse.jdt.ui.ISharedImages; | |
29 | import org.eclipse.jdt.ui.JavaUI; | |
30 | ||
31 | import org.eclipse.jdt.internal.ui.JavaPlugin; | |
32 | import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels; | |
33 | import org.eclipse.jdt.internal.ui.viewsupport.ImageDescriptorRegistry; | |
34 | import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages; | |
35 | ||
36 | public class CPListLabelProvider extends LabelProvider { | |
37 | ||
38 | String fNewLabel; | |
39 | ||
40 | String fClassLabel; | |
41 | ||
42 | private String fMissing; | |
43 | ||
44 | public ImageDescriptorRegistry fRegistry; | |
45 | public ISharedImages fSharedImages; | |
46 | ||
47 | ImageDescriptor fProjectImage; | |
48 | ||
49 | public ClasspathAttributeConfigurationDescriptors fAttributeDescriptors; | |
50 | ||
51 | ||
52 | public CPListLabelProvider() { | |
53 | fNewLabel= NewWizardMessages.CPListLabelProvider_new; | |
54 | fClassLabel= NewWizardMessages.CPListLabelProvider_classcontainer; | |
55 | fMissing= NewWizardMessages.CPListLabelProvider_missing; | |
56 | fRegistry= JavaPlugin.getImageDescriptorRegistry(); | |
57 | ||
58 | fSharedImages= JavaUI.getSharedImages(); | |
59 | ||
60 | IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); | |
61 | ||
62 | fProjectImage= workbench.getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT); | |
63 | fAttributeDescriptors= JavaPlugin.getDefault().getClasspathAttributeConfigurationDescriptors(); | |
64 | } | |
65 | ||
66 | @Override | |
67 | public String getText(Object element) { | |
68 | if (element instanceof CPListElement) { | |
69 | return getCPListElementText((CPListElement) element); | |
70 | } else if (element instanceof CPListElementAttribute) { | |
71 | CPListElementAttribute attribute= (CPListElementAttribute) element; | |
72 | return attribute.generated_2297199394940351098(this); | |
73 | } else if (element instanceof CPUserLibraryElement) { | |
74 | return getCPUserLibraryText((CPUserLibraryElement) element); | |
75 | } else if (element instanceof IAccessRule) { | |
76 | IAccessRule rule= (IAccessRule) element; | |
77 | return Messages.format(NewWizardMessages.CPListLabelProvider_access_rules_label, new String[] { AccessRulesLabelProvider.getResolutionLabel(rule.getKind()), BasicElementLabels.getPathLabel(rule.getPattern(), false)}); | |
78 | } | |
79 | return super.getText(element); | |
80 | } | |
81 | ||
82 | public String getCPUserLibraryText(CPUserLibraryElement element) { | |
83 | return element.generated_6170624604143659829(); | |
84 | } | |
85 | ||
86 | public String getCPListElementAttributeText(CPListElementAttribute attrib) { | |
87 | String notAvailable= NewWizardMessages.CPListLabelProvider_none; | |
88 | return attrib.generated_2233670715107051429(this, notAvailable); | |
89 | } | |
90 | ||
91 | public String getCPListElementText(CPListElement cpentry) { | |
92 | return cpentry.generated_8488069069699244284(this); | |
93 | } | |
94 | ||
95 | String getPathString(IPath path, boolean isExternal) { | |
96 | if (ArchiveFileFilter.isArchivePath(path, true)) { | |
97 | String appended= BasicElementLabels.getPathLabel(path.removeLastSegments(1), isExternal); | |
98 | String lastSegment= BasicElementLabels.getResourceName(path.lastSegment()); | |
99 | return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { lastSegment, appended }); | |
100 | } else { | |
101 | return BasicElementLabels.getPathLabel(path, isExternal); | |
102 | } | |
103 | } | |
104 | ||
105 | String getVariableString(IPath path) { | |
106 | String name= BasicElementLabels.getPathLabel(path, false); | |
107 | IPath entryPath= JavaCore.getClasspathVariable(path.segment(0)); | |
108 | if (entryPath != null) { | |
109 | String appended= BasicElementLabels.getPathLabel(entryPath.append(path.removeFirstSegments(1)), true); | |
110 | return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { name, appended }); | |
111 | } else { | |
112 | return name; | |
113 | } | |
114 | } | |
115 | ||
116 | public ImageDescriptor getCPListElementBaseImage(CPListElement cpentry) { | |
117 | return cpentry.generated_2372546680956635795(this); | |
118 | } | |
119 | ||
120 | @Override | |
121 | public Image getImage(Object element) { | |
122 | return fRegistry.generated_5429915211795607587(this, element); | |
123 | } | |
124 | } |