OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.ui.internal.filesview; | 14 package com.google.dart.tools.ui.internal.filesview; |
15 | 15 |
16 import com.google.dart.engine.element.LibraryElement; | |
17 import com.google.dart.engine.source.SourceKind; | |
18 import com.google.dart.tools.core.DartCore; | 16 import com.google.dart.tools.core.DartCore; |
19 import com.google.dart.tools.core.DartCoreDebug; | |
20 import com.google.dart.tools.core.analysis.model.AnalysisEvent; | 17 import com.google.dart.tools.core.analysis.model.AnalysisEvent; |
21 import com.google.dart.tools.core.analysis.model.AnalysisListener; | 18 import com.google.dart.tools.core.analysis.model.AnalysisListener; |
22 import com.google.dart.tools.core.analysis.model.ProjectManager; | |
23 import com.google.dart.tools.core.analysis.model.ResolvedEvent; | 19 import com.google.dart.tools.core.analysis.model.ResolvedEvent; |
24 import com.google.dart.tools.core.analysis.model.ResolvedHtmlEvent; | 20 import com.google.dart.tools.core.analysis.model.ResolvedHtmlEvent; |
25 import com.google.dart.tools.core.internal.builder.AnalysisWorker; | 21 import com.google.dart.tools.core.internal.builder.AnalysisWorker; |
26 import com.google.dart.tools.core.utilities.io.FilenameUtils; | |
27 import com.google.dart.tools.ui.DartToolsPlugin; | 22 import com.google.dart.tools.ui.DartToolsPlugin; |
28 | 23 |
29 import org.eclipse.core.filesystem.IFileStore; | 24 import org.eclipse.core.filesystem.IFileStore; |
30 import org.eclipse.core.resources.IFile; | 25 import org.eclipse.core.resources.IFile; |
31 import org.eclipse.core.resources.IFolder; | 26 import org.eclipse.core.resources.IFolder; |
32 import org.eclipse.core.resources.IResource; | 27 import org.eclipse.core.resources.IResource; |
33 import org.eclipse.core.runtime.CoreException; | 28 import org.eclipse.core.runtime.CoreException; |
34 import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelP
rovider; | 29 import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelP
rovider; |
35 import org.eclipse.jface.viewers.ILabelProvider; | 30 import org.eclipse.jface.viewers.ILabelProvider; |
36 import org.eclipse.jface.viewers.ILabelProviderListener; | 31 import org.eclipse.jface.viewers.ILabelProviderListener; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 108 } |
114 } | 109 } |
115 | 110 |
116 if (resource instanceof IFile) { | 111 if (resource instanceof IFile) { |
117 IFile file = (IFile) resource; | 112 IFile file = (IFile) resource; |
118 | 113 |
119 if (DartCore.isBuildDart(file)) { | 114 if (DartCore.isBuildDart(file)) { |
120 return DartToolsPlugin.getImage(BUILD_FILE_ICON); | 115 return DartToolsPlugin.getImage(BUILD_FILE_ICON); |
121 } | 116 } |
122 | 117 |
123 if (DartCoreDebug.EXPERIMENTAL) { | 118 // TODO(scheglov) disabled because even with tasks it causes short, but
noticeable UI locks |
124 SourceKind kind = DartCore.getProjectManager().getSourceKind(file); | 119 // if (DartCoreDebug.EXPERIMENTAL) { |
125 if (kind == SourceKind.LIBRARY) { | 120 // SourceKind kind = DartCore.getProjectManager().getSourceKind(file); |
126 return DartToolsPlugin.getImage(LIBRARY_ICON); | 121 // if (kind == SourceKind.LIBRARY) { |
127 } | 122 // return DartToolsPlugin.getImage(LIBRARY_ICON); |
128 } | 123 // } |
| 124 // } |
129 } | 125 } |
130 | 126 |
131 if (element instanceof IFolder) { | 127 if (element instanceof IFolder) { |
132 IFolder folder = (IFolder) element; | 128 IFolder folder = (IFolder) element; |
133 | 129 |
134 if (DartCore.isPackagesDirectory(folder)) { | 130 if (DartCore.isPackagesDirectory(folder)) { |
135 return DartToolsPlugin.getImage(PACKAGES_FOLDER_ICON); | 131 return DartToolsPlugin.getImage(PACKAGES_FOLDER_ICON); |
136 } | 132 } |
137 | 133 |
138 if (DartCore.isPackagesResource(folder)) { | 134 if (DartCore.isPackagesResource(folder)) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 String remappingPath = DartCore.getResourceRemapping(file); | 186 String remappingPath = DartCore.getResourceRemapping(file); |
191 | 187 |
192 if (remappingPath != null) { | 188 if (remappingPath != null) { |
193 StyledString str = new StyledString(file.getName()); | 189 StyledString str = new StyledString(file.getName()); |
194 str.append( | 190 str.append( |
195 " [" + getRelativePath(file, remappingPath) + "]", | 191 " [" + getRelativePath(file, remappingPath) + "]", |
196 StyledString.QUALIFIER_STYLER); | 192 StyledString.QUALIFIER_STYLER); |
197 return str; | 193 return str; |
198 } | 194 } |
199 | 195 |
200 // Append the library name to library units. | 196 // TODO(scheglov) disabled because even with tasks it causes short, bu
t noticeable UI locks |
201 ProjectManager projectManager = DartCore.getProjectManager(); | 197 // // Append the library name to library units. |
202 SourceKind kind = projectManager.getSourceKind((IFile) resource); | 198 // ProjectManager projectManager = DartCore.getProjectManager(); |
203 | 199 // SourceKind kind = projectManager.getSourceKind((IFile) resource); |
204 if (kind == SourceKind.LIBRARY) { | 200 // |
205 LibraryElement libraryElement = projectManager.getLibraryElementOrNu
ll((IFile) resource); | 201 // if (kind == SourceKind.LIBRARY) { |
206 | 202 // LibraryElement libraryElement = projectManager.getLibraryElementOr
Null((IFile) resource); |
207 if (libraryElement != null) { | 203 // |
208 String name = libraryElement.getName(); | 204 // if (libraryElement != null) { |
209 | 205 // String name = libraryElement.getName(); |
210 if (name == null || name.length() == 0) { | 206 // |
211 | 207 // if (name == null || name.length() == 0) { |
212 if (libraryElement.getEntryPoint() != null) { | 208 // |
213 name = FilenameUtils.removeExtension(resource.getName()); | 209 // if (libraryElement.getEntryPoint() != null) { |
214 } | 210 // name = FilenameUtils.removeExtension(resource.getName()); |
215 } | 211 // } |
216 | 212 // } |
217 string.append(" [" + name + "]", StyledString.QUALIFIER_STYLER); /
/$NON-NLS-1$ //$NON-NLS-2$ | 213 // |
218 } | 214 // string.append(" [" + name + "]", StyledString.QUALIFIER_STYLER);
//$NON-NLS-1$ //$NON-NLS-2$ |
219 } | 215 // } |
| 216 // } |
220 } | 217 } |
221 } catch (Throwable th) { | 218 } catch (Throwable th) { |
222 DartToolsPlugin.log(th); | 219 DartToolsPlugin.log(th); |
223 } | 220 } |
224 | 221 |
225 return string; | 222 return string; |
226 } | 223 } |
227 | 224 |
228 if (element instanceof DartLibraryNode && ((DartLibraryNode) element).getCat
egory() != null) { | 225 if (element instanceof DartLibraryNode && ((DartLibraryNode) element).getCat
egory() != null) { |
229 StyledString string = new StyledString(((DartLibraryNode) element).getLabe
l()); | 226 StyledString string = new StyledString(((DartLibraryNode) element).getLabe
l()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 306 } |
310 | 307 |
311 private void uiExec(Runnable runnable) { | 308 private void uiExec(Runnable runnable) { |
312 try { | 309 try { |
313 Display.getDefault().asyncExec(runnable); | 310 Display.getDefault().asyncExec(runnable); |
314 } catch (SWTException e) { | 311 } catch (SWTException e) { |
315 // Ignore -- might occur if async events get dispatched after the WS is cl
osed | 312 // Ignore -- might occur if async events get dispatched after the WS is cl
osed |
316 } | 313 } |
317 } | 314 } |
318 } | 315 } |
OLD | NEW |