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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkLibraryNode.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkDirectoryNode.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkLibraryNode.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkLibraryNode.java (revision 0)
+++ editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkLibraryNode.java (revision 0)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2012, the Dart project authors.
+ *
+ * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.dart.tools.ui.internal.filesview;
+
+import com.google.dart.tools.ui.DartPluginImages;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.WorkbenchAdapter;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A representation of a sdk library (e.g. dart:core, dart:io, ...).
+ */
+class SdkLibraryNode {
+
+ static class SdkLibraryWorkbenchAdapter extends WorkbenchAdapter implements IAdapterFactory {
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == IWorkbenchAdapter.class) {
+ return this;
+ } else {
+ return null;
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class[] getAdapterList() {
+ return new Class[] {IWorkbenchAdapter.class};
+ }
+
+ @Override
+ public ImageDescriptor getImageDescriptor(Object object) {
+ return DartPluginImages.DESC_DART_LIB_FILE;
+ }
+
+ @Override
+ public String getLabel(Object object) {
+ return ((SdkLibraryNode) object).toString();
+ }
+ }
+
+ static {
+ Platform.getAdapterManager().registerAdapters(new SdkLibraryWorkbenchAdapter(),
+ SdkLibraryNode.class);
+ }
+
+ private IFileStore root;
+
+ public SdkLibraryNode(IFileStore root) {
+ this.root = root;
+ }
+
+ public IFileStore[] getFiles() {
+ try {
+ List<IFileStore> members = filteredMembers(root);
+
+ return members.toArray(new IFileStore[members.size()]);
+ } catch (CoreException e) {
+ return new IFileStore[0];
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "dart:" + root.getName();
+ }
+
+ private List<IFileStore> filteredMembers(IFileStore file) throws CoreException {
+ List<IFileStore> children = new ArrayList<IFileStore>();
+
+ for (IFileStore child : file.childStores(EFS.NONE, new NullProgressMonitor())) {
+ String name = child.getName();
+ if (!(name.startsWith("."))) {
+ children.add(child);
+ }
+ }
+
+ return children;
+ }
+
+}
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/ui/internal/filesview/SdkDirectoryNode.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698