Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkDirectoryNode.java

Issue 9704021: Add a top-level node in the Files view to display the SDK libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012, the Dart project authors.
3 *
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
6 *
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
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
11 * or implied. See the License for the specific language governing permissions a nd limitations under
12 * the License.
13 */
14
15 package com.google.dart.tools.ui.internal.filesview;
16
17 import com.google.dart.tools.core.internal.model.SystemLibraryManagerProvider;
18 import com.google.dart.tools.ui.DartToolsPlugin;
19
20 import org.eclipse.core.filesystem.EFS;
21 import org.eclipse.core.runtime.IAdapterFactory;
22 import org.eclipse.core.runtime.Platform;
23 import org.eclipse.jface.resource.ImageDescriptor;
24 import org.eclipse.ui.model.IWorkbenchAdapter;
25 import org.eclipse.ui.model.WorkbenchAdapter;
26
27 import java.io.File;
28 import java.util.ArrayList;
29 import java.util.List;
30
31 /**
32 * A class used to represent the SDK directory.
33 */
34 class SdkDirectoryNode {
35
36 static class SdkDirectoryWorkbenchAdapter extends WorkbenchAdapter implements IAdapterFactory {
37 @SuppressWarnings("rawtypes")
38 @Override
39 public Object getAdapter(Object adaptableObject, Class adapterType) {
40 if (adapterType == IWorkbenchAdapter.class) {
41 return this;
42 } else {
43 return null;
44 }
45 }
46
47 @SuppressWarnings("rawtypes")
48 @Override
49 public Class[] getAdapterList() {
50 return new Class[] {IWorkbenchAdapter.class};
51 }
52
53 @Override
54 public ImageDescriptor getImageDescriptor(Object object) {
55 return DartToolsPlugin.getImageDescriptor("icons/full/dart16/library_conta iner.png");
56 }
57
58 @Override
59 public String getLabel(Object object) {
60 return ((SdkDirectoryNode) object).toString();
61 }
62 }
63
64 public static final SdkDirectoryNode INSTANCE = new SdkDirectoryNode();
65
66 static {
67 Platform.getAdapterManager().registerAdapters(new SdkDirectoryWorkbenchAdapt er(),
68 SdkDirectoryNode.class);
69 }
70
71 private SdkLibraryNode[] libraries;
72
73 public SdkLibraryNode[] getLibraries() {
74 if (libraries == null) {
75 List<SdkLibraryNode> libs = new ArrayList<SdkLibraryNode>();
76
77 File file = SystemLibraryManagerProvider.getSystemLibraryManager().getLibr ariesDir();
78
79 for (File child : file.listFiles()) {
80 if (child.isDirectory()) {
81 libs.add(new SdkLibraryNode(EFS.getLocalFileSystem().fromLocalFile(chi ld)));
82 }
83 }
84
85 libraries = libs.toArray(new SdkLibraryNode[libs.size()]);
86 }
87
88 return libraries;
89 }
90
91 @Override
92 public String toString() {
93 return "SDK Libraries";
94 }
95
96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698